agent-tower 0.5.2-beta.4 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +37 -7
- package/dist/cli.js.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/routes/system.d.ts.map +1 -1
- package/dist/routes/system.js +9 -0
- package/dist/routes/system.js.map +1 -1
- package/dist/services/mcp-config.service.d.ts +6 -0
- package/dist/services/mcp-config.service.d.ts.map +1 -0
- package/dist/services/mcp-config.service.js +47 -0
- package/dist/services/mcp-config.service.js.map +1 -0
- package/dist/services/mcp-config.service.test.d.ts +2 -0
- package/dist/services/mcp-config.service.test.d.ts.map +1 -0
- package/dist/services/mcp-config.service.test.js +42 -0
- package/dist/services/mcp-config.service.test.js.map +1 -0
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +7 -1
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/utils/data-dir.d.ts +3 -0
- package/dist/utils/data-dir.d.ts.map +1 -0
- package/dist/utils/data-dir.js +10 -0
- package/dist/utils/data-dir.js.map +1 -0
- package/dist/utils/process-launch.d.ts +1 -0
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +17 -4
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +17 -1
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BIMA7LtG.js → AgentDemoPage-DAdN5g19.js} +1 -1
- package/dist/web/assets/{DemoPage-Ck0jATn9.js → DemoPage-Xc4QRNUj.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-C5KUTpFg.js → GeneralSettingsPage-DWKl6BHA.js} +1 -1
- package/dist/web/assets/McpSettingsPage-BHEMUq7Z.js +1 -0
- package/dist/web/assets/{MemberAvatar-CKkPlE4w.js → MemberAvatar-b_WKLu8w.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-C2KeYegv.js +1 -0
- package/dist/web/assets/{ProfileSettingsPage-D_YQBJqm.js → ProfileSettingsPage-CVOCVwVK.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-J_5GxZQ7.js +90 -0
- package/dist/web/assets/ProjectSettingsPage-CP3V8oAJ.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-BbruFhJJ.js → ProviderSettingsPage-DQ_IDUUZ.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-zGxTmEVL.js → SettingsMasterDetail-Cx9Ylq9N.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-B3dBegBu.js → TeamSettingsPage-BHE2x82g.js} +1 -1
- package/dist/web/assets/arc-D31VhUJX.js +1 -0
- package/dist/web/assets/architectureDiagram-3BPJPVTR-Ak9jpJ8q.js +36 -0
- package/dist/web/assets/{arrow-left-DTTqavaj.js → arrow-left-DcUokonk.js} +1 -1
- package/dist/web/assets/blockDiagram-GPEHLZMM-DEDpa_4t.js +132 -0
- package/dist/web/assets/c4Diagram-AAUBKEIU-BgS3ci_x.js +10 -0
- package/dist/web/assets/channel-BLjA9Brq.js +1 -0
- package/dist/web/assets/check-DyTLNLlk.js +1 -0
- package/dist/web/assets/{chevron-down-CXD7aP1s.js → chevron-down-DuDzRplH.js} +1 -1
- package/dist/web/assets/{chevron-right-DSp9sZpx.js → chevron-right-BezhysME.js} +1 -1
- package/dist/web/assets/{chevron-up-DAXQrjEz.js → chevron-up-DtQ85g91.js} +1 -1
- package/dist/web/assets/chunk-2J33WTMH-BnpAjP2E.js +1 -0
- package/dist/web/assets/chunk-4BX2VUAB-DNUdFpBR.js +1 -0
- package/dist/web/assets/chunk-55IACEB6-CTj6ihx_.js +1 -0
- package/dist/web/assets/chunk-727SXJPM-yKiHVB7X.js +206 -0
- package/dist/web/assets/chunk-AQP2D5EJ-njbMVjqc.js +231 -0
- package/dist/web/assets/chunk-FMBD7UC4-h0jEUL75.js +15 -0
- package/dist/web/assets/chunk-ND2GUHAM-DjMFJZNr.js +1 -0
- package/dist/web/assets/chunk-QZHKN3VN-odAhWIp4.js +1 -0
- package/dist/web/assets/circle-alert-IhLKVEi9.js +1 -0
- package/dist/web/assets/classDiagram-4FO5ZUOK-DHqakOiv.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DHqakOiv.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-Cwwrn6vr.js → code-block-OCS4YCEC-4ofbxqu2.js} +1 -1
- package/dist/web/assets/{confirm-dialog-DnHo_qsz.js → confirm-dialog-Amksh2QM.js} +1 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-Ds62_zKQ.js +1 -0
- package/dist/web/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
- package/dist/web/assets/dagre-BM42HDAG-De9CyhMh.js +4 -0
- package/dist/web/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/web/assets/diagram-2AECGRRQ-Db7DRtzA.js +43 -0
- package/dist/web/assets/diagram-5GNKFQAL-DXeGI1-M.js +10 -0
- package/dist/web/assets/diagram-KO2AKTUF-Llle6qEC.js +3 -0
- package/dist/web/assets/diagram-LMA3HP47-BcK1LGRh.js +24 -0
- package/dist/web/assets/diagram-OG6HWLK6-0_sJ3YRD.js +24 -0
- package/dist/web/assets/erDiagram-TEJ5UH35-BjT0k23c.js +85 -0
- package/dist/web/assets/flowDiagram-I6XJVG4X-kaKS6P_m.js +162 -0
- package/dist/web/assets/folder-picker-CbAfVBHD.js +1 -0
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CW8IoCY6.js +292 -0
- package/dist/web/assets/gitGraphDiagram-PVQCEYII-C5-QVJMh.js +106 -0
- package/dist/web/assets/graph--OzhPTMs.js +1 -0
- package/dist/web/assets/{index-X6FFd4Oy.js → index-Bd5HU-dB.js} +9 -9
- package/dist/web/assets/index-Du7RXa9t.js +303 -0
- package/dist/web/assets/index-LbQD7FZK.css +1 -0
- package/dist/web/assets/infoDiagram-5YYISTIA-CG7QnPme.js +2 -0
- package/dist/web/assets/init-Gi6I4Gst.js +1 -0
- package/dist/web/assets/{input-CWSScfQB.js → input-BxcpVmsb.js} +1 -1
- package/dist/web/assets/ishikawaDiagram-YF4QCWOH-DitLiYai.js +70 -0
- package/dist/web/assets/journeyDiagram-JHISSGLW-EKXFhiai.js +139 -0
- package/dist/web/assets/kanban-definition-UN3LZRKU-Ckbr1P9R.js +89 -0
- package/dist/web/assets/katex-HP8lGamR.js +257 -0
- package/dist/web/assets/{layers-DMovMRW4.js → layers-Dqjek9Kd.js} +1 -1
- package/dist/web/assets/layout-SsrduOYp.js +1 -0
- package/dist/web/assets/linear-HA2k3O-l.js +1 -0
- package/dist/web/assets/loader-circle-B4v8mirO.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-CmO9pIR-.js → mermaid-NOHMQCX5-C2N-Y-YP.js} +5 -5
- package/dist/web/assets/{message-square-tazyMedo.js → message-square-B-2bz9LU.js} +1 -1
- package/dist/web/assets/mindmap-definition-RKZ34NQL-ByCTUtXz.js +96 -0
- package/dist/web/assets/{modal-D9LZcnXe.js → modal-C6m1dmin.js} +1 -1
- package/dist/web/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/web/assets/{pencil-Cfcl8xtO.js → pencil-DzjmtIoi.js} +1 -1
- package/dist/web/assets/pieDiagram-4H26LBE5-DeQnXQoJ.js +30 -0
- package/dist/web/assets/quadrantDiagram-W4KKPZXB--ocdxSbH.js +7 -0
- package/dist/web/assets/requirementDiagram-4Y6WPE33-CJq21gDX.js +84 -0
- package/dist/web/assets/{rotate-ccw-BCxAIasK.js → rotate-ccw-BhUVdZv6.js} +1 -1
- package/dist/web/assets/sankeyDiagram-5OEKKPKP-U373GNMv.js +40 -0
- package/dist/web/assets/{select-wCJbdjbF.js → select-CCf5nwYs.js} +1 -1
- package/dist/web/assets/sequenceDiagram-3UESZ5HK-BuH8el8s.js +162 -0
- package/dist/web/assets/stateDiagram-AJRCARHV-CqZ_L1ch.js +1 -0
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DkD_6IX-.js +1 -0
- package/dist/web/assets/{switch-BpVaaZIq.js → switch-DsjSr4nv.js} +1 -1
- package/dist/web/assets/terminal-JXRig8oL.js +1 -0
- package/dist/web/assets/{textarea-CqAqQ-DJ.js → textarea-BzeEPT1A.js} +1 -1
- package/dist/web/assets/timeline-definition-PNZ67QCA-BIrIbCOG.js +120 -0
- package/dist/web/assets/{upload-Doc6mqhw.js → upload-BwkqnAVE.js} +1 -1
- package/dist/web/assets/{use-profiles-CLbwBXdL.js → use-profiles-DcyUHq0p.js} +1 -1
- package/dist/web/assets/{use-providers-C8Rfahov.js → use-providers-BWgjPVX8.js} +1 -1
- package/dist/web/assets/vennDiagram-CIIHVFJN-Dmk1mluX.js +34 -0
- package/dist/web/assets/wardley-L42UT6IY-CEY4M7Op.js +161 -0
- package/dist/web/assets/wardleyDiagram-YWT4CUSO-CiK-Q213.js +78 -0
- package/dist/web/assets/xychartDiagram-2RQKCTM6-C5rj3Hpu.js +7 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +16 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
- package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
- package/package.json +3 -3
- package/dist/web/assets/NotificationSettingsPage-Dl2nJ6Kj.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-D2_609qP.js +0 -89
- package/dist/web/assets/ProjectSettingsPage-DpewUnnG.js +0 -2
- package/dist/web/assets/check-N8co_7vS.js +0 -1
- package/dist/web/assets/folder-picker-TUuS8jPV.js +0 -1
- package/dist/web/assets/index-JZcaQb4r.css +0 -1
- package/dist/web/assets/loader-circle-CvnvXNY6.js +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import{U as en,V as qn,W as Hc,Y as Wc,Z as $c,_ as Ii,$ as Uc,a0 as qc,k as at,a1 as Kc,a2 as Xc,r as y,a3 as Vc,a4 as Yc,a5 as Gc,a6 as Qc,a7 as Kn,a8 as Xn,a9 as Zc,aa as Jc,ab as ed,h as pe,ac as ce,P as Zt,i as Nt,l as wt,m as xe,q as ae,u as le,j as t,T as mt,X as Wt,g as Z,B as Me,ad as va,ae as xa,af as ba,ag as cs,ah as td,s as _a,ai as sd,aj as rd,ak as id,t as ut,E as Qt,F as ct,G as xs,al as ya,am as tn,an as Bi,v as nd,L as Vn,ao as Sa,R as Yn,ap as sn,aq as wa,ar as Ca,as as ka,at as od,au as ad,av as ld,aw as cd,ax as dd,H as Gn,ay as Qn}from"./index-X6FFd4Oy.js";import{S as it,W as lt,a as Mt,C as Us,A as Ht,T as zt}from"./log-adapter-CtvxzS4j.js";import{C as Fr}from"./confirm-dialog-DnHo_qsz.js";import{f as Ea,c as ja,d as Na,b as Ra,h as Ta,S as ws,A as Zn,P as zr,Q as rn,s as nn,G as Aa,u as Ma,a as Da,e as Sr,T as wr}from"./mermaid-NOHMQCX5-CmO9pIR-.js";import{C as ht}from"./chevron-down-CXD7aP1s.js";import{C as Ot}from"./chevron-right-DSp9sZpx.js";import{b as ud,a as La,F as hd,g as fd,h as md,f as pd,u as gd}from"./folder-picker-TUuS8jPV.js";import{L as Cs}from"./layers-DMovMRW4.js";import{L as ze}from"./loader-circle-CvnvXNY6.js";import{M as Lt}from"./MemberAvatar-CKkPlE4w.js";import{C as Pa}from"./chevron-up-DAXQrjEz.js";import{C as yt}from"./check-N8co_7vS.js";import{M as Es,P as Ut,a as Hr,T as on}from"./modal-D9LZcnXe.js";import{S as as}from"./select-wCJbdjbF.js";import{u as js}from"./use-providers-C8Rfahov.js";import{M as an}from"./message-square-tazyMedo.js";import{U as Fi,C as vd}from"./upload-Doc6mqhw.js";import{A as qs}from"./arrow-left-DTTqavaj.js";import{R as xd}from"./rotate-ccw-BCxAIasK.js";var bd=class extends en{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:qn()})}getOptimisticResult(e){return e.behavior=qn(),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:m,isRefetching:p,isError:g,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=g&&i==="forward",u=m&&i==="forward",c=g&&i==="backward",v=m&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Wc(s,r.data),hasPreviousPage:Hc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:v,isRefetchError:n&&!l&&!c,isRefetching:p&&!u&&!v}}};function Jn(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function _d(e,s,r){const o=e.slice(0);return o[s]=r,o}var yd=class extends $c{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Ii.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const m=o.map(u=>u.observer),p=m.map(u=>u.getCurrentResult()),g=r.length!==m.length,n=m.some((u,c)=>u!==r[c]),i=g||n,l=i?!0:p.some((u,c)=>{const v=this.#e[c];return!v||!Uc(u,v)});!i&&!l||(i&&(this.#c=o,this.#t=m),this.#e=p,this.hasListeners()&&(i&&(Jn(r,m).forEach(u=>{u.destroy()}),Jn(m,r).forEach(u=>{u.subscribe(c=>{this.#f(u,c)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),o=r.map(p=>p.observer.getOptimisticResult(p.defaultedQueryOptions)),m=r.map(p=>p.defaultedQueryOptions.queryHash);return[o,p=>this.#u(p??o,s,m),()=>this.#d(o,r)]}#d(e,s){return s.map((r,o)=>{const m=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{s.forEach(g=>{g.observer.trackProp(p)})})})}#u(e,s,r){if(s){const o=this.#l,m=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((p,g)=>p!==o[g]));return(!this.#s||this.#e!==this.#a||m||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=qc(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(o=>{const m=o.options.queryHash;if(!m)return;const p=s.get(m);p?p.push(o):s.set(m,[o])});const r=[];return e.forEach(o=>{const m=this.#r.defaultQueryOptions(o),g=s.get(m.queryHash)?.shift()??new en(this.#r,m);r.push({defaultedQueryOptions:m,observer:g})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=_d(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Ii.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Sd({queries:e,...s},r){const o=at(),m=Kc(),p=Xc(),g=y.useMemo(()=>e.map(x=>{const a=o.defaultQueryOptions(x);return a._optimisticResults=m?"isRestoring":"optimistic",a}),[e,o,m]);g.forEach(x=>{Vc(x);const a=o.getQueryCache().get(x.queryHash);Yc(x,p,a)}),Gc(p);const[n]=y.useState(()=>new yd(o,g,s)),[i,l,u]=n.getOptimisticResult(g,s.combine),c=!m&&s.subscribed!==!1;y.useSyncExternalStore(y.useCallback(x=>c?n.subscribe(Ii.batchCalls(x)):Qc,[n,c]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),y.useEffect(()=>{n.setQueries(g,s)},[g,s,n]);const b=i.some((x,a)=>Kn(g[a],x))?i.flatMap((x,a)=>{const f=g[a];if(f){const d=new en(o,f);if(Kn(f,x))return Xn(f,d,p);Zc(x,m)&&Xn(f,d,p)}return[]}):[];if(b.length>0)throw Promise.all(b);const S=i.find((x,a)=>{const f=g[a];return f&&Jc({result:x,errorResetBoundary:p,throwOnError:f.throwOnError,query:o.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return l(u())}function ln(e,s){return ed(e,bd)}const wd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ks=pe("arrow-down",wd);const Cd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],kd=pe("arrow-right",Cd);const Ed=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wr=pe("arrow-up",Ed);const jd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oa=pe("ban",jd);const Nd=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Rd=pe("bot",Nd);const Td=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ad=pe("chevron-left",Td);const Md=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],bs=pe("clock-3",Md);const Dd=[["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"}]],Qs=pe("code-xml",Dd);const Ld=[["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"}]],eo=pe("copy-plus",Ld);const Pd=[["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"}]],to=pe("copy",Pd);const Od=[["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"}]],Ia=pe("ellipsis-vertical",Od);const Id=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],cn=pe("external-link",Id);const Bd=[["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"}]],Fd=pe("file-braces-corner",Bd);const zd=[["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"}]],Cr=pe("file-code-corner",zd);const Hd=[["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"}]],Wd=pe("file-exclamation-point",Hd);const $d=[["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:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],dn=pe("file-text",$d);const Ud=[["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"}]],$r=pe("folder-open",Ud);const qd=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Kd=pe("gauge",qd);const Xd=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],un=pe("git-branch",Xd);const Vd=[["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"}]],Zs=pe("git-graph",Vd);const Yd=[["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"}]],ks=pe("history",Yd);const Gd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],hn=pe("image",Gd);const Qd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zd=pe("info",Qd);const Jd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],eu=pe("lock-keyhole",Jd);const tu=[["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"}]],su=pe("maximize",tu);const ru=[["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=pe("panel-left-close",ru);const nu=[["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"}]],ou=pe("panel-left-open",nu);const au=[["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"}]],lu=pe("panel-right-close",au);const cu=[["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"}]],kr=pe("panel-right-open",cu);const du=[["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"}]],uu=pe("pen-line",du);const hu=[["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"}]],qt=pe("play",hu);const fu=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ur=pe("refresh-cw",fu);const mu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],pu=pe("save",mu);const gu=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],fn=pe("search",gu);const vu=[["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"}]],Ba=pe("settings-2",vu);const xu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Fa=pe("shield",xu);const bu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],so=pe("smartphone",bu);const _u=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],yu=pe("square-pen",_u);const Su=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Er=pe("terminal",Su);const wu=[["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"}]],ur=pe("user-plus",wu);const Cu=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],za=pe("zap",Cu);const ku=[["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"}]],Eu=pe("zoom-in",ku);const ju=[["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"}]],Nu=pe("zoom-out",ju),qr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ns(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function mn(e){return"nodeType"in e}function St(e){var s,r;return e?Ns(e)?e:mn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function pn(e){const{Document:s}=St(e);return e instanceof s}function Js(e){return Ns(e)?!1:e instanceof St(e).HTMLElement}function Ha(e){return e instanceof St(e).SVGElement}function Rs(e){return e?Ns(e)?e.document:mn(e)?pn(e)?e:Js(e)||Ha(e)?e.ownerDocument:document:document:document}const Kt=qr?y.useLayoutEffect:y.useEffect;function Kr(e){const s=y.useRef(e);return Kt(()=>{s.current=e}),y.useCallback(function(){for(var r=arguments.length,o=new Array(r),m=0;m<r;m++)o[m]=arguments[m];return s.current==null?void 0:s.current(...o)},[])}function Ru(){const e=y.useRef(null),s=y.useCallback((o,m)=>{e.current=setInterval(o,m)},[]),r=y.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Xs(e,s){s===void 0&&(s=[e]);const r=y.useRef(e);return Kt(()=>{r.current!==e&&(r.current=e)},s),r}function er(e,s){const r=y.useRef();return y.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function jr(e){const s=Kr(e),r=y.useRef(null),o=y.useCallback(m=>{m!==r.current&&s?.(m,r.current),r.current=m},[]);return[r,o]}function Nr(e){const s=y.useRef();return y.useEffect(()=>{s.current=e},[e]),s.current}let pi={};function Xr(e,s){return y.useMemo(()=>{if(s)return s;const r=pi[e]==null?0:pi[e]+1;return pi[e]=r,e+"-"+r},[e,s])}function Wa(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),m=1;m<r;m++)o[m-1]=arguments[m];return o.reduce((p,g)=>{const n=Object.entries(g);for(const[i,l]of n){const u=p[i];u!=null&&(p[i]=u+e*l)}return p},{...s})}}const Ss=Wa(1),Rr=Wa(-1);function Tu(e){return"clientX"in e&&"clientY"in e}function gn(e){if(!e)return!1;const{KeyboardEvent:s}=St(e.target);return s&&e instanceof s}function Au(e){if(!e)return!1;const{TouchEvent:s}=St(e.target);return s&&e instanceof s}function Tr(e){if(Au(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 Tu(e)?{x:e.clientX,y:e.clientY}:null}const Vs=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[Vs.Translate.toString(e),Vs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),ro="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Mu(e){return e.matches(ro)?e:e.querySelector(ro)}const Du={display:"none"};function Lu(e){let{id:s,value:r}=e;return ce.createElement("div",{id:s,style:Du},r)}function Pu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const m={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 ce.createElement("div",{id:s,style:m,role:"status","aria-live":o,"aria-atomic":!0},r)}function Ou(){const[e,s]=y.useState("");return{announce:y.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const $a=y.createContext(null);function Iu(e){const s=y.useContext($a);y.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Bu(){const[e]=y.useState(()=>new Set),s=y.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[y.useCallback(o=>{let{type:m,event:p}=o;e.forEach(g=>{var n;return(n=g[m])==null?void 0:n.call(g,p)})},[e]),s]}const Fu={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},zu={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 Hu(e){let{announcements:s=zu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:m=Fu}=e;const{announce:p,announcement:g}=Ou(),n=Xr("DndLiveRegion"),[i,l]=y.useState(!1);if(y.useEffect(()=>{l(!0)},[]),Iu(y.useMemo(()=>({onDragStart(c){let{active:v}=c;p(s.onDragStart({active:v}))},onDragMove(c){let{active:v,over:b}=c;s.onDragMove&&p(s.onDragMove({active:v,over:b}))},onDragOver(c){let{active:v,over:b}=c;p(s.onDragOver({active:v,over:b}))},onDragEnd(c){let{active:v,over:b}=c;p(s.onDragEnd({active:v,over:b}))},onDragCancel(c){let{active:v,over:b}=c;p(s.onDragCancel({active:v,over:b}))}}),[p,s])),!i)return null;const u=ce.createElement(ce.Fragment,null,ce.createElement(Lu,{id:o,value:m.draggable}),ce.createElement(Pu,{id:n,announcement:g}));return r?Zt.createPortal(u,r):u}var ot;(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"})(ot||(ot={}));function Ar(){}function Wu(e,s){return y.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function $u(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return y.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const It=Object.freeze({x:0,y:0});function Uu(e,s){const r=Tr(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 qu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Ku(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Xu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),m=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),g=m-o,n=p-r;if(o<m&&r<p){const i=s.width*s.height,l=e.width*e.height,u=g*n,c=u/(i+l-u);return Number(c.toFixed(4))}return 0}const Vu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const m=[];for(const p of o){const{id:g}=p,n=r.get(g);if(n){const i=Xu(n,s);i>0&&m.push({id:g,data:{droppableContainer:p,value:i}})}}return m.sort(qu)};function Yu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ua(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:It}function Gu(e){return function(r){for(var o=arguments.length,m=new Array(o>1?o-1:0),p=1;p<o;p++)m[p-1]=arguments[p];return m.reduce((g,n)=>({...g,top:g.top+e*n.y,bottom:g.bottom+e*n.y,left:g.left+e*n.x,right:g.right+e*n.x}),{...r})}}const Qu=Gu(1);function qa(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 Zu(e,s,r){const o=qa(s);if(!o)return e;const{scaleX:m,scaleY:p,x:g,y:n}=o,i=e.left-g-(1-m)*parseFloat(r),l=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),u=m?e.width/m:e.width,c=p?e.height/p:e.height;return{width:u,height:c,top:l,right:i+u,bottom:l+c,left:i}}const Ju={ignoreTransform:!1};function tr(e,s){s===void 0&&(s=Ju);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=St(e).getComputedStyle(e);l&&(r=Zu(r,l,u))}const{top:o,left:m,width:p,height:g,bottom:n,right:i}=r;return{top:o,left:m,width:p,height:g,bottom:n,right:i}}function io(e){return tr(e,{ignoreTransform:!0})}function eh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function th(e,s){return s===void 0&&(s=St(e).getComputedStyle(e)),s.position==="fixed"}function sh(e,s){s===void 0&&(s=St(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=s[m];return typeof p=="string"?r.test(p):!1})}function vn(e,s){const r=[];function o(m){if(s!=null&&r.length>=s||!m)return r;if(pn(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!Js(m)||Ha(m)||r.includes(m))return r;const p=St(e).getComputedStyle(m);return m!==e&&sh(m,p)&&r.push(m),th(m,p)?r:o(m.parentNode)}return e?o(e):r}function Ka(e){const[s]=vn(e,1);return s??null}function gi(e){return!qr||!e?null:Ns(e)?e:mn(e)?pn(e)||e===Rs(e).scrollingElement?window:Js(e)?e:null:null}function Xa(e){return Ns(e)?e.scrollX:e.scrollLeft}function Va(e){return Ns(e)?e.scrollY:e.scrollTop}function zi(e){return{x:Xa(e),y:Va(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function Ya(e){return!qr||!e?!1:e===document.scrollingElement}function Ga(e){const s={x:0,y:0},r=Ya(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},m=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,g=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:m,isLeft:p,isBottom:g,isRight:n,maxScroll:o,minScroll:s}}const rh={x:.2,y:.2};function ih(e,s,r,o,m){let{top:p,left:g,right:n,bottom:i}=r;o===void 0&&(o=10),m===void 0&&(m=rh);const{isTop:l,isBottom:u,isLeft:c,isRight:v}=Ga(e),b={x:0,y:0},S={x:0,y:0},x={height:s.height*m.y,width:s.width*m.x};return!l&&p<=s.top+x.height?(b.y=dt.Backward,S.y=o*Math.abs((s.top+x.height-p)/x.height)):!u&&i>=s.bottom-x.height&&(b.y=dt.Forward,S.y=o*Math.abs((s.bottom-x.height-i)/x.height)),!v&&n>=s.right-x.width?(b.x=dt.Forward,S.x=o*Math.abs((s.right-x.width-n)/x.width)):!c&&g<=s.left+x.width&&(b.x=dt.Backward,S.x=o*Math.abs((s.left+x.width-g)/x.width)),{direction:b,speed:S}}function nh(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:g}=window;return{top:0,left:0,right:p,bottom:g,width:p,height:g}}const{top:s,left:r,right:o,bottom:m}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:m,width:e.clientWidth,height:e.clientHeight}}function Qa(e){return e.reduce((s,r)=>Ss(s,zi(r)),It)}function oh(e){return e.reduce((s,r)=>s+Xa(r),0)}function ah(e){return e.reduce((s,r)=>s+Va(r),0)}function Za(e,s){if(s===void 0&&(s=tr),!e)return;const{top:r,left:o,bottom:m,right:p}=s(e);Ka(e)&&(m<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const lh=[["x",["left","right"],oh],["y",["top","bottom"],ah]];class xn{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=vn(r),m=Qa(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,g,n]of lh)for(const i of g)Object.defineProperty(this,i,{get:()=>{const l=n(o),u=m[p]-l;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class zs{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 m;(m=this.target)==null||m.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function ch(e){const{EventTarget:s}=St(e);return e instanceof s?e:Rs(e)}function vi(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 At;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(At||(At={}));function no(e){e.preventDefault()}function dh(e){e.stopPropagation()}var We;(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"})(We||(We={}));const Ja={start:[We.Space,We.Enter],cancel:[We.Esc],end:[We.Space,We.Enter,We.Tab]},uh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case We.Right:return{...r,x:r.x+25};case We.Left:return{...r,x:r.x-25};case We.Down:return{...r,y:r.y+25};case We.Up:return{...r,y:r.y-25}}};class el{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 zs(Rs(r)),this.windowListeners=new zs(St(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(At.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Za(o),r(It)}handleKeyDown(s){if(gn(s)){const{active:r,context:o,options:m}=this.props,{keyboardCodes:p=Ja,coordinateGetter:g=uh,scrollBehavior:n="smooth"}=m,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,u=l?{x:l.left,y:l.top}:It;this.referenceCoordinates||(this.referenceCoordinates=u);const c=g(s,{active:r,context:o.current,currentCoordinates:u});if(c){const v=Rr(c,u),b={x:0,y:0},{scrollableAncestors:S}=o.current;for(const x of S){const a=s.code,{isTop:f,isRight:d,isLeft:h,isBottom:_,maxScroll:w,minScroll:k}=Ga(x),j=nh(x),C={x:Math.min(a===We.Right?j.right-j.width/2:j.right,Math.max(a===We.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===We.Down?j.bottom-j.height/2:j.bottom,Math.max(a===We.Down?j.top:j.top+j.height/2,c.y))},E=a===We.Right&&!d||a===We.Left&&!h,N=a===We.Down&&!_||a===We.Up&&!f;if(E&&C.x!==c.x){const D=x.scrollLeft+v.x,A=a===We.Right&&D<=w.x||a===We.Left&&D>=k.x;if(A&&!v.y){x.scrollTo({left:D,behavior:n});return}A?b.x=x.scrollLeft-D:b.x=a===We.Right?x.scrollLeft-w.x:x.scrollLeft-k.x,b.x&&x.scrollBy({left:-b.x,behavior:n});break}else if(N&&C.y!==c.y){const D=x.scrollTop+v.y,A=a===We.Down&&D<=w.y||a===We.Up&&D>=k.y;if(A&&!v.x){x.scrollTo({top:D,behavior:n});return}A?b.y=x.scrollTop-D:b.y=a===We.Down?x.scrollTop-w.y:x.scrollTop-k.y,b.y&&x.scrollBy({top:-b.y,behavior:n});break}}this.handleMove(s,Ss(Rr(c,this.referenceCoordinates),b))}}}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()}}el.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Ja,onActivation:m}=s,{active:p}=r;const{code:g}=e.nativeEvent;if(o.start.includes(g)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function oo(e){return!!(e&&"distance"in e)}function ao(e){return!!(e&&"delay"in e)}class bn{constructor(s,r,o){var m;o===void 0&&(o=ch(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:p}=s,{target:g}=p;this.props=s,this.events=r,this.document=Rs(g),this.documentListeners=new zs(this.document),this.listeners=new zs(o),this.windowListeners=new zs(St(g)),this.initialCoordinates=(m=Tr(p))!=null?m:It,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(At.Resize,this.handleCancel),this.windowListeners.add(At.DragStart,no),this.windowListeners.add(At.VisibilityChange,this.handleCancel),this.windowListeners.add(At.ContextMenu,no),this.documentListeners.add(At.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ao(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(oo(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:m}=this.props;m(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(At.Click,dh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(At.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:m,props:p}=this,{onMove:g,options:{activationConstraint:n}}=p;if(!m)return;const i=(r=Tr(s))!=null?r:It,l=Rr(m,i);if(!o&&n){if(oo(n)){if(n.tolerance!=null&&vi(l,n.tolerance))return this.handleCancel();if(vi(l,n.distance))return this.handleStart()}if(ao(n)&&vi(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),g(i)}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===We.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const hh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _n extends bn{constructor(s){const{event:r}=s,o=Rs(r.target);super(s,hh,o)}}_n.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 fh={move:{name:"mousemove"},end:{name:"mouseup"}};var Hi;(function(e){e[e.RightClick=2]="RightClick"})(Hi||(Hi={}));class mh extends bn{constructor(s){super(s,fh,Rs(s.event.target))}}mh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Hi.RightClick?!1:(o?.({event:r}),!0)}}];const xi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ph extends bn{constructor(s){super(s,xi)}static setup(){return window.addEventListener(xi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(xi.move.name,s)};function s(){}}}ph.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:m}=r;return m.length>1?!1:(o?.({event:r}),!0)}}];var Hs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hs||(Hs={}));var Mr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Mr||(Mr={}));function gh(e){let{acceleration:s,activator:r=Hs.Pointer,canScroll:o,draggingRect:m,enabled:p,interval:g=5,order:n=Mr.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:v}=e;const b=xh({delta:c,disabled:!p}),[S,x]=Ru(),a=y.useRef({x:0,y:0}),f=y.useRef({x:0,y:0}),d=y.useMemo(()=>{switch(r){case Hs.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Hs.DraggableRect:return m}},[r,m,i]),h=y.useRef(null),_=y.useCallback(()=>{const k=h.current;if(!k)return;const j=a.current.x*f.current.x,C=a.current.y*f.current.y;k.scrollBy(j,C)},[]),w=y.useMemo(()=>n===Mr.TreeOrder?[...l].reverse():l,[n,l]);y.useEffect(()=>{if(!p||!l.length||!d){x();return}for(const k of w){if(o?.(k)===!1)continue;const j=l.indexOf(k),C=u[j];if(!C)continue;const{direction:E,speed:N}=ih(k,C,d,s,v);for(const D of["x","y"])b[D][E[D]]||(N[D]=0,E[D]=0);if(N.x>0||N.y>0){x(),h.current=k,S(_,g),a.current=N,f.current=E;return}}a.current={x:0,y:0},f.current={x:0,y:0},x()},[s,_,o,x,p,g,JSON.stringify(d),JSON.stringify(b),S,l,w,u,JSON.stringify(v)])}const vh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function xh(e){let{delta:s,disabled:r}=e;const o=Nr(s);return er(m=>{if(r||!o||!m)return vh;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[dt.Backward]:m.x[dt.Backward]||p.x===-1,[dt.Forward]:m.x[dt.Forward]||p.x===1},y:{[dt.Backward]:m.y[dt.Backward]||p.y===-1,[dt.Forward]:m.y[dt.Forward]||p.y===1}}},[r,s,o])}function bh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return er(m=>{var p;return s==null?null:(p=o??m)!=null?p:null},[o,s])}function _h(e,s){return y.useMemo(()=>e.reduce((r,o)=>{const{sensor:m}=o,p=m.activators.map(g=>({eventName:g.eventName,handler:s(g.handler,o)}));return[...r,...p]},[]),[e,s])}var Ys;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ys||(Ys={}));var Wi;(function(e){e.Optimized="optimized"})(Wi||(Wi={}));const lo=new Map;function yh(e,s){let{dragging:r,dependencies:o,config:m}=s;const[p,g]=y.useState(null),{frequency:n,measure:i,strategy:l}=m,u=y.useRef(e),c=a(),v=Xs(c),b=y.useCallback(function(f){f===void 0&&(f=[]),!v.current&&g(d=>d===null?f:d.concat(f.filter(h=>!d.includes(h))))},[v]),S=y.useRef(null),x=er(f=>{if(c&&!r)return lo;if(!f||f===lo||u.current!==e||p!=null){const d=new Map;for(let h of e){if(!h)continue;if(p&&p.length>0&&!p.includes(h.id)&&h.rect.current){d.set(h.id,h.rect.current);continue}const _=h.node.current,w=_?new xn(i(_),_):null;h.rect.current=w,w&&d.set(h.id,w)}return d}return f},[e,p,r,c,i]);return y.useEffect(()=>{u.current=e},[e]),y.useEffect(()=>{c||b()},[r,c]),y.useEffect(()=>{p&&p.length>0&&g(null)},[JSON.stringify(p)]),y.useEffect(()=>{c||typeof n!="number"||S.current!==null||(S.current=setTimeout(()=>{b(),S.current=null},n))},[n,c,b,...o]),{droppableRects:x,measureDroppableContainers:b,measuringScheduled:p!=null};function a(){switch(l){case Ys.Always:return!1;case Ys.BeforeDragging:return r;default:return!r}}}function yn(e,s){return er(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Sh(e,s){return yn(e,s)}function wh(e){let{callback:s,disabled:r}=e;const o=Kr(s),m=y.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return y.useEffect(()=>()=>m?.disconnect(),[m]),m}function Vr(e){let{callback:s,disabled:r}=e;const o=Kr(s),m=y.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return y.useEffect(()=>()=>m?.disconnect(),[m]),m}function Ch(e){return new xn(tr(e),e)}function co(e,s,r){s===void 0&&(s=Ch);const[o,m]=y.useState(null);function p(){m(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const u=s(e);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const g=wh({callback(i){if(e)for(const l of i){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){p();break}}}}),n=Vr({callback:p});return Kt(()=>{p(),e?(n?.observe(e),g?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),g?.disconnect())},[e]),o}function kh(e){const s=yn(e);return Ua(e,s)}const uo=[];function Eh(e){const s=y.useRef(e),r=er(o=>e?o&&o!==uo&&e&&s.current&&e.parentNode===s.current.parentNode?o:vn(e):uo,[e]);return y.useEffect(()=>{s.current=e},[e]),r}function jh(e){const[s,r]=y.useState(null),o=y.useRef(e),m=y.useCallback(p=>{const g=gi(p.target);g&&r(n=>n?(n.set(g,zi(g)),new Map(n)):null)},[]);return y.useEffect(()=>{const p=o.current;if(e!==p){g(p);const n=e.map(i=>{const l=gi(i);return l?(l.addEventListener("scroll",m,{passive:!0}),[l,zi(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{g(e),g(p)};function g(n){n.forEach(i=>{const l=gi(i);l?.removeEventListener("scroll",m)})}},[m,e]),y.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,g)=>Ss(p,g),It):Qa(e):It,[e,s])}function ho(e,s){s===void 0&&(s=[]);const r=y.useRef(null);return y.useEffect(()=>{r.current=null},s),y.useEffect(()=>{const o=e!==It;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Rr(e,r.current):It}function Nh(e){y.useEffect(()=>{if(!qr)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 Rh(e,s){return y.useMemo(()=>e.reduce((r,o)=>{let{eventName:m,handler:p}=o;return r[m]=g=>{p(g,s)},r},{}),[e,s])}function tl(e){return y.useMemo(()=>e?eh(e):null,[e])}const fo=[];function Th(e,s){s===void 0&&(s=tr);const[r]=e,o=tl(r?St(r):null),[m,p]=y.useState(fo);function g(){p(()=>e.length?e.map(i=>Ya(i)?o:new xn(s(i),i)):fo)}const n=Vr({callback:g});return Kt(()=>{n?.disconnect(),g(),e.forEach(i=>n?.observe(i))},[e]),m}function sl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Js(s)?s:e}function Ah(e){let{measure:s}=e;const[r,o]=y.useState(null),m=y.useCallback(l=>{for(const{target:u}of l)if(Js(u)){o(c=>{const v=s(u);return c?{...c,width:v.width,height:v.height}:v});break}},[s]),p=Vr({callback:m}),g=y.useCallback(l=>{const u=sl(l);p?.disconnect(),u&&p?.observe(u),o(u?s(u):null)},[s,p]),[n,i]=jr(g);return y.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const Mh=[{sensor:_n,options:{}},{sensor:el,options:{}}],Dh={current:{}},_r={draggable:{measure:io},droppable:{measure:io,strategy:Ys.WhileDragging,frequency:Wi.Optimized},dragOverlay:{measure:tr}};class Ws 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 Lh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ws,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ar},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:_r,measureDroppableContainers:Ar,windowRect:null,measuringScheduled:!1},rl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ar,draggableNodes:new Map,over:null,measureDroppableContainers:Ar},sr=y.createContext(rl),il=y.createContext(Lh);function Ph(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ws}}}function Oh(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.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 ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,m=new Ws(e.droppable.containers);return m.set(o,r),{...e,droppable:{...e.droppable,containers:m}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:m}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const g=new Ws(e.droppable.containers);return g.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:g}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const p=new Ws(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function Ih(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:m}=y.useContext(sr),p=Nr(o),g=Nr(r?.id);return y.useEffect(()=>{if(!s&&!o&&p&&g!=null){if(!gn(p)||document.activeElement===p.target)return;const n=m.get(g);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[i.current,l.current]){if(!u)continue;const c=Mu(u);if(c){c.focus();break}}})}},[o,s,m,g,p]),null}function nl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...o}),r):r}function Bh(e){return y.useMemo(()=>({draggable:{..._r.draggable,...e?.draggable},droppable:{..._r.droppable,...e?.droppable},dragOverlay:{..._r.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Fh(e){let{activeNode:s,measure:r,initialRect:o,config:m=!0}=e;const p=y.useRef(!1),{x:g,y:n}=typeof m=="boolean"?{x:m,y:m}:m;Kt(()=>{if(!g&&!n||!s){p.current=!1;return}if(p.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=Ua(u,o);if(g||(c.x=0),n||(c.y=0),p.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const v=Ka(l);v&&v.scrollBy({top:c.y,left:c.x})}},[s,g,n,o,r])}const Yr=y.createContext({...It,scaleX:1,scaleY:1});var Gt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Gt||(Gt={}));const zh=y.memo(function(s){var r,o,m,p;let{id:g,accessibility:n,autoScroll:i=!0,children:l,sensors:u=Mh,collisionDetection:c=Vu,measuring:v,modifiers:b,...S}=s;const x=y.useReducer(Oh,void 0,Ph),[a,f]=x,[d,h]=Bu(),[_,w]=y.useState(Gt.Uninitialized),k=_===Gt.Initialized,{draggable:{active:j,nodes:C,translate:E},droppable:{containers:N}}=a,D=j!=null?C.get(j):null,A=y.useRef({initial:null,translated:null}),M=y.useMemo(()=>{var me;return j!=null?{id:j,data:(me=D?.data)!=null?me:Dh,rect:A}:null},[j,D]),I=y.useRef(null),[L,F]=y.useState(null),[H,T]=y.useState(null),O=Xs(S,Object.values(S)),P=Xr("DndDescribedBy",g),B=y.useMemo(()=>N.getEnabled(),[N]),$=Bh(v),{droppableRects:X,measureDroppableContainers:U,measuringScheduled:K}=yh(B,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),W=bh(C,j),R=y.useMemo(()=>H?Tr(H):null,[H]),z=tt(),V=Sh(W,$.draggable.measure);Fh({activeNode:j!=null?C.get(j):null,config:z.layoutShiftCompensation,initialRect:V,measure:$.draggable.measure});const q=co(W,$.draggable.measure,V),se=co(W?W.parentElement:null),Q=y.useRef({activatorEvent:null,active:null,activeNode:W,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ee=N.getNodeFor((r=Q.current.over)==null?void 0:r.id),be=Ah({measure:$.dragOverlay.measure}),Ce=(o=be.nodeRef.current)!=null?o:W,Oe=k?(m=be.rect)!=null?m:q:null,de=!!(be.nodeRef.current&&be.rect),Ke=kh(de?null:q),fe=tl(Ce?St(Ce):null),ge=Eh(k?ee??W:null),$e=Th(ge),et=nl(b,{transform:{x:E.x-Ke.x,y:E.y-Ke.y,scaleX:1,scaleY:1},activatorEvent:H,active:M,activeNodeRect:q,containerNodeRect:se,draggingNodeRect:Oe,over:Q.current.over,overlayNodeRect:be.rect,scrollableAncestors:ge,scrollableAncestorRects:$e,windowRect:fe}),De=R?Ss(R,E):null,re=jh(ge),ye=ho(re),je=ho(re,[q]),Le=Ss(et,ye),Ae=Oe?Qu(Oe,et):null,Se=M&&Ae?c({active:M,collisionRect:Ae,droppableRects:X,droppableContainers:B,pointerCoordinates:De}):null,ke=Ku(Se,"id"),[Ne,G]=y.useState(null),oe=de?et:Ss(et,je),we=Yu(oe,(p=Ne?.rect)!=null?p:null,q),Y=y.useRef(null),te=y.useCallback((me,Xe)=>{let{sensor:He,options:nt}=Xe;if(I.current==null)return;const Pe=C.get(I.current);if(!Pe)return;const Te=me.nativeEvent,Ve=new He({active:I.current,activeNode:Pe,event:Te,options:nt,context:Q,onAbort(st){if(!C.get(st))return;const{onDragAbort:gt}=O.current,vt={id:st};gt?.(vt),d({type:"onDragAbort",event:vt})},onPending(st,pt,gt,vt){if(!C.get(st))return;const{onDragPending:Bt}=O.current,xt={id:st,constraint:pt,initialCoordinates:gt,offset:vt};Bt?.(xt),d({type:"onDragPending",event:xt})},onStart(st){const pt=I.current;if(pt==null)return;const gt=C.get(pt);if(!gt)return;const{onDragStart:vt}=O.current,Ye={activatorEvent:Te,active:{id:pt,data:gt.data,rect:A}};Zt.unstable_batchedUpdates(()=>{vt?.(Ye),w(Gt.Initializing),f({type:ot.DragStart,initialCoordinates:st,active:pt}),d({type:"onDragStart",event:Ye}),F(Y.current),T(Te)})},onMove(st){f({type:ot.DragMove,coordinates:st})},onEnd:Ze(ot.DragEnd),onCancel:Ze(ot.DragCancel)});Y.current=Ve;function Ze(st){return async function(){const{active:gt,collisions:vt,over:Ye,scrollAdjustedTranslate:Bt}=Q.current;let xt=null;if(gt&&Bt){const{cancelDrop:Rt}=O.current;xt={activatorEvent:Te,active:gt,collisions:vt,delta:Bt,over:Ye},st===ot.DragEnd&&typeof Rt=="function"&&await Promise.resolve(Rt(xt))&&(st=ot.DragCancel)}I.current=null,Zt.unstable_batchedUpdates(()=>{f({type:st}),w(Gt.Uninitialized),G(null),F(null),T(null),Y.current=null;const Rt=st===ot.DragEnd?"onDragEnd":"onDragCancel";if(xt){const is=O.current[Rt];is?.(xt),d({type:Rt,event:xt})}})}}},[C]),ie=y.useCallback((me,Xe)=>(He,nt)=>{const Pe=He.nativeEvent,Te=C.get(nt);if(I.current!==null||!Te||Pe.dndKit||Pe.defaultPrevented)return;const Ve={active:Te};me(He,Xe.options,Ve)===!0&&(Pe.dndKit={capturedBy:Xe.sensor},I.current=nt,te(He,Xe))},[C,te]),he=_h(u,ie);Nh(u),Kt(()=>{q&&_===Gt.Initializing&&w(Gt.Initialized)},[q,_]),y.useEffect(()=>{const{onDragMove:me}=O.current,{active:Xe,activatorEvent:He,collisions:nt,over:Pe}=Q.current;if(!Xe||!He)return;const Te={active:Xe,activatorEvent:He,collisions:nt,delta:{x:Le.x,y:Le.y},over:Pe};Zt.unstable_batchedUpdates(()=>{me?.(Te),d({type:"onDragMove",event:Te})})},[Le.x,Le.y]),y.useEffect(()=>{const{active:me,activatorEvent:Xe,collisions:He,droppableContainers:nt,scrollAdjustedTranslate:Pe}=Q.current;if(!me||I.current==null||!Xe||!Pe)return;const{onDragOver:Te}=O.current,Ve=nt.get(ke),Ze=Ve&&Ve.rect.current?{id:Ve.id,rect:Ve.rect.current,data:Ve.data,disabled:Ve.disabled}:null,st={active:me,activatorEvent:Xe,collisions:He,delta:{x:Pe.x,y:Pe.y},over:Ze};Zt.unstable_batchedUpdates(()=>{G(Ze),Te?.(st),d({type:"onDragOver",event:st})})},[ke]),Kt(()=>{Q.current={activatorEvent:H,active:M,activeNode:W,collisionRect:Ae,collisions:Se,droppableRects:X,draggableNodes:C,draggingNode:Ce,draggingNodeRect:Oe,droppableContainers:N,over:Ne,scrollableAncestors:ge,scrollAdjustedTranslate:Le},A.current={initial:Oe,translated:Ae}},[M,W,Se,Ae,C,Ce,Oe,X,N,Ne,ge,Le]),gh({...z,delta:E,draggingRect:Ae,pointerCoordinates:De,scrollableAncestors:ge,scrollableAncestorRects:$e});const Be=y.useMemo(()=>({active:M,activeNode:W,activeNodeRect:q,activatorEvent:H,collisions:Se,containerNodeRect:se,dragOverlay:be,draggableNodes:C,droppableContainers:N,droppableRects:X,over:Ne,measureDroppableContainers:U,scrollableAncestors:ge,scrollableAncestorRects:$e,measuringConfiguration:$,measuringScheduled:K,windowRect:fe}),[M,W,q,H,Se,se,be,C,N,X,Ne,U,ge,$e,$,K,fe]),Re=y.useMemo(()=>({activatorEvent:H,activators:he,active:M,activeNodeRect:q,ariaDescribedById:{draggable:P},dispatch:f,draggableNodes:C,over:Ne,measureDroppableContainers:U}),[H,he,M,q,f,P,C,Ne,U]);return ce.createElement($a.Provider,{value:h},ce.createElement(sr.Provider,{value:Re},ce.createElement(il.Provider,{value:Be},ce.createElement(Yr.Provider,{value:we},l)),ce.createElement(Ih,{disabled:n?.restoreFocus===!1})),ce.createElement(Hu,{...n,hiddenTextDescribedById:P}));function tt(){const me=L?.autoScrollEnabled===!1,Xe=typeof i=="object"?i.enabled===!1:i===!1,He=k&&!me&&!Xe;return typeof i=="object"?{...i,enabled:He}:{enabled:He}}}),Hh=y.createContext(null),mo="button",Wh="Draggable";function $h(e){let{id:s,data:r,disabled:o=!1,attributes:m}=e;const p=Xr(Wh),{activators:g,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:v}=y.useContext(sr),{role:b=mo,roleDescription:S="draggable",tabIndex:x=0}=m??{},a=i?.id===s,f=y.useContext(a?Yr:Hh),[d,h]=jr(),[_,w]=jr(),k=Rh(g,s),j=Xs(r);Kt(()=>(c.set(s,{id:s,key:p,node:d,activatorNode:_,data:j}),()=>{const E=c.get(s);E&&E.key===p&&c.delete(s)}),[c,s]);const C=y.useMemo(()=>({role:b,tabIndex:x,"aria-disabled":o,"aria-pressed":a&&b===mo?!0:void 0,"aria-roledescription":S,"aria-describedby":u.draggable}),[o,b,x,a,S,u.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:C,isDragging:a,listeners:o?void 0:k,node:d,over:v,setNodeRef:h,setActivatorNodeRef:w,transform:f}}function Uh(){return y.useContext(il)}const qh="Droppable",Kh={timeout:25};function Xh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:m}=e;const p=Xr(qh),{active:g,dispatch:n,over:i,measureDroppableContainers:l}=y.useContext(sr),u=y.useRef({disabled:r}),c=y.useRef(!1),v=y.useRef(null),b=y.useRef(null),{disabled:S,updateMeasurementsFor:x,timeout:a}={...Kh,...m},f=Xs(x??o),d=y.useCallback(()=>{if(!c.current){c.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{l(Array.isArray(f.current)?f.current:[f.current]),b.current=null},a)},[a]),h=Vr({callback:d,disabled:S||!g}),_=y.useCallback((C,E)=>{h&&(E&&(h.unobserve(E),c.current=!1),C&&h.observe(C))},[h]),[w,k]=jr(_),j=Xs(s);return y.useEffect(()=>{!h||!w.current||(h.disconnect(),c.current=!1,h.observe(w.current))},[w,h]),y.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:p,disabled:r,node:w,rect:v,data:j}}),()=>n({type:ot.UnregisterDroppable,key:p,id:o})),[o]),y.useEffect(()=>{r!==u.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:p,disabled:r}),u.current.disabled=r)},[o,p,r,n]),{active:g,rect:v,isOver:i?.id===o,node:w,over:i,setNodeRef:k}}function Vh(e){let{animation:s,children:r}=e;const[o,m]=y.useState(null),[p,g]=y.useState(null),n=Nr(r);return!r&&!o&&n&&m(n),Kt(()=>{if(!p)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){m(null);return}Promise.resolve(s(l,p)).then(()=>{m(null)})},[s,o,p]),ce.createElement(ce.Fragment,null,r,o?y.cloneElement(o,{ref:g}):null)}const Yh={x:0,y:0,scaleX:1,scaleY:1};function Gh(e){let{children:s}=e;return ce.createElement(sr.Provider,{value:rl},ce.createElement(Yr.Provider,{value:Yh},s))}const Qh={position:"fixed",touchAction:"none"},Zh=e=>gn(e)?"transform 250ms ease":void 0,Jh=y.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:m,children:p,className:g,rect:n,style:i,transform:l,transition:u=Zh}=e;if(!n)return null;const c=m?l:{...l,scaleX:1,scaleY:1},v={...Qh,width:n.width,height:n.height,top:n.top,left:n.left,transform:Vs.Transform.toString(c),transformOrigin:m&&o?Uu(o,n):void 0,transition:typeof u=="function"?u(o):u,...i};return ce.createElement(r,{className:g,style:v,ref:s},p)}),ef=e=>s=>{let{active:r,dragOverlay:o}=s;const m={},{styles:p,className:g}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(m[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return g!=null&&g.active&&r.node.classList.add(g.active),g!=null&&g.dragOverlay&&o.node.classList.add(g.dragOverlay),function(){for(const[i,l]of Object.entries(m))r.node.style.setProperty(i,l);g!=null&&g.active&&r.node.classList.remove(g.active)}},tf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:Vs.Transform.toString(s)},{transform:Vs.Transform.toString(r)}]},sf={duration:250,easing:"ease",keyframes:tf,sideEffects:ef({styles:{active:{opacity:"0"}}})};function rf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:m}=e;return Kr((p,g)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const l=sl(g);if(!l)return;const{transform:u}=St(g).getComputedStyle(g),c=qa(u);if(!c)return;const v=typeof s=="function"?s:nf(s);return Za(i,m.draggable.measure),v({active:{id:p,data:n.data,node:i,rect:m.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:g,rect:m.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:m,transform:c})})}function nf(e){const{duration:s,easing:r,sideEffects:o,keyframes:m}={...sf,...e};return p=>{let{active:g,dragOverlay:n,transform:i,...l}=p;if(!s)return;const u={x:n.rect.left-g.rect.left,y:n.rect.top-g.rect.top},c={scaleX:i.scaleX!==1?g.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?g.rect.height*i.scaleY/n.rect.height:1},v={x:i.x-u.x,y:i.y-u.y,...c},b=m({...l,active:g,dragOverlay:n,transform:{initial:i,final:v}}),[S]=b,x=b[b.length-1];if(JSON.stringify(S)===JSON.stringify(x))return;const a=o?.({active:g,dragOverlay:n,...l}),f=n.node.animate(b,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{f.onfinish=()=>{a?.(),d()}})}}let po=0;function of(e){return y.useMemo(()=>{if(e!=null)return po++,po},[e])}const af=ce.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:m,transition:p,modifiers:g,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:v,containerNodeRect:b,draggableNodes:S,droppableContainers:x,dragOverlay:a,over:f,measuringConfiguration:d,scrollableAncestors:h,scrollableAncestorRects:_,windowRect:w}=Uh(),k=y.useContext(Yr),j=of(c?.id),C=nl(g,{activatorEvent:u,active:c,activeNodeRect:v,containerNodeRect:b,draggingNodeRect:a.rect,over:f,overlayNodeRect:a.rect,scrollableAncestors:h,scrollableAncestorRects:_,transform:k,windowRect:w}),E=yn(v),N=rf({config:o,draggableNodes:S,droppableContainers:x,measuringConfiguration:d}),D=E?a.setRef:void 0;return ce.createElement(Gh,null,ce.createElement(Vh,{animation:N},c&&j?ce.createElement(Jh,{key:j,id:c.id,ref:D,as:n,activatorEvent:u,adjustScale:s,className:i,transition:p,rect:E,style:{zIndex:l,...m},transform:C},r):null))}),ol=768;function lf(e){const s=window.matchMedia(`(max-width: ${ol-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function cf(){return window.innerWidth<ol}function df(){return!1}function al(){return y.useSyncExternalStore(lf,cf,df)}function Sn(e){return Nt({queryKey:ae.workspaces.list(e),queryFn:()=>xe.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ll(e){const s=at();return wt({mutationFn:r=>xe.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ae.workspaces.list(e)}),s.invalidateQueries({queryKey:ae.tasks.all})}})}function uf(){const e=at();return wt({mutationFn:({id:s,commitMessage:r})=>xe.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all}),e.invalidateQueries({queryKey:ae.git.all})},onError:()=>{e.invalidateQueries({queryKey:ae.git.all})}})}function hf(){const e=at();return wt({mutationFn:s=>xe.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function wn(){return wt({mutationFn:({workspaceId:e,editorType:s})=>xe.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Cn(e,s={}){return Nt({queryKey:ae.workspaces.gitStatus(e),queryFn:()=>xe.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function ff(){const e=at();return wt({mutationFn:s=>xe.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function cl(){const e=at();return wt({mutationFn:s=>xe.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function mf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(g=>g.status===it.RUNNING||g.status===it.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function kn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:m,workspaces:p,isLoading:g}){const{t:n}=le(),{data:i,isLoading:l}=Sn(p===void 0&&e?o:""),u=p??i,c=p===void 0&&e&&l,v=y.useMemo(()=>mf(u,n),[u,n]);return t.jsx(Fr,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:m})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):v.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:v.map((b,S)=>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:b})]},S))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:g||c})}const ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},$i={[ve.Review]:{label:"Review",icon:Ta,iconClass:"text-warning",accentClass:"text-warning"},[ve.Running]:{label:"Running",icon:Ra,iconClass:"text-info",accentClass:"text-info"},[ve.Pending]:{label:"Pending",icon:Na,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ve.Done]:{label:"Done",icon:ja,iconClass:"text-success/80",accentClass:"text-success"},[ve.Cancelled]:{label:"Cancelled",icon:Ea,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},pf=[ve.Review,ve.Running,ve.Pending,ve.Done,ve.Cancelled],dl=y.createContext(null),gf=3e4;function vf(e=gf){const[,s]=y.useState(0);y.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function xf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?mt("{count}s ago",{count:s}):s<3600?mt("{count}m ago",{count:Math.floor(s/60)}):s<86400?mt("{count}h ago",{count:Math.floor(s/3600)}):mt("{count}d ago",{count:Math.floor(s/86400)})}function bf({task:e,status:s,isSelected:r,isAgentActive:o,project:m,onSelectTask:p,onTaskStatusChange:g,onDeleteTask:n,disableDrag:i}){const{t:l}=le(),u=y.useContext(dl),c=y.useRef(null),v=!!e.projectArchivedAt,b=v||!!i,{attributes:S,listeners:x,setNodeRef:a,isDragging:f}=$h({id:e.id,data:{task:e,fromStatus:s},disabled:b}),d=y.useCallback(M=>{c.current=M,a(M),u&&(M?u.registry.set(e.id,M):u.registry.delete(e.id))},[a,u,e.id]);y.useEffect(()=>()=>{u?.registry.delete(e.id)},[e.id,u]);const[h,_]=y.useState(null),[w,k]=y.useState(!1),j=y.useRef(null),C=y.useRef(null),E=y.useCallback(M=>{v||!g&&!n||(M.preventDefault(),_({x:M.clientX,y:M.clientY}))},[v,g,n]),N=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),D=y.useCallback(M=>{if(!i||v||!g&&!n)return;const I=M.touches[0];if(!I)return;const{clientX:L,clientY:F}=I;C.current=setTimeout(()=>{C.current=null,_({x:L,y:F})},500)},[i,v,g,n]);y.useEffect(()=>{if(!h)return;const M=I=>{j.current&&!j.current.contains(I.target)&&_(null)};return document.addEventListener("mousedown",M),document.addEventListener("touchstart",M),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("touchstart",M)}},[h]);const A=m?m.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>p(e.id),onContextMenu:E,onTouchStart:D,onTouchEnd:N,onTouchMove:N,title:A,"aria-label":A?`${e.title} — ${A}`:e.title,className:`flex items-center gap-2.5 mx-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
6
|
-
${f?"opacity-30":""}
|
|
7
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...b?{}:x,...b?{}:S,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:M,iconClass:I}=$i[s];return t.jsx(M,{className:`${I} ${s===ve.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.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?l("源码已删除"):l("已删除")}),o&&t.jsxs("span",{className:"relative inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-success/70"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-success"})]}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums group-hover:hidden",children:xf(e.updatedAt)}),m&&t.jsxs("span",{className:"shrink-0 hidden group-hover:inline-flex items-center gap-1 max-w-[120px]",children:[t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${m.color.replace("text-","bg-")}`}),t.jsx("span",{className:"truncate text-[11px] text-muted-foreground/60",children:m.name})]})]}),h&&t.jsxs("div",{ref:j,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:h.x,top:h.y},children:[g&&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:l("Move to")}),pf.filter(M=>M!==s).map(M=>{const{icon:I,label:L,accentClass:F}=$i[M];return t.jsxs("button",{onClick:()=>{g(e.id,M),_(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(I,{className:`w-3.5 h-3.5 ${F}`}),t.jsx("span",{className:"text-foreground/80",children:l(L)})]},M)})]}),n&&t.jsxs(t.Fragment,{children:[g&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{k(!0),_(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:l("Delete Task")})]})]})]}),t.jsx(kn,{isOpen:w,onClose:()=>k(!1),onConfirm:()=>{n?.(e.id),k(!1)},taskId:e.id,taskTitle:e.title})]})}const _f=y.memo(function({title:s,tasks:r,status:o,defaultOpen:m,selectedTaskId:p,onSelectTask:g,projects:n,activeTaskIds:i,isDragging:l,dragFromStatus:u,onTaskStatusChange:c,onDeleteTask:v,disableDrag:b}){const{t:S}=le(),[x,a]=y.useState(m);vf();const f=r.length===0,d=l&&u===o,h=l&&u!==o,{setNodeRef:_,isOver:w}=Xh({id:`group-${o}`,data:{status:o}}),k=o===ve.Review,j=S(s),C=l?d&&(x||!0):x;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!l&&a(E=>!E),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:j}),k&&!f?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:C?t.jsx(ht,{size:12}):t.jsx(Ot,{size:12})})]}),h&&t.jsx("div",{ref:_,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
8
|
-
${w?"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:w?S("Drop into {title}",{title:j}):S("Drop here")})}),C&&!h&&t.jsx("div",{ref:d?void 0:_,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
9
|
-
${w&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
10
|
-
${f&&l?"border border-dashed border-border mx-2":""}`,children:f?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:S("No tasks")}):r.map(E=>{const N=n.find(M=>M.id===E.projectId),D=p===E.id,A=i?.has(E.id)??!1;return t.jsx(bf,{task:E,status:o,isSelected:D,isAgentActive:A,project:N,onSelectTask:g,onTaskStatusChange:E.projectArchivedAt?void 0:c,onDeleteTask:E.projectArchivedAt?void 0:v,disableDrag:b},E.id)})})]})}),yf=12,Sf=50;function wf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:m}){const{t:p}=le(),[g,n]=y.useState(""),[i,l]=y.useState(0),u=y.useRef(null);y.useEffect(()=>{e&&(n(""),l(0))},[e]);const c=y.useMemo(()=>{const S=g.trim().toLowerCase();return S?r.filter(x=>x.title.toLowerCase().includes(S)).slice(0,Sf):r.slice(0,yf)},[r,g]);y.useEffect(()=>{l(0)},[g]),y.useEffect(()=>{u.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const v=y.useCallback(S=>{m(S),s()},[m,s]),b=y.useCallback(S=>{if(S.key==="Escape")S.preventDefault(),s();else if(S.key==="ArrowDown")S.preventDefault(),l(x=>Math.min(x+1,c.length-1));else if(S.key==="ArrowUp")S.preventDefault(),l(x=>Math.max(x-1,0));else if(S.key==="Enter"&&!S.nativeEvent.isComposing){S.preventDefault();const x=c[i];x&&v(x.id)}},[s,c,i,v]);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(fn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:g,onChange:S=>n(S.target.value),onKeyDown:b,placeholder:p("Search tasks..."),"aria-label":p("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:[!g.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:p("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((S,x)=>{const a=o.find(h=>h.id===S.projectId),{icon:f,iconClass:d}=$i[S.status];return t.jsxs("button",{onClick:()=>v(S.id),onMouseEnter:()=>l(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
11
|
-
${x===i?"bg-accent":""}`,children:[t.jsx(f,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:S.title,children:S.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},S.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:p("No matching tasks")})]})]}):null}const Cf=260,kf=220;function Ef(e){const s={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const jf=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function go({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:m,setFilterProjectId:p,width:g=320,onCreateTask:n,onCreateProject:i,isCreateActive:l,activeTaskIds:u,onTaskStatusChange:c,onDeleteTask:v}){const{t:b}=le(),S=al(),[x,a]=y.useState(null),[f,d]=y.useState(null),[h,_]=y.useState(!1),w=y.useRef(new Map),k=y.useRef(new Set),j=y.useRef(new Map),C=y.useMemo(()=>({registry:w.current}),[]),E=y.useCallback(P=>{P.remove(),k.current.delete(P)},[]),N=m?e.filter(P=>P.projectId===m):e,D=y.useCallback((P,B)=>{const $=document.querySelector(`[data-task-group-status="${P}"]`);if(!$)return null;const U=($.querySelector("button")??$).getBoundingClientRect();return U.width===0||U.height===0?null:new DOMRect(U.left+8,U.bottom+4,B.width,B.height)},[]),A=y.useCallback((P,B,$,X=!1)=>{const U=document.createElement("div");U.setAttribute("aria-hidden","true"),U.innerHTML=$;const K=U.firstElementChild;K&&(K.style.cssText="",K.className=K.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),K.style.pointerEvents="none",K.style.width=`${P.width}px`,K.style.height=`${P.height}px`,K.style.margin="0",K.style.backgroundColor="var(--sidebar-accent)",K.style.borderRadius="0.375rem",K.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",K.style.opacity="0.96",K.style.transition="none",K.setAttribute("tabindex","-1")),Object.assign(U.style,{position:"fixed",left:`${P.left}px`,top:`${P.top}px`,width:`${P.width}px`,height:`${P.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(U),k.current.add(U);const W=B.left-P.left,R=B.top-P.top;U.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${W}px, ${R}px)`,opacity:X?.12:.96,offset:1}],{duration:X?kf:Cf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>E(U),()=>E(U))},[E]);y.useLayoutEffect(()=>{const P=window.matchMedia("(prefers-reduced-motion: reduce)").matches,B=new Map;for(const $ of N){const X=w.current.get($.id);if(!X)continue;const U={status:$.status,rect:X.getBoundingClientRect(),html:X.outerHTML};if(B.set($.id,U),P)continue;const K=j.current.get($.id);if(!K||K.status===$.status)continue;const W=U.rect.left-K.rect.left,R=U.rect.top-K.rect.top;Math.abs(W)<1&&Math.abs(R)<1||A(K.rect,U.rect,K.html)}if(!P)for(const[$,X]of j.current){if(B.has($))continue;const U=N.find(W=>W.id===$);if(!U||U.status===X.status)continue;const K=D(U.status,X.rect);K&&A(X.rect,K,X.html,!0)}j.current=B},[N,A,D]),y.useEffect(()=>()=>{for(const P of k.current)P.remove();k.current.clear()},[]);const M=$u(Wu(_n,{activationConstraint:{distance:8}})),I=y.useCallback(P=>{const B=P.active.data.current?.task,$=P.active.data.current?.fromStatus;B&&a(B),$&&d($)},[]),L=y.useCallback(P=>{a(null),d(null);const{active:B,over:$}=P;if(!$)return;const X=B.data.current?.task,U=B.data.current?.fromStatus,K=$.data.current?.status;!X||!U||!K||X.projectArchivedAt||U!==K&&c?.(X.id,K)},[c]),T=!!!(m?s.find(P=>P.id===m)??null:null)?.archivedAt,O=Ef(N);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:g},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,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:b("New Project"),children:[t.jsx(ud,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!T,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
|
|
12
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:b(T?"New Task":"Deleted projects are read-only"),children:[t.jsx(yu,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("New Task")})]}),t.jsxs("button",{onClick:()=>_(!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:b("Search"),children:[t.jsx(fn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("Search")})]})]}),N.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Cs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:b("No tasks")}),T&&n?t.jsx("button",{onClick:n,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:b("New Task")}):null]}):t.jsx(dl.Provider,{value:C,children:t.jsxs(zh,{sensors:M,onDragStart:I,onDragEnd:L,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:jf.map(({status:P,title:B,defaultOpen:$})=>t.jsx(_f,{title:B,tasks:O[P],status:P,defaultOpen:$,selectedTaskId:r,onSelectTask:o,projects:s,activeTaskIds:u,isDragging:x!==null,dragFromStatus:f,onTaskStatusChange:c,onDeleteTask:v,disableDrag:S},P))}),t.jsx(af,{dropAnimation:null,children:x?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:x.title,children:x.title})}):null})]})}),N.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:b("{count} tasks",{count:N.length})}),m?t.jsx("button",{onClick:()=>p(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:b("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:b("{count} tasks",{count:0})})}),t.jsx(wf,{isOpen:h,onClose:()=>_(!1),tasks:N,projects:s,onSelectTask:o})]})}const Nf={damping:.7,stiffness:.05,mass:1.25},Rf=70,Tf=1e3/60,Af=350;let Gr=!1;globalThis.document?.addEventListener("mousedown",()=>{Gr=!0});globalThis.document?.addEventListener("mouseup",()=>{Gr=!1});globalThis.document?.addEventListener("click",()=>{Gr=!1});const En=(e={})=>{const[s,r]=y.useState(!1),[o,m]=y.useState(e.initial!==!1),[p,g]=y.useState(!1),n=y.useRef(null);n.current=e;const i=y.useCallback(()=>{if(!Gr)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const h=d.getRangeAt(0);return h.commonAncestorContainer.contains(a.current)||a.current?.contains(h.commonAncestorContainer)},[]),l=y.useCallback(d=>{c.isAtBottom=d,m(d)},[]),u=y.useCallback(d=>{c.escapedFromLock=d,r(d)},[]),c=y.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(h){a.current&&(a.current.scrollTop=h,c.ignoreScrollToTop=a.current.scrollTop)},get targetScrollTop(){return!a.current||!f.current?0:a.current.scrollHeight-1-a.current.clientHeight},get calculatedTargetScrollTop(){if(!a.current||!f.current)return 0;const{targetScrollTop:h}=this;if(!e.targetScrollTop)return h;if(d?.targetScrollTop===h)return d.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(h,{scrollElement:a.current,contentElement:f.current}),h),0);return d={targetScrollTop:h,calculatedScrollTop:_},requestAnimationFrame(()=>{d=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Rf}}},[]),v=y.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||l(!0);const h=Date.now()+(Number(d.wait)||0),_=_i(n.current,d.animation),{ignoreEscapes:w=!1}=d;let k,j=c.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=h+(d.duration??0);const C=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!c.isAtBottom)return c.animation=void 0,!1;const{scrollTop:N}=c,D=performance.now(),A=(D-(c.lastTick??D))/Tf;if(c.animation||(c.animation={behavior:_,promise:E,ignoreEscapes:w}),c.animation.behavior===_&&(c.lastTick=D),i()||h>Date.now())return C();if(N<Math.min(j,c.calculatedTargetScrollTop)){if(c.animation?.behavior===_){if(_==="instant")return c.scrollTop=c.calculatedTargetScrollTop,C();c.velocity=(_.damping*c.velocity+_.stiffness*c.scrollDifference)/_.mass,c.accumulated+=c.velocity*A,c.scrollTop+=c.accumulated,c.scrollTop!==N&&(c.accumulated=0)}return C()}return k>Date.now()?(j=c.calculatedTargetScrollTop,C()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?v({animation:_i(n.current,n.current.resize),ignoreEscapes:w,duration:Math.max(0,k-Date.now())||void 0}):c.isAtBottom)});return E.then(N=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),N))};return d.wait!==!0&&(c.animation=void 0),c.animation?.behavior===_?c.animation.promise:C()},[l,i,c]),b=y.useCallback(()=>{u(!0),l(!1)},[u,l]),S=y.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:h,ignoreScrollToTop:_}=c;let{lastScrollTop:w=h}=c;c.lastScrollTop=h,c.ignoreScrollToTop=void 0,_&&_>h&&(w=_),g(c.isNearBottom),setTimeout(()=>{if(c.resizeDifference||h===_)return;if(i()){u(!0),l(!1);return}const k=h>w,j=h<w;if(c.animation?.ignoreEscapes){c.scrollTop=w;return}j&&(u(!0),l(!1)),k&&u(!1),!c.escapedFromLock&&c.isNearBottom&&l(!0)},1)},[u,l,i,c]),x=y.useCallback(({target:d,deltaY:h})=>{let _=d;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===a.current&&h<0&&a.current.scrollHeight>a.current.clientHeight&&!c.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,c]),a=vo(d=>{a.current?.removeEventListener("scroll",S),a.current?.removeEventListener("wheel",x),d?.addEventListener("scroll",S,{passive:!0}),d?.addEventListener("wheel",x,{passive:!0})},[]),f=vo(d=>{if(c.resizeObserver?.disconnect(),!d)return;let h;c.resizeObserver=new ResizeObserver(([_])=>{const{height:w}=_.contentRect,k=w-(h??w);if(c.resizeDifference=k,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),g(c.isNearBottom),k>=0){const j=_i(n.current,h?n.current.resize:n.current.initial);v({animation:j,wait:!0,preserveScrollPosition:!0,duration:j==="instant"?void 0:Af})}else c.isNearBottom&&(u(!1),l(!0));h=w,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===k&&(c.resizeDifference=0)},1)})}),c.resizeObserver?.observe(d)},[]);return{contentRef:f,scrollRef:a,scrollToBottom:v,stopScroll:b,isAtBottom:o||p,isNearBottom:p,escapedFromLock:s,state:c}};function vo(e,s){const r=y.useCallback(o=>(r.current=o,e(o)),s);return r}const bi=new Map;function _i(...e){const s={...Nf};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,s.damping=m.damping??s.damping,s.stiffness=m.stiffness??s.stiffness,s.mass=m.mass??s.mass)}const o=JSON.stringify(s);return bi.has(o)||bi.set(o,Object.freeze(s)),r?"instant":bi.get(o)}function Mf({content:e,children:s,className:r="",side:o="top"}){const m=o==="bottom"?"top-full mt-2":"bottom-full mb-2",p=o==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return t.jsxs("div",{className:`group/tooltip relative ${r}`,children:[s,t.jsxs("div",{className:`absolute ${m} left-1/2 -translate-x-1/2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[100] shadow-lg`,children:[e,t.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function hr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Df(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function jn({usage:e,tooltipSide:s="top"}){const{t:r}=le();if(!e)return null;const o=e.modelContextWindow,m=o?e.totalTokens/o:0,p=o?Math.min(Math.round(m*100),100):null,g=o?Df(m):"text-neutral-400",n=o?t.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:hr(e.totalTokens),max:hr(o)})}):t.jsx("span",{children:r("已使用: {used} tokens",{used:hr(e.totalTokens)})});return t.jsx(Mf,{content:n,side:s,children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[t.jsx(Kd,{size:14,className:g}),t.jsxs("span",{className:`tabular-nums ${g}`,children:[hr(e.totalTokens),p!==null&&t.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const Lf="/api";async function Pf(e){const s=new FormData;s.append("file",e);const r=await fetch(`${Lf}/attachments/upload`,{method:"POST",body:s});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error||`Upload failed (${r.status})`)}return r.json()}let Of=0;function Qr(){const[e,s]=y.useState([]),r=y.useRef(e);r.current=e;const o=y.useCallback(async c=>{const v=c.map(b=>({tempId:`tmp-${++Of}`,file:b,progress:0,status:"uploading"}));s(b=>[...b,...v]),await Promise.allSettled(v.map(async b=>{try{const S=await Pf(b.file);s(x=>x.map(a=>a.tempId===b.tempId?{...a,status:"done",progress:100,attachment:S}:a))}catch(S){s(x=>x.map(a=>a.tempId===b.tempId?{...a,status:"error",error:S instanceof Error?S.message:"Upload failed"}:a))}}))},[]),m=y.useCallback(()=>r.current.filter(c=>c.status==="done"&&c.attachment).map(c=>c.attachment),[]),p=y.useCallback(c=>{s(v=>v.filter(b=>b.tempId!==c))},[]),g=y.useCallback(()=>{s([])},[]),n=y.useCallback(c=>{c.length!==0&&s(v=>{const b=new Set(v.map(x=>x.attachment?.id??x.tempId)),S=c.filter(x=>{const a=x.attachment?.id??x.tempId;return b.has(a)?!1:(b.add(a),!0)});return S.length>0?[...v,...S]:v})},[]),i=y.useCallback(()=>{const c=m();return c.length===0?"":c.map(v=>`${v.mimeType.startsWith("image/")?"!":""}[${v.originalName}](${v.storagePath})`).join(`
|
|
13
|
-
`)},[m]),l=e.length>0,u=e.some(c=>c.status==="uploading");return{files:e,addFiles:o,removeFile:p,clear:g,restoreFiles:n,buildMarkdownLinks:i,getDoneAttachments:m,hasFiles:l,isUploading:u}}function If(e){const s=y.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return Nt({queryKey:["attachments","metadata",s],queryFn:()=>xe.get("/attachments/metadata",{params:{ids:s.join(",")}}),enabled:s.length>0,staleTime:300*1e3})}const Bf="/api";function Ff(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Zr({files:e,onRemove:s}){return e.length===0?null:t.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>t.jsx(zf,{item:r,onRemove:s},r.tempId))})}function zf({item:e,onRemove:s}){const r=e.file.type.startsWith("image/"),o=e.status==="error",m=e.status==="uploading";return t.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${o?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[r&&e.status==="done"&&e.attachment?t.jsx("img",{src:`${Bf}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):t.jsx("span",{className:"flex-shrink-0",children:m?t.jsx(ze,{size:16,className:"animate-spin text-neutral-400"}):r?t.jsx(hn,{size:16,className:"text-neutral-400"}):t.jsx(dn,{size:16,className:"text-neutral-400"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate font-medium",children:e.file.name}),o?t.jsx("div",{className:"truncate text-red-500",children:e.error}):t.jsx("div",{className:"text-neutral-400",children:Ff(e.file.size)})]}),t.jsx("button",{onClick:()=>s(e.tempId),className:"absolute -top-1.5 -right-1.5 hidden group-hover:flex items-center justify-center w-5 h-5 rounded-full bg-neutral-700 text-white hover:bg-neutral-900 transition-colors",children:t.jsx(Wt,{size:10})})]})}const Hf=10,Wf=24,ul=Hf*Wf,$f=8;function Uf(e,s=ul){return e>s+$f}function qf(e,s){return e.includes(s)?e:[...e,s]}function Kf(e,s){return e.filter(r=>r!==s)}function Xf(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 Jr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function xo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Vf(e,s=[],r=[]){const o=new Set(r.filter(p=>Jr.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...s.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!o.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,g)=>{const n=xo(p.sortTime)-xo(g.sortTime);return n!==0?n:p.order!==g.order?p.order-g.order:p.key.localeCompare(g.key)})}function Yf(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 Gf(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 Qf(e,s){const r=e.reduce((m,p)=>(m[p.status]=(m[p.status]??0)+1,m),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([m,p])=>{const g=r[m];return g?`${g} ${s(p)}`:null}).filter(m=>!!m).join(" · ")}function Zf(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Jf({status:e}){const{t:s}=le();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(Yf(e))})}function em({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:m,isStopPending:p,stoppingMemberId:g,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:l}=le(),[u,c]=y.useState(Zf),v=y.useMemo(()=>e.filter(S=>Jr.has(S.status)).sort((S,x)=>Date.parse(x.updatedAt??x.createdAt??"")-Date.parse(S.updatedAt??S.createdAt??"")),[e]);if(v.length===0)return null;const b=Qf(v,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(S=>!S),"aria-expanded":u,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:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:b})]}),u?t.jsx(ht,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Pa,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:v.map(S=>{const x=s.get(S.memberId),a=r.get(S.workRequestId),f=!!(S.sessionId&&o),d=!!x,h=n===S.id,_=p&&g===S.memberId,w=a?.instruction??S.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:w,className:Z("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",f?"cursor-pointer hover:bg-white":"cursor-default"),role:f?"button":void 0,tabIndex:f?0:void 0,onClick:()=>S.sessionId&&o?.(S.sessionId),onKeyDown:k=>{!f||!S.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(S.sessionId))},children:[t.jsx(Lt,{name:x?.name??l("Agent"),avatar:x?.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:x?.name??l("Agent")}),t.jsx("span",{className:Z("shrink-0",Gf(S.status)),children:t.jsx(Jf,{status:S.status})})]}),f&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),S.sessionId&&o?.(S.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:l("View log"),"aria-label":`${l("View log")} ${x?.name??l("Agent")}`,children:t.jsx(kr,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(S.id)},onKeyDown:k=>k.stopPropagation(),disabled:_,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:l("Stop"),"aria-label":`${l("Stop")} ${x?.name??l("Agent")}`,children:t.jsx(ws,{size:12})})]}),d&&h&&x&&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:l("Stop running work?")}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:_,onClick:()=>m(x.id,!1),children:[t.jsx(ws,{size:11}),t.jsx("span",{children:l(_?"Stopping":"Stop only")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:_,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>m(x.id,!0),children:[t.jsx(Oa,{size:11}),t.jsx("span",{children:l(_?"Stopping":"Stop + clear queue")})]})]})]},S.id)})})]})}const Dr="/api",tm=240;let bo=0;function sm(e,s){return bo+=1,{id:`pending-room-message-${Date.now()}-${bo}`,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 hl(e){return"pendingStatus"in e}const rm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Dr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function im(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function nm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Ui(e,s){if(s.length===0)return e;const r=new Set(s.map(nm));return e.split(`
|
|
14
|
-
`).map(o=>{const m=o.match(/^\s*/)?.[0]??"",p=o.trimStart();for(const g of r){if(p===g)return null;if(p.startsWith(`${g} `)||p.startsWith(`${g} `))return`${m}${p.slice(g.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
|
-
`).replace(/\n{3,}/g,`
|
|
16
|
-
|
|
17
|
-
`).trim()}function om(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qi(e,s){return e instanceof Error?e.message:s}function am(e,s=tm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function lm(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 cm(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(r)):!0}function _o(e){return e.membershipStatus!=="REMOVED"}function dm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function um(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function hm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const m=r.map(g=>dm(g,s)).filter(g=>g&&!o.includes(`@${g}`));if(m.length===0)return o;const p=m.map(g=>`@${g}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${p}`:p}function fm(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 mm({content:e,isUser:s}){return t.jsx("div",{className:Z("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(rn,{urlTransform:rm,components:nn,children:e})})}function pm({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 m=s.filter(g=>g.mimeType.startsWith("image/")),p=new Map(m.map((g,n)=>[g.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(g=>{const n=`${Dr}${g.url}`;if(g.mimeType.startsWith("image/")){const l=p.get(g.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(m,l),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:g.originalName,children:[t.jsx("img",{src:n,alt:g.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:g.originalName})]},g.id)}return t.jsxs("a",{href:n,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:g.originalName,children:[t.jsx(dn,{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:g.originalName}),t.jsx("span",{className:"text-neutral-400",children:im(g.sizeBytes)})]}),t.jsx(cn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},g.id)})})}function gm({message:e,content:s,attachmentIds:r,isUser:o,tone:m,onOpenImage:p}){const g=y.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:n=[],isLoading:i}=If(g),l=n.length>0?Ui(s,n):s;return t.jsxs(t.Fragment,{children:[l.trim()&&t.jsx(bm,{message:e,content:l,attachments:n,isUser:o,tone:m}),t.jsx(pm,{hasAttachmentIds:g.length>0,attachments:n,isLoading:i,onOpenImage:p})]})}function vm({images:e,index:s,onClose:r,onSelect:o}){const m=e[s];if(!m)return null;const p=s>0,g=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(Wt,{size:20})}),p&&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(Ad,{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:`${Dr}${m.url}`,alt:m.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:m.originalName}),t.jsxs("a",{href:`${Dr}${m.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"]})]})]}),g&&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(Ot,{size:24,"aria-hidden":!0})})]})}function xm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const p=[e.trim(),s].filter(Boolean).join(`
|
|
18
|
-
|
|
19
|
-
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function bm({message:e,content:s,attachments:r,isUser:o,tone:m=o?"user":"agent"}){const{t:p}=le(),g=y.useId(),n=y.useRef(null),[i,l]=y.useState(null),[u,c]=y.useState(!1),[v,b]=y.useState(null),S=td(e.teamRunId,e.id,!1),x=S.data?.content,a=x?Ui(x,r):void 0,d=!!(a&&a!==s)?a:s,h=!!(e.isTruncated&&!hl(e)),_=i?.messageId===e.id&&i.content===d&&i.expanded,w=y.useCallback(()=>{const N=n.current;N&&c(Uf(N.scrollHeight))},[]);y.useLayoutEffect(()=>{w();const N=n.current;if(!N)return;const D=window.requestAnimationFrame(w),A=typeof ResizeObserver>"u"?null:new ResizeObserver(w);return A?.observe(N),window.addEventListener("resize",w),()=>{window.cancelAnimationFrame(D),A?.disconnect(),window.removeEventListener("resize",w)}},[d,w]);const k=y.useCallback(async()=>{if(b(null),_){l({messageId:e.id,content:d,expanded:!1});return}if(h&&!x){const N=await S.refetch();if(N.error){b(qi(N.error,p("Failed to load full message")));return}const D=N.data?.content?Ui(N.data.content,r):d;l({messageId:e.id,content:D,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,h,x,S,_,e.id,d,p]),j=(u||h)&&!_,C=u||h,E=S.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:g,ref:n,onLoadCapture:w,className:Z("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:ul}:void 0,children:[t.jsx(mm,{content:d,isUser:o}),j&&t.jsx("div",{className:Z("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",m==="system"?"to-amber-50":m==="user"?"to-neutral-900":"to-neutral-100")})]}),C&&t.jsxs("button",{type:"button","aria-expanded":_,"aria-controls":g,"aria-label":p(_?"Collapse message":"Expand full message"),disabled:E,onClick:()=>{k()},className:Z("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",m==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":m==="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",E?"cursor-wait opacity-70":""),children:[_?t.jsx(Pa,{size:13}):t.jsx(ht,{size:13}),t.jsx("span",{children:p(E?"Loading":_?"Collapse message":"Expand full message")})]}),v&&t.jsx("div",{className:Z("mt-1 text-xs",m==="user"?"text-red-200":"text-red-600"),children:v})]})}function fl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:m,children:p,headerAddon:g,bubbleClassName:n,isPending:i}){return m?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:p})}):t.jsxs("div",{className:Z("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(Lt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Z("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:Z("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(bs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:om(r)}),g]}),t.jsx("div",{className:Z("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",n,i?"opacity-70":""),children:p})]}),o&&t.jsx(Lt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function _m({message:e,senderName:s,senderMember:r,memberById:o,displayContent:m,onOpenImage:p}){const{t:g}=le(),n=e.senderType==="user",i=e.senderType==="system",l=hl(e)?e.pendingStatus:null,u=e.mentions??[],c=e.workRequestIds?.length??0,v=e.visibility==="PRIVATE",b=v?um(e,o):[],S=t.jsxs(t.Fragment,{children:[v&&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:b.join(", "),children:[t.jsx(eu,{size:10}),t.jsxs("span",{className:"truncate",children:[g("Private"),b.length>0?`: ${b.join(", ")}`:""]})]}),!i&&c>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:[g("Work requests"),": ",c]}),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:g("发送中...")}),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:g("发送失败")})]});return t.jsx(fl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:n,isSystem:i,headerAddon:S,bubbleClassName:n&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(gm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:n&&l!=="failed",tone:i?"system":void 0,onOpenImage:p})})}function ym({request:e,member:s,onApprove:r,onReject:o,isActionPending:m,isApprovePending:p,isRejectPending:g}){const{t:n}=le();return t.jsx(fl,{senderName:s?.name??n("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(bs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(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??am(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:m,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(yt,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:o,children:[t.jsx(Wt,{size:12}),t.jsx("span",{children:n(g?"Rejecting":"Reject")})]})]})]})})}function ml({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:m,onViewInvocationSession:p,compactComposer:g,centered:n}){const{t:i}=le(),l=va(e.id),u=xa(e.id),c=ba(e.id),[v,b]=y.useState(""),[S,x]=y.useState(!1),[a,f]=y.useState(null),[d,h]=y.useState(0),[_,w]=y.useState([]),[k,j]=y.useState(!1),[C,E]=y.useState(null),[N,D]=y.useState([]),[A,M]=y.useState(null),I=y.useRef(null),L=y.useRef(null),{files:F,addFiles:H,removeFile:T,clear:O,restoreFiles:P,buildMarkdownLinks:B,getDoneAttachments:$,isUploading:X}=Qr(),U=F.some(G=>G.status==="done"&&G.attachment),[K,W]=y.useState(null),{scrollRef:R,contentRef:z,isAtBottom:V,scrollToBottom:q}=En({resize:"smooth",initial:"instant"}),se=y.useMemo(()=>new Map((e.members??[]).map(G=>[G.id,G])),[e.members]),Q=y.useMemo(()=>(e.members??[]).filter(_o),[e.members]),ee=y.useMemo(()=>new Map((e.invocations??[]).map(G=>[G.id,G])),[e.invocations]),be=y.useMemo(()=>{const G=new Set(s.map(we=>we.id)),oe=N.filter(we=>!G.has(we.id));return[...s,...oe].sort((we,Y)=>{const te=Date.parse(we.createdAt??""),ie=Date.parse(Y.createdAt??"");return(Number.isNaN(te)?0:te)-(Number.isNaN(ie)?0:ie)})},[s,N]),Ce=y.useMemo(()=>new Map((e.workRequests??[]).map(G=>[G.id,G])),[e.workRequests]),Oe=y.useMemo(()=>Vf(be,e.workRequests??[],e.invocations??[]),[be,e.invocations,e.workRequests]),de=y.useMemo(()=>(e.invocations??[]).filter(G=>Jr.has(G.status)),[e.invocations]),Ke=y.useMemo(()=>_.map(G=>se.get(G)).filter(G=>!!G).filter(_o),[se,_]),fe=y.useMemo(()=>{const G=a?.query??"";return Q.filter(oe=>cm(oe,G)).sort((oe,we)=>{const Y=_.includes(oe.id),te=_.includes(we.id);return Y!==te?Y?1:-1:oe.name.localeCompare(we.name)})},[Q,a?.query,_]),ge=!r&&(S||!!a)&&fe.length>0,$e=y.useCallback((G,oe)=>{if(oe==null){f(null);return}f(lm(G,oe)),h(0)},[]),et=y.useCallback(G=>{w(ie=>qf(ie,G.id));const oe=`@${G.name} `;if(a){const ie=`${v.slice(0,a.start)}${oe}${v.slice(a.end)}`,he=a.start+oe.length;b(ie),f(null),x(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange(he,he)});return}const we=v.length===0||/\s$/.test(v)?"":" ",Y=`${v}${we}${oe}`,te=Y.length;b(Y),x(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange(te,te)})},[v,a]),De=y.useCallback(G=>{w(oe=>Kf(oe,G))},[]),re=y.useCallback(G=>{const oe=G.target.value;b(oe),E(null);const we=G.target;we.style.height="auto",we.style.height=`${Math.max(g?40:72,Math.min(we.scrollHeight,g?140:240))}px`,x(!1),$e(oe,we.selectionStart)},[g,$e]),ye=y.useCallback(G=>{const oe=G.target.files;oe&&oe.length>0&&(H(Array.from(oe)),E(null)),G.target.value=""},[H]),je=y.useCallback(G=>{const oe=[];for(const we of G.clipboardData.items)if(we.kind==="file"){const Y=we.getAsFile();Y&&oe.push(Y)}oe.length>0&&(G.preventDefault(),H(oe),E(null))},[H]),Le=y.useCallback(async()=>{if(r||k||X)return;const G=B(),oe=$().map(Re=>Re.id),we=Xf(_,Q),Y=xm({draft:v,attachmentMarkdown:G,attachmentIds:oe,mentions:we});if(!Y||!v.trim()&&!U)return;const te=sm(e.id,Y),ie=v,he=_,Be=F;D(Re=>[...Re,te]),b(""),w([]),x(!1),f(null),O(),I.current&&(I.current.style.height=g?"40px":"72px"),requestAnimationFrame(()=>q()),j(!0),E(null);try{const Re=await m(Y);D(tt=>tt.filter(me=>me.id!==te.id)),Re&&typeof Re=="object"&&"id"in Re&&requestAnimationFrame(()=>q())}catch(Re){const tt=Re instanceof Error?Re.message:"Failed to send room message";D(me=>me.map(Xe=>Xe.id===te.id?{...Xe,pendingStatus:"failed",error:tt}:Xe)),b(me=>me.length===0?ie:me),w(me=>me.length===0?he:me),P(Be),E(tt),requestAnimationFrame(()=>q())}finally{j(!1)}},[Q,F,B,O,g,v,$,U,k,X,m,r,P,q,_,e.id]),Ae=y.useCallback(G=>{const oe=G.nativeEvent.isComposing||G.nativeEvent.keyCode===229;if(ge){if(G.key==="ArrowDown"){G.preventDefault(),h(we=>(we+1)%fe.length);return}if(G.key==="ArrowUp"){G.preventDefault(),h(we=>(we-1+fe.length)%fe.length);return}if(G.key==="Enter"&&!oe||G.key==="Tab"){G.preventDefault();const we=fe[d]??fe[0];we&&et(we);return}if(G.key==="Escape"){G.preventDefault(),f(null),x(!1);return}}G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!oe&&(G.preventDefault(),Le())},[et,Le,d,fe,ge]);y.useEffect(()=>{b(""),w([]),x(!1),f(null),E(null),D([]),O(),M(null),I.current&&(I.current.style.height=g?"40px":"72px")},[O,g,e.id]);const Se=l.isError?l.error:u.isError?u.error:null,ke=l.isPending||u.isPending,Ne=y.useCallback((G,oe)=>{c.mutate({memberId:G,cancelQueued:oe},{onSuccess:()=>M(null)})},[c]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[K&&t.jsx(vm,{images:K.images,index:K.index,onClose:()=>W(null),onSelect:G=>W(oe=>oe&&{...oe,index:G})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:Z("h-full overflow-y-auto scrollbar-app-thin bg-white",g?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:z,className:Z(g?"space-y-2.5":"space-y-3",n&&"max-w-5xl 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(cs,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:i("No room messages yet")})]}):Oe.map(G=>{if(G.kind==="pendingApproval"){const ie=G.request,he=se.get(ie.targetMemberId),Be=l.isPending&&l.variables===ie.id,Re=u.isPending&&u.variables===ie.id;return t.jsx(ym,{request:ie,member:he,onApprove:()=>l.mutate(ie.id),onReject:()=>u.mutate(ie.id),isActionPending:ke,isApprovePending:Be,isRejectPending:Re},G.key)}const oe=G.message,we=fm(oe,se,ee),Y=oe.senderType==="user"?i("你"):oe.senderType==="system"?i("System"):we?.name??i("Agent"),te=hm(oe,se);return t.jsx(_m,{message:oe,senderName:Y,senderMember:we,memberById:se,displayContent:te,onOpenImage:(ie,he)=>W({images:ie,index:he})},G.key)}),Se&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(Se,i("Failed to update work request"))}),c.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(c.error,i("Failed to stop member work"))})]})}),!V&&t.jsxs("button",{type:"button",onClick:()=>q(),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(Ks,{size:14}),t.jsx("span",{children:i("Back to bottom")})]})]}),t.jsx("div",{className:Z("shrink-0 border-t border-transparent bg-white",g?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Z(n&&"max-w-5xl mx-auto"),children:[t.jsx(em,{invocations:de,memberById:se,workRequestById:Ce,onViewInvocationSession:p,onStopMember:Ne,isStopPending:c.isPending,stoppingMemberId:c.variables?.memberId??null,stopPromptInvocationId:A,onToggleStopConfirm:G=>M(oe=>oe===G?null:G)}),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??i("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:i(a?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:fe.map((G,oe)=>{const we=_.includes(G.id),Y=oe===d;return t.jsxs("button",{type:"button",onMouseEnter:()=>h(oe),onMouseDown:te=>{te.preventDefault(),et(G)},className:Z("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",Y?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Lt,{name:G.name,avatar:G.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:G.name}),we&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[G.providerId,G.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Zn,{size:15,className:"text-neutral-400"})]},G.id)})})]}),Ke.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Ke.map(G=>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:["@",G.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:G.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>De(G.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:i("Remove mention"),"aria-label":`${i("Remove mention")} ${G.name}`,children:t.jsx(Wt,{size:12})})]},G.id))}),t.jsx(Zr,{files:F,onRemove:T}),t.jsx("textarea",{ref:I,value:v,rows:g?1:void 0,onChange:re,onKeyDown:Ae,onPaste:je,onClick:G=>$e(v,G.currentTarget.selectionStart),onSelect:G=>$e(v,G.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:Z("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",g?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:g?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Z("flex items-center justify-between",g?"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:L,type:"file",multiple:!0,className:"hidden",onChange:ye}),t.jsx("button",{type:"button",onClick:()=>L.current?.click(),title:i("Upload file"),"aria-label":i("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(zr,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{x(G=>!G),f(null),requestAnimationFrame(()=>I.current?.focus())},disabled:Ke.length===0&&Q.length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:Z("rounded-lg transition-colors",g?"p-1.5":"p-2",S?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Ke.length===0&&Q.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Zn,{size:g?15:18})}),Ke.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Ke.length," ",i("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Le()},disabled:r||k||X||!v.trim()&&!U,title:i(X?"Uploading...":k?"发送中...":"发送"),"aria-label":i(X?"Uploading...":k?"发送中...":"发送"),className:Z("rounded-lg transition-all duration-200",g?"p-1.5":"p-2",(v.trim()||U)&&!r&&!k&&!X?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",k||X?"opacity-70":""),children:t.jsx(Wr,{size:g?15:18})})]}),C&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:C})]})]})})]})}function Sm(e){return e?e.slice(0,8):""}function yo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Nn(e){return e?.workspaceKind===lt.MAIN_DIRECTORY}function ds(e){return e?Nn(e)?"Project directory":e.branchName:"—"}function Jt(e){return e?.workingDir||e?.worktreePath||void 0}function Rn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),m=s?.mainWorkspaceId??null;return e.map(p=>{const g=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(m&&p.id===m),l=i?"main":p.parentWorkspaceId?"child":"root",u=n?.name??(p.ownerMemberId?`Member ${Sm(p.ownerMemberId)}`:void 0),c=Nn(p)?"Project directory":i?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:g?ds(g):void 0,isMain:i}}).sort((p,g)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(p)-n(g);return i!==0?i:yo(p.workspace.createdAt)-yo(g.workspace.createdAt)})}function pl(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===Mt.ACTIVE)?.id??e[0]?.id}function gl(e,s){return!e||e.status!==Mt.ACTIVE||Nn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function vl(e,s,r){return e?.parentWorkspaceId?s?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Tn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},wm=[{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:"合并工作区"}],xl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Cm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],bl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],km=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Os(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Tn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function gs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Tn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function yi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Tn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Em(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function jm(e){return{name:e.name.trim(),aliases:Em(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 So(e,s){return e instanceof Error?e.message:s}function wo(e){return e.membershipStatus!=="REMOVED"}function Ki(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Co(e){return Ki(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function ko(e){return xl.find(s=>s.value===e)?.label??e}function Nm(e){return bl.find(s=>s.value===e)?.label??e}function Ft({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Eo({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 Rm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=le(),{data:m=[]}=_a(),{data:p=[]}=js(),g=sd(r.id),n=rd(r.id),i=id(r.id),l=y.useRef(!1),[u,c]=y.useState("edit"),[v,b]=y.useState(null),[S,x]=y.useState(""),[a,f]=y.useState(Os()),[d,h]=y.useState(null),[_,w]=y.useState(null),k=r.members??[],j=y.useMemo(()=>k.filter(wo),[k]),C=y.useMemo(()=>_&&wo(_)&&!j.some(W=>W.id===_.id)?[...j,_]:j,[_,j]),E=v?j.find(W=>W.id===v)??null:null,N=_?.id===v?_:E,D=S?m.find(W=>W.id===S)??null:null,A=g.isPending||n.isPending||i.isPending,M=C.filter(Ki).length,I=y.useMemo(()=>{const W=p.map(({provider:R,availability:z})=>({value:R.id,label:R.name+(z.type==="NOT_FOUND"?o(" (不可用)"):""),disabled:z.type==="NOT_FOUND"}));return a.providerId&&!W.some(R=>R.value===a.providerId)&&W.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),W},[a.providerId,p,o]);y.useEffect(()=>{if(!e){l.current=!1,w(null);return}if(l.current)return;l.current=!0;const W=C[0]??null;c(W?"edit":"add-preset"),b(W?.id??null),x(""),f(W?gs(W):Os()),h(null)},[C,e]),y.useEffect(()=>{_&&j.some(W=>W.id===_.id)&&w(null)},[_,j]),y.useEffect(()=>{u==="add-preset"&&D&&f(yi(D))},[u,D]);const L=(W,R)=>{f(z=>({...z,[W]:R}))},F=(W,R)=>{f(z=>({...z,capabilities:{...z.capabilities,[W]:R}}))},H=W=>{c("edit"),b(W.id),x(""),f(gs(W))},T=()=>{c("add-preset"),b(null);const W=D??m[0]??null;x(W?.id??""),f(W?yi(W):Os())},O=()=>{c("add-custom"),b(null),x(""),f(Os())},P=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),B=u==="add-preset"?!!S:u==="edit"?!!(N&&P):P,$=async()=>{try{if(u==="add-preset"){if(!S)return;const R=await g.mutateAsync({memberPresetId:S});ut.success(o("Member added")),w(R),c("edit"),b(R.id),x(""),f(gs(R));return}const W=jm(a);if(!W.name||!W.providerId||!W.rolePrompt){ut.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const R=await g.mutateAsync({member:W});ut.success(o("Member added")),w(R),c("edit"),b(R.id),f(gs(R));return}if(N){const R=await n.mutateAsync({memberId:N.id,data:W});ut.success(o("Member updated")),w(z=>z?.id===R.id?R:z),b(R.id),f(gs(R))}}catch(W){ut.error(So(W,o("Failed to save member")))}},X=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),v===d.id){const W=C.find(R=>R.id!==d.id)??null;b(W?.id??null),c(W?"edit":"add-preset"),f(W?gs(W):Os())}w(W=>W?.id===d.id?null:W),h(null),ut.success(o("Member removed"))}catch(W){ut.error(So(W,o("Failed to remove member")))}},U=()=>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(ur,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:A,children:[t.jsx(eo,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:m.length===0?t.jsx(Eo,{icon:t.jsx(ur,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:A,children:[t.jsx(Ut,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:m.map(W=>{const R=S===W.id;return t.jsxs("button",{type:"button",onClick:()=>{x(W.id),f(yi(W))},className:Z("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",R?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Lt,{name:W.name,avatar:W.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:W.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:W.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(ko(W.workspacePolicy))," · ",o(Nm(W.sessionPolicy))]})]}),R?t.jsx(yt,{size:16,className:"shrink-0 text-neutral-900"}):null]},W.id)})})})]}),K=()=>{const W=u==="edit";return W&&!N?t.jsx("div",{className:"p-5",children:t.jsx(Eo,{icon:t.jsx(cs,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:A,children:[t.jsx(Ut,{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:[W?t.jsx(Ba,{size:15,className:"text-neutral-500"}):t.jsx(Ut,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(W?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(W?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),W&&N?t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>h(N),disabled:A,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(Me,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:A,children:[t.jsx(ur,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[W&&N?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(Lt,{name:N.name,avatar:N.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:Z("h-2 w-2 shrink-0 rounded-full",Co(N))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:N.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[N.providerId," · ",o(ko(N.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(Ft,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:R=>L("name",R.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(Ft,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:R=>L("aliasesText",R.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("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Provider")}),t.jsx(as,{value:a.providerId,onChange:R=>L("providerId",R),options:I})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:R=>L("avatar",R.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(Ft,{children:o("Workspace policy")}),t.jsx(as,{value:a.workspacePolicy,onChange:R=>L("workspacePolicy",R),options:xl.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Trigger policy")}),t.jsx(as,{value:a.triggerPolicy,onChange:R=>L("triggerPolicy",R),options:Cm.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Session policy")}),t.jsx(as,{value:a.sessionPolicy,onChange:R=>L("sessionPolicy",R),options:bl.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Queue policy")}),t.jsx(as,{value:a.queueManagementPolicy,onChange:R=>L("queueManagementPolicy",R),options:km.map(R=>({value:R.value,label:o(R.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:R=>L("rolePrompt",R.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(Ft,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:wm.map(R=>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:!!a.capabilities[R.key],onChange:z=>F(R.key,z.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(R.label)})]},R.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Es,{isOpen:e,onClose:A?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:A,children:o("Close")}),t.jsx(Me,{type:"button",onClick:$,disabled:A||!B,children:o(A?"Processing...":u==="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(cs,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[C.length," ",o("active")," · ",M," ",o("working")]})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"outline",onClick:T,disabled:A,title:o("Add member"),children:t.jsx(Ut,{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:C.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:C.map(W=>{const R=u==="edit"&&v===W.id;return t.jsxs("button",{type:"button",onClick:()=>H(W),className:Z("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",R?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Lt,{name:W.name,avatar:W.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:Z("h-1.5 w-1.5 shrink-0 rounded-full",Co(W))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:W.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:W.providerId})]}),t.jsx(uu,{size:13,className:Z("shrink-0 text-neutral-300 transition-opacity",R?"opacity-100":"opacity-0 group-hover:opacity-100")})]},W.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:T,disabled:A,className:Z("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",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(ur,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:A,className:Z("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",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(eo,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?U():K()})]})}),t.jsx(Fr,{isOpen:!!d,onClose:()=>h(null),onConfirm:X,title:o("Remove member"),variant:"danger",isLoading:i.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&&Ki(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(Hr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Tm=[],Am=[],Mm=[],Dm=240;function Lm(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 jo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Si(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 No(e,s){return e instanceof Error?e.message:s}function Pm(e,s=Dm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function fr(e){return e?e.instructionPreview??Pm(e.instruction):""}function Om(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 Im(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 Bm(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 Fm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function zm(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 Hm(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Wm(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 $m(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Um(e,s){return s.find(r=>r.memberId===e.id&&Jr.has(r.status))}function _l({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:m}){const{t:p}=le(),g=va(e.id),n=xa(e.id),i=ba(e.id),[l,u]=y.useState(null),[c,v]=y.useState(null),[b,S]=y.useState(!1),[x,a]=y.useState(!1),f=e.members??Tm,d=y.useMemo(()=>f.filter(L=>L.membershipStatus!=="REMOVED"),[f]),h=e.workRequests??Am,_=e.invocations??Mm,w=y.useMemo(()=>Rn(s,e),[e,s]),k=y.useMemo(()=>new Map(h.map(L=>[L.id,L])),[h]),j=y.useMemo(()=>[...h].filter(L=>L.status==="PENDING_APPROVAL").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[h]),C=y.useMemo(()=>[...h].filter(L=>L.status==="QUEUED").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[h]),E=y.useMemo(()=>[...f].map(L=>({member:L,status:Lm(L.status)})).sort((L,F)=>jo[L.status]-jo[F.status]),[f]),N=g.isError?g.error:n.isError?n.error:null,D=g.isPending||n.isPending,A=w.find(L=>L.workspace.id===r),M=e.messages??[],I=E.filter(({status:L})=>L==="running"||L==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Rm,{isOpen:x,onClose:()=>a(!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(Cs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("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:p("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:p("Messages"),children:[t.jsx(an,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:M.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[t.jsx(cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:I>0?`${I}/${d.length}`:d.length}),I>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),C.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(bs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:C.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(bs,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.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(bs,{size:13}),t.jsx("span",{children:p("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:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(L=>{const F=f.find(O=>O.id===L.targetMemberId),H=g.isPending&&g.variables===L.id,T=n.isPending&&n.variables===L.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(Lt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:fr(L)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(Fm(L.requesterType))}),t.jsx("span",{children:Si(L.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>g.mutate(L.id),disabled:D,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(yt,{size:11}),t.jsx("span",{className:"truncate",children:p(H?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(L.id),disabled:D,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(Wt,{size:11}),t.jsx("span",{className:"truncate",children:p(T?"Rejecting":"Reject")})]})]})]},L.id)})}),N&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(N,p("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(cs,{size:13}),t.jsx("span",{children:p("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(Ba,{size:13})})]}),f.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:L,status:F})=>{const H=Um(L,_),T=$m(_.filter(K=>K.memberId===L.id)),O=H?k.get(H.workRequestId):void 0,P=c===L.id,B=F==="running"||F==="waiting room reply",$=B&&!!H,X=l===L.id,U=i.isPending&&i.variables?.memberId===L.id;return t.jsxs("div",{className:Z("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Lt,{name:L.name,avatar:L.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:Z("h-1.5 w-1.5 shrink-0 rounded-full",Bm(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:L.name}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Im(F)),children:p(Om(F))})]}),B&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:fr(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(X?null:L.id),disabled:i.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:p("Stop"),"aria-label":p("Stop"),children:t.jsx(ws,{size:12})}),H?.sessionId&&m&&t.jsx("button",{type:"button",onClick:()=>m(H.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(kr,{size:12})}),t.jsx("button",{type:"button",onClick:()=>v(P?null:L.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":P,children:P?t.jsx(ht,{size:13}):t.jsx(Ot,{size:13})})]})]}),$&&X&&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:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:i.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(ws,{size:10}),t.jsx("span",{children:U&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:i.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(Oa,{size:10}),t.jsx("span",{children:U&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),P&&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:L.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.sessionPolicy==="resume_last"?p("Resume last session"):p("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:p("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:T.length})]}),T.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:T.map(K=>{const W=k.get(K.workRequestId),R=!!(K.sessionId&&m);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:Z("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",zm(K.status)),children:K.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Si(K.updatedAt??K.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:fr(W)||K.workRequestId})]}),R&&t.jsxs("button",{type:"button",onClick:()=>K.sessionId&&m?.(K.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:p("View log"),"aria-label":p("View log"),children:[t.jsx(kr,{size:10}),t.jsx("span",{children:p("Log")})]})]})},K.id)})})]}),E[E.length-1]?.member.id!==L.id&&!P&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},L.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(i.error,p("Failed to stop member work"))})]}),C.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(bs,{size:13}),t.jsx("span",{children:p("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:C.length})]}),t.jsx("div",{className:"space-y-1",children:C.map(L=>{const F=f.find(H=>H.id===L.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(Lt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:fr(L)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Si(L.createdAt)})]})},L.id)})})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>S(L=>!L),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":b,"aria-label":p("Workspaces"),children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[A&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:ds(A.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:w.length}),b?t.jsx(ht,{size:13,className:"text-neutral-400"}):t.jsx(Ot,{size:13,className:"text-neutral-400"})]})]}),b&&t.jsx("div",{className:"space-y-1.5",children:w.map(L=>{const F=r===L.workspace.id;return t.jsx("div",{className:Z("rounded-md border bg-white px-3 py-2",F?"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:p(L.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Wm(L.roleLabel)),children:p(L.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Hm(L.workspace.status)),children:L.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:ds(L.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:[L.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",L.ownerName]}),L.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",L.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(L.workspace.id),disabled:!o||F,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:p("View workspace"),children:[F?t.jsx(yt,{size:11}):t.jsx(un,{size:11}),t.jsx("span",{children:p(F?"Selected":"Select")})]})]})},L.workspace.id)})})]}),j.length===0&&C.length===0&&E.every(({status:L})=>L==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var wi={exports:{}},Ro;function qm(){return Ro||(Ro=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(g,n,i){var l=this&&this.__decorate||function(h,_,w,k){var j,C=arguments.length,E=C<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,_,w,k);else for(var N=h.length-1;N>=0;N--)(j=h[N])&&(E=(C<3?j(E):C>3?j(_,w,E):j(_,w))||E);return C>3&&E&&Object.defineProperty(_,w,E),E},u=this&&this.__param||function(h,_){return function(w,k){_(w,k,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),v=i(6114),b=i(9924),S=i(844),x=i(5596),a=i(4725),f=i(3656);let d=n.AccessibilityManager=class extends S.Disposable{constructor(h,_){super(),this._terminal=h,this._renderService=_,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 w=0;w<this._terminal.rows;w++)this._rowElements[w]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[w]);if(this._topBoundaryFocusListener=w=>this._handleBoundaryFocus(w,0),this._bottomBoundaryFocusListener=w=>this._handleBoundaryFocus(w,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 b.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((w=>this._handleResize(w.rows)))),this.register(this._terminal.onRender((w=>this._refreshRows(w.start,w.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((w=>this._handleChar(w)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
-
`)))),this.register(this._terminal.onA11yTab((w=>this._handleTab(w)))),this.register(this._terminal.onKey((w=>this._handleKey(w.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new x.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,f.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(h){for(let _=0;_<h;_++)this._handleChar(" ")}_handleChar(h){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==h&&(this._charsToAnnounce+=h):this._charsToAnnounce+=h,h===`
|
|
21
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),v.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,v.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,_){this._liveRegionDebouncer.refresh(h,_,this._terminal.rows)}_renderRows(h,_){const w=this._terminal.buffer,k=w.lines.length.toString();for(let j=h;j<=_;j++){const C=w.translateBufferLineToString(w.ydisp+j,!0),E=(w.ydisp+j+1).toString(),N=this._rowElements[j];N&&(C.length===0?N.innerText=" ":N.textContent=C,N.setAttribute("aria-posinset",E),N.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,_){const w=h.target,k=this._rowElements[_===0?1:this._rowElements.length-2];if(w.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==k)return;let j,C;if(_===0?(j=w,C=this._rowElements.pop(),this._rowContainer.removeChild(C)):(j=this._rowElements.shift(),C=w,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),C.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_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 h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(g,n)=>{function i(v){return v.replace(/\r?\n/g,"\r")}function l(v,b){return b?"\x1B[200~"+v+"\x1B[201~":v}function u(v,b,S,x){v=l(v=i(v),S.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(v,!0),b.value=""}function c(v,b,S){const x=S.getBoundingClientRect(),a=v.clientX-x.left-10,f=v.clientY-x.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${a}px`,b.style.top=`${f}px`,b.style.zIndex="1000",b.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=l,n.copyHandler=function(v,b){v.clipboardData&&v.clipboardData.setData("text/plain",b.selectionText),v.preventDefault()},n.handlePasteEvent=function(v,b,S,x){v.stopPropagation(),v.clipboardData&&u(v.clipboardData.getData("text/plain"),b,S,x)},n.paste=u,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(v,b,S,x,a){c(v,b,S),a&&x.rightClickSelect(v),b.value=x.selectionText,b.select()}},7239:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const l=i(1505);n.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(u,c,v){this._css.set(u,c,v)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,v){this._color.set(u,c,v)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,l,u,c){i.addEventListener(l,u,c);let v=!1;return{dispose:()=>{v||(v=!0,i.removeEventListener(l,u,c))}}}},6465:function(g,n,i){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),v=i(8460),b=i(844),S=i(2585);let x=n.Linkifier2=class extends b.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new v.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new v.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,b.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,b.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const f=this._linkProviders.indexOf(a);f!==-1&&this._linkProviders.splice(f,1)}}}attachToDom(a,f,d){this._element=a,this._mouseService=f,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(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const f=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const d=a.composedPath();for(let h=0;h<d.length;h++){const _=d[h];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,f){var d,h;this._activeProviderReplies&&f||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((w=>{w?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let _=!1;for(const[w,k]of this._linkProviders.entries())f?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(w)&&(_=this._checkLinkProviderResult(w,a,_)):k.provideLinks(a.y,(j=>{var C,E;if(this._isMouseOut)return;const N=j?.map((D=>({link:D})));(C=this._activeProviderReplies)===null||C===void 0||C.set(w,N),_=this._checkLinkProviderResult(w,a,_),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,f){const d=new Set;for(let h=0;h<f.size;h++){const _=f.get(h);if(_)for(let w=0;w<_.length;w++){const k=_[w],j=k.link.range.start.y<a?0:k.link.range.start.x,C=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=C;E++){if(d.has(E)){_.splice(w--,1);break}d.add(E)}}}}_checkLinkProviderResult(a,f,d){var h;if(!this._activeProviderReplies)return d;const _=this._activeProviderReplies.get(a);let w=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(w=!0);if(!w&&_){const k=_.find((j=>this._linkAtPosition(j.link,f)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const j=(h=this._activeProviderReplies.get(k))===null||h===void 0?void 0:h.find((C=>this._linkAtPosition(C.link,f)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const f=this._positionFromMouseEvent(a,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,f){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!f||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,b.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(a.link,f)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,h;return(h=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:d=>{var h,_;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,h;return(h=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||h===void 0?void 0:h.decorations.underline},set:d=>{var h,_,w;!((h=this._currentLink)===null||h===void 0)&&h.state&&((w=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||w===void 0?void 0:w.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const h=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(h,_),this._lastMouseEvent&&this._element)){const w=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);w&&this._askForLink(w,!1)}}))))}_linkHover(a,f,d){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(d,f.text)}_fireUnderlineEvent(a,f){const d=a.range,h=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-h-1,d.end.x,d.end.y-h-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(a,f,d){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(d,f.text)}_linkAtPosition(a,f){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,h=a.range.end.y*this._bufferService.cols+a.range.end.x,_=f.y*this._bufferService.cols+f.x;return d<=_&&_<=h}_positionFromMouseEvent(a,f,d){const h=d.getCoords(a,f,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,f,d,h,_){return{x1:a,y1:f,x2:d,y2:h,cols:this._bufferService.cols,fg:_}}};n.Linkifier2=x=l([u(0,S.IBufferService)],x)},9042:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(g,n,i){var l=this&&this.__decorate||function(x,a,f,d){var h,_=arguments.length,w=_<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,f,d);else for(var k=x.length-1;k>=0;k--)(h=x[k])&&(w=(_<3?h(w):_>3?h(a,f,w):h(a,f))||w);return _>3&&w&&Object.defineProperty(a,f,w),w},u=this&&this.__param||function(x,a){return function(f,d){a(f,d,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),v=i(2585);let b=n.OscLinkProvider=class{constructor(x,a,f){this._bufferService=x,this._optionsService=a,this._oscLinkService=f}provideLinks(x,a){var f;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const h=[],_=this._optionsService.rawOptions.linkHandler,w=new c.CellData,k=d.getTrimmedLength();let j=-1,C=-1,E=!1;for(let N=0;N<k;N++)if(C!==-1||d.hasContent(N)){if(d.loadCell(N,w),w.hasExtendedAttrs()&&w.extended.urlId){if(C===-1){C=N,j=w.extended.urlId;continue}E=w.extended.urlId!==j}else C!==-1&&(E=!0);if(E||C!==-1&&N===k-1){const D=(f=this._oscLinkService.getLinkData(j))===null||f===void 0?void 0:f.uri;if(D){const A={start:{x:C+1,y:x},end:{x:N+(E||N!==k-1?0:1),y:x}};let M=!1;if(!_?.allowNonHttpProtocols)try{const I=new URL(D);["http:","https:"].includes(I.protocol)||(M=!0)}catch{M=!0}M||h.push({text:D,range:A,activate:(I,L)=>_?_.activate(I,L,A):S(0,L),hover:(I,L)=>{var F;return(F=_?.hover)===null||F===void 0?void 0:F.call(_,I,L,A)},leave:(I,L)=>{var F;return(F=_?.leave)===null||F===void 0?void 0:F.call(_,I,L,A)}})}E=!1,w.hasExtendedAttrs()&&w.extended.urlId?(C=N,j=w.extended.urlId):(C=-1,j=-1)}}a(h)}};function S(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
|
-
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=b=l([u(0,v.IBufferService),u(1,v.IOptionsService),u(2,v.IOscLinkService)],b)},6193:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,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 i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class u extends l.Disposable{constructor(v){super(),this._parentWindow=v,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(v){this._listener&&this.clearListener(),this._listener=v,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var v;this._outerListener&&((v=this._resolutionMediaMatchList)===null||v===void 0||v.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)}}n.ScreenDprMonitor=u},3236:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),u=i(3656),c=i(6465),v=i(9042),b=i(3730),S=i(1680),x=i(3107),a=i(5744),f=i(2950),d=i(1296),h=i(428),_=i(4269),w=i(5114),k=i(8934),j=i(3230),C=i(9312),E=i(4725),N=i(6731),D=i(8055),A=i(8969),M=i(8460),I=i(844),L=i(6114),F=i(8437),H=i(2584),T=i(7399),O=i(5941),P=i(9074),B=i(2585),$=i(5435),X=i(4567),U=typeof window<"u"?window.document:null;class K extends A.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(R={}){super(R),this.browser=L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((z,V)=>this.refresh(z,V)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((z=>this._reportWindowsOptions(z)))),this.register(this._inputHandler.onColor((z=>this._handleColorEvent(z)))),this.register((0,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((z=>this._afterResize(z.cols,z.rows)))),this.register((0,I.toDisposable)((()=>{var z,V;this._customKeyEventHandler=void 0,(V=(z=this.element)===null||z===void 0?void 0:z.parentNode)===null||V===void 0||V.removeChild(this.element)})))}_handleColorEvent(R){if(this._themeService)for(const z of R){let V,q="";switch(z.index){case 256:V="foreground",q="10";break;case 257:V="background",q="11";break;case 258:V="cursor",q="12";break;default:V="ansi",q="4;"+z.index}switch(z.type){case 0:const se=D.color.toColorRGB(V==="ansi"?this._themeService.colors.ansi[z.index]:this._themeService.colors[V]);this.coreService.triggerDataEvent(`${H.C0.ESC}]${q};${(0,O.toRgbString)(se)}${H.C1_ESCAPED.ST}`);break;case 1:if(V==="ansi")this._themeService.modifyColors((Q=>Q.ansi[z.index]=D.rgba.toColor(...z.color)));else{const Q=V;this._themeService.modifyColors((ee=>ee[Q]=D.rgba.toColor(...z.color)))}break;case 2:this._themeService.restoreColor(z.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(R){R?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(R){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[I"),this.updateCursorStyle(R),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var R;return(R=this.textarea)===null||R===void 0?void 0:R.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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 R=this.buffer.ybase+this.buffer.y,z=this.buffer.lines.get(R);if(!z)return;const V=Math.min(this.buffer.x,this.cols-1),q=this._renderService.dimensions.css.cell.height,se=z.getWidth(V),Q=this._renderService.dimensions.css.cell.width*se,ee=this.buffer.y*this._renderService.dimensions.css.cell.height,be=V*this._renderService.dimensions.css.cell.width;this.textarea.style.left=be+"px",this.textarea.style.top=ee+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=q+"px",this.textarea.style.lineHeight=q+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(z=>{this.hasSelection()&&(0,l.copyHandler)(z,this._selectionService)})));const R=z=>(0,l.handlePasteEvent)(z,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",R)),this.register((0,u.addDisposableDomListener)(this.element,"paste",R)),L.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(z=>{z.button===2&&(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(z=>{(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),L.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(z=>{z.button===1&&(0,l.moveTextAreaUnderMouseCursor)(z,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(R=>this._keyUp(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(R=>this._keyDown(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(R=>this._keyPress(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(R=>this._compositionHelper.compositionupdate(R)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(R=>this._inputEvent(R)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(R){var z;if(!R)throw new Error("Terminal requires a parent element.");R.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=R.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),R.appendChild(this.element);const V=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),V.appendChild(this._viewportElement),this._viewportScrollArea=U.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=U.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=U.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),V.appendChild(this.screenElement),this.textarea=U.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",v.promptLabel),L.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(w.CoreBrowserService,this.textarea,(z=this._document.defaultView)!==null&&z!==void 0?z:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(q=>this._handleTextAreaFocus(q)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((q=>this._onRender.fire(q)))),this.onResize((q=>this._renderService.resize(q.cols,q.rows))),this._compositionView=U.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(f.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(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((q=>this.scrollLines(q.amount,q.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(C.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((q=>this.scrollLines(q.amount,q.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((q=>this._renderService.handleSelectionChanged(q.start,q.end,q.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((q=>{this.textarea.value=q,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((q=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(q=>this._selectionService.handleMouseDown(q)))),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(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(q=>this._handleScreenReaderModeOptionChange(q)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(q=>{!this._overviewRulerRenderer&&q&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.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 R=this,z=this.element;function V(Q){const ee=R._mouseService.getMouseReportCoords(Q,R.screenElement);if(!ee)return!1;let be,Ce;switch(Q.overrideType||Q.type){case"mousemove":Ce=32,Q.buttons===void 0?(be=3,Q.button!==void 0&&(be=Q.button<3?Q.button:3)):be=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":Ce=0,be=Q.button<3?Q.button:3;break;case"mousedown":Ce=1,be=Q.button<3?Q.button:3;break;case"wheel":if(R.viewport.getLinesScrolled(Q)===0)return!1;Ce=Q.deltaY<0?0:1,be=4;break;default:return!1}return!(Ce===void 0||be===void 0||be>4)&&R.coreMouseService.triggerMouseEvent({col:ee.col,row:ee.row,x:ee.x,y:ee.y,button:be,action:Ce,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const q={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:Q=>(V(Q),Q.buttons||(this._document.removeEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.removeEventListener("mousemove",q.mousedrag)),this.cancel(Q)),wheel:Q=>(V(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&V(Q)},mousemove:Q=>{Q.buttons||V(Q)}};this.register(this.coreMouseService.onProtocolChange((Q=>{Q?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Q)),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&Q?q.mousemove||(z.addEventListener("mousemove",se.mousemove),q.mousemove=se.mousemove):(z.removeEventListener("mousemove",q.mousemove),q.mousemove=null),16&Q?q.wheel||(z.addEventListener("wheel",se.wheel,{passive:!1}),q.wheel=se.wheel):(z.removeEventListener("wheel",q.wheel),q.wheel=null),2&Q?q.mouseup||(z.addEventListener("mouseup",se.mouseup),q.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",q.mouseup),z.removeEventListener("mouseup",q.mouseup),q.mouseup=null),4&Q?q.mousedrag||(q.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",q.mousedrag),q.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(z,"mousedown",(Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return V(Q),q.mouseup&&this._document.addEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.addEventListener("mousemove",q.mousedrag),this.cancel(Q)}))),this.register((0,u.addDisposableDomListener)(z,"wheel",(Q=>{if(!q.wheel){if(!this.buffer.hasScrollback){const ee=this.viewport.getLinesScrolled(Q);if(ee===0)return;const be=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let Ce="";for(let Oe=0;Oe<Math.abs(ee);Oe++)Ce+=be;return this.coreService.triggerDataEvent(Ce,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(z,"touchstart",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(z,"touchmove",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)}),{passive:!1}))}refresh(R,z){var V;(V=this._renderService)===null||V===void 0||V.refreshRows(R,z)}updateCursorStyle(R){var z;!((z=this._selectionService)===null||z===void 0)&&z.shouldColumnSelect(R)?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(R,z,V=0){var q;V===1?(super.scrollLines(R,z,V),this.refresh(0,this.rows-1)):(q=this.viewport)===null||q===void 0||q.scrollLines(R)}paste(R){(0,l.paste)(R,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(R){this._customKeyEventHandler=R}registerLinkProvider(R){return this.linkifier2.registerLinkProvider(R)}registerCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const z=this._characterJoinerService.register(R);return this.refresh(0,this.rows-1),z}deregisterCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(R)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(R){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+R)}registerDecoration(R){return this._decorationService.registerDecoration(R)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(R,z,V){this._selectionService.setSelection(R,z,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 R;(R=this._selectionService)===null||R===void 0||R.clearSelection()}selectAll(){var R;(R=this._selectionService)===null||R===void 0||R.selectAll()}selectLines(R,z){var V;(V=this._selectionService)===null||V===void 0||V.selectLines(R,z)}_keyDown(R){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;const z=this.browser.isMac&&this.options.macOptionIsMeta&&R.altKey;if(!z&&!this._compositionHelper.keydown(R))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;z||R.key!=="Dead"&&R.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const V=(0,T.evaluateKeyboardEvent)(R,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(R),V.type===3||V.type===2){const q=this.rows-1;return this.scrollLines(V.type===2?-q:q),this.cancel(R,!0)}return V.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,R)||(V.cancel&&this.cancel(R,!0),!V.key||!!(R.key&&!R.ctrlKey&&!R.altKey&&!R.metaKey&&R.key.length===1&&R.key.charCodeAt(0)>=65&&R.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(V.key!==H.C0.ETX&&V.key!==H.C0.CR||(this.textarea.value=""),this._onKey.fire({key:V.key,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(V.key,!0),!this.optionsService.rawOptions.screenReaderMode||R.altKey||R.ctrlKey?this.cancel(R,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(R,z){const V=R.isMac&&!this.options.macOptionIsMeta&&z.altKey&&!z.ctrlKey&&!z.metaKey||R.isWindows&&z.altKey&&z.ctrlKey&&!z.metaKey||R.isWindows&&z.getModifierState("AltGraph");return z.type==="keypress"?V:V&&(!z.keyCode||z.keyCode>47)}_keyUp(R){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1||((function(z){return z.keyCode===16||z.keyCode===17||z.keyCode===18})(R)||this.focus(),this.updateCursorStyle(R),this._keyPressHandled=!1)}_keyPress(R){let z;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;if(this.cancel(R),R.charCode)z=R.charCode;else if(R.which===null||R.which===void 0)z=R.keyCode;else{if(R.which===0||R.charCode===0)return!1;z=R.which}return!(!z||(R.altKey||R.ctrlKey||R.metaKey)&&!this._isThirdLevelShift(this.browser,R)||(z=String.fromCharCode(z),this._onKey.fire({key:z,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(z,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(R){if(R.data&&R.inputType==="insertText"&&(!R.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const z=R.data;return this.coreService.triggerDataEvent(z,!0),this.cancel(R),!0}return!1}resize(R,z){R!==this.cols||z!==this.rows?super.resize(R,z):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(R,z){var V,q;(V=this._charSizeService)===null||V===void 0||V.measure(),(q=this.viewport)===null||q===void 0||q.syncScrollArea(!0)}clear(){var R;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 z=1;z<this.rows;z++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(R=this.viewport)===null||R===void 0||R.reset(),this.refresh(0,this.rows-1)}}reset(){var R,z;this.options.rows=this.rows,this.options.cols=this.cols;const V=this._customKeyEventHandler;this._setup(),super.reset(),(R=this._selectionService)===null||R===void 0||R.reset(),this._decorationService.reset(),(z=this.viewport)===null||z===void 0||z.reset(),this._customKeyEventHandler=V,this.refresh(0,this.rows-1)}clearTextureAtlas(){var R;(R=this._renderService)===null||R===void 0||R.clearTextureAtlas()}_reportFocus(){var R;!((R=this.element)===null||R===void 0)&&R.classList.contains("focus")?this.coreService.triggerDataEvent(H.C0.ESC+"[I"):this.coreService.triggerDataEvent(H.C0.ESC+"[O")}_reportWindowsOptions(R){if(this._renderService)switch(R){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const z=this._renderService.dimensions.css.canvas.width.toFixed(0),V=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[4;${V};${z}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const q=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[6;${se};${q}t`)}}cancel(R,z){if(this.options.cancelEvents||z)return R.preventDefault(),R.stopPropagation(),!1}}n.Terminal=K},9924:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,u){this._rowCount=u,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const v=c-this._lastRefreshMs,b=this._debounceThresholdMS-v;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),b)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(g,n,i){var l=this&&this.__decorate||function(f,d,h,_){var w,k=arguments.length,j=k<3?d:_===null?_=Object.getOwnPropertyDescriptor(d,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,h,_);else for(var C=f.length-1;C>=0;C--)(w=f[C])&&(j=(k<3?w(j):k>3?w(d,h,j):w(d,h))||j);return k>3&&j&&Object.defineProperty(d,h,j),j},u=this&&this.__param||function(f,d){return function(h,_){d(h,_,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),v=i(4725),b=i(8460),S=i(844),x=i(2585);let a=n.Viewport=class extends S.Disposable{constructor(f,d,h,_,w,k,j,C){super(),this._viewportElement=f,this._scrollArea=d,this._bufferService=h,this._optionsService=_,this._charSizeService=w,this._renderService=k,this._coreBrowserService=j,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 b.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((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(C.colors),this.register(C.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(f){this._viewportElement.style.backgroundColor=f.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(f){if(f)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 f=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==f&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=f),this._refreshAnimationFrame=null}syncScrollArea(f=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(f);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(f)}_handleScroll(f){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 f=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(f*(this._smoothScrollState.target-this._smoothScrollState.origin)),f<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(f,d){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&h<this._lastRecordedBufferHeight)||(f.cancelable&&f.preventDefault(),!1)}handleWheel(f){const d=this._getPixelsScrolled(f);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(f,d))}scrollLines(f){if(f!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=f*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:f,suppressScrollEvent:!1})}_getPixelsScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let d=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(f,d){var h;let _,w="";const k=[],j=d??this._bufferService.buffer.lines.length,C=this._bufferService.buffer.lines;for(let E=f;E<j;E++){const N=C.get(E);if(!N)continue;const D=(h=C.get(E+1))===null||h===void 0?void 0:h.isWrapped;if(w+=N.translateToString(!D),!D||E===C.length-1){const A=document.createElement("div");A.textContent=w,k.push(A),w.length>0&&(_=A),w=""}}return{bufferElements:k,cursorElement:_}}getLinesScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let d=this._applyScrollModifier(f.deltaY,f);return f.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):f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(f,d){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&d.altKey||h==="ctrl"&&d.ctrlKey||h==="shift"&&d.shiftKey?f*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:f*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(f){this._lastTouchY=f.touches[0].pageY}handleTouchMove(f){const d=this._lastTouchY-f.touches[0].pageY;return this._lastTouchY=f.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(f,d))}};n.Viewport=a=l([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,v.ICharSizeService),u(5,v.IRenderService),u(6,v.ICoreBrowserService),u(7,v.IThemeService)],a)},3107:function(g,n,i){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),v=i(4725),b=i(844),S=i(2585);let x=n.BufferDecorationRenderer=class extends b.Disposable{constructor(a,f,d,h){super(),this._screenElement=a,this._bufferService=f,this._decorationService=d,this._renderService=h,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((_=>this._removeDecoration(_)))),this.register((0,b.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 a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var f,d;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((f=a?.options)===null||f===void 0?void 0:f.layer)==="top"),h.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=(d=a.options.x)!==null&&d!==void 0?d:0;return _&&_>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(a,h),h}_refreshStyle(a){const f=a.marker.line-this._bufferService.buffers.active.ydisp;if(f<0||f>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=f*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,f=a.element){var d;if(!f)return;const h=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?f.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":f.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var f;(f=this._decorationElements.get(a))===null||f===void 0||f.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=x=l([u(1,S.IBufferService),u(2,S.IDecorationService),u(3,v.IRenderService)],x)},5871:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.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(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,u){return l>=i.startBufferLine-this._linePadding[u||"full"]&&l<=i.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(g,n,i){var l=this&&this.__decorate||function(_,w,k,j){var C,E=arguments.length,N=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,w,k,j);else for(var D=_.length-1;D>=0;D--)(C=_[D])&&(N=(E<3?C(N):E>3?C(w,k,N):C(w,k))||N);return E>3&&N&&Object.defineProperty(w,k,N),N},u=this&&this.__param||function(_,w){return function(k,j){w(k,j,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),v=i(3656),b=i(4725),S=i(844),x=i(2585),a={full:0,left:0,center:0,right:0},f={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let h=n.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,w,k,j,C,E,N){var D;super(),this._viewportElement=_,this._screenElement=w,this._bufferService=k,this._decorationService=j,this._renderService=C,this._optionsService=E,this._coreBrowseService=N,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(),(D=this._viewportElement.parentElement)===null||D===void 0||D.insertBefore(this._canvas,this._viewportElement);const A=this._canvas.getContext("2d");if(!A)throw new Error("Ctx cannot be null");this._ctx=A,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,S.toDisposable)((()=>{var M;(M=this._canvas)===null||M===void 0||M.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,v.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),w=Math.ceil(this._canvas.width/3);f.full=this._canvas.width,f.left=_,f.center=w,f.right=_,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=f.left,d.right=f.left+f.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,w=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);a.left=w,a.center=w,a.right=w}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.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 w of this._decorationService.decorations)this._colorZoneStore.addDecoration(w);this._ctx.lineWidth=1;const _=this._colorZoneStore.zones;for(const w of _)w.position!=="full"&&this._renderColorZone(w);for(const w of _)w.position==="full"&&this._renderColorZone(w);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(d[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-a[_.position||"full"]/2),f[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[_.position||"full"]))}_queueRefresh(_,w){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=w||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=h=l([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,b.IRenderService),u(5,x.IOptionsService),u(6,b.ICoreBrowserService)],h)},2950:function(g,n,i){var l=this&&this.__decorate||function(x,a,f,d){var h,_=arguments.length,w=_<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,f,d);else for(var k=x.length-1;k>=0;k--)(h=x[k])&&(w=(_<3?h(w):_>3?h(a,f,w):h(a,f))||w);return _>3&&w&&Object.defineProperty(a,f,w),w},u=this&&this.__param||function(x,a){return function(f,d){a(f,d,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),v=i(2585),b=i(2584);let S=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,f,d,h,_){this._textarea=x,this._compositionView=a,this._bufferService=f,this._optionsService=d,this._coreService=h,this._renderService=_,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(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let f;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,f=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),f.length>0&&this._coreService.triggerDataEvent(f,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,f=a.replace(x,"");this._dataAlreadySent=f,a.length>x.length?this._coreService.triggerDataEvent(f,!0):a.length<x.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),f=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=f+"px",this._compositionView.style.lineHeight=f+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=S=l([u(2,v.IBufferService),u(3,v.IOptionsService),u(4,v.ICoreService),u(5,c.IRenderService)],S)},9806:(g,n)=>{function i(l,u,c){const v=c.getBoundingClientRect(),b=l.getComputedStyle(c),S=parseInt(b.getPropertyValue("padding-left")),x=parseInt(b.getPropertyValue("padding-top"));return[u.clientX-v.left-S,u.clientY-v.top-x]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,u,c,v,b,S,x,a,f){if(!S)return;const d=i(l,u,c);return d?(d[0]=Math.ceil((d[0]+(f?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),v+(f?1:0)),d[1]=Math.min(Math.max(d[1],1),b),d):void 0}},9504:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function u(a,f,d,h){const _=a-c(a,d),w=f-c(f,d),k=Math.abs(_-w)-(function(j,C,E){let N=0;const D=j-c(j,E),A=C-c(C,E);for(let M=0;M<Math.abs(D-A);M++){const I=v(j,C)==="A"?-1:1,L=E.buffer.lines.get(D+I*M);L?.isWrapped&&N++}return N})(a,f,d);return x(k,S(v(a,f),h))}function c(a,f){let d=0,h=f.buffer.lines.get(a),_=h?.isWrapped;for(;_&&a>=0&&a<f.rows;)d++,h=f.buffer.lines.get(--a),_=h?.isWrapped;return d}function v(a,f){return a>f?"A":"B"}function b(a,f,d,h,_,w){let k=a,j=f,C="";for(;k!==d||j!==h;)k+=_?1:-1,_&&k>w.cols-1?(C+=w.buffer.translateBufferLineToString(j,!1,a,k),k=0,a=0,j++):!_&&k<0&&(C+=w.buffer.translateBufferLineToString(j,!1,0,a+1),k=w.cols-1,a=k,j--);return C+w.buffer.translateBufferLineToString(j,!1,a,k)}function S(a,f){const d=f?"O":"[";return l.C0.ESC+d+a}function x(a,f){a=Math.floor(a);let d="";for(let h=0;h<a;h++)d+=f;return d}n.moveToCellSequence=function(a,f,d,h){const _=d.buffer.x,w=d.buffer.y;if(!d.buffer.hasScrollback)return(function(C,E,N,D,A,M){return u(E,D,A,M).length===0?"":x(b(C,E,C,E-c(E,A),!1,A).length,S("D",M))})(_,w,0,f,d,h)+u(w,f,d,h)+(function(C,E,N,D,A,M){let I;I=u(E,D,A,M).length>0?D-c(D,A):E;const L=D,F=(function(H,T,O,P,B,$){let X;return X=u(O,P,B,$).length>0?P-c(P,B):T,H<O&&X<=P||H>=O&&X<P?"C":"D"})(C,E,N,D,A,M);return x(b(C,I,N,L,F==="C",A).length,S(F,M))})(_,w,a,f,d,h);let k;if(w===f)return k=_>a?"D":"C",x(Math.abs(_-a),S(k,h));k=w>f?"D":"C";const j=Math.abs(w-f);return x((function(C,E){return E.cols-C})(w>f?a:_,d)+(j-1)*d.cols+1+((w>f?_:a)-1),S(k,h))}},1296:function(g,n,i){var l=this&&this.__decorate||function(A,M,I,L){var F,H=arguments.length,T=H<3?M:L===null?L=Object.getOwnPropertyDescriptor(M,I):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(A,M,I,L);else for(var O=A.length-1;O>=0;O--)(F=A[O])&&(T=(H<3?F(T):H>3?F(M,I,T):F(M,I))||T);return H>3&&T&&Object.defineProperty(M,I,T),T},u=this&&this.__param||function(A,M){return function(I,L){M(I,L,A)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),v=i(2550),b=i(2223),S=i(6171),x=i(4725),a=i(8055),f=i(8460),d=i(844),h=i(2585),_="xterm-dom-renderer-owner-",w="xterm-rows",k="xterm-fg-",j="xterm-bg-",C="xterm-focus",E="xterm-selection";let N=1,D=n.DomRenderer=class extends d.Disposable{constructor(A,M,I,L,F,H,T,O,P,B){super(),this._element=A,this._screenElement=M,this._viewportElement=I,this._linkifier2=L,this._charSizeService=H,this._optionsService=T,this._bufferService=O,this._coreBrowserService=P,this._themeService=B,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(w),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(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new v.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 A=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*A,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*A),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/A),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/A),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 I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${w} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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(A){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${w} { color: ${A.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${w} .xterm-dim { color: ${a.color.multiplyOpacity(A.foreground,.5).css};}`,M+=`${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;}`,M+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",M+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${A.cursor.css}; color: ${A.cursorAccent.css}; } 50% { background-color: inherit; color: ${A.cursor.css}; }}`,M+=`${this._terminalSelector} .${w}.${C} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w}.${C} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-block { background-color: ${A.cursor.css}; color: ${A.cursorAccent.css};}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${A.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${A.cursor.css} inset;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${A.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${A.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${A.selectionInactiveBackgroundOpaque.css};}`;for(const[I,L]of A.ansi.entries())M+=`${this._terminalSelector} .${k}${I} { color: ${L.css}; }${this._terminalSelector} .${k}${I}.xterm-dim { color: ${a.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${j}${I} { background-color: ${L.css}; }`;M+=`${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(A.background).css}; }${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(A.background),.5).css}; }${this._terminalSelector} .${j}${b.INVERTED_DEFAULT_COLOR} { background-color: ${A.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const A=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${A}px`,this._rowFactory.defaultSpacing=A}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(A,M){for(let I=this._rowElements.length;I<=M;I++){const L=document.createElement("div");this._rowContainer.appendChild(L),this._rowElements.push(L)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(A,M){this._refreshRowElements(A,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(C)}handleFocus(){this._rowContainer.classList.add(C),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(A,M,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(A,M,I),this.renderRows(0,this._bufferService.rows-1),!A||!M)return;const L=A[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,H=Math.max(L,0),T=Math.min(F,this._bufferService.rows-1);if(H>=this._bufferService.rows||T<0)return;const O=document.createDocumentFragment();if(I){const P=A[0]>M[0];O.appendChild(this._createSelectionElement(H,P?M[0]:A[0],P?A[0]:M[0],T-H+1))}else{const P=L===H?A[0]:0,B=H===F?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,P,B));const $=T-H-1;if(O.appendChild(this._createSelectionElement(H+1,0,this._bufferService.cols,$)),H!==T){const X=F===T?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(T,0,X))}}this._selectionContainer.appendChild(O)}_createSelectionElement(A,M,I,L=1){const F=document.createElement("div");return F.style.height=L*this.dimensions.css.cell.height+"px",F.style.top=A*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(I-M)+"px",F}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 A of this._rowElements)A.replaceChildren()}renderRows(A,M){const I=this._bufferService.buffer,L=I.ybase+I.y,F=Math.min(I.x,this._bufferService.cols-1),H=this._optionsService.rawOptions.cursorBlink,T=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=A;P<=M;P++){const B=P+I.ydisp,$=this._rowElements[P],X=I.lines.get(B);if(!$||!X)break;$.replaceChildren(...this._rowFactory.createRow(X,B,B===L,T,O,F,H,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(A){this._setCellUnderline(A.x1,A.x2,A.y1,A.y2,A.cols,!0)}_handleLinkLeave(A){this._setCellUnderline(A.x1,A.x2,A.y1,A.y2,A.cols,!1)}_setCellUnderline(A,M,I,L,F,H){I<0&&(A=0),L<0&&(M=0);const T=this._bufferService.rows-1;I=Math.max(Math.min(I,T),0),L=Math.max(Math.min(L,T),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,P=O.ybase+O.y,B=Math.min(O.x,F-1),$=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let K=I;K<=L;++K){const W=K+O.ydisp,R=this._rowElements[K],z=O.lines.get(W);if(!R||!z)break;R.replaceChildren(...this._rowFactory.createRow(z,W,W===P,X,U,B,$,this.dimensions.css.cell.width,this._widthCache,H?K===I?A:0:-1,H?(K===L?M:F)-1:-1))}}};n.DomRenderer=D=l([u(4,h.IInstantiationService),u(5,x.ICharSizeService),u(6,h.IOptionsService),u(7,h.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],D)},3787:function(g,n,i){var l=this&&this.__decorate||function(k,j,C,E){var N,D=arguments.length,A=D<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,C):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(k,j,C,E);else for(var M=k.length-1;M>=0;M--)(N=k[M])&&(A=(D<3?N(A):D>3?N(j,C,A):N(j,C))||A);return D>3&&A&&Object.defineProperty(j,C,A),A},u=this&&this.__param||function(k,j){return function(C,E){j(C,E,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),v=i(643),b=i(511),S=i(2585),x=i(8055),a=i(4725),f=i(4269),d=i(6171),h=i(3734);let _=n.DomRendererRowFactory=class{constructor(k,j,C,E,N,D,A){this._document=k,this._characterJoinerService=j,this._optionsService=C,this._coreBrowserService=E,this._coreService=N,this._decorationService=D,this._themeService=A,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,C){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=C}createRow(k,j,C,E,N,D,A,M,I,L,F){const H=[],T=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let P,B=k.getNoBgTrimmedLength();C&&B<D+1&&(B=D+1);let $=0,X="",U=0,K=0,W=0,R=!1,z=0,V=!1,q=0;const se=[],Q=L!==-1&&F!==-1;for(let ee=0;ee<B;ee++){k.loadCell(ee,this._workCell);let be=this._workCell.getWidth();if(be===0)continue;let Ce=!1,Oe=ee,de=this._workCell;if(T.length>0&&ee===T[0][0]){Ce=!0;const G=T.shift();de=new f.JoinedCellData(this._workCell,k.translateToString(!0,G[0],G[1]),G[1]-G[0]),Oe=G[1]-1,be=de.getWidth()}const Ke=this._isCellInSelection(ee,j),fe=C&&ee===D,ge=Q&&ee>=L&&ee<=F;let $e=!1;this._decorationService.forEachDecorationAtCell(ee,j,void 0,(G=>{$e=!0}));let et=de.getChars()||v.WHITESPACE_CELL_CHAR;if(et===" "&&(de.isUnderline()||de.isOverline())&&(et=" "),q=be*M-I.get(et,de.isBold(),de.isItalic()),P){if($&&(Ke&&V||!Ke&&!V&&de.bg===U)&&(Ke&&V&&O.selectionForeground||de.fg===K)&&de.extended.ext===W&&ge===R&&q===z&&!fe&&!Ce&&!$e){X+=et,$++;continue}$&&(P.textContent=X),P=this._document.createElement("span"),$=0,X=""}else P=this._document.createElement("span");if(U=de.bg,K=de.fg,W=de.extended.ext,R=ge,z=q,V=Ke,Ce&&D>=ee&&D<=Oe&&(D=ee),!this._coreService.isCursorHidden&&fe){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)A&&se.push("xterm-cursor-blink"),se.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(de.isBold()&&se.push("xterm-bold"),de.isItalic()&&se.push("xterm-italic"),de.isDim()&&se.push("xterm-dim"),X=de.isInvisible()?v.WHITESPACE_CELL_CHAR:de.getChars()||v.WHITESPACE_CELL_CHAR,de.isUnderline()&&(se.push(`xterm-underline-${de.extended.underlineStyle}`),X===" "&&(X=" "),!de.isUnderlineColorDefault()))if(de.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(de.getUnderlineColor()).join(",")})`;else{let G=de.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&de.isBold()&&G<8&&(G+=8),P.style.textDecorationColor=O.ansi[G].css}de.isOverline()&&(se.push("xterm-overline"),X===" "&&(X=" ")),de.isStrikethrough()&&se.push("xterm-strikethrough"),ge&&(P.style.textDecoration="underline");let De=de.getFgColor(),re=de.getFgColorMode(),ye=de.getBgColor(),je=de.getBgColorMode();const Le=!!de.isInverse();if(Le){const G=De;De=ye,ye=G;const oe=re;re=je,je=oe}let Ae,Se,ke,Ne=!1;switch(this._decorationService.forEachDecorationAtCell(ee,j,void 0,(G=>{G.options.layer!=="top"&&Ne||(G.backgroundColorRGB&&(je=50331648,ye=G.backgroundColorRGB.rgba>>8&16777215,Ae=G.backgroundColorRGB),G.foregroundColorRGB&&(re=50331648,De=G.foregroundColorRGB.rgba>>8&16777215,Se=G.foregroundColorRGB),Ne=G.options.layer==="top")})),!Ne&&Ke&&(Ae=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,ye=Ae.rgba>>8&16777215,je=50331648,Ne=!0,O.selectionForeground&&(re=50331648,De=O.selectionForeground.rgba>>8&16777215,Se=O.selectionForeground)),Ne&&se.push("xterm-decoration-top"),je){case 16777216:case 33554432:ke=O.ansi[ye],se.push(`xterm-bg-${ye}`);break;case 50331648:ke=x.rgba.toColor(ye>>16,ye>>8&255,255&ye),this._addStyle(P,`background-color:#${w((ye>>>0).toString(16),"0",6)}`);break;default:Le?(ke=O.foreground,se.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ke=O.background}switch(Ae||de.isDim()&&(Ae=x.color.multiplyOpacity(ke,.5)),re){case 16777216:case 33554432:de.isBold()&&De<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(De+=8),this._applyMinimumContrast(P,ke,O.ansi[De],de,Ae,void 0)||se.push(`xterm-fg-${De}`);break;case 50331648:const G=x.rgba.toColor(De>>16&255,De>>8&255,255&De);this._applyMinimumContrast(P,ke,G,de,Ae,Se)||this._addStyle(P,`color:#${w(De.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,ke,O.foreground,de,Ae,void 0)||Le&&se.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}se.length&&(P.className=se.join(" "),se.length=0),fe||Ce||$e?P.textContent=X:$++,q!==this.defaultSpacing&&(P.style.letterSpacing=`${q}px`),H.push(P),ee=Oe}return P&&$&&(P.textContent=X),H}_applyMinimumContrast(k,j,C,E,N,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const A=this._getContrastCache(E);let M;if(N||D||(M=A.getColor(j.rgba,C.rgba)),M===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);M=x.color.ensureContrastRatio(N||j,D||C,I),A.setColor((N||j).rgba,(D||C).rgba,M??null)}return!!M&&(this._addStyle(k,`color:${M.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const C=this._selectionStart,E=this._selectionEnd;return!(!C||!E)&&(this._columnSelectMode?C[0]<=E[0]?k>=C[0]&&j>=C[1]&&k<E[0]&&j<=E[1]:k<C[0]&&j>=C[1]&&k>=E[0]&&j<=E[1]:j>C[1]&&j<E[1]||C[1]===E[1]&&j===C[1]&&k>=C[0]&&k<E[0]||C[1]<E[1]&&j===E[1]&&k<E[0]||C[1]<E[1]&&j===C[1]&&k>=C[0])}};function w(k,j,C){for(;k.length<C;)k=j+k;return k}n.DomRendererRowFactory=_=l([u(1,a.ICharacterJoinerService),u(2,S.IOptionsService),u(3,a.ICoreBrowserService),u(4,S.ICoreService),u(5,S.IDecorationService),u(6,a.IThemeService)],_)},2550:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.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 l=i.createElement("span"),u=i.createElement("span");u.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const v=i.createElement("span");v.style.fontWeight="bold",v.style.fontStyle="italic",this._measureElements=[l,u,c,v],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(v),i.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(i,l,u,c){i===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,u){let c=0;if(!l&&!u&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let v=i;l&&(v+="B"),u&&(v+="I");let b=this._holey.get(v);if(b===void 0){let S=0;l&&(S|=1),u&&(S|=2),b=this._measure(i,S),this._holey.set(v,b)}return b}_measure(i,l){const u=this._measureElements[l];return u.textContent=i.repeat(32),u.offsetWidth/32}}},2223:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(g,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(u){return 9472<=u&&u<=9631})(l)},n.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:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,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 i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(g,n,i){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),v=i(8460),b=i(844);let S=n.CharSizeService=class extends b.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,f,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new v.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new x(a,f,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=S=l([u(2,c.IOptionsService)],S);class x{constructor(f,d,h){this._document=f,this._parentElement=d,this._optionsService=h,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 f={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return f.width!==0&&f.height!==0&&(this._result.width=f.width/32,this._result.height=Math.ceil(f.height)),this._result}}},4269:function(g,n,i){var l=this&&this.__decorate||function(f,d,h,_){var w,k=arguments.length,j=k<3?d:_===null?_=Object.getOwnPropertyDescriptor(d,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,h,_);else for(var C=f.length-1;C>=0;C--)(w=f[C])&&(j=(k<3?w(j):k>3?w(d,h,j):w(d,h))||j);return k>3&&j&&Object.defineProperty(d,h,j),j},u=this&&this.__param||function(f,d){return function(h,_){d(h,_,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),v=i(643),b=i(511),S=i(2585);class x extends c.AttributeData{constructor(d,h,_){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=h,this._width=_}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()]}}n.JoinedCellData=x;let a=n.CharacterJoinerService=class yl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(d){const h={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(h),h.id}deregister(d){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===d)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(d);if(!h||h.length===0)return[];const _=[],w=h.translateToString(!0);let k=0,j=0,C=0,E=h.getFg(0),N=h.getBg(0);for(let D=0;D<h.getTrimmedLength();D++)if(h.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==N){if(D-k>1){const A=this._getJoinedRanges(w,C,j,h,k);for(let M=0;M<A.length;M++)_.push(A[M])}k=D,C=j,E=this._workCell.fg,N=this._workCell.bg}j+=this._workCell.getChars().length||v.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const D=this._getJoinedRanges(w,C,j,h,k);for(let A=0;A<D.length;A++)_.push(D[A])}return _}_getJoinedRanges(d,h,_,w,k){const j=d.substring(h,_);let C=[];try{C=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const N=this._characterJoiners[E].handler(j);for(let D=0;D<N.length;D++)yl._mergeRanges(C,N[D])}catch(N){console.error(N)}return this._stringRangesToCellRanges(C,w,k),C}_stringRangesToCellRanges(d,h,_){let w=0,k=!1,j=0,C=d[w];if(C){for(let E=_;E<this._bufferService.cols;E++){const N=h.getWidth(E),D=h.getString(E).length||v.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&C[0]<=j&&(C[0]=E,k=!0),C[1]<=j){if(C[1]=E,C=d[++w],!C)break;C[0]<=j?(C[0]=E,k=!0):k=!1}j+=D}}C&&(C[1]=this._bufferService.cols)}}static _mergeRanges(d,h){let _=!1;for(let w=0;w<d.length;w++){const k=d[w];if(_){if(h[1]<=k[0])return d[w-1][1]=h[1],d;if(h[1]<=k[1])return d[w-1][1]=Math.max(h[1],k[1]),d.splice(w,1),d;d.splice(w,1),w--}else{if(h[1]<=k[0])return d.splice(w,0,h),d;if(h[1]<=k[1])return k[0]=Math.min(h[0],k[0]),d;h[0]<k[1]&&(k[0]=Math.min(h[0],k[0]),_=!0)}}return _?d[d.length-1][1]=h[1]:d.push(h),d}};n.CharacterJoinerService=a=l([u(0,S.IBufferService)],a)},5114:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,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(g,n,i){var l=this&&this.__decorate||function(S,x,a,f){var d,h=arguments.length,_=h<3?x:f===null?f=Object.getOwnPropertyDescriptor(x,a):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(S,x,a,f);else for(var w=S.length-1;w>=0;w--)(d=S[w])&&(_=(h<3?d(_):h>3?d(x,a,_):d(x,a))||_);return h>3&&_&&Object.defineProperty(x,a,_),_},u=this&&this.__param||function(S,x){return function(a,f){x(a,f,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),v=i(9806);let b=n.MouseService=class{constructor(S,x){this._renderService=S,this._charSizeService=x}getCoords(S,x,a,f,d){return(0,v.getCoords)(window,S,x,a,f,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(S,x){const a=(0,v.getCoordsRelativeToElement)(window,S,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=b=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],b)},3230:function(g,n,i){var l=this&&this.__decorate||function(_,w,k,j){var C,E=arguments.length,N=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,w,k,j);else for(var D=_.length-1;D>=0;D--)(C=_[D])&&(N=(E<3?C(N):E>3?C(w,k,N):C(w,k))||N);return E>3&&N&&Object.defineProperty(w,k,N),N},u=this&&this.__param||function(_,w){return function(k,j){w(k,j,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),v=i(6193),b=i(5596),S=i(4725),x=i(8460),a=i(844),f=i(7226),d=i(2585);let h=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,w,k,j,C,E,N,D){if(super(),this._rowCount=_,this._charSizeService=j,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new f.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 x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new v.RenderDebouncer(N.window,((A,M)=>this._renderRows(A,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new b.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var A;return(A=this._renderer.value)===null||A===void 0?void 0:A.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(C.onDecorationRegistered((()=>this._fullRefresh()))),this.register(C.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(D.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const A=new N.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});A.observe(w),this.register({dispose:()=>A.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.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(_,w,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,w,this._rowCount))}_renderRows(_,w){this._renderer.value&&(_=Math.min(_,this._rowCount-1),w=Math.min(w,this._rowCount-1),this._renderer.value.renderRows(_,w),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:w}),this._onRender.fire({start:_,end:w}),this._isNextRenderRedrawOnly=!0)}resize(_,w){this._rowCount=w,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(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((w=>this.refreshRows(w.start,w.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,w;this._renderer.value&&((w=(_=this._renderer.value).clearTextureAtlas)===null||w===void 0||w.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,w){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,w))):this._renderer.value.handleResize(_,w),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,w,k){var j;this._selectionState.start=_,this._selectionState.end=w,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(_,w,k)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};n.RenderService=h=l([u(2,d.IOptionsService),u(3,S.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,S.ICoreBrowserService),u(7,S.IThemeService)],h)},9312:function(g,n,i){var l=this&&this.__decorate||function(C,E,N,D){var A,M=arguments.length,I=M<3?E:D===null?D=Object.getOwnPropertyDescriptor(E,N):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(C,E,N,D);else for(var L=C.length-1;L>=0;L--)(A=C[L])&&(I=(M<3?A(I):M>3?A(E,N,I):A(E,N))||I);return M>3&&I&&Object.defineProperty(E,N,I),I},u=this&&this.__param||function(C,E){return function(N,D){E(N,D,C)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),v=i(9504),b=i(456),S=i(4725),x=i(8460),a=i(844),f=i(6114),d=i(4841),h=i(511),_=i(2585),w=" ",k=new RegExp(w,"g");let j=n.SelectionService=class extends a.Disposable{constructor(C,E,N,D,A,M,I,L,F){super(),this._element=C,this._screenElement=E,this._linkifier=N,this._bufferService=D,this._coreService=A,this._mouseService=M,this._optionsService=I,this._renderService=L,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=H=>this._handleMouseMove(H),this._mouseUpListener=H=>this._handleMouseUp(H),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((H=>this._handleTrim(H))),this.register(this._bufferService.buffers.onBufferActivate((H=>this._handleBufferActivate(H)))),this.enable(),this._model=new b.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.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 C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!C||!E||C[0]===E[0]&&C[1]===E[1])}get selectionText(){const C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!C||!E)return"";const N=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(C[0]===E[0])return"";const A=C[0]<E[0]?C[0]:E[0],M=C[0]<E[0]?E[0]:C[0];for(let I=C[1];I<=E[1];I++){const L=N.translateBufferLineToString(I,!0,A,M);D.push(L)}}else{const A=C[1]===E[1]?E[0]:void 0;D.push(N.translateBufferLineToString(C[1],!0,C[0],A));for(let M=C[1]+1;M<=E[1]-1;M++){const I=N.lines.get(M),L=N.translateBufferLineToString(M,!0);I?.isWrapped?D[D.length-1]+=L:D.push(L)}if(C[1]!==E[1]){const M=N.lines.get(E[1]),I=N.translateBufferLineToString(E[1],!0,0,E[0]);M&&M.isWrapped?D[D.length-1]+=I:D.push(I)}}return D.map((A=>A.replace(k," "))).join(f.isWindows?`\r
|
|
24
|
-
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(C){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),f.isLinux&&C&&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(C){const E=this._getMouseBufferCoords(C),N=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(N&&D&&E)&&this._areCoordsInSelection(E,N,D)}isCellInSelection(C,E){const N=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!N||!D)&&this._areCoordsInSelection([C,E],N,D)}_areCoordsInSelection(C,E,N){return C[1]>E[1]&&C[1]<N[1]||E[1]===N[1]&&C[1]===E[1]&&C[0]>=E[0]&&C[0]<N[0]||E[1]<N[1]&&C[1]===N[1]&&C[0]<N[0]||E[1]<N[1]&&C[1]===E[1]&&C[0]>=E[0]}_selectWordAtCursor(C,E){var N,D;const A=(D=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||D===void 0?void 0:D.range;if(A)return this._model.selectionStart=[A.start.x-1,A.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(A,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(C);return!!M&&(this._selectWordAt(M,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(C,E){this._model.clearSelection(),C=Math.max(C,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,C],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(C){this._model.handleTrim(C)&&this.refresh()}_getMouseBufferCoords(C){const E=this._mouseService.getCoords(C,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(C){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,C,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=N?0:(E>N&&(E-=N),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(C){return f.isMac?C.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:C.shiftKey}handleMouseDown(C){if(this._mouseDownTimeStamp=C.timeStamp,(C.button!==2||!this.hasSelection)&&C.button===0){if(!this._enabled){if(!this.shouldForceSelection(C))return;C.stopPropagation()}C.preventDefault(),this._dragScrollAmount=0,this._enabled&&C.shiftKey?this._handleIncrementalClick(C):C.detail===1?this._handleSingleClick(C):C.detail===2?this._handleDoubleClick(C):C.detail===3&&this._handleTripleClick(C),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(C){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(C))}_handleSingleClick(C){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(C)?3:0,this._model.selectionStart=this._getMouseBufferCoords(C),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(C){this._selectWordAtCursor(C,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(C){const E=this._getMouseBufferCoords(C);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(C){return C.altKey&&!(f.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(C){if(C.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(C),!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(C),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const N=this._bufferService.buffer;if(this._model.selectionEnd[1]<N.lines.length){const D=N.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}E&&E[0]===this._model.selectionEnd[0]&&E[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 C=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(C.ydisp+this._bufferService.rows,C.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=C.ydisp),this.refresh()}}_handleMouseUp(C){const E=C.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&C.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(C,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const D=(0,v.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,N=!(!C||!E||C[0]===E[0]&&C[1]===E[1]);N?C&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&C[0]===this._oldSelectionStart[0]&&C[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(C,E,N)):this._oldHasSelection&&this._fireOnSelectionChange(C,E,N)}_fireOnSelectionChange(C,E,N){this._oldSelectionStart=C,this._oldSelectionEnd=E,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(C){this.clearSelection(),this._trimListener.dispose(),this._trimListener=C.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(C,E){let N=E;for(let D=0;E>=D;D++){const A=C.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:A>1&&E!==D&&(N+=A-1)}return N}setSelection(C,E,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[C,E],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(C){this._isClickInSelection(C)||(this._selectWordAtCursor(C,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(C,E,N=!0,D=!0){if(C[0]>=this._bufferService.cols)return;const A=this._bufferService.buffer,M=A.lines.get(C[1]);if(!M)return;const I=A.translateBufferLineToString(C[1],!1);let L=this._convertViewportColToCharacterIndex(M,C[0]),F=L;const H=C[0]-L;let T=0,O=0,P=0,B=0;if(I.charAt(L)===" "){for(;L>0&&I.charAt(L-1)===" ";)L--;for(;F<I.length&&I.charAt(F+1)===" ";)F++}else{let U=C[0],K=C[0];M.getWidth(U)===0&&(T++,U--),M.getWidth(K)===2&&(O++,K++);const W=M.getString(K).length;for(W>1&&(B+=W-1,F+=W-1);U>0&&L>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===0?(T++,U--):R>1&&(P+=R-1,L-=R-1),L--,U--}for(;K<M.length&&F+1<I.length&&!this._isCharWordSeparator(M.loadCell(K+1,this._workCell));){M.loadCell(K+1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,K++):R>1&&(B+=R-1,F+=R-1),F++,K++}}F++;let $=L+H-T+P,X=Math.min(this._bufferService.cols,F-L+T+O-P-B);if(E||I.slice(L,F).trim()!==""){if(N&&$===0&&M.getCodePoint(0)!==32){const U=A.lines.get(C[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const K=this._getWordAt([this._bufferService.cols-1,C[1]-1],!1,!0,!1);if(K){const W=this._bufferService.cols-K.start;$-=W,X+=W}}}if(D&&$+X===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=A.lines.get(C[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const K=this._getWordAt([0,C[1]+1],!1,!1,!0);K&&(X+=K.length)}}return{start:$,length:X}}}_selectWordAt(C,E){const N=this._getWordAt(C,E);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,C[1]--;this._model.selectionStart=[N.start,C[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(C){const E=this._getWordAt(C,!0);if(E){let N=C[1];for(;E.start<0;)E.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,N]}}_isCharWordSeparator(C){return C.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(C.getChars())>=0}_selectLineAt(C){const E=this._bufferService.buffer.getWrappedRangeForLine(C),N={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(N,this._bufferService.cols)}};n.SelectionService=j=l([u(3,_.IBufferService),u(4,_.ICoreService),u(5,S.IMouseService),u(6,_.IOptionsService),u(7,S.IRenderService),u(8,S.ICoreBrowserService)],j)},4725:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const l=i(8343);n.ICharSizeService=(0,l.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),n.IMouseService=(0,l.createDecorator)("MouseService"),n.IRenderService=(0,l.createDecorator)("RenderService"),n.ISelectionService=(0,l.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(g,n,i){var l=this&&this.__decorate||function(j,C,E,N){var D,A=arguments.length,M=A<3?C:N===null?N=Object.getOwnPropertyDescriptor(C,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,C,E,N);else for(var I=j.length-1;I>=0;I--)(D=j[I])&&(M=(A<3?D(M):A>3?D(C,E,M):D(C,E))||M);return A>3&&M&&Object.defineProperty(C,E,M),M},u=this&&this.__param||function(j,C){return function(E,N){C(E,N,j)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),v=i(8055),b=i(8460),S=i(844),x=i(2585),a=v.css.toColor("#ffffff"),f=v.css.toColor("#000000"),d=v.css.toColor("#ffffff"),h=v.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[v.css.toColor("#2e3436"),v.css.toColor("#cc0000"),v.css.toColor("#4e9a06"),v.css.toColor("#c4a000"),v.css.toColor("#3465a4"),v.css.toColor("#75507b"),v.css.toColor("#06989a"),v.css.toColor("#d3d7cf"),v.css.toColor("#555753"),v.css.toColor("#ef2929"),v.css.toColor("#8ae234"),v.css.toColor("#fce94f"),v.css.toColor("#729fcf"),v.css.toColor("#ad7fa8"),v.css.toColor("#34e2e2"),v.css.toColor("#eeeeec")],C=[0,95,135,175,215,255];for(let E=0;E<216;E++){const N=C[E/36%6|0],D=C[E/6%6|0],A=C[E%6];j.push({css:v.channels.toCss(N,D,A),rgba:v.channels.toRgba(N,D,A)})}for(let E=0;E<24;E++){const N=8+10*E;j.push({css:v.channels.toCss(N,N,N),rgba:v.channels.toRgba(N,N,N)})}return j})());let w=n.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:f,cursor:d,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:v.color.blend(f,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:v.color.blend(f,_),ansi:n.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(j={}){const C=this._colors;if(C.foreground=k(j.foreground,a),C.background=k(j.background,f),C.cursor=k(j.cursor,d),C.cursorAccent=k(j.cursorAccent,h),C.selectionBackgroundTransparent=k(j.selectionBackground,_),C.selectionBackgroundOpaque=v.color.blend(C.background,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundOpaque=v.color.blend(C.background,C.selectionInactiveBackgroundTransparent),C.selectionForeground=j.selectionForeground?k(j.selectionForeground,v.NULL_COLOR):void 0,C.selectionForeground===v.NULL_COLOR&&(C.selectionForeground=void 0),v.color.isOpaque(C.selectionBackgroundTransparent)&&(C.selectionBackgroundTransparent=v.color.opacity(C.selectionBackgroundTransparent,.3)),v.color.isOpaque(C.selectionInactiveBackgroundTransparent)&&(C.selectionInactiveBackgroundTransparent=v.color.opacity(C.selectionInactiveBackgroundTransparent,.3)),C.ansi=n.DEFAULT_ANSI_COLORS.slice(),C.ansi[0]=k(j.black,n.DEFAULT_ANSI_COLORS[0]),C.ansi[1]=k(j.red,n.DEFAULT_ANSI_COLORS[1]),C.ansi[2]=k(j.green,n.DEFAULT_ANSI_COLORS[2]),C.ansi[3]=k(j.yellow,n.DEFAULT_ANSI_COLORS[3]),C.ansi[4]=k(j.blue,n.DEFAULT_ANSI_COLORS[4]),C.ansi[5]=k(j.magenta,n.DEFAULT_ANSI_COLORS[5]),C.ansi[6]=k(j.cyan,n.DEFAULT_ANSI_COLORS[6]),C.ansi[7]=k(j.white,n.DEFAULT_ANSI_COLORS[7]),C.ansi[8]=k(j.brightBlack,n.DEFAULT_ANSI_COLORS[8]),C.ansi[9]=k(j.brightRed,n.DEFAULT_ANSI_COLORS[9]),C.ansi[10]=k(j.brightGreen,n.DEFAULT_ANSI_COLORS[10]),C.ansi[11]=k(j.brightYellow,n.DEFAULT_ANSI_COLORS[11]),C.ansi[12]=k(j.brightBlue,n.DEFAULT_ANSI_COLORS[12]),C.ansi[13]=k(j.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),C.ansi[14]=k(j.brightCyan,n.DEFAULT_ANSI_COLORS[14]),C.ansi[15]=k(j.brightWhite,n.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(C.ansi.length-16,j.extendedAnsi.length);for(let N=0;N<E;N++)C.ansi[N+16]=k(j.extendedAnsi[N],n.DEFAULT_ANSI_COLORS[N+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){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[j]=this._restoreColors.ansi[j]}else for(let C=0;C<this._restoreColors.ansi.length;++C)this._colors.ansi[C]=this._restoreColors.ansi[C]}modifyColors(j){j(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(j,C){if(j!==void 0)try{return v.css.toColor(j)}catch{}return C}n.ThemeService=w=l([u(0,x.IOptionsService)],w)},6349:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),u=i(844);class c extends u.Disposable{constructor(b){super(),this._maxLength=b,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.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(b){if(this._maxLength===b)return;const S=new Array(b);for(let x=0;x<Math.min(b,this.length);x++)S[x]=this._array[this._getCyclicIndex(x)];this._array=S,this._maxLength=b,this._startIndex=0}get length(){return this._length}set length(b){if(b>this._length)for(let S=this._length;S<b;S++)this._array[S]=void 0;this._length=b}get(b){return this._array[this._getCyclicIndex(b)]}set(b,S){this._array[this._getCyclicIndex(b)]=S}push(b){this._array[this._getCyclicIndex(this._length)]=b,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(b,S,...x){if(S){for(let a=b;a<this._length-S;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+S)];this._length-=S,this.onDeleteEmitter.fire({index:b,amount:S})}for(let a=this._length-1;a>=b;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(b+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:b,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,S,x){if(!(S<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let f=S-1;f>=0;f--)this.set(b+f+x,this.get(b+f));const a=b+S+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<S;a++)this.set(b+a+x,this.get(b+a))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}n.CircularList=c},1439:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const v in l)c[v]=u<=1?l[v]:l[v]&&i(l[v],u-1);return c}},8055:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const l=i(6114);let u=0,c=0,v=0,b=0;var S,x,a,f,d;function h(w){const k=w.toString(16);return k.length<2?"0"+k:k}function _(w,k){return w<k?(k+.05)/(w+.05):(w+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(w){w.toCss=function(k,j,C,E){return E!==void 0?`#${h(k)}${h(j)}${h(C)}${h(E)}`:`#${h(k)}${h(j)}${h(C)}`},w.toRgba=function(k,j,C,E=255){return(k<<24|j<<16|C<<8|E)>>>0}})(S||(n.channels=S={})),(function(w){function k(j,C){return b=Math.round(255*C),[u,c,v]=d.toChannels(j.rgba),{css:S.toCss(u,c,v,b),rgba:S.toRgba(u,c,v,b)}}w.blend=function(j,C){if(b=(255&C.rgba)/255,b===1)return{css:C.css,rgba:C.rgba};const E=C.rgba>>24&255,N=C.rgba>>16&255,D=C.rgba>>8&255,A=j.rgba>>24&255,M=j.rgba>>16&255,I=j.rgba>>8&255;return u=A+Math.round((E-A)*b),c=M+Math.round((N-M)*b),v=I+Math.round((D-I)*b),{css:S.toCss(u,c,v),rgba:S.toRgba(u,c,v)}},w.isOpaque=function(j){return(255&j.rgba)==255},w.ensureContrastRatio=function(j,C,E){const N=d.ensureContrastRatio(j.rgba,C.rgba,E);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},w.opaque=function(j){const C=(255|j.rgba)>>>0;return[u,c,v]=d.toChannels(C),{css:S.toCss(u,c,v),rgba:C}},w.opacity=k,w.multiplyOpacity=function(j,C){return b=255&j.rgba,k(j,b*C/255)},w.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(x||(n.color=x={})),(function(w){let k,j;if(!l.isNode){const C=document.createElement("canvas");C.width=1,C.height=1;const E=C.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}w.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return u=parseInt(C.slice(1,2).repeat(2),16),c=parseInt(C.slice(2,3).repeat(2),16),v=parseInt(C.slice(3,4).repeat(2),16),d.toColor(u,c,v);case 5:return u=parseInt(C.slice(1,2).repeat(2),16),c=parseInt(C.slice(2,3).repeat(2),16),v=parseInt(C.slice(3,4).repeat(2),16),b=parseInt(C.slice(4,5).repeat(2),16),d.toColor(u,c,v,b);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const E=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return u=parseInt(E[1]),c=parseInt(E[2]),v=parseInt(E[3]),b=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,v,b);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=C,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,v,b]=k.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(u,c,v,b),css:C}}})(a||(n.css=a={})),(function(w){function k(j,C,E){const N=j/255,D=C/255,A=E/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))}w.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},w.relativeLuminance2=k})(f||(n.rgb=f={})),(function(w){function k(C,E,N){const D=C>>24&255,A=C>>16&255,M=C>>8&255;let I=E>>24&255,L=E>>16&255,F=E>>8&255,H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));for(;H<N&&(I>0||L>0||F>0);)I-=Math.max(0,Math.ceil(.1*I)),L-=Math.max(0,Math.ceil(.1*L)),F-=Math.max(0,Math.ceil(.1*F)),H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));return(I<<24|L<<16|F<<8|255)>>>0}function j(C,E,N){const D=C>>24&255,A=C>>16&255,M=C>>8&255;let I=E>>24&255,L=E>>16&255,F=E>>8&255,H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));for(;H<N&&(I<255||L<255||F<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=Math.min(255,F+Math.ceil(.1*(255-F))),H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));return(I<<24|L<<16|F<<8|255)>>>0}w.ensureContrastRatio=function(C,E,N){const D=f.relativeLuminance(C>>8),A=f.relativeLuminance(E>>8);if(_(D,A)<N){if(A<D){const L=k(C,E,N),F=_(D,f.relativeLuminance(L>>8));if(F<N){const H=j(C,E,N);return F>_(D,f.relativeLuminance(H>>8))?L:H}return L}const M=j(C,E,N),I=_(D,f.relativeLuminance(M>>8));if(I<N){const L=k(C,E,N);return I>_(D,f.relativeLuminance(L>>8))?M:L}return M}},w.reduceLuminance=k,w.increaseLuminance=j,w.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]},w.toColor=function(C,E,N,D){return{css:S.toCss(C,E,N,D),rgba:S.toRgba(C,E,N,D)}}})(d||(n.rgba=d={})),n.toPaddedHex=h,n.contrastRatio=_},8969:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const l=i(844),u=i(2585),c=i(4348),v=i(7866),b=i(744),S=i(7302),x=i(6975),a=i(8460),f=i(1753),d=i(1480),h=i(7994),_=i(9282),w=i(5435),k=i(5981),j=i(2660);let C=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((D=>{var A;(A=this._onScrollApi)===null||A===void 0||A.fire(D.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(D){for(const A in D)this.optionsService.options[A]=D[A]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new S.OptionsService(D)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(v.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(x.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(f.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new w.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.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((A=>{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((A=>{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(((A,M)=>this._inputHandler.parse(A,M)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,A){this._writeBuffer.write(D,A)}writeSync(D,A){this._logService.logLevel<=u.LogLevelEnum.WARN&&!C&&(this._logService.warn("writeSync is unreliable and will be removed soon."),C=!0),this._writeBuffer.writeSync(D,A)}resize(D,A){isNaN(D)||isNaN(A)||(D=Math.max(D,b.MINIMUM_COLS),A=Math.max(A,b.MINIMUM_ROWS),this._bufferService.resize(D,A))}scroll(D,A=!1){this._bufferService.scroll(D,A)}scrollLines(D,A,M){this._bufferService.scrollLines(D,A,M)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const A=D-this._bufferService.buffer.ydisp;A!==0&&this.scrollLines(A)}registerEscHandler(D,A){return this._inputHandler.registerEscHandler(D,A)}registerDcsHandler(D,A){return this._inputHandler.registerDcsHandler(D,A)}registerCsiHandler(D,A){return this._inputHandler.registerCsiHandler(D,A)}registerOscHandler(D,A){return this._inputHandler.registerOscHandler(D,A)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const A=this.optionsService.rawOptions.windowsPty;A&&A.buildNumber!==void 0&&A.buildNumber!==void 0?D=A.backend==="conpty"&&A.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const A of D)A.dispose()}))}}}n.CoreTerminal=E},8460:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,l){return i((u=>l.fire(u)))}},5435:function(g,n,i){var l=this&&this.__decorate||function(H,T,O,P){var B,$=arguments.length,X=$<3?T:P===null?P=Object.getOwnPropertyDescriptor(T,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(H,T,O,P);else for(var U=H.length-1;U>=0;U--)(B=H[U])&&(X=($<3?B(X):$>3?B(T,O,X):B(T,O))||X);return $>3&&X&&Object.defineProperty(T,O,X),X},u=this&&this.__param||function(H,T){return function(O,P){T(O,P,H)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),v=i(7116),b=i(2015),S=i(844),x=i(482),a=i(8437),f=i(8460),d=i(643),h=i(511),_=i(3734),w=i(2585),k=i(6242),j=i(6351),C=i(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function D(H,T){if(H>24)return T.setWinLines||!1;switch(H){case 1:return!!T.restoreWin;case 2:return!!T.minimizeWin;case 3:return!!T.setWinPosition;case 4:return!!T.setWinSizePixels;case 5:return!!T.raiseWin;case 6:return!!T.lowerWin;case 7:return!!T.refreshWin;case 8:return!!T.setWinSizeChars;case 9:return!!T.maximizeWin;case 10:return!!T.fullscreenWin;case 11:return!!T.getWinState;case 13:return!!T.getWinPosition;case 14:return!!T.getWinSizePixels;case 15:return!!T.getScreenSizePixels;case 16:return!!T.getCellSizePixels;case 18:return!!T.getWinSizeChars;case 19:return!!T.getScreenSizeChars;case 20:return!!T.getIconTitle;case 21:return!!T.getWinTitle;case 22:return!!T.pushTitle;case 23:return!!T.popTitle;case 24:return!!T.setWinLines}return!1}var A;(function(H){H[H.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",H[H.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(A||(n.WindowsOptionsReportType=A={}));let M=0;class I extends S.Disposable{getAttrData(){return this._curAttrData}constructor(T,O,P,B,$,X,U,K,W=new b.EscapeSequenceParser){super(),this._bufferService=T,this._charsetService=O,this._coreService=P,this._logService=B,this._optionsService=$,this._oscLinkService=X,this._coreMouseService=U,this._unicodeService=K,this._parser=W,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new f.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new f.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new f.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new f.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new f.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new f.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new f.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new f.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new f.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new f.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new f.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new f.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 L(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._parser.setCsiHandlerFallback(((R,z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:z.toArray()})})),this._parser.setEscHandlerFallback((R=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})})),this._parser.setExecuteHandlerFallback((R=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})})),this._parser.setOscHandlerFallback(((R,z,V)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:z,data:V})})),this._parser.setDcsHandlerFallback(((R,z,V)=>{z==="HOOK"&&(V=V.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:z,payload:V})})),this._parser.setPrintHandler(((R,z,V)=>this.print(R,z,V))),this._parser.registerCsiHandler({final:"@"},(R=>this.insertChars(R))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R=>this.scrollLeft(R))),this._parser.registerCsiHandler({final:"A"},(R=>this.cursorUp(R))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R=>this.scrollRight(R))),this._parser.registerCsiHandler({final:"B"},(R=>this.cursorDown(R))),this._parser.registerCsiHandler({final:"C"},(R=>this.cursorForward(R))),this._parser.registerCsiHandler({final:"D"},(R=>this.cursorBackward(R))),this._parser.registerCsiHandler({final:"E"},(R=>this.cursorNextLine(R))),this._parser.registerCsiHandler({final:"F"},(R=>this.cursorPrecedingLine(R))),this._parser.registerCsiHandler({final:"G"},(R=>this.cursorCharAbsolute(R))),this._parser.registerCsiHandler({final:"H"},(R=>this.cursorPosition(R))),this._parser.registerCsiHandler({final:"I"},(R=>this.cursorForwardTab(R))),this._parser.registerCsiHandler({final:"J"},(R=>this.eraseInDisplay(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R=>this.eraseInDisplay(R,!0))),this._parser.registerCsiHandler({final:"K"},(R=>this.eraseInLine(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R=>this.eraseInLine(R,!0))),this._parser.registerCsiHandler({final:"L"},(R=>this.insertLines(R))),this._parser.registerCsiHandler({final:"M"},(R=>this.deleteLines(R))),this._parser.registerCsiHandler({final:"P"},(R=>this.deleteChars(R))),this._parser.registerCsiHandler({final:"S"},(R=>this.scrollUp(R))),this._parser.registerCsiHandler({final:"T"},(R=>this.scrollDown(R))),this._parser.registerCsiHandler({final:"X"},(R=>this.eraseChars(R))),this._parser.registerCsiHandler({final:"Z"},(R=>this.cursorBackwardTab(R))),this._parser.registerCsiHandler({final:"`"},(R=>this.charPosAbsolute(R))),this._parser.registerCsiHandler({final:"a"},(R=>this.hPositionRelative(R))),this._parser.registerCsiHandler({final:"b"},(R=>this.repeatPrecedingCharacter(R))),this._parser.registerCsiHandler({final:"c"},(R=>this.sendDeviceAttributesPrimary(R))),this._parser.registerCsiHandler({prefix:">",final:"c"},(R=>this.sendDeviceAttributesSecondary(R))),this._parser.registerCsiHandler({final:"d"},(R=>this.linePosAbsolute(R))),this._parser.registerCsiHandler({final:"e"},(R=>this.vPositionRelative(R))),this._parser.registerCsiHandler({final:"f"},(R=>this.hVPosition(R))),this._parser.registerCsiHandler({final:"g"},(R=>this.tabClear(R))),this._parser.registerCsiHandler({final:"h"},(R=>this.setMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R=>this.setModePrivate(R))),this._parser.registerCsiHandler({final:"l"},(R=>this.resetMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R=>this.resetModePrivate(R))),this._parser.registerCsiHandler({final:"m"},(R=>this.charAttributes(R))),this._parser.registerCsiHandler({final:"n"},(R=>this.deviceStatus(R))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R=>this.deviceStatusPrivate(R))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R=>this.softReset(R))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R=>this.setCursorStyle(R))),this._parser.registerCsiHandler({final:"r"},(R=>this.setScrollRegion(R))),this._parser.registerCsiHandler({final:"s"},(R=>this.saveCursor(R))),this._parser.registerCsiHandler({final:"t"},(R=>this.windowOptions(R))),this._parser.registerCsiHandler({final:"u"},(R=>this.restoreCursor(R))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R=>this.insertColumns(R))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R=>this.deleteColumns(R))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R=>this.selectProtected(R))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R=>this.requestMode(R,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R=>this.requestMode(R,!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((R=>(this.setTitle(R),this.setIconName(R),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((R=>this.setIconName(R)))),this._parser.registerOscHandler(2,new k.OscHandler((R=>this.setTitle(R)))),this._parser.registerOscHandler(4,new k.OscHandler((R=>this.setOrReportIndexedColor(R)))),this._parser.registerOscHandler(8,new k.OscHandler((R=>this.setHyperlink(R)))),this._parser.registerOscHandler(10,new k.OscHandler((R=>this.setOrReportFgColor(R)))),this._parser.registerOscHandler(11,new k.OscHandler((R=>this.setOrReportBgColor(R)))),this._parser.registerOscHandler(12,new k.OscHandler((R=>this.setOrReportCursorColor(R)))),this._parser.registerOscHandler(104,new k.OscHandler((R=>this.restoreIndexedColor(R)))),this._parser.registerOscHandler(110,new k.OscHandler((R=>this.restoreFgColor(R)))),this._parser.registerOscHandler(111,new k.OscHandler((R=>this.restoreBgColor(R)))),this._parser.registerOscHandler(112,new k.OscHandler((R=>this.restoreCursorColor(R)))),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 R in v.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},(()=>this.selectCharset("("+R))),this._parser.registerEscHandler({intermediates:")",final:R},(()=>this.selectCharset(")"+R))),this._parser.registerEscHandler({intermediates:"*",final:R},(()=>this.selectCharset("*"+R))),this._parser.registerEscHandler({intermediates:"+",final:R},(()=>this.selectCharset("+"+R))),this._parser.registerEscHandler({intermediates:"-",final:R},(()=>this.selectCharset("-"+R))),this._parser.registerEscHandler({intermediates:".",final:R},(()=>this.selectCharset("."+R))),this._parser.registerEscHandler({intermediates:"/",final:R},(()=>this.selectCharset("/"+R)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((R=>(this._logService.error("Parsing error: ",R),R))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((R,z)=>this.requestStatusString(R,z))))}_preserveStack(T,O,P,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=T,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=P,this._parseStack.position=B}_logSlowResolvingAsync(T){this._logService.logLevel<=w.LogLevelEnum.WARN&&Promise.race([T,new Promise(((O,P)=>setTimeout((()=>P("#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(T,O){let P,B=this._activeBuffer.x,$=this._activeBuffer.y,X=0;const U=this._parseStack.paused;if(U){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(P),P;B=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,T.length>N&&(X=this._parseStack.position+N)}if(this._logService.logLevel<=w.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof T=="string"?` "${T}"`:` "${Array.prototype.map.call(T,(K=>String.fromCharCode(K))).join("")}"`),typeof T=="string"?T.split("").map((K=>K.charCodeAt(0))):T),this._parseBuffer.length<T.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(T.length,N))),U||this._dirtyRowTracker.clearRange(),T.length>N)for(let K=X;K<T.length;K+=N){const W=K+N<T.length?K+N:T.length,R=typeof T=="string"?this._stringDecoder.decode(T.substring(K,W),this._parseBuffer):this._utf8Decoder.decode(T.subarray(K,W),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,R))return this._preserveStack(B,$,R,K),this._logSlowResolvingAsync(P),P}else if(!U){const K=typeof T=="string"?this._stringDecoder.decode(T,this._parseBuffer):this._utf8Decoder.decode(T,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,K))return this._preserveStack(B,$,K,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===B&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(T,O,P){let B,$;const X=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,K=this._bufferService.cols,W=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,z=this._curAttrData;let V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-O>0&&V.getWidth(this._activeBuffer.x-1)===2&&V.setCellFromCodePoint(this._activeBuffer.x-1,0,1,z.fg,z.bg,z.extended);for(let q=O;q<P;++q){if(B=T[q],$=this._unicodeService.wcwidth(B),B<127&&X){const se=X[String.fromCharCode(B)];se&&(B=se.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,x.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=K){if(W){for(;this._activeBuffer.x<K;)V.setCellFromCodePoint(this._activeBuffer.x++,0,1,z.fg,z.bg,z.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=K-1,$===2)continue}if(R&&(V.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(z),z),V.getWidth(K-1)===2&&V.setCellFromCodePoint(K-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,z.fg,z.bg,z.extended)),V.setCellFromCodePoint(this._activeBuffer.x++,B,$,z.fg,z.bg,z.extended),$>0)for(;--$;)V.setCellFromCodePoint(this._activeBuffer.x++,0,0,z.fg,z.bg,z.extended)}else V.getWidth(this._activeBuffer.x-1)?V.addCodepointToCell(this._activeBuffer.x-1,B):V.addCodepointToCell(this._activeBuffer.x-2,B)}P-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<K&&P-O>0&&V.getWidth(this._activeBuffer.x)===0&&!V.hasContent(this._activeBuffer.x)&&V.setCellFromCodePoint(this._activeBuffer.x,0,1,z.fg,z.bg,z.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(T,O){return T.final!=="t"||T.prefix||T.intermediates?this._parser.registerCsiHandler(T,O):this._parser.registerCsiHandler(T,(P=>!D(P.params[0],this._optionsService.rawOptions.windowOptions)||O(P)))}registerDcsHandler(T,O){return this._parser.registerDcsHandler(T,new j.DcsHandler(O))}registerEscHandler(T,O){return this._parser.registerEscHandler(T,O)}registerOscHandler(T,O){return this._parser.registerOscHandler(T,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 T;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&&(!((T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||T===void 0)&&T.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 T=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-T),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(T=this._bufferService.cols-1){this._activeBuffer.x=Math.min(T,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(T,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=T,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=T,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(T,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+T,this._activeBuffer.y+O)}cursorUp(T){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,T.params[0]||1)):this._moveCursor(0,-(T.params[0]||1)),!0}cursorDown(T){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,T.params[0]||1)):this._moveCursor(0,T.params[0]||1),!0}cursorForward(T){return this._moveCursor(T.params[0]||1,0),!0}cursorBackward(T){return this._moveCursor(-(T.params[0]||1),0),!0}cursorNextLine(T){return this.cursorDown(T),this._activeBuffer.x=0,!0}cursorPrecedingLine(T){return this.cursorUp(T),this._activeBuffer.x=0,!0}cursorCharAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(T){return this._setCursor(T.length>=2?(T.params[1]||1)-1:0,(T.params[0]||1)-1),!0}charPosAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(T){return this._moveCursor(T.params[0]||1,0),!0}linePosAbsolute(T){return this._setCursor(this._activeBuffer.x,(T.params[0]||1)-1),!0}vPositionRelative(T){return this._moveCursor(0,T.params[0]||1),!0}hVPosition(T){return this.cursorPosition(T),!0}tabClear(T){const O=T.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=T.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=T.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(T){const O=T.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(T,O,P,B=!1,$=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);X.replaceCells(O,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),B&&(X.isWrapped=!1)}_resetBufferLine(T,O=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+T),P.isWrapped=!1)}eraseInDisplay(T,O=!1){let P;switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);P<this._bufferService.rows;P++)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,0),this._onScroll.fire(0))}return!0}eraseInLine(T,O=!1){switch(this._restrictCursor(this._bufferService.cols),T.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(T){this._restrictCursor();let O=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;O--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(T){this._restrictCursor();let O=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;O--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(T){let O=T.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(T){let O=T.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(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(T.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(T){if(!this._parser.precedingCodepoint)return!0;const O=T.params[0]||1,P=new Uint32Array(O);for(let B=0;B<O;++B)P[B]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(T){return T.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(T){return T.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(T.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(T){return(this._optionsService.rawOptions.termName+"").indexOf(T)===0}setMode(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,v.DEFAULT_CHARSET),this._charsetService.setgCharset(1,v.DEFAULT_CHARSET),this._charsetService.setgCharset(2,v.DEFAULT_CHARSET),this._charsetService.setgCharset(3,v.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(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(T){for(let O=0;O<T.length;O++)switch(T.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(),T.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(T,O){const P=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:$}=this._coreMouseService,X=this._coreService,{buffers:U,cols:K}=this._bufferService,{active:W,alt:R}=U,z=this._optionsService.rawOptions,V=ee=>ee?1:2,q=T.params[0];return se=q,Q=O?q===2?4:q===4?V(X.modes.insertMode):q===12?3:q===20?V(z.convertEol):0:q===1?V(P.applicationCursorKeys):q===3?z.windowOptions.setWinLines?K===80?2:K===132?1:0:0:q===6?V(P.origin):q===7?V(P.wraparound):q===8?3:q===9?V(B==="X10"):q===12?V(z.cursorBlink):q===25?V(!X.isCursorHidden):q===45?V(P.reverseWraparound):q===66?V(P.applicationKeypad):q===67?4:q===1e3?V(B==="VT200"):q===1002?V(B==="DRAG"):q===1003?V(B==="ANY"):q===1004?V(P.sendFocus):q===1005?4:q===1006?V($==="SGR"):q===1015?4:q===1016?V($==="SGR_PIXELS"):q===1048?1:q===47||q===1047||q===1049?V(W===R):q===2004?V(P.bracketedPasteMode):0,X.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${se};${Q}$y`),!0;var se,Q}_updateAttrColor(T,O,P,B,$){return O===2?(T|=50331648,T&=-16777216,T|=_.AttributeData.fromColorRGB([P,B,$])):O===5&&(T&=-50331904,T|=33554432|255&P),T}_extractColor(T,O,P){const B=[0,0,-1,0,0,0];let $=0,X=0;do{if(B[X+$]=T.params[O+X],T.hasSubParams(O+X)){const U=T.getSubParams(O+X);let K=0;do B[1]===5&&($=1),B[X+K+1+$]=U[K];while(++K<U.length&&K+X+1+$<B.length);break}if(B[1]===5&&X+$>=2||B[1]===2&&X+$>=5)break;B[1]&&($=1)}while(++X+O<T.length&&X+$<B.length);for(let U=2;U<B.length;++U)B[U]===-1&&(B[U]=0);switch(B[0]){case 38:P.fg=this._updateAttrColor(P.fg,B[1],B[3],B[4],B[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,B[1],B[3],B[4],B[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,B[1],B[3],B[4],B[5])}return X}_processUnderline(T,O){O.extended=O.extended.clone(),(!~T||T>5)&&(T=1),O.extended.underlineStyle=T,O.fg|=268435456,T===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(T){T.fg=a.DEFAULT_ATTR_DATA.fg,T.bg=a.DEFAULT_ATTR_DATA.bg,T.extended=T.extended.clone(),T.extended.underlineStyle=0,T.extended.underlineColor&=-67108864,T.updateExtended()}charAttributes(T){if(T.length===1&&T.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=T.length;let P;const B=this._curAttrData;for(let $=0;$<O;$++)P=T.params[$],P>=30&&P<=37?(B.fg&=-50331904,B.fg|=16777216|P-30):P>=40&&P<=47?(B.bg&=-50331904,B.bg|=16777216|P-40):P>=90&&P<=97?(B.fg&=-50331904,B.fg|=16777224|P-90):P>=100&&P<=107?(B.bg&=-50331904,B.bg|=16777224|P-100):P===0?this._processSGR0(B):P===1?B.fg|=134217728:P===3?B.bg|=67108864:P===4?(B.fg|=268435456,this._processUnderline(T.hasSubParams($)?T.getSubParams($)[0]:1,B)):P===5?B.fg|=536870912:P===7?B.fg|=67108864:P===8?B.fg|=1073741824:P===9?B.fg|=2147483648:P===2?B.bg|=134217728:P===21?this._processUnderline(2,B):P===22?(B.fg&=-134217729,B.bg&=-134217729):P===23?B.bg&=-67108865:P===24?(B.fg&=-268435457,this._processUnderline(0,B)):P===25?B.fg&=-536870913:P===27?B.fg&=-67108865:P===28?B.fg&=-1073741825:P===29?B.fg&=2147483647:P===39?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):P===49?(B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(T,$,B):P===53?B.bg|=1073741824:P===55?B.bg&=-1073741825:P===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):P===100?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(T){switch(T.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${P}R`)}return!0}deviceStatusPrivate(T){if(T.params[0]===6){const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${P}R`)}return!0}softReset(T){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.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(T){const O=T.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 P=O%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(T){const O=T.params[0]||1;let P;return(T.length<2||(P=T.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(T){if(!D(T.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=T.length>1?T.params[1]:0;switch(T.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(A.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(A.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(T){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(T){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(T){return this._windowTitle=T,this._onTitleChange.fire(T),!0}setIconName(T){return this._iconName=T,!0}setOrReportIndexedColor(T){const O=[],P=T.split(";");for(;P.length>1;){const B=P.shift(),$=P.shift();if(/^\d+$/.exec(B)){const X=parseInt(B);if(F(X))if($==="?")O.push({type:0,index:X});else{const U=(0,C.parseColor)($);U&&O.push({type:1,index:X,color:U})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(T){const O=T.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(T,O){this._getCurrentLinkId()&&this._finishHyperlink();const P=T.split(":");let B;const $=P.findIndex((X=>X.startsWith("id=")));return $!==-1&&(B=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,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(T,O){const P=T.split(";");for(let B=0;B<P.length&&!(O>=this._specialColors.length);++B,++O)if(P[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const $=(0,C.parseColor)(P[B]);$&&this._onColor.fire([{type:1,index:this._specialColors[O],color:$}])}return!0}setOrReportFgColor(T){return this._setOrReportSpecialColor(T,0)}setOrReportBgColor(T){return this._setOrReportSpecialColor(T,1)}setOrReportCursorColor(T){return this._setOrReportSpecialColor(T,2)}restoreIndexedColor(T){if(!T)return this._onColor.fire([{type:2}]),!0;const O=[],P=T.split(";");for(let B=0;B<P.length;++B)if(/^\d+$/.exec(P[B])){const $=parseInt(P[B]);F($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(T){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(T){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(T){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,v.DEFAULT_CHARSET),!0}selectCharset(T){return T.length!==2?(this.selectDefaultCharset(),!0):(T[0]==="/"||this._charsetService.setgCharset(E[T[0]],v.CHARSETS[T[1]]||v.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 T=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,T,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=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(T){return this._charsetService.setgLevel(T),!0}screenAlignmentPattern(){const T=new h.CellData;T.content=4194373,T.fg=this._curAttrData.fg,T.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const P=this._activeBuffer.ybase+this._activeBuffer.y+O,B=this._activeBuffer.lines.get(P);B&&(B.fill(T),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(T,O){const P=this._bufferService.buffer,B=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(T==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:T==='"p'?'P1$r61;1"p':T==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:T==="m"?"P1$r0m":T===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(T,O){this._dirtyRowTracker.markRangeDirty(T,O)}}n.InputHandler=I;let L=class{constructor(H){this._bufferService=H,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(H){H<this.start?this.start=H:H>this.end&&(this.end=H)}markRangeDirty(H,T){H>T&&(M=H,H=T,T=M),H<this.start&&(this.start=H),T>this.end&&(this.end=T)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(H){return 0<=H&&H<256}L=l([u(0,w.IBufferService)],L)},844:(g,n)=>{function i(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},n.toDisposable=function(l){return{dispose:l}},n.disposeArray=i,n.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(u,c,v){this._data[u]||(this._data[u]={}),this._data[u][c]=v}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,u,c,v,b){this._data.get(l,u)||this._data.set(l,u,new i),this._data.get(l,u).set(c,v,b)}get(l,u,c,v){var b;return(b=this._data.get(l,u))===null||b===void 0?void 0:b.get(c,v)}clear(){this._data.clear()}}},6114:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,l=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const u=i.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),n.isIpad=l==="iPad",n.isIphone=l==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),n.isLinux=l.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(i=this._search(u),i===-1)||this._getKey(this._array[i])!==u)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,u){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do u(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let v=u+c>>1;const b=this._getKey(this._array[v]);if(b>l)c=v-1;else{if(!(b<l)){for(;v>0&&this._getKey(this._array[v-1])===l;)v--;return v}u=v+1}}return u}}},7226:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(b){this._tasks.push(b),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(b){this._idleCallback=void 0;let S=0,x=0,a=b.timeRemaining(),f=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),x=Math.max(S,x),f=b.timeRemaining(),1.5*x>f)return a-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-S))}ms`),void this._start();a=f}this.clear()}}class c extends u{_requestCallback(b){return setTimeout((()=>b(this._createDeadline(16))))}_cancelCallback(b){clearTimeout(b)}_createDeadline(b){const S=Date.now()+b;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(v){return requestIdleCallback(v)}_cancelCallback(v){cancelIdleCallback(v)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(v){this._queue.clear(),this._queue.enqueue(v)}flush(){this._queue.flush()}}},9282:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const l=i(643);n.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),v=c?.get(u.cols-1),b=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);b&&v&&(b.isWrapped=v[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&v[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}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 i;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}}n.AttributeData=i;class l{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,v=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=v}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=l},9092:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const l=i(6349),u=i(7226),c=i(3734),v=i(8437),b=i(4634),S=i(511),x=i(643),a=i(4863),f=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(d,h,_){this._hasScrollback=d,this._optionsService=h,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=v.DEFAULT_ATTR_DATA.clone(),this.savedCharset=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.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,h){return new v.BufferLine(this._bufferService.cols,this.getNullCell(d),h)}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 h=d+this._optionsService.rawOptions.scrollback;return h>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:h}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=v.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,h){const _=this.getNullCell(v.DEFAULT_ATTR_DATA);let w=0;const k=this._getCorrectBufferLength(h);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let C=0;C<this.lines.length;C++)w+=+this.lines.get(C).resize(d,_);let j=0;if(this._rows<h)for(let C=this._rows;C<h;C++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new v.BufferLine(d,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new v.BufferLine(d,_)));else for(let C=this._rows;C>h;C--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const C=this.lines.length-k;C>0&&(this.lines.trimStart(C),this.ybase=Math.max(this.ybase-C,0),this.ydisp=Math.max(this.ydisp-C,0),this.savedY=Math.max(this.savedY-C,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,h-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(d,h),this._cols>d))for(let j=0;j<this.lines.length;j++)w+=+this.lines.get(j).resize(d,_);this._cols=d,this._rows=h,this._memoryCleanupQueue.clear(),w>.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 h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>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,h){this._cols!==d&&(d>this._cols?this._reflowLarger(d,h):this._reflowSmaller(d,h))}_reflowLarger(d,h){const _=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(v.DEFAULT_ATTR_DATA));if(_.length>0){const w=(0,b.reflowLargerCreateNewLayout)(this.lines,_);(0,b.reflowLargerApplyNewLayout)(this.lines,w.layout),this._reflowLargerAdjustViewport(d,h,w.countRemoved)}}_reflowLargerAdjustViewport(d,h,_){const w=this.getNullCell(v.DEFAULT_ATTR_DATA);let k=_;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new v.BufferLine(d,w))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(d,h){const _=this.getNullCell(v.DEFAULT_ATTR_DATA),w=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let C=this.lines.get(j);if(!C||!C.isWrapped&&C.getTrimmedLength()<=d)continue;const E=[C];for(;C.isWrapped&&j>0;)C=this.lines.get(--j),E.unshift(C);const N=this.ybase+this.y;if(N>=j&&N<j+E.length)continue;const D=E[E.length-1].getTrimmedLength(),A=(0,b.reflowSmallerGetNewLineLengths)(E,this._cols,d),M=A.length-E.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const L=[];for(let B=0;B<M;B++){const $=this.getBlankLine(v.DEFAULT_ATTR_DATA,!0);L.push($)}L.length>0&&(w.push({start:j+E.length+k,newLines:L}),k+=L.length),E.push(...L);let F=A.length-1,H=A[F];H===0&&(F--,H=A[F]);let T=E.length-M-1,O=D;for(;T>=0;){const B=Math.min(O,H);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[T],O-B,H-B,B,!0),H-=B,H===0&&(F--,H=A[F]),O-=B,O===0){T--;const $=Math.max(T,0);O=(0,b.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let B=0;B<E.length;B++)A[B]<d&&E[B].setCell(A[B],_);let P=M-I;for(;P-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+h-1)}if(w.length>0){const j=[],C=[];for(let F=0;F<this.lines.length;F++)C.push(this.lines.get(F));const E=this.lines.length;let N=E-1,D=0,A=w[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let M=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(A&&A.start>N+M){for(let H=A.newLines.length-1;H>=0;H--)this.lines.set(F--,A.newLines[H]);F++,j.push({index:N+1,amount:A.newLines.length}),M+=A.newLines.length,A=w[++D]}else this.lines.set(F,C[N--]);let I=0;for(let F=j.length-1;F>=0;F--)j[F].index+=I,this.lines.onInsertEmitter.fire(j[F]),I+=j[F].amount;const L=Math.max(0,E+k-this.lines.maxLength);L>0&&this.lines.onTrimEmitter.fire(L)}}translateBufferLineToString(d,h,_=0,w){const k=this.lines.get(d);return k?k.translateToString(h,_,w):""}getWrappedRangeForLine(d){let h=d,_=d;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:h,last:_}}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 h=0;h<this.markers.length;h++)this.markers[h].line===d&&(this.markers[h].dispose(),this.markers.splice(h--,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 h=new a.Marker(d);return this.markers.push(h),h.register(this.lines.onTrim((_=>{h.line-=_,h.line<0&&h.dispose()}))),h.register(this.lines.onInsert((_=>{h.line>=_.index&&(h.line+=_.amount)}))),h.register(this.lines.onDelete((_=>{h.line>=_.index&&h.line<_.index+_.amount&&h.dispose(),h.line>_.index&&(h.line-=_.amount)}))),h.register(h.onDispose((()=>this._removeMarker(h)))),h}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const l=i(3734),u=i(511),c=i(643),v=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let b=0;class S{constructor(a,f,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const h=f||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let _=0;_<a;++_)this.setCell(_,h);this.length=a}get(a){const f=this._data[3*a+0],d=2097151&f;return[this._data[3*a+1],2097152&f?this._combined[a]:d?(0,v.stringFromCodePoint)(d):"",f>>22,2097152&f?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,f){this._data[3*a+1]=f[c.CHAR_DATA_ATTR_INDEX],f[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=f[1],this._data[3*a+0]=2097152|a|f[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=f[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const f=this._data[3*a+0];return 2097152&f?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&f}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const f=this._data[3*a+0];return 2097152&f?this._combined[a]:2097151&f?(0,v.stringFromCodePoint)(2097151&f):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,f){return b=3*a,f.content=this._data[b+0],f.fg=this._data[b+1],f.bg=this._data[b+2],2097152&f.content&&(f.combinedData=this._combined[a]),268435456&f.bg&&(f.extended=this._extendedAttrs[a]),f}setCell(a,f){2097152&f.content&&(this._combined[a]=f.combinedData),268435456&f.bg&&(this._extendedAttrs[a]=f.extended),this._data[3*a+0]=f.content,this._data[3*a+1]=f.fg,this._data[3*a+2]=f.bg}setCellFromCodePoint(a,f,d,h,_,w){268435456&_&&(this._extendedAttrs[a]=w),this._data[3*a+0]=f|d<<22,this._data[3*a+1]=h,this._data[3*a+2]=_}addCodepointToCell(a,f){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,v.stringFromCodePoint)(f):(2097151&d?(this._combined[a]=(0,v.stringFromCodePoint)(2097151&d)+(0,v.stringFromCodePoint)(f),d&=-2097152,d|=2097152):d=f|4194304,this._data[3*a+0]=d)}insertCells(a,f,d,h){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length-a){const _=new u.CellData;for(let w=this.length-a-f-1;w>=0;--w)this.setCell(a+f+w,this.loadCell(a+w,_));for(let w=0;w<f;++w)this.setCell(a+w,d)}else for(let _=a;_<this.length;++_)this.setCell(_,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs)}deleteCells(a,f,d,h){if(a%=this.length,f<this.length-a){const _=new u.CellData;for(let w=0;w<this.length-a-f;++w)this.setCell(a+w,this.loadCell(a+f+w,_));for(let w=this.length-f;w<this.length;++w)this.setCell(w,d)}else for(let _=a;_<this.length;++_)this.setCell(_,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs)}replaceCells(a,f,d,h,_=!1){if(_)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&!this.isProtected(f)&&this.setCellFromCodePoint(f,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs);a<f&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs);a<f&&a<this.length;)this.setCell(a++,d)}resize(a,f){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const h=new Uint32Array(d);h.set(this._data),this._data=h}for(let h=this.length;h<a;++h)this.setCell(h,f)}else{this._data=this._data.subarray(0,d);const h=Object.keys(this._combined);for(let w=0;w<h.length;w++){const k=parseInt(h[w],10);k>=a&&delete this._combined[k]}const _=Object.keys(this._extendedAttrs);for(let w=0;w<_.length;w++){const k=parseInt(_[w],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,f=!1){if(f)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const f in a._combined)this._combined[f]=a._combined[f];this._extendedAttrs={};for(const f in a._extendedAttrs)this._extendedAttrs[f]=a._extendedAttrs[f];this.isWrapped=a.isWrapped}clone(){const a=new S(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const f in this._combined)a._combined[f]=this._combined[f];for(const f in this._extendedAttrs)a._extendedAttrs[f]=this._extendedAttrs[f];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,f,d,h,_){const w=a._data;if(_)for(let j=h-1;j>=0;j--){for(let C=0;C<3;C++)this._data[3*(d+j)+C]=w[3*(f+j)+C];268435456&w[3*(f+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[f+j])}else for(let j=0;j<h;j++){for(let C=0;C<3;C++)this._data[3*(d+j)+C]=w[3*(f+j)+C];268435456&w[3*(f+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[f+j])}const k=Object.keys(a._combined);for(let j=0;j<k.length;j++){const C=parseInt(k[j],10);C>=f&&(this._combined[C-f+d]=a._combined[C])}}translateToString(a=!1,f=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let h="";for(;f<d;){const _=this._data[3*f+0],w=2097151&_;h+=2097152&_?this._combined[f]:w?(0,v.stringFromCodePoint)(w):c.WHITESPACE_CELL_CHAR,f+=_>>22||1}return h}}n.BufferLine=S},4841:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(g,n)=>{function i(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const v=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,b=l[u+1].getWidth(0)===2;return v&&b?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(l,u,c,v,b){const S=[];for(let x=0;x<l.length-1;x++){let a=x,f=l.get(++a);if(!f.isWrapped)continue;const d=[l.get(x)];for(;a<l.length&&f.isWrapped;)d.push(f),f=l.get(++a);if(v>=x&&v<a){x+=d.length-1;continue}let h=0,_=i(d,h,u),w=1,k=0;for(;w<d.length;){const C=i(d,w,u),E=C-k,N=c-_,D=Math.min(E,N);d[h].copyCellsFrom(d[w],k,_,D,!1),_+=D,_===c&&(h++,_=0),k+=D,k===C&&(w++,k=0),_===0&&h!==0&&d[h-1].getWidth(c-1)===2&&(d[h].copyCellsFrom(d[h-1],c-1,_++,1,!1),d[h-1].setCell(c-1,b))}d[h].replaceCells(_,c,b);let j=0;for(let C=d.length-1;C>0&&(C>h||d[C].getTrimmedLength()===0);C--)j++;j>0&&(S.push(x+d.length-j),S.push(j)),x+=d.length-1}return S},n.reflowLargerCreateNewLayout=function(l,u){const c=[];let v=0,b=u[v],S=0;for(let x=0;x<l.length;x++)if(b===x){const a=u[++v];l.onDeleteEmitter.fire({index:x-S,amount:a}),x+=a-1,S+=a,b=u[++v]}else c.push(x);return{layout:c,countRemoved:S}},n.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let v=0;v<u.length;v++)c.push(l.get(u[v]));for(let v=0;v<c.length;v++)l.set(v,c[v]);l.length=u.length},n.reflowSmallerGetNewLineLengths=function(l,u,c){const v=[],b=l.map(((f,d)=>i(l,d,u))).reduce(((f,d)=>f+d));let S=0,x=0,a=0;for(;a<b;){if(b-a<c){v.push(b-a);break}S+=c;const f=i(l,x,u);S>f&&(S-=f,x++);const d=l[x].getWidth(S-1)===2;d&&S--;const h=d?c-1:c;v.push(h),a+=h}return v},n.getWrappedLineTrimmedLength=i},5295:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const l=i(8460),u=i(844),c=i(9092);class v extends u.Disposable{constructor(S,x){super(),this._optionsService=S,this._bufferService=x,this._onBufferActivate=this.register(new l.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(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),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(S,x){this._normal.resize(S,x),this._alt.resize(S,x),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}n.BufferSet=v},511:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),u=i(643),c=i(3734);class v extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const x=new v;return x.setFromCharData(S),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(S[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(S[u.CHAR_DATA_CHAR_INDEX].length===2){const a=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const f=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=f&&f<=57343?this.content=1024*(a-55296)+f-56320+65536|S[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=S[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=v},643:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const l=i(8460),u=i(844);class c{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}n.Marker=c,c._nextId=1},7116:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.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:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(g,n)=>{var i,l,u;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.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=""})(i||(n.C0=i={})),(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=""})(l||(n.C1=l={})),(function(c){c.ST=`${i.ESC}\\`})(u||(n.C1_ESCAPED=u={}))},7399:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),u={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:["'",'"']};n.evaluateKeyboardEvent=function(c,v,b,S){const x={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?x.key=v?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?x.key=v?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?x.key=v?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(x.key=v?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){x.key=l.C0.ESC+l.C0.DEL;break}x.key=l.C0.DEL;break;case 9:if(c.shiftKey){x.key=l.C0.ESC+"[Z";break}x.key=l.C0.HT,x.cancel=!0;break;case 13:x.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,x.cancel=!0;break;case 27:x.key=l.C0.ESC,c.altKey&&(x.key=l.C0.ESC+l.C0.ESC),x.cancel=!0;break;case 37:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"D",x.key===l.C0.ESC+"[1;3D"&&(x.key=l.C0.ESC+(b?"b":"[1;5D"))):x.key=v?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"C",x.key===l.C0.ESC+"[1;3C"&&(x.key=l.C0.ESC+(b?"f":"[1;5C"))):x.key=v?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"A",b||x.key!==l.C0.ESC+"[1;3A"||(x.key=l.C0.ESC+"[1;5A")):x.key=v?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"B",b||x.key!==l.C0.ESC+"[1;3B"||(x.key=l.C0.ESC+"[1;5B")):x.key=v?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(x.key=l.C0.ESC+"[2~");break;case 46:x.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:x.key=a?l.C0.ESC+"[1;"+(a+1)+"H":v?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:x.key=a?l.C0.ESC+"[1;"+(a+1)+"F":v?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?x.type=2:c.ctrlKey?x.key=l.C0.ESC+"[5;"+(a+1)+"~":x.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?x.type=3:c.ctrlKey?x.key=l.C0.ESC+"[6;"+(a+1)+"~":x.key=l.C0.ESC+"[6~";break;case 112:x.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:x.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:x.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:x.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:x.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:x.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:x.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:x.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:x.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:x.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:x.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:x.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(b&&!S||!c.altKey||c.metaKey)!b||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?x.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(x.key=l.C0.US),c.key==="@"&&(x.key=l.C0.NUL)):c.keyCode===65&&(x.type=1);else{const f=u[c.keyCode],d=f?.[c.shiftKey?1:0];if(d)x.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const h=c.ctrlKey?c.keyCode-64:c.keyCode+32;let _=String.fromCharCode(h);c.shiftKey&&(_=_.toUpperCase()),x.key=l.C0.ESC+_}else if(c.keyCode===32)x.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let h=c.code.slice(3,4);c.shiftKey||(h=h.toLowerCase()),x.key=l.C0.ESC+h,x.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?x.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?x.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?x.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?x.key=l.C0.DEL:c.keyCode===219?x.key=l.C0.ESC:c.keyCode===220?x.key=l.C0.FS:c.keyCode===221&&(x.key=l.C0.GS)}return x}},482:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,l=0,u=i.length){let c="";for(let v=l;v<u;++v){let b=i[v];b>65535?(b-=65536,c+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):c+=String.fromCharCode(b)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const u=i.length;if(!u)return 0;let c=0,v=0;if(this._interim){const b=i.charCodeAt(v++);56320<=b&&b<=57343?l[c++]=1024*(this._interim-55296)+b-56320+65536:(l[c++]=this._interim,l[c++]=b),this._interim=0}for(let b=v;b<u;++b){const S=i.charCodeAt(b);if(55296<=S&&S<=56319){if(++b>=u)return this._interim=S,c;const x=i.charCodeAt(b);56320<=x&&x<=57343?l[c++]=1024*(S-55296)+x-56320+65536:(l[c++]=S,l[c++]=x)}else S!==65279&&(l[c++]=S)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const u=i.length;if(!u)return 0;let c,v,b,S,x=0,a=0,f=0;if(this.interim[0]){let _=!1,w=this.interim[0];w&=(224&w)==192?31:(240&w)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)w<<=6,w|=k;const C=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=C-j;for(;f<E;){if(f>=u)return 0;if(k=i[f++],(192&k)!=128){f--,_=!0;break}this.interim[j++]=k,w<<=6,w|=63&k}_||(C===2?w<128?f--:l[x++]=w:C===3?w<2048||w>=55296&&w<=57343||w===65279||(l[x++]=w):w<65536||w>1114111||(l[x++]=w)),this.interim.fill(0)}const d=u-4;let h=f;for(;h<u;){for(;!(!(h<d)||128&(c=i[h])||128&(v=i[h+1])||128&(b=i[h+2])||128&(S=i[h+3]));)l[x++]=c,l[x++]=v,l[x++]=b,l[x++]=S,h+=4;if(c=i[h++],c<128)l[x++]=c;else if((224&c)==192){if(h>=u)return this.interim[0]=c,x;if(v=i[h++],(192&v)!=128){h--;continue}if(a=(31&c)<<6|63&v,a<128){h--;continue}l[x++]=a}else if((240&c)==224){if(h>=u)return this.interim[0]=c,x;if(v=i[h++],(192&v)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=v,x;if(b=i[h++],(192&b)!=128){h--;continue}if(a=(15&c)<<12|(63&v)<<6|63&b,a<2048||a>=55296&&a<=57343||a===65279)continue;l[x++]=a}else if((248&c)==240){if(h>=u)return this.interim[0]=c,x;if(v=i[h++],(192&v)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=v,x;if(b=i[h++],(192&b)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=v,this.interim[2]=b,x;if(S=i[h++],(192&S)!=128){h--;continue}if(a=(7&c)<<18|(63&v)<<12|(63&b)<<6|63&S,a<65536||a>1114111)continue;l[x++]=a}}return x}}},225:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[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]],l=[[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 u;n.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<i.length;++c)u.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(v,b){let S,x=0,a=b.length-1;if(v<b[0][0]||v>b[a][1])return!1;for(;a>=x;)if(S=x+a>>1,v>b[S][1])x=S+1;else{if(!(v<b[S][0]))return!0;a=S-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const l=i(8460),u=i(844);class c extends u.Disposable{constructor(b){super(),this._action=b,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(b,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(b,S){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+=b.length,this._writeBuffer.push(b),this._callbacks.push(S),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(S)}_innerWrite(b=0,S=!0){const x=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],f=this._action(a,S);if(f){const h=_=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(x,_);return void f.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(h)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=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()}}n.WriteBuffer=c},5941:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\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})$/,l=/^[\da-f]+$/;function u(c,v){const b=c.toString(16),S=b.length<2?"0"+b:b;switch(v){case 4:return b[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}n.parseColor=function(c){if(!c)return;let v=c.toLowerCase();if(v.indexOf("rgb:")===0){v=v.slice(4);const b=i.exec(v);if(b){const S=b[1]?15:b[4]?255:b[7]?4095:65535;return[Math.round(parseInt(b[1]||b[4]||b[7]||b[10],16)/S*255),Math.round(parseInt(b[2]||b[5]||b[8]||b[11],16)/S*255),Math.round(parseInt(b[3]||b[6]||b[9]||b[12],16)/S*255)]}}else if(v.indexOf("#")===0&&(v=v.slice(1),l.exec(v)&&[3,6,9,12].includes(v.length))){const b=v.length/3,S=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(v.slice(b*x,b*x+b),16);S[x]=b===1?a<<4:b===2?a:b===3?a>>4:a>>8}return S}},n.toRgbString=function(c,v=16){const[b,S,x]=c;return`rgb:${u(b,v)}/${u(S,v)}/${u(x,v)}`}},5770:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const l=i(482),u=i(8742),c=i(5770),v=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=v,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=v}registerHandler(S,x){this._handlers[S]===void 0&&(this._handlers[S]=[]);const a=this._handlers[S];return a.push(x),{dispose:()=>{const f=a.indexOf(x);f!==-1&&a.splice(f,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=v,this._ident=0}hook(S,x){if(this.reset(),this._ident=S,this._active=this._handlers[S]||v,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(S,x,a){if(this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].put(S,x,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(S,x,a))}unhook(S,x=!0){if(this._active.length){let a=!1,f=this._active.length-1,d=!1;if(this._stack.paused&&(f=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;f>=0&&(a=this._active[f].unhook(S),a!==!0);f--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!1,a;f--}for(;f>=0;f--)if(a=this._active[f].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",S);this._active=v,this._ident=0}};const b=new u.Params;b.addParam(0),n.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=b,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():b,this._data="",this._hitLimit=!1}put(S,x,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(S,x,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let x=!1;if(this._hitLimit)x=!1;else if(S&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=b,this._data="",this._hitLimit=!1,a)));return this._params=b,this._data="",this._hitLimit=!1,x}}},2015:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const l=i(844),u=i(8742),c=i(6242),v=i(6351);class b{constructor(f){this.table=new Uint8Array(f)}setDefault(f,d){this.table.fill(f<<4|d)}add(f,d,h,_){this.table[d<<8|f]=h<<4|_}addMany(f,d,h,_){for(let w=0;w<f.length;w++)this.table[d<<8|f[w]]=h<<4|_}}n.TransitionTable=b;const S=160;n.VT500_TRANSITION_TABLE=(function(){const a=new b(4095),f=Array.apply(null,Array(256)).map(((j,C)=>C)),d=(j,C)=>f.slice(j,C),h=d(32,127),_=d(0,24);_.push(25),_.push.apply(_,d(28,32));const w=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(h,0,2,0),w)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(_,0,3,0),a.addMany(_,1,3,1),a.add(127,1,0,1),a.addMany(_,8,0,8),a.addMany(_,3,3,3),a.add(127,3,0,3),a.addMany(_,4,3,4),a.add(127,4,0,4),a.addMany(_,6,3,6),a.addMany(_,5,3,5),a.add(127,5,0,5),a.addMany(_,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(h,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(h,7,0,7),a.addMany(_,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(_,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(_,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(_,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(_,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(_,13,13,13),a.addMany(h,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(S,0,2,0),a.add(S,8,5,8),a.add(S,6,0,6),a.add(S,11,0,11),a.add(S,13,13,13),a})();class x extends l.Disposable{constructor(f=n.VT500_TRANSITION_TABLE){super(),this._transitions=f,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,h,_)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,h)=>{},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,l.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 v.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(f,d=[64,126]){let h=0;if(f.prefix){if(f.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=f.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(f.intermediates){if(f.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let w=0;w<f.intermediates.length;++w){const k=f.intermediates.charCodeAt(w);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=k}}if(f.final.length!==1)throw new Error("final must be a single byte");const _=f.final.charCodeAt(0);if(d[0]>_||_>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return h<<=8,h|=_,h}identToString(f){const d=[];for(;f;)d.push(String.fromCharCode(255&f)),f>>=8;return d.reverse().join("")}setPrintHandler(f){this._printHandler=f}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(f,d){const h=this._identifier(f,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const _=this._escHandlers[h];return _.push(d),{dispose:()=>{const w=_.indexOf(d);w!==-1&&_.splice(w,1)}}}clearEscHandler(f){this._escHandlers[this._identifier(f,[48,126])]&&delete this._escHandlers[this._identifier(f,[48,126])]}setEscHandlerFallback(f){this._escHandlerFb=f}setExecuteHandler(f,d){this._executeHandlers[f.charCodeAt(0)]=d}clearExecuteHandler(f){this._executeHandlers[f.charCodeAt(0)]&&delete this._executeHandlers[f.charCodeAt(0)]}setExecuteHandlerFallback(f){this._executeHandlerFb=f}registerCsiHandler(f,d){const h=this._identifier(f);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const _=this._csiHandlers[h];return _.push(d),{dispose:()=>{const w=_.indexOf(d);w!==-1&&_.splice(w,1)}}}clearCsiHandler(f){this._csiHandlers[this._identifier(f)]&&delete this._csiHandlers[this._identifier(f)]}setCsiHandlerFallback(f){this._csiHandlerFb=f}registerDcsHandler(f,d){return this._dcsParser.registerHandler(this._identifier(f),d)}clearDcsHandler(f){this._dcsParser.clearHandler(this._identifier(f))}setDcsHandlerFallback(f){this._dcsParser.setHandlerFallback(f)}registerOscHandler(f,d){return this._oscParser.registerHandler(f,d)}clearOscHandler(f){this._oscParser.clearHandler(f)}setOscHandlerFallback(f){this._oscParser.setHandlerFallback(f)}setErrorHandler(f){this._errorHandler=f}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(f,d,h,_,w){this._parseStack.state=f,this._parseStack.handlers=d,this._parseStack.handlerPos=h,this._parseStack.transition=_,this._parseStack.chunkPos=w}parse(f,d,h){let _,w=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const C=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&E>-1){for(;E>=0&&(_=C[E](this._params),_!==!0);E--)if(_ instanceof Promise)return this._parseStack.handlerPos=E,_}this._parseStack.handlers=[];break;case 4:if(h===!1&&E>-1){for(;E>=0&&(_=C[E](),_!==!0);E--)if(_ instanceof Promise)return this._parseStack.handlerPos=E,_}this._parseStack.handlers=[];break;case 6:if(w=f[this._parseStack.chunkPos],_=this._dcsParser.unhook(w!==24&&w!==26,h),_)return _;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(w=f[this._parseStack.chunkPos],_=this._oscParser.end(w!==24&&w!==26,h),_)return _;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let C=j;C<d;++C){switch(w=f[C],k=this._transitions.table[this.currentState<<8|(w<160?w:S)],k>>4){case 2:for(let M=C+1;;++M){if(M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}}break;case 3:this._executeHandlers[w]?this._executeHandlers[w]():this._executeHandlerFb(w),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:C,code:w,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|w];let N=E?E.length-1:-1;for(;N>=0&&(_=E[N](this._params),_!==!0);N--)if(_ instanceof Promise)return this._preserveStack(3,E,N,k,C),_;N<0&&this._csiHandlerFb(this._collect<<8|w,this._params),this.precedingCodepoint=0;break;case 8:do switch(w){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(w-48)}while(++C<d&&(w=f[C])>47&&w<60);C--;break;case 9:this._collect<<=8,this._collect|=w;break;case 10:const D=this._escHandlers[this._collect<<8|w];let A=D?D.length-1:-1;for(;A>=0&&(_=D[A](),_!==!0);A--)if(_ instanceof Promise)return this._preserveStack(4,D,A,k,C),_;A<0&&this._escHandlerFb(this._collect<<8|w),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|w,this._params);break;case 13:for(let M=C+1;;++M)if(M>=d||(w=f[M])===24||w===26||w===27||w>127&&w<S){this._dcsParser.put(f,C,M),C=M-1;break}break;case 14:if(_=this._dcsParser.unhook(w!==24&&w!==26),_)return this._preserveStack(6,[],0,k,C),_;w===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 M=C+1;;M++)if(M>=d||(w=f[M])<32||w>127&&w<S){this._oscParser.put(f,C,M),C=M-1;break}break;case 6:if(_=this._oscParser.end(w!==24&&w!==26),_)return this._preserveStack(5,[],0,k,C),_;w===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=x},6242:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const l=i(5770),u=i(482),c=[];n.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(v,b){this._handlers[v]===void 0&&(this._handlers[v]=[]);const S=this._handlers[v];return S.push(b),{dispose:()=>{const x=S.indexOf(b);x!==-1&&S.splice(x,1)}}}clearHandler(v){this._handlers[v]&&delete this._handlers[v]}setHandlerFallback(v){this._handlerFb=v}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let v=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;v>=0;--v)this._active[v].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 v=this._active.length-1;v>=0;v--)this._active[v].start();else this._handlerFb(this._id,"START")}_put(v,b,S){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(v,b,S);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(v,b,S))}start(){this.reset(),this._state=1}put(v,b,S){if(this._state!==3){if(this._state===1)for(;b<S;){const x=v[b++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&S-b>0&&this._put(v,b,S)}}end(v,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,S=b,a=this._stack.fallThrough,this._stack.paused=!1),!a&&S===!1){for(;x>=0&&(S=this._active[x].end(v),S!==!0);x--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,S;x--}for(;x>=0;x--)if(S=this._active[x].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",v);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(v){this._handler=v,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(v,b,S){this._hitLimit||(this._data+=(0,u.utf32ToString)(v,b,S),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(v){let b=!1;if(this._hitLimit)b=!1;else if(v&&(b=this._handler(this._data),b instanceof Promise))return b.then((S=>(this._data="",this._hitLimit=!1,S)));return this._data="",this._hitLimit=!1,b}}},8742:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class l{static fromArray(c){const v=new l;if(!c.length)return v;for(let b=Array.isArray(c[0])?1:0;b<c.length;++b){const S=c[b];if(Array.isArray(S))for(let x=0;x<S.length;++x)v.addSubParam(S[x]);else v.addParam(S)}return v}constructor(c=32,v=32){if(this.maxLength=c,this.maxSubParamsLength=v,v>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(v),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(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 v=0;v<this.length;++v){c.push(this.params[v]);const b=this._subParamsIdx[v]>>8,S=255&this._subParamsIdx[v];S-b>0&&c.push(Array.prototype.slice.call(this._subParams,b,S))}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>i?i: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>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const v=this._subParamsIdx[c]>>8,b=255&this._subParamsIdx[c];return b-v>0?this._subParams.subarray(v,b):null}getSubParamsAll(){const c={};for(let v=0;v<this.length;++v){const b=this._subParamsIdx[v]>>8,S=255&this._subParamsIdx[v];S-b>0&&(c[v]=this._subParams.slice(b,S))}return c}addDigit(c){let v;if(this._rejectDigits||!(v=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,S=b[v-1];b[v-1]=~S?Math.min(10*S+c,i):c}}n.Params=l},5741:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===i){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const l=i(3785),u=i(511);n.BufferApiView=class{constructor(c,v){this._buffer=c,this.type=v}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 v=this._buffer.lines.get(c);if(v)return new l.BufferLineApiView(v)}getNullCell(){return new u.CellData}}},3785:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new l.CellData)}translateToString(u,c,v){return this._line.translateToString(u,c,v)}}},8285:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),u=i(8460),c=i(844);class v extends c.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.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)}}n.BufferNamespaceApi=v},7975:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(u=>l(u.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((u,c)=>l(u,c.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(g,n,i){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),v=i(844),b=i(5295),S=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let x=n.BufferService=class extends v.Disposable{get buffer(){return this.buffers.active}constructor(a){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(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(a,this))}resize(a,f){this.cols=a,this.rows=f,this.buffers.resize(a,f),this._onResize.fire({cols:a,rows:f})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,f=!1){const d=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===a.fg&&h.getBg(0)===a.bg||(h=d.getBlankLine(a,f),this._cachedBlankLine=h),h.isWrapped=f;const _=d.ybase+d.scrollTop,w=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;w===d.lines.length-1?k?d.lines.recycle().copyFrom(h):d.lines.push(h.clone()):d.lines.splice(w+1,0,h.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=w-_+1;d.lines.shiftElements(_+1,k-1,-1),d.lines.set(w,h.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,f,d){const h=this.buffer;if(a<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else a+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const _=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+a,h.ybase),0),_!==h.ydisp&&(f||this._onScroll.fire(h.ydisp))}};n.BufferService=x=l([u(0,S.IOptionsService)],x)},7994:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(g,n,i){var l=this&&this.__decorate||function(h,_,w,k){var j,C=arguments.length,E=C<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,_,w,k);else for(var N=h.length-1;N>=0;N--)(j=h[N])&&(E=(C<3?j(E):C>3?j(_,w,E):j(_,w))||E);return C>3&&E&&Object.defineProperty(_,w,E),E},u=this&&this.__param||function(h,_){return function(w,k){_(w,k,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),v=i(8460),b=i(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function x(h,_){let w=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(w|=64,w|=h.action):(w|=3&h.button,4&h.button&&(w|=64),8&h.button&&(w|=128),h.action===32?w|=32:h.action!==0||_||(w|=3)),w}const a=String.fromCharCode,f={DEFAULT:h=>{const _=[x(h,!1)+32,h.col+32,h.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${a(_[0])}${a(_[1])}${a(_[2])}`},SGR:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${x(h,!0)};${h.col};${h.row}${_}`},SGR_PIXELS:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${x(h,!0)};${h.x};${h.y}${_}`}};let d=n.CoreMouseService=class extends b.Disposable{constructor(h,_){super(),this._bufferService=h,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new v.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const w of Object.keys(S))this.addProtocol(w,S[w]);for(const w of Object.keys(f))this.addEncoding(w,f[w]);this.reset()}addProtocol(h,_){this._protocols[h]=_}addEncoding(h,_){this._encodings[h]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const _=this._encodings[this._activeEncoding](h);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,_,w){if(w){if(h.x!==_.x||h.y!==_.y)return!1}else if(h.col!==_.col||h.row!==_.row)return!1;return h.button===_.button&&h.action===_.action&&h.ctrl===_.ctrl&&h.alt===_.alt&&h.shift===_.shift}};n.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(g,n,i){var l=this&&this.__decorate||function(d,h,_,w){var k,j=arguments.length,C=j<3?h:w===null?w=Object.getOwnPropertyDescriptor(h,_):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(d,h,_,w);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(C=(j<3?k(C):j>3?k(h,_,C):k(h,_))||C);return j>3&&C&&Object.defineProperty(h,_,C),C},u=this&&this.__param||function(d,h){return function(_,w){h(_,w,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),v=i(8460),b=i(844),S=i(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let f=n.CoreService=class extends b.Disposable{constructor(d,h,_){super(),this._bufferService=d,this._logService=h,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new v.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new v.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((w=>w.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((h=>h.charCodeAt(0))))),this._onBinary.fire(d))}};n.CoreService=f=l([u(0,S.IBufferService),u(1,S.ILogService),u(2,S.IOptionsService)],f)},9074:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),u=i(8460),c=i(844),v=i(6106);let b=0,S=0;class x extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new v.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const h=new a(d);if(h){const _=h.marker.onDispose((()=>h.dispose()));h.onDispose((()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),_.dispose())})),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,h,_){var w,k,j;let C=0,E=0;for(const N of this._decorations.getKeyIterator(h))C=(w=N.options.x)!==null&&w!==void 0?w:0,E=C+((k=N.options.width)!==null&&k!==void 0?k:1),d>=C&&d<E&&(!_||((j=N.options.layer)!==null&&j!==void 0?j:"bottom")===_)&&(yield N)}forEachDecorationAtCell(d,h,_,w){this._decorations.forEachByKey(h,(k=>{var j,C,E;b=(j=k.options.x)!==null&&j!==void 0?j:0,S=b+((C=k.options.width)!==null&&C!==void 0?C:1),d>=b&&d<S&&(!_||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&w(k)}))}}n.DecorationService=x;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.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:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const l=i(2585),u=i(8343);class c{constructor(...b){this._entries=new Map;for(const[S,x]of b)this.set(S,x)}set(b,S){const x=this._entries.get(b);return this._entries.set(b,S),x}forEach(b){for(const[S,x]of this._entries.entries())b(S,x)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(v,b){this._services.set(v,b)}getService(v){return this._services.get(v)}createInstance(v,...b){const S=(0,u.getServiceDependencies)(v).sort(((f,d)=>f.index-d.index)),x=[];for(const f of S){const d=this._services.get(f.id);if(!d)throw new Error(`[createInstance] ${v.name} depends on UNKNOWN service ${f.id}.`);x.push(d)}const a=S.length>0?S[0].index:b.length;if(b.length!==a)throw new Error(`[createInstance] First service dependency of ${v.name} at position ${a+1} conflicts with ${b.length} static arguments`);return new v(...b,...x)}}},7866:function(g,n,i){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),v=i(2585),b={trace:v.LogLevelEnum.TRACE,debug:v.LogLevelEnum.DEBUG,info:v.LogLevelEnum.INFO,warn:v.LogLevelEnum.WARN,error:v.LogLevelEnum.ERROR,off:v.LogLevelEnum.OFF};let S,x=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=v.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let f=0;f<a.length;f++)typeof a[f]=="function"&&(a[f]=a[f]())}_log(a,f,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+f,...d)}trace(a,...f){var d,h;this._logLevel<=v.LogLevelEnum.TRACE&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,a,f)}debug(a,...f){var d,h;this._logLevel<=v.LogLevelEnum.DEBUG&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,a,f)}info(a,...f){var d,h;this._logLevel<=v.LogLevelEnum.INFO&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,a,f)}warn(a,...f){var d,h;this._logLevel<=v.LogLevelEnum.WARN&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,a,f)}error(a,...f){var d,h;this._logLevel<=v.LogLevelEnum.ERROR&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,a,f)}};n.LogService=x=l([u(0,v.IOptionsService)],x),n.setTraceLogger=function(a){S=a},n.traceCall=function(a,f,d){if(typeof d.value!="function")throw new Error("not supported");const h=d.value;d.value=function(..._){if(S.logLevel!==v.LogLevelEnum.TRACE)return h.apply(this,_);S.trace(`GlyphRenderer#${h.name}(${_.map((k=>JSON.stringify(k))).join(", ")})`);const w=h.apply(this,_);return S.trace(`GlyphRenderer#${h.name} return`,w),w}}},7302:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const l=i(8460),u=i(844),c=i(6114);n.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 v=["normal","bold","100","200","300","400","500","600","700","800","900"];class b extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const f in x)if(f in a)try{const d=x[f];a[f]=this._sanitizeAndValidateOption(f,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((f=>{f===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((f=>{x.indexOf(f)!==-1&&a()}))}_setupOptions(){const x=f=>{if(!(f in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);return this.rawOptions[f]},a=(f,d)=>{if(!(f in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);d=this._sanitizeAndValidateOption(f,d),this.rawOptions[f]!==d&&(this.rawOptions[f]=d,this._onOptionChange.fire(f))};for(const f in this.rawOptions){const d={get:x.bind(this,f),set:a.bind(this,f)};Object.defineProperty(this.options,f,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[x]),!(function(f){return f==="block"||f==="underline"||f==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=v.includes(a)?a:n.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=b},2660:function(g,n,i){var l=this&&this.__decorate||function(b,S,x,a){var f,d=arguments.length,h=d<3?S:a===null?a=Object.getOwnPropertyDescriptor(S,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(b,S,x,a);else for(var _=b.length-1;_>=0;_--)(f=b[_])&&(h=(d<3?f(h):d>3?f(S,x,h):f(S,x))||h);return d>3&&h&&Object.defineProperty(S,x,h),h},u=this&&this.__param||function(b,S){return function(x,a){S(x,a,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let v=n.OscLinkService=class{constructor(b){this._bufferService=b,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(b){const S=this._bufferService.buffer;if(b.id===void 0){const _=S.addMarker(S.ybase+S.y),w={data:b,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(w,_))),this._dataByLinkId.set(w.id,w),w.id}const x=b,a=this._getEntryIdKey(x),f=this._entriesWithId.get(a);if(f)return this.addLineToLink(f.id,S.ybase+S.y),f.id;const d=S.addMarker(S.ybase+S.y),h={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(h,d))),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(b,S){const x=this._dataByLinkId.get(b);if(x&&x.lines.every((a=>a.line!==S))){const a=this._bufferService.buffer.addMarker(S);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(b){var S;return(S=this._dataByLinkId.get(b))===null||S===void 0?void 0:S.data}_getEntryIdKey(b){return`${b.id};;${b.uri}`}_removeMarkerFromLink(b,S){const x=b.lines.indexOf(S);x!==-1&&(b.lines.splice(x,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};n.OscLinkService=v=l([u(0,c.IBufferService)],v)},8343:(g,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",l="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(u){return u[l]||[]},n.createDecorator=function(u){if(n.serviceRegistry.has(u))return n.serviceRegistry.get(u);const c=function(v,b,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,f){a[i]===a?a[l].push({id:x,index:f}):(a[l]=[{id:x,index:f}],a[i]=a)})(c,v,S)};return c.toString=()=>u,n.serviceRegistry.set(u,c),c}},2585:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const l=i(8343);var u;n.IBufferService=(0,l.createDecorator)("BufferService"),n.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),n.ICoreService=(0,l.createDecorator)("CoreService"),n.ICharsetService=(0,l.createDecorator)("CharsetService"),n.IInstantiationService=(0,l.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"})(u||(n.LogLevelEnum=u={})),n.ILogService=(0,l.createDecorator)("LogService"),n.IOptionsService=(0,l.createDecorator)("OptionsService"),n.IOscLinkService=(0,l.createDecorator)("OscLinkService"),n.IUnicodeService=(0,l.createDecorator)("UnicodeService"),n.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(g,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const l=i(8460),u=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new u.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 v=0;const b=c.length;for(let S=0;S<b;++S){let x=c.charCodeAt(S);if(55296<=x&&x<=56319){if(++S>=b)return v+this.wcwidth(x);const a=c.charCodeAt(S);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:v+=this.wcwidth(a)}v+=this.wcwidth(x)}return v}}}},o={};function m(g){var n=o[g];if(n!==void 0)return n.exports;var i=o[g]={exports:{}};return r[g].call(i.exports,i,i.exports,m),i.exports}var p={};return(()=>{var g=p;Object.defineProperty(g,"__esModule",{value:!0}),g.Terminal=void 0;const n=m(9042),i=m(3236),l=m(844),u=m(5741),c=m(8285),v=m(7975),b=m(7090),S=["cols","rows"];class x extends l.Disposable{constructor(f){super(),this._core=this.register(new i.Terminal(f)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=_=>this._core.options[_],h=(_,w)=>{this._checkReadonlyOptions(_),this._core.options[_]=w};for(const _ in this._core.options){const w={get:d.bind(this,_),set:h.bind(this,_)};Object.defineProperty(this._publicOptions,_,w)}}_checkReadonlyOptions(f){if(S.includes(f))throw new Error(`Option "${f}" 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 v.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new b.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 f=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:f.applicationCursorKeys,applicationKeypadMode:f.applicationKeypad,bracketedPasteMode:f.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:f.origin,reverseWraparoundMode:f.reverseWraparound,sendFocusMode:f.sendFocus,wraparoundMode:f.wraparound}}get options(){return this._publicOptions}set options(f){for(const d in f)this._publicOptions[d]=f[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(f,d){this._verifyIntegers(f,d),this._core.resize(f,d)}open(f){this._core.open(f)}attachCustomKeyEventHandler(f){this._core.attachCustomKeyEventHandler(f)}registerLinkProvider(f){return this._core.registerLinkProvider(f)}registerCharacterJoiner(f){return this._checkProposedApi(),this._core.registerCharacterJoiner(f)}deregisterCharacterJoiner(f){this._checkProposedApi(),this._core.deregisterCharacterJoiner(f)}registerMarker(f=0){return this._verifyIntegers(f),this._core.registerMarker(f)}registerDecoration(f){var d,h,_;return this._checkProposedApi(),this._verifyPositiveIntegers((d=f.x)!==null&&d!==void 0?d:0,(h=f.width)!==null&&h!==void 0?h:0,(_=f.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(f)}hasSelection(){return this._core.hasSelection()}select(f,d,h){this._verifyIntegers(f,d,h),this._core.select(f,d,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(f,d){this._verifyIntegers(f,d),this._core.selectLines(f,d)}dispose(){super.dispose()}scrollLines(f){this._verifyIntegers(f),this._core.scrollLines(f)}scrollPages(f){this._verifyIntegers(f),this._core.scrollPages(f)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(f){this._verifyIntegers(f),this._core.scrollToLine(f)}clear(){this._core.clear()}write(f,d){this._core.write(f,d)}writeln(f,d){this._core.write(f),this._core.write(`\r
|
|
27
|
-
`,d)}paste(f){this._core.paste(f)}refresh(f,d){this._verifyIntegers(f,d),this._core.refresh(f,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(f){this._addonManager.loadAddon(this,f)}static get strings(){return n}_verifyIntegers(...f){for(const d of f)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...f){for(const d of f)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}g.Terminal=x})(),p})()))})(wi)),wi.exports}var Km=qm();var Xm=2,Vm=1,Ym=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")),m=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),g={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},n=g.top+g.bottom,i=g.right+g.left,l=o-n,u=m-i-s;return{cols:Math.max(Xm,Math.floor(u/e.css.cell.width)),rows:Math.max(Vm,Math.floor(l/e.css.cell.height))}}};function Gm(e={}){const{cwd:s,cols:r,rows:o,onOutput:m,onExit:p}=e,[g,n]=y.useState(null),[i,l]=y.useState(()=>Qt.isConnected()),[u,c]=y.useState(!1),[v,b]=y.useState(!1),[S,x]=y.useState(!1),a=y.useRef({onOutput:m,onExit:p});a.current={onOutput:m,onExit:p};const f=y.useRef(null);f.current=g,y.useEffect(()=>{if(!g)return;const k=Qt.getSocket(),j=()=>{l(!0),c(!1),n(null),x(!0)},C=()=>{l(!1),c(!1)},E=M=>{M.terminalId===g&&a.current.onOutput?.(M.data)},N=M=>{M.terminalId===g&&(c(!1),a.current.onExit?.(M.exitCode),n(null))},D=M=>{M.terminalId===g&&c(!0)},A=M=>{M.terminalId===g&&c(!1)};return k.on("connect",j),k.on("disconnect",C),k.on(ct.TERMINAL_STDOUT,E),k.on(ct.TERMINAL_EXIT,N),k.on(ct.TERMINAL_SUBSCRIBED,D),k.on(ct.TERMINAL_UNSUBSCRIBED,A),l(k.connected),k.connected&&k.emit(xs.SUBSCRIBE,{topic:"terminal",id:g},M=>{M.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",C),k.off(ct.TERMINAL_STDOUT,E),k.off(ct.TERMINAL_EXIT,N),k.off(ct.TERMINAL_SUBSCRIBED,D),k.off(ct.TERMINAL_UNSUBSCRIBED,A),k.emit(xs.UNSUBSCRIBE,{topic:"terminal",id:g})}},[g]);const d=y.useCallback(async()=>{const k=Qt.getSocket();if(!k.connected)return null;b(!0);try{const j=await xe.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(j.terminalId),x(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{b(!1)}},[s,r,o]),h=y.useCallback(async()=>{const k=f.current;if(k){try{await xe.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}n(null),c(!1)}},[]),_=y.useCallback(k=>{const j=f.current;if(!j)return;Qt.getSocket().emit(xs.TERMINAL_INPUT,{terminalId:j,data:k})},[]),w=y.useCallback((k,j)=>{const C=f.current;if(!C)return;Qt.getSocket().emit(xs.TERMINAL_RESIZE,{terminalId:C,cols:k,rows:j})},[]);return y.useEffect(()=>()=>{const k=f.current;k&&xe.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:g,isConnected:i,isAttached:u,isCreating:v,needsRecreate:S,create:d,destroy:h,sendInput:_,resize:w}}const Qm={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"},Zm=ce.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:m}){const p=y.useRef(null),g=y.useRef(null),n=y.useRef(null),i=y.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:v,sendInput:b,resize:S}=Gm({cwd:s,onOutput:y.useCallback(x=>{g.current?.write(x)},[]),onExit:y.useCallback(x=>{g.current?.writeln(`\r
|
|
28
|
-
\x1B[90m[Process exited with code ${x}]\x1B[0m`),o?.(x)},[o])});return y.useEffect(()=>{if(!c)return;const x=g.current;x&&x.writeln(`\r
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),v()},[c,v]),y.useLayoutEffect(()=>{if(!p.current)return;const x=new Km.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Qm,scrollback:5e3,convertEol:!0}),a=new Ym;x.loadAddon(a),x.open(p.current);const f=(d=0)=>{if(!(d>=5))try{const _=p.current;if(!_||_.clientWidth===0||_.clientHeight===0){setTimeout(()=>f(d+1),50);return}a.fit(),S(x.cols,x.rows)}catch{setTimeout(()=>f(d+1),50)}};return f(0),setTimeout(()=>f(1),100),g.current=x,n.current=a,()=>{x.dispose(),g.current=null,n.current=null}},[S]),y.useEffect(()=>{i.current||(i.current=!0,v())},[v]),y.useEffect(()=>{const x=g.current;if(!x||!u)return;const a=x.onData(f=>{b(f)});return()=>a.dispose()},[b,u]),y.useEffect(()=>{u&&m?.({sendInput:b})},[u,b,m]),y.useEffect(()=>{if(!r)return;const x=n.current,a=g.current,f=p.current;if(!x||!a||!f)return;let d=!1,h;const _=w=>{d||w>=5||(h=requestAnimationFrame(()=>{if(!d)if(f.clientWidth>0&&f.clientHeight>0)try{x.fit(),S(a.cols,a.rows)}catch{}else setTimeout(()=>_(w+1),30)}))};return _(0),()=>{d=!0,h!=null&&cancelAnimationFrame(h)}},[r,S]),y.useEffect(()=>{if(!p.current)return;const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=n.current,f=g.current,d=p.current;a&&f&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),S(f.cols,f.rows))}catch{}})});return x.observe(p.current),()=>x.disconnect()},[S]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!l&&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:p,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Jm=ce.memo(function({commands:s,onSelect:r}){const{t:o}=le(),[m,p]=y.useState(!1),g=y.useRef(null),n=y.useRef(null);return y.useEffect(()=>{if(!m)return;const i=l=>{g.current&&!g.current.contains(l.target)&&n.current&&!n.current.contains(l.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[m]),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:n,onClick:()=>p(!m),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${m?"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(za,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(ht,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&t.jsx("div",{ref:g,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((i,l)=>t.jsxs("button",{onClick:()=>{r(i.command),p(!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(qt,{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:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},l))})})]})]})});let Ci=0;function To(){return Ci+=1,{id:`shell-${Ci}`,order:Ci}}const ep=ce.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:m}=le(),[p,g]=y.useState(()=>[To()]),[n,i]=y.useState(()=>p[0].id),l=y.useRef(new Map),u=y.useCallback(()=>{const x=To();g(a=>[...a,x]),i(x.id)},[]),c=y.useCallback((x,a)=>{a.stopPropagation(),l.current.delete(x),g(f=>{const d=f.filter(h=>h.id!==x);return x===n&&d.length>0&&i(d[d.length-1].id),d})},[n]),v=y.useCallback(x=>{l.current.delete(x),g(a=>{const f=a.filter(d=>d.id!==x);return x===n&&f.length>0&&i(f[f.length-1].id),f})},[n]),b=y.useCallback((x,a)=>{l.current.set(x,a.sendInput)},[]),S=y.useCallback(x=>{const a=l.current.get(n);a&&a(x+"\r")},[n]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",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 flex-1 min-w-0",children:p.map(x=>t.jsxs("button",{onClick:()=>i(x.id),className:Z("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",x.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Er,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:x.order})}),p.length>1&&t.jsx("span",{onClick:a=>c(x.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Wt,{size:10})})]},x.id))}),t.jsx("button",{onClick:u,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:m("New Terminal"),children:t.jsx(Ut,{size:14})}),o.length>0&&t.jsx(Jm,{commands:o,onSelect:S})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:p.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(Er,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:u,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):p.map(x=>t.jsx("div",{className:"absolute inset-0",style:{display:x.id===n?"block":"none"},children:t.jsx(Zm,{cwd:s,isVisible:r&&x.id===n,onExit:()=>v(x.id),onReady:a=>b(x.id,a)})},x.id))})]})});function Ao(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 tp(e){if(Array.isArray(e))return e}function sp(e,s,r){return(s=cp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function rp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,m,p,g,n=[],i=!0,l=!1;try{if(p=(r=r.call(e)).next,s!==0)for(;!(i=(o=p.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(u){l=!0,m=u}finally{try{if(!i&&r.return!=null&&(g=r.return(),Object(g)!==g))return}finally{if(l)throw m}}return n}}function ip(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
30
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Do(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Mo(Object(r),!0).forEach(function(o){sp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function np(e,s){if(e==null)return{};var r,o,m=op(e,s);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(m[r]=e[r])}return m}function op(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 ap(e,s){return tp(e)||rp(e,s)||dp(e,s)||ip()}function lp(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 cp(e){var s=lp(e,"string");return typeof s=="symbol"?s:s+""}function dp(e,s){if(e){if(typeof e=="string")return Ao(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)?Ao(e,s):void 0}}function up(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Lo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Po(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lo(Object(r),!0).forEach(function(o){up(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function hp(){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(m,p){return p(m)},o)}}function Fs(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var g=arguments.length,n=new Array(g),i=0;i<g;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function Lr(e){return{}.toString.call(e).includes("Object")}function fp(e){return!Object.keys(e).length}function Gs(e){return typeof e=="function"}function mp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function pp(e,s){return Lr(s)||es("changeType"),Object.keys(s).some(function(r){return!mp(e,r)})&&es("changeField"),s}function gp(e){Gs(e)||es("selectorType")}function vp(e){Gs(e)||Lr(e)||es("handlerType"),Lr(e)&&Object.values(e).some(function(s){return!Gs(s)})&&es("handlersType")}function xp(e){e||es("initialIsRequired"),Lr(e)||es("initialType"),fp(e)&&es("initialContent")}function bp(e,s){throw new Error(e[s]||e.default)}var _p={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"},es=Fs(bp)(_p),mr={changes:pp,selector:gp,handler:vp,initial:xp};function yp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};mr.initial(e),mr.handler(s);var r={current:e},o=Fs(Cp)(r,s),m=Fs(wp)(r),p=Fs(mr.changes)(e),g=Fs(Sp)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return mr.selector(l),l(r.current)}function i(l){hp(o,m,p,g)(l)}return[n,i]}function Sp(e,s){return Gs(s)?s(e.current):s}function wp(e,s){return e.current=Po(Po({},e.current),s),s}function Cp(e,s,r){return Gs(s)?s(e.current):Object.keys(r).forEach(function(o){var m;return(m=s[o])===null||m===void 0?void 0:m.call(s,e.current[o])}),r}var kp={create:yp},Ep={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function jp(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var g=arguments.length,n=new Array(g),i=0;i<g;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function Np(e){return{}.toString.call(e).includes("Object")}function Rp(e){return e||Oo("configIsRequired"),Np(e)||Oo("configType"),e.urls?(Tp(),{paths:{vs:e.urls.monacoBase}}):e}function Tp(){console.warn(Sl.deprecation)}function Ap(e,s){throw new Error(e[s]||e.default)}var Sl={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!
|
|
31
|
-
You are using deprecated way of configuration.
|
|
32
|
-
|
|
33
|
-
Instead of using
|
|
34
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
35
|
-
use
|
|
36
|
-
monaco.config({ paths: { vs: '...' } })
|
|
37
|
-
|
|
38
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},Oo=jp(Ap)(Sl),Mp={config:Rp},Dp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(m){return r.reduceRight(function(p,g){return g(p)},m)}};function wl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],wl(e[r],s[r]))}),Do(Do({},e),s)}var Lp={type:"cancelation",msg:"operation is manually canceled"};function ki(e){var s=!1,r=new Promise(function(o,m){e.then(function(p){return s?m(Lp):o(p)}),e.catch(m)});return r.cancel=function(){return s=!0},r}var Pp=["monaco"],Op=kp.create({config:Ep,isInitialized:!1,resolve:null,reject:null,monaco:null}),Cl=ap(Op,2),rr=Cl[0],ei=Cl[1];function Ip(e){var s=Mp.config(e),r=s.monaco,o=np(s,Pp);ei(function(m){return{config:wl(m.config,o),monaco:r}})}function Bp(){var e=rr(function(s){var r=s.monaco,o=s.isInitialized,m=s.resolve;return{monaco:r,isInitialized:o,resolve:m}});if(!e.isInitialized){if(ei({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ki(Ei);if(window.monaco&&window.monaco.editor)return kl(window.monaco),e.resolve(window.monaco),ki(Ei);Dp(Fp,Hp)(Wp)}return ki(Ei)}function Fp(e){return document.body.appendChild(e)}function zp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Hp(e){var s=rr(function(o){var m=o.config,p=o.reject;return{config:m,reject:p}}),r=zp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Wp(){var e=rr(function(r){var o=r.config,m=r.resolve,p=r.reject;return{config:o,resolve:m,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;kl(o),e.resolve(o)},function(r){e.reject(r)})}function kl(e){rr().monaco||ei({monaco:e})}function $p(){return rr(function(e){var s=e.monaco;return s})}var Ei=new Promise(function(e,s){return ei({resolve:e,reject:s})}),El={config:Ip,init:Bp,__getMonacoInstance:$p},Up={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ji=Up,qp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Kp=qp;function Xp({children:e}){return ce.createElement("div",{style:Kp.container},e)}var Vp=Xp,Yp=Vp;function Gp({width:e,height:s,isEditorReady:r,loading:o,_ref:m,className:p,wrapperProps:g}){return ce.createElement("section",{style:{...ji.wrapper,width:e,height:s},...g},!r&&ce.createElement(Yp,null,o),ce.createElement("div",{ref:m,style:{...ji.fullWidth,...!r&&ji.hide},className:p}))}var Qp=Gp,jl=y.memo(Qp);function Zp(e){y.useEffect(e,[])}var Nl=Zp;function Jp(e,s,r=!0){let o=y.useRef(!0);y.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var jt=Jp;function $s(){}function _s(e,s,r,o){return eg(e,o)||tg(e,s,r,o)}function eg(e,s){return e.editor.getModel(Rl(e,s))}function tg(e,s,r,o){return e.editor.createModel(s,r,o?Rl(e,o):void 0)}function Rl(e,s){return e.Uri.parse(s)}function sg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:g,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:u="Loading...",options:c={},height:v="100%",width:b="100%",className:S,wrapperProps:x={},beforeMount:a=$s,onMount:f=$s}){let[d,h]=y.useState(!1),[_,w]=y.useState(!0),k=y.useRef(null),j=y.useRef(null),C=y.useRef(null),E=y.useRef(f),N=y.useRef(a),D=y.useRef(!1);Nl(()=>{let L=El.init();return L.then(F=>(j.current=F)&&w(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?I():L.cancel()}),jt(()=>{if(k.current&&j.current){let L=k.current.getOriginalEditor(),F=_s(j.current,e||"",o||r||"text",p||"");F!==L.getModel()&&L.setModel(F)}},[p],d),jt(()=>{if(k.current&&j.current){let L=k.current.getModifiedEditor(),F=_s(j.current,s||"",m||r||"text",g||"");F!==L.getModel()&&L.setModel(F)}},[g],d),jt(()=>{let L=k.current.getModifiedEditor();L.getOption(j.current.editor.EditorOption.readOnly)?L.setValue(s||""):s!==L.getValue()&&(L.executeEdits("",[{range:L.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),L.pushUndoStop())},[s],d),jt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),jt(()=>{let{original:L,modified:F}=k.current.getModel();j.current.editor.setModelLanguage(L,o||r||"text"),j.current.editor.setModelLanguage(F,m||r||"text")},[r,o,m],d),jt(()=>{j.current?.editor.setTheme(l)},[l],d),jt(()=>{k.current?.updateOptions(c)},[c],d);let A=y.useCallback(()=>{if(!j.current)return;N.current(j.current);let L=_s(j.current,e||"",o||r||"text",p||""),F=_s(j.current,s||"",m||r||"text",g||"");k.current?.setModel({original:L,modified:F})},[r,s,m,e,o,p,g]),M=y.useCallback(()=>{!D.current&&C.current&&(k.current=j.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...c}),A(),j.current?.editor.setTheme(l),h(!0),D.current=!0)},[c,l,A]);y.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),y.useEffect(()=>{!_&&!d&&M()},[_,d,M]);function I(){let L=k.current?.getModel();n||L?.original?.dispose(),i||L?.modified?.dispose(),k.current?.dispose()}return ce.createElement(jl,{width:b,height:v,isEditorReady:d,loading:u,_ref:C,className:S,wrapperProps:x})}var rg=sg;y.memo(rg);function ig(e){let s=y.useRef();return y.useEffect(()=>{s.current=e},[e]),s.current}var ng=ig,pr=new Map;function og({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:m,path:p,theme:g="light",line:n,loading:i="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:v=!1,width:b="100%",height:S="100%",className:x,wrapperProps:a={},beforeMount:f=$s,onMount:d=$s,onChange:h,onValidate:_=$s}){let[w,k]=y.useState(!1),[j,C]=y.useState(!0),E=y.useRef(null),N=y.useRef(null),D=y.useRef(null),A=y.useRef(d),M=y.useRef(f),I=y.useRef(),L=y.useRef(o),F=ng(p),H=y.useRef(!1),T=y.useRef(!1);Nl(()=>{let B=El.init();return B.then($=>(E.current=$)&&C(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>N.current?P():B.cancel()}),jt(()=>{let B=_s(E.current,e||o||"",s||m||"",p||r||"");B!==N.current?.getModel()&&(c&&pr.set(F,N.current?.saveViewState()),N.current?.setModel(B),c&&N.current?.restoreViewState(pr.get(p)))},[p],w),jt(()=>{N.current?.updateOptions(l)},[l],w),jt(()=>{!N.current||o===void 0||(N.current.getOption(E.current.editor.EditorOption.readOnly)?N.current.setValue(o):o!==N.current.getValue()&&(T.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),N.current.pushUndoStop(),T.current=!1))},[o],w),jt(()=>{let B=N.current?.getModel();B&&m&&E.current?.editor.setModelLanguage(B,m)},[m],w),jt(()=>{n!==void 0&&N.current?.revealLine(n)},[n],w),jt(()=>{E.current?.editor.setTheme(g)},[g],w);let O=y.useCallback(()=>{if(!(!D.current||!E.current)&&!H.current){M.current(E.current);let B=p||r,$=_s(E.current,o||e||"",s||m||"",B||"");N.current=E.current?.editor.create(D.current,{model:$,automaticLayout:!0,...l},u),c&&N.current.restoreViewState(pr.get(B)),E.current.editor.setTheme(g),n!==void 0&&N.current.revealLine(n),k(!0),H.current=!0}},[e,s,r,o,m,p,l,u,c,g,n]);y.useEffect(()=>{w&&A.current(N.current,E.current)},[w]),y.useEffect(()=>{!j&&!w&&O()},[j,w,O]),L.current=o,y.useEffect(()=>{w&&h&&(I.current?.dispose(),I.current=N.current?.onDidChangeModelContent(B=>{T.current||h(N.current.getValue(),B)}))},[w,h]),y.useEffect(()=>{if(w){let B=E.current.editor.onDidChangeMarkers($=>{let X=N.current.getModel()?.uri;if(X&&$.find(U=>U.path===X.path)){let U=E.current.editor.getModelMarkers({resource:X});_?.(U)}});return()=>{B?.dispose()}}return()=>{}},[w,_]);function P(){I.current?.dispose(),v?c&&pr.set(p,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return ce.createElement(jl,{width:b,height:S,isEditorReady:w,loading:i,_ref:D,className:x,wrapperProps:a})}var ag=og,lg=y.memo(ag),cg=lg,Dt=function(e,s){return Number(e.toFixed(s))},dg=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},ug=function(e){return-Math.cos(e*Math.PI)/2+.5},hg=function(e){return e},fg=function(e){return e*e},mg=function(e){return e*(2-e)},pg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},gg=function(e){return e*e*e},vg=function(e){return--e*e*e+1},xg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},bg=function(e){return e*e*e*e},_g=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},Sg=function(e){return e*e*e*e*e},wg=function(e){return 1+--e*e*e*e*e},Cg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Tl={easeOut:ug,linear:hg,easeInQuad:fg,easeOutQuad:mg,easeInOutQuad:pg,easeInCubic:gg,easeOutCubic:vg,easeInOutCubic:xg,easeInQuart:bg,easeOutQuart:_g,easeInOutQuart:yg,easeInQuint:Sg,easeOutQuint:wg,easeInOutQuint:Cg},Al=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Pt=function(e){e.mounted&&(Al(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Ml(e,s,r,o){if(e.mounted){var m=new Date().getTime(),p=1;Pt(e),e.animation=function(){if(!e.mounted)return Al(e.animation);var g=new Date().getTime()-m,n=g/r,i=Tl[s],l=i(n);g>=r?(o(p),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function kg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function rs(e,s,r,o){var m=kg(s);if(!(!e.mounted||!m)){var p=e.setTransformState,g=e.transformState,n=g.scale,i=g.positionX,l=g.positionY,u=s.scale-n,c=s.positionX-i,v=s.positionY-l;r===0?p(s.scale,s.positionX,s.positionY):Ml(e,o,r,function(b){var S=n+u*b,x=i+c*b,a=l+v*b;p(S,x,a)})}}function Eg(e,s,r){var o=e.offsetWidth,m=e.offsetHeight,p=s.offsetWidth,g=s.offsetHeight,n=p*r,i=g*r,l=o-n,u=m-i;return{wrapperWidth:o,wrapperHeight:m,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:u}}var jg=function(e,s,r,o,m,p,g){var n=e>s?r*(g?1:.5):0,i=o>m?p*(g?1:.5):0,l=e-s-n,u=n,c=o-m-i,v=i;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:v}},An=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=Eg(r,o,s),g=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,l=p.newDiffWidth,u=p.newContentHeight,c=p.newDiffHeight,v=jg(g,i,l,n,u,c,!!m);return v},Xi=function(e,s,r,o){return o?e<s?Dt(s,2):e>r?Dt(r,2):Dt(e,2):Dt(e,2)},ls=function(e,s){var r=An(e,s);return e.bounds=r,r};function ir(e,s,r,o,m,p,g){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,v=0;g&&(c=m,v=p);var b=Xi(e,n-c,l+c,o),S=Xi(s,i-v,u+v,o);return{x:b,y:S}}function ti(e,s,r,o,m,p){var g=e.transformState,n=g.scale,i=g.positionX,l=g.positionY,u=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*u,v=l-r*u,b=ir(c,v,m,p,0,0,null);return b}function nr(e,s,r,o,m){var p=m?o:0,g=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=g?g:e}var Io=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,m=e.wrapperComponent,p=s.target,g="shadowRoot"in p&&"composedPath"in s,n=g?s.composedPath().some(function(u){return u instanceof Element?m?.contains(u):!1}):m?.contains(p),i=o&&p&&n;if(!i)return!1;var l=si(p,r);return!l},Bo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,m=o.panning.disabled,p=s&&r&&!m;return!!p},Ng=function(e,s){var r=e.transformState,o=r.positionX,m=r.positionY;e.isPanning=!0;var p=s.clientX,g=s.clientY;e.startCoords={x:p-o,y:g-m}},Rg=function(e,s){var r=s.touches,o=e.transformState,m=o.positionX,p=o.positionY;e.isPanning=!0;var g=r.length===1;if(g){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-m,y:i-p}}};function Tg(e){var s=e.transformState,r=s.positionX,o=s.positionY,m=s.scale,p=e.setup,g=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,l=e.wrapperComponent;if(!(g||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,v=u.minPositionX,b=u.maxPositionY,S=u.minPositionY,x=r>c||r<v,a=o>b||o<S,f=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>b?l.offsetHeight:e.setup.minPositionY||0,h=ti(e,f,d,m,e.bounds,n||i),_=h.x,w=h.y;return{scale:m,positionX:x?_:r,positionY:a?w:o}}}function Dl(e,s,r,o,m){var p=e.setup.limitToBounds,g=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(!(g===null||n===null||s===u&&r===c)){var v=ir(s,r,n,p,o,m,g),b=v.x,S=v.y;e.setTransformState(l,b,S)}}var Ag=function(e,s,r){var o=e.startCoords,m=e.transformState,p=e.setup.panning,g=p.lockAxisX,n=p.lockAxisY,i=m.positionX,l=m.positionY;if(!o)return{x:i,y:l};var u=s-o.x,c=r-o.y,v=g?i:u,b=n?l:c;return{x:v,y:b}},ss=function(e,s){var r=e.setup,o=e.transformState,m=o.scale,p=r.minScale,g=r.disablePadding;return s>0&&m>=p&&!g?s:0},Mg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,g=m.disabled,n=!g||p>1||!o||s;return!!n},Dg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,m=e.setup,p=m.disabled,g=m.velocityAnimation,n=e.transformState.scale,i=g.disabled,l=!i||n>1||!p||s;return!(!l||!r||!o)};function Lg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,m=r.animationTime,p=r.sensitivity;return o?m*s*p:m}function Fo(e,s,r,o,m,p,g,n,i,l){if(m){if(s>g&&r>g){var u=g+(e-g)*l;return u>i?i:u<g?g:u}if(s<p&&r<p){var u=p+(e-p)*l;return u<n?n:u>p?p:u}}return o?s:Xi(e,p,g,m)}function Pg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Og(e,s){var r=Mg(e);if(r){var o=e.lastMousePosition,m=e.velocityTime,p=e.setup,g=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&m&&g){var l=Pg(g,n),u=s.x-o.x,c=s.y-o.y,v=u/l,b=c/l,S=i-m,x=u*u+c*c,a=Math.sqrt(x)/S;e.velocity={velocityX:v,velocityY:b,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function Ig(e){var s=e.velocity,r=e.bounds,o=e.setup,m=e.wrapperComponent,p=Dg(e);if(!(!p||!s||!r||!m)){var g=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,v=r.minPositionY,b=o.limitToBounds,S=o.alignmentAnimation,x=o.zoomAnimation,a=o.panning,f=a.lockAxisY,d=a.lockAxisX,h=x.animationType,_=S.sizeX,w=S.sizeY,k=S.velocityAlignmentTime,j=k,C=Lg(e,i),E=Math.max(C,j),N=ss(e,_),D=ss(e,w),A=N*m.offsetWidth/100,M=D*m.offsetHeight/100,I=l+A,L=u-A,F=c+M,H=v-M,T=e.transformState,O=new Date().getTime();Ml(e,h,E,function(P){var B=e.transformState,$=B.scale,X=B.positionX,U=B.positionY,K=new Date().getTime()-O,W=K/j,R=Tl[S.animationType],z=1-R(Math.min(1,W)),V=1-P,q=X+g*V,se=U+n*V,Q=Fo(q,T.positionX,X,d,b,u,l,L,I,z),ee=Fo(se,T.positionY,U,f,b,v,c,H,F,z);(X!==q||U!==se)&&e.setTransformState($,Q,ee)})}}function zo(e,s){var r=e.transformState.scale;Pt(e),ls(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Rg(e,s):Ng(e,s)}function Mn(e,s){var r=e.transformState.scale,o=e.setup,m=o.minScale,p=o.alignmentAnimation,g=p.disabled,n=p.sizeX,i=p.sizeY,l=p.animationTime,u=p.animationType,c=g||r<m||!n&&!i;if(!c){var v=Tg(e);v&&rs(e,v,s??l,u)}}function Ho(e,s,r){var o=e.startCoords,m=e.setup,p=m.alignmentAnimation,g=p.sizeX,n=p.sizeY;if(o){var i=Ag(e,s,r),l=i.x,u=i.y,c=ss(e,g),v=ss(e,n);Og(e,{x:l,y:u}),Dl(e,l,u,c,v)}}function Bg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),g=m?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,l=g?.width||0,u=g?.height||0,c=n<l||i<u,v=!s&&r&&r?.total>.1&&c;v?Ig(e):Mn(e)}}function Dn(e,s,r,o){var m=e.setup,p=m.minScale,g=m.maxScale,n=m.limitToBounds,i=nr(Dt(s,2),p,g,0,!1),l=ls(e,i),u=ti(e,r,o,i,l,n),c=u.x,v=u.y;return{scale:i,positionX:c,positionY:v}}function Ll(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,g=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,l=i.disabled,u=i.animationTime,c=i.animationType,v=l||o>=g;if((o>=1||n)&&Mn(e),!(v||!m||!e.mounted)){var b=s||m.offsetWidth/2,S=r||m.offsetHeight/2,x=Dn(e,g,b,S);x&&rs(e,x,u,c)}}var ts=function(){return ts=Object.assign||function(s){for(var r,o=1,m=arguments.length;o<m;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},ts.apply(this,arguments)};function Wo(e,s,r){for(var o=0,m=s.length,p;o<m;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var gr={scale:1,positionX:0,positionY:0},Is={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}},Vi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Pl=function(e){var s,r,o,m;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:gr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:gr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:gr.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:gr.positionY}},$o=function(e){var s=ts({},Is);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",m=typeof Is[r]<"u";if(m&&o){var p=Object.prototype.toString.call(Is[r]),g=p==="[object Object]",n=p==="[object Array]";g?s[r]=ts(ts({},Is[r]),e[r]):n?s[r]=Wo(Wo([],Is[r],!0),e[r]):s[r]=e[r]}}),s},Ol=function(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,g=p.maxScale,n=p.minScale,i=p.zoomAnimation,l=p.smooth,u=i.size;if(!m)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,v=nr(Dt(c,3),n,g,u,!1);return v};function Il(e,s,r,o,m){var p=e.wrapperComponent,g=e.transformState,n=g.scale,i=g.positionX,l=g.positionY;if(!p)return console.error("No WrapperComponent found");var u=p.offsetWidth,c=p.offsetHeight,v=(u/2-i)/n,b=(c/2-l)/n,S=Ol(e,s,r),x=Dn(e,S,v,b);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");rs(e,x,o,m)}function Bl(e,s,r,o){var m=e.setup,p=e.wrapperComponent,g=m.limitToBounds,n=Pl(e.props),i=e.transformState,l=i.scale,u=i.positionX,c=i.positionY;if(p){var v=An(e,n.scale),b=ir(n.positionX,n.positionY,v,g,0,0,p),S={scale:n.scale,positionX:b.x,positionY:b.y};l===n.scale&&u===n.positionX&&c===n.positionY||(o?.(),rs(e,S,s,r))}}function Fg(e,s,r,o){var m=e.getBoundingClientRect(),p=s.getBoundingClientRect(),g=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(m.x-g.x+n)/o.scale,y:(m.y-g.y+i)/o.scale}}function zg(e,s,r){var o=e.wrapperComponent,m=e.contentComponent,p=e.transformState,g=e.setup,n=g.limitToBounds,i=g.minScale,l=g.maxScale;if(!o||!m)return p;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),v=Fg(s,o,m,p),b=v.x,S=v.y,x=c.width/p.scale,a=c.height/p.scale,f=o.offsetWidth/x,d=o.offsetHeight/a,h=nr(r||Math.min(f,d),i,l,0,!1),_=(u.width-x*h)/2,w=(u.height-a*h)/2,k=(u.left-b)*h+_,j=(u.top-S)*h+w,C=An(e,h),E=ir(k,j,C,n,0,0,o),N=E.x,D=E.y;return{positionX:N,positionY:D,scale:h}}var Hg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Il(e,1,s,r,o)}},Wg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Il(e,-1,s,r,o)}},$g=function(e){return function(s,r,o,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var g=e.transformState,n=g.positionX,i=g.positionY,l=g.scale,u=e.wrapperComponent,c=e.contentComponent,v=e.setup.disabled;if(!(v||!u||!c)){var b={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};rs(e,b,m,p)}}},Ug=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Bl(e,s,r)}},qg=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var m=e.transformState,p=e.wrapperComponent,g=e.contentComponent;if(p&&g){var n=Fl(s||m.scale,p,g);rs(e,n,r,o)}}},Kg=function(e){return function(s,r,o,m){o===void 0&&(o=600),m===void 0&&(m="easeOut"),Pt(e);var p=e.wrapperComponent,g=typeof s=="string"?document.getElementById(s):s;if(p&&g&&p.contains(g)){var n=zg(e,g,r);rs(e,n,o,m)}}},Pr=function(e){return{instance:e,zoomIn:Hg(e),zoomOut:Wg(e),setTransform:$g(e),resetTransform:Ug(e),centerView:qg(e),zoomToElement:Kg(e)}},Yi=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,Yi(e)),Object.assign(s,Pr(e)),s},Ni=!1;function Ri(){try{var e={get passive(){return Ni=!0,!1}};return e}catch{return Ni=!1,Ni}}var vr=".".concat(Vi.wrapperClass),si=function(e,s){return s.some(function(r){return e.matches("".concat(vr," ").concat(r,", ").concat(vr," .").concat(r,", ").concat(vr," ").concat(r," *, ").concat(vr," .").concat(r," *"))})},Gi=function(e){e&&clearTimeout(e)},Xg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Fl=function(e,s,r){var o=r.offsetWidth*e,m=r.offsetHeight*e,p=(s.offsetWidth-o)/2,g=(s.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:g}};function Vg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Yg=function(e,s){var r=e.setup.wheel,o=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,g=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,u=n&&!i&&!o&&l;if(!u||m&&!s.ctrlKey||p&&s.ctrlKey)return!1;var c=si(l,g);return!c},Gg=function(e){return e?e.deltaY<0?1:-1:0};function Qg(e,s){var r=Gg(e),o=dg(s,r);return o}function zl(e,s,r){var o=s.getBoundingClientRect(),m=0,p=0;if("clientX"in e)m=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var g=e.touches[0];m=(g.clientX-o.left)/r,p=(g.clientY-o.top)/r}return(Number.isNaN(m)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:m,y:p}}var Zg=function(e,s,r,o,m){var p=e.transformState.scale,g=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,u=n.zoomAnimation,c=n.disablePadding,v=u.size,b=u.disabled;if(!g)throw new Error("Wrapper is not mounted");var S=p+s*r,x=o?!1:!b,a=nr(Dt(S,3),l,i,v,x&&!c);return a},Jg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,m=e.setup,p=m.maxScale,g=m.minScale;return r?o<p||o>g||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},ev=function(e,s){var r=e.setup.pinch,o=r.disabled,m=r.excluded,p=e.isInitialized,g=s.target,n=p&&!o&&g;if(!n)return!1;var i=si(g,m);return!i},tv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,m=r&&!s&&o;return!!m},sv=function(e,s,r){var o=r.getBoundingClientRect(),m=e.touches,p=Dt(m[0].clientX-o.left,5),g=Dt(m[0].clientY-o.top,5),n=Dt(m[1].clientX-o.left,5),i=Dt(m[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(g+i)/2/s}},Hl=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))},rv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,m=e.setup,p=m.maxScale,g=m.minScale,n=m.zoomAnimation,i=m.disablePadding,l=n.size,u=n.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,v=c*r;return nr(Dt(v,2),g,p,l,!u&&!i)},iv=160,nv=100,ov=function(e,s){var r=e.props,o=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(Pt(e),Qe(qe(e),s,o),Qe(qe(e),s,m))},av=function(e,s){var r=e.props,o=r.onWheel,m=r.onZoom,p=e.contentComponent,g=e.setup,n=e.transformState,i=n.scale,l=g.limitToBounds,u=g.centerZoomedOut,c=g.zoomAnimation,v=g.wheel,b=g.disablePadding,S=g.smooth,x=c.size,a=c.disabled,f=v.step,d=v.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var h=Qg(s,null),_=S?d*Math.abs(s.deltaY):f,w=Zg(e,h,_,!s.ctrlKey);if(i!==w){var k=ls(e,w),j=zl(s,p,i),C=a||x===0||u||b,E=l&&C,N=ti(e,j.x,j.y,w,k,E),D=N.x,A=N.y;e.previousWheelEvent=s,e.setTransformState(w,D,A),Qe(qe(e),s,o),Qe(qe(e),s,m)}},lv=function(e,s){var r=e.props,o=r.onWheelStop,m=r.onZoomStop;Gi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Ll(e,s.x,s.y),e.wheelAnimationTimer=null)},nv);var p=Jg(e,s);p&&(Gi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(qe(e),s,o),Qe(qe(e),s,m))},iv))},Wl=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 m=s/2,p=r/2;return{x:m,y:p}},cv=function(e,s){var r=Hl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Wl(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Pt(e)},dv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,g=e.setup,n=g.limitToBounds,i=g.centerZoomedOut,l=g.zoomAnimation,u=g.alignmentAnimation,c=l.disabled,v=l.size;if(!(o===null||!r)){var b=sv(s,p,r);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var S=Hl(s),x=rv(e,S),a=Wl(s),f=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===p&&f===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var h=ls(e,x),_=c||v===0||i,w=n&&_,k=ti(e,b.x,b.y,x,h,w),j=k.x,C=k.y;e.pinchMidpoint=b,e.lastDistance=S;var E=u.sizeX,N=u.sizeY,D=ss(e,E),A=ss(e,N),M=j+f,I=C+d,L=ir(M,I,h,n,D,A,m),F=L.x,H=L.y;e.setTransformState(x,F,H)}}}},uv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Ll(e,s?.x,s?.y)},$l=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;Gi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(qe(e),s,r)},o)},hv=function(e,s){var r=e.props,o=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,g=p.animationTime,n=p.animationType;Qe(qe(e),s,o),Bl(e,g,n,function(){return Qe(qe(e),s,m)}),$l(e,s)};function fv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function mv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,g=m.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,u=r.doubleClick,c=u.disabled,v=u.mode,b=u.step,S=u.animationTime,x=u.animationType;if(!c&&!o){if(v==="reset")return hv(e,s);if(!p)return console.error("No ContentComponent found");var a=fv(v,e.transformState.scale),f=Ol(e,a,b);if(g!==f){Qe(qe(e),s,i);var d=zl(s,p,g),h=Dn(e,f,d.x,d.y);if(!h)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(qe(e),s,l),rs(e,h,S,x),$l(e,s)}}}var pv=function(e,s){var r=e.isInitialized,o=e.setup,m=e.wrapperComponent,p=o.doubleClick,g=p.disabled,n=p.excluded,i=s.target,l=m?.contains(i),u=r&&i&&l&&!g;if(!u)return!1;var c=si(i,n);return!c},gv=(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,ls(r,r.transformState.scale),r.setup=$o(o)},this.initializeWindowEvents=function(){var o,m,p=Ri(),g=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=g?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),g?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,m,p=Ri(),g=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=g?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),g?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),Pt(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(o){var m=Ri();o.addEventListener("wheel",r.onWheelZoom,m),o.addEventListener("dblclick",r.onDoubleClick,m),o.addEventListener("touchstart",r.onTouchPanningStart,m),o.addEventListener("touchmove",r.onTouchPanning,m),o.addEventListener("touchend",r.onTouchPanningStop,m)},this.handleInitialize=function(o,m){var p=!1,g=r.setup.centerOnInit,n=function(i,l){for(var u=0,c=i;u<c.length;u++){var v=c[u];if(v.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(qe(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,m))if(g&&!p){var l=m.offsetWidth,u=m.offsetHeight;(l>0||u>0)&&(p=!0,r.setCenter())}else Pt(r),ls(r,r.transformState.scale),Mn(r,0)}),r.observer.observe(o),r.observer.observe(m)},this.onWheelZoom=function(o){var m=r.setup.disabled;if(!m){var p=Yg(r,o);if(p){var g=r.isPressingKeys(r.setup.wheel.activationKeys);g&&(ov(r,o),av(r,o),lv(r,o))}}},this.onWheelPanning=function(o){var m=r.setup,p=m.disabled,g=m.wheel,n=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!g.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,u=i.positionY,c=l-o.deltaX,v=u-o.deltaY,b=n.lockAxisX?l:c,S=n.lockAxisY?u:v,x=r.setup.alignmentAnimation,a=x.sizeX,f=x.sizeY,d=ss(r,a),h=ss(r,f);b===l&&S===u||Dl(r,b,S,d,h)}},this.onPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var g=Io(r,o);if(g){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(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(),Pt(r),zo(r,o),Qe(qe(r),o,p)))}}},this.onPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var g=Bo(r);if(g){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Ho(r,o.clientX,o.clientY),Qe(qe(r),o,p))}}},this.onPanningStop=function(o){var m=r.props.onPanningStop;r.isPanning&&(Bg(r),Qe(qe(r),o,m))},this.onPinchStart=function(o){var m=r.setup.disabled,p=r.props,g=p.onPinchingStart,n=p.onZoomStart;if(!m){var i=ev(r,o);i&&(cv(r,o),Pt(r),Qe(qe(r),o,g),Qe(qe(r),o,n))}},this.onPinch=function(o){var m=r.setup.disabled,p=r.props,g=p.onPinching,n=p.onZoom;if(!m){var i=tv(r);i&&(o.preventDefault(),o.stopPropagation(),dv(r,o),Qe(qe(r),o,g),Qe(qe(r),o,n))}},this.onPinchStop=function(o){var m=r.props,p=m.onPinchingStop,g=m.onZoomStop;r.pinchStartScale&&(uv(r),Qe(qe(r),o,p),Qe(qe(r),o,g))},this.onTouchPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var g=Io(r,o);if(g){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,Pt(r);var i=o.touches,l=i.length===1,u=i.length===2;l&&(Pt(r),zo(r,o),Qe(qe(r),o,p)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(m)return;var g=Bo(r);if(!g)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Ho(r,n.clientX,n.clientY),Qe(qe(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var m=r.setup.disabled;if(!m){var p=pv(r,o);p&&mv(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(m){return r.pressedKeys[m]}):!0},this.setTransformState=function(o,m,p){var g=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(m)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=m,r.transformState.positionY=p,r.applyTransformation();var n=qe(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Qe(n,{scale:o,positionX:m,positionY:p},g)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Fl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,m,p){return r.props.customTransform?r.props.customTransform(o,m,p):Xg(o,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,m=o.scale,p=o.positionX,g=o.positionY,n=r.handleTransformStyles(p,g,m);r.contentComponent.style.transform=n}},this.getContext=function(){return qe(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,m){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=m,ls(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=qe(r);Qe(p,void 0,r.props.onInit)},this.props=s,this.setup=$o(this.props),this.transformState=Pl(this.props)}return e})(),ri=ce.createContext(null),vv=function(e,s){return typeof e=="function"?e(s):e},xv=ce.forwardRef(function(e,s){var r=y.useRef(new gv(e)).current,o=vv(e.children,Pr(r));return y.useImperativeHandle(s,function(){return Pr(r)},[r]),y.useEffect(function(){r.update(e)},[r,e]),ce.createElement(ri.Provider,{value:r},o)});ce.forwardRef(function(e,s){var r=y.useRef(null),o=y.useContext(ri);return y.useEffect(function(){return o.onChange(function(m){if(r.current){var p=0,g=0;r.current.style.transform=o.handleTransformStyles(p,g,1/m.instance.transformState.scale)}})},[o]),ce.createElement("div",ts({},e,{ref:Vg([r,s])}))});function bv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",r==="top"&&o.firstChild?o.insertBefore(m,o.firstChild):o.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var _v=`.transform-component-module_wrapper__SPB86 {
|
|
40
|
-
position: relative;
|
|
41
|
-
width: -moz-fit-content;
|
|
42
|
-
width: fit-content;
|
|
43
|
-
height: -moz-fit-content;
|
|
44
|
-
height: fit-content;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
47
|
-
-webkit-user-select: none; /* Safari */
|
|
48
|
-
-khtml-user-select: none; /* Konqueror HTML */
|
|
49
|
-
-moz-user-select: none; /* Firefox */
|
|
50
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
51
|
-
user-select: none;
|
|
52
|
-
margin: 0;
|
|
53
|
-
padding: 0;
|
|
54
|
-
transform: translate3d(0, 0, 0);
|
|
55
|
-
}
|
|
56
|
-
.transform-component-module_content__FBWxo {
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-wrap: wrap;
|
|
59
|
-
width: -moz-fit-content;
|
|
60
|
-
width: fit-content;
|
|
61
|
-
height: -moz-fit-content;
|
|
62
|
-
height: fit-content;
|
|
63
|
-
margin: 0;
|
|
64
|
-
padding: 0;
|
|
65
|
-
transform-origin: 0% 0%;
|
|
66
|
-
}
|
|
67
|
-
.transform-component-module_content__FBWxo img {
|
|
68
|
-
pointer-events: none;
|
|
69
|
-
}
|
|
70
|
-
`,Uo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};bv(_v);var yv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,g=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,v=y.useContext(ri),b=v.init,S=v.cleanupWindowEvents,x=y.useRef(null),a=y.useRef(null);return y.useEffect(function(){var f=x.current,d=a.current;return f!==null&&d!==null&&b&&b?.(f,d),function(){S?.()}},[]),ce.createElement("div",ts({},l,{ref:x,className:"".concat(Vi.wrapperClass," ").concat(Uo.wrapper," ").concat(o),style:g}),ce.createElement("div",ts({},c,{ref:a,className:"".concat(Vi.contentClass," ").concat(Uo.content," ").concat(p),style:n}),s))},Ul=function(){var e=y.useContext(ri);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Sv=function(){var e=Ul();return Pr(e)};function wv(e){var s=Ul(),r=y.useState(e(Yi(s))),o=r[0],m=r[1];return y.useEffect(function(){var p=!0,g=s.onChange(function(n){p&&m(e(Yi(n.instance)))});return function(){g(),p=!1}},[e,s]),o}function Cv(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 kv(e,s){return Nt({queryKey:ae.files.tree(e||"",s),queryFn:()=>xe.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Ev(e,s){return Nt({queryKey:ae.files.content(e||"",s||""),queryFn:()=>xe.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function jv(e){const s=at();return y.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Nv(){const e=at();return wt({mutationFn:s=>xe.post("/files/write",s),onSuccess:(s,r)=>{const o=ae.files.content(r.workingDir,r.path),m=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:m?.language||Cv(r.path)})}})}function Rv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function Tv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const Av=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Mv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&Av.has(s)?hn:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Cr:s==="json"?Fd:s==="md"||s==="mdx"||s==="txt"?dn:hd}const qo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:m,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:Z("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:m}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),ql=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:g})=>{const{t:n}=le(),{data:i,isLoading:l,isError:u}=kv(e,s),c=y.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(v=>{if(v.type==="directory"){const f=Rv(s,v.name),d=o.has(f);return t.jsxs("div",{children:[t.jsx(qo,{depth:r,onClick:()=>m(f),rightIcon:d?t.jsx(ht,{size:14,className:"text-neutral-400"}):t.jsx(Ot,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx($r,{size:14,className:"text-amber-500"}):t.jsx(La,{size:14,className:"text-amber-500"}),label:v.name}),d&&t.jsx(ql,{workingDir:e,path:f,depth:r+1,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:g})]},f)}const b=Tv(s,v.name),S=Mv(v),x=g===b,a=S===hn;return t.jsx(qo,{depth:r,active:x,onClick:()=>p(b),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?t.jsx(S,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:v.name},b)})})},Dv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:m})=>{const{t:p}=le(),[g,n]=y.useState(()=>new Set),i=jv(e),l=y.useCallback(u=>{n(c=>{const v=new Set(c);return v.has(u)?v.delete(u):v.add(u),v})},[]);return t.jsxs("div",{className:Z("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:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:t.jsx(Ur,{size:13})}),m&&t.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("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(ql,{workingDir:e,path:"/",depth:0,expanded:g,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},Lv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Pv(e){const s=e.split(".").pop()?.toLowerCase();return s?Lv.has(s):!1}function Ov(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Iv=({filePath:e})=>{const{t:s}=le(),{zoomIn:r,zoomOut:o,centerView:m}=Sv(),p=wv(n=>n.state.scale),g=Math.round(p*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(Nu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>m(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:[g,"%"]}),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(Eu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>m(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(su,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Bv=({workingDir:e,filePath:s})=>{const{t:r}=le(),[o,m]=y.useState(!1),p=Ov(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(xv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Iv,{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:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function Fv(e){const s=e.split("/");return s[s.length-1]||e}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"}}const Hv=({active:e,name:s,isDirty:r,onClick:o,onClose:m})=>{const{t:p}=le();return t.jsxs("button",{type:"button",onClick:o,className:Z("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:Z("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:m,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Wt,{size:12})})]})},Wv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=le(),[m,p]=y.useState([]),[g,n]=y.useState(null),i=Nv(),[l,u]=y.useState(280),[c,v]=y.useState(!1),[b,S]=y.useState(!1),x=y.useRef(280),a=y.useCallback(()=>{v(M=>(M?u(x.current):x.current=l,!M))},[l]),f=y.useCallback(M=>{M.preventDefault(),S(!0);const I=M.clientX,L=l,F=T=>{const O=T.clientX-I,P=Math.min(480,Math.max(160,L+O));u(P)},H=()=>{S(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H)},[l]);y.useEffect(()=>{p([]),n(null)},[e]);const d=y.useMemo(()=>m.find(M=>M.path===g)||null,[m,g]),{data:h,isFetching:_,isError:w,error:k}=Ev(e,d?.isImage?null:g);y.useEffect(()=>{!g||!h||p(M=>M.map(I=>I.path!==g||I.isDirty||I.loaded?I:{...I,language:h.language||I.language,content:h.content,savedContent:h.content,isDirty:!1,loaded:!0}))},[g,h]);const j=y.useCallback(M=>{p(I=>{if(I.find(H=>H.path===M))return I;const F=Pv(M);return[...I,{path:M,name:Fv(M),language:zv(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),n(M)},[]),C=y.useCallback(M=>{p(I=>{const L=I.filter(F=>F.path!==M);return n(F=>F!==M?F:L.length?L[L.length-1].path:null),L})},[]),E=y.useCallback(M=>{p(I=>I.map(L=>{if(L.path!==g)return L;const F=M!==L.savedContent;return{...L,content:M,isDirty:F}}))},[g]),N=y.useCallback(async()=>{r||!e||!d||(await i.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(M=>M.map(I=>I.path===d.path?{...I,savedContent:I.content,isDirty:!1,loaded:!0}:I)))},[d,r,i,e]),D=y.useRef(()=>{});y.useEffect(()=>{D.current=()=>{N().catch(()=>{})}},[N]),y.useEffect(()=>{const M=I=>{r||(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"&&(I.preventDefault(),D.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const A=y.useCallback((M,I)=>{M.addCommand(I.KeyMod.CtrlCmd|I.KeyCode.KeyS,()=>{D.current()})},[]);return t.jsxs("div",{className:Z("flex h-full overflow-hidden bg-white",s),style:b?{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:c?36:l,transition:b?"none":"width 0.15s ease"},children:c?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:o("Expand file tree"),children:t.jsx(ou,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Dv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:f,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",b?"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:[m.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):m.map(M=>t.jsx(Hv,{active:M.path===g,name:M.name,isDirty:M.isDirty,onClick:()=>n(M.path),onClose:I=>{I.stopPropagation(),C(M.path)}},M.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),i.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!i.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(Bv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(cg,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>E(M??""),onMount:A,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),_&&!d.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(ze,{size:14,className:"animate-spin"}),o("Loading file...")]})}),w&&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:[o("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("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:o("No workspace selected.")})})]})]})};function Ln(e,s={}){return Nt({queryKey:ae.git.changes(e||""),queryFn:()=>xe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Kl(e,s,r){return Nt({queryKey:ae.git.diff(e||"",s||"",r),queryFn:()=>xe.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Pn(e,s){return Nt({queryKey:ae.git.commitFiles(e||"",s||""),queryFn:()=>xe.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function On(e,s,r){return Nt({queryKey:ae.git.commitDiff(e||"",s||"",r||""),queryFn:()=>xe.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function $v({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:m,isPending:p,error:g,onConfirm:n}){const{t:i}=le(),[l,u]=y.useState(""),[c,v]=y.useState(!1);y.useEffect(()=>{e&&(v(!1),u(m??""))},[e]),y.useEffect(()=>{c||!e||u(m??"")},[m,c,e]);const b=()=>{p||s()};return t.jsx(Es,{isOpen:e,onClose:b,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:b,disabled:p,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(l.trim()||void 0),disabled:p,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:p?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Fi,{size:14}),i("确认提交")]})})]}),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(kd,{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:i("提交消息")}),t.jsx("textarea",{value:l,onChange:S=>{v(!0),u(S.target.value)},placeholder:i("请描述本次修改的内容"),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:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),g&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:g})]})})}function vs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Uv(e){if(!(e instanceof ya)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Us.REBASE&&s.conflictOp!==Us.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:vs(s,"sourceBranch"),targetBranch:vs(s,"targetBranch"),sourceWorktreePath:vs(s,"sourceWorktreePath"),targetWorktreePath:vs(s,"targetWorktreePath"),sourceWorkspaceId:vs(s,"sourceWorkspaceId"),targetWorkspaceId:vs(s,"targetWorkspaceId")}}function Ko(e,s,r,o){const m=Uv(e);if(m){r(m);return}o(e instanceof Error?e.message:s)}function Xl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:m,onRefreshCommitMessage:p,onConflict:g,onResolveConflicts:n}){const{t:i}=le(),{data:l,isLoading:u}=Cn(e),c=ff(),v=uf(),b=cl(),[S,x]=y.useState(!1),[a,f]=y.useState(null);if(y.useEffect(()=>{S&&p?.()},[S,p]),u||!l)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(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const d=l.conflictedFiles.length>0,h=l.operation!=="idle",_=l.hasUncommittedChanges||l.untrackedCount>0,w=l.uncommittedCount+l.untrackedCount,k=!d&&!h&&!_,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!_&&!d,C=()=>{f(null),c.mutate(e,{onError:A=>{Ko(A,i("更新失败,请稍后重试"),M=>g(M),f)}})},E=()=>{f(null),x(!0)},N=A=>{f(null),v.mutate({id:e,commitMessage:A},{onSuccess:()=>x(!1),onError:M=>{Ko(M,i("提交失败,请稍后重试"),I=>{x(!1),g(I)},f)}})},D=()=>{v.isPending||(x(!1),f(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(Zd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):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:[a&&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:a}),_&&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(Wd,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:w})})]}),d&&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(Hr,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,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:i("处理冲突")}),t.jsx("button",{onClick:()=>b.mutate(e),disabled:b.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:b.isPending?i("正在撤销..."):i("撤销操作")})]})]}),h&&!d&&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(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>b.mutate(e),disabled:b.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(vd,{size:12}),b.isPending?i("正在撤销..."):i("撤销操作")]})]}),!d&&!h&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:C,disabled:!k||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(Ur,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:m??l.ahead})}),l.behind===0&&!_?t.jsxs("button",{onClick:E,disabled:v.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(Fi,{size:12}),i("提交变更")]}):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:i(_?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Fi,{size:12}),i("提交变更")]})]})]})]})}),t.jsx($v,{isOpen:S,onClose:D,branchName:s,targetBranch:r,commitMessage:o,isPending:v.isPending,error:a,onConfirm:N})]})}const Ti=50,Ai=400,Xo={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"},Vo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Vl(e){const s=e.split("/");return s[s.length-1]||e}function qv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Kv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?mt("{count}s ago",{count:r}):r<3600?mt("{count}m ago",{count:Math.floor(r/60)}):r<86400?mt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?mt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function yr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Qi=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:Z("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"})]}),Xv=({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:Z("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:Z("pl-2 whitespace-pre",o),children:e})]})},Yl=({diff:e})=>{const{t:s}=le(),[r,o]=y.useState(!1),m=y.useMemo(()=>e.split(`
|
|
71
|
-
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const p=!r&&m.length>Ai,g=p?m.slice(0,Ai):m;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[g.map((n,i)=>t.jsx(Xv,{line:n,lineNum:i+1},i)),p&&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:m.length-Ai})})]})},Vv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:m}=le(),{data:p,isLoading:g,isError:n}=Kl(e,o?s:null,r);return!o||g?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:m("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:m("差异加载失败")}):t.jsx(Yl,{diff:p?.diff||""})},Yv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:m}=le(),{data:p,isLoading:g,isError:n}=On(e,o?s:null,o?r:null);return!o||g?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:m("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:m("差异加载失败")}):t.jsx(Yl,{diff:p?.diff||""})},Mi=({entry:e,source:s,workingDir:r,flash:o,registerNode:m})=>{const[p,g]=y.useState(!1),[n,i]=y.useState(!1),l=y.useRef(null),u=yr(s,e.path);y.useEffect(()=>(m(u,l.current),()=>m(u,null)),[u,m]),y.useEffect(()=>{const b=l.current;if(!b||n)return;const S=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(i(!0),S.disconnect())},{rootMargin:"300px 0px"});return S.observe(b),()=>S.disconnect()},[n]);const c=Xo[e.status]||Xo.M,v=qv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:Z("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>g(b=>!b),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[p?t.jsx(Ot,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(ht,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:Z("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:Vl(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:v}),t.jsx("span",{className:"ml-auto"}),t.jsx(Qi,{additions:e.additions,deletions:e.deletions})]}),!p&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Vv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(Yv,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function Gv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let m=s;for(let p=0;p<o.length-1;p++){const g=o[p];m.dirs.has(g)||m.dirs.set(g,{name:g,path:m.path?`${m.path}/${g}`:g,dirs:new Map,files:[]}),m=m.dirs.get(g)}m.files.push(r)}return Gl(s)}function Gl(e){const s=new Map;for(const r of e.dirs.values()){let o=Gl(r);for(;o.dirs.size===1&&o.files.length===0;){const m=[...o.dirs.values()][0];o={...m,name:`${o.name}/${m.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const Qv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[m,p]=y.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>p(g=>!g),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:[m?t.jsx($r,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(La,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),m&&t.jsx(Ql,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Ql=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((m,p)=>m.name.localeCompare(p.name)).map(m=>t.jsx(Qv,{dir:m,depth:s,activeKey:r,onSelect:o},m.path)),e.files.slice().sort((m,p)=>m.path.localeCompare(p.path)).map(m=>{const p=r===m.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(m),className:Z("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",p?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:m.path,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full shrink-0",Vo[m.status]||Vo.M)}),t.jsx("span",{className:Z("text-xs truncate",p?"text-foreground font-medium":"text-foreground/90"),children:Vl(m.path)})]},m.cardKey)})]}),Zv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=le(),{data:m,isLoading:p,fetchNextPage:g,hasNextPage:n,isFetchingNextPage:i}=ln({queryKey:ae.git.log(e),queryFn:({pageParam:u=0})=>xe.get("/git/log",{params:{workingDir:e,limit:String(Ti),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Ti?void 0:c.length*Ti}),l=m?.pages.flatMap(u=>u.commits)||[];return p?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(ze,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.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:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:Z("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:u.message,children:[t.jsx("span",{className:Z("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:Z("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",Kv(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>g(),disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Jv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,canRunGitOperations:p,onRefreshCommitMessage:g,onConflict:n,onResolveConflicts:i})=>{const{t:l}=le(),[u,c]=y.useState({kind:"overview"}),[v,b]=y.useState(""),[S,x]=y.useState(null),[a,f]=y.useState(null),{data:d,isLoading:h,isError:_}=Ln(e),w=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=Pn(e,w),C=y.useRef(new Map),E=y.useRef(null),N=y.useRef(null),D=y.useCallback((U,K)=>{K?C.current.set(U,K):C.current.delete(U)},[]),{uncommitted:A,committed:M,commitFiles:I}=y.useMemo(()=>{const U=R=>!v.trim()||R.path.toLowerCase().includes(v.trim().toLowerCase());if(u.kind==="commit"){const R={kind:"commit",hash:u.commit.hash},z=(k?.files||[]).filter(U).map(V=>({...V,cardKey:yr(R,V.path)}));return{uncommitted:[],committed:[],commitFiles:z}}const K=(d?.uncommitted||[]).filter(U).map(R=>({...R,cardKey:yr({kind:"working",diffType:"uncommitted"},R.path)})),W=(d?.committed||[]).filter(U).map(R=>({...R,cardKey:yr({kind:"working",diffType:"committed"},R.path)}));return{uncommitted:K,committed:W,commitFiles:[]}},[u,d,k,v]),L=u.kind==="commit"?I:[...A,...M],F=y.useMemo(()=>Gv(L),[L]),H=y.useMemo(()=>{let U=0,K=0;for(const W of L)U+=W.additions??0,K+=W.deletions??0;return{additions:U,deletions:K,files:L.length}},[L]),T=y.useCallback(()=>{const U=E.current;if(!U)return;const K=U.getBoundingClientRect().top;let W=null,R=Number.NEGATIVE_INFINITY;for(const[z,V]of C.current){const q=V.getBoundingClientRect().top-K;q<=48&&q>R&&(R=q,W=z)}if(!W){let z=null,V=Number.POSITIVE_INFINITY;for(const[q,se]of C.current){const Q=se.getBoundingClientRect().top-K;Q<V&&(V=Q,z=q)}W=z}x(W)},[]);y.useEffect(()=>{const U=E.current;if(!U)return;let K=0;const W=()=>{cancelAnimationFrame(K),K=requestAnimationFrame(T)};return U.addEventListener("scroll",W,{passive:!0}),()=>{U.removeEventListener("scroll",W),cancelAnimationFrame(K)}},[T]);const O=y.useCallback(U=>{const K=C.current.get(U.cardKey);K&&(K.scrollIntoView({behavior:"smooth",block:"start"}),x(U.cardKey),f(U.cardKey),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>f(null),1200))},[]),P=y.useCallback(U=>{c(K=>K.kind==="commit"&&K.commit.hash===U.hash?{kind:"overview"}:{kind:"commit",commit:U}),b(""),x(null),E.current?.scrollTo({top:0})},[]),B=y.useCallback(()=>{c({kind:"overview"}),b(""),x(null),E.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:l("未选择工作区")});const $=p&&s&&r&&o,X=u.kind==="commit"?j:h;return t.jsxs("div",{className:"flex flex-col h-full bg-background",children:[$&&n&&i&&t.jsx(Xl,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,committedFileCount:d?.committed?.length,onRefreshCommitMessage:g,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Zs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:H.files})}),t.jsx(Qi,{additions:H.additions,deletions:H.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(qs,{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:B,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(qs,{size:12}),l("全部变更")]}),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:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(Qi,{className:"ml-auto",additions:H.additions,deletions:H.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:X?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(U=>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"})]})]},U))}):_&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):L.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Cr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:v.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:I.map(U=>t.jsx(Mi,{entry:U,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[A.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:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:A.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:A.map(U=>t.jsx(Mi,{entry:U,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))})]}),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:l("已提交")}),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(U=>t.jsx(Mi,{entry:U,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))})]})]})}),t.jsxs("aside",{className:"w-60 shrink-0 border-l border-border flex flex-col min-h-0",children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(fn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:v,onChange:U=>b(U.target.value),placeholder:l("筛选文件..."),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:L.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:v.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(Ql,{node:F,depth:0,activeKey:S,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(ks,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Zv,{workingDir:e,selectedHash:w,onSelectCommit:P})})]})]})]})]})},Di=50,Yo={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 e0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?mt("{count}s ago",{count:r}):r<3600?mt("{count}m ago",{count:Math.floor(r/60)}):r<86400?mt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?mt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function t0(e){const s=e.split("/");return s[s.length-1]||e}function s0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const r0=({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:Z("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:Z("pl-2 whitespace-pre",o),children:e})]})},i0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=le(),{data:m,isLoading:p,isError:g}=On(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(g)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.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 i=n.split(`
|
|
72
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,u)=>t.jsx(r0,{line:l,lineNum:u+1},u))})},n0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:m}=le(),{data:p,isLoading:g}=Pn(e,s);if(g)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(ze,{size:12,className:"animate-spin"}),t.jsx("span",{children:m("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:m("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const l=Yo[i.status]||Yo.M,u=s0(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:Z("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:t0(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},o0=({workingDir:e})=>{const{t:s}=le(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:n}=ln({queryKey:ae.git.log(e||""),queryFn:({pageParam:w=0})=>xe.get("/git/log",{params:{workingDir:e||"",limit:String(Di),skip:String(w)}}),initialPageParam:0,getNextPageParam:(w,k)=>w.commits.length<Di?void 0:k.length*Di,enabled:!!e}),i=r?.pages.flatMap(w=>w.commits)||[],[l,u]=y.useState(null),[c,v]=y.useState(null),[b,S]=y.useState(280),[x,a]=y.useState(!1),f=y.useCallback(w=>{w.preventDefault(),a(!0);const k=w.clientX,j=b,C=N=>{const D=Math.min(480,Math.max(180,j+(N.clientX-k)));S(D)},E=()=>{a(!1),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",E)},[b]),d=w=>{l===w?(u(null),v(null)):(u(w),v(null))},h=y.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(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(m)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(i.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(ks,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const _=i.find(w=>w.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},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(ks,{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:i.length})]})}),t.jsxs("div",{ref:h,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[i.map(w=>{const k=l===w.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(w.hash),className:Z("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"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:Z("w-2 h-2 rounded-full shrink-0 transition-colors",k?"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:w.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:w.message}),t.jsx(Ot,{size:12,className:Z("shrink-0 text-muted-foreground/70 transition-transform",k&&"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:w.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:e0(w.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[w.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:w.body}),t.jsx(n0,{workingDir:e,hash:w.hash,selectedPath:c,onSelectFile:v})]})]},w.hash)}),g&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:c&&l?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(Cr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:c}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",_?.shortHash,")"]})]}),t.jsx(i0,{workingDir:e,hash:l,filePath:c})]}):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(Cr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function a0(e){return Nt({queryKey:ae.previews.status(e??""),queryFn:async()=>{const s=await xe.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function l0(e){const s=at();return wt({mutationFn:r=>xe.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:ae.previews.status(e)}),s.invalidateQueries({queryKey:ae.workspaces.all}))}})}function c0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function d0({workspaceId:e,readOnly:s}){const{t:r}=le(),{data:o,isLoading:m,refetch:p,isFetching:g}=a0(e),n=l0(e),[i,l]=y.useState(""),[u,c]=y.useState(0);y.useEffect(()=>{l(o?.target??"")},[o?.target]);const v=y.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${u}`,[u,o?.ready,o?.viewUrl]),b=async()=>{if(e)try{await n.mutateAsync(i.trim()||null),c(x=>x+1),ut.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");ut.error(a)}},S=async()=>{await p(),c(x=>x+1)};return e?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-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:i,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),b())},disabled:s||n.isPending,placeholder:c0(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-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.jsxs(Me,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:s||n.isPending,title:r("Save preview target"),children:[n.isPending?t.jsx(ze,{className:"animate-spin"}):t.jsx(pu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Me,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:g,title:r("Refresh preview"),children:[g?t.jsx(ze,{className:"animate-spin"}):t.jsx(Ur,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Me,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(cn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:m?r("Checking preview target..."):o?.ready?`${r("Proxying")} ${o.target}`:o?.configured?`${r("Preview target is not reachable")}${o.error?`: ${o.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:v?t.jsx("iframe",{src:v,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},v):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:o?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function u0(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Go(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 h0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Zl({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:m,className:p,buttonClassName:g}){const{t:n}=le(),[i,l]=y.useState(!1),u=y.useRef(null),c=y.useMemo(()=>Rn(e,s),[e,s]),v=c.find(b=>b.workspace.id===r)??c[0];return y.useEffect(()=>{if(!i)return;const b=S=>{u.current&&!u.current.contains(S.target)&&l(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[i]),c.length<=1?null:t.jsxs("div",{ref:u,className:Z("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>l(b=>!b),disabled:m,className:Z("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",g),title:n("Workspace"),children:[t.jsx(Cs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(v.roleLabel)),children:n(v.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(v.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:h0(ds(v.workspace))}),t.jsx(ht,{size:13,className:Z("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&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(b=>{const S=b.workspace.id===v.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(b.workspace.id),l(!1)},className:Z("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",S&&"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:S?t.jsx(yt,{size:13}):t.jsx(un,{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:n(b.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(b.roleLabel)),children:n(b.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",u0(b.workspace.status)),children:b.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:ds(b.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:[b.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",b.ownerName]}),b.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",b.parentBranchName]}),t.jsx("span",{children:b.workspace.id.slice(0,8)})]})]})]},b.workspace.id)})})]})}const f0=[{key:"review",label:"Changes",icon:t.jsx(Zs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Qs,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Er,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Aa,{size:14})}],m0=[{key:"history",label:"History",icon:t.jsx(ks,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Qs,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Er,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Aa,{size:14})}],p0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{onClick:s,className:Z("flex items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px",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})]}),Jl=ce.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:m,projectId:p,hideChanges:g,readOnly:n,repoDeleted:i,teamRun:l,teamStatus:u,gitProps:c,workspaces:v,selectedWorkspaceId:b,onSelectWorkspace:S,tabRef:x}){const{t:a}=le(),f=tn(D=>D.setVisibleContext),d=y.useMemo(()=>{const D=g?m0:f0,A=n?D.filter(M=>M.key!=="terminal"):D;return l?[{key:"team-status",label:"Team Status",icon:t.jsx(cs,{size:14})},...A]:A},[g,n,l]),[h,_]=y.useState(g?"history":"review");y.useImperativeHandle(x,()=>({setTab:D=>_(D)}),[]);const{data:w}=fd(p??""),k=y.useMemo(()=>{if(!w?.quickCommands)return[];try{return JSON.parse(w.quickCommands)}catch{return[]}},[w?.quickCommands]),[j,C]=y.useState([]),E=y.useRef(void 0);y.useEffect(()=>{m&&m!==E.current&&(E.current=m,C(D=>D.includes(m)?D:[...D,m]))},[m]),y.useEffect(()=>{n&&h==="terminal"&&_(g?"history":"review")},[h,g,n]),y.useEffect(()=>{l||h!=="team-status"||_(g?"history":"review")},[h,g,l]),y.useEffect(()=>{const D=h==="review"?"changes":h==="history"?"history":null;if(!o||!m||!D){f(null);return}return f({workspaceId:o,workingDir:m,tab:D}),()=>{f(null)}},[h,f,m,o]);const N=!!S&&Rn(v,l).length>1;return t.jsxs("div",{className:Z("flex flex-col h-full bg-white",s),children:[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:a(i?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),t.jsx("div",{className:"flex items-center px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:d.map(D=>t.jsx(p0,{active:h===D.key,onClick:()=>_(D.key),icon:D.icon,label:a(D.label)},D.key))}),t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[N&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Zl,{workspaces:v,teamRun:l,selectedWorkspaceId:b,onSelectWorkspace:S,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[h==="team-status"&&l&&u,h==="editor"&&t.jsx(Wv,{workingDir:m,readOnly:n}),j.map(D=>{const A=h==="terminal"&&m===D;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:A?"block":"none"},children:t.jsx(ep,{cwd:D,isVisible:A,quickCommands:k})},D)}),h==="preview"&&t.jsx(d0,{workspaceId:o,readOnly:n}),h==="review"&&t.jsx(Jv,{workingDir:m,workspaceId:o,branchName:c?.branchName,targetBranch:c?.targetBranch,commitMessage:c?.commitMessage,canRunGitOperations:c?.canRunGitOperations,onRefreshCommitMessage:c?.onRefreshCommitMessage,onConflict:c?.onConflict,onResolveConflicts:c?.onResolveConflicts}),h==="history"&&t.jsx(o0,{workingDir:m})]})]})]})}),Qo=1500,g0=3e3;function v0(e){const[s,r]=y.useState(null),o=y.useRef(0),m=y.useRef(null),p=y.useRef(null);return y.useEffect(()=>{if(!e)return;const g=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Qt.connect(),i=u=>{r(u),p.current=setTimeout(()=>r(null),g0)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){g(),m.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const v=o.current>0?Date.now()-o.current:0,b=Qo-v;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),m.current=c,p.current=setTimeout(()=>i(c),Qo)):b>0?(m.current=c,g(),p.current=setTimeout(()=>i(c),b)):i(c)};return n.on(ct.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(ct.WORKSPACE_SETUP_PROGRESS,l),g(),o.current=0,m.current=null}},[e]),s}function In(){const e=at();return wt({mutationFn:s=>xe.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function ec(){const e=at();return wt({mutationFn:s=>xe.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)})}})}function Bn(){const e=at();return wt({mutationFn:({id:s,message:r,providerId:o})=>xe.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function tc(e,s){return y.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[e,s])}function sc({isOpen:e,onClose:s,onStarted:r,taskId:o,taskTitle:m,taskDescription:p,taskPrompt:g}){const{t:n}=le(),[i,l]=y.useState(""),[u,c]=y.useState(""),[v,b]=y.useState(lt.WORKTREE),[S,x]=y.useState("idle"),[a,f]=y.useState(null),d=at(),h=ll(o),_=In(),{data:w,isLoading:k}=js();y.useEffect(()=>{if(!e||!w)return;const A=w.find(M=>M.availability.type!=="NOT_FOUND");A&&l(A.provider.id)},[e,w]),y.useEffect(()=>{if(e){const A=[m];p&&A.push(p),c(g?.trim()||A.join(`
|
|
73
|
-
|
|
74
|
-
`)),b(lt.WORKTREE),x("idle"),f(null)}},[e,m,p,g]);const j=S!=="idle",C=async()=>{if(!(!i||!u.trim())){f(null);try{x("creating-workspace");const A=await h.mutateAsync({workspaceKind:v});x("creating-session");const M=await xe.post(`/workspaces/${A.id}/sessions`,{providerId:i,prompt:u.trim()});x("starting-session"),await _.mutateAsync(M.id),await d.invalidateQueries({queryKey:ae.workspaces.list(o)}),x("idle"),r?.(),s()}catch(A){x("idle"),f(A instanceof Error?A.message:n("启动失败,请重试"))}}},E={idle:n("启动"),"creating-workspace":n("创建工作空间..."),"creating-session":n("创建会话..."),"starting-session":n("启动 Agent...")},N=(w??[]).map(({provider:A,availability:M})=>{const I=M.type!=="NOT_FOUND";return{value:A.id,label:I?A.name:`${A.name}${n(" (不可用)")}`,disabled:!I}}),D=[{value:lt.WORKTREE,label:n("工作树模式")},{value:lt.MAIN_DIRECTORY,label:n("本地模式")}];return t.jsx(Es,{isOpen:e,onClose:j?()=>{}:s,title:n("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{variant:"outline",onClick:s,disabled:j,children:n("取消")}),t.jsx(Me,{onClick:C,disabled:j||!i||!u.trim(),children:E[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("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:n("Agent")}),t.jsx(as,{value:i,onChange:l,options:N,placeholder:n(k?"加载中...":"选择 Agent"),disabled:j||k})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:n("模式")}),t.jsx(as,{value:v,onChange:A=>b(A),options:D,disabled:j})]})]}),v===lt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:n("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:n("任务描述")}),t.jsx("textarea",{value:u,onChange:A=>c(A.target.value),rows:5,disabled:j,placeholder:n("描述你想让 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"})]}),a&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:a})]})})}function rc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function x0(e,s,r){const o=e?.providerId??r?.providerId??null,m=o?s?.find(n=>n.provider.id===o)?.provider:null,p=m?.name??o??e?.agentType??r?.agentType??null;if(!p)return null;const g=o&&m?.name&&o!==m.name?`${m.name} (${o})`:p;return{label:p,title:g}}function ic({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:g="top"}){const{t:n}=le(),i=x0(e,s,{providerId:m,agentType:p});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&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:`${n("Provider")}: ${i.title}`,children:[t.jsx(Qs,{size:o?12:14,className:"shrink-0 text-neutral-400"}),t.jsx("span",{className:"min-w-0 truncate",children:Bi(i.label,o?12:18)})]}),t.jsx(jn,{usage:r,tooltipSide:g})]})}function Zo(e,s,r,o){if(r.filter(g=>g===o).length<=1)return e;const p=r.slice(0,s+1).filter(g=>g===o).length;return`${e} #${p}`}function b0(e){return Object.values(e).filter(Boolean).length}function nc({mode:e,setMode:s,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:g=!1}){const{t:n}=le(),{data:i}=js(),{data:l,isError:u,isFetching:c,isLoading:v,refetch:b}=_a(),{data:S,isError:x,isFetching:a,isLoading:f,refetch:d}=nd(),h=y.useMemo(()=>new Map((i??[]).map(({provider:N,availability:D})=>[N.id,N.name+(D.type==="NOT_FOUND"?n(" (不可用)"):"")])),[i,n]),_=y.useMemo(()=>new Map((l??[]).map(N=>[N.id,N])),[l]),w=y.useMemo(()=>new Map((S??[]).map(N=>[N.id,N])),[S]),k=y.useMemo(()=>m.map(N=>_.get(N)).filter(N=>!!N),[_,m]);y.useEffect(()=>{l!==void 0&&p(N=>{const D=N.filter(A=>_.has(A));return D.length===N.length&&D.every((A,M)=>A===N[M])?N:D})},[l,_,p]),y.useEffect(()=>{S!==void 0&&o(N=>!N||w.has(N)?N:null)},[o,w,S]);const j=N=>{g||o(D=>D===N?null:N)},C=N=>{g||p(D=>[...D,N])},E=N=>{g||p(D=>D.filter((A,M)=>M!==N))};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 shrink-0",children:n("执行模式")}),t.jsxs("div",{className:"inline-flex rounded-md bg-white p-0.5 shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>!g&&s("AUTO"),disabled:g,className:Z("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(za,{size:11}),n("自动模式")]}),t.jsxs("button",{type:"button",onClick:()=>!g&&s("CONFIRM"),disabled:g,className:Z("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(Fa,{size:11}),n("确认模式")]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("section",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium text-neutral-500 mb-1.5",children:n("团队模板")}),x?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("团队模板加载失败")}),t.jsx("button",{type:"button",onClick:()=>{d()},disabled:g||a,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):f?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(ze,{size:12,className:"animate-spin"}),n("加载中...")]}):(S??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有团队模板"),t.jsx(Vn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1.5",children:(S??[]).map(N=>{const D=N.id===r,A=N.members?.length??0,M=N.members?.map(L=>L.memberPresetId)??[],I=N.members?.slice(0,3).map((L,F)=>Zo(L.memberPreset?.name??L.memberPresetId,F,M,L.memberPresetId)).join(", ");return t.jsx("button",{type:"button",onClick:()=>j(N.id),disabled:g,className:Z("w-full rounded-lg px-3 py-2 text-left transition-all disabled:cursor-not-allowed disabled:opacity-60",D?"bg-blue-50 ring-1 ring-blue-200":"bg-white hover:bg-white/80"),children:t.jsxs("div",{className:"flex items-center 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("span",{className:Z("text-xs truncate",D?"font-medium text-blue-800":"text-neutral-800"),children:N.name}),t.jsxs("span",{className:"text-[10px] text-neutral-400 shrink-0",children:[A,n("人")]})]}),I&&t.jsx("div",{className:"mt-0.5 text-[10px] text-neutral-400 truncate",children:I})]}),D&&t.jsx(yt,{size:13,className:"shrink-0 text-blue-600"})]})},N.id)})})]}),t.jsxs("section",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:n("追加成员")}),k.length>0&&t.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-blue-600 text-[9px] font-medium text-white px-1",children:k.length})]}),k.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:k.map((N,D)=>{const A=Zo(N.name,D,m,N.id);return t.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded bg-blue-50 text-[10px] text-neutral-700",children:[t.jsx(Lt,{name:N.name,avatar:N.avatar,className:"h-3.5 w-3.5 text-[7px]"}),t.jsx("span",{className:"max-w-[80px] truncate",children:A}),t.jsx("button",{type:"button",onClick:()=>E(D),disabled:g,className:"p-0.5 text-neutral-400 hover:text-red-500 disabled:opacity-30 rounded",children:t.jsx(Wt,{size:9})})]},`${N.id}-${D}`)})}),u?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("成员预设加载失败")}),t.jsx("button",{type:"button",onClick:()=>{b()},disabled:g||c,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):v?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(ze,{size:12,className:"animate-spin"}),n("加载中...")]}):(l??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有成员预设"),t.jsx(Vn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:(l??[]).map(N=>{const D=m.filter(I=>I===N.id).length,A=h.get(N.providerId)??N.providerId,M=b0(N.capabilities);return t.jsxs("button",{type:"button",onClick:()=>C(N.id),disabled:g,className:Z("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left transition-all",g&&"cursor-not-allowed opacity-60","bg-white hover:bg-white/80"),children:[t.jsx(Lt,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs text-neutral-800 truncate",children:N.name}),t.jsxs("div",{className:"text-[10px] text-neutral-400 truncate",children:[A," · ",M,"/10"]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[D>0&&t.jsxs("span",{className:"text-[9px] text-blue-600 font-medium",children:["×",D]}),t.jsx(Ut,{size:12,className:"text-neutral-300"})]})]},N.id)})})]})]})]})}function _0({isOpen:e,onClose:s,taskId:r}){const{t:o}=le(),[m,p]=y.useState("AUTO"),[g,n]=y.useState(null),[i,l]=y.useState([]),[u,c]=y.useState(null),v=Sa();y.useEffect(()=>{e&&(p("AUTO"),n(null),l([]),c(null))},[e]);const b=v.isPending,S=!!g||i.length>0,x=async()=>{if(!b){if(!g&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await v.mutateAsync({taskId:r,mode:m,...g?{teamTemplateId:g}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(f){if(f instanceof ya&&f.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(f instanceof Error?f.message:o("创建 TeamRun 失败"))}}},a=b||!S;return t.jsxs(Es,{isOpen:e,onClose:b?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:b,children:o("取消")}),t.jsx(Me,{type:"button",onClick:x,disabled:a,children:o(b?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(nc,{mode:m,setMode:p,selectedTemplateId:g,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:l,disabled:b}),u&&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:u})]})}function oc({providers:e,currentProviderId:s,agentType:r,onSelect:o}){const{t:m}=le(),[p,g]=y.useState(!1),n=y.useRef(null),i=e.filter(u=>String(u.provider.agentType)===r),l=e.find(u=>u.provider.id===s);return y.useEffect(()=>{function u(c){n.current&&!n.current.contains(c.target)&&g(!1)}if(p)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[p]),i.length<=1?t.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[t.jsx(Yn,{size:14,className:"shrink-0"}),t.jsx("span",{children:l?.provider.name?Bi(l.provider.name,12):r})]}):t.jsxs("div",{className:"relative",ref:n,children:[t.jsxs("button",{onClick:()=>g(!p),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${l?.provider.name??r} (click to change)`,children:[t.jsx(Yn,{size:14,className:"shrink-0"}),t.jsx("span",{children:l?.provider.name?Bi(l.provider.name,12):r}),t.jsx(ht,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[t.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),i.map(u=>t.jsxs("button",{onClick:()=>{o(u.provider.id),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${u.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate max-w-[120px]",children:u.provider.name}),u.provider.isDefault&&t.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),u.provider.id===s&&t.jsx(yt,{size:14,className:"shrink-0"})]},u.provider.id))]})]})}function y0({commands:e,selectedIndex:s,query:r,hasCatalog:o,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:g="No slash commands catalog for this agent yet.",emptyQueryMessage:n,insertionHint:i="Enter / Tab to insert",compact:l=!1,onSelect:u}){const c=l?"px-1.5 pb-1.5":"px-2 pb-2",v=l?"px-2 py-1.5":"px-2.5 py-2",b=l?"max-h-36":"max-h-48";return t.jsxs("div",{className:l?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${l?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:i})]}),e.length===0?t.jsx("div",{className:`${l?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?n??`No matches for ${p}${r}`:g}):t.jsx("div",{className:`${c} ${b} overflow-y-auto`,children:e.map((S,x)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(S),className:`w-full rounded-lg border text-left transition-colors ${x===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${v}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:S.command}),S.kind&&S.kind!=="builtin"?t.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:S.scope?`${S.scope} ${S.kind}`:S.kind}):null]}),t.jsx("div",{className:`${l?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:S.description})]},S.command))})]})}const Yt=12,xr=8;function Or({open:e,anchorRef:s,commands:r,selectedIndex:o,query:m,hasCatalog:p,title:g,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:l,insertionHint:u,compact:c=!1,onSelect:v}){const b=y.useRef(null),[S,x]=y.useState(null);return y.useLayoutEffect(()=>{if(!e){x(null);return}const a=s.current;if(!a)return;let f=0;const d=()=>{const w=s.current;if(!w)return;const k=w.getBoundingClientRect(),j=window.innerWidth,C=window.innerHeight,E=c?260:320,N=c?j-Yt*2:560,D=Math.min(Math.max(k.width,E),Math.max(E,N)),A=Math.min(Math.max(Yt,k.left),Math.max(Yt,j-Yt-D)),M=C-k.bottom-xr-Yt,I=k.top-xr-Yt,L=b.current?.offsetHeight??(c?220:280),F=c?240:320,H=M<180&&I>M,O=Math.max(120,Math.min(F,H?I:M)),P=H?Math.max(Yt,k.top-xr-Math.min(L,O)):Math.min(C-Yt-Math.min(L,O),k.bottom+xr);x({top:P,left:A,width:D,maxHeight:O})},h=()=>{cancelAnimationFrame(f),f=requestAnimationFrame(d)};h();const _=new ResizeObserver(h);return _.observe(a),b.current&&_.observe(b.current),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),window.visualViewport?.addEventListener("resize",h),window.visualViewport?.addEventListener("scroll",h),()=>{cancelAnimationFrame(f),_.disconnect(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),window.visualViewport?.removeEventListener("resize",h),window.visualViewport?.removeEventListener("scroll",h)}},[s,r.length,c,e,m,o]),!e||!S||typeof document>"u"?null:Zt.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:b,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:S.top,left:S.left,width:S.width,maxHeight:S.maxHeight},children:t.jsx(y0,{commands:r,selectedIndex:o,query:m,hasCatalog:p,title:g,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:l,insertionHint:u,compact:c,onSelect:v})})}),document.body)}function S0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=le(),m=cl();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const p=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 px-4 py-3 rounded-lg border border-amber-200 bg-amber-50 flex items-center gap-3",children:[t.jsx(Hr,{size:18,className:"text-amber-600 shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-amber-900",children:o("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:s.conflictedFiles.length})})}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(Me,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:o("中止操作")}),t.jsx(Me,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function ac(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function lc(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 w0(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 C0(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 k0(e,s,r,o,m){const p=ac(r),g=lc(m);return o===Us.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...g.length>0?["","### 上下文",...g]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...g.length>0?["","### 上下文",...g]:[],"","### 冲突文件",p,"","### 解决步骤",...w0(e,m)].join(`
|
|
77
|
-
`)}function E0(e){const s=e.conflictOp===Us.REBASE?"Rebase":"Merge",r=ac(e.conflictedFiles),o=[...lc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Us.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":C0(e)].join(`
|
|
78
|
-
`)}function j0(e){if(e.teamRunId)return{type:"team_room",message:E0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:k0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function cc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:m,sourceBranch:p,targetBranch:g,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:v,sourceWorktreePath:b,targetWorktreePath:S,sessions:x,currentSessionId:a,teamRunId:f}){const{t:d}=le(),[h,_]=y.useState(""),w=Bn(),k=sn(f??""),j=wn(),C=!!f,E=a||h,N=C?k.isPending:w.isPending,D=()=>{const F=j0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:v,sourceWorktreePath:b,targetWorktreePath:S,sourceBranch:p,targetBranch:g,conflictedFiles:m,conflictOp:o,teamRunId:f,currentSessionId:a,selectedSessionId:h});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ut.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&w.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},A=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},M=o==="REBASE"?"Rebase":"Merge",I=!C&&!a&&x.length>0,L=C||!!E;return t.jsx(Es,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:A,children:d("在 IDE 中打开")}),t.jsx(Me,{onClick:D,disabled:!L||N,children:d(N?"发送中...":"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:m.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>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:F},F))})]}),C&&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,由团队调度处理。")}),I&&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:h,onChange:F=>_(F.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...")}),x.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!C&&!E&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function N0({agentType:e,workingDir:s}){return Nt({queryKey:ae.system.slashCommandCatalog(e,s),queryFn:async()=>(await xe.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function R0(e,s){const r=new Set,o=[];for(const m of[...e,...s]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),o.push(m.kind?m:{...m,kind:"builtin"}))}return o}function ii(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function T0(e){return ii(e.command)}function A0(e,s){if(!s)return 1e3;const r=T0(e),o=e.aliases?.map(ii)??[],m=[r,...o];let p=0;for(const n of m)n===s?p=Math.max(p,500):n.startsWith(s)?p=Math.max(p,400-(n.length-s.length)):n.includes(s)&&(p=Math.max(p,250-n.indexOf(s)));return p>0?p:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function Jo(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:ii(s[2]),replaceStart:r}}function dc(e,s){const r=ii(s);return r?e.map((o,m)=>({command:o,index:m,score:A0(o,r)})).filter(o=>o.score>0).sort((o,m)=>m.score-o.score||o.index-m.index||o.command.command.localeCompare(m.command.command)).map(o=>o.command):e.slice()}const M0=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],D0=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],L0=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],P0=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],O0={[Ht.CODEX]:M0,[Ht.CLAUDE_CODE]:D0,[Ht.GEMINI_CLI]:L0,[Ht.CURSOR_AGENT]:P0};function uc(e){return e.trim().toLowerCase().replace(/^\//,"")}function I0(e){return e?(O0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function B0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?uc(s[1]):null}function F0(e,s){return dc(e,uc(s))}function z0(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 hc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:g}){const[n,i]=y.useState(0),{data:l=[]}=N0({agentType:e,workingDir:s}),u=y.useMemo(()=>R0(I0(e),l),[e,l]),c=y.useMemo(()=>B0(r),[r]),v=y.useMemo(()=>c===null?[]:F0(u,c),[u,c]),b=y.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,g))}px`)},[g,p,m]);y.useEffect(()=>{i(0)},[e,c]),y.useEffect(()=>{n<v.length||i(0)},[v.length,n]);const S=y.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const h=m.current;h&&(b(),h.focus(),h.setSelectionRange(d.length,d.length))})},[r,b,o,m]),x=y.useCallback(a=>c===null||v.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(f=>(f+1)%v.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(f=>(f-1+v.length)%v.length),!0):z0(a)?(a.preventDefault(),S(v[n]??v[0]),!0):!1,[S,v,c,n]);return{allCommands:u,query:c,filteredCommands:v,selectedIndex:n,setSelectedIndex:i,applyCommand:S,handleKeyDown:x}}function H0({agentType:e,workingDir:s}){return Nt({queryKey:ae.system.skillCatalog(e,s),queryFn:async()=>(await xe.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Ht.CODEX,staleTime:3e4})}function W0(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 fc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:g}){const[n,i]=y.useState(0),{data:l=[]}=H0({agentType:e,workingDir:s}),c=y.useMemo(()=>e===Ht.CODEX?Jo(r):null,[e,r])?.query??null,v=y.useMemo(()=>c===null?[]:dc(l,c),[c,l]),b=y.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,g))}px`)},[g,p,m]);y.useEffect(()=>{i(0)},[e,c]),y.useEffect(()=>{n<v.length||i(0)},[v.length,n]);const S=y.useCallback(a=>{const f=Jo(r);if(!f)return;const d=`${r.slice(0,f.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const h=m.current;h&&(b(),h.focus(),h.setSelectionRange(d.length,d.length))})},[r,b,o,m]),x=y.useCallback(a=>c===null||v.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(f=>(f+1)%v.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(f=>(f-1+v.length)%v.length),!0):W0(a)?(a.preventDefault(),S(v[n]??v[0]),!0):!1,[S,v,c,n]);return{allSkills:l,query:c,filteredSkills:v,selectedIndex:n,setSelectedIndex:i,applySkill:S,handleKeyDown:x}}const $0="/api",U0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${$0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,q0=675,ea=320,ta=1200;function K0(){const{t:e}=le();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 sa=[{status:ve.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ta,{className:"w-3 h-3"})},{status:ve.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Ra,{className:"w-3 h-3"})},{status:ve.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Na,{className:"w-3 h-3"})},{status:ve.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(ja,{className:"w-3 h-3"})},{status:ve.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Ea,{className:"w-3 h-3"})}];function X0({status:e,onChangeStatus:s}){const{t:r}=le(),[o,m]=y.useState(!1),p=y.useRef(null);y.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const g=sa.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&m(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${g.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[g.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:sa.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function ra({state:e,onRetry:s}){const{t:r}=le(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",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",{children:o})]})}function V0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:m,onAutoStartRecovered:p}){const{t:g}=le(),[n,i]=y.useState(""),[l,u]=y.useState(!1),[c,v]=y.useState(!1),[b,S]=y.useState(!1),[x,a]=y.useState(!1),[f,d]=y.useState(!1),[h,_]=y.useState(!1),[w,k]=y.useState(null),j=y.useRef(null),[C,E]=y.useState(!1),[N,D]=y.useState(null),[A,M]=y.useState(void 0),[I,L]=y.useState(!1),F=y.useRef(null),H=y.useRef(null),T=y.useRef(null),O=y.useRef(null),{scrollRef:P,contentRef:B,isAtBottom:$,scrollToBottom:X}=En({resize:"smooth",initial:"instant"}),[U,K]=y.useState(q0),[W,R]=y.useState(!0),[z,V]=y.useState(!1),q=y.useRef(0),se=y.useRef(0),Q=y.useRef(null),{data:ee,isLoading:be}=Sn(e?.id??""),Ce=v0(e?.id),{data:Oe}=wa(e?.id??""),{data:de}=Ca(Oe?.id??""),Ke=sn(Oe?.id??""),fe=Oe??null,ge=!!fe,$e=Oe===null,et=!!(e?.id&&Oe===null),{data:De,isLoading:re}=ka(e?.id??"",et);y.useEffect(()=>{L(!1),D(null),M(void 0)},[e?.id]);const ye=y.useMemo(()=>pl(ee,fe,A),[A,fe,ee]);y.useEffect(()=>{A&&!ee?.some(J=>J.id===A)&&M(void 0)},[A,ee]);const je=y.useMemo(()=>ee?.find(J=>J.id===ye),[ye,ee]),Le=je?.status===Mt.ACTIVE?je.id:void 0,Ae=gl(je,fe);y.useEffect(()=>{if(!I||!ee)return;ee.some(ue=>ue.status==="ACTIVE"&&ue.sessions&&ue.sessions.length>0)&&L(!1)},[ee,I]);const Se=y.useMemo(()=>{if(I||!ee)return null;const J=ft=>{const mi=ft.createdAt,Ps=ft.endedAt??ft.startedAt??mi;if(!Ps)return 0;const ps=Date.parse(Ps);return Number.isNaN(ps)?0:ps},ue=(ft,mi)=>{const Ps=ft.filter(ps=>mi.includes(ps.status));return Ps.length===0?null:Ps.sort((ps,zc)=>J(zc)-J(ps))[0]??null},Ge=ee.filter(ft=>ft.status==="ACTIVE"&&Array.isArray(ft.sessions)).flatMap(ft=>ft.sessions??[]),Et=ue(Ge,[it.RUNNING])??ue(Ge,[it.PENDING])??ue(Ge,[it.COMPLETED,it.FAILED,it.CANCELLED]);if(Et)return Et;const _t=ee.filter(ft=>(ft.status==="MERGED"||ft.status==="ABANDONED"||ft.status==="HIBERNATED")&&Array.isArray(ft.sessions)).flatMap(ft=>ft.sessions??[]);return ue(_t,[it.COMPLETED,it.FAILED,it.CANCELLED])},[ee,I]),ke=Se?.id??"",Ne=ge?N??"":ke,G=y.useMemo(()=>{if(!N||!ee)return null;for(const J of ee){const ue=J.sessions?.find(Ge=>Ge.id===N);if(ue)return ue}return null},[N,ee]),oe=y.useMemo(()=>{if(!N||!fe?.invocations)return null;const J=fe.invocations.filter(ue=>ue.sessionId===N);return J.length===0?null:J.sort((ue,Ge)=>{const Et=Date.parse(ue.updatedAt??ue.createdAt??""),_t=Date.parse(Ge.updatedAt??Ge.createdAt??"");return(Number.isNaN(_t)?0:_t)-(Number.isNaN(Et)?0:Et)})[0]??null},[N,fe?.invocations]),we=y.useMemo(()=>!oe?.memberId||!fe?.members?null:fe.members.find(J=>J.id===oe.memberId)??null,[oe?.memberId,fe?.members]),Y=N?G:Se??null,te=Y?.status===it.RUNNING||Y?.status===it.PENDING,ie=!!e?.projectArchivedAt,he=!!e?.projectRepoDeletedAt,Be=g(he?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Re}=js(),[tt,me]=y.useState(null);y.useEffect(()=>{me(Se?.providerId??null)},[Se?.providerId]);const Xe=y.useMemo(()=>!Se||!ee?!1:!ee.some(ue=>ue.status==="ACTIVE"&&ue.sessions?.some(Ge=>Ge.id===Se.id)),[Se,ee]),He=y.useMemo(()=>{if(!(!ee||I)){if(je)return Jt(je);for(const J of ee)if(J.status==="ACTIVE"&&Jt(J))return Jt(J);return Jt(ee[0])}},[I,je,ee]),nt=hc({agentType:Se?.agentType,workingDir:He,input:n,setInput:i,textareaRef:T,minHeight:60,maxHeight:300}),Pe=fc({agentType:Se?.agentType,workingDir:He,input:n,setInput:i,textareaRef:T,minHeight:60,maxHeight:300}),Te=tn(J=>J.visibleContext),Ve=!!(W&&Ae&&Le&&Te?.workspaceId===Le&&Te.tab==="changes"),{data:Ze}=Cn(Le??"",{enabled:Ve}),st=je?.sessions??[],pt=ds(je),gt=je?.commitMessage,vt=y.useMemo(()=>vl(je,ee,e?.mainBranch??""),[je,e?.mainBranch,ee]),Ye=y.useMemo(()=>Ze?.conflictOp&&Ze.conflictedFiles.length>0?{conflictOp:Ze.conflictOp,conflictedFiles:Ze.conflictedFiles}:w,[Ze?.conflictOp,Ze?.conflictedFiles,w]),Bt=Ye?.targetWorkspaceId??Le,xt=Ye?.targetWorktreePath??je?.worktreePath,Rt=Ye?.sourceBranch??pt,is=Ye?.targetBranch??vt,Je=at(),hs=y.useCallback(async()=>e?.id?Je.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}):null,[Je,e?.id]),or=y.useCallback(()=>e?.id?Je.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Je]);y.useEffect(()=>{if(!C)return;const J=ue=>{H.current&&!H.current.contains(ue.target)&&E(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[C]);const Ts=Bn(),Xt=wn(),ns=od(),ar=ll(e?.id??""),As=In(),fs=hf(),$t=y.useMemo(()=>!ee||ee.some(ue=>ue.status==="ACTIVE")?null:ee.find(ue=>ue.status==="HIBERNATED")??null,[ee]),ms=y.useRef(null);y.useEffect(()=>{$t&&ms.current!==$t.id&&(fs.isPending||(ms.current=$t.id,fs.mutate($t.id,{onSettled:()=>{ms.current=null}})))},[$t,fs]);const ni=y.useCallback(async()=>{if(!e?.id)return;const J=Se?.providerId??Re?.find(ue=>ue.availability.type!=="NOT_FOUND")?.provider.id;if(J){a(!1),d(!0);try{const Ge=(await hs())?.prompt??e.title;await ns.mutateAsync(e.id),L(!0);const Et=await ar.mutateAsync({}),_t=await xe.post(`/workspaces/${Et.id}/sessions`,{providerId:J,prompt:Ge});await As.mutateAsync(_t.id),await Je.invalidateQueries({queryKey:ae.workspaces.list(e.id)})}catch(ue){console.error("[retry] failed:",ue),L(!1)}finally{d(!1)}}},[e?.id,e?.title,Se?.providerId,Re,hs,ns,ar,As,Je]),Ms=y.useCallback(async()=>{e?.id&&(await hs(),u(!0))},[hs,e?.id]),lr=y.useCallback(()=>{je?.id&&Xt.mutate({workspaceId:je.id})},[Xt,je?.id]),oi=y.useCallback(()=>{!e?.id||!s||(s(e.id),S(!1))},[e?.id,s]),cr=y.useCallback(J=>{D(J),requestAnimationFrame(()=>{X()})},[X]),ai=y.useCallback(()=>{D(null)},[]),Ds=y.useCallback(J=>{k(J??null),_(!0)},[]),li=y.useCallback(J=>Ke.mutateAsync(J),[Ke]),Tt=y.useCallback(()=>{Je.invalidateQueries({queryKey:ad.all})},[Je]),{isConnected:ne,isLoadingSnapshot:_e,logs:Ie,entries:Ue,attach:bt}=Ma({sessionId:Ne,sessionStatus:Y?.status,onExit:y.useCallback(()=>{Je.invalidateQueries({queryKey:["workspaces"]})},[Je])});y.useEffect(()=>{if(!e?.id)return;const J=Qt.connect();J.emit(xs.SUBSCRIBE,{topic:"task",id:e.id});const ue=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:["tasks"]}),Tt())},Ge=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Tt())},Et=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Tt())};return J.on(ct.TASK_UPDATED,ue),J.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ge),J.on(ct.WORKSPACE_HIBERNATED,Et),()=>{J.off(ct.TASK_UPDATED,ue),J.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ge),J.off(ct.WORKSPACE_HIBERNATED,Et),J.emit(xs.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Je,Tt]),y.useEffect(()=>{if(!Ne)return;const J=Qt.connect(),ue=Ge=>{Ge.sessionId===Ne&&(Je.invalidateQueries({queryKey:["workspaces"]}),Tt())};return J.on(ct.SESSION_COMPLETED,ue),()=>{J.off(ct.SESSION_COMPLETED,ue)}},[Ne,Je,Tt]);const{todos:Ct}=Da(Ue),{files:Fe,addFiles:kt,removeFile:Vt,clear:os,buildMarkdownLinks:zn,hasFiles:Ls,isUploading:dr}=Qr(),Tc=y.useMemo(()=>rc(Y),[Y?.tokenUsage]),Hn=tc(Ie,Tc);y.useEffect(()=>{Ne&&ne&&bt()},[Ne,ne,bt]);const Wn=y.useRef(e?.id);y.useEffect(()=>{if(Wn.current!==e?.id&&P.current){const J=P.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}Wn.current=e?.id},[e?.id,P]);const ci=ec(),di=y.useRef(!1),$n=y.useCallback(async()=>{if(!n.trim()&&!Ls||!Ne||di.current||dr)return;di.current=!0;const J=zn(),ue=[n.trim(),J].filter(Boolean).join(`
|
|
79
|
-
|
|
80
|
-
`);i(""),os(),T.current&&(T.current.style.height="60px"),Ts.mutate({id:Ne,message:ue,providerId:tt??void 0},{onSuccess:()=>{bt()},onSettled:()=>{di.current=!1}})},[n,Ne,Ts,bt,Ls,dr,zn,os,tt]),Ac=y.useCallback(async()=>{Ne&&(await ci.mutateAsync(Ne),Je.invalidateQueries({queryKey:["workspaces"]}))},[Ne,ci,Je]),Mc=y.useCallback(J=>{const ue=J.target.files;ue&&ue.length>0&&kt(Array.from(ue)),J.target.value=""},[kt]),Dc=y.useCallback(J=>{const ue=J.clipboardData.items,Ge=[];for(const Et of ue)if(Et.kind==="file"){const _t=Et.getAsFile();_t&&Ge.push(_t)}Ge.length>0&&(J.preventDefault(),kt(Ge))},[kt]),[Un,ui]=y.useState(!1),Lc=y.useCallback(J=>{J.preventDefault(),ui(!0)},[]),Pc=y.useCallback(J=>{J.preventDefault(),ui(!1)},[]),Oc=y.useCallback(J=>{J.preventDefault(),ui(!1);const ue=J.dataTransfer.files;ue.length>0&&kt(Array.from(ue))},[kt]),hi=y.useCallback(J=>{const ue=J.clientX-q.current,Ge=Math.max(ea,Math.min(se.current+ue,ta));Q.current&&(Q.current.style.width=`${Ge}px`)},[]),fi=y.useCallback(()=>{if(V(!1),Q.current){const J=Q.current.getBoundingClientRect().width;K(Math.max(ea,Math.min(Math.round(J),ta)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);y.useEffect(()=>{if(z)return document.addEventListener("mousemove",hi),document.addEventListener("mouseup",fi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",hi),document.removeEventListener("mouseup",fi),document.body.style.cursor="",document.body.style.userSelect=""}},[z,hi,fi]);const Ic=y.useCallback(J=>{J.preventDefault(),q.current=J.clientX,se.current=U,V(!0)},[U]),Bc=y.useCallback(()=>{R(J=>!J)},[]),Fc=y.useCallback(J=>{i(J.target.value);const ue=J.target;ue.style.height="auto";const Ge=ue.scrollHeight;ue.style.height=`${Math.max(60,Math.min(Ge,300))}px`},[]);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?g("源码已删除"):g("已删除")}),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("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(X0,{status:e.status,onChangeStatus:!ie&&o?J=>o(e.id,J):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:lr,disabled:!He||ie,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:g("Open in IDE"),children:t.jsx(Qs,{size:16})}),t.jsx("button",{onClick:Bc,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:g("Toggle Workspace"),children:W?t.jsx(lu,{size:16}):t.jsx(kr,{size:16})}),(s||$e)&&!ie&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsx("button",{onClick:()=>E(J=>!J),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:g("More actions"),children:t.jsx(Ia,{size:16})}),C&&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:[$e&&t.jsxs("button",{onClick:()=>{v(!0),E(!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(Ut,{size:15}),t.jsx("span",{children:g("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),E(!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(xd,{size:15}),t.jsx("span",{children:g("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{S(!0),E(!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:g("删除任务")})]})]})]})]})]})]})]}),Ae&&Le&&Ze&&t.jsx(S0,{workspaceId:Le,gitStatus:Ze,onResolve:()=>Ds()}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{ref:Q,className:`flex flex-col bg-background relative ${W?"flex-shrink-0":"flex-1"}`,style:{width:W?U:"100%"},children:ge&&fe?N?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:g("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ic,{session:Y,providers:Re,usage:Hn,providerIdFallback:we?.providerId,agentTypeFallback:Y?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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:ai,children:[t.jsx(qs,{size:13}),t.jsx("span",{children:g("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:B,className:`w-full ${W?"":"max-w-5xl mx-auto"}`,children:_e?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:g("Loading logs...")})]}):Ie.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:g(te?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Sr,{logs:Ie})})}),!$&&t.jsxs("button",{onClick:()=>X(),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":g("Scroll to bottom"),children:[t.jsx(Ks,{size:14}),t.jsx("span",{children:g("回到底部")})]})]}),Ct.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:`${W?"":"max-w-5xl mx-auto"}`,children:t.jsx(wr,{todos:Ct})})})]}):t.jsx(ml,{teamRun:fe,messages:de??fe.messages??[],readOnly:ie,readOnlyMessage:Be,onSendMessage:li,onViewInvocationSession:cr,centered:!W}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:B,className:`w-full min-w-0 ${W?"":"max-w-5xl mx-auto"}`,children:[(re||De?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:re?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:g("Loading...")}):De?.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(rn,{urlTransform:U0,components:nn,children:De.body})}):null}),Ce&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[Ce.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",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",{children:g("Setup ({current}/{total}): {command}",{current:Ce.currentIndex,total:Ce.totalCommands,command:Ce.currentCommand})})]}),Ce.status==="completed"&&t.jsx("span",{className:"text-success",children:g("Setup 完成")}),Ce.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:g("Setup 失败: {error}",{error:Ce.error})})]}),!ie&&m&&(be||ke)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ra,{state:m,onRetry:m.status==="failed"?Ms:void 0})}):null,be?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:g("Loading...")})]}):ke?_e?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:g("Loading logs...")})]}):Ie.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:g(te?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Sr,{logs:Ie}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",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(qt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:g(ie?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ie?Be:g("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ie&&m?t.jsx(ra,{state:m}):null,!ie&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:Ms,disabled:!!(m&&m.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),m?.status==="failed"?g("重试启动 Agent"):g("启动 Agent")]}),$e&&t.jsxs(Me,{variant:"outline",onClick:()=>v(!0),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),g("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>X(),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":g("Scroll to bottom"),children:[t.jsx(Ks,{size:14}),t.jsx("span",{children:g("回到底部")})]})]}),Ct.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:`${W?"":"max-w-5xl mx-auto"}`,children:t.jsx(wr,{todos:Ct})})}),ie?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:`${W?"":"max-w-5xl 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:Be})})}):Xe?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:`${W?"":"max-w-5xl 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:g("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:Ms,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),g("启动新 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:Lc,onDragLeave:Pc,onDrop:Oc,children:[t.jsx("div",{className:`${W?"":"max-w-5xl mx-auto"}`,children:t.jsxs("div",{ref:F,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Un?"border-info bg-info/5":"border-border"}`,children:[t.jsx(Zr,{files:Fe,onRemove:Vt}),t.jsx("textarea",{ref:T,value:n,onChange:Fc,onPaste:Dc,onKeyDown:J=>{Pe.handleKeyDown(J)||nt.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),$n())},rows:1,placeholder:g(Un?"Drop files here...":ke&&!te?"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:O,type:"file",multiple:!0,className:"hidden",onChange:Mc}),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:()=>O.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:g("Upload file"),children:t.jsx(zr,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Se&&Re&&t.jsx(oc,{providers:Re,currentProviderId:tt,agentType:Se.agentType,onSelect:me}),t.jsx(jn,{usage:Hn}),te&&!n.trim()&&!Ls?t.jsx("button",{onClick:Ac,disabled:ci.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(ws,{size:14})}):t.jsx("button",{onClick:$n,disabled:!n.trim()&&!Ls||dr,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Ls)&&!dr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Wr,{size:18})})]})]})]})}),t.jsx(Or,{open:nt.query!==null,anchorRef:F,commands:nt.filteredCommands,selectedIndex:nt.selectedIndex,query:nt.query??"",hasCatalog:nt.allCommands.length>0,onSelect:nt.applyCommand}),t.jsx(Or,{open:Pe.query!==null,anchorRef:F,commands:Pe.filteredSkills,selectedIndex:Pe.selectedIndex,query:Pe.query??"",hasCatalog:Pe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Pe.applySkill})]})]})}),W&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/50 transition-colors z-30 flex-shrink-0 border-l border-border",onMouseDown:Ic}),W&&t.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:t.jsx(Jl,{sessionId:ke||void 0,workspaceId:ye,workingDir:He,projectId:e.projectId,readOnly:ie,repoDeleted:he,teamRun:fe,teamStatus:fe?t.jsx(_l,{teamRun:fe,workspaces:ee,selectedWorkspaceId:ye,onSelectWorkspace:M,onViewInvocationSession:cr}):void 0,workspaces:ee,selectedWorkspaceId:ye,onSelectWorkspace:M,tabRef:j,gitProps:Ae&&Le?{branchName:pt,targetBranch:vt,commitMessage:gt,canRunGitOperations:!0,onRefreshCommitMessage:or,onConflict:Ds,onResolveConflicts:()=>Ds()}:void 0})})]}),!ie&&t.jsx(sc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:De?.title??e.title,taskDescription:De?.body??"",taskPrompt:De?.prompt,onStarted:()=>p?.(e.id)}),$e&&!ie&&t.jsx(_0,{isOpen:c,onClose:()=>v(!1),taskId:e.id}),Ae&&Bt&&Ye&&t.jsx(cc,{open:h,onOpenChange:J=>{_(J),J||k(null)},workspaceId:Bt,conflictOp:Ye.conflictOp,conflictedFiles:Ye.conflictedFiles,sourceBranch:Rt,targetBranch:is,operation:Ze?.operation,worktreePath:xt,mergeAborted:Ye.mergeAborted,mergeStrategy:Ye.mergeStrategy,sourceWorkspaceId:Ye.sourceWorkspaceId,targetWorkspaceId:Ye.targetWorkspaceId,sourceWorktreePath:Ye.sourceWorktreePath,targetWorktreePath:Ye.targetWorktreePath,sessions:st,currentSessionId:ge?void 0:ke,teamRunId:fe?.id}),t.jsx(Fr,{isOpen:x,onClose:()=>a(!1),onConfirm:ni,title:g("重新开始任务"),description:t.jsx("p",{children:g("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:g("确认重试"),variant:"default",isLoading:f}),t.jsx(kn,{isOpen:b,onClose:()=>S(!1),onConfirm:oi,taskId:e.id,taskTitle:e.title,workspaces:ee,isLoading:r})]}):t.jsx(K0,{})}function Fn(e){switch(e){case zt.TODO:return ve.Pending;case zt.IN_PROGRESS:return ve.Running;case zt.IN_REVIEW:return ve.Review;case zt.DONE:return ve.Done;case zt.CANCELLED:return ve.Cancelled}}function Y0(e){switch(e){case ve.Pending:return zt.TODO;case ve.Running:return zt.IN_PROGRESS;case ve.Review:return zt.IN_REVIEW;case ve.Done:return zt.DONE;case ve.Cancelled:return zt.CANCELLED}}function G0(e){switch(e){case Ht.CLAUDE_CODE:return"Claude Code";case Ht.GEMINI_CLI:return"Gemini CLI";case Ht.CURSOR_AGENT:return"Cursor Agent";case Ht.CODEX:return"Codex"}}const Ir=["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 mc(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 pc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function gc(e){return e?e.workspaceKind===lt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function Q0(e){return{id:e.id,name:e.name,color:e.color||Ir[mc(e.name,Ir.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Z0(e){const s=pc(e);if(!s)return{agent:"—",branch:"—"};const r=gc(s),o=s.sessions;if(o&&o.length>0){const m=o[o.length-1];return{agent:G0(m.agentType),branch:r}}return{agent:"—",branch:r}}function J0(e){const{agent:s,branch:r}=Z0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Fn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function ex(e,s,r){const o=pc(e.workspaces,r),m=gc(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Ir[mc(s.name,Ir.length)],title:e.titlePreview??e.title,status:Fn(e.status),branch:m,mainBranch:o?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const ia={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 tx(e){const s=e.split("/");return s[s.length-1]||e}function sx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function rx({workingDir:e,filePath:s,type:r}){const{t:o}=le(),{data:m,isLoading:p,isError:g}=Kl(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(g)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
81
|
-
`);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:i.map((l,u)=>{let c="",v="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",v="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",v="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",v="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,v),children:l},u)})})}function ix({entry:e,type:s,workingDir:r}){const[o,m]=y.useState(!1),p=ia[e.status]||ia.M,g=sx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:Z("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:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),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:tx(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:g})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(ht,{size:14}):t.jsx(Ot,{size:14})})]}),o&&t.jsx(rx,{workingDir:r,filePath:e.path,type:s})]})}function na({title:e,entries:s,type:r,workingDir:o,defaultOpen:m}){const{t:p}=le(),[g,n]=y.useState(m);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),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:g?t.jsx(ht,{size:14}):t.jsx(Ot,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),g&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(ix,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function nx({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:m}=Ln(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(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(m)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const p=r?.uncommitted||[],g=r?.committed||[];return p.length+g.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Zs,{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(na,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(na,{title:"Committed",entries:g,type:"committed",workingDir:e,defaultOpen:!1})]})}const Li=50,oa={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 ox(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?mt("{count}s ago",{count:r}):r<3600?mt("{count}m ago",{count:Math.floor(r/60)}):r<86400?mt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?mt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function ax(e){const s=e.split("/");return s[s.length-1]||e}function lx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function cx({workingDir:e,hash:s,filePath:r}){const{t:o}=le(),{data:m,isLoading:p,isError:g}=On(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(g)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
82
|
-
`);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:i.map((l,u)=>{let c="",v="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",v="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",v="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",v="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,v),children:l},u)})})}function dx({entry:e,workingDir:s,hash:r}){const[o,m]=y.useState(!1),p=oa[e.status]||oa.M,g=lx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:Z("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:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),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:ax(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:g})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(ht,{size:14}):t.jsx(Ot,{size:14})})]}),o&&t.jsx(cx,{workingDir:s,hash:r,filePath:e.path})]})}function ux({commit:e,workingDir:s}){const{t:r}=le(),[o,m]=y.useState(!1),{data:p,isLoading:g}=Pn(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(i=>!i),className:Z("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:Z("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:ox(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(ht,{size:14}):t.jsx(Ot,{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}),g?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.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:n.map(i=>t.jsx(dx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function hx({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:n}=ln({queryKey:ae.git.log(e||""),queryFn:({pageParam:l=0})=>xe.get("/git/log",{params:{workingDir:e||"",limit:String(Li),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Li?void 0:u.length*Li,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(ks,{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:i.map(l=>t.jsx(ux,{commit:l,workingDir:e},l.hash))}),g&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{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 fx="/api",mx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${fx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function px({status:e}){const s={[ve.Running]:"bg-blue-500",[ve.Review]:"bg-amber-500",[ve.Pending]:"bg-neutral-400",[ve.Done]:"bg-emerald-500",[ve.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const gx=[{key:"chat",label:"Chat",icon:an},{key:"changes",label:"Changes",icon:Zs},{key:"history",label:"History",icon:ks},{key:"workspace",label:"Workspace",icon:$r}],vx=[{key:"chat",label:"Team room",icon:an},{key:"team-status",label:"Team Status",icon:cs},{key:"changes",label:"Changes",icon:Zs},{key:"workspace",label:"Workspace",icon:$r}];function aa({state:e,onRetry:s}){const{t:r}=le(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",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",{children:o})]})}function xx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:m,onAutoStartRecovered:p}){const{t:g}=le(),n=tn(ne=>ne.setVisibleContext),[i,l]=y.useState("chat"),[u,c]=y.useState(""),[v,b]=y.useState(!1),[S,x]=y.useState(!1),[a,f]=y.useState(!1),[d,h]=y.useState(null),[_,w]=y.useState(void 0),k=y.useRef(null),j=y.useRef(null),C=y.useRef(null),E=y.useRef(null),{scrollRef:N,contentRef:D,isAtBottom:A,scrollToBottom:M}=En({resize:"smooth",initial:"instant"}),I=at();y.useEffect(()=>{if(!a)return;const ne=_e=>{j.current&&!j.current.contains(_e.target)&&f(!1)};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[a]);const{data:L,isLoading:F}=Sn(e.id),{data:H}=wa(e.id),{data:T}=Ca(H?.id??""),O=sn(H?.id??""),P=H??null,B=P?vx:gx,$=H===null,{data:X,isLoading:U}=ka(e.id,$);y.useEffect(()=>{w(void 0),h(null)},[e.id]),y.useEffect(()=>{P&&i==="history"&&l("chat"),!P&&i==="team-status"&&l("chat")},[i,P]);const K=y.useMemo(()=>pl(L,P,_),[_,P,L]);y.useEffect(()=>{_&&!L?.some(ne=>ne.id===_)&&w(void 0)},[_,L]);const W=y.useMemo(()=>L?.find(ne=>ne.id===K),[K,L]),R=y.useMemo(()=>{if(L){if(W)return Jt(W);for(const ne of L)if(ne.status==="ACTIVE"&&Jt(ne))return Jt(ne);return Jt(L[0])}},[W,L]),z=W?.status===Mt.ACTIVE?W.id:void 0,V=gl(W,P),q=W?.branchName??"",se=W?.commitMessage,Q=y.useMemo(()=>vl(W,L,e?.mainBranch??""),[W,e?.mainBranch,L]),{data:ee}=Cn(z??"",{enabled:i==="changes"}),{data:be}=Ln(R,{enabled:i==="changes"}),Ce=be?.committed?.length,[Oe,de]=y.useState(!1),[Ke,fe]=y.useState(null);y.useEffect(()=>{const ne=i==="changes"?"changes":i==="history"?"history":null;if(!z||!R||!ne){n(null);return}return n({workspaceId:z,workingDir:R,tab:ne}),()=>{n(null)}},[i,z,n,R]);const ge=y.useMemo(()=>ee?.conflictOp&&ee.conflictedFiles.length>0?{conflictOp:ee.conflictOp,conflictedFiles:ee.conflictedFiles}:Ke,[ee?.conflictOp,ee?.conflictedFiles,Ke]),$e=ge?.targetWorkspaceId??z,et=ge?.targetWorktreePath??W?.worktreePath,De=ge?.sourceBranch??q,re=ge?.targetBranch??Q,ye=W?.sessions??[],je=y.useCallback(ne=>{fe(ne??null),de(!0)},[]),Le=y.useCallback(()=>e?.id?I.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,I]),Ae=y.useCallback(async()=>I.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}),[I,e.id]),Se=y.useMemo(()=>{if(!L)return null;const ne=L.filter(Fe=>Fe.status==="ACTIVE"&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]),_e=Fe=>{const kt=Fe.createdAt,Vt=Fe.endedAt??Fe.startedAt??kt;if(!Vt)return 0;const os=Date.parse(Vt);return Number.isNaN(os)?0:os},Ie=Fe=>{const kt=ne.filter(Vt=>Fe.includes(Vt.status));return kt.length===0?null:kt.sort((Vt,os)=>_e(os)-_e(Vt))[0]??null},Ue=Ie([it.RUNNING])??Ie([it.PENDING])??Ie([it.COMPLETED,it.FAILED,it.CANCELLED]);if(Ue)return Ue;const Ct=L.filter(Fe=>(Fe.status==="ABANDONED"||Fe.status==="MERGED"||Fe.status==="HIBERNATED")&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]).filter(Fe=>[it.COMPLETED,it.FAILED,it.CANCELLED].includes(Fe.status));return Ct.length===0?null:Ct.sort((Fe,kt)=>_e(kt)-_e(Fe))[0]??null},[L]),ke=Se?.id??"",Ne=P?d??"":ke,G=y.useMemo(()=>{if(!d||!L)return null;for(const ne of L){const _e=ne.sessions?.find(Ie=>Ie.id===d);if(_e)return _e}return null},[d,L]),oe=y.useMemo(()=>{if(!d||!P?.invocations)return null;const ne=P.invocations.filter(_e=>_e.sessionId===d);return ne.length===0?null:ne.sort((_e,Ie)=>{const Ue=Date.parse(_e.updatedAt??_e.createdAt??""),bt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(bt)?0:bt)-(Number.isNaN(Ue)?0:Ue)})[0]??null},[d,P?.invocations]),we=y.useMemo(()=>!oe?.memberId||!P?.members?null:P.members.find(ne=>ne.id===oe.memberId)??null,[oe?.memberId,P?.members]),Y=d?G:Se??null,te=Y?.status===it.RUNNING||Y?.status===it.PENDING,ie=!!e.projectArchivedAt,he=!!e.projectRepoDeletedAt,Be=g(he?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),Re=y.useMemo(()=>!Se||!L?!1:!L.some(_e=>_e.status==="ACTIVE"&&_e.sessions?.some(Ie=>Ie.id===Se.id)),[Se,L]),{data:tt}=js(),[me,Xe]=y.useState(null),He=me?.sessionId===ke?me.providerId:Se?.providerId??null,nt=y.useCallback(ne=>{Xe({sessionId:ke,providerId:ne})},[ke]),Pe=hc({agentType:Se?.agentType,workingDir:R,input:u,setInput:c,textareaRef:C,minHeight:40,maxHeight:140}),Te=fc({agentType:Se?.agentType,workingDir:R,input:u,setInput:c,textareaRef:C,minHeight:40,maxHeight:140}),Ve=R&&W?W.id:void 0,Ze=Bn(),st=wn(),pt=ec(),{isConnected:gt,isLoadingSnapshot:vt,logs:Ye,entries:Bt,attach:xt}=Ma({sessionId:Ne,sessionStatus:Y?.status,onExit:y.useCallback(()=>{I.invalidateQueries({queryKey:["workspaces"]})},[I])}),{todos:Rt}=Da(Bt),{files:is,addFiles:Je,removeFile:hs,clear:or,buildMarkdownLinks:Ts,hasFiles:Xt,isUploading:ns}=Qr(),ar=y.useMemo(()=>rc(Y),[Y?.tokenUsage]),As=tc(Ye,ar);y.useEffect(()=>{Ne&>&&xt()},[Ne,gt,xt]);const fs=y.useRef(null);y.useEffect(()=>{if(fs.current!==e.id&&N.current){const ne=N.current;requestAnimationFrame(()=>{ne.scrollTop=ne.scrollHeight})}fs.current=e.id},[e.id,N]);const $t=y.useRef(!1),ms=y.useCallback(async()=>{if(!u.trim()&&!Xt||!ke||$t.current||ns)return;$t.current=!0;const ne=Ts(),_e=[u.trim(),ne].filter(Boolean).join(`
|
|
83
|
-
|
|
84
|
-
`);c(""),or(),C.current&&(C.current.style.height="40px"),Ze.mutate({id:ke,message:_e,providerId:He??void 0},{onSuccess:()=>xt(),onSettled:()=>{$t.current=!1}})},[u,ke,Ze,xt,Xt,ns,Ts,or,He]),ni=y.useCallback(async()=>{ke&&(await pt.mutateAsync(ke),I.invalidateQueries({queryKey:["workspaces"]}))},[ke,pt,I]),Ms=y.useCallback(ne=>O.mutateAsync(ne),[O]),lr=y.useCallback(ne=>{h(ne),l("chat"),requestAnimationFrame(()=>{M()})},[M]),oi=y.useCallback(()=>{h(null)},[]),cr=y.useCallback(ne=>{const _e=ne.target.files;_e&&_e.length>0&&Je(Array.from(_e)),ne.target.value=""},[Je]),ai=y.useCallback(ne=>{const _e=ne.clipboardData.items,Ie=[];for(const Ue of _e)if(Ue.kind==="file"){const bt=Ue.getAsFile();bt&&Ie.push(bt)}Ie.length>0&&(ne.preventDefault(),Je(Ie))},[Je]),Ds=y.useCallback(ne=>{c(ne.target.value);const _e=ne.target;_e.style.height="auto",_e.style.height=`${Math.max(40,Math.min(_e.scrollHeight,140))}px`},[]),li=y.useCallback(()=>{Ve&&st.mutate({workspaceId:Ve})},[st,Ve]),Tt=y.useRef(null);return y.useEffect(()=>{const ne=window.visualViewport;if(!ne)return;let _e=!1;const Ie=()=>{Tt.current&&(Tt.current.style.height=`${ne.height}px`,Tt.current.style.top=`${ne.offsetTop}px`)},Ue=()=>Ie(),bt=()=>{_e||Ie()},Ct=()=>{_e=!0},Fe=()=>{_e=!1,requestAnimationFrame(Ie)};return ne.addEventListener("resize",Ue),ne.addEventListener("scroll",bt),document.addEventListener("touchstart",Ct,{passive:!0}),document.addEventListener("touchend",Fe,{passive:!0}),document.addEventListener("touchcancel",Fe,{passive:!0}),()=>{ne.removeEventListener("resize",Ue),ne.removeEventListener("scroll",bt),document.removeEventListener("touchstart",Ct),document.removeEventListener("touchend",Fe),document.removeEventListener("touchcancel",Fe)}},[]),y.useEffect(()=>{const ne=Tt.current;if(!ne)return;const _e=Ie=>{let Ue=Ie.target;for(;Ue&&Ue!==ne;){if(Ue.tagName==="TEXTAREA"){if(Ue.scrollHeight>Ue.clientHeight)return;Ue=Ue.parentElement;continue}const Ct=window.getComputedStyle(Ue).overflowY;if((Ct==="auto"||Ct==="scroll")&&Ue.scrollHeight>Ue.clientHeight)return;Ue=Ue.parentElement}Ie.preventDefault()};return ne.addEventListener("touchmove",_e,{passive:!1}),()=>ne.removeEventListener("touchmove",_e)},[]),t.jsxs("div",{ref:Tt,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(qs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),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?g("源码已删除"):g("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(px,{status:e.status}),t.jsx("button",{onClick:li,disabled:!Ve||ie,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Qs,{size:16})}),r&&!ie&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>f(ne=>!ne),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Ia,{size:16})}),a&&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:()=>{x(!0),f(!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:g("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:B.map(({key:ne,label:_e,icon:Ie})=>t.jsxs("button",{onClick:()=>l(ne),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===ne?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ie,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:g(_e)})]},ne))})]}),i==="chat"&&(P?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?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:g("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(ic,{session:Y,providers:tt,usage:As,compact:!0,providerIdFallback:we?.providerId,agentTypeFallback:Y?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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:oi,children:[t.jsx(qs,{size:12}),t.jsx("span",{children:g("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:N,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:D,children:vt?t.jsx(Pi,{label:g("Loading logs...")}):Ye.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:g(te?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Sr,{logs:Ye})})}),!A&&t.jsxs("button",{onClick:()=>M(),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":g("Scroll to bottom"),children:[t.jsx(Ks,{size:12}),t.jsx("span",{children:g("回到底部")})]})]}),Rt.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(wr,{todos:Rt,compact:!0})})]}):t.jsx(ml,{teamRun:P,messages:T??P.messages??[],readOnly:ie,readOnlyMessage:Be,onSendMessage:Ms,onViewInvocationSession:lr,compactComposer:!0})}):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:N,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:D,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:U?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:g("Loading...")}):X?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(rn,{urlTransform:mx,components:nn,children:X.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!ie&&m&&(F||ke)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(aa,{state:m,onRetry:m.status==="failed"?async()=>{await Ae(),b(!0)}:void 0})}):null,F?t.jsx(Pi,{label:"Loading..."}):ke?vt?t.jsx(Pi,{label:"Loading logs..."}):Ye.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:te?"Waiting for agent output...":"No logs recorded."}):t.jsx(Sr,{logs:Ye}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",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(qt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:g("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:ie?Be:g("选择一个 Agent 来执行此任务")}),!ie&&m?t.jsx(aa,{state:m}):null,!ie&&t.jsxs(Me,{onClick:async()=>{await Ae(),b(!0)},disabled:!!(m&&m.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),m?.status==="failed"?g("重试启动 Agent"):g("启动 Agent")]})]})]})}),!A&&t.jsxs("button",{onClick:()=>M(),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(Ks,{size:12}),t.jsx("span",{children:g("回到底部")})]})]}),Rt.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(wr,{todos:Rt,compact:!0})}),ie?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:Be})}):Re?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:g("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:async()=>{await Ae(),b(!0)},children:[t.jsx(qt,{size:14,className:"mr-1.5"}),g("启动新 Agent")]})]})}):ke&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[t.jsxs("div",{ref:k,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(Zr,{files:is,onRemove:hs}),t.jsx("textarea",{ref:C,value:u,onChange:Ds,onPaste:ai,onKeyDown:ne=>{Te.handleKeyDown(ne)||Pe.handleKeyDown(ne)||ne.key==="Enter"&&!ne.shiftKey&&!ne.repeat&&!ne.nativeEvent.isComposing&&ne.nativeEvent.keyCode!==229&&(ne.preventDefault(),ms())},rows:1,placeholder:te?"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:E,type:"file",multiple:!0,className:"hidden",onChange:cr}),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:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(zr,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Se&&tt&&t.jsx(oc,{providers:tt,currentProviderId:He,agentType:Se.agentType,onSelect:nt}),t.jsx(jn,{usage:As}),te&&!u.trim()&&!Xt?t.jsx("button",{onClick:ni,disabled:pt.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(ws,{size:12})}):t.jsx("button",{onClick:ms,disabled:!u.trim()&&!Xt||ns,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Xt)&&!ns?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Wr,{size:15})})]})]})]}),t.jsx(Or,{open:Pe.query!==null,anchorRef:k,commands:Pe.filteredCommands,selectedIndex:Pe.selectedIndex,query:Pe.query??"",hasCatalog:Pe.allCommands.length>0,compact:!0,onSelect:Pe.applyCommand}),t.jsx(Or,{open:Te.query!==null,anchorRef:k,commands:Te.filteredSkills,selectedIndex:Te.selectedIndex,query:Te.query??"",hasCatalog:Te.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Te.applySkill})]})]})),i==="team-status"&&P&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(_l,{teamRun:P,workspaces:L,selectedWorkspaceId:K,onSelectWorkspace:w,onViewInvocationSession:lr})}),i==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[L&&L.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Zl,{workspaces:L,teamRun:P,selectedWorkspaceId:K,onSelectWorkspace:w,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),V&&z&&t.jsx("div",{className:"shrink-0",children:t.jsx(Xl,{workspaceId:z,branchName:q,targetBranch:Q,commitMessage:se,committedFileCount:Ce,onRefreshCommitMessage:Le,onConflict:je,onResolveConflicts:()=>je()})}),t.jsx(nx,{workingDir:R})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(hx,{workingDir:R})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Jl,{sessionId:ke||void 0,workspaceId:K,workingDir:R,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:ie,repoDeleted:he})}),!ie&&t.jsx(sc,{isOpen:v,onClose:()=>b(!1),taskId:e.id,taskTitle:X?.title??e.title,taskDescription:X?.body??"",taskPrompt:X?.prompt,onStarted:()=>p?.(e.id)}),t.jsx(kn,{isOpen:S,onClose:()=>x(!1),onConfirm:()=>{r?.(e.id),x(!1)},taskId:e.id,taskTitle:e.title,workspaces:L,isLoading:o}),Oe&&ge&&$e&&t.jsx(cc,{open:Oe,onOpenChange:ne=>{de(ne),ne||fe(null)},workspaceId:$e,conflictOp:ge.conflictOp,conflictedFiles:ge.conflictedFiles,sourceBranch:De,targetBranch:re,operation:ee?.operation,worktreePath:et,mergeAborted:ge.mergeAborted,mergeStrategy:ge.mergeStrategy,sourceWorkspaceId:ge.sourceWorkspaceId,targetWorkspaceId:ge.targetWorkspaceId,sourceWorktreePath:ge.sourceWorktreePath,targetWorktreePath:ge.targetWorktreePath,sessions:ye,currentSessionId:P?void 0:ke,teamRunId:P?.id})]})}function Pi({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 bx=Object.defineProperty,Br=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,la=(e,s,r)=>s in e?bx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Zi=(e,s)=>{for(var r in s||(s={}))vc.call(s,r)&&la(e,r,s[r]);if(Br)for(var r of Br(s))xc.call(s,r)&&la(e,r,s[r]);return e},Ji=(e,s)=>{var r={};for(var o in e)vc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Br)for(var o of Br(e))s.indexOf(o)<0&&xc.call(e,o)&&(r[o]=e[o]);return r};var us;(e=>{const s=class Ee{constructor(i,l,u,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Ee.MIN_VERSION||i>Ee.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=i*4+17;let v=[];for(let S=0;S<this.size;S++)v.push(!1);for(let S=0;S<this.size;S++)this.modules.push(v.slice()),this.isFunction.push(v.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(u);if(this.drawCodewords(b),c==-1){let S=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<S&&(c=x,S=a),this.applyMask(x)}}m(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const u=e.QrSegment.makeSegments(i);return Ee.encodeSegments(u,l)}static encodeBinary(i,l){const u=e.QrSegment.makeBytes(i);return Ee.encodeSegments([u],l)}static encodeSegments(i,l,u=1,c=40,v=-1,b=!0){if(!(Ee.MIN_VERSION<=u&&u<=c&&c<=Ee.MAX_VERSION)||v<-1||v>7)throw new RangeError("Invalid value");let S,x;for(S=u;;S++){const h=Ee.getNumDataCodewords(S,l)*8,_=g.getTotalBits(i,S);if(_<=h){x=_;break}if(S>=c)throw new RangeError("Data too long")}for(const h of[Ee.Ecc.MEDIUM,Ee.Ecc.QUARTILE,Ee.Ecc.HIGH])b&&x<=Ee.getNumDataCodewords(S,h)*8&&(l=h);let a=[];for(const h of i){r(h.mode.modeBits,4,a),r(h.numChars,h.mode.numCharCountBits(S),a);for(const _ of h.getData())a.push(_)}m(a.length==x);const f=Ee.getNumDataCodewords(S,l)*8;m(a.length<=f),r(0,Math.min(4,f-a.length),a),r(0,(8-a.length%8)%8,a),m(a.length%8==0);for(let h=236;a.length<f;h^=253)r(h,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((h,_)=>d[_>>>3]|=h<<7-(_&7)),new Ee(S,l,d,v)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let u=l;for(let v=0;v<10;v++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;m(c>>>15==0);for(let v=0;v<=5;v++)this.setFunctionModule(8,v,o(c,v));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let v=9;v<15;v++)this.setFunctionModule(14-v,8,o(c,v));for(let v=0;v<8;v++)this.setFunctionModule(this.size-1-v,8,o(c,v));for(let v=8;v<15;v++)this.setFunctionModule(8,this.size-15+v,o(c,v));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;m(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),v=this.size-11+u%3,b=Math.floor(u/3);this.setFunctionModule(v,b,c),this.setFunctionModule(b,v,c)}}drawFinderPattern(i,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const v=Math.max(Math.abs(c),Math.abs(u)),b=i+c,S=l+u;0<=b&&b<this.size&&0<=S&&S<this.size&&this.setFunctionModule(b,S,v!=2&&v!=4)}}drawAlignmentPattern(i,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,l,u){this.modules[l][i]=u,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,u=this.errorCorrectionLevel;if(i.length!=Ee.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Ee.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],v=Ee.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],b=Math.floor(Ee.getNumRawDataModules(l)/8),S=c-b%c,x=Math.floor(b/c);let a=[];const f=Ee.reedSolomonComputeDivisor(v);for(let h=0,_=0;h<c;h++){let w=i.slice(_,_+x-v+(h<S?0:1));_+=w.length;const k=Ee.reedSolomonComputeRemainder(w,f);h<S&&w.push(0),a.push(w.concat(k))}let d=[];for(let h=0;h<a[0].length;h++)a.forEach((_,w)=>{(h!=x-v||w>=S)&&d.push(_[h])});return m(d.length==b),d}drawCodewords(i){if(i.length!=Math.floor(Ee.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let v=0;v<2;v++){const b=u-v,x=(u+1&2)==0?this.size-1-c:c;!this.isFunction[x][b]&&l<i.length*8&&(this.modules[x][b]=o(i[l>>>3],7-(l&7)),l++)}}m(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let i=0;for(let v=0;v<this.size;v++){let b=!1,S=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[v][a]==b?(S++,S==5?i+=Ee.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,x),b||(i+=this.finderPenaltyCountPatterns(x)*Ee.PENALTY_N3),b=this.modules[v][a],S=1);i+=this.finderPenaltyTerminateAndCount(b,S,x)*Ee.PENALTY_N3}for(let v=0;v<this.size;v++){let b=!1,S=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][v]==b?(S++,S==5?i+=Ee.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,x),b||(i+=this.finderPenaltyCountPatterns(x)*Ee.PENALTY_N3),b=this.modules[a][v],S=1);i+=this.finderPenaltyTerminateAndCount(b,S,x)*Ee.PENALTY_N3}for(let v=0;v<this.size-1;v++)for(let b=0;b<this.size-1;b++){const S=this.modules[v][b];S==this.modules[v][b+1]&&S==this.modules[v+1][b]&&S==this.modules[v+1][b+1]&&(i+=Ee.PENALTY_N2)}let l=0;for(const v of this.modules)l=v.reduce((b,S)=>b+(S?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return m(0<=c&&c<=9),i+=c*Ee.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Ee.MIN_VERSION||i>Ee.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;l-=(25*u-10)*u-55,i>=7&&(l-=36)}return m(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Ee.getNumRawDataModules(i)/8)-Ee.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Ee.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<i;c++){for(let v=0;v<l.length;v++)l[v]=Ee.reedSolomonMultiply(l[v],u),v+1<l.length&&(l[v]^=l[v+1]);u=Ee.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(i,l){let u=l.map(c=>0);for(const c of i){const v=c^u.shift();u.push(0),l.forEach((b,S)=>u[S]^=Ee.reedSolomonMultiply(b,v))}return u}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*i;return m(u>>>8==0),u}finderPenaltyCountPatterns(i){const l=i[1];m(l<=this.size*3);const u=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(u&&i[0]>=l*4&&i[6]>=l?1:0)+(u&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,u){return i&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};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(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)l.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function m(n){if(!n)throw new Error("Assertion error")}const p=class rt{constructor(i,l,u){if(this.mode=i,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let l=[];for(const u of i)r(u,8,l);return new rt(rt.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!rt.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,l),u+=c}return new rt(rt.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!rt.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=i.length;u+=2){let c=rt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=rt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,l)}return u<i.length&&r(rt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,l),new rt(rt.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:rt.isNumeric(i)?[rt.makeNumeric(i)]:rt.isAlphanumeric(i)?[rt.makeAlphanumeric(i)]:[rt.makeBytes(rt.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new rt(rt.Mode.ECI,0,l)}static isNumeric(i){return rt.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return rt.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let u=0;for(const c of i){const v=c.mode.numCharCountBits(l);if(c.numChars>=1<<v)return 1/0;u+=4+v+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?l.push(i.charCodeAt(u)):(l.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return l}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let g=p;e.QrSegment=p})(us||(us={}));(e=>{(s=>{const r=class{constructor(m,p){this.ordinal=m,this.formatBits=p}};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={}))})(us||(us={}));(e=>{(s=>{const r=class{constructor(m,p){this.modeBits=m,this.numBitsCharCount=p}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+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={}))})(us||(us={}));var ys=us;var _x={L:ys.QrCode.Ecc.LOW,M:ys.QrCode.Ecc.MEDIUM,Q:ys.QrCode.Ecc.QUARTILE,H:ys.QrCode.Ecc.HIGH},bc=128,_c="L",yc="#FFFFFF",Sc="#000000",wc=!1,Cc=1,yx=4,Sx=0,wx=.1;function kc(e,s=0){const r=[];return e.forEach(function(o,m){let p=null;o.forEach(function(g,n){if(!g&&p!==null){r.push(`M${p+s} ${m+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!g)return;p===null?r.push(`M${n+s},${m+s} h1v1H${n+s}z`):r.push(`M${p+s},${m+s} h${n+1-p}v1H${p+s}z`);return}g&&p===null&&(p=n)})}),r.join("")}function Ec(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((m,p)=>p<s.x||p>=s.x+s.w?m:!1))}function Cx(e,s,r,o){if(o==null)return null;const m=e.length+r*2,p=Math.floor(s*wx),g=m/s,n=(o.width||p)*g,i=(o.height||p)*g,l=o.x==null?e.length/2-n/2:o.x*g,u=o.y==null?e.length/2-i/2:o.y*g,c=o.opacity==null?1:o.opacity;let v=null;if(o.excavate){let S=Math.floor(l),x=Math.floor(u),a=Math.ceil(n+l-S),f=Math.ceil(i+u-x);v={x:S,y:x,w:a,h:f}}const b=o.crossOrigin;return{x:l,y:u,h:i,w:n,excavation:v,opacity:c,crossOrigin:b}}function kx(e,s){return s!=null?Math.max(Math.floor(s),0):e?yx:Sx}function jc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:m,imageSettings:p,size:g,boostLevel:n}){let i=ce.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...ys.QrSegment.makeSegments(a)),x),[]);return ys.QrCode.encodeSegments(S,_x[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:v}=ce.useMemo(()=>{let b=i.getModules();const S=kx(o,m),x=b.length+S*2,a=Cx(b,g,S,p);return{cells:b,margin:S,numCells:x,calculatedImageSettings:a}},[i,g,p,o,m]);return{qrcode:i,margin:u,cells:l,numCells:c,calculatedImageSettings:v}}var Ex=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),jx=ce.forwardRef(function(s,r){const o=s,{value:m,size:p=bc,level:g=_c,bgColor:n=yc,fgColor:i=Sc,includeMargin:l=wc,minVersion:u=Cc,boostLevel:c,marginSize:v,imageSettings:b}=o,x=Ji(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,f=Ji(x,["style"]),d=b?.src,h=ce.useRef(null),_=ce.useRef(null),w=ce.useCallback(I=>{h.current=I,typeof r=="function"?r(I):r&&(r.current=I)},[r]),[k,j]=ce.useState(!1),{margin:C,cells:E,numCells:N,calculatedImageSettings:D}=jc({value:m,level:g,minVersion:u,boostLevel:c,includeMargin:l,marginSize:v,imageSettings:b,size:p});ce.useEffect(()=>{if(h.current!=null){const I=h.current,L=I.getContext("2d");if(!L)return;let F=E;const H=_.current,T=D!=null&&H!==null&&H.complete&&H.naturalHeight!==0&&H.naturalWidth!==0;T&&D.excavation!=null&&(F=Ec(E,D.excavation));const O=window.devicePixelRatio||1;I.height=I.width=p*O;const P=p/N*O;L.scale(P,P),L.fillStyle=n,L.fillRect(0,0,N,N),L.fillStyle=i,Ex?L.fill(new Path2D(kc(F,C))):E.forEach(function(B,$){B.forEach(function(X,U){X&&L.fillRect(U+C,$+C,1,1)})}),D&&(L.globalAlpha=D.opacity),T&&L.drawImage(H,D.x+C,D.y+C,D.w,D.h)}}),ce.useEffect(()=>{j(!1)},[d]);const A=Zi({height:p,width:p},a);let M=null;return d!=null&&(M=ce.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:_,crossOrigin:D?.crossOrigin})),ce.createElement(ce.Fragment,null,ce.createElement("canvas",Zi({style:A,height:p,width:p,ref:w,role:"img"},f)),M)});jx.displayName="QRCodeCanvas";var Nc=ce.forwardRef(function(s,r){const o=s,{value:m,size:p=bc,level:g=_c,bgColor:n=yc,fgColor:i=Sc,includeMargin:l=wc,minVersion:u=Cc,boostLevel:c,title:v,marginSize:b,imageSettings:S}=o,x=Ji(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:f,numCells:d,calculatedImageSettings:h}=jc({value:m,level:g,minVersion:u,boostLevel:c,includeMargin:l,marginSize:b,imageSettings:S,size:p});let _=f,w=null;S!=null&&h!=null&&(h.excavation!=null&&(_=Ec(f,h.excavation)),w=ce.createElement("image",{href:S.src,height:h.h,width:h.w,x:h.x+a,y:h.y+a,preserveAspectRatio:"none",opacity:h.opacity,crossOrigin:h.crossOrigin}));const k=kc(_,a);return ce.createElement("svg",Zi({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!v&&ce.createElement("title",null,v),ce.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ce.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),w)});Nc.displayName="QRCodeSVG";function Rc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Nx(){return Nt({queryKey:ae.tunnel.status,queryFn:()=>xe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Rx(){const e=at();return wt({mutationFn:()=>xe.post("/tunnel/start",{port:Rc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function Tx(){const e=at();return wt({mutationFn:()=>xe.post("/tunnel/regenerate",{port:Rc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function Ax(){const e=at();return wt({mutationFn:()=>xe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function Mx(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 Dx(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 Lx(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 ca(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 m=Math.round(o/60);return m<24?`${m}h ago`:`${Math.round(m/24)}d ago`}function Bs(e){const s=e?.trim();return s||null}function Px(e){if(!e)return"";const s=[Bs(e.lastLocalError),Bs(e.lastRemoteError),Bs(e.lastError)].filter(m=>m!==null),r=Bs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Bs(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
85
|
-
`)}function da(){const{t:e}=le(),{data:s}=Nx(),r=Rx(),o=Ax(),m=Tx(),[p,g]=y.useState(!1),[n,i]=y.useState(null),l=y.useRef(null),[u,c]=y.useState({top:0,right:0}),[v,b]=y.useState(!1),[S,x]=y.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",f=r.isPending||s?.status==="starting",d=m.isPending,h=s?.shareableUrl,_=s?.token,w=Mx(s),k=Dx(s),j=Px(s);y.useEffect(()=>{if(p&&l.current){const I=l.current.getBoundingClientRect();c({top:I.bottom+8,right:window.innerWidth-I.right})}},[p]);const C=y.useCallback(()=>{g(!0)},[a]),E=y.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>g(!0)})},[r]),N=y.useCallback(()=>{h&&(navigator.clipboard.writeText(h),i("url"),setTimeout(()=>i(null),2e3))},[h]),D=y.useCallback(()=>{_&&(navigator.clipboard.writeText(_),i("token"),setTimeout(()=>i(null),2e3))},[_]),A=y.useCallback(()=>{o.mutate(),g(!1),b(!1),x(!1)},[o]),M=y.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{x(!1),g(!0)}})},[m]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:C,disabled:f,className:`p-1.5 rounded-md transition-colors ${w.button}`,title:e(w.label),children:f?t.jsx(ze,{size:16,className:"animate-spin"}):w.icon==="warn"?t.jsx(Hr,{size:16}):t.jsx(so,{size:16})}),a&&!f&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${w.dot} rounded-full`}),p&&!a&&Zt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>g(!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:u.top,right:u.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(so,{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:()=>g(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Wt,{size:14})})]}),t.jsxs("button",{onClick:E,disabled:f,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:[f&&t.jsx(ze,{size:13,className:"animate-spin"}),e(f?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&Zt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>g(!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:u.top,right:u.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 ${w.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Lx(s))})]}),t.jsx("button",{onClick:()=>g(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Wt,{size:14})})]}),_&&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(Fa,{size:12}),t.jsx("span",{children:e("Token protected")})]}),h&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Nc,{value:h,size:160})}),h||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:h??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:I=>I.target.select()}),t.jsx("button",{onClick:N,disabled:!h,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:n==="url"?t.jsx(yt,{size:14,className:"text-emerald-500"}):t.jsx(to,{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:ca(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:ca(s?.lastHealthyAt)})]})]}),j&&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:j}),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.")}),_&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>b(!v),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(v?"Hide token":"Show token")}),v&&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:_}),t.jsx("button",{onClick:D,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:n==="token"?t.jsx(yt,{size:14,className:"text-emerald-500"}):t.jsx(to,{size:14})})]})]}),S&&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:()=>x(!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:M,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")})]})]}),!S&&t.jsxs("button",{onClick:()=>x(!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(Ur,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:A,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 Oi({isOpen:e,onClose:s}){const{t:r}=le(),o=md(),[m,p]=y.useState(""),[g,n]=y.useState(""),[i,l]=y.useState(null),[u,c]=y.useState(!1),[v,b]=y.useState(!1),S=m.trim(),x=g.trim(),a=u||o.isPending,f=y.useMemo(()=>!!(S&&x&&!a),[S,x,a]),d=y.useCallback(()=>{p(""),n(""),l(null),b(!1)},[]),h=y.useCallback(()=>{a||(d(),s())},[a,s,d]);y.useEffect(()=>{e||d()},[e,d]);const _=y.useCallback(async j=>{try{await o.mutateAsync({name:S,repoPath:x,initEmptyRepo:j}),d(),s()}catch(C){const E=C instanceof Error?C.message:r("Failed to create project");l(E),ut.error(E)}},[o,s,d,r,S,x]),w=y.useCallback(async()=>{if(!(!S||!x||a)){l(null),c(!0);try{const j=await xe.get("/filesystem/validate",{params:{path:x}});if(j.valid){await _(!1);return}if(j.reason==="no_git"&&j.isEmpty){b(!0);return}if(j.reason==="no_git"){l(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}l(j.error??r("Selected path is not a valid directory"))}catch(j){l(j instanceof Error?j.message:r("Could not check repository path"))}finally{c(!1)}}},[_,a,r,S,x]),k=y.useCallback(()=>{b(!1),_(!0)},[_]);return t.jsxs(t.Fragment,{children:[t.jsx(Es,{isOpen:e,onClose:h,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:h,disabled:a,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:w,disabled:!f,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${f?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?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:m,onChange:j=>p(j.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,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("Repository Path")}),t.jsx(pd,{value:g,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(Fr,{isOpen:v,onClose:()=>{o.isPending||b(!1)},onConfirm:k,title:r("Initialize Git repository?"),description: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."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:o.isPending})]})}const Ox="/assets/agent-tower-logo-COx9gy77.png";function ua({className:e="h-7 w-7"}){return t.jsx("img",{src:Ox,alt:"Agent Tower",className:`block shrink-0 object-contain ${e}`})}const Ix={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function ha({projects:e,providers:s,isProvidersLoading:r,onSubmit:o,defaultProjectId:m="",defaultProviderId:p="",onProjectChange:g,createStep:n}){const{t:i}=le(),[l,u]=y.useState(""),[c,v]=y.useState(m),[b,S]=y.useState(p),[x,a]=y.useState("SOLO"),[f,d]=y.useState(lt.WORKTREE),[h,_]=y.useState("AUTO"),[w,k]=y.useState(null),[j,C]=y.useState([]),[E,N]=y.useState(!1),[D,A]=y.useState(!1),[M,I]=y.useState(!1),[L,F]=y.useState(!1),H=y.useRef(null),T=y.useRef(null),O=y.useRef(null),P=y.useRef(null),B=y.useRef(null),{files:$,addFiles:X,removeFile:U,clear:K,buildMarkdownLinks:W,isUploading:R}=Qr();y.useEffect(()=>{v(m),g?.(m)},[m,g]),y.useEffect(()=>{S(p)},[p]),y.useEffect(()=>{if(!D)return;const re=ye=>{H.current&&!H.current.contains(ye.target)&&A(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[D]),y.useEffect(()=>{if(!M)return;const re=ye=>{T.current&&!T.current.contains(ye.target)&&I(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[M]),y.useEffect(()=>{if(!L)return;const re=ye=>{O.current&&!O.current.contains(ye.target)&&F(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[L]);const z=y.useMemo(()=>e.find(re=>re.id===c),[e,c]),V=y.useMemo(()=>s.find(re=>re.id===b),[s,b]),q=f===lt.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),se=n!=="idle",Q=!!w||j.length>0,ee=!se&&!R&&l.trim().length>0&&!!c&&(x==="TEAM"?Q:!!b),be=y.useCallback(async()=>{if(!ee)return;const re=W();try{await o({title:l.trim(),description:"",projectId:c,providerId:b,mode:x,workspaceMode:x==="SOLO"?f:lt.WORKTREE,teamRunMode:h,teamTemplateId:w,memberPresetIds:j,attachmentLinks:re}),u(""),K()}catch{}},[ee,l,c,b,x,f,h,w,j,o,W,K]),Ce=y.useCallback(re=>{re.key==="Enter"&&!re.shiftKey&&!re.nativeEvent.isComposing&&re.nativeEvent.keyCode!==229&&(re.preventDefault(),be())},[be]),Oe=y.useCallback(re=>{const ye=re.target.files;ye&&ye.length>0&&X(Array.from(ye)),re.target.value=""},[X]),de=y.useCallback(re=>{v(re),g?.(re),A(!1)},[g]),Ke=y.useCallback(re=>{const ye=re.clipboardData.items,je=[];for(const Le of ye)if(Le.kind==="file"){const Ae=Le.getAsFile();Ae&&je.push(Ae)}je.length>0&&(re.preventDefault(),X(je))},[X]),[fe,ge]=y.useState(!1),$e=y.useCallback(re=>{re.preventDefault(),ge(!0)},[]),et=y.useCallback(re=>{re.preventDefault(),ge(!1)},[]),De=y.useCallback(re=>{re.preventDefault(),ge(!1);const ye=re.dataTransfer.files;ye.length>0&&X(Array.from(ye))},[X]);return t.jsxs("div",{className:"w-full",children:[t.jsxs("div",{className:Z("relative bg-background rounded-xl border transition-colors duration-200","hover:border-ring/40 focus-within:border-ring/60",fe?"border-info bg-info/5":"border-border",se&&"opacity-80"),onDragOver:$e,onDragLeave:et,onDrop:De,children:[$.length>0&&t.jsx("div",{className:"px-4 pt-3",children:t.jsx(Zr,{files:$,onRemove:U})}),t.jsx("textarea",{ref:P,value:l,onChange:re=>u(re.target.value),onKeyDown:Ce,onPaste:Ke,placeholder:i("Describe your task..."),disabled:se,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-base text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"80px",maxHeight:"200px",fieldSizing:"content"}}),fe&&t.jsx("div",{className:"px-4 pb-2",children:t.jsx("div",{className:"flex items-center justify-center py-3 border-2 border-dashed border-border rounded-lg text-sm text-muted-foreground",children:i("Drop files here")})}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>B.current?.click(),disabled:se||R,className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:t.jsx(zr,{size:18})}),t.jsx("input",{ref:B,type:"file",multiple:!0,onChange:Oe,className:"hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[R&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin"}),i("Uploading...")]}),se&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin"}),i(Ix[n])]}),!se&&!R&&x==="TEAM"&&!Q&&l.trim().length>0&&t.jsx("span",{className:"text-[11px] text-warning",children:i("请选择团队模板或追加成员")}),ee&&t.jsxs("span",{className:"hidden sm:inline text-[11px] text-muted-foreground/60 select-none",children:["⏎ ",i("创建")]}),t.jsx("button",{type:"button",onClick:be,disabled:!ee,className:Z("p-2 rounded-lg transition-all duration-200",ee?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"),title:i("Create & Start"),children:t.jsx(Wr,{size:16})})]})]})]}),t.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5",children:[t.jsxs("div",{className:"relative",ref:H,children:[t.jsxs("button",{type:"button",onClick:()=>{se||A(re=>!re)},disabled:se,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",z?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx("span",{className:"size-2 rounded-full shrink-0",style:{backgroundColor:z?.color??"var(--muted-foreground)"}}),t.jsx("span",{className:"max-w-[120px] truncate",children:z?.name??i("Project")}),t.jsx(ht,{size:12,className:Z("text-muted-foreground/70 transition-transform",D&&"rotate-180")})]}),D&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:e.map(re=>t.jsxs("button",{type:"button",onClick:()=>de(re.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:re.color??"var(--muted-foreground)"}}),t.jsx("span",{className:Z("truncate flex-1",re.id===c?"text-foreground font-medium":"text-muted-foreground"),children:re.name}),t.jsx(yt,{size:14,className:Z("ml-2 shrink-0",re.id===c?"opacity-100":"opacity-0")})]},re.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:T,children:[t.jsxs("button",{type:"button",onClick:()=>{se||I(re=>!re)},disabled:se,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",V?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx(Rd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[120px] truncate",children:V?.name??i(r?"Loading...":"Agent")}),t.jsx(ht,{size:12,className:Z("text-muted-foreground/70 transition-transform",M&&"rotate-180")})]}),M&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(re=>t.jsxs("button",{type:"button",disabled:!re.available,onClick:()=>{S(re.id),I(!1)},className:Z("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",!re.available&&"opacity-40 cursor-not-allowed"),children:[t.jsx(yt,{size:14,className:Z("mr-2 shrink-0",re.id===b?"opacity-100":"opacity-0")}),t.jsxs("span",{className:Z("truncate",re.id===b?"text-foreground font-medium":"text-muted-foreground"),children:[re.name,re.available?"":i(" (unavailable)")]})]},re.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:O,children:[t.jsxs("button",{type:"button",onClick:()=>{se||F(re=>!re)},disabled:se,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","text-foreground/80"),children:[t.jsx(un,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[96px] truncate",children:q}),t.jsx(ht,{size:12,className:Z("text-muted-foreground/70 transition-transform",L&&"rotate-180")})]}),L&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-40 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 z-50",children:[t.jsxs("button",{type:"button",onClick:()=>{d(lt.WORKTREE),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(yt,{size:14,className:Z("mr-2 shrink-0",f===lt.WORKTREE?"opacity-100":"opacity-0")}),t.jsx("span",{className:Z("truncate",f===lt.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:i("工作树模式")})]}),t.jsxs("button",{type:"button",onClick:()=>{d(lt.MAIN_DIRECTORY),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(yt,{size:14,className:Z("mr-2 shrink-0",f===lt.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),t.jsx("span",{className:Z("truncate",f===lt.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:i("本地模式")})]})]})]}),t.jsxs("div",{className:"ml-auto inline-flex items-center rounded-lg border border-border/70 bg-muted/50 p-0.5",children:[t.jsx("button",{type:"button",onClick:()=>{se||x==="SOLO"||(a("SOLO"),N(!1))},disabled:se,className:Z("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="SOLO"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:i("Switch to Solo Agent"),children:i("单人")}),t.jsx("button",{type:"button",onClick:()=>{se||x==="TEAM"||(a("TEAM"),F(!1),d(lt.WORKTREE),N(!0))},disabled:se,className:Z("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="TEAM"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:i("Switch to TeamRun"),children:i("团队")})]})]}),x==="SOLO"&&f===lt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2",children:t.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-2.5 py-1.5 text-[11px] leading-relaxed text-warning",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),x==="TEAM"&&E&&t.jsxs("div",{className:"mt-2 rounded-xl bg-muted/50 px-4 pt-3 pb-4",children:[t.jsx("div",{className:"mb-2.5",children:t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:i("团队协作配置")})}),t.jsx(nc,{mode:h,setMode:_,selectedTemplateId:w,setSelectedTemplateId:k,selectedMemberPresetIds:j,setSelectedMemberPresetIds:C,disabled:se})]})]})}const fa=t.jsx("span",{className:"font-semibold text-foreground tracking-tight text-base",children:"Agent Tower"});function ma({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o}){const{t:m}=le(),[p,g]=y.useState(!1),n=e.filter(l=>!l.archivedAt),i=s?e.find(l=>l.id===s)??null:null;return t.jsxs("div",{className:"relative flex items-center min-w-0",children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>g(l=>!l),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:[i?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${i.color.replace("text-","bg-")}`}):t.jsx(Cs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:i?i.name:m("All Projects")}),t.jsx(ht,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`})]}),p?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>g(!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),g(!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(Cs,{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(yt,{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(l=>{const u=s===l.id;return t.jsxs("button",{onClick:()=>{r(l.id),g(!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 ${l.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${u?"text-foreground font-medium":"text-muted-foreground"}`,children:l.name}),u?t.jsx(yt,{size:14,className:"text-foreground shrink-0"}):null]},l.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{g(!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(Ut,{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 Bx=260,Fx=600,ga=400,zx=100,br=1e3;function Hx(e,s){return e&&(e.data.findIndex(o=>o.id===s.id)>=0?{...e,data:e.data.map(o=>o.id===s.id?{...o,...s}:o)}:{...e,data:[s,...e.data],total:e.total+1})}function cb(){const{t:e,locale:s}=le(),[r,o]=y.useState(null),[m,p]=y.useState(null),[g,n]=y.useState(ga),[i,l]=y.useState(!1),[u,c]=y.useState("idle"),[v,b]=y.useState({}),S=y.useRef(!1),x=y.useRef(0),a=y.useRef(ga),f=y.useRef(null),d=at(),{data:h,isLoading:_}=js(),{data:w,isLoading:k}=gd({limit:zx}),j=y.useMemo(()=>w?.data??[],[w?.data]),C=y.useMemo(()=>j.map(Q0),[j]),E=m&&j.some(Y=>Y.id===m)?m:null,{data:N,isLoading:D}=ld(E??"",{limit:br}),A=Sd({queries:E?[]:j.map(Y=>({queryKey:ae.tasks.list(Y.id,{limit:br}),queryFn:()=>xe.get(`/projects/${Y.id}/tasks`,{params:{limit:String(br)}})}))}),M=!E&&A.some(Y=>Y.isLoading),I=y.useMemo(()=>{if(E)return N?.data??[];const Y=[];for(const te of A)te.data?.data&&Y.push(...te.data.data);return Y},[E,N,A]),[L,F]=y.useState([]),H=y.useMemo(()=>{if(L.length===0)return I;const Y=new Set(I.map(te=>te.id));return[...L.filter(te=>!Y.has(te.id)),...I]},[I,L]),[T,O]=y.useState(null),P=y.useMemo(()=>r&&H.some(Y=>Y.id===r)?r:T&&r===T?T:null,[r,H,T]);y.useEffect(()=>{T&&H.some(Y=>Y.id===T)&&O(null)},[T,H]),y.useEffect(()=>{if(L.length===0)return;const Y=new Set(I.map(te=>te.id));L.some(te=>Y.has(te.id))&&F(te=>te.filter(ie=>!Y.has(ie.id)))},[I,L]);const B=y.useMemo(()=>{const Y=new Map;for(const te of H){const ie=te.createdAt?new Date(te.createdAt).getTime():0,he=Y.get(te.projectId)??0;ie>he&&Y.set(te.projectId,ie)}return[...j].sort((te,ie)=>{const he=Y.get(te.id)??(te.createdAt?new Date(te.createdAt).getTime():0);return(Y.get(ie.id)??(ie.createdAt?new Date(ie.createdAt).getTime():0))-he})},[j,H]),$=y.useMemo(()=>B.filter(Y=>!Y.archivedAt),[B]),X=y.useMemo(()=>{if(!h)return[];const Y=localStorage.getItem("providerUsageCount"),te=Y?JSON.parse(Y):{};return[...h].sort((ie,he)=>{const Be=ie.availability.type!=="NOT_FOUND",Re=he.availability.type!=="NOT_FOUND";if(Be!==Re)return Be?-1:1;const tt=te[ie.provider.id]??0;return(te[he.provider.id]??0)-tt})},[h]),U=y.useMemo(()=>H.map(J0),[H]),K=y.useMemo(()=>new Set,[]),W=y.useMemo(()=>{if(!P)return null;const Y=H.find(ie=>ie.id===P);if(!Y)return null;const te=j.find(ie=>ie.id===Y.projectId);if(!te){const ie=ds(Y.workspaces?.find(he=>he.status==="ACTIVE")??Y.workspaces?.[0]);return{id:Y.id,projectId:Y.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:Y.title,status:Fn(Y.status),branch:ie,mainBranch:"main",description:Y.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return ex(Y,te)},[P,H,j]),R=Sa(),z=cd(),V=dd(),q=In(),se=y.useCallback(Y=>{F(te=>te.some(ie=>ie.id===Y.id)?te.map(ie=>ie.id===Y.id?{...ie,...Y}:ie):[Y,...te]),d.setQueryData(ae.tasks.list(Y.projectId,{limit:br}),te=>Hx(te,Y)),d.setQueryData(ae.tasks.detail(Y.id),Y),O(Y.id),o(Y.id)},[d]),Q=y.useCallback((Y,te,ie)=>{const he=Y.id,Be=[Y.title,Y.description].filter(Boolean).join(`
|
|
86
|
-
|
|
87
|
-
`);b(Re=>({...Re,[he]:{status:"creating-workspace"}})),(async()=>{try{const Re=await xe.post(`/tasks/${he}/workspaces`,{workspaceKind:ie});b(me=>({...me,[he]:{status:"creating-session"}}));const tt=await xe.post(`/workspaces/${Re.id}/sessions`,{providerId:te,prompt:Be});b(me=>({...me,[he]:{status:"starting-session"}})),await q.mutateAsync(tt.id),await d.invalidateQueries({queryKey:ae.workspaces.list(he)}),await d.invalidateQueries({queryKey:ae.tasks.all}),b(me=>{const{[he]:Xe,...He}=me;return He})}catch(Re){const tt=Re instanceof Error?Re.message:e("启动 Agent 失败");b(me=>({...me,[he]:{status:"failed",error:tt}})),ut.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ae.workspaces.list(he)}),d.invalidateQueries({queryKey:ae.tasks.all})}})()},[d,q,e]),ee=y.useCallback(Y=>{b(te=>{const{[Y]:ie,...he}=te;return he}),d.invalidateQueries({queryKey:ae.workspaces.list(Y)}),d.invalidateQueries({queryKey:ae.tasks.all})},[d]),be=y.useCallback(Y=>{z.mutate(Y,{onSuccess:()=>{P===Y&&o(null),b(te=>{const{[Y]:ie,...he}=te;return he}),F(te=>te.filter(ie=>ie.id!==Y)),d.invalidateQueries({queryKey:ae.tasks.all})},onError:()=>{ut.error(e("删除任务失败"))}})},[z,P,d,e]),Ce=y.useCallback((Y,te)=>{V.mutate({id:Y,status:Y0(te)},{onError:()=>{ut.error(e("状态变更失败,该操作不被允许"))}})},[V,e]),Oe=y.useCallback(Y=>{Y.preventDefault(),S.current=!0,x.current=Y.clientX,a.current=g,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[g]);y.useEffect(()=>{const Y=ie=>{if(!S.current)return;const he=ie.clientX-x.current,Be=Math.max(Bx,Math.min(Fx,a.current+he));n(Be)},te=()=>{S.current&&(S.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",te),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",te)}},[]);const de=y.useCallback(()=>{l(!0)},[]),Ke=y.useCallback(()=>{if($.length===0){ut.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[$,e]),fe=y.useCallback(()=>{l(!1)},[]),ge=y.useCallback(async Y=>{const{title:te,description:ie,projectId:he,providerId:Be,mode:Re,workspaceMode:tt,teamRunMode:me,teamTemplateId:Xe,memberPresetIds:He,attachmentLinks:nt}=Y,Pe=[ie,nt].filter(Boolean).join(`
|
|
88
|
-
|
|
89
|
-
`);let Te=null;try{if(c("creating-task"),Te=await xe.post(`/projects/${he}/tasks`,{title:te,description:Pe||void 0}),localStorage.setItem("lastSelectedProjectId",he),Re==="SOLO"&&Be){localStorage.setItem("lastSelectedProviderId",Be);const Ve=localStorage.getItem("providerUsageCount"),Ze=Ve?JSON.parse(Ve):{};Ze[Be]=(Ze[Be]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Ze))}Re==="TEAM"?(c("creating-teamrun"),await R.mutateAsync({taskId:Te.id,mode:me,...Xe?{teamTemplateId:Xe}:{},...He.length>0?{memberPresetIds:He}:{}})):Be&&Q(Te,Be,tt),E&&he!==E&&p(null),se(Te),c("idle"),d.invalidateQueries({queryKey:ae.tasks.all}),d.invalidateQueries({queryKey:ae.projects.all})}catch(Ve){if(c("idle"),Te&&Re==="TEAM"){try{await z.mutateAsync(Te.id)}catch{}throw ut.error(e("TeamRun 创建失败,请检查团队配置后重试")),Ve}else if(Te)E&&he!==E&&p(null),se(Te),d.invalidateQueries({queryKey:ae.tasks.all}),d.invalidateQueries({queryKey:ae.projects.all});else throw ut.error(Ve instanceof Error?Ve.message:e("Failed to create task")),Ve}},[R,Q,z,d,e,E,se]),$e=k||D||M,et=y.useMemo(()=>$.map(Y=>({id:Y.id,name:Y.name,color:C.find(te=>te.id===Y.id)?.color})),[$,C]),De=y.useMemo(()=>X.map(({provider:Y,availability:te})=>({id:Y.id,name:Y.name,available:te.type!=="NOT_FOUND"})),[X]),re=y.useMemo(()=>{if(E&&$.find(te=>te.id===E))return E;const Y=localStorage.getItem("lastSelectedProjectId");return Y&&$.find(te=>te.id===Y)?Y:$[0]?.id??""},[$,E]),[ye,je]=y.useState(re);y.useEffect(()=>{je(re)},[re]);const Le=y.useMemo(()=>$.find(Y=>Y.id===ye)?.name??$.find(Y=>Y.id===re)?.name??e("Project"),[$,ye,re,e]),Ae=s==="zh-CN"?`你需要在 ${Le} 中做点什么?`:`What do you need to do in ${Le}?`,Se=y.useMemo(()=>{const Y=localStorage.getItem("lastSelectedProviderId");return Y&&X.find(ie=>ie.provider.id===Y&&ie.availability.type!=="NOT_FOUND")?Y:X.find(ie=>ie.availability.type!=="NOT_FOUND")?.provider.id??""},[X]),ke=al(),[Ne,G]=y.useState(!1),oe=y.useCallback(()=>{if($.length===0){ut.error(e("没有可用项目,请先创建或恢复项目"));return}G(!0)},[$,e]),we=y.useCallback(async Y=>{await ge(Y),G(!1)},[ge]);return ke?Ne?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:()=>G(!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-2xl tracking-tight leading-tight text-foreground mb-6 break-words",children:Ae}),t.jsx(ha,{projects:et,providers:De,isProvidersLoading:_,onSubmit:we,defaultProjectId:re,defaultProviderId:Se,onProjectChange:je,createStep:u})]})]}):P&&W?t.jsxs(t.Fragment,{children:[t.jsx(xx,{task:W,onBack:()=>o(null),onDeleteTask:W.projectArchivedAt?void 0:be,isDeleting:z.isPending,autoStartState:v[W.id]??null,onAutoStartRecovered:ee}),t.jsx(Oi,{isOpen:i,onClose:fe})]}):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(ua,{}),fa,t.jsx(ma,{projects:C,filterProjectId:E,setFilterProjectId:p,onCreateProject:de})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(da,{}),t.jsx("button",{onClick:()=>Qn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Gn,{size:16})})]})]}),$e&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(pa,{})}):t.jsx(go,{tasks:U,projects:C,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:"100%",onCreateTask:oe,onCreateProject:de,activeTaskIds:K,onTaskStatusChange:Ce})]}),t.jsx(Oi,{isOpen:i,onClose:fe})]}):t.jsxs("div",{ref:f,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ua,{}),fa,t.jsx(ma,{projects:C,filterProjectId:E,setFilterProjectId:p,onCreateProject:de})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(da,{}),t.jsx("button",{onClick:()=>Qn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",children:t.jsx(Gn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[$e&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:g},children:t.jsx(pa,{})}):t.jsx(go,{tasks:U,projects:C,selectedTaskId:P,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:g,onCreateTask:Ke,onCreateProject:de,isCreateActive:!P,activeTaskIds:K,onTaskStatusChange:Ce,onDeleteTask:be}),t.jsx("div",{onMouseDown:Oe,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:P&&W?t.jsx(V0,{task:W,onDeleteTask:W.projectArchivedAt?void 0:be,isDeleting:z.isPending,onTaskStatusChange:W.projectArchivedAt?void 0:Ce,autoStartState:v[W.id]??null,onAutoStartRecovered:ee}):P&&!W?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-3xl tracking-tight leading-tight text-foreground mb-8 break-words",children:Ae}),t.jsx(ha,{projects:et,providers:De,isProvidersLoading:_,onSubmit:ge,defaultProjectId:re,defaultProviderId:Se,onProjectChange:je,createStep:u})]})})})]}),t.jsx(Oi,{isOpen:i,onClose:fe})]})}export{cb as ProjectKanbanPage};
|