agent-tower 0.5.1 → 0.5.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -0
- package/dist/app.js.map +1 -1
- package/dist/core/container.d.ts +2 -0
- package/dist/core/container.d.ts.map +1 -1
- package/dist/core/container.js +8 -0
- package/dist/core/container.js.map +1 -1
- package/dist/executors/__tests__/codex.executor.test.js +348 -7
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/codex.executor.d.ts +18 -1
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +75 -7
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/mcp/http-client.d.ts +4 -1
- package/dist/mcp/http-client.d.ts.map +1 -1
- package/dist/mcp/http-client.js +2 -2
- package/dist/mcp/http-client.js.map +1 -1
- package/dist/mcp/tools/workspaces.d.ts.map +1 -1
- package/dist/mcp/tools/workspaces.js +4 -1
- package/dist/mcp/tools/workspaces.js.map +1 -1
- package/dist/mcp/types.d.ts +3 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -1
- package/dist/routes/__tests__/tasks.test.js +37 -0
- package/dist/routes/__tests__/tasks.test.js.map +1 -1
- package/dist/routes/git.d.ts.map +1 -1
- package/dist/routes/git.js +6 -1
- package/dist/routes/git.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +12 -0
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/system.d.ts.map +1 -1
- package/dist/routes/system.js +21 -5
- package/dist/routes/system.js.map +1 -1
- package/dist/routes/tasks.js +2 -2
- package/dist/routes/tasks.js.map +1 -1
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +11 -4
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/services/__tests__/project.service.test.d.ts +2 -0
- package/dist/services/__tests__/project.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/project.service.test.js +62 -0
- package/dist/services/__tests__/project.service.test.js.map +1 -0
- package/dist/services/__tests__/session-manager.team-run.test.js +98 -0
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/__tests__/task.service.test.js +416 -38
- package/dist/services/__tests__/task.service.test.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +68 -0
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/__tests__/team-run.service.test.js +47 -1
- package/dist/services/__tests__/team-run.service.test.js.map +1 -1
- package/dist/services/__tests__/team-scheduler.service.test.js +49 -0
- package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -1
- package/dist/services/__tests__/workspace.service.test.js +157 -0
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/commit-message.service.d.ts.map +1 -1
- package/dist/services/commit-message.service.js +3 -0
- package/dist/services/commit-message.service.js.map +1 -1
- package/dist/services/deleted-task-guard.d.ts +11 -0
- package/dist/services/deleted-task-guard.d.ts.map +1 -0
- package/dist/services/deleted-task-guard.js +10 -0
- package/dist/services/deleted-task-guard.js.map +1 -0
- package/dist/services/project.service.d.ts +1 -0
- package/dist/services/project.service.d.ts.map +1 -1
- package/dist/services/project.service.js +4 -3
- package/dist/services/project.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +55 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +133 -41
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task-cleanup.service.d.ts +48 -0
- package/dist/services/task-cleanup.service.d.ts.map +1 -0
- package/dist/services/task-cleanup.service.js +209 -0
- package/dist/services/task-cleanup.service.js.map +1 -0
- package/dist/services/task.service.d.ts +19 -7
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +139 -63
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/team-reconciler.service.d.ts.map +1 -1
- package/dist/services/team-reconciler.service.js +21 -1
- package/dist/services/team-reconciler.service.js.map +1 -1
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +15 -1
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/team-scheduler.service.d.ts +3 -1
- package/dist/services/team-scheduler.service.d.ts.map +1 -1
- package/dist/services/team-scheduler.service.js +16 -0
- package/dist/services/team-scheduler.service.js.map +1 -1
- package/dist/services/workspace-kind.d.ts +13 -0
- package/dist/services/workspace-kind.d.ts.map +1 -0
- package/dist/services/workspace-kind.js +16 -0
- package/dist/services/workspace-kind.js.map +1 -0
- package/dist/services/workspace.service.d.ts +26 -0
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +173 -23
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-CkhVcgZo.js +1 -0
- package/dist/web/assets/{DemoPage-DeXHpe0f.js → DemoPage-dkmp8Vvn.js} +3 -3
- package/dist/web/assets/GeneralSettingsPage-B4DH6g3D.js +1 -0
- package/dist/web/assets/MemberAvatar-pwugXGL4.js +1 -0
- package/dist/web/assets/NotificationSettingsPage-C-bPU_ZE.js +1 -0
- package/dist/web/assets/ProfileSettingsPage-Dlr6BmHb.js +3 -0
- package/dist/web/assets/ProjectKanbanPage-7oEfjjWV.js +89 -0
- package/dist/web/assets/ProjectSettingsPage-DZZksq5G.js +2 -0
- package/dist/web/assets/ProviderSettingsPage-BWN7CEG6.js +54 -0
- package/dist/web/assets/SettingsSection-C-sMhXpf.js +1 -0
- package/dist/web/assets/TeamSettingsPage-924xpocx.js +1 -0
- package/dist/web/assets/arrow-left-UHjQiY5K.js +1 -0
- package/dist/web/assets/button-CUTjpRqw.js +1 -0
- package/dist/web/assets/check-CPkZgPjx.js +1 -0
- package/dist/web/assets/chevron-down-Bby7sJEv.js +1 -0
- package/dist/web/assets/chevron-right-DCC0lyoB.js +1 -0
- package/dist/web/assets/{chevron-up-xy9sRgGr.js → chevron-up-BnCoaejn.js} +1 -1
- package/dist/web/assets/{circle-check-D53Ur01f.js → circle-check-BscClK07.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-BHTzJkrx.js → code-block-OCS4YCEC-DkMlYSza.js} +1 -1
- package/dist/web/assets/confirm-dialog-wsb35VpE.js +1 -0
- package/dist/web/assets/folder-picker-B-X_nrS1.js +1 -0
- package/dist/web/assets/index-4hNWw0yi.css +1 -0
- package/dist/web/assets/index-CUJoWIuo.js +13 -0
- package/dist/web/assets/loader-circle-Cul4BuAa.js +1 -0
- package/dist/web/assets/log-adapter-CtvxzS4j.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-BSPQ7bmi.js → mermaid-NOHMQCX5-DoPzf-UA.js} +53 -53
- package/dist/web/assets/message-square-C7Q71jFj.js +1 -0
- package/dist/web/assets/modal-25-qs8P5.js +1 -0
- package/dist/web/assets/{pencil-zfyDXHtM.js → pencil-CaJR6Dqm.js} +1 -1
- package/dist/web/assets/rotate-ccw-Bvz7590n.js +1 -0
- package/dist/web/assets/{select-CEtSClHi.js → select-CzeTYLO4.js} +1 -1
- package/dist/web/assets/upload-_2T21rVP.js +1 -0
- package/dist/web/assets/{use-profiles-BrCaq-M0.js → use-profiles-BaCwGP06.js} +1 -1
- package/dist/web/assets/{use-providers-BmGR6zlI.js → use-providers-Bwl7R5Ql.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +10 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js +6 -0
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +24 -5
- package/node_modules/@prisma/client/.prisma/client/index-browser.js +19 -0
- package/node_modules/@prisma/client/.prisma/client/index.d.ts +1652 -142
- package/node_modules/@prisma/client/.prisma/client/index.js +24 -5
- package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
- package/node_modules/@prisma/client/.prisma/client/schema.prisma +29 -1
- package/node_modules/@prisma/client/.prisma/client/wasm.js +19 -0
- package/package.json +1 -1
- package/prisma/migrations/20260603000000_add_task_cleanup_jobs/migration.sql +21 -0
- package/prisma/migrations/20260609000000_add_workspace_kind_working_dir/migration.sql +7 -0
- package/prisma/schema.prisma +29 -1
- package/dist/web/assets/AgentDemoPage-C41Npg-J.js +0 -1
- package/dist/web/assets/GeneralSettingsPage-ROIAXf_I.js +0 -1
- package/dist/web/assets/MemberAvatar-Bgb9cNkt.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-BSFFB_Xk.js +0 -1
- package/dist/web/assets/ProfileSettingsPage-n6J_nKUb.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-BUwfUX3X.js +0 -90
- package/dist/web/assets/ProjectSettingsPage-Dv5Ab2MY.js +0 -2
- package/dist/web/assets/ProviderSettingsPage-Ckp_pVCi.js +0 -54
- package/dist/web/assets/TeamSettingsPage-DjlyHMct.js +0 -1
- package/dist/web/assets/button-_UA8cNod.js +0 -1
- package/dist/web/assets/chevron-down-qLfxqOnz.js +0 -1
- package/dist/web/assets/chevron-right-SY4_v7-h.js +0 -1
- package/dist/web/assets/confirm-dialog-D9WQU47x.js +0 -1
- package/dist/web/assets/folder-picker-DPW13OyX.js +0 -1
- package/dist/web/assets/index-BjIvVVfi.css +0 -1
- package/dist/web/assets/index-BsrxN6e4.js +0 -13
- package/dist/web/assets/loader-circle-CPz4Agyr.js +0 -1
- package/dist/web/assets/log-adapter-i7kNXXup.js +0 -1
- package/dist/web/assets/modal-BLPS1r7Q.js +0 -1
- package/dist/web/assets/upload-hdDyQIIu.js +0 -1
- package/dist/web/assets/utils-CkSf8FUe.js +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import{Q as Ni,G as _n,H as Xl,I as Yl,J as Vl,K as gi,M as Gl,N as Ql,g as et,O as Zl,P as Jl,r as C,R as ec,T as tc,U as sc,V as rc,W as xn,Y as bn,Z as ic,_ as nc,$ as oc,e as be,a0 as ne,A as Vt,f as yt,h as ft,i as _e,q as le,u as ce,j as s,X as Ot,d as J,a1 as Oo,a2 as Io,a3 as Bo,a4 as ps,w as Yt,S as it,C as ds,a5 as Fo,E as Gt,t as Rt,a6 as vi,k as ac,l as lc,L as yn,a7 as zo,a8 as Sn,a9 as Ri,aa as Ho,ab as Wo,ac as cc,ad as dc,ae as uc,af as hc,ag as fc,x as wn,ah as Cn}from"./index-CUJoWIuo.js";import{S as Ye,W as rt,a as kt,C as Ms,A as Pt,T as Lt}from"./log-adapter-CtvxzS4j.js";import{f as Ai,b as Ti,d as Mi,c as Di,h as Li,S as gs,A as kn,P as Sr,Q as Pi,s as Oi,G as $o,u as Uo,a as qo,e as or,T as ar}from"./mermaid-NOHMQCX5-DoPzf-UA.js";import{C as Ii}from"./confirm-dialog-wsb35VpE.js";import{C as lt}from"./chevron-down-Bby7sJEv.js";import{C as It}from"./chevron-right-DCC0lyoB.js";import{C as ht}from"./check-CPkZgPjx.js";import{P as vs,a as Bi,M as zs,T as Ko}from"./modal-25-qs8P5.js";import{B as Ve}from"./button-CUTjpRqw.js";import{L as Fe}from"./loader-circle-Cul4BuAa.js";import{M as zt}from"./MemberAvatar-pwugXGL4.js";import{C as Xo}from"./chevron-up-BnCoaejn.js";import{M as Fi}from"./message-square-C7Q71jFj.js";import{a as mc,F as pc,f as gc,g as vc,e as _c,u as xc}from"./folder-picker-B-X_nrS1.js";import{C as bc,U as Gr}from"./upload-_2T21rVP.js";import{u as Hs}from"./use-providers-Bwl7R5Ql.js";import{S as En}from"./select-CzeTYLO4.js";import{R as yc}from"./rotate-ccw-Bvz7590n.js";import{A as _i}from"./arrow-left-UHjQiY5K.js";var Sc=class extends Ni{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:_n()})}getOptimisticResult(e){return e.behavior=_n(),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,t){const{state:r}=e,a=super.createResult(e,t),{isFetching:m,isRefetching:p,isError:_,isRefetchError:i}=a,n=r.fetchMeta?.fetchMore?.direction,c=_&&n==="forward",h=m&&n==="forward",l=_&&n==="backward",g=m&&n==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Yl(t,r.data),hasPreviousPage:Xl(t,r.data),isFetchNextPageError:c,isFetchingNextPage:h,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:i&&!c&&!l,isRefetching:p&&!h&&!g}}};function jn(e,t){const r=new Set(t);return e.filter(a=>!r.has(a))}function wc(e,t,r){const a=e.slice(0);return a[t]=r,a}var Cc=class extends Vl{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,gi.batch(()=>{const r=this.#t,a=this.#h(this.#i);a.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const m=a.map(h=>h.observer),p=m.map(h=>h.getCurrentResult()),_=r.length!==m.length,i=m.some((h,l)=>h!==r[l]),n=_||i,c=n?!0:p.some((h,l)=>{const g=this.#e[l];return!g||!Gl(h,g)});!n&&!c||(n&&(this.#c=a,this.#t=m),this.#e=p,this.hasListeners()&&(n&&(jn(r,m).forEach(h=>{h.destroy()}),jn(m,r).forEach(h=>{h.subscribe(l=>{this.#f(h,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const r=this.#h(e),a=r.map(p=>p.observer.getOptimisticResult(p.defaultedQueryOptions)),m=r.map(p=>p.defaultedQueryOptions.queryHash);return[a,p=>this.#u(p??a,t,m),()=>this.#d(a,r)]}#d(e,t){return t.map((r,a)=>{const m=e[a];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{t.forEach(_=>{_.observer.trackProp(p)})})})}#u(e,t,r){if(t){const a=this.#l,m=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((p,_)=>p!==a[_]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Ql(this.#s,t(e))),this.#s}return e}#h(e){const t=new Map;this.#t.forEach(a=>{const m=a.options.queryHash;if(!m)return;const p=t.get(m);p?p.push(a):t.set(m,[a])});const r=[];return e.forEach(a=>{const m=this.#r.defaultQueryOptions(a),_=t.get(m.queryHash)?.shift()??new Ni(this.#r,m);r.push({defaultedQueryOptions:m,observer:_})}),r}#f(e,t){const r=this.#t.indexOf(e);r!==-1&&(this.#e=wc(this.#e,r,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),r=this.#u(t,this.#n?.combine);e!==r&&gi.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function kc({queries:e,...t},r){const a=et(),m=Zl(),p=Jl(),_=C.useMemo(()=>e.map(v=>{const o=a.defaultQueryOptions(v);return o._optimisticResults=m?"isRestoring":"optimistic",o}),[e,a,m]);_.forEach(v=>{ec(v);const o=a.getQueryCache().get(v.queryHash);tc(v,p,o)}),sc(p);const[i]=C.useState(()=>new Cc(a,_,t)),[n,c,h]=i.getOptimisticResult(_,t.combine),l=!m&&t.subscribed!==!1;C.useSyncExternalStore(C.useCallback(v=>l?i.subscribe(gi.batchCalls(v)):rc,[i,l]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(_,t)},[_,t,i]);const b=n.some((v,o)=>xn(_[o],v))?n.flatMap((v,o)=>{const f=_[o];if(f){const d=new Ni(a,f);if(xn(f,v))return bn(f,d,p);ic(v,m)&&bn(f,d,p)}return[]}):[];if(b.length>0)throw Promise.all(b);const S=n.find((v,o)=>{const f=_[o];return f&&nc({result:v,errorResetBoundary:p,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return c(h())}function Yo(e,t){return oc(e,Sc)}const Ec=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ds=be("arrow-down",Ec);const jc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Nc=be("arrow-right",jc);const Rc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],wr=be("arrow-up",Rc);const Ac=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Vo=be("ban",Ac);const Tc=[["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"}]],Mc=be("bot",Tc);const Dc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Lc=be("chevron-left",Dc);const Pc=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],us=be("clock-3",Pc);const Oc=[["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"}]],Ws=be("code-xml",Oc);const Ic=[["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"}]],Nn=be("copy",Ic);const Bc=[["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"}]],Go=be("ellipsis-vertical",Bc);const Fc=[["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"}]],zi=be("external-link",Fc);const zc=[["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"}]],Hc=be("file-braces-corner",zc);const Wc=[["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"}]],Ls=be("file-code-corner",Wc);const $c=[["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"}]],Uc=be("file-exclamation-point",$c);const qc=[["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"}]],Hi=be("file-text",qc);const Kc=[["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"}]],Cr=be("folder-open",Kc);const Xc=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Yc=be("gauge",Xc);const Vc=[["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"}]],Wi=be("git-branch",Vc);const Gc=[["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"}]],_s=be("git-graph",Gc);const Qc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],xs=be("history",Qc);const Zc=[["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"}]],$i=be("image",Zc);const Jc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ed=be("info",Jc);const td=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Ps=be("layers",td);const sd=[["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"}]],rd=be("lock-keyhole",sd);const id=[["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"}]],nd=be("maximize",id);const od=[["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"}]],ad=be("panel-left-close",od);const ld=[["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"}]],cd=be("panel-left-open",ld);const dd=[["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"}]],ud=be("panel-right-close",dd);const hd=[["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"}]],lr=be("panel-right-open",hd);const fd=[["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"}]],rs=be("play",fd);const md=[["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"}]],kr=be("refresh-cw",md);const pd=[["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"}]],gd=be("save",pd);const vd=[["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"}]],Qo=be("shield",vd);const _d=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Rn=be("smartphone",_d);const xd=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],cr=be("terminal",xd);const bd=[["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"}]],Zo=be("zap",bd);const yd=[["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"}]],Sd=be("zoom-in",yd);const wd=[["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"}]],Cd=be("zoom-out",wd),Er=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function bs(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ui(e){return"nodeType"in e}function ut(e){var t,r;return e?bs(e)?e:Ui(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function qi(e){const{Document:t}=ut(e);return e instanceof t}function $s(e){return bs(e)?!1:e instanceof ut(e).HTMLElement}function Jo(e){return e instanceof ut(e).SVGElement}function ys(e){return e?bs(e)?e.document:Ui(e)?qi(e)?e:$s(e)||Jo(e)?e.ownerDocument:document:document:document}const Ht=Er?C.useLayoutEffect:C.useEffect;function jr(e){const t=C.useRef(e);return Ht(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,a=new Array(r),m=0;m<r;m++)a[m]=arguments[m];return t.current==null?void 0:t.current(...a)},[])}function kd(){const e=C.useRef(null),t=C.useCallback((a,m)=>{e.current=setInterval(a,m)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function Os(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Ht(()=>{r.current!==e&&(r.current=e)},t),r}function Us(e,t){const r=C.useRef();return C.useMemo(()=>{const a=e(r.current);return r.current=a,a},[...t])}function dr(e){const t=jr(e),r=C.useRef(null),a=C.useCallback(m=>{m!==r.current&&t?.(m,r.current),r.current=m},[]);return[r,a]}function ur(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Qr={};function Nr(e,t){return C.useMemo(()=>{if(t)return t;const r=Qr[e]==null?0:Qr[e]+1;return Qr[e]=r,e+"-"+r},[e,t])}function ea(e){return function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),m=1;m<r;m++)a[m-1]=arguments[m];return a.reduce((p,_)=>{const i=Object.entries(_);for(const[n,c]of i){const h=p[n];h!=null&&(p[n]=h+e*c)}return p},{...t})}}const ms=ea(1),hr=ea(-1);function Ed(e){return"clientX"in e&&"clientY"in e}function Ki(e){if(!e)return!1;const{KeyboardEvent:t}=ut(e.target);return t&&e instanceof t}function jd(e){if(!e)return!1;const{TouchEvent:t}=ut(e.target);return t&&e instanceof t}function fr(e){if(jd(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Ed(e)?{x:e.clientX,y:e.clientY}:null}const Is=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Is.Translate.toString(e),Is.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:a}=e;return t+" "+r+"ms "+a}}}),An="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Nd(e){return e.matches(An)?e:e.querySelector(An)}const Rd={display:"none"};function Ad(e){let{id:t,value:r}=e;return ne.createElement("div",{id:t,style:Rd},r)}function Td(e){let{id:t,announcement:r,ariaLiveType:a="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 ne.createElement("div",{id:t,style:m,role:"status","aria-live":a,"aria-atomic":!0},r)}function Md(){const[e,t]=C.useState("");return{announce:C.useCallback(a=>{a!=null&&t(a)},[]),announcement:e}}const ta=C.createContext(null);function Dd(e){const t=C.useContext(ta);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ld(){const[e]=C.useState(()=>new Set),t=C.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]);return[C.useCallback(a=>{let{type:m,event:p}=a;e.forEach(_=>{var i;return(i=_[m])==null?void 0:i.call(_,p)})},[e]),t]}const Pd={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
|
+
`},Od={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Id(e){let{announcements:t=Od,container:r,hiddenTextDescribedById:a,screenReaderInstructions:m=Pd}=e;const{announce:p,announcement:_}=Md(),i=Nr("DndLiveRegion"),[n,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),Dd(C.useMemo(()=>({onDragStart(l){let{active:g}=l;p(t.onDragStart({active:g}))},onDragMove(l){let{active:g,over:b}=l;t.onDragMove&&p(t.onDragMove({active:g,over:b}))},onDragOver(l){let{active:g,over:b}=l;p(t.onDragOver({active:g,over:b}))},onDragEnd(l){let{active:g,over:b}=l;p(t.onDragEnd({active:g,over:b}))},onDragCancel(l){let{active:g,over:b}=l;p(t.onDragCancel({active:g,over:b}))}}),[p,t])),!n)return null;const h=ne.createElement(ne.Fragment,null,ne.createElement(Ad,{id:a,value:m.draggable}),ne.createElement(Td,{id:i,announcement:_}));return r?Vt.createPortal(h,r):h}var Je;(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"})(Je||(Je={}));function mr(){}function Bd(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Fd(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return C.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Tt=Object.freeze({x:0,y:0});function zd(e,t){const r=fr(e);if(!r)return"0 0";const a={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return a.x+"% "+a.y+"%"}function Hd(e,t){let{data:{value:r}}=e,{data:{value:a}}=t;return a-r}function Wd(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function $d(e,t){const r=Math.max(t.top,e.top),a=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),p=Math.min(t.top+t.height,e.top+e.height),_=m-a,i=p-r;if(a<m&&r<p){const n=t.width*t.height,c=e.width*e.height,h=_*i,l=h/(n+c-h);return Number(l.toFixed(4))}return 0}const Ud=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:a}=e;const m=[];for(const p of a){const{id:_}=p,i=r.get(_);if(i){const n=$d(i,t);n>0&&m.push({id:_,data:{droppableContainer:p,value:n}})}}return m.sort(Hd)};function qd(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function sa(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Tt}function Kd(e){return function(r){for(var a=arguments.length,m=new Array(a>1?a-1:0),p=1;p<a;p++)m[p-1]=arguments[p];return m.reduce((_,i)=>({..._,top:_.top+e*i.y,bottom:_.bottom+e*i.y,left:_.left+e*i.x,right:_.right+e*i.x}),{...r})}}const Xd=Kd(1);function ra(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Yd(e,t,r){const a=ra(t);if(!a)return e;const{scaleX:m,scaleY:p,x:_,y:i}=a,n=e.left-_-(1-m)*parseFloat(r),c=e.top-i-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),h=m?e.width/m:e.width,l=p?e.height/p:e.height;return{width:h,height:l,top:c,right:n+h,bottom:c+l,left:n}}const Vd={ignoreTransform:!1};function qs(e,t){t===void 0&&(t=Vd);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:h}=ut(e).getComputedStyle(e);c&&(r=Yd(r,c,h))}const{top:a,left:m,width:p,height:_,bottom:i,right:n}=r;return{top:a,left:m,width:p,height:_,bottom:i,right:n}}function Tn(e){return qs(e,{ignoreTransform:!0})}function Gd(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Qd(e,t){return t===void 0&&(t=ut(e).getComputedStyle(e)),t.position==="fixed"}function Zd(e,t){t===void 0&&(t=ut(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=t[m];return typeof p=="string"?r.test(p):!1})}function Xi(e,t){const r=[];function a(m){if(t!=null&&r.length>=t||!m)return r;if(qi(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!$s(m)||Jo(m)||r.includes(m))return r;const p=ut(e).getComputedStyle(m);return m!==e&&Zd(m,p)&&r.push(m),Qd(m,p)?r:a(m.parentNode)}return e?a(e):r}function ia(e){const[t]=Xi(e,1);return t??null}function Zr(e){return!Er||!e?null:bs(e)?e:Ui(e)?qi(e)||e===ys(e).scrollingElement?window:$s(e)?e:null:null}function na(e){return bs(e)?e.scrollX:e.scrollLeft}function oa(e){return bs(e)?e.scrollY:e.scrollTop}function xi(e){return{x:na(e),y:oa(e)}}var nt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(nt||(nt={}));function aa(e){return!Er||!e?!1:e===document.scrollingElement}function la(e){const t={x:0,y:0},r=aa(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},m=e.scrollTop<=t.y,p=e.scrollLeft<=t.x,_=e.scrollTop>=a.y,i=e.scrollLeft>=a.x;return{isTop:m,isLeft:p,isBottom:_,isRight:i,maxScroll:a,minScroll:t}}const Jd={x:.2,y:.2};function eu(e,t,r,a,m){let{top:p,left:_,right:i,bottom:n}=r;a===void 0&&(a=10),m===void 0&&(m=Jd);const{isTop:c,isBottom:h,isLeft:l,isRight:g}=la(e),b={x:0,y:0},S={x:0,y:0},v={height:t.height*m.y,width:t.width*m.x};return!c&&p<=t.top+v.height?(b.y=nt.Backward,S.y=a*Math.abs((t.top+v.height-p)/v.height)):!h&&n>=t.bottom-v.height&&(b.y=nt.Forward,S.y=a*Math.abs((t.bottom-v.height-n)/v.height)),!g&&i>=t.right-v.width?(b.x=nt.Forward,S.x=a*Math.abs((t.right-v.width-i)/v.width)):!l&&_<=t.left+v.width&&(b.x=nt.Backward,S.x=a*Math.abs((t.left+v.width-_)/v.width)),{direction:b,speed:S}}function tu(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:_}=window;return{top:0,left:0,right:p,bottom:_,width:p,height:_}}const{top:t,left:r,right:a,bottom:m}=e.getBoundingClientRect();return{top:t,left:r,right:a,bottom:m,width:e.clientWidth,height:e.clientHeight}}function ca(e){return e.reduce((t,r)=>ms(t,xi(r)),Tt)}function su(e){return e.reduce((t,r)=>t+na(r),0)}function ru(e){return e.reduce((t,r)=>t+oa(r),0)}function da(e,t){if(t===void 0&&(t=qs),!e)return;const{top:r,left:a,bottom:m,right:p}=t(e);ia(e)&&(m<=0||p<=0||r>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const iu=[["x",["left","right"],su],["y",["top","bottom"],ru]];class Yi{constructor(t,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 a=Xi(r),m=ca(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[p,_,i]of iu)for(const n of _)Object.defineProperty(this,n,{get:()=>{const c=i(a),h=m[p]-c;return this.rect[n]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ns{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...r)})},this.target=t}add(t,r,a){var m;(m=this.target)==null||m.addEventListener(t,r,a),this.listeners.push([t,r,a])}}function nu(e){const{EventTarget:t}=ut(e);return e instanceof t?e:ys(e)}function Jr(e,t){const r=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+a**2)>t:"x"in t&&"y"in t?r>t.x&&a>t.y:"x"in t?r>t.x:"y"in t?a>t.y:!1}var Ct;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Ct||(Ct={}));function Mn(e){e.preventDefault()}function ou(e){e.stopPropagation()}var Ie;(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"})(Ie||(Ie={}));const ua={start:[Ie.Space,Ie.Enter],cancel:[Ie.Esc],end:[Ie.Space,Ie.Enter,Ie.Tab]},au=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Ie.Right:return{...r,x:r.x+25};case Ie.Left:return{...r,x:r.x-25};case Ie.Down:return{...r,y:r.y+25};case Ie.Up:return{...r,y:r.y-25}}};class ha{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new Ns(ys(r)),this.windowListeners=new Ns(ut(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ct.Resize,this.handleCancel),this.windowListeners.add(Ct.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ct.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,a=t.node.current;a&&da(a),r(Tt)}handleKeyDown(t){if(Ki(t)){const{active:r,context:a,options:m}=this.props,{keyboardCodes:p=ua,coordinateGetter:_=au,scrollBehavior:i="smooth"}=m,{code:n}=t;if(p.end.includes(n)){this.handleEnd(t);return}if(p.cancel.includes(n)){this.handleCancel(t);return}const{collisionRect:c}=a.current,h=c?{x:c.left,y:c.top}:Tt;this.referenceCoordinates||(this.referenceCoordinates=h);const l=_(t,{active:r,context:a.current,currentCoordinates:h});if(l){const g=hr(l,h),b={x:0,y:0},{scrollableAncestors:S}=a.current;for(const v of S){const o=t.code,{isTop:f,isRight:d,isLeft:u,isBottom:x,maxScroll:y,minScroll:k}=la(v),j=tu(v),w={x:Math.min(o===Ie.Right?j.right-j.width/2:j.right,Math.max(o===Ie.Right?j.left:j.left+j.width/2,l.x)),y:Math.min(o===Ie.Down?j.bottom-j.height/2:j.bottom,Math.max(o===Ie.Down?j.top:j.top+j.height/2,l.y))},E=o===Ie.Right&&!d||o===Ie.Left&&!u,N=o===Ie.Down&&!x||o===Ie.Up&&!f;if(E&&w.x!==l.x){const T=v.scrollLeft+g.x,R=o===Ie.Right&&T<=y.x||o===Ie.Left&&T>=k.x;if(R&&!g.y){v.scrollTo({left:T,behavior:i});return}R?b.x=v.scrollLeft-T:b.x=o===Ie.Right?v.scrollLeft-y.x:v.scrollLeft-k.x,b.x&&v.scrollBy({left:-b.x,behavior:i});break}else if(N&&w.y!==l.y){const T=v.scrollTop+g.y,R=o===Ie.Down&&T<=y.y||o===Ie.Up&&T>=k.y;if(R&&!g.x){v.scrollTo({top:T,behavior:i});return}R?b.y=v.scrollTop-T:b.y=o===Ie.Down?v.scrollTop-y.y:v.scrollTop-k.y,b.y&&v.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(t,ms(hr(l,this.referenceCoordinates),b))}}}handleMove(t,r){const{onMove:a}=this.props;t.preventDefault(),a(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}ha.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:a=ua,onActivation:m}=t,{active:p}=r;const{code:_}=e.nativeEvent;if(a.start.includes(_)){const i=p.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Dn(e){return!!(e&&"distance"in e)}function Ln(e){return!!(e&&"delay"in e)}class Vi{constructor(t,r,a){var m;a===void 0&&(a=nu(t.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=t,this.events=r;const{event:p}=t,{target:_}=p;this.props=t,this.events=r,this.document=ys(_),this.documentListeners=new Ns(this.document),this.listeners=new Ns(a),this.windowListeners=new Ns(ut(_)),this.initialCoordinates=(m=fr(p))!=null?m:Tt,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:t,props:{options:{activationConstraint:r,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Ct.Resize,this.handleCancel),this.windowListeners.add(Ct.DragStart,Mn),this.windowListeners.add(Ct.VisibilityChange,this.handleCancel),this.windowListeners.add(Ct.ContextMenu,Mn),this.documentListeners.add(Ct.Keydown,this.handleKeydown),r){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ln(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Dn(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(t,r){const{active:a,onPending:m}=this.props;m(a,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Ct.Click,ou,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ct.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:a,initialCoordinates:m,props:p}=this,{onMove:_,options:{activationConstraint:i}}=p;if(!m)return;const n=(r=fr(t))!=null?r:Tt,c=hr(m,n);if(!a&&i){if(Dn(i)){if(i.tolerance!=null&&Jr(c,i.tolerance))return this.handleCancel();if(Jr(c,i.distance))return this.handleStart()}if(Ln(i)&&Jr(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),_(n)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Ie.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const lu={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Gi extends Vi{constructor(t){const{event:r}=t,a=ys(r.target);super(t,lu,a)}}Gi.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;return!r.isPrimary||r.button!==0?!1:(a?.({event:r}),!0)}}];const cu={move:{name:"mousemove"},end:{name:"mouseup"}};var bi;(function(e){e[e.RightClick=2]="RightClick"})(bi||(bi={}));class du extends Vi{constructor(t){super(t,cu,ys(t.event.target))}}du.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;return r.button===bi.RightClick?!1:(a?.({event:r}),!0)}}];const ei={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class uu extends Vi{constructor(t){super(t,ei)}static setup(){return window.addEventListener(ei.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ei.move.name,t)};function t(){}}}uu.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;const{touches:m}=r;return m.length>1?!1:(a?.({event:r}),!0)}}];var Rs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Rs||(Rs={}));var pr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(pr||(pr={}));function hu(e){let{acceleration:t,activator:r=Rs.Pointer,canScroll:a,draggingRect:m,enabled:p,interval:_=5,order:i=pr.TreeOrder,pointerCoordinates:n,scrollableAncestors:c,scrollableAncestorRects:h,delta:l,threshold:g}=e;const b=mu({delta:l,disabled:!p}),[S,v]=kd(),o=C.useRef({x:0,y:0}),f=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case Rs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case Rs.DraggableRect:return m}},[r,m,n]),u=C.useRef(null),x=C.useCallback(()=>{const k=u.current;if(!k)return;const j=o.current.x*f.current.x,w=o.current.y*f.current.y;k.scrollBy(j,w)},[]),y=C.useMemo(()=>i===pr.TreeOrder?[...c].reverse():c,[i,c]);C.useEffect(()=>{if(!p||!c.length||!d){v();return}for(const k of y){if(a?.(k)===!1)continue;const j=c.indexOf(k),w=h[j];if(!w)continue;const{direction:E,speed:N}=eu(k,w,d,t,g);for(const T of["x","y"])b[T][E[T]]||(N[T]=0,E[T]=0);if(N.x>0||N.y>0){v(),u.current=k,S(x,_),o.current=N,f.current=E;return}}o.current={x:0,y:0},f.current={x:0,y:0},v()},[t,x,a,v,p,_,JSON.stringify(d),JSON.stringify(b),S,c,y,h,JSON.stringify(g)])}const fu={x:{[nt.Backward]:!1,[nt.Forward]:!1},y:{[nt.Backward]:!1,[nt.Forward]:!1}};function mu(e){let{delta:t,disabled:r}=e;const a=ur(t);return Us(m=>{if(r||!a||!m)return fu;const p={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[nt.Backward]:m.x[nt.Backward]||p.x===-1,[nt.Forward]:m.x[nt.Forward]||p.x===1},y:{[nt.Backward]:m.y[nt.Backward]||p.y===-1,[nt.Forward]:m.y[nt.Forward]||p.y===1}}},[r,t,a])}function pu(e,t){const r=t!=null?e.get(t):void 0,a=r?r.node.current:null;return Us(m=>{var p;return t==null?null:(p=a??m)!=null?p:null},[a,t])}function gu(e,t){return C.useMemo(()=>e.reduce((r,a)=>{const{sensor:m}=a,p=m.activators.map(_=>({eventName:_.eventName,handler:t(_.handler,a)}));return[...r,...p]},[]),[e,t])}var Bs;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Bs||(Bs={}));var yi;(function(e){e.Optimized="optimized"})(yi||(yi={}));const Pn=new Map;function vu(e,t){let{dragging:r,dependencies:a,config:m}=t;const[p,_]=C.useState(null),{frequency:i,measure:n,strategy:c}=m,h=C.useRef(e),l=o(),g=Os(l),b=C.useCallback(function(f){f===void 0&&(f=[]),!g.current&&_(d=>d===null?f:d.concat(f.filter(u=>!d.includes(u))))},[g]),S=C.useRef(null),v=Us(f=>{if(l&&!r)return Pn;if(!f||f===Pn||h.current!==e||p!=null){const d=new Map;for(let u of e){if(!u)continue;if(p&&p.length>0&&!p.includes(u.id)&&u.rect.current){d.set(u.id,u.rect.current);continue}const x=u.node.current,y=x?new Yi(n(x),x):null;u.rect.current=y,y&&d.set(u.id,y)}return d}return f},[e,p,r,l,n]);return C.useEffect(()=>{h.current=e},[e]),C.useEffect(()=>{l||b()},[r,l]),C.useEffect(()=>{p&&p.length>0&&_(null)},[JSON.stringify(p)]),C.useEffect(()=>{l||typeof i!="number"||S.current!==null||(S.current=setTimeout(()=>{b(),S.current=null},i))},[i,l,b,...a]),{droppableRects:v,measureDroppableContainers:b,measuringScheduled:p!=null};function o(){switch(c){case Bs.Always:return!1;case Bs.BeforeDragging:return r;default:return!r}}}function Qi(e,t){return Us(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function _u(e,t){return Qi(e,t)}function xu(e){let{callback:t,disabled:r}=e;const a=jr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(a)},[a,r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function Rr(e){let{callback:t,disabled:r}=e;const a=jr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(a)},[r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function bu(e){return new Yi(qs(e),e)}function On(e,t,r){t===void 0&&(t=bu);const[a,m]=C.useState(null);function p(){m(n=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=n??r)!=null?c:null}const h=t(e);return JSON.stringify(n)===JSON.stringify(h)?n:h})}const _=xu({callback(n){if(e)for(const c of n){const{type:h,target:l}=c;if(h==="childList"&&l instanceof HTMLElement&&l.contains(e)){p();break}}}}),i=Rr({callback:p});return Ht(()=>{p(),e?(i?.observe(e),_?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),_?.disconnect())},[e]),a}function yu(e){const t=Qi(e);return sa(e,t)}const In=[];function Su(e){const t=C.useRef(e),r=Us(a=>e?a&&a!==In&&e&&t.current&&e.parentNode===t.current.parentNode?a:Xi(e):In,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function wu(e){const[t,r]=C.useState(null),a=C.useRef(e),m=C.useCallback(p=>{const _=Zr(p.target);_&&r(i=>i?(i.set(_,xi(_)),new Map(i)):null)},[]);return C.useEffect(()=>{const p=a.current;if(e!==p){_(p);const i=e.map(n=>{const c=Zr(n);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,xi(c)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),a.current=e}return()=>{_(e),_(p)};function _(i){i.forEach(n=>{const c=Zr(n);c?.removeEventListener("scroll",m)})}},[m,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((p,_)=>ms(p,_),Tt):ca(e):Tt,[e,t])}function Bn(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const a=e!==Tt;a&&!r.current&&(r.current=e),!a&&r.current&&(r.current=null)},[e]),r.current?hr(e,r.current):Tt}function Cu(e){C.useEffect(()=>{if(!Er)return;const t=e.map(r=>{let{sensor:a}=r;return a.setup==null?void 0:a.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function ku(e,t){return C.useMemo(()=>e.reduce((r,a)=>{let{eventName:m,handler:p}=a;return r[m]=_=>{p(_,t)},r},{}),[e,t])}function fa(e){return C.useMemo(()=>e?Gd(e):null,[e])}const Fn=[];function Eu(e,t){t===void 0&&(t=qs);const[r]=e,a=fa(r?ut(r):null),[m,p]=C.useState(Fn);function _(){p(()=>e.length?e.map(n=>aa(n)?a:new Yi(t(n),n)):Fn)}const i=Rr({callback:_});return Ht(()=>{i?.disconnect(),_(),e.forEach(n=>i?.observe(n))},[e]),m}function ma(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return $s(t)?t:e}function ju(e){let{measure:t}=e;const[r,a]=C.useState(null),m=C.useCallback(c=>{for(const{target:h}of c)if($s(h)){a(l=>{const g=t(h);return l?{...l,width:g.width,height:g.height}:g});break}},[t]),p=Rr({callback:m}),_=C.useCallback(c=>{const h=ma(c);p?.disconnect(),h&&p?.observe(h),a(h?t(h):null)},[t,p]),[i,n]=dr(_);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const Nu=[{sensor:Gi,options:{}},{sensor:ha,options:{}}],Ru={current:{}},nr={draggable:{measure:Tn},droppable:{measure:Tn,strategy:Bs.WhileDragging,frequency:yi.Optimized},dragOverlay:{measure:qs}};class As extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,a;return(r=(a=this.get(t))==null?void 0:a.node.current)!=null?r:void 0}}const Au={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new As,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nr,measureDroppableContainers:mr,windowRect:null,measuringScheduled:!1},pa={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mr,draggableNodes:new Map,over:null,measureDroppableContainers:mr},Ks=C.createContext(pa),ga=C.createContext(Au);function Tu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new As}}}function Mu(e,t){switch(t.type){case Je.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Je.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Je.DragEnd:case Je.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Je.RegisterDroppable:{const{element:r}=t,{id:a}=r,m=new As(e.droppable.containers);return m.set(a,r),{...e,droppable:{...e.droppable,containers:m}}}case Je.SetDroppableDisabled:{const{id:r,key:a,disabled:m}=t,p=e.droppable.containers.get(r);if(!p||a!==p.key)return e;const _=new As(e.droppable.containers);return _.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:_}}}case Je.UnregisterDroppable:{const{id:r,key:a}=t,m=e.droppable.containers.get(r);if(!m||a!==m.key)return e;const p=new As(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function Du(e){let{disabled:t}=e;const{active:r,activatorEvent:a,draggableNodes:m}=C.useContext(Ks),p=ur(a),_=ur(r?.id);return C.useEffect(()=>{if(!t&&!a&&p&&_!=null){if(!Ki(p)||document.activeElement===p.target)return;const i=m.get(_);if(!i)return;const{activatorNode:n,node:c}=i;if(!n.current&&!c.current)return;requestAnimationFrame(()=>{for(const h of[n.current,c.current]){if(!h)continue;const l=Nd(h);if(l){l.focus();break}}})}},[a,t,m,_,p]),null}function va(e,t){let{transform:r,...a}=t;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...a}),r):r}function Lu(e){return C.useMemo(()=>({draggable:{...nr.draggable,...e?.draggable},droppable:{...nr.droppable,...e?.droppable},dragOverlay:{...nr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Pu(e){let{activeNode:t,measure:r,initialRect:a,config:m=!0}=e;const p=C.useRef(!1),{x:_,y:i}=typeof m=="boolean"?{x:m,y:m}:m;Ht(()=>{if(!_&&!i||!t){p.current=!1;return}if(p.current||!a)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const h=r(c),l=sa(h,a);if(_||(l.x=0),i||(l.y=0),p.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=ia(c);g&&g.scrollBy({top:l.y,left:l.x})}},[t,_,i,a,r])}const Ar=C.createContext({...Tt,scaleX:1,scaleY:1});var Xt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Xt||(Xt={}));const Ou=C.memo(function(t){var r,a,m,p;let{id:_,accessibility:i,autoScroll:n=!0,children:c,sensors:h=Nu,collisionDetection:l=Ud,measuring:g,modifiers:b,...S}=t;const v=C.useReducer(Mu,void 0,Tu),[o,f]=v,[d,u]=Ld(),[x,y]=C.useState(Xt.Uninitialized),k=x===Xt.Initialized,{draggable:{active:j,nodes:w,translate:E},droppable:{containers:N}}=o,T=j!=null?w.get(j):null,R=C.useRef({initial:null,translated:null}),M=C.useMemo(()=>{var ke;return j!=null?{id:j,data:(ke=T?.data)!=null?ke:Ru,rect:R}:null},[j,T]),O=C.useRef(null),[B,F]=C.useState(null),[z,A]=C.useState(null),L=Os(S,Object.values(S)),P=Nr("DndDescribedBy",_),I=C.useMemo(()=>N.getEnabled(),[N]),$=Lu(g),{droppableRects:X,measureDroppableContainers:V,measuringScheduled:se}=vu(I,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),ae=pu(w,j),D=C.useMemo(()=>z?fr(z):null,[z]),H=He(),q=_u(ae,$.draggable.measure);Pu({activeNode:j!=null?w.get(j):null,config:H.layoutShiftCompensation,initialRect:q,measure:$.draggable.measure});const W=On(ae,$.draggable.measure,q),Y=On(ae?ae.parentElement:null),Q=C.useRef({activatorEvent:null,active:null,activeNode:ae,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=N.getNodeFor((r=Q.current.over)==null?void 0:r.id),de=ju({measure:$.dragOverlay.measure}),je=(a=de.nodeRef.current)!=null?a:ae,ze=k?(m=de.rect)!=null?m:W:null,re=!!(de.nodeRef.current&&de.rect),Te=yu(re?null:W),Ue=fa(je?ut(je):null),Ae=Su(k?oe??ae:null),Se=Eu(Ae),U=va(b,{transform:{x:E.x-Te.x,y:E.y-Te.y,scaleX:1,scaleY:1},activatorEvent:z,active:M,activeNodeRect:W,containerNodeRect:Y,draggingNodeRect:ze,over:Q.current.over,overlayNodeRect:de.rect,scrollableAncestors:Ae,scrollableAncestorRects:Se,windowRect:Ue}),ee=D?ms(D,E):null,ie=wu(Ae),pe=Bn(ie),he=Bn(ie,[W]),qe=ms(U,pe),we=ze?Xd(ze,U):null,Ge=M&&we?l({active:M,collisionRect:we,droppableRects:X,droppableContainers:I,pointerCoordinates:ee}):null,Ce=Wd(Ge,"id"),[K,G]=C.useState(null),fe=re?U:ms(U,he),ge=qd(fe,(p=K?.rect)!=null?p:null,W),xe=C.useRef(null),Ne=C.useCallback((ke,tt)=>{let{sensor:Qe,options:mt}=tt;if(O.current==null)return;const st=w.get(O.current);if(!st)return;const Ee=ke.nativeEvent,ct=new Qe({active:O.current,activeNode:st,event:Ee,options:mt,context:Q,onAbort(We){if(!w.get(We))return;const{onDragAbort:Re}=L.current,gt={id:We};Re?.(gt),d({type:"onDragAbort",event:gt})},onPending(We,St,Re,gt){if(!w.get(We))return;const{onDragPending:Nt}=L.current,ot={id:We,constraint:St,initialCoordinates:Re,offset:gt};Nt?.(ot),d({type:"onDragPending",event:ot})},onStart(We){const St=O.current;if(St==null)return;const Re=w.get(St);if(!Re)return;const{onDragStart:gt}=L.current,jt={activatorEvent:Ee,active:{id:St,data:Re.data,rect:R}};Vt.unstable_batchedUpdates(()=>{gt?.(jt),y(Xt.Initializing),f({type:Je.DragStart,initialCoordinates:We,active:St}),d({type:"onDragStart",event:jt}),F(xe.current),A(Ee)})},onMove(We){f({type:Je.DragMove,coordinates:We})},onEnd:pt(Je.DragEnd),onCancel:pt(Je.DragCancel)});xe.current=ct;function pt(We){return async function(){const{active:Re,collisions:gt,over:jt,scrollAdjustedTranslate:Nt}=Q.current;let ot=null;if(Re&&Nt){const{cancelDrop:vt}=L.current;ot={activatorEvent:Ee,active:Re,collisions:gt,delta:Nt,over:jt},We===Je.DragEnd&&typeof vt=="function"&&await Promise.resolve(vt(ot))&&(We=Je.DragCancel)}O.current=null,Vt.unstable_batchedUpdates(()=>{f({type:We}),y(Xt.Uninitialized),G(null),F(null),A(null),xe.current=null;const vt=We===Je.DragEnd?"onDragEnd":"onDragCancel";if(ot){const Wt=L.current[vt];Wt?.(ot),d({type:vt,event:ot})}})}}},[w]),Ze=C.useCallback((ke,tt)=>(Qe,mt)=>{const st=Qe.nativeEvent,Ee=w.get(mt);if(O.current!==null||!Ee||st.dndKit||st.defaultPrevented)return;const ct={active:Ee};ke(Qe,tt.options,ct)===!0&&(st.dndKit={capturedBy:tt.sensor},O.current=mt,Ne(Qe,tt))},[w,Ne]),Mt=gu(h,Ze);Cu(h),Ht(()=>{W&&x===Xt.Initializing&&y(Xt.Initialized)},[W,x]),C.useEffect(()=>{const{onDragMove:ke}=L.current,{active:tt,activatorEvent:Qe,collisions:mt,over:st}=Q.current;if(!tt||!Qe)return;const Ee={active:tt,activatorEvent:Qe,collisions:mt,delta:{x:qe.x,y:qe.y},over:st};Vt.unstable_batchedUpdates(()=>{ke?.(Ee),d({type:"onDragMove",event:Ee})})},[qe.x,qe.y]),C.useEffect(()=>{const{active:ke,activatorEvent:tt,collisions:Qe,droppableContainers:mt,scrollAdjustedTranslate:st}=Q.current;if(!ke||O.current==null||!tt||!st)return;const{onDragOver:Ee}=L.current,ct=mt.get(Ce),pt=ct&&ct.rect.current?{id:ct.id,rect:ct.rect.current,data:ct.data,disabled:ct.disabled}:null,We={active:ke,activatorEvent:tt,collisions:Qe,delta:{x:st.x,y:st.y},over:pt};Vt.unstable_batchedUpdates(()=>{G(pt),Ee?.(We),d({type:"onDragOver",event:We})})},[Ce]),Ht(()=>{Q.current={activatorEvent:z,active:M,activeNode:ae,collisionRect:we,collisions:Ge,droppableRects:X,draggableNodes:w,draggingNode:je,draggingNodeRect:ze,droppableContainers:N,over:K,scrollableAncestors:Ae,scrollAdjustedTranslate:qe},R.current={initial:ze,translated:we}},[M,ae,Ge,we,w,je,ze,X,N,K,Ae,qe]),hu({...H,delta:E,draggingRect:we,pointerCoordinates:ee,scrollableAncestors:Ae,scrollableAncestorRects:Se});const Oe=C.useMemo(()=>({active:M,activeNode:ae,activeNodeRect:W,activatorEvent:z,collisions:Ge,containerNodeRect:Y,dragOverlay:de,draggableNodes:w,droppableContainers:N,droppableRects:X,over:K,measureDroppableContainers:V,scrollableAncestors:Ae,scrollableAncestorRects:Se,measuringConfiguration:$,measuringScheduled:se,windowRect:Ue}),[M,ae,W,z,Ge,Y,de,w,N,X,K,V,Ae,Se,$,se,Ue]),Ke=C.useMemo(()=>({activatorEvent:z,activators:Mt,active:M,activeNodeRect:W,ariaDescribedById:{draggable:P},dispatch:f,draggableNodes:w,over:K,measureDroppableContainers:V}),[z,Mt,M,W,f,P,w,K,V]);return ne.createElement(ta.Provider,{value:u},ne.createElement(Ks.Provider,{value:Ke},ne.createElement(ga.Provider,{value:Oe},ne.createElement(Ar.Provider,{value:ge},c)),ne.createElement(Du,{disabled:i?.restoreFocus===!1})),ne.createElement(Id,{...i,hiddenTextDescribedById:P}));function He(){const ke=B?.autoScrollEnabled===!1,tt=typeof n=="object"?n.enabled===!1:n===!1,Qe=k&&!ke&&!tt;return typeof n=="object"?{...n,enabled:Qe}:{enabled:Qe}}}),Iu=C.createContext(null),zn="button",Bu="Draggable";function Fu(e){let{id:t,data:r,disabled:a=!1,attributes:m}=e;const p=Nr(Bu),{activators:_,activatorEvent:i,active:n,activeNodeRect:c,ariaDescribedById:h,draggableNodes:l,over:g}=C.useContext(Ks),{role:b=zn,roleDescription:S="draggable",tabIndex:v=0}=m??{},o=n?.id===t,f=C.useContext(o?Ar:Iu),[d,u]=dr(),[x,y]=dr(),k=ku(_,t),j=Os(r);Ht(()=>(l.set(t,{id:t,key:p,node:d,activatorNode:x,data:j}),()=>{const E=l.get(t);E&&E.key===p&&l.delete(t)}),[l,t]);const w=C.useMemo(()=>({role:b,tabIndex:v,"aria-disabled":a,"aria-pressed":o&&b===zn?!0:void 0,"aria-roledescription":S,"aria-describedby":h.draggable}),[a,b,v,o,S,h.draggable]);return{active:n,activatorEvent:i,activeNodeRect:c,attributes:w,isDragging:o,listeners:a?void 0:k,node:d,over:g,setNodeRef:u,setActivatorNodeRef:y,transform:f}}function zu(){return C.useContext(ga)}const Hu="Droppable",Wu={timeout:25};function $u(e){let{data:t,disabled:r=!1,id:a,resizeObserverConfig:m}=e;const p=Nr(Hu),{active:_,dispatch:i,over:n,measureDroppableContainers:c}=C.useContext(Ks),h=C.useRef({disabled:r}),l=C.useRef(!1),g=C.useRef(null),b=C.useRef(null),{disabled:S,updateMeasurementsFor:v,timeout:o}={...Wu,...m},f=Os(v??a),d=C.useCallback(()=>{if(!l.current){l.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{c(Array.isArray(f.current)?f.current:[f.current]),b.current=null},o)},[o]),u=Rr({callback:d,disabled:S||!_}),x=C.useCallback((w,E)=>{u&&(E&&(u.unobserve(E),l.current=!1),w&&u.observe(w))},[u]),[y,k]=dr(x),j=Os(t);return C.useEffect(()=>{!u||!y.current||(u.disconnect(),l.current=!1,u.observe(y.current))},[y,u]),C.useEffect(()=>(i({type:Je.RegisterDroppable,element:{id:a,key:p,disabled:r,node:y,rect:g,data:j}}),()=>i({type:Je.UnregisterDroppable,key:p,id:a})),[a]),C.useEffect(()=>{r!==h.current.disabled&&(i({type:Je.SetDroppableDisabled,id:a,key:p,disabled:r}),h.current.disabled=r)},[a,p,r,i]),{active:_,rect:g,isOver:n?.id===a,node:y,over:n,setNodeRef:k}}function Uu(e){let{animation:t,children:r}=e;const[a,m]=C.useState(null),[p,_]=C.useState(null),i=ur(r);return!r&&!a&&i&&m(i),Ht(()=>{if(!p)return;const n=a?.key,c=a?.props.id;if(n==null||c==null){m(null);return}Promise.resolve(t(c,p)).then(()=>{m(null)})},[t,a,p]),ne.createElement(ne.Fragment,null,r,a?C.cloneElement(a,{ref:_}):null)}const qu={x:0,y:0,scaleX:1,scaleY:1};function Ku(e){let{children:t}=e;return ne.createElement(Ks.Provider,{value:pa},ne.createElement(Ar.Provider,{value:qu},t))}const Xu={position:"fixed",touchAction:"none"},Yu=e=>Ki(e)?"transform 250ms ease":void 0,Vu=C.forwardRef((e,t)=>{let{as:r,activatorEvent:a,adjustScale:m,children:p,className:_,rect:i,style:n,transform:c,transition:h=Yu}=e;if(!i)return null;const l=m?c:{...c,scaleX:1,scaleY:1},g={...Xu,width:i.width,height:i.height,top:i.top,left:i.left,transform:Is.Transform.toString(l),transformOrigin:m&&a?zd(a,i):void 0,transition:typeof h=="function"?h(a):h,...n};return ne.createElement(r,{className:_,style:g,ref:t},p)}),Gu=e=>t=>{let{active:r,dragOverlay:a}=t;const m={},{styles:p,className:_}=e;if(p!=null&&p.active)for(const[i,n]of Object.entries(p.active))n!==void 0&&(m[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(p!=null&&p.dragOverlay)for(const[i,n]of Object.entries(p.dragOverlay))n!==void 0&&a.node.style.setProperty(i,n);return _!=null&&_.active&&r.node.classList.add(_.active),_!=null&&_.dragOverlay&&a.node.classList.add(_.dragOverlay),function(){for(const[n,c]of Object.entries(m))r.node.style.setProperty(n,c);_!=null&&_.active&&r.node.classList.remove(_.active)}},Qu=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:Is.Transform.toString(t)},{transform:Is.Transform.toString(r)}]},Zu={duration:250,easing:"ease",keyframes:Qu,sideEffects:Gu({styles:{active:{opacity:"0"}}})};function Ju(e){let{config:t,draggableNodes:r,droppableContainers:a,measuringConfiguration:m}=e;return jr((p,_)=>{if(t===null)return;const i=r.get(p);if(!i)return;const n=i.node.current;if(!n)return;const c=ma(_);if(!c)return;const{transform:h}=ut(_).getComputedStyle(_),l=ra(h);if(!l)return;const g=typeof t=="function"?t:eh(t);return da(n,m.draggable.measure),g({active:{id:p,data:i.data,node:n,rect:m.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:_,rect:m.dragOverlay.measure(c)},droppableContainers:a,measuringConfiguration:m,transform:l})})}function eh(e){const{duration:t,easing:r,sideEffects:a,keyframes:m}={...Zu,...e};return p=>{let{active:_,dragOverlay:i,transform:n,...c}=p;if(!t)return;const h={x:i.rect.left-_.rect.left,y:i.rect.top-_.rect.top},l={scaleX:n.scaleX!==1?_.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?_.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-h.x,y:n.y-h.y,...l},b=m({...c,active:_,dragOverlay:i,transform:{initial:n,final:g}}),[S]=b,v=b[b.length-1];if(JSON.stringify(S)===JSON.stringify(v))return;const o=a?.({active:_,dragOverlay:i,...c}),f=i.node.animate(b,{duration:t,easing:r,fill:"forwards"});return new Promise(d=>{f.onfinish=()=>{o?.(),d()}})}}let Hn=0;function th(e){return C.useMemo(()=>{if(e!=null)return Hn++,Hn},[e])}const sh=ne.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:a,style:m,transition:p,modifiers:_,wrapperElement:i="div",className:n,zIndex:c=999}=e;const{activatorEvent:h,active:l,activeNodeRect:g,containerNodeRect:b,draggableNodes:S,droppableContainers:v,dragOverlay:o,over:f,measuringConfiguration:d,scrollableAncestors:u,scrollableAncestorRects:x,windowRect:y}=zu(),k=C.useContext(Ar),j=th(l?.id),w=va(_,{activatorEvent:h,active:l,activeNodeRect:g,containerNodeRect:b,draggingNodeRect:o.rect,over:f,overlayNodeRect:o.rect,scrollableAncestors:u,scrollableAncestorRects:x,transform:k,windowRect:y}),E=Qi(g),N=Ju({config:a,draggableNodes:S,droppableContainers:v,measuringConfiguration:d}),T=E?o.setRef:void 0;return ne.createElement(Ku,null,ne.createElement(Uu,{animation:N},l&&j?ne.createElement(Vu,{key:j,id:l.id,ref:T,as:i,activatorEvent:h,adjustScale:t,className:n,transition:p,rect:E,style:{zIndex:c,...m},transform:w},r):null))}),_a=768;function rh(e){const t=window.matchMedia(`(max-width: ${_a-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function ih(){return window.innerWidth<_a}function nh(){return!1}function xa(){return C.useSyncExternalStore(rh,ih,nh)}function Zi(e){return yt({queryKey:le.workspaces.list(e),queryFn:()=>_e.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ba(e){const t=et();return ft({mutationFn:r=>_e.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{t.invalidateQueries({queryKey:le.workspaces.list(e)}),t.invalidateQueries({queryKey:le.tasks.all})}})}function oh(){const e=et();return ft({mutationFn:({id:t,commitMessage:r})=>_e.post(`/workspaces/${t}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.git.all})},onError:()=>{e.invalidateQueries({queryKey:le.git.all})}})}function ah(){const e=et();return ft({mutationFn:t=>_e.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Ji(){return ft({mutationFn:({workspaceId:e,editorType:t})=>_e.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function en(e){return yt({queryKey:le.workspaces.gitStatus(e),queryFn:()=>_e.get(`/workspaces/${e}/git-status`),enabled:!!e})}function lh(){const e=et();return ft({mutationFn:t=>_e.post(`/workspaces/${t}/rebase`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})},onError:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})}})}function ya(){const e=et();return ft({mutationFn:t=>_e.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})}})}function ch(e,t){const r=[];if(!e||e.length===0)return r;const a=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(_=>_.status===Ye.RUNNING||_.status===Ye.PENDING))&&r.push(t("正在运行的 Agent 将被停止")),a&&(r.push(t("分支上未合并的变更将丢失")),r.push(t("关联的工作目录(worktree)将被清理"))),r}function tn({isOpen:e,onClose:t,onConfirm:r,taskId:a,taskTitle:m,workspaces:p,isLoading:_}){const{t:i}=ce(),{data:n,isLoading:c}=Zi(p===void 0&&e?a:""),h=p??n,l=p===void 0&&e&&c,g=C.useMemo(()=>ch(h,i),[h,i]);return s.jsx(Ii,{isOpen:e,onClose:t,onConfirm:r,title:i("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:m})}),l?s.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?s.jsx("ul",{className:"mt-2 space-y-1",children:g.map((b,S)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:b})]},S))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:_||l})}const me={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},dh=[{status:me.Review,label:"Review",icon:Ai,color:"text-amber-600"},{status:me.Running,label:"Running",icon:Ti,color:"text-blue-600"},{status:me.Pending,label:"Pending",icon:Mi,color:"text-neutral-600"},{status:me.Done,label:"Done",icon:Di,color:"text-emerald-600"},{status:me.Cancelled,label:"Cancelled",icon:Li,color:"text-neutral-500"}];function uh({task:e,status:t,isSelected:r,isAgentActive:a,project:m,onSelectTask:p,onTaskStatusChange:_,onDeleteTask:i,disableDrag:n}){const{t:c}=ce(),h=!!e.projectArchivedAt,l=h||!!n,{attributes:g,listeners:b,setNodeRef:S,isDragging:v}=Fu({id:e.id,data:{task:e,fromStatus:t},disabled:l}),[o,f]=C.useState(null),[d,u]=C.useState(!1),x=C.useRef(null),y=C.useRef(null),k=C.useCallback(E=>{h||!_&&!i||(E.preventDefault(),f({x:E.clientX,y:E.clientY}))},[h,_,i]),j=C.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),w=C.useCallback(E=>{if(!n||h||!_&&!i)return;const N=E.touches[0];if(!N)return;const{clientX:T,clientY:R}=N;y.current=setTimeout(()=>{y.current=null,f({x:T,y:R})},500)},[n,h,_,i]);return C.useEffect(()=>{if(!o)return;const E=N=>{x.current&&!x.current.contains(N.target)&&f(null)};return document.addEventListener("mousedown",E),document.addEventListener("touchstart",E),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("touchstart",E)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:S,onClick:()=>p(e.id),onContextMenu:k,onTouchStart:w,onTouchEnd:j,onTouchMove:j,className:`flex items-start pl-7 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
6
|
+
${v?"opacity-30":""}
|
|
7
|
+
${r?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l?{}:b,...l?{}:g,children:[s.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===me.Running?"text-blue-600":"text-neutral-500"}`,children:[t===me.Review&&s.jsx(Ai,{className:r?"text-amber-600":"text-neutral-500"}),t===me.Running&&s.jsx(Ti,{className:"animate-pulse"}),t===me.Pending&&s.jsx(Mi,{}),t===me.Done&&s.jsx(Di,{className:"text-neutral-400"}),t===me.Cancelled&&s.jsx(Li,{className:"text-neutral-400"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center",children:[s.jsx("span",{className:`mr-1 max-w-[45%] shrink-0 truncate font-medium ${m?.color||"text-neutral-500"}`,title:m?.name,children:m?.name}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:"/"}),s.jsx("span",{className:`ml-1 min-w-0 flex-1 truncate ${r?"text-neutral-900":"text-neutral-700"}`,title:e.title,children:e.title}),e.projectArchivedAt&&s.jsx("span",{className:"ml-1.5 inline-flex shrink-0 items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),a&&s.jsxs("span",{className:"relative ml-1.5 inline-flex h-2 w-2 shrink-0 align-middle",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),s.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${r?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),o&&s.jsxs("div",{ref:x,className:"fixed z-[100] w-44 bg-white rounded-lg border border-neutral-200 shadow-xl py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:o.x,top:o.y},children:[_&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:c("Move to")}),dh.filter(E=>E.status!==t).map(E=>{const N=E.icon;return s.jsxs("button",{onClick:()=>{_(e.id,E.status),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[s.jsx(N,{className:`w-3.5 h-3.5 ${E.color}`}),s.jsx("span",{className:"text-neutral-700",children:c(E.label)})]},E.status)})]}),i&&s.jsxs(s.Fragment,{children:[_&&s.jsx("div",{className:"my-1 border-t border-neutral-100"}),s.jsxs("button",{onClick:()=>{u(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors",children:[s.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:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),s.jsx("span",{children:c("Delete Task")})]})]})]}),s.jsx(tn,{isOpen:d,onClose:()=>u(!1),onConfirm:()=>{i?.(e.id),u(!1)},taskId:e.id,taskTitle:e.title})]})}const hh=C.memo(function({title:t,tasks:r,status:a,defaultOpen:m,selectedTaskId:p,onSelectTask:_,projects:i,activeTaskIds:n,isDragging:c,dragFromStatus:h,onTaskStatusChange:l,onDeleteTask:g,disableDrag:b}){const{t:S}=ce(),[v,o]=C.useState(m),f=r.length===0,d=c&&h===a,u=c&&h!==a,{setNodeRef:x,isOver:y}=$u({id:`group-${a}`,data:{status:a}}),k=a===me.Review,j=S(t),w=c?d&&(v||!0):v;return s.jsxs("div",{className:"mb-2",children:[s.jsxs("button",{onClick:()=>!c&&o(E=>!E),className:"flex items-center w-full px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx("span",{className:"mr-2 text-neutral-400",children:w?s.jsx(lt,{size:14}):s.jsx(It,{size:14})}),s.jsx("span",{className:"flex-1 text-left",children:j}),k&&!f?s.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:r.length}):s.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",r.length,")"]})]}),u&&s.jsx("div",{ref:x,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
8
|
+
${y?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:s.jsx("span",{className:"text-xs font-medium",children:y?S("Drop into {title}",{title:j}):S("Drop here")})}),w&&!u&&s.jsx("div",{ref:d?void 0:x,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
|
|
9
|
+
${y&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
|
|
10
|
+
${f&&c?"border border-dashed border-neutral-300":""}`,children:f?s.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-7",children:S("No tasks")}):r.map(E=>{const N=i.find(M=>M.id===E.projectId),T=p===E.id,R=n?.has(E.id)??!1;return s.jsx(uh,{task:E,status:a,isSelected:T,isAgentActive:R,project:N,onSelectTask:_,onTaskStatusChange:E.projectArchivedAt?void 0:l,onDeleteTask:E.projectArchivedAt?void 0:g,disableDrag:b},E.id)})})]})});function fh(e){const t={[me.Review]:[],[me.Running]:[],[me.Pending]:[],[me.Done]:[],[me.Cancelled]:[]};for(const r of e)t[r.status].push(r);return t}const mh=[{status:me.Review,title:"Review",defaultOpen:!0},{status:me.Running,title:"Running",defaultOpen:!0},{status:me.Pending,title:"Pending",defaultOpen:!1},{status:me.Done,title:"Done",defaultOpen:!1},{status:me.Cancelled,title:"Cancelled",defaultOpen:!1}];function Wn({tasks:e=[],projects:t=[],selectedTaskId:r,onSelectTask:a,filterProjectId:m,setFilterProjectId:p,width:_=320,onCreateProject:i,onCreateTask:n,activeTaskIds:c,onTaskStatusChange:h,onDeleteTask:l}){const{t:g}=ce(),b=xa(),[S,v]=C.useState(!1),[o,f]=C.useState(null),[d,u]=C.useState(null),x=Fd(Bd(Gi,{activationConstraint:{distance:8}})),y=C.useCallback(O=>{const B=O.active.data.current?.task,F=O.active.data.current?.fromStatus;B&&f(B),F&&u(F)},[]),k=C.useCallback(O=>{f(null),u(null);const{active:B,over:F}=O;if(!F)return;const z=B.data.current?.task,A=B.data.current?.fromStatus,L=F.data.current?.status;!z||!A||!L||z.projectArchivedAt||A!==L&&h?.(z.id,L)},[h]),j=m?e.filter(O=>O.projectId===m):e,w=m?t.find(O=>O.id===m)??null:null,E=t.filter(O=>!O.archivedAt),T=!!!w?.archivedAt,R=fh(j),M=_==="100%";return s.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${M?"":"border-r border-neutral-200"}`,style:{width:_},children:[s.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[s.jsxs("div",{className:"relative flex-1 mr-2",children:[s.jsxs("button",{onClick:()=>v(O=>!O),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),s.jsx("span",{className:"truncate",children:w.name})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ps,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),s.jsx("span",{children:g("All Projects")})]}),s.jsx(lt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${S?"rotate-180":""}`})]}),S?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>v(!1)}),s.jsxs("div",{className:"absolute left-0 top-full mt-1 w-56 bg-white border border-neutral-200 rounded-lg shadow-xl shadow-neutral-200/50 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[s.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:g("Select View")}),s.jsxs("button",{onClick:()=>{p(null),v(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded border border-neutral-200 bg-neutral-50 text-neutral-500 group-hover:border-neutral-300",children:s.jsx(Ps,{size:12})}),s.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:g("All Projects")})]}),m===null?s.jsx(ht,{size:14,className:"text-neutral-900"}):null]}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),E.map(O=>{const B=m===O.id,F=O.color.replace("text-","bg-");return s.jsxs("button",{onClick:()=>{p(O.id),v(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${F}`}),s.jsx("span",{className:B?"text-neutral-900 font-medium":"text-neutral-600",children:O.name})]}),B?s.jsx(ht,{size:14,className:"text-neutral-900"}):null]},O.id)}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),s.jsxs("button",{onClick:()=>{v(!1),i?.()},className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx(vs,{size:14}),s.jsx("span",{children:g("Create New Project...")})]})]})]}):null]}),s.jsx("button",{onClick:n,disabled:!T,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:g(T?"New Task":"Deleted projects are read-only"),children:s.jsx(vs,{size:18})})]}),s.jsxs(Ou,{sensors:x,onDragStart:y,onDragEnd:k,children:[s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin py-4 relative",children:mh.map(({status:O,title:B,defaultOpen:F})=>s.jsx(hh,{title:B,tasks:R[O],status:O,defaultOpen:F,selectedTaskId:r,onSelectTask:a,projects:t,activeTaskIds:c,isDragging:o!==null,dragFromStatus:d,onTaskStatusChange:h,onDeleteTask:l,disableDrag:b},O))}),s.jsx(sh,{dropAnimation:null,children:o?s.jsx("div",{className:"bg-white shadow-lg rounded-md border border-neutral-200 px-4 py-2 text-sm max-w-[280px] opacity-90",children:s.jsx("span",{className:"block truncate font-medium text-neutral-700",title:o.title,children:o.title})}):null})]}),j.length>0?s.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[s.jsx("span",{children:g("{count} tasks",{count:j.length})}),m?s.jsx("button",{onClick:()=>p(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:g("Clear filter")}):null]}):s.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:s.jsx("span",{children:g("{count} tasks",{count:0})})})]})}const ph={damping:.7,stiffness:.05,mass:1.25},gh=70,vh=1e3/60,_h=350;let Tr=!1;globalThis.document?.addEventListener("mousedown",()=>{Tr=!0});globalThis.document?.addEventListener("mouseup",()=>{Tr=!1});globalThis.document?.addEventListener("click",()=>{Tr=!1});const sn=(e={})=>{const[t,r]=C.useState(!1),[a,m]=C.useState(e.initial!==!1),[p,_]=C.useState(!1),i=C.useRef(null);i.current=e;const n=C.useCallback(()=>{if(!Tr)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const u=d.getRangeAt(0);return u.commonAncestorContainer.contains(o.current)||o.current?.contains(u.commonAncestorContainer)},[]),c=C.useCallback(d=>{l.isAtBottom=d,m(d)},[]),h=C.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=C.useMemo(()=>{let d;return{escapedFromLock:t,isAtBottom:a,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return o.current?.scrollTop??0},set scrollTop(u){o.current&&(o.current.scrollTop=u,l.ignoreScrollToTop=o.current.scrollTop)},get targetScrollTop(){return!o.current||!f.current?0:o.current.scrollHeight-1-o.current.clientHeight},get calculatedTargetScrollTop(){if(!o.current||!f.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(d?.targetScrollTop===u)return d.calculatedScrollTop;const x=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:o.current,contentElement:f.current}),u),0);return d={targetScrollTop:u,calculatedScrollTop:x},requestAnimationFrame(()=>{d=void 0}),x},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=gh}}},[]),g=C.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const u=Date.now()+(Number(d.wait)||0),x=si(i.current,d.animation),{ignoreEscapes:y=!1}=d;let k,j=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=u+(d.duration??0);const w=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:N}=l,T=performance.now(),R=(T-(l.lastTick??T))/vh;if(l.animation||(l.animation={behavior:x,promise:E,ignoreEscapes:y}),l.animation.behavior===x&&(l.lastTick=T),n()||u>Date.now())return w();if(N<Math.min(j,l.calculatedTargetScrollTop)){if(l.animation?.behavior===x){if(x==="instant")return l.scrollTop=l.calculatedTargetScrollTop,w();l.velocity=(x.damping*l.velocity+x.stiffness*l.scrollDifference)/x.mass,l.accumulated+=l.velocity*R,l.scrollTop+=l.accumulated,l.scrollTop!==N&&(l.accumulated=0)}return w()}return k>Date.now()?(j=l.calculatedTargetScrollTop,w()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:si(i.current,i.current.resize),ignoreEscapes:y,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return E.then(N=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),N))};return d.wait!==!0&&(l.animation=void 0),l.animation?.behavior===x?l.animation.promise:w()},[c,n,l]),b=C.useCallback(()=>{h(!0),c(!1)},[h,c]),S=C.useCallback(({target:d})=>{if(d!==o.current)return;const{scrollTop:u,ignoreScrollToTop:x}=l;let{lastScrollTop:y=u}=l;l.lastScrollTop=u,l.ignoreScrollToTop=void 0,x&&x>u&&(y=x),_(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||u===x)return;if(n()){h(!0),c(!1);return}const k=u>y,j=u<y;if(l.animation?.ignoreEscapes){l.scrollTop=y;return}j&&(h(!0),c(!1)),k&&h(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[h,c,n,l]),v=C.useCallback(({target:d,deltaY:u})=>{let x=d;for(;!["scroll","auto"].includes(getComputedStyle(x).overflow);){if(!x.parentElement)return;x=x.parentElement}x===o.current&&u<0&&o.current.scrollHeight>o.current.clientHeight&&!l.animation?.ignoreEscapes&&(h(!0),c(!1))},[h,c,l]),o=$n(d=>{o.current?.removeEventListener("scroll",S),o.current?.removeEventListener("wheel",v),d?.addEventListener("scroll",S,{passive:!0}),d?.addEventListener("wheel",v,{passive:!0})},[]),f=$n(d=>{if(l.resizeObserver?.disconnect(),!d)return;let u;l.resizeObserver=new ResizeObserver(([x])=>{const{height:y}=x.contentRect,k=y-(u??y);if(l.resizeDifference=k,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),_(l.isNearBottom),k>=0){const j=si(i.current,u?i.current.resize:i.current.initial);g({animation:j,wait:!0,preserveScrollPosition:!0,duration:j==="instant"?void 0:_h})}else l.isNearBottom&&(h(!1),c(!0));u=y,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===k&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:f,scrollRef:o,scrollToBottom:g,stopScroll:b,isAtBottom:a||p,isNearBottom:p,escapedFromLock:t,state:l}};function $n(e,t){const r=C.useCallback(a=>(r.current=a,e(a)),t);return r}const ti=new Map;function si(...e){const t={...ph};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,t.damping=m.damping??t.damping,t.stiffness=m.stiffness??t.stiffness,t.mass=m.mass??t.mass)}const a=JSON.stringify(t);return ti.has(a)||ti.set(a,Object.freeze(t)),r?"instant":ti.get(a)}function xh({content:e,children:t,className:r="",side:a="top"}){const m=a==="bottom"?"top-full mt-2":"bottom-full mb-2",p=a==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return s.jsxs("div",{className:`group/tooltip relative ${r}`,children:[t,s.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,s.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function Js(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function bh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function rn({usage:e,tooltipSide:t="top"}){const{t:r}=ce();if(!e)return null;const a=e.modelContextWindow,m=a?e.totalTokens/a:0,p=a?Math.min(Math.round(m*100),100):null,_=a?bh(m):"text-neutral-400",i=a?s.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:Js(e.totalTokens),max:Js(a)})}):s.jsx("span",{children:r("已使用: {used} tokens",{used:Js(e.totalTokens)})});return s.jsx(xh,{content:i,side:t,children:s.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:[s.jsx(Yc,{size:14,className:_}),s.jsxs("span",{className:`tabular-nums ${_}`,children:[Js(e.totalTokens),p!==null&&s.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const yh="/api";async function Sh(e){const t=new FormData;t.append("file",e);const r=await fetch(`${yh}/attachments/upload`,{method:"POST",body:t});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||`Upload failed (${r.status})`)}return r.json()}let wh=0;function Mr(){const[e,t]=C.useState([]),r=C.useRef(e);r.current=e;const a=C.useCallback(async l=>{const g=l.map(b=>({tempId:`tmp-${++wh}`,file:b,progress:0,status:"uploading"}));t(b=>[...b,...g]),await Promise.allSettled(g.map(async b=>{try{const S=await Sh(b.file);t(v=>v.map(o=>o.tempId===b.tempId?{...o,status:"done",progress:100,attachment:S}:o))}catch(S){t(v=>v.map(o=>o.tempId===b.tempId?{...o,status:"error",error:S instanceof Error?S.message:"Upload failed"}:o))}}))},[]),m=C.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),p=C.useCallback(l=>{t(g=>g.filter(b=>b.tempId!==l))},[]),_=C.useCallback(()=>{t([])},[]),i=C.useCallback(l=>{l.length!==0&&t(g=>{const b=new Set(g.map(v=>v.attachment?.id??v.tempId)),S=l.filter(v=>{const o=v.attachment?.id??v.tempId;return b.has(o)?!1:(b.add(o),!0)});return S.length>0?[...g,...S]:g})},[]),n=C.useCallback(()=>{const l=m();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
|
|
11
|
+
`)},[m]),c=e.length>0,h=e.some(l=>l.status==="uploading");return{files:e,addFiles:a,removeFile:p,clear:_,restoreFiles:i,buildMarkdownLinks:n,getDoneAttachments:m,hasFiles:c,isUploading:h}}function Ch(e){const t=C.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return yt({queryKey:["attachments","metadata",t],queryFn:()=>_e.get("/attachments/metadata",{params:{ids:t.join(",")}}),enabled:t.length>0,staleTime:300*1e3})}const kh="/api";function Eh(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Dr({files:e,onRemove:t}){return e.length===0?null:s.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>s.jsx(jh,{item:r,onRemove:t},r.tempId))})}function jh({item:e,onRemove:t}){const r=e.file.type.startsWith("image/"),a=e.status==="error",m=e.status==="uploading";return s.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${a?"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?s.jsx("img",{src:`${kh}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):s.jsx("span",{className:"flex-shrink-0",children:m?s.jsx(Fe,{size:16,className:"animate-spin text-neutral-400"}):r?s.jsx($i,{size:16,className:"text-neutral-400"}):s.jsx(Hi,{size:16,className:"text-neutral-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-medium",children:e.file.name}),a?s.jsx("div",{className:"truncate text-red-500",children:e.error}):s.jsx("div",{className:"text-neutral-400",children:Eh(e.file.size)})]}),s.jsx("button",{onClick:()=>t(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:s.jsx(Ot,{size:10})})]})}const Nh=10,Rh=24,Sa=Nh*Rh,Ah=8;function Th(e,t=Sa){return e>t+Ah}function Mh(e,t){return e.includes(t)?e:[...e,t]}function Dh(e,t){return e.filter(r=>r!==t)}function Lh(e,t){const r=new Map(t.map(a=>[a.id,a]));return e.map(a=>r.get(a)).filter(a=>!!a).map(a=>({memberId:a.id,label:a.name}))}const Lr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Un(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function Ph(e,t=[],r=[]){const a=new Set(r.filter(p=>Lr.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...t.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!a.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,_)=>{const i=Un(p.sortTime)-Un(_.sortTime);return i!==0?i:p.order!==_.order?p.order-_.order:p.key.localeCompare(_.key)})}function Oh(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 Ih(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 Bh(e,t){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 _=r[m];return _?`${_} ${t(p)}`:null}).filter(m=>!!m).join(" · ")}function Fh(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function zh({status:e}){const{t}=ce();return e==="RUNNING"?s.jsxs(s.Fragment,{children:[t("Working"),s.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[s.jsx("span",{children:"."}),s.jsx("span",{className:"active-work-dots__second",children:"."}),s.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):s.jsx(s.Fragment,{children:t(Oh(e))})}function Hh({invocations:e,memberById:t,workRequestById:r,onViewInvocationSession:a,onStopMember:m,isStopPending:p,stoppingMemberId:_,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:c}=ce(),[h,l]=C.useState(Fh),g=C.useMemo(()=>e.filter(S=>Lr.has(S.status)).sort((S,v)=>Date.parse(v.updatedAt??v.createdAt??"")-Date.parse(S.updatedAt??S.createdAt??"")),[e]);if(g.length===0)return null;const b=Bh(g,c);return s.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[s.jsxs("button",{type:"button",onClick:()=>l(S=>!S),"aria-expanded":h,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[s.jsxs("span",{className:"min-w-0 truncate",children:[s.jsx("span",{className:"font-medium text-neutral-800",children:c("Active work")}),s.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),s.jsx("span",{children:b})]}),h?s.jsx(lt,{size:15,className:"shrink-0 text-neutral-400"}):s.jsx(Xo,{size:15,className:"shrink-0 text-neutral-400"})]}),h&&s.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(S=>{const v=t.get(S.memberId),o=r.get(S.workRequestId),f=!!(S.sessionId&&a),d=!!v,u=i===S.id,x=p&&_===S.memberId,y=o?.instruction??S.workRequestId;return s.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[s.jsxs("div",{title:y,className:J("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&&a?.(S.sessionId),onKeyDown:k=>{!f||!S.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),a?.(S.sessionId))},children:[s.jsx(zt,{name:v?.name??c("Agent"),avatar:v?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[s.jsx("span",{className:"truncate font-medium text-neutral-800",children:v?.name??c("Agent")}),s.jsx("span",{className:J("shrink-0",Ih(S.status)),children:s.jsx(zh,{status:S.status})})]}),f&&s.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),S.sessionId&&a?.(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:c("View log"),"aria-label":`${c("View log")} ${v?.name??c("Agent")}`,children:s.jsx(lr,{size:13})}),d&&s.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(S.id)},onKeyDown:k=>k.stopPropagation(),disabled:x,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:c("Stop"),"aria-label":`${c("Stop")} ${v?.name??c("Agent")}`,children:s.jsx(gs,{size:12})})]}),d&&u&&v&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[s.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:c("Stop running work?")}),s.jsxs(Ve,{type:"button",size:"xs",variant:"outline",disabled:x,onClick:()=>m(v.id,!1),children:[s.jsx(gs,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop only")})]}),s.jsxs(Ve,{type:"button",size:"xs",variant:"outline",disabled:x,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>m(v.id,!0),children:[s.jsx(Vo,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop + clear queue")})]})]})]},S.id)})})]})}const gr="/api";let qn=0;function Wh(e,t){return qn+=1,{id:`pending-room-message-${Date.now()}-${qn}`,teamRunId:e,senderType:t.senderType??"user",senderId:t.senderId??null,senderInvocationId:t.senderInvocationId??null,kind:t.kind??((t.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:t.content,mentions:t.mentions??[],workRequestIds:[],artifactRefs:t.artifactRefs??[],attachmentIds:t.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function $h(e){return"pendingStatus"in e}const Uh=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${gr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function qh(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Kh(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Xh(e,t){if(t.length===0)return e;const r=new Set(t.map(Kh));return e.split(`
|
|
12
|
+
`).map(a=>{const m=a.match(/^\s*/)?.[0]??"",p=a.trimStart();for(const _ of r){if(p===_)return null;if(p.startsWith(`${_} `)||p.startsWith(`${_} `))return`${m}${p.slice(_.length).trimStart()}`}return a}).filter(a=>a!=null).join(`
|
|
13
|
+
`).replace(/\n{3,}/g,`
|
|
14
|
+
|
|
15
|
+
`).trim()}function Yh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Kn(e,t){return e instanceof Error?e.message:t}function Vh(e,t){const a=e.slice(0,t).match(/(^|\s)@([^\s@]*)$/);return!a||a.index==null?null:{start:a.index+a[1].length,end:t,query:a[2]??""}}function Gh(e,t){const r=t.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(r)):!0}function Qh(e,t){return e.label??t.get(e.memberId)?.name??e.memberId}function Zh(e,t){return(e.recipientMemberIds??[]).map(r=>t.get(r)?.name??r)}function Jh(e,t){const r=e.mentions??[];if(r.length===0)return e.content;const a=r.map(p=>Qh(p,t)).filter(p=>p&&!e.content.includes(`@${p}`));if(a.length===0)return e.content;const m=a.map(p=>`@${p}`).join(" ");return e.content.trimEnd()?`${e.content.trimEnd()} ${m}`:m}function ef(e,t,r){if(e.senderType!=="agent")return null;if(e.senderId&&t.has(e.senderId))return t.get(e.senderId)??null;if(e.senderInvocationId){const a=r.get(e.senderInvocationId);if(a?.memberId&&t.has(a.memberId))return t.get(a.memberId)??null}return null}function tf({content:e,isUser:t}){return s.jsx("div",{className:J("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",t?["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:s.jsx(Pi,{urlTransform:Uh,components:Oi,children:e})})}function sf({hasAttachmentIds:e,attachments:t,isLoading:r,onOpenImage:a}){if(!e)return null;if(r&&t.length===0)return s.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(t.length===0)return null;const m=t.filter(_=>_.mimeType.startsWith("image/")),p=new Map(m.map((_,i)=>[_.id,i]));return s.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:t.map(_=>{const i=`${gr}${_.url}`;if(_.mimeType.startsWith("image/")){const c=p.get(_.id)??0;return s.jsxs("button",{type:"button",onClick:()=>a(m,c),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:_.originalName,children:[s.jsx("img",{src:i,alt:_.originalName,className:"h-full w-full object-cover",loading:"lazy"}),s.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:_.originalName})]},_.id)}return s.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:_.originalName,children:[s.jsx(Hi,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-medium",children:_.originalName}),s.jsx("span",{className:"text-neutral-400",children:qh(_.sizeBytes)})]}),s.jsx(zi,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},_.id)})})}function rf({content:e,attachmentIds:t,isUser:r,tone:a,onOpenImage:m}){const p=C.useMemo(()=>Array.from(new Set(t??[])),[t]),{data:_=[],isLoading:i}=Ch(p),n=_.length>0?Xh(e,_):e;return s.jsxs(s.Fragment,{children:[n.trim()&&s.jsx(af,{content:n,isUser:r,tone:a}),s.jsx(sf,{hasAttachmentIds:p.length>0,attachments:_,isLoading:i,onOpenImage:m})]})}function nf({images:e,index:t,onClose:r,onSelect:a}){const m=e[t];if(!m)return null;const p=t>0,_=t<e.length-1;return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[s.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:s.jsx(Ot,{size:20})}),p&&s.jsx("button",{type:"button",onClick:()=>a(t-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:s.jsx(Lc,{size:24,"aria-hidden":!0})}),s.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[s.jsx("img",{src:`${gr}${m.url}`,alt:m.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[s.jsx("span",{className:"max-w-[70vw] truncate",children:m.originalName}),s.jsxs("a",{href:`${gr}${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:[s.jsx(zi,{size:13,"aria-hidden":!0}),"Open"]})]})]}),_&&s.jsx("button",{type:"button",onClick:()=>a(t+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:s.jsx(It,{size:24,"aria-hidden":!0})})]})}function of({draft:e,attachmentMarkdown:t,attachmentIds:r,mentions:a}){const p=[e.trim(),t].filter(Boolean).join(`
|
|
16
|
+
|
|
17
|
+
`);return p?{content:p,mentions:a,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function af({content:e,isUser:t,tone:r=t?"user":"agent"}){const{t:a}=ce(),m=C.useId(),p=C.useRef(null),[_,i]=C.useState(null),[n,c]=C.useState(!1),h=_?.content===e&&_.expanded,l=C.useCallback(()=>{const b=p.current;b&&c(Th(b.scrollHeight))},[]);C.useLayoutEffect(()=>{l();const b=p.current;if(!b)return;const S=window.requestAnimationFrame(l),v=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return v?.observe(b),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(S),v?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=n&&!h;return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{id:m,ref:p,onLoadCapture:l,className:J("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:Sa}:void 0,children:[s.jsx(tf,{content:e,isUser:t}),g&&s.jsx("div",{className:J("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",r==="system"?"to-amber-50":r==="user"?"to-neutral-900":"to-neutral-100")})]}),n&&s.jsxs("button",{type:"button","aria-expanded":h,"aria-controls":m,"aria-label":a(h?"Collapse message":"Expand full message"),onClick:()=>i({content:e,expanded:!h}),className:J("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",r==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":r==="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"),children:[h?s.jsx(Xo,{size:13}):s.jsx(lt,{size:13}),s.jsx("span",{children:a(h?"Collapse message":"Expand full message")})]})]})}function wa({senderName:e,avatar:t,createdAt:r,isUser:a,isSystem:m,children:p,headerAddon:_,bubbleClassName:i,isPending:n}){return m?s.jsx("div",{className:"flex justify-center",children:s.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})}):s.jsxs("div",{className:J("group flex items-start gap-3",a?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!a&&s.jsx(zt,{name:e,avatar:t??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:J("flex min-w-0 max-w-[min(86%,46rem)] flex-col",a?"items-end":"items-start"),children:[s.jsxs("div",{className:J("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",a?"justify-end":"justify-start"),children:[s.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),s.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),s.jsx(us,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"shrink-0",children:Yh(r)}),_]}),s.jsx("div",{className:J("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",a?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,n?"opacity-70":""),children:p})]}),a&&s.jsx(zt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function lf({message:e,senderName:t,senderMember:r,memberById:a,displayContent:m,onOpenImage:p}){const{t:_}=ce(),i=e.senderType==="user",n=e.senderType==="system",c=$h(e)?e.pendingStatus:null,h=e.mentions??[],l=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",b=g?Zh(e,a):[],S=s.jsxs(s.Fragment,{children:[g&&s.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:[s.jsx(rd,{size:10}),s.jsxs("span",{className:"truncate",children:[_("Private"),b.length>0?`: ${b.join(", ")}`:""]})]}),!n&&l>0&&h.length===0&&s.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:[_("Work requests"),": ",l]}),c==="sending"&&s.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:_("发送中...")}),c==="failed"&&s.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:_("发送失败")})]});return s.jsx(wa,{senderName:t,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:n,headerAddon:S,bubbleClassName:i&&c==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:c==="sending",children:s.jsx(rf,{content:m,attachmentIds:e.attachmentIds,isUser:i&&c!=="failed",tone:n?"system":void 0,onOpenImage:p})})}function cf({request:e,member:t,onApprove:r,onReject:a,isActionPending:m,isApprovePending:p,isRejectPending:_}){const{t:i}=ce();return s.jsx(wa,{senderName:t?.name??i("Agent"),avatar:t?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.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:[s.jsx(us,{size:11}),i("Pending approval")]}),s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),s.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instruction}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(Ve,{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:[s.jsx(ht,{size:12}),s.jsx("span",{children:i(p?"Approving":"Approve")})]}),s.jsxs(Ve,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:a,children:[s.jsx(Ot,{size:12}),s.jsx("span",{children:i(_?"Rejecting":"Reject")})]})]})]})})}function Ca({teamRun:e,messages:t,readOnly:r,readOnlyMessage:a,onSendMessage:m,onViewInvocationSession:p,compactComposer:_,centered:i}){const{t:n}=ce(),c=Oo(e.id),h=Io(e.id),l=Bo(e.id),[g,b]=C.useState(""),[S,v]=C.useState(!1),[o,f]=C.useState(null),[d,u]=C.useState(0),[x,y]=C.useState([]),[k,j]=C.useState(!1),[w,E]=C.useState(null),[N,T]=C.useState([]),[R,M]=C.useState(null),O=C.useRef(null),B=C.useRef(null),{files:F,addFiles:z,removeFile:A,clear:L,restoreFiles:P,buildMarkdownLinks:I,getDoneAttachments:$,isUploading:X}=Mr(),V=F.some(K=>K.status==="done"&&K.attachment),[se,ae]=C.useState(null),{scrollRef:D,contentRef:H,isAtBottom:q,scrollToBottom:W}=sn({resize:"smooth",initial:"instant"}),Y=C.useMemo(()=>new Map((e.members??[]).map(K=>[K.id,K])),[e.members]),Q=C.useMemo(()=>new Map((e.invocations??[]).map(K=>[K.id,K])),[e.invocations]),oe=C.useMemo(()=>{const K=new Set(t.map(fe=>fe.id)),G=N.filter(fe=>!K.has(fe.id));return[...t,...G].sort((fe,ge)=>{const xe=Date.parse(fe.createdAt??""),Ne=Date.parse(ge.createdAt??"");return(Number.isNaN(xe)?0:xe)-(Number.isNaN(Ne)?0:Ne)})},[t,N]),de=C.useMemo(()=>new Map((e.workRequests??[]).map(K=>[K.id,K])),[e.workRequests]),je=C.useMemo(()=>Ph(oe,e.workRequests??[],e.invocations??[]),[oe,e.invocations,e.workRequests]),ze=C.useMemo(()=>(e.invocations??[]).filter(K=>Lr.has(K.status)),[e.invocations]),re=C.useMemo(()=>x.map(K=>Y.get(K)).filter(K=>!!K),[Y,x]),Te=C.useMemo(()=>{const K=o?.query??"";return(e.members??[]).filter(G=>Gh(G,K)).sort((G,fe)=>{const ge=x.includes(G.id),xe=x.includes(fe.id);return ge!==xe?ge?1:-1:G.name.localeCompare(fe.name)})},[o?.query,x,e.members]),Ue=!r&&(S||!!o)&&Te.length>0,Ae=C.useCallback((K,G)=>{if(G==null){f(null);return}f(Vh(K,G)),u(0)},[]),Se=C.useCallback(K=>{y(Ne=>Mh(Ne,K.id));const G=`@${K.name} `;if(o){const Ne=`${g.slice(0,o.start)}${G}${g.slice(o.end)}`,Ze=o.start+G.length;b(Ne),f(null),v(!1),requestAnimationFrame(()=>{O.current?.focus(),O.current?.setSelectionRange(Ze,Ze)});return}const fe=g.length===0||/\s$/.test(g)?"":" ",ge=`${g}${fe}${G}`,xe=ge.length;b(ge),v(!1),requestAnimationFrame(()=>{O.current?.focus(),O.current?.setSelectionRange(xe,xe)})},[g,o]),U=C.useCallback(K=>{y(G=>Dh(G,K))},[]),ee=C.useCallback(K=>{const G=K.target.value;b(G),E(null);const fe=K.target;fe.style.height="auto",fe.style.height=`${Math.max(_?40:72,Math.min(fe.scrollHeight,_?140:240))}px`,v(!1),Ae(G,fe.selectionStart)},[_,Ae]),ie=C.useCallback(K=>{const G=K.target.files;G&&G.length>0&&(z(Array.from(G)),E(null)),K.target.value=""},[z]),pe=C.useCallback(K=>{const G=[];for(const fe of K.clipboardData.items)if(fe.kind==="file"){const ge=fe.getAsFile();ge&&G.push(ge)}G.length>0&&(K.preventDefault(),z(G),E(null))},[z]),he=C.useCallback(async()=>{if(r||k||X)return;const K=I(),G=$().map(Oe=>Oe.id),fe=Lh(x,e.members??[]),ge=of({draft:g,attachmentMarkdown:K,attachmentIds:G,mentions:fe});if(!ge||!g.trim()&&!V)return;const xe=Wh(e.id,ge),Ne=g,Ze=x,Mt=F;T(Oe=>[...Oe,xe]),b(""),y([]),v(!1),f(null),L(),O.current&&(O.current.style.height=_?"40px":"72px"),requestAnimationFrame(()=>W()),j(!0),E(null);try{const Oe=await m(ge);T(Ke=>Ke.filter(He=>He.id!==xe.id)),Oe&&typeof Oe=="object"&&"id"in Oe&&requestAnimationFrame(()=>W())}catch(Oe){const Ke=Oe instanceof Error?Oe.message:"Failed to send room message";T(He=>He.map(ke=>ke.id===xe.id?{...ke,pendingStatus:"failed",error:Ke}:ke)),b(He=>He.length===0?Ne:He),y(He=>He.length===0?Ze:He),P(Mt),E(Ke),requestAnimationFrame(()=>W())}finally{j(!1)}},[F,I,L,_,g,$,V,k,X,m,r,P,W,x,e.id,e.members]),qe=C.useCallback(K=>{const G=K.nativeEvent.isComposing||K.nativeEvent.keyCode===229;if(Ue){if(K.key==="ArrowDown"){K.preventDefault(),u(fe=>(fe+1)%Te.length);return}if(K.key==="ArrowUp"){K.preventDefault(),u(fe=>(fe-1+Te.length)%Te.length);return}if(K.key==="Enter"&&!G||K.key==="Tab"){K.preventDefault();const fe=Te[d]??Te[0];fe&&Se(fe);return}if(K.key==="Escape"){K.preventDefault(),f(null),v(!1);return}}K.key==="Enter"&&!K.shiftKey&&!K.repeat&&!G&&(K.preventDefault(),he())},[Se,he,d,Te,Ue]);C.useEffect(()=>{b(""),y([]),v(!1),f(null),E(null),T([]),L(),M(null),O.current&&(O.current.style.height=_?"40px":"72px")},[L,_,e.id]);const we=c.isError?c.error:h.isError?h.error:null,Ge=c.isPending||h.isPending,Ce=C.useCallback((K,G)=>{l.mutate({memberId:K,cancelQueued:G},{onSuccess:()=>M(null)})},[l]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[se&&s.jsx(nf,{images:se.images,index:se.index,onClose:()=>ae(null),onSelect:K=>ae(G=>G&&{...G,index:K})}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:D,className:J("h-full overflow-y-auto scrollbar-app-thin bg-white",_?"px-3 py-3":"px-4 py-4"),children:s.jsxs("div",{ref:H,className:J(_?"space-y-2.5":"space-y-3",i&&"max-w-5xl mx-auto"),children:[je.length===0?s.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:[s.jsx(ps,{size:24,className:"text-neutral-400"}),s.jsx("span",{className:"text-sm",children:n("No room messages yet")})]}):je.map(K=>{if(K.kind==="pendingApproval"){const Ne=K.request,Ze=Y.get(Ne.targetMemberId),Mt=c.isPending&&c.variables===Ne.id,Oe=h.isPending&&h.variables===Ne.id;return s.jsx(cf,{request:Ne,member:Ze,onApprove:()=>c.mutate(Ne.id),onReject:()=>h.mutate(Ne.id),isActionPending:Ge,isApprovePending:Mt,isRejectPending:Oe},K.key)}const G=K.message,fe=ef(G,Y,Q),ge=G.senderType==="user"?n("你"):G.senderType==="system"?n("System"):fe?.name??n("Agent"),xe=Jh(G,Y);return s.jsx(lf,{message:G,senderName:ge,senderMember:fe,memberById:Y,displayContent:xe,onOpenImage:(Ne,Ze)=>ae({images:Ne,index:Ze})},K.key)}),we&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Kn(we,n("Failed to update work request"))}),l.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Kn(l.error,n("Failed to stop member work"))})]})}),!q&&s.jsxs("button",{type:"button",onClick:()=>W(),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:[s.jsx(Ds,{size:14}),s.jsx("span",{children:n("Back to bottom")})]})]}),s.jsx("div",{className:J("shrink-0 border-t border-transparent bg-white",_?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:s.jsxs("div",{className:J(i&&"max-w-5xl mx-auto"),children:[s.jsx(Hh,{invocations:ze,memberById:Y,workRequestById:de,onViewInvocationSession:p,onStopMember:Ce,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:R,onToggleStopConfirm:K=>M(G=>G===K?null:K)}),r?s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:a??n("This project is read-only")}):s.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:[Ue&&s.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:[s.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:n(o?"Mention members":"Team members")}),s.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Te.map((K,G)=>{const fe=x.includes(K.id),ge=G===d;return s.jsxs("button",{type:"button",onMouseEnter:()=>u(G),onMouseDown:xe=>{xe.preventDefault(),Se(K)},className:J("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ge?"bg-neutral-100":"hover:bg-neutral-50"),children:[s.jsx(zt,{name:K.name,avatar:K.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:K.name}),fe&&s.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:n("selected")})]}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:[K.providerId,K.id.slice(0,8)].filter(Boolean).join(" · ")})]}),s.jsx(kn,{size:15,className:"text-neutral-400"})]},K.id)})})]}),re.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:re.map(K=>s.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:[s.jsxs("span",{className:"truncate font-medium",children:["@",K.name]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:K.id.slice(0,8)}),s.jsx("button",{type:"button",onClick:()=>U(K.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:n("Remove mention"),"aria-label":`${n("Remove mention")} ${K.name}`,children:s.jsx(Ot,{size:12})})]},K.id))}),s.jsx(Dr,{files:F,onRemove:A}),s.jsx("textarea",{ref:O,value:g,rows:_?1:void 0,onChange:ee,onKeyDown:qe,onPaste:pe,onClick:K=>Ae(g,K.currentTarget.selectionStart),onSelect:K=>Ae(g,K.currentTarget.selectionStart),placeholder:n("Message the team room..."),className:J("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",_?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:_?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),s.jsxs("div",{className:J("flex items-center justify-between",_?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{ref:B,type:"file",multiple:!0,className:"hidden",onChange:ie}),s.jsx("button",{type:"button",onClick:()=>B.current?.click(),title:n("Upload file"),"aria-label":n("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:s.jsx(Sr,{size:18})}),s.jsx("button",{type:"button",onClick:()=>{v(K=>!K),f(null),requestAnimationFrame(()=>O.current?.focus())},disabled:re.length===0&&(e.members??[]).length===0,title:n("Mention members"),"aria-label":n("Mention members"),className:J("rounded-lg transition-colors",_?"p-1.5":"p-2",S?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",re.length===0&&(e.members??[]).length===0?"cursor-not-allowed opacity-50":""),children:s.jsx(kn,{size:_?15:18})}),re.length>0&&s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[re.length," ",n("selected")]})]}),s.jsx("button",{type:"button",onClick:()=>{he()},disabled:r||k||X||!g.trim()&&!V,title:n(X?"Uploading...":k?"发送中...":"发送"),"aria-label":n(X?"Uploading...":k?"发送中...":"发送"),className:J("rounded-lg transition-all duration-200",_?"p-1.5":"p-2",(g.trim()||V)&&!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:s.jsx(wr,{size:_?15:18})})]}),w&&s.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:w})]})]})})]})}function df(e){return e?e.slice(0,8):""}function Xn(e){const t=e?Date.parse(e):0;return Number.isNaN(t)?0:t}function nn(e){return e?.workspaceKind===rt.MAIN_DIRECTORY}function ns(e){return e?nn(e)?"Project directory":e.branchName:"—"}function Qt(e){return e?.workingDir||e?.worktreePath||void 0}function on(e,t){if(!e?.length)return[];const r=new Map((t?.members??[]).map(p=>[p.id,p])),a=new Map(e.map(p=>[p.id,p])),m=t?.mainWorkspaceId??null;return e.map(p=>{const _=p.parentWorkspaceId?a.get(p.parentWorkspaceId):void 0,i=p.ownerMemberId?r.get(p.ownerMemberId):void 0,n=!!(m&&p.id===m),c=n?"main":p.parentWorkspaceId?"child":"root",h=i?.name??(p.ownerMemberId?`Member ${df(p.ownerMemberId)}`:void 0),l=nn(p)?"Project directory":n?"Main workspace":c==="child"?h?`${h} workspace`:"Child workspace":t?"Root workspace":"Workspace";return{workspace:p,kind:c,roleLabel:n?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:h,parentBranchName:_?ns(_):void 0,isMain:n}}).sort((p,_)=>{const i=c=>c.kind==="main"?0:c.kind==="child"?1:2,n=i(p)-i(_);return n!==0?n:Xn(p.workspace.createdAt)-Xn(_.workspace.createdAt)})}function ka(e,t,r){if(e?.length)return r&&e.some(a=>a.id===r)?r:t?.mainWorkspaceId&&e.some(a=>a.id===t.mainWorkspaceId)?t.mainWorkspaceId:e.find(a=>a.status===kt.ACTIVE)?.id??e[0]?.id}function Ea(e,t){return!e||e.status!==kt.ACTIVE||nn(e)?!1:!t||e.parentWorkspaceId?!0:!!(t.mainWorkspaceId&&e.id===t.mainWorkspaceId)}function ja(e,t,r){return e?.parentWorkspaceId?t?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const uf=[],hf=[],ff=[];function mf(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";default:return"idle"}}const Yn={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5};function ri(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Vn(e,t){return e instanceof Error?e.message:t}function pf(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"idle":return"Idle"}}function gf(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"idle":return"border-neutral-200 bg-white text-neutral-500"}}function vf(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"idle":return"bg-neutral-300"}}function _f(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function xf(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 bf(e){switch(e){case kt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case kt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case kt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case kt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function yf(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 Sf(e){return[...e].sort((t,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(t.updatedAt??t.createdAt??""))}function wf(e,t){return t.find(r=>r.memberId===e.id&&Lr.has(r.status))}function Na({teamRun:e,workspaces:t,selectedWorkspaceId:r,onSelectWorkspace:a,onViewInvocationSession:m}){const{t:p}=ce(),_=Oo(e.id),i=Io(e.id),n=Bo(e.id),[c,h]=C.useState(null),[l,g]=C.useState(null),[b,S]=C.useState(!1),v=e.members??uf,o=e.workRequests??hf,f=e.invocations??ff,d=C.useMemo(()=>on(t,e),[e,t]),u=C.useMemo(()=>new Map(o.map(R=>[R.id,R])),[o]),x=C.useMemo(()=>[...o].filter(R=>R.status==="PENDING_APPROVAL").sort((R,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(R.updatedAt??R.createdAt??"")),[o]),y=C.useMemo(()=>[...o].filter(R=>R.status==="QUEUED").sort((R,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(R.updatedAt??R.createdAt??"")),[o]),k=C.useMemo(()=>[...v].map(R=>({member:R,status:mf(R.status)})).sort((R,M)=>Yn[R.status]-Yn[M.status]),[v]),j=_.isError?_.error:i.isError?i.error:null,w=_.isPending||i.isPending,E=d.find(R=>R.workspace.id===r),N=e.messages??[],T=k.filter(({status:R})=>R==="running"||R==="waiting room reply").length;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ps,{size:14,className:"text-neutral-500 shrink-0"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),s.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:[s.jsx("span",{children:p("Team mode")}),s.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),s.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:[s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[s.jsx(Fi,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:N.length})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[s.jsx(ps,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:T>0?`${T}/${v.length}`:v.length}),T>0&&s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),y.length>0&&s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[s.jsx(us,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:y.length})]}),x.length>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[s.jsx(us,{size:11}),s.jsx("span",{className:"tabular-nums",children:x.length})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[x.length>0&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[s.jsx(us,{size:13}),s.jsx("span",{children:p("Pending approval")}),s.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:x.length})]}),s.jsx("div",{className:"space-y-1.5",children:x.map(R=>{const M=v.find(F=>F.id===R.targetMemberId),O=_.isPending&&_.variables===R.id,B=i.isPending&&i.variables===R.id;return s.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[s.jsx("div",{className:"flex items-start justify-between gap-2",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(zt,{name:M?.name??"Agent",avatar:M?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??R.targetMemberId})]}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:R.instruction})]})}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[s.jsx("span",{children:p(_f(R.requesterType))}),s.jsx("span",{children:ri(R.createdAt)})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>_.mutate(R.id),disabled:w,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:[s.jsx(ht,{size:11}),s.jsx("span",{className:"truncate",children:p(O?"Approving":"Approve")})]}),s.jsxs("button",{type:"button",onClick:()=>i.mutate(R.id),disabled:w,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:[s.jsx(Ot,{size:11}),s.jsx("span",{className:"truncate",children:p(B?"Rejecting":"Reject")})]})]})]},R.id)})}),j&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Vn(j,p("Failed to update work request"))})]}),s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(ps,{size:13}),s.jsx("span",{children:p("Members")}),s.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:v.length})]}),v.length===0?s.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):s.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:k.map(({member:R,status:M})=>{const O=wf(R,f),B=Sf(f.filter($=>$.memberId===R.id)),F=O?u.get(O.workRequestId):void 0,z=l===R.id,A=M==="running"||M==="waiting room reply",L=A&&!!O,P=c===R.id,I=n.isPending&&n.variables?.memberId===R.id;return s.jsxs("div",{className:J("bg-white",z&&"bg-neutral-50/50"),children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(zt,{name:R.name,avatar:R.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:J("h-1.5 w-1.5 shrink-0 rounded-full",vf(M))}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:R.name}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",gf(M)),children:p(pf(M))})]}),A&&F?.instruction&&s.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:F.instruction})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L&&s.jsx("button",{type:"button",onClick:()=>h(P?null:R.id),disabled:n.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:p("Stop"),"aria-label":p("Stop"),children:s.jsx(gs,{size:12})}),O?.sessionId&&m&&s.jsx("button",{type:"button",onClick:()=>m(O.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:s.jsx(lr,{size:12})}),s.jsx("button",{type:"button",onClick:()=>g(z?null:R.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":z,children:z?s.jsx(lt,{size:13}):s.jsx(It,{size:13})})]})]}),L&&P&&s.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[s.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:R.id,cancelQueued:!1},{onSuccess:()=>h(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(gs,{size:10}),s.jsx("span",{children:I&&n.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:R.id,cancelQueued:!0},{onSuccess:()=>h(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(Vo,{size:10}),s.jsx("span",{children:I&&n.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),z&&s.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[s.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[s.jsx("span",{children:R.providerId}),s.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),s.jsx("span",{children:R.workspacePolicy}),s.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),s.jsx("span",{children:R.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),s.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:B.length})]}),B.length===0?s.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):s.jsx("div",{className:"space-y-1",children:B.map($=>{const X=u.get($.workRequestId),V=!!($.sessionId&&m);return s.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:J("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",xf($.status)),children:$.status}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:ri($.updatedAt??$.createdAt)})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:X?.instruction??$.workRequestId})]}),V&&s.jsxs("button",{type:"button",onClick:()=>$.sessionId&&m?.($.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:[s.jsx(lr,{size:10}),s.jsx("span",{children:p("Log")})]})]})},$.id)})})]}),k[k.length-1]?.member.id!==R.id&&!z&&s.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},R.id)})}),n.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Vn(n.error,p("Failed to stop member work"))})]}),y.length>0&&s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(us,{size:13}),s.jsx("span",{children:p("Queue")}),s.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:y.length})]}),s.jsx("div",{className:"space-y-1",children:y.map(R=>{const M=v.find(O=>O.id===R.targetMemberId);return s.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(zt,{name:M?.name??"Agent",avatar:M?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??R.targetMemberId})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:R.instruction})]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:ri(R.createdAt)})]})},R.id)})})]}),d.length>0&&s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>S(R=>!R),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:[s.jsx(Ps,{size:13}),s.jsx("span",{children:p("Workspaces")}),s.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[E&&s.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:ns(E.workspace)}),s.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:d.length}),b?s.jsx(lt,{size:13,className:"text-neutral-400"}):s.jsx(It,{size:13,className:"text-neutral-400"})]})]}),b&&s.jsx("div",{className:"space-y-1.5",children:d.map(R=>{const M=r===R.workspace.id;return s.jsx("div",{className:J("rounded-md border bg-white px-3 py-2",M?"border-neutral-400 shadow-sm":"border-neutral-200"),children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(R.displayName)}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",yf(R.roleLabel)),children:p(R.roleLabel)}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",bf(R.workspace.status)),children:R.workspace.status})]}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:ns(R.workspace)}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[R.ownerName&&s.jsxs("span",{children:[p("Owner"),": ",R.ownerName]}),R.parentBranchName&&s.jsxs("span",{children:[p("Parent"),": ",R.parentBranchName]})]})]}),s.jsxs("button",{type:"button",onClick:()=>a?.(R.workspace.id),disabled:!a||M,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:[M?s.jsx(ht,{size:11}):s.jsx(Wi,{size:11}),s.jsx("span",{children:p(M?"Selected":"Select")})]})]})},R.workspace.id)})})]}),x.length===0&&y.length===0&&k.every(({status:R})=>R==="idle")&&s.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var ii={exports:{}},Gn;function Cf(){return Gn||(Gn=1,(function(e,t){(function(r,a){e.exports=a()})(self,(()=>(()=>{var r={4567:function(_,i,n){var c=this&&this.__decorate||function(u,x,y,k){var j,w=arguments.length,E=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,x,y,k);else for(var N=u.length-1;N>=0;N--)(j=u[N])&&(E=(w<3?j(E):w>3?j(x,y,E):j(x,y))||E);return w>3&&E&&Object.defineProperty(x,y,E),E},h=this&&this.__param||function(u,x){return function(y,k){x(y,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const l=n(9042),g=n(6114),b=n(9924),S=n(844),v=n(5596),o=n(4725),f=n(3656);let d=i.AccessibilityManager=class extends S.Disposable{constructor(u,x){super(),this._terminal=u,this._renderService=x,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 y=0;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);if(this._topBoundaryFocusListener=y=>this._handleBoundaryFocus(y,0),this._bottomBoundaryFocusListener=y=>this._handleBoundaryFocus(y,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((y=>this._handleResize(y.rows)))),this.register(this._terminal.onRender((y=>this._refreshRows(y.start,y.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((y=>this._handleChar(y)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
18
|
+
`)))),this.register(this._terminal.onA11yTab((y=>this._handleTab(y)))),this.register(this._terminal.onKey((y=>this._handleKey(y.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new v.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(u){for(let x=0;x<u;x++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
|
|
19
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,x){this._liveRegionDebouncer.refresh(u,x,this._terminal.rows)}_renderRows(u,x){const y=this._terminal.buffer,k=y.lines.length.toString();for(let j=u;j<=x;j++){const w=y.translateBufferLineToString(y.ydisp+j,!0),E=(y.ydisp+j+1).toString(),N=this._rowElements[j];N&&(w.length===0?N.innerText=" ":N.textContent=w,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(u,x){const y=u.target,k=this._rowElements[x===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==k)return;let j,w;if(x===0?(j=y,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(j=this._rowElements.shift(),w=y,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),x===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(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_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 u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=c([h(1,o.IRenderService)],d)},3614:(_,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function c(g,b){return b?"\x1B[200~"+g+"\x1B[201~":g}function h(g,b,S,v){g=c(g=n(g),S.decPrivateModes.bracketedPasteMode&&v.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(g,!0),b.value=""}function l(g,b,S){const v=S.getBoundingClientRect(),o=g.clientX-v.left-10,f=g.clientY-v.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${o}px`,b.style.top=`${f}px`,b.style.zIndex="1000",b.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=c,i.copyHandler=function(g,b){g.clipboardData&&g.clipboardData.setData("text/plain",b.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,b,S,v){g.stopPropagation(),g.clipboardData&&h(g.clipboardData.getData("text/plain"),b,S,v)},i.paste=h,i.moveTextAreaUnderMouseCursor=l,i.rightClickHandler=function(g,b,S,v,o){l(g,b,S),o&&v.rightClickSelect(g),b.value=v.selectionText,b.select()}},7239:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=n(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(h,l,g){this._css.set(h,l,g)}getCss(h,l){return this._css.get(h,l)}setColor(h,l,g){this._color.set(h,l,g)}getColor(h,l){return this._color.get(h,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,c,h,l){n.addEventListener(c,h,l);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(c,h,l))}}}},6465:function(_,i,n){var c=this&&this.__decorate||function(o,f,d,u){var x,y=arguments.length,k=y<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,f,d,u);else for(var j=o.length-1;j>=0;j--)(x=o[j])&&(k=(y<3?x(k):y>3?x(f,d,k):x(f,d))||k);return y>3&&k&&Object.defineProperty(f,d,k),k},h=this&&this.__param||function(o,f){return function(d,u){f(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const l=n(3656),g=n(8460),b=n(844),S=n(2585);let v=i.Linkifier2=class extends b.Disposable{get currentLink(){return this._currentLink}constructor(o){super(),this._bufferService=o,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,b.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,b.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(o){return this._linkProviders.push(o),{dispose:()=>{const f=this._linkProviders.indexOf(o);f!==-1&&this._linkProviders.splice(f,1)}}}attachToDom(o,f,d){this._element=o,this._mouseService=f,this._renderService=d,this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(o){if(this._lastMouseEvent=o,!this._element||!this._mouseService)return;const f=this._positionFromMouseEvent(o,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const d=o.composedPath();for(let u=0;u<d.length;u++){const x=d[u];if(x.classList.contains("xterm"))break;if(x.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(o){if(this._activeLine!==o.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(o,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,o)||(this._clearCurrentLink(),this._askForLink(o,!0))}_askForLink(o,f){var d,u;this._activeProviderReplies&&f||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((y=>{y?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=o.y);let x=!1;for(const[y,k]of this._linkProviders.entries())f?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(y)&&(x=this._checkLinkProviderResult(y,o,x)):k.provideLinks(o.y,(j=>{var w,E;if(this._isMouseOut)return;const N=j?.map((T=>({link:T})));(w=this._activeProviderReplies)===null||w===void 0||w.set(y,N),x=this._checkLinkProviderResult(y,o,x),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(o.y,this._activeProviderReplies)}))}_removeIntersectingLinks(o,f){const d=new Set;for(let u=0;u<f.size;u++){const x=f.get(u);if(x)for(let y=0;y<x.length;y++){const k=x[y],j=k.link.range.start.y<o?0:k.link.range.start.x,w=k.link.range.end.y>o?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=w;E++){if(d.has(E)){x.splice(y--,1);break}d.add(E)}}}}_checkLinkProviderResult(o,f,d){var u;if(!this._activeProviderReplies)return d;const x=this._activeProviderReplies.get(o);let y=!1;for(let k=0;k<o;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(y=!0);if(!y&&x){const k=x.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=(u=this._activeProviderReplies.get(k))===null||u===void 0?void 0:u.find((w=>this._linkAtPosition(w.link,f)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(o){if(!this._element||!this._mouseService||!this._currentLink)return;const f=this._positionFromMouseEvent(o,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(o,this._currentLink.link.text)}_clearCurrentLink(o,f){this._element&&this._currentLink&&this._lastMouseEvent&&(!o||!f||this._currentLink.link.range.start.y>=o&&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(o){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(o.link,f)&&(this._currentLink=o,this._currentLink.state={decorations:{underline:o.link.decorations===void 0||o.link.decorations.underline,pointerCursor:o.link.decorations===void 0||o.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,o.link,this._lastMouseEvent),o.link.decorations={},Object.defineProperties(o.link.decorations,{pointerCursor:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:d=>{var u,x;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((x=this._element)===null||x===void 0||x.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.underline},set:d=>{var u,x,y;!((u=this._currentLink)===null||u===void 0)&&u.state&&((y=(x=this._currentLink)===null||x===void 0?void 0:x.state)===null||y===void 0?void 0:y.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(o.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const u=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,x=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=x&&(this._clearCurrentLink(u,x),this._lastMouseEvent&&this._element)){const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._askForLink(y,!1)}}))))}_linkHover(o,f,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&o.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(d,f.text)}_fireUnderlineEvent(o,f){const d=o.range,u=this._bufferService.buffer.ydisp,x=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-u-1,d.end.x,d.end.y-u-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(x)}_linkLeave(o,f,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&o.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(d,f.text)}_linkAtPosition(o,f){const d=o.range.start.y*this._bufferService.cols+o.range.start.x,u=o.range.end.y*this._bufferService.cols+o.range.end.x,x=f.y*this._bufferService.cols+f.x;return d<=x&&x<=u}_positionFromMouseEvent(o,f,d){const u=d.getCoords(o,f,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(o,f,d,u,x){return{x1:o,y1:f,x2:d,y2:u,cols:this._bufferService.cols,fg:x}}};i.Linkifier2=v=c([h(0,S.IBufferService)],v)},9042:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(_,i,n){var c=this&&this.__decorate||function(v,o,f,d){var u,x=arguments.length,y=x<3?o:d===null?d=Object.getOwnPropertyDescriptor(o,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,o,f,d);else for(var k=v.length-1;k>=0;k--)(u=v[k])&&(y=(x<3?u(y):x>3?u(o,f,y):u(o,f))||y);return x>3&&y&&Object.defineProperty(o,f,y),y},h=this&&this.__param||function(v,o){return function(f,d){o(f,d,v)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const l=n(511),g=n(2585);let b=i.OscLinkProvider=class{constructor(v,o,f){this._bufferService=v,this._optionsService=o,this._oscLinkService=f}provideLinks(v,o){var f;const d=this._bufferService.buffer.lines.get(v-1);if(!d)return void o(void 0);const u=[],x=this._optionsService.rawOptions.linkHandler,y=new l.CellData,k=d.getTrimmedLength();let j=-1,w=-1,E=!1;for(let N=0;N<k;N++)if(w!==-1||d.hasContent(N)){if(d.loadCell(N,y),y.hasExtendedAttrs()&&y.extended.urlId){if(w===-1){w=N,j=y.extended.urlId;continue}E=y.extended.urlId!==j}else w!==-1&&(E=!0);if(E||w!==-1&&N===k-1){const T=(f=this._oscLinkService.getLinkData(j))===null||f===void 0?void 0:f.uri;if(T){const R={start:{x:w+1,y:v},end:{x:N+(E||N!==k-1?0:1),y:v}};let M=!1;if(!x?.allowNonHttpProtocols)try{const O=new URL(T);["http:","https:"].includes(O.protocol)||(M=!0)}catch{M=!0}M||u.push({text:T,range:R,activate:(O,B)=>x?x.activate(O,B,R):S(0,B),hover:(O,B)=>{var F;return(F=x?.hover)===null||F===void 0?void 0:F.call(x,O,B,R)},leave:(O,B)=>{var F;return(F=x?.leave)===null||F===void 0?void 0:F.call(x,O,B,R)}})}E=!1,y.hasExtendedAttrs()&&y.extended.urlId?(w=N,j=y.extended.urlId):(w=-1,j=-1)}}o(u)}};function S(v,o){if(confirm(`Do you want to navigate to ${o}?
|
|
20
|
+
|
|
21
|
+
WARNING: This link could potentially be dangerous`)){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=o}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=b=c([h(0,g.IBufferService),h(1,g.IOptionsService),h(2,g.IOscLinkService)],b)},6193:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,c){this._parentWindow=n,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,c,h){this._rowCount=h,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=n(844);class h extends c.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,c.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=h},3236:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=n(3614),h=n(3656),l=n(6465),g=n(9042),b=n(3730),S=n(1680),v=n(3107),o=n(5744),f=n(2950),d=n(1296),u=n(428),x=n(4269),y=n(5114),k=n(8934),j=n(3230),w=n(9312),E=n(4725),N=n(6731),T=n(8055),R=n(8969),M=n(8460),O=n(844),B=n(6114),F=n(8437),z=n(2584),A=n(7399),L=n(5941),P=n(9074),I=n(2585),$=n(5435),X=n(4567),V=typeof window<"u"?window.document:null;class se extends R.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(D={}){super(D),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new O.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(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,q)=>this.refresh(H,q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),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((H=>this._afterResize(H.cols,H.rows)))),this.register((0,O.toDisposable)((()=>{var H,q;this._customKeyEventHandler=void 0,(q=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||q===void 0||q.removeChild(this.element)})))}_handleColorEvent(D){if(this._themeService)for(const H of D){let q,W="";switch(H.index){case 256:q="foreground",W="10";break;case 257:q="background",W="11";break;case 258:q="cursor",W="12";break;default:q="ansi",W="4;"+H.index}switch(H.type){case 0:const Y=T.color.toColorRGB(q==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[q]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,L.toRgbString)(Y)}${z.C1_ESCAPED.ST}`);break;case 1:if(q==="ansi")this._themeService.modifyColors((Q=>Q.ansi[H.index]=T.rgba.toColor(...H.color)));else{const Q=q;this._themeService.modifyColors((oe=>oe[Q]=T.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(D){D?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(D){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(D),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var D;return(D=this.textarea)===null||D===void 0?void 0:D.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.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 D=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(D);if(!H)return;const q=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,Y=H.getWidth(q),Q=this._renderService.dimensions.css.cell.width*Y,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,de=q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=de+"px",this.textarea.style.top=oe+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,h.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const D=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,h.addDisposableDomListener)(this.textarea,"paste",D)),this.register((0,h.addDisposableDomListener)(this.element,"paste",D)),B.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",(D=>this._keyUp(D)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",(D=>this._keyDown(D)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",(D=>this._keyPress(D)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",(D=>this._compositionHelper.compositionupdate(D)))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,h.addDisposableDomListener)(this.textarea,"input",(D=>this._inputEvent(D)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(D){var H;if(!D)throw new Error("Terminal requires a parent element.");D.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=D.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),D.appendChild(this.element);const q=V.createDocumentFragment();this._viewportElement=V.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),q.appendChild(this._viewportElement),this._viewportScrollArea=V.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=V.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=V.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),q.appendChild(this.screenElement),this.textarea=V.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),B.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(y.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,h.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,h.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.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(x.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((W=>this._onRender.fire(W)))),this.onResize((W=>this._renderService.resize(W.cols,W.rows))),this._compositionView=V.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(q);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((W=>this.scrollLines(W.amount,W.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(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((W=>this.scrollLines(W.amount,W.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((W=>this._renderService.handleSelectionChanged(W.start,W.end,W.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((W=>{this.textarea.value=W,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((W=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,h.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(v.BufferDecorationRenderer,this.screenElement)),this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(W=>this._selectionService.handleMouseDown(W)))),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",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.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 D=this,H=this.element;function q(Q){const oe=D._mouseService.getMouseReportCoords(Q,D.screenElement);if(!oe)return!1;let de,je;switch(Q.overrideType||Q.type){case"mousemove":je=32,Q.buttons===void 0?(de=3,Q.button!==void 0&&(de=Q.button<3?Q.button:3)):de=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":je=0,de=Q.button<3?Q.button:3;break;case"mousedown":je=1,de=Q.button<3?Q.button:3;break;case"wheel":if(D.viewport.getLinesScrolled(Q)===0)return!1;je=Q.deltaY<0?0:1,de=4;break;default:return!1}return!(je===void 0||de===void 0||de>4)&&D.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:de,action:je,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Y={mouseup:Q=>(q(Q),Q.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(Q)),wheel:Q=>(q(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&q(Q)},mousemove:Q=>{Q.buttons||q(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?W.mousemove||(H.addEventListener("mousemove",Y.mousemove),W.mousemove=Y.mousemove):(H.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&Q?W.wheel||(H.addEventListener("wheel",Y.wheel,{passive:!1}),W.wheel=Y.wheel):(H.removeEventListener("wheel",W.wheel),W.wheel=null),2&Q?W.mouseup||(H.addEventListener("mouseup",Y.mouseup),W.mouseup=Y.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),H.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&Q?W.mousedrag||(W.mousedrag=Y.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,h.addDisposableDomListener)(H,"mousedown",(Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return q(Q),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(Q)}))),this.register((0,h.addDisposableDomListener)(H,"wheel",(Q=>{if(!W.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(Q);if(oe===0)return;const de=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let je="";for(let ze=0;ze<Math.abs(oe);ze++)je+=de;return this.coreService.triggerDataEvent(je,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}}),{passive:!1})),this.register((0,h.addDisposableDomListener)(H,"touchstart",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)}),{passive:!0})),this.register((0,h.addDisposableDomListener)(H,"touchmove",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)}),{passive:!1}))}refresh(D,H){var q;(q=this._renderService)===null||q===void 0||q.refreshRows(D,H)}updateCursorStyle(D){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(D)?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(D,H,q=0){var W;q===1?(super.scrollLines(D,H,q),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(D)}paste(D){(0,c.paste)(D,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(D){this._customKeyEventHandler=D}registerLinkProvider(D){return this.linkifier2.registerLinkProvider(D)}registerCharacterJoiner(D){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(D);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(D){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(D)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(D){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+D)}registerDecoration(D){return this._decorationService.registerDecoration(D)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(D,H,q){this._selectionService.setSelection(D,H,q)}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 D;(D=this._selectionService)===null||D===void 0||D.clearSelection()}selectAll(){var D;(D=this._selectionService)===null||D===void 0||D.selectAll()}selectLines(D,H){var q;(q=this._selectionService)===null||q===void 0||q.selectLines(D,H)}_keyDown(D){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(D)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&D.altKey;if(!H&&!this._compositionHelper.keydown(D))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||D.key!=="Dead"&&D.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const q=(0,A.evaluateKeyboardEvent)(D,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(D),q.type===3||q.type===2){const W=this.rows-1;return this.scrollLines(q.type===2?-W:W),this.cancel(D,!0)}return q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,D)||(q.cancel&&this.cancel(D,!0),!q.key||!!(D.key&&!D.ctrlKey&&!D.altKey&&!D.metaKey&&D.key.length===1&&D.key.charCodeAt(0)>=65&&D.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(q.key!==z.C0.ETX&&q.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:q.key,domEvent:D}),this._showCursor(),this.coreService.triggerDataEvent(q.key,!0),!this.optionsService.rawOptions.screenReaderMode||D.altKey||D.ctrlKey?this.cancel(D,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(D,H){const q=D.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||D.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||D.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?q:q&&(!H.keyCode||H.keyCode>47)}_keyUp(D){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(D)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(D)||this.focus(),this.updateCursorStyle(D),this._keyPressHandled=!1)}_keyPress(D){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(D)===!1)return!1;if(this.cancel(D),D.charCode)H=D.charCode;else if(D.which===null||D.which===void 0)H=D.keyCode;else{if(D.which===0||D.charCode===0)return!1;H=D.which}return!(!H||(D.altKey||D.ctrlKey||D.metaKey)&&!this._isThirdLevelShift(this.browser,D)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:D}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(D){if(D.data&&D.inputType==="insertText"&&(!D.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=D.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(D),!0}return!1}resize(D,H){D!==this.cols||H!==this.rows?super.resize(D,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(D,H){var q,W;(q=this._charSizeService)===null||q===void 0||q.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var D;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 H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(D=this.viewport)===null||D===void 0||D.reset(),this.refresh(0,this.rows-1)}}reset(){var D,H;this.options.rows=this.rows,this.options.cols=this.cols;const q=this._customKeyEventHandler;this._setup(),super.reset(),(D=this._selectionService)===null||D===void 0||D.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=q,this.refresh(0,this.rows-1)}clearTextureAtlas(){var D;(D=this._renderService)===null||D===void 0||D.clearTextureAtlas()}_reportFocus(){var D;!((D=this.element)===null||D===void 0)&&D.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(D){if(this._renderService)switch(D){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${q};${H}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),Y=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${Y};${W}t`)}}cancel(D,H){if(this.options.cancelEvents||H)return D.preventDefault(),D.stopPropagation(),!1}}i.Terminal=se},9924:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,c=1e3){this._renderCallback=n,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,c,h){this._rowCount=h,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=l-this._lastRefreshMs,b=this._debounceThresholdMS-g;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 n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c)}}},1680:function(_,i,n){var c=this&&this.__decorate||function(f,d,u,x){var y,k=arguments.length,j=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,u,x);else for(var w=f.length-1;w>=0;w--)(y=f[w])&&(j=(k<3?y(j):k>3?y(d,u,j):y(d,u))||j);return k>3&&j&&Object.defineProperty(d,u,j),j},h=this&&this.__param||function(f,d){return function(u,x){d(u,x,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const l=n(3656),g=n(4725),b=n(8460),S=n(844),v=n(2585);let o=i.Viewport=class extends S.Disposable{constructor(f,d,u,x,y,k,j,w){super(),this._viewportElement=f,this._scrollArea=d,this._bufferService=u,this._optionsService=x,this._charSizeService=y,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,l.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(w.colors),this.register(w.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 u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&u<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 u;let x,y="";const k=[],j=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let E=f;E<j;E++){const N=w.get(E);if(!N)continue;const T=(u=w.get(E+1))===null||u===void 0?void 0:u.isWrapped;if(y+=N.translateToString(!T),!T||E===w.length-1){const R=document.createElement("div");R.textContent=y,k.push(R),y.length>0&&(x=R),y=""}}return{bufferElements:k,cursorElement:x}}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 u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&d.altKey||u==="ctrl"&&d.ctrlKey||u==="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))}};i.Viewport=o=c([h(2,v.IBufferService),h(3,v.IOptionsService),h(4,g.ICharSizeService),h(5,g.IRenderService),h(6,g.ICoreBrowserService),h(7,g.IThemeService)],o)},3107:function(_,i,n){var c=this&&this.__decorate||function(o,f,d,u){var x,y=arguments.length,k=y<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,f,d,u);else for(var j=o.length-1;j>=0;j--)(x=o[j])&&(k=(y<3?x(k):y>3?x(f,d,k):x(f,d))||k);return y>3&&k&&Object.defineProperty(f,d,k),k},h=this&&this.__param||function(o,f){return function(d,u){f(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const l=n(3656),g=n(4725),b=n(844),S=n(2585);let v=i.BufferDecorationRenderer=class extends b.Disposable{constructor(o,f,d,u){super(),this._screenElement=o,this._bufferService=f,this._decorationService=d,this._renderService=u,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,l.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((x=>this._removeDecoration(x)))),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 o of this._decorationService.decorations)this._renderDecoration(o);this._dimensionsChanged=!1}_renderDecoration(o){this._refreshStyle(o),this._dimensionsChanged&&this._refreshXPosition(o)}_createElement(o){var f,d;const u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((f=o?.options)===null||f===void 0?void 0:f.layer)==="top"),u.style.width=`${Math.round((o.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(o.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(o.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const x=(d=o.options.x)!==null&&d!==void 0?d:0;return x&&x>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(o,u),u}_refreshStyle(o){const f=o.marker.line-this._bufferService.buffers.active.ydisp;if(f<0||f>=this._bufferService.rows)o.element&&(o.element.style.display="none",o.onRenderEmitter.fire(o.element));else{let d=this._decorationElements.get(o);d||(d=this._createElement(o),o.element=d,this._decorationElements.set(o,d),this._container.appendChild(d),o.onDispose((()=>{this._decorationElements.delete(o),d.remove()}))),d.style.top=f*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",o.onRenderEmitter.fire(d)}}_refreshXPosition(o,f=o.element){var d;if(!f)return;const u=(d=o.options.x)!==null&&d!==void 0?d:0;(o.options.anchor||"left")==="right"?f.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":f.style.left=u?u*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(o){var f;(f=this._decorationElements.get(o))===null||f===void 0||f.remove(),this._decorationElements.delete(o),o.dispose()}};i.BufferDecorationRenderer=v=c([h(1,S.IBufferService),h(2,S.IDecorationService),h(3,g.IRenderService)],v)},5871:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(n){if(n.options.overviewRulerOptions){for(const c of this._zones)if(c.color===n.options.overviewRulerOptions.color&&c.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,n.marker.line))return;if(this._lineAdjacentToZone(c,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(c,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,c){return c>=n.startBufferLine&&c<=n.endBufferLine}_lineAdjacentToZone(n,c,h){return c>=n.startBufferLine-this._linePadding[h||"full"]&&c<=n.endBufferLine+this._linePadding[h||"full"]}_addLineToZone(n,c){n.startBufferLine=Math.min(n.startBufferLine,c),n.endBufferLine=Math.max(n.endBufferLine,c)}}},5744:function(_,i,n){var c=this&&this.__decorate||function(x,y,k,j){var w,E=arguments.length,N=E<3?y:j===null?j=Object.getOwnPropertyDescriptor(y,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(x,y,k,j);else for(var T=x.length-1;T>=0;T--)(w=x[T])&&(N=(E<3?w(N):E>3?w(y,k,N):w(y,k))||N);return E>3&&N&&Object.defineProperty(y,k,N),N},h=this&&this.__param||function(x,y){return function(k,j){y(k,j,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const l=n(5871),g=n(3656),b=n(4725),S=n(844),v=n(2585),o={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 u=i.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,y,k,j,w,E,N){var T;super(),this._viewportElement=x,this._screenElement=y,this._bufferService=k,this._decorationService=j,this._renderService=w,this._optionsService=E,this._coreBrowseService=N,this._colorZoneStore=new l.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(),(T=this._viewportElement.parentElement)===null||T===void 0||T.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,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,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const x=Math.floor(this._canvas.width/3),y=Math.ceil(this._canvas.width/3);f.full=this._canvas.width,f.left=x,f.center=y,f.right=x,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=f.left,d.right=f.left+f.center}_refreshDrawHeightConstants(){o.full=Math.round(2*this._coreBrowseService.dpr);const x=this._canvas.height/this._bufferService.buffer.lines.length,y=Math.round(Math.max(Math.min(x,12),6)*this._coreBrowseService.dpr);o.left=y,o.center=y,o.right=y}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.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 y of this._decorationService.decorations)this._colorZoneStore.addDecoration(y);this._ctx.lineWidth=1;const x=this._colorZoneStore.zones;for(const y of x)y.position!=="full"&&this._renderColorZone(y);for(const y of x)y.position==="full"&&this._renderColorZone(y);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(d[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-o[x.position||"full"]/2),f[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+o[x.position||"full"]))}_queueRefresh(x,y){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=y||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=u=c([h(2,v.IBufferService),h(3,v.IDecorationService),h(4,b.IRenderService),h(5,v.IOptionsService),h(6,b.ICoreBrowserService)],u)},2950:function(_,i,n){var c=this&&this.__decorate||function(v,o,f,d){var u,x=arguments.length,y=x<3?o:d===null?d=Object.getOwnPropertyDescriptor(o,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,o,f,d);else for(var k=v.length-1;k>=0;k--)(u=v[k])&&(y=(x<3?u(y):x>3?u(o,f,y):u(o,f))||y);return x>3&&y&&Object.defineProperty(o,f,y),y},h=this&&this.__param||function(v,o){return function(f,d){o(f,d,v)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const l=n(4725),g=n(2585),b=n(2584);let S=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(v,o,f,d,u,x){this._textarea=v,this._compositionView=o,this._bufferService=f,this._optionsService=d,this._coreService=u,this._renderService=x,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(v){this._compositionView.textContent=v.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(v){if(this._isComposing||this._isSendingComposition){if(v.keyCode===229||v.keyCode===16||v.keyCode===17||v.keyCode===18)return!1;this._finalizeComposition(!1)}return v.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(v){if(this._compositionView.classList.remove("active"),this._isComposing=!1,v){const o={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let f;this._isSendingComposition=!1,o.start+=this._dataAlreadySent.length,f=this._isComposing?this._textarea.value.substring(o.start,o.end):this._textarea.value.substring(o.start),f.length>0&&this._coreService.triggerDataEvent(f,!0)}}),0)}else{this._isSendingComposition=!1;const o=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(o,!0)}}_handleAnyTextareaChanges(){const v=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const o=this._textarea.value,f=o.replace(v,"");this._dataAlreadySent=f,o.length>v.length?this._coreService.triggerDataEvent(f,!0):o.length<v.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):o.length===v.length&&o!==v&&this._coreService.triggerDataEvent(o,!0)}}),0)}updateCompositionElements(v){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const o=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,u=o*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"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 x=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(x.width,1)+"px",this._textarea.style.height=Math.max(x.height,1)+"px",this._textarea.style.lineHeight=x.height+"px"}v||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=S=c([h(2,g.IBufferService),h(3,g.IOptionsService),h(4,g.ICoreService),h(5,l.IRenderService)],S)},9806:(_,i)=>{function n(c,h,l){const g=l.getBoundingClientRect(),b=c.getComputedStyle(l),S=parseInt(b.getPropertyValue("padding-left")),v=parseInt(b.getPropertyValue("padding-top"));return[h.clientX-g.left-S,h.clientY-g.top-v]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(c,h,l,g,b,S,v,o,f){if(!S)return;const d=n(c,h,l);return d?(d[0]=Math.ceil((d[0]+(f?v/2:0))/v),d[1]=Math.ceil(d[1]/o),d[0]=Math.min(Math.max(d[0],1),g+(f?1:0)),d[1]=Math.min(Math.max(d[1],1),b),d):void 0}},9504:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=n(2584);function h(o,f,d,u){const x=o-l(o,d),y=f-l(f,d),k=Math.abs(x-y)-(function(j,w,E){let N=0;const T=j-l(j,E),R=w-l(w,E);for(let M=0;M<Math.abs(T-R);M++){const O=g(j,w)==="A"?-1:1,B=E.buffer.lines.get(T+O*M);B?.isWrapped&&N++}return N})(o,f,d);return v(k,S(g(o,f),u))}function l(o,f){let d=0,u=f.buffer.lines.get(o),x=u?.isWrapped;for(;x&&o>=0&&o<f.rows;)d++,u=f.buffer.lines.get(--o),x=u?.isWrapped;return d}function g(o,f){return o>f?"A":"B"}function b(o,f,d,u,x,y){let k=o,j=f,w="";for(;k!==d||j!==u;)k+=x?1:-1,x&&k>y.cols-1?(w+=y.buffer.translateBufferLineToString(j,!1,o,k),k=0,o=0,j++):!x&&k<0&&(w+=y.buffer.translateBufferLineToString(j,!1,0,o+1),k=y.cols-1,o=k,j--);return w+y.buffer.translateBufferLineToString(j,!1,o,k)}function S(o,f){const d=f?"O":"[";return c.C0.ESC+d+o}function v(o,f){o=Math.floor(o);let d="";for(let u=0;u<o;u++)d+=f;return d}i.moveToCellSequence=function(o,f,d,u){const x=d.buffer.x,y=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,E,N,T,R,M){return h(E,T,R,M).length===0?"":v(b(w,E,w,E-l(E,R),!1,R).length,S("D",M))})(x,y,0,f,d,u)+h(y,f,d,u)+(function(w,E,N,T,R,M){let O;O=h(E,T,R,M).length>0?T-l(T,R):E;const B=T,F=(function(z,A,L,P,I,$){let X;return X=h(L,P,I,$).length>0?P-l(P,I):A,z<L&&X<=P||z>=L&&X<P?"C":"D"})(w,E,N,T,R,M);return v(b(w,O,N,B,F==="C",R).length,S(F,M))})(x,y,o,f,d,u);let k;if(y===f)return k=x>o?"D":"C",v(Math.abs(x-o),S(k,u));k=y>f?"D":"C";const j=Math.abs(y-f);return v((function(w,E){return E.cols-w})(y>f?o:x,d)+(j-1)*d.cols+1+((y>f?x:o)-1),S(k,u))}},1296:function(_,i,n){var c=this&&this.__decorate||function(R,M,O,B){var F,z=arguments.length,A=z<3?M:B===null?B=Object.getOwnPropertyDescriptor(M,O):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(R,M,O,B);else for(var L=R.length-1;L>=0;L--)(F=R[L])&&(A=(z<3?F(A):z>3?F(M,O,A):F(M,O))||A);return z>3&&A&&Object.defineProperty(M,O,A),A},h=this&&this.__param||function(R,M){return function(O,B){M(O,B,R)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const l=n(3787),g=n(2550),b=n(2223),S=n(6171),v=n(4725),o=n(8055),f=n(8460),d=n(844),u=n(2585),x="xterm-dom-renderer-owner-",y="xterm-rows",k="xterm-fg-",j="xterm-bg-",w="xterm-focus",E="xterm-selection";let N=1,T=i.DomRenderer=class extends d.Disposable{constructor(R,M,O,B,F,z,A,L,P,I){super(),this._element=R,this._screenElement=M,this._viewportElement=O,this._linkifier2=B,this._charSizeService=z,this._optionsService=A,this._bufferService=L,this._coreBrowserService=P,this._themeService=I,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(y),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(l.DomRendererRowFactory,document),this._element.classList.add(x+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(x+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),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/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),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 O of this._rowElements)O.style.width=`${this.dimensions.css.canvas.width}px`,O.style.height=`${this.dimensions.css.cell.height}px`,O.style.lineHeight=`${this.dimensions.css.cell.height}px`,O.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${y} 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(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${y} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${y} .xterm-dim { color: ${o.color.multiplyOpacity(R.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: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,M+=`${this._terminalSelector} .${y}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${y}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.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: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[O,B]of R.ansi.entries())M+=`${this._terminalSelector} .${k}${O} { color: ${B.css}; }${this._terminalSelector} .${k}${O}.xterm-dim { color: ${o.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${j}${O} { background-color: ${B.css}; }`;M+=`${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR} { color: ${o.color.opaque(R.background).css}; }${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${o.color.multiplyOpacity(o.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${j}${b.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,M){for(let O=this._rowElements.length;O<=M;O++){const B=document.createElement("div");this._rowContainer.appendChild(B),this._rowElements.push(B)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,M){this._refreshRowElements(R,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,M,O){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,M,O),this.renderRows(0,this._bufferService.rows-1),!R||!M)return;const B=R[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,z=Math.max(B,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const L=document.createDocumentFragment();if(O){const P=R[0]>M[0];L.appendChild(this._createSelectionElement(z,P?M[0]:R[0],P?R[0]:M[0],A-z+1))}else{const P=B===z?R[0]:0,I=z===F?M[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(z,P,I));const $=A-z-1;if(L.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,$)),z!==A){const X=F===A?M[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(A,0,X))}}this._selectionContainer.appendChild(L)}_createSelectionElement(R,M,O,B=1){const F=document.createElement("div");return F.style.height=B*this.dimensions.css.cell.height+"px",F.style.top=R*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(O-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 R of this._rowElements)R.replaceChildren()}renderRows(R,M){const O=this._bufferService.buffer,B=O.ybase+O.y,F=Math.min(O.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,L=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=R;P<=M;P++){const I=P+O.ydisp,$=this._rowElements[P],X=O.lines.get(I);if(!$||!X)break;$.replaceChildren(...this._rowFactory.createRow(X,I,I===B,A,L,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${x}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,M,O,B,F,z){O<0&&(R=0),B<0&&(M=0);const A=this._bufferService.rows-1;O=Math.max(Math.min(O,A),0),B=Math.max(Math.min(B,A),0),F=Math.min(F,this._bufferService.cols);const L=this._bufferService.buffer,P=L.ybase+L.y,I=Math.min(L.x,F-1),$=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,V=this._optionsService.rawOptions.cursorInactiveStyle;for(let se=O;se<=B;++se){const ae=se+L.ydisp,D=this._rowElements[se],H=L.lines.get(ae);if(!D||!H)break;D.replaceChildren(...this._rowFactory.createRow(H,ae,ae===P,X,V,I,$,this.dimensions.css.cell.width,this._widthCache,z?se===O?R:0:-1,z?(se===B?M:F)-1:-1))}}};i.DomRenderer=T=c([h(4,u.IInstantiationService),h(5,v.ICharSizeService),h(6,u.IOptionsService),h(7,u.IBufferService),h(8,v.ICoreBrowserService),h(9,v.IThemeService)],T)},3787:function(_,i,n){var c=this&&this.__decorate||function(k,j,w,E){var N,T=arguments.length,R=T<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,w):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(k,j,w,E);else for(var M=k.length-1;M>=0;M--)(N=k[M])&&(R=(T<3?N(R):T>3?N(j,w,R):N(j,w))||R);return T>3&&R&&Object.defineProperty(j,w,R),R},h=this&&this.__param||function(k,j){return function(w,E){j(w,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const l=n(2223),g=n(643),b=n(511),S=n(2585),v=n(8055),o=n(4725),f=n(4269),d=n(6171),u=n(3734);let x=i.DomRendererRowFactory=class{constructor(k,j,w,E,N,T,R){this._document=k,this._characterJoinerService=j,this._optionsService=w,this._coreBrowserService=E,this._coreService=N,this._decorationService=T,this._themeService=R,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,w){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=w}createRow(k,j,w,E,N,T,R,M,O,B,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(j),L=this._themeService.colors;let P,I=k.getNoBgTrimmedLength();w&&I<T+1&&(I=T+1);let $=0,X="",V=0,se=0,ae=0,D=!1,H=0,q=!1,W=0;const Y=[],Q=B!==-1&&F!==-1;for(let oe=0;oe<I;oe++){k.loadCell(oe,this._workCell);let de=this._workCell.getWidth();if(de===0)continue;let je=!1,ze=oe,re=this._workCell;if(A.length>0&&oe===A[0][0]){je=!0;const G=A.shift();re=new f.JoinedCellData(this._workCell,k.translateToString(!0,G[0],G[1]),G[1]-G[0]),ze=G[1]-1,de=re.getWidth()}const Te=this._isCellInSelection(oe,j),Ue=w&&oe===T,Ae=Q&&oe>=B&&oe<=F;let Se=!1;this._decorationService.forEachDecorationAtCell(oe,j,void 0,(G=>{Se=!0}));let U=re.getChars()||g.WHITESPACE_CELL_CHAR;if(U===" "&&(re.isUnderline()||re.isOverline())&&(U=" "),W=de*M-O.get(U,re.isBold(),re.isItalic()),P){if($&&(Te&&q||!Te&&!q&&re.bg===V)&&(Te&&q&&L.selectionForeground||re.fg===se)&&re.extended.ext===ae&&Ae===D&&W===H&&!Ue&&!je&&!Se){X+=U,$++;continue}$&&(P.textContent=X),P=this._document.createElement("span"),$=0,X=""}else P=this._document.createElement("span");if(V=re.bg,se=re.fg,ae=re.extended.ext,D=Ae,H=W,q=Te,je&&T>=oe&&T<=ze&&(T=oe),!this._coreService.isCursorHidden&&Ue){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&Y.push("xterm-cursor-blink"),Y.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline")}}if(re.isBold()&&Y.push("xterm-bold"),re.isItalic()&&Y.push("xterm-italic"),re.isDim()&&Y.push("xterm-dim"),X=re.isInvisible()?g.WHITESPACE_CELL_CHAR:re.getChars()||g.WHITESPACE_CELL_CHAR,re.isUnderline()&&(Y.push(`xterm-underline-${re.extended.underlineStyle}`),X===" "&&(X=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let G=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&G<8&&(G+=8),P.style.textDecorationColor=L.ansi[G].css}re.isOverline()&&(Y.push("xterm-overline"),X===" "&&(X=" ")),re.isStrikethrough()&&Y.push("xterm-strikethrough"),Ae&&(P.style.textDecoration="underline");let ee=re.getFgColor(),ie=re.getFgColorMode(),pe=re.getBgColor(),he=re.getBgColorMode();const qe=!!re.isInverse();if(qe){const G=ee;ee=pe,pe=G;const fe=ie;ie=he,he=fe}let we,Ge,Ce,K=!1;switch(this._decorationService.forEachDecorationAtCell(oe,j,void 0,(G=>{G.options.layer!=="top"&&K||(G.backgroundColorRGB&&(he=50331648,pe=G.backgroundColorRGB.rgba>>8&16777215,we=G.backgroundColorRGB),G.foregroundColorRGB&&(ie=50331648,ee=G.foregroundColorRGB.rgba>>8&16777215,Ge=G.foregroundColorRGB),K=G.options.layer==="top")})),!K&&Te&&(we=this._coreBrowserService.isFocused?L.selectionBackgroundOpaque:L.selectionInactiveBackgroundOpaque,pe=we.rgba>>8&16777215,he=50331648,K=!0,L.selectionForeground&&(ie=50331648,ee=L.selectionForeground.rgba>>8&16777215,Ge=L.selectionForeground)),K&&Y.push("xterm-decoration-top"),he){case 16777216:case 33554432:Ce=L.ansi[pe],Y.push(`xterm-bg-${pe}`);break;case 50331648:Ce=v.rgba.toColor(pe>>16,pe>>8&255,255&pe),this._addStyle(P,`background-color:#${y((pe>>>0).toString(16),"0",6)}`);break;default:qe?(Ce=L.foreground,Y.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):Ce=L.background}switch(we||re.isDim()&&(we=v.color.multiplyOpacity(Ce,.5)),ie){case 16777216:case 33554432:re.isBold()&&ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ee+=8),this._applyMinimumContrast(P,Ce,L.ansi[ee],re,we,void 0)||Y.push(`xterm-fg-${ee}`);break;case 50331648:const G=v.rgba.toColor(ee>>16&255,ee>>8&255,255&ee);this._applyMinimumContrast(P,Ce,G,re,we,Ge)||this._addStyle(P,`color:#${y(ee.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Ce,L.foreground,re,we,void 0)||qe&&Y.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}Y.length&&(P.className=Y.join(" "),Y.length=0),Ue||je||Se?P.textContent=X:$++,W!==this.defaultSpacing&&(P.style.letterSpacing=`${W}px`),z.push(P),oe=ze}return P&&$&&(P.textContent=X),z}_applyMinimumContrast(k,j,w,E,N,T){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const R=this._getContrastCache(E);let M;if(N||T||(M=R.getColor(j.rgba,w.rgba)),M===void 0){const O=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);M=v.color.ensureContrastRatio(N||j,T||w,O),R.setColor((N||j).rgba,(T||w).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 w=this._selectionStart,E=this._selectionEnd;return!(!w||!E)&&(this._columnSelectMode?w[0]<=E[0]?k>=w[0]&&j>=w[1]&&k<E[0]&&j<=E[1]:k<w[0]&&j>=w[1]&&k>=E[0]&&j<=E[1]:j>w[1]&&j<E[1]||w[1]===E[1]&&j===w[1]&&k>=w[0]&&k<E[0]||w[1]<E[1]&&j===E[1]&&k<E[0]||w[1]<E[1]&&j===w[1]&&k>=w[0])}};function y(k,j,w){for(;k.length<w;)k=j+k;return k}i.DomRendererRowFactory=x=c([h(1,o.ICharacterJoinerService),h(2,S.IOptionsService),h(3,o.ICoreBrowserService),h(4,S.ICoreService),h(5,S.IDecorationService),h(6,o.IThemeService)],x)},2550:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const c=n.createElement("span"),h=n.createElement("span");h.style.fontWeight="bold";const l=n.createElement("span");l.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,h,l,g],this._container.appendChild(c),this._container.appendChild(h),this._container.appendChild(l),this._container.appendChild(g),n.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(n,c,h,l){n===this._font&&c===this._fontSize&&h===this._weight&&l===this._weightBold||(this._font=n,this._fontSize=c,this._weight=h,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(n,c,h){let l=0;if(!c&&!h&&n.length===1&&(l=n.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(n,0);let g=n;c&&(g+="B"),h&&(g+="I");let b=this._holey.get(g);if(b===void 0){let S=0;c&&(S|=1),h&&(S|=2),b=this._measure(n,S),this._holey.set(g,b)}return b}_measure(n,c){const h=this._measureElements[c];return h.textContent=n.repeat(32),h.offsetWidth/32}}},2223:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(_,i)=>{function n(c){return 57508<=c&&c<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return n(c)||(function(h){return 9472<=h&&h<=9631})(c)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,c=this.selectionEnd;return!(!n||!c)&&(n[1]>c[1]||n[1]===c[1]&&n[0]>c[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(_,i,n){var c=this&&this.__decorate||function(o,f,d,u){var x,y=arguments.length,k=y<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,f,d,u);else for(var j=o.length-1;j>=0;j--)(x=o[j])&&(k=(y<3?x(k):y>3?x(f,d,k):x(f,d))||k);return y>3&&k&&Object.defineProperty(f,d,k),k},h=this&&this.__param||function(o,f){return function(d,u){f(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const l=n(2585),g=n(8460),b=n(844);let S=i.CharSizeService=class extends b.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(o,f,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new v(o,f,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const o=this._measureStrategy.measure();o.width===this.width&&o.height===this.height||(this.width=o.width,this.height=o.height,this._onCharSizeChange.fire())}};i.CharSizeService=S=c([h(2,l.IOptionsService)],S);class v{constructor(f,d,u){this._document=f,this._parentElement=d,this._optionsService=u,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(_,i,n){var c=this&&this.__decorate||function(f,d,u,x){var y,k=arguments.length,j=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,u,x);else for(var w=f.length-1;w>=0;w--)(y=f[w])&&(j=(k<3?y(j):k>3?y(d,u,j):y(d,u))||j);return k>3&&j&&Object.defineProperty(d,u,j),j},h=this&&this.__param||function(f,d){return function(u,x){d(u,x,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const l=n(3734),g=n(643),b=n(511),S=n(2585);class v extends l.AttributeData{constructor(d,u,x){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=u,this._width=x}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=v;let o=i.CharacterJoinerService=class Ra{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(d){const u={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(u),u.id}deregister(d){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===d)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(d);if(!u||u.length===0)return[];const x=[],y=u.translateToString(!0);let k=0,j=0,w=0,E=u.getFg(0),N=u.getBg(0);for(let T=0;T<u.getTrimmedLength();T++)if(u.loadCell(T,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==N){if(T-k>1){const R=this._getJoinedRanges(y,w,j,u,k);for(let M=0;M<R.length;M++)x.push(R[M])}k=T,w=j,E=this._workCell.fg,N=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const T=this._getJoinedRanges(y,w,j,u,k);for(let R=0;R<T.length;R++)x.push(T[R])}return x}_getJoinedRanges(d,u,x,y,k){const j=d.substring(u,x);let w=[];try{w=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 T=0;T<N.length;T++)Ra._mergeRanges(w,N[T])}catch(N){console.error(N)}return this._stringRangesToCellRanges(w,y,k),w}_stringRangesToCellRanges(d,u,x){let y=0,k=!1,j=0,w=d[y];if(w){for(let E=x;E<this._bufferService.cols;E++){const N=u.getWidth(E),T=u.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&w[0]<=j&&(w[0]=E,k=!0),w[1]<=j){if(w[1]=E,w=d[++y],!w)break;w[0]<=j?(w[0]=E,k=!0):k=!1}j+=T}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,u){let x=!1;for(let y=0;y<d.length;y++){const k=d[y];if(x){if(u[1]<=k[0])return d[y-1][1]=u[1],d;if(u[1]<=k[1])return d[y-1][1]=Math.max(u[1],k[1]),d.splice(y,1),d;d.splice(y,1),y--}else{if(u[1]<=k[0])return d.splice(y,0,u),d;if(u[1]<=k[1])return k[0]=Math.min(u[0],k[0]),d;u[0]<k[1]&&(k[0]=Math.min(u[0],k[0]),x=!0)}}return x?d[d.length-1][1]=u[1]:d.push(u),d}};i.CharacterJoinerService=o=c([h(0,S.IBufferService)],o)},5114:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,c){this._textarea=n,this.window=c,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(_,i,n){var c=this&&this.__decorate||function(S,v,o,f){var d,u=arguments.length,x=u<3?v:f===null?f=Object.getOwnPropertyDescriptor(v,o):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(S,v,o,f);else for(var y=S.length-1;y>=0;y--)(d=S[y])&&(x=(u<3?d(x):u>3?d(v,o,x):d(v,o))||x);return u>3&&x&&Object.defineProperty(v,o,x),x},h=this&&this.__param||function(S,v){return function(o,f){v(o,f,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const l=n(4725),g=n(9806);let b=i.MouseService=class{constructor(S,v){this._renderService=S,this._charSizeService=v}getCoords(S,v,o,f,d){return(0,g.getCoords)(window,S,v,o,f,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(S,v){const o=(0,g.getCoordsRelativeToElement)(window,S,v);if(this._charSizeService.hasValidSize)return o[0]=Math.min(Math.max(o[0],0),this._renderService.dimensions.css.canvas.width-1),o[1]=Math.min(Math.max(o[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(o[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(o[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(o[0]),y:Math.floor(o[1])}}};i.MouseService=b=c([h(0,l.IRenderService),h(1,l.ICharSizeService)],b)},3230:function(_,i,n){var c=this&&this.__decorate||function(x,y,k,j){var w,E=arguments.length,N=E<3?y:j===null?j=Object.getOwnPropertyDescriptor(y,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(x,y,k,j);else for(var T=x.length-1;T>=0;T--)(w=x[T])&&(N=(E<3?w(N):E>3?w(y,k,N):w(y,k))||N);return E>3&&N&&Object.defineProperty(y,k,N),N},h=this&&this.__param||function(x,y){return function(k,j){y(k,j,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const l=n(3656),g=n(6193),b=n(5596),S=n(4725),v=n(8460),o=n(844),f=n(7226),d=n(2585);let u=i.RenderService=class extends o.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(x,y,k,j,w,E,N,T){if(super(),this._rowCount=x,this._charSizeService=j,this._renderer=this.register(new o.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 v.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new v.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new v.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new v.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((R,M)=>this._renderRows(R,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 R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.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,l.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(T.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const R=new N.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});R.observe(y),this.register({dispose:()=>R.disconnect()})}}_handleIntersectionChange(x){this._isPaused=x.isIntersecting===void 0?x.intersectionRatio===0:!x.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(x,y,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(x,y,this._rowCount))}_renderRows(x,y){this._renderer.value&&(x=Math.min(x,this._rowCount-1),y=Math.min(y,this._rowCount-1),this._renderer.value.renderRows(x,y),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:x,end:y}),this._onRender.fire({start:x,end:y}),this._isNextRenderRedrawOnly=!0)}resize(x,y){this._rowCount=y,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(x){this._renderer.value=x,this._renderer.value.onRequestRedraw((y=>this.refreshRows(y.start,y.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(x){return this._renderDebouncer.addRefreshCallback(x)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var x,y;this._renderer.value&&((y=(x=this._renderer.value).clearTextureAtlas)===null||y===void 0||y.call(x),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(x,y){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(x,y))):this._renderer.value.handleResize(x,y),this._fullRefresh())}handleCharSizeChanged(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCharSizeChanged()}handleBlur(){var x;(x=this._renderer.value)===null||x===void 0||x.handleBlur()}handleFocus(){var x;(x=this._renderer.value)===null||x===void 0||x.handleFocus()}handleSelectionChanged(x,y,k){var j;this._selectionState.start=x,this._selectionState.end=y,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(x,y,k)}handleCursorMove(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCursorMove()}clear(){var x;(x=this._renderer.value)===null||x===void 0||x.clear()}};i.RenderService=u=c([h(2,d.IOptionsService),h(3,S.ICharSizeService),h(4,d.IDecorationService),h(5,d.IBufferService),h(6,S.ICoreBrowserService),h(7,S.IThemeService)],u)},9312:function(_,i,n){var c=this&&this.__decorate||function(w,E,N,T){var R,M=arguments.length,O=M<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(w,E,N,T);else for(var B=w.length-1;B>=0;B--)(R=w[B])&&(O=(M<3?R(O):M>3?R(E,N,O):R(E,N))||O);return M>3&&O&&Object.defineProperty(E,N,O),O},h=this&&this.__param||function(w,E){return function(N,T){E(N,T,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const l=n(9806),g=n(9504),b=n(456),S=n(4725),v=n(8460),o=n(844),f=n(6114),d=n(4841),u=n(511),x=n(2585),y=" ",k=new RegExp(y,"g");let j=i.SelectionService=class extends o.Disposable{constructor(w,E,N,T,R,M,O,B,F){super(),this._element=w,this._screenElement=E,this._linkifier=N,this._bufferService=T,this._coreService=R,this._mouseService=M,this._optionsService=O,this._renderService=B,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new v.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new v.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new v.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((z=>this._handleTrim(z))),this.register(this._bufferService.buffers.onBufferActivate((z=>this._handleBufferActivate(z)))),this.enable(),this._model=new b.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,o.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 w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!w||!E||w[0]===E[0]&&w[1]===E[1])}get selectionText(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!w||!E)return"";const N=this._bufferService.buffer,T=[];if(this._activeSelectionMode===3){if(w[0]===E[0])return"";const R=w[0]<E[0]?w[0]:E[0],M=w[0]<E[0]?E[0]:w[0];for(let O=w[1];O<=E[1];O++){const B=N.translateBufferLineToString(O,!0,R,M);T.push(B)}}else{const R=w[1]===E[1]?E[0]:void 0;T.push(N.translateBufferLineToString(w[1],!0,w[0],R));for(let M=w[1]+1;M<=E[1]-1;M++){const O=N.lines.get(M),B=N.translateBufferLineToString(M,!0);O?.isWrapped?T[T.length-1]+=B:T.push(B)}if(w[1]!==E[1]){const M=N.lines.get(E[1]),O=N.translateBufferLineToString(E[1],!0,0,E[0]);M&&M.isWrapped?T[T.length-1]+=O:T.push(O)}}return T.map((R=>R.replace(k," "))).join(f.isWindows?`\r
|
|
22
|
+
`:`
|
|
23
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),f.isLinux&&w&&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(w){const E=this._getMouseBufferCoords(w),N=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!!(N&&T&&E)&&this._areCoordsInSelection(E,N,T)}isCellInSelection(w,E){const N=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!(!N||!T)&&this._areCoordsInSelection([w,E],N,T)}_areCoordsInSelection(w,E,N){return w[1]>E[1]&&w[1]<N[1]||E[1]===N[1]&&w[1]===E[1]&&w[0]>=E[0]&&w[0]<N[0]||E[1]<N[1]&&w[1]===N[1]&&w[0]<N[0]||E[1]<N[1]&&w[1]===E[1]&&w[0]>=E[0]}_selectWordAtCursor(w,E){var N,T;const R=(T=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||T===void 0?void 0:T.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(w);return!!M&&(this._selectWordAt(M,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,E){this._model.clearSelection(),w=Math.max(w,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const E=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(w){let E=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,w,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(w){return f.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),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(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!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(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const E=this._getMouseBufferCoords(w);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(w){return w.altKey&&!(f.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.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(w),!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(w),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 T=N.lines.get(this._model.selectionEnd[1]);T&&T.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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const E=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const T=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(T,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,N=!(!w||!E||w[0]===E[0]&&w[1]===E[1]);N?w&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,E,N)):this._oldHasSelection&&this._fireOnSelectionChange(w,E,N)}_fireOnSelectionChange(w,E,N){this._oldSelectionStart=w,this._oldSelectionEnd=E,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(w,E){let N=E;for(let T=0;E>=T;T++){const R=w.loadCell(T,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:R>1&&E!==T&&(N+=R-1)}return N}setSelection(w,E,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,E],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,E,N=!0,T=!0){if(w[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,M=R.lines.get(w[1]);if(!M)return;const O=R.translateBufferLineToString(w[1],!1);let B=this._convertViewportColToCharacterIndex(M,w[0]),F=B;const z=w[0]-B;let A=0,L=0,P=0,I=0;if(O.charAt(B)===" "){for(;B>0&&O.charAt(B-1)===" ";)B--;for(;F<O.length&&O.charAt(F+1)===" ";)F++}else{let V=w[0],se=w[0];M.getWidth(V)===0&&(A++,V--),M.getWidth(se)===2&&(L++,se++);const ae=M.getString(se).length;for(ae>1&&(I+=ae-1,F+=ae-1);V>0&&B>0&&!this._isCharWordSeparator(M.loadCell(V-1,this._workCell));){M.loadCell(V-1,this._workCell);const D=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,V--):D>1&&(P+=D-1,B-=D-1),B--,V--}for(;se<M.length&&F+1<O.length&&!this._isCharWordSeparator(M.loadCell(se+1,this._workCell));){M.loadCell(se+1,this._workCell);const D=this._workCell.getChars().length;this._workCell.getWidth()===2?(L++,se++):D>1&&(I+=D-1,F+=D-1),F++,se++}}F++;let $=B+z-A+P,X=Math.min(this._bufferService.cols,F-B+A+L-P-I);if(E||O.slice(B,F).trim()!==""){if(N&&$===0&&M.getCodePoint(0)!==32){const V=R.lines.get(w[1]-1);if(V&&M.isWrapped&&V.getCodePoint(this._bufferService.cols-1)!==32){const se=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(se){const ae=this._bufferService.cols-se.start;$-=ae,X+=ae}}}if(T&&$+X===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const V=R.lines.get(w[1]+1);if(V?.isWrapped&&V.getCodePoint(0)!==32){const se=this._getWordAt([0,w[1]+1],!1,!1,!0);se&&(X+=se.length)}}return{start:$,length:X}}}_selectWordAt(w,E){const N=this._getWordAt(w,E);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[N.start,w[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(w){const E=this._getWordAt(w,!0);if(E){let N=w[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(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const E=this._bufferService.buffer.getWrappedRangeForLine(w),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)}};i.SelectionService=j=c([h(3,x.IBufferService),h(4,x.ICoreService),h(5,S.IMouseService),h(6,x.IOptionsService),h(7,S.IRenderService),h(8,S.ICoreBrowserService)],j)},4725:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const c=n(8343);i.ICharSizeService=(0,c.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),i.IMouseService=(0,c.createDecorator)("MouseService"),i.IRenderService=(0,c.createDecorator)("RenderService"),i.ISelectionService=(0,c.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(_,i,n){var c=this&&this.__decorate||function(j,w,E,N){var T,R=arguments.length,M=R<3?w:N===null?N=Object.getOwnPropertyDescriptor(w,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,w,E,N);else for(var O=j.length-1;O>=0;O--)(T=j[O])&&(M=(R<3?T(M):R>3?T(w,E,M):T(w,E))||M);return R>3&&M&&Object.defineProperty(w,E,M),M},h=this&&this.__param||function(j,w){return function(E,N){w(E,N,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const l=n(7239),g=n(8055),b=n(8460),S=n(844),v=n(2585),o=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),x={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],w=[0,95,135,175,215,255];for(let E=0;E<216;E++){const N=w[E/36%6|0],T=w[E/6%6|0],R=w[E%6];j.push({css:g.channels.toCss(N,T,R),rgba:g.channels.toRgba(N,T,R)})}for(let E=0;E<24;E++){const N=8+10*E;j.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return j})());let y=i.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:o,background:f,cursor:d,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:x,selectionBackgroundOpaque:g.color.blend(f,x),selectionInactiveBackgroundTransparent:x,selectionInactiveBackgroundOpaque:g.color.blend(f,x),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(j={}){const w=this._colors;if(w.foreground=k(j.foreground,o),w.background=k(j.background,f),w.cursor=k(j.cursor,d),w.cursorAccent=k(j.cursorAccent,u),w.selectionBackgroundTransparent=k(j.selectionBackground,x),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(w.ansi.length-16,j.extendedAnsi.length);for(let N=0;N<E;N++)w.ansi[N+16]=k(j.extendedAnsi[N],i.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 w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}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,w){if(j!==void 0)try{return g.css.toColor(j)}catch{}return w}i.ThemeService=y=c([h(0,v.IOptionsService)],y)},6349:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=n(8460),h=n(844);class l extends h.Disposable{constructor(b){super(),this._maxLength=b,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.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 v=0;v<Math.min(b,this.length);v++)S[v]=this._array[this._getCyclicIndex(v)];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,...v){if(S){for(let o=b;o<this._length-S;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+S)];this._length-=S,this.onDeleteEmitter.fire({index:b,amount:S})}for(let o=this._length-1;o>=b;o--)this._array[this._getCyclicIndex(o+v.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<v.length;o++)this._array[this._getCyclicIndex(b+o)]=v[o];if(v.length&&this.onInsertEmitter.fire({index:b,amount:v.length}),this._length+v.length>this._maxLength){const o=this._length+v.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=v.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,S,v){if(!(S<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+v<0)throw new Error("Cannot shift elements in list beyond index 0");if(v>0){for(let f=S-1;f>=0;f--)this.set(b+f+v,this.get(b+f));const o=b+S+v-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<S;o++)this.set(b+o+v,this.get(b+o))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}i.CircularList=l},1439:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(c,h=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=h<=1?c[g]:c[g]&&n(c[g],h-1);return l}},8055:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const c=n(6114);let h=0,l=0,g=0,b=0;var S,v,o,f,d;function u(y){const k=y.toString(16);return k.length<2?"0"+k:k}function x(y,k){return y<k?(k+.05)/(y+.05):(y+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(y){y.toCss=function(k,j,w,E){return E!==void 0?`#${u(k)}${u(j)}${u(w)}${u(E)}`:`#${u(k)}${u(j)}${u(w)}`},y.toRgba=function(k,j,w,E=255){return(k<<24|j<<16|w<<8|E)>>>0}})(S||(i.channels=S={})),(function(y){function k(j,w){return b=Math.round(255*w),[h,l,g]=d.toChannels(j.rgba),{css:S.toCss(h,l,g,b),rgba:S.toRgba(h,l,g,b)}}y.blend=function(j,w){if(b=(255&w.rgba)/255,b===1)return{css:w.css,rgba:w.rgba};const E=w.rgba>>24&255,N=w.rgba>>16&255,T=w.rgba>>8&255,R=j.rgba>>24&255,M=j.rgba>>16&255,O=j.rgba>>8&255;return h=R+Math.round((E-R)*b),l=M+Math.round((N-M)*b),g=O+Math.round((T-O)*b),{css:S.toCss(h,l,g),rgba:S.toRgba(h,l,g)}},y.isOpaque=function(j){return(255&j.rgba)==255},y.ensureContrastRatio=function(j,w,E){const N=d.ensureContrastRatio(j.rgba,w.rgba,E);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},y.opaque=function(j){const w=(255|j.rgba)>>>0;return[h,l,g]=d.toChannels(w),{css:S.toCss(h,l,g),rgba:w}},y.opacity=k,y.multiplyOpacity=function(j,w){return b=255&j.rgba,k(j,b*w/255)},y.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(v||(i.color=v={})),(function(y){let k,j;if(!c.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const E=w.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}y.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return h=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(h,l,g);case 5:return h=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),b=parseInt(w.slice(4,5).repeat(2),16),d.toColor(h,l,g,b);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const E=w.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 h=parseInt(E[1]),l=parseInt(E[2]),g=parseInt(E[3]),b=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(h,l,g,b);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[h,l,g,b]=k.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(h,l,g,b),css:w}}})(o||(i.css=o={})),(function(y){function k(j,w,E){const N=j/255,T=w/255,R=E/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}y.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},y.relativeLuminance2=k})(f||(i.rgb=f={})),(function(y){function k(w,E,N){const T=w>>24&255,R=w>>16&255,M=w>>8&255;let O=E>>24&255,B=E>>16&255,F=E>>8&255,z=x(f.relativeLuminance2(O,B,F),f.relativeLuminance2(T,R,M));for(;z<N&&(O>0||B>0||F>0);)O-=Math.max(0,Math.ceil(.1*O)),B-=Math.max(0,Math.ceil(.1*B)),F-=Math.max(0,Math.ceil(.1*F)),z=x(f.relativeLuminance2(O,B,F),f.relativeLuminance2(T,R,M));return(O<<24|B<<16|F<<8|255)>>>0}function j(w,E,N){const T=w>>24&255,R=w>>16&255,M=w>>8&255;let O=E>>24&255,B=E>>16&255,F=E>>8&255,z=x(f.relativeLuminance2(O,B,F),f.relativeLuminance2(T,R,M));for(;z<N&&(O<255||B<255||F<255);)O=Math.min(255,O+Math.ceil(.1*(255-O))),B=Math.min(255,B+Math.ceil(.1*(255-B))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=x(f.relativeLuminance2(O,B,F),f.relativeLuminance2(T,R,M));return(O<<24|B<<16|F<<8|255)>>>0}y.ensureContrastRatio=function(w,E,N){const T=f.relativeLuminance(w>>8),R=f.relativeLuminance(E>>8);if(x(T,R)<N){if(R<T){const B=k(w,E,N),F=x(T,f.relativeLuminance(B>>8));if(F<N){const z=j(w,E,N);return F>x(T,f.relativeLuminance(z>>8))?B:z}return B}const M=j(w,E,N),O=x(T,f.relativeLuminance(M>>8));if(O<N){const B=k(w,E,N);return O>x(T,f.relativeLuminance(B>>8))?M:B}return M}},y.reduceLuminance=k,y.increaseLuminance=j,y.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},y.toColor=function(w,E,N,T){return{css:S.toCss(w,E,N,T),rgba:S.toRgba(w,E,N,T)}}})(d||(i.rgba=d={})),i.toPaddedHex=u,i.contrastRatio=x},8969:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=n(844),h=n(2585),l=n(4348),g=n(7866),b=n(744),S=n(7302),v=n(6975),o=n(8460),f=n(1753),d=n(1480),u=n(7994),x=n(9282),y=n(5435),k=n(5981),j=n(2660);let w=!1;class E extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new o.EventEmitter),this._onScroll.event((T=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(T.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(T){for(const R in T)this.optionsService.options[R]=T[R]}constructor(T){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new o.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new o.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new o.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new S.OptionsService(T)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(v.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(f.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(h.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new y.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,o.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,o.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,o.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,o.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((R=>{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((R=>{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(((R,M)=>this._inputHandler.parse(R,M)))),this.register((0,o.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(T,R){this._writeBuffer.write(T,R)}writeSync(T,R){this._logService.logLevel<=h.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(T,R)}resize(T,R){isNaN(T)||isNaN(R)||(T=Math.max(T,b.MINIMUM_COLS),R=Math.max(R,b.MINIMUM_ROWS),this._bufferService.resize(T,R))}scroll(T,R=!1){this._bufferService.scroll(T,R)}scrollLines(T,R,M){this._bufferService.scrollLines(T,R,M)}scrollPages(T){this.scrollLines(T*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(T){const R=T-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(T,R){return this._inputHandler.registerEscHandler(T,R)}registerDcsHandler(T,R){return this._inputHandler.registerDcsHandler(T,R)}registerCsiHandler(T,R){return this._inputHandler.registerCsiHandler(T,R)}registerOscHandler(T,R){return this._inputHandler.registerOscHandler(T,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let T=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?T=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(T=!0),T?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const T=[];T.push(this.onLineFeed(x.updateWindowsModeWrappedState.bind(null,this._bufferService))),T.push(this.registerCsiHandler({final:"H"},(()=>((0,x.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const R of T)R.dispose()}))}}}i.CoreTerminal=E},8460:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===n)return void this._listeners.splice(c,1)}}})),this._event}fire(n,c){const h=[];for(let l=0;l<this._listeners.length;l++)h.push(this._listeners[l]);for(let l=0;l<h.length;l++)h[l].call(void 0,n,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,c){return n((h=>c.fire(h)))}},5435:function(_,i,n){var c=this&&this.__decorate||function(z,A,L,P){var I,$=arguments.length,X=$<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,L):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(z,A,L,P);else for(var V=z.length-1;V>=0;V--)(I=z[V])&&(X=($<3?I(X):$>3?I(A,L,X):I(A,L))||X);return $>3&&X&&Object.defineProperty(A,L,X),X},h=this&&this.__param||function(z,A){return function(L,P){A(L,P,z)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const l=n(2584),g=n(7116),b=n(2015),S=n(844),v=n(482),o=n(8437),f=n(8460),d=n(643),u=n(511),x=n(3734),y=n(2585),k=n(6242),j=n(6351),w=n(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function T(z,A){if(z>24)return A.setWinLines||!1;switch(z){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var R;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(i.WindowsOptionsReportType=R={}));let M=0;class O extends S.Disposable{getAttrData(){return this._curAttrData}constructor(A,L,P,I,$,X,V,se,ae=new b.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=L,this._coreService=P,this._logService=I,this._optionsService=$,this._oscLinkService=X,this._coreMouseService=V,this._unicodeService=se,this._parser=ae,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new v.StringToUtf32,this._utf8Decoder=new v.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.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 B(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._parser.setCsiHandlerFallback(((D,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(D),params:H.toArray()})})),this._parser.setEscHandlerFallback((D=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(D)})})),this._parser.setExecuteHandlerFallback((D=>{this._logService.debug("Unknown EXECUTE code: ",{code:D})})),this._parser.setOscHandlerFallback(((D,H,q)=>{this._logService.debug("Unknown OSC code: ",{identifier:D,action:H,data:q})})),this._parser.setDcsHandlerFallback(((D,H,q)=>{H==="HOOK"&&(q=q.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(D),action:H,payload:q})})),this._parser.setPrintHandler(((D,H,q)=>this.print(D,H,q))),this._parser.registerCsiHandler({final:"@"},(D=>this.insertChars(D))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(D=>this.scrollLeft(D))),this._parser.registerCsiHandler({final:"A"},(D=>this.cursorUp(D))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(D=>this.scrollRight(D))),this._parser.registerCsiHandler({final:"B"},(D=>this.cursorDown(D))),this._parser.registerCsiHandler({final:"C"},(D=>this.cursorForward(D))),this._parser.registerCsiHandler({final:"D"},(D=>this.cursorBackward(D))),this._parser.registerCsiHandler({final:"E"},(D=>this.cursorNextLine(D))),this._parser.registerCsiHandler({final:"F"},(D=>this.cursorPrecedingLine(D))),this._parser.registerCsiHandler({final:"G"},(D=>this.cursorCharAbsolute(D))),this._parser.registerCsiHandler({final:"H"},(D=>this.cursorPosition(D))),this._parser.registerCsiHandler({final:"I"},(D=>this.cursorForwardTab(D))),this._parser.registerCsiHandler({final:"J"},(D=>this.eraseInDisplay(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(D=>this.eraseInDisplay(D,!0))),this._parser.registerCsiHandler({final:"K"},(D=>this.eraseInLine(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(D=>this.eraseInLine(D,!0))),this._parser.registerCsiHandler({final:"L"},(D=>this.insertLines(D))),this._parser.registerCsiHandler({final:"M"},(D=>this.deleteLines(D))),this._parser.registerCsiHandler({final:"P"},(D=>this.deleteChars(D))),this._parser.registerCsiHandler({final:"S"},(D=>this.scrollUp(D))),this._parser.registerCsiHandler({final:"T"},(D=>this.scrollDown(D))),this._parser.registerCsiHandler({final:"X"},(D=>this.eraseChars(D))),this._parser.registerCsiHandler({final:"Z"},(D=>this.cursorBackwardTab(D))),this._parser.registerCsiHandler({final:"`"},(D=>this.charPosAbsolute(D))),this._parser.registerCsiHandler({final:"a"},(D=>this.hPositionRelative(D))),this._parser.registerCsiHandler({final:"b"},(D=>this.repeatPrecedingCharacter(D))),this._parser.registerCsiHandler({final:"c"},(D=>this.sendDeviceAttributesPrimary(D))),this._parser.registerCsiHandler({prefix:">",final:"c"},(D=>this.sendDeviceAttributesSecondary(D))),this._parser.registerCsiHandler({final:"d"},(D=>this.linePosAbsolute(D))),this._parser.registerCsiHandler({final:"e"},(D=>this.vPositionRelative(D))),this._parser.registerCsiHandler({final:"f"},(D=>this.hVPosition(D))),this._parser.registerCsiHandler({final:"g"},(D=>this.tabClear(D))),this._parser.registerCsiHandler({final:"h"},(D=>this.setMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(D=>this.setModePrivate(D))),this._parser.registerCsiHandler({final:"l"},(D=>this.resetMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(D=>this.resetModePrivate(D))),this._parser.registerCsiHandler({final:"m"},(D=>this.charAttributes(D))),this._parser.registerCsiHandler({final:"n"},(D=>this.deviceStatus(D))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(D=>this.deviceStatusPrivate(D))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(D=>this.softReset(D))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(D=>this.setCursorStyle(D))),this._parser.registerCsiHandler({final:"r"},(D=>this.setScrollRegion(D))),this._parser.registerCsiHandler({final:"s"},(D=>this.saveCursor(D))),this._parser.registerCsiHandler({final:"t"},(D=>this.windowOptions(D))),this._parser.registerCsiHandler({final:"u"},(D=>this.restoreCursor(D))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(D=>this.insertColumns(D))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(D=>this.deleteColumns(D))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(D=>this.selectProtected(D))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(D=>this.requestMode(D,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(D=>this.requestMode(D,!1))),this._parser.setExecuteHandler(l.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(l.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(l.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(l.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(l.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(l.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(l.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(l.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(l.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((D=>(this.setTitle(D),this.setIconName(D),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((D=>this.setIconName(D)))),this._parser.registerOscHandler(2,new k.OscHandler((D=>this.setTitle(D)))),this._parser.registerOscHandler(4,new k.OscHandler((D=>this.setOrReportIndexedColor(D)))),this._parser.registerOscHandler(8,new k.OscHandler((D=>this.setHyperlink(D)))),this._parser.registerOscHandler(10,new k.OscHandler((D=>this.setOrReportFgColor(D)))),this._parser.registerOscHandler(11,new k.OscHandler((D=>this.setOrReportBgColor(D)))),this._parser.registerOscHandler(12,new k.OscHandler((D=>this.setOrReportCursorColor(D)))),this._parser.registerOscHandler(104,new k.OscHandler((D=>this.restoreIndexedColor(D)))),this._parser.registerOscHandler(110,new k.OscHandler((D=>this.restoreFgColor(D)))),this._parser.registerOscHandler(111,new k.OscHandler((D=>this.restoreBgColor(D)))),this._parser.registerOscHandler(112,new k.OscHandler((D=>this.restoreCursorColor(D)))),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 D in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:D},(()=>this.selectCharset("("+D))),this._parser.registerEscHandler({intermediates:")",final:D},(()=>this.selectCharset(")"+D))),this._parser.registerEscHandler({intermediates:"*",final:D},(()=>this.selectCharset("*"+D))),this._parser.registerEscHandler({intermediates:"+",final:D},(()=>this.selectCharset("+"+D))),this._parser.registerEscHandler({intermediates:"-",final:D},(()=>this.selectCharset("-"+D))),this._parser.registerEscHandler({intermediates:".",final:D},(()=>this.selectCharset("."+D))),this._parser.registerEscHandler({intermediates:"/",final:D},(()=>this.selectCharset("/"+D)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((D=>(this._logService.error("Parsing error: ",D),D))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((D,H)=>this.requestStatusString(D,H))))}_preserveStack(A,L,P,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=L,this._parseStack.decodedLength=P,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=y.LogLevelEnum.WARN&&Promise.race([A,new Promise(((L,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((L=>{if(L!=="#SLOW_TIMEOUT")throw L;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,L){let P,I=this._activeBuffer.x,$=this._activeBuffer.y,X=0;const V=this._parseStack.paused;if(V){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,L))return this._logSlowResolvingAsync(P),P;I=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>N&&(X=this._parseStack.position+N)}if(this._logService.logLevel<=y.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(se=>String.fromCharCode(se))).join("")}"`),typeof A=="string"?A.split("").map((se=>se.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(A.length,N))),V||this._dirtyRowTracker.clearRange(),A.length>N)for(let se=X;se<A.length;se+=N){const ae=se+N<A.length?se+N:A.length,D=typeof A=="string"?this._stringDecoder.decode(A.substring(se,ae),this._parseBuffer):this._utf8Decoder.decode(A.subarray(se,ae),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,D))return this._preserveStack(I,$,D,se),this._logSlowResolvingAsync(P),P}else if(!V){const se=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,se))return this._preserveStack(I,$,se,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===I&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,L,P){let I,$;const X=this._charsetService.charset,V=this._optionsService.rawOptions.screenReaderMode,se=this._bufferService.cols,ae=this._coreService.decPrivateModes.wraparound,D=this._coreService.modes.insertMode,H=this._curAttrData;let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-L>0&&q.getWidth(this._activeBuffer.x-1)===2&&q.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=L;W<P;++W){if(I=A[W],$=this._unicodeService.wcwidth(I),I<127&&X){const Y=X[String.fromCharCode(I)];Y&&(I=Y.charCodeAt(0))}if(V&&this._onA11yChar.fire((0,v.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=se){if(ae){for(;this._activeBuffer.x<se;)q.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.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),q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=se-1,$===2)continue}if(D&&(q.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(H),H),q.getWidth(se-1)===2&&q.setCellFromCodePoint(se-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),q.setCellFromCodePoint(this._activeBuffer.x++,I,$,H.fg,H.bg,H.extended),$>0)for(;--$;)q.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else q.getWidth(this._activeBuffer.x-1)?q.addCodepointToCell(this._activeBuffer.x-1,I):q.addCodepointToCell(this._activeBuffer.x-2,I)}P-L>0&&(q.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<se&&P-L>0&&q.getWidth(this._activeBuffer.x)===0&&!q.hasContent(this._activeBuffer.x)&&q.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,L){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,L):this._parser.registerCsiHandler(A,(P=>!T(P.params[0],this._optionsService.rawOptions.windowOptions)||L(P)))}registerDcsHandler(A,L){return this._parser.registerDcsHandler(A,new j.DcsHandler(L))}registerEscHandler(A,L){return this._parser.registerEscHandler(A,L)}registerOscHandler(A,L){return this._parser.registerOscHandler(A,new k.OscHandler(L))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);L.hasWidth(this._activeBuffer.x)&&!L.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,L){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+L):(this._activeBuffer.x=A,this._activeBuffer.y=L),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,L){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+L)}cursorUp(A){const L=this._activeBuffer.y-this._activeBuffer.scrollTop;return L>=0?this._moveCursor(0,-Math.min(L,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const L=this._activeBuffer.scrollBottom-this._activeBuffer.y;return L>=0?this._moveCursor(0,Math.min(L,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const L=A.params[0];return L===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:L===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=A.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=A.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const L=A.params[0];return L===1&&(this._curAttrData.bg|=536870912),L!==2&&L!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,L,P,I=!1,$=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);X.replaceCells(L,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),I&&(X.isWrapped=!1)}_resetBufferLine(A,L=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),L),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),P.isWrapped=!1)}eraseInDisplay(A,L=!1){let P;switch(this._restrictCursor(this._bufferService.cols),A.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,L);P<this._bufferService.rows;P++)this._resetBufferLine(P,L);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,L),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,L);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,L);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(A,L=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,L);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,L)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let L=A.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,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;L--;)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(A){this._restrictCursor();let L=A.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 I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;L--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let L=A.params[0]||1;for(;L--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let L=A.params[0]||1;for(;L--;)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(o.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.deleteCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.insertCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.insertCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.deleteCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const L=A.params[0]||1,P=new Uint32Array(L);for(let I=0;I<L;++I)P[I]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[L]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,L){const P=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:$}=this._coreMouseService,X=this._coreService,{buffers:V,cols:se}=this._bufferService,{active:ae,alt:D}=V,H=this._optionsService.rawOptions,q=oe=>oe?1:2,W=A.params[0];return Y=W,Q=L?W===2?4:W===4?q(X.modes.insertMode):W===12?3:W===20?q(H.convertEol):0:W===1?q(P.applicationCursorKeys):W===3?H.windowOptions.setWinLines?se===80?2:se===132?1:0:0:W===6?q(P.origin):W===7?q(P.wraparound):W===8?3:W===9?q(I==="X10"):W===12?q(H.cursorBlink):W===25?q(!X.isCursorHidden):W===45?q(P.reverseWraparound):W===66?q(P.applicationKeypad):W===67?4:W===1e3?q(I==="VT200"):W===1002?q(I==="DRAG"):W===1003?q(I==="ANY"):W===1004?q(P.sendFocus):W===1005?4:W===1006?q($==="SGR"):W===1015?4:W===1016?q($==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?q(ae===D):W===2004?q(P.bracketedPasteMode):0,X.triggerDataEvent(`${l.C0.ESC}[${L?"":"?"}${Y};${Q}$y`),!0;var Y,Q}_updateAttrColor(A,L,P,I,$){return L===2?(A|=50331648,A&=-16777216,A|=x.AttributeData.fromColorRGB([P,I,$])):L===5&&(A&=-50331904,A|=33554432|255&P),A}_extractColor(A,L,P){const I=[0,0,-1,0,0,0];let $=0,X=0;do{if(I[X+$]=A.params[L+X],A.hasSubParams(L+X)){const V=A.getSubParams(L+X);let se=0;do I[1]===5&&($=1),I[X+se+1+$]=V[se];while(++se<V.length&&se+X+1+$<I.length);break}if(I[1]===5&&X+$>=2||I[1]===2&&X+$>=5)break;I[1]&&($=1)}while(++X+L<A.length&&X+$<I.length);for(let V=2;V<I.length;++V)I[V]===-1&&(I[V]=0);switch(I[0]){case 38:P.fg=this._updateAttrColor(P.fg,I[1],I[3],I[4],I[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,I[1],I[3],I[4],I[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,I[1],I[3],I[4],I[5])}return X}_processUnderline(A,L){L.extended=L.extended.clone(),(!~A||A>5)&&(A=1),L.extended.underlineStyle=A,L.fg|=268435456,A===0&&(L.fg&=-268435457),L.updateExtended()}_processSGR0(A){A.fg=o.DEFAULT_ATTR_DATA.fg,A.bg=o.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const L=A.length;let P;const I=this._curAttrData;for(let $=0;$<L;$++)P=A.params[$],P>=30&&P<=37?(I.fg&=-50331904,I.fg|=16777216|P-30):P>=40&&P<=47?(I.bg&=-50331904,I.bg|=16777216|P-40):P>=90&&P<=97?(I.fg&=-50331904,I.fg|=16777224|P-90):P>=100&&P<=107?(I.bg&=-50331904,I.bg|=16777224|P-100):P===0?this._processSGR0(I):P===1?I.fg|=134217728:P===3?I.bg|=67108864:P===4?(I.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,I)):P===5?I.fg|=536870912:P===7?I.fg|=67108864:P===8?I.fg|=1073741824:P===9?I.fg|=2147483648:P===2?I.bg|=134217728:P===21?this._processUnderline(2,I):P===22?(I.fg&=-134217729,I.bg&=-134217729):P===23?I.bg&=-67108865:P===24?(I.fg&=-268435457,this._processUnderline(0,I)):P===25?I.fg&=-536870913:P===27?I.fg&=-67108865:P===28?I.fg&=-1073741825:P===29?I.fg&=2147483647:P===39?(I.fg&=-67108864,I.fg|=16777215&o.DEFAULT_ATTR_DATA.fg):P===49?(I.bg&=-67108864,I.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(A,$,I):P===53?I.bg|=1073741824:P===55?I.bg&=-1073741825:P===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):P===100?(I.fg&=-67108864,I.fg|=16777215&o.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const L=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${L};${P}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const L=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${L};${P}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const L=A.params[0]||1;switch(L){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=L%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(A){const L=A.params[0]||1;let P;return(A.length<2||(P=A.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>L&&(this._activeBuffer.scrollTop=L-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(A){if(!T(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const L=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:L!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:L!==0&&L!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),L!==0&&L!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:L!==0&&L!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),L!==0&&L!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const L=[],P=A.split(";");for(;P.length>1;){const I=P.shift(),$=P.shift();if(/^\d+$/.exec(I)){const X=parseInt(I);if(F(X))if($==="?")L.push({type:0,index:X});else{const V=(0,w.parseColor)($);V&&L.push({type:1,index:X,color:V})}}}return L.length&&this._onColor.fire(L),!0}setHyperlink(A){const L=A.split(";");return!(L.length<2)&&(L[1]?this._createHyperlink(L[0],L[1]):!L[0]&&this._finishHyperlink())}_createHyperlink(A,L){this._getCurrentLinkId()&&this._finishHyperlink();const P=A.split(":");let I;const $=P.findIndex((X=>X.startsWith("id=")));return $!==-1&&(I=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:L}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,L){const P=A.split(";");for(let I=0;I<P.length&&!(L>=this._specialColors.length);++I,++L)if(P[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[L]}]);else{const $=(0,w.parseColor)(P[I]);$&&this._onColor.fire([{type:1,index:this._specialColors[L],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const L=[],P=A.split(";");for(let I=0;I<P.length;++I)if(/^\d+$/.exec(P[I])){const $=parseInt(P[I]);F($)&&L.push({type:2,index:$})}return L.length&&this._onColor.fire(L),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new u.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let L=0;L<this._bufferService.rows;++L){const P=this._activeBuffer.ybase+this._activeBuffer.y+L,I=this._activeBuffer.lines.get(P);I&&(I.fill(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,L){const P=this._bufferService.buffer,I=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${$}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,L){this._dirtyRowTracker.markRangeDirty(A,L)}}i.InputHandler=O;let B=class{constructor(z){this._bufferService=z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(z){z<this.start?this.start=z:z>this.end&&(this.end=z)}markRangeDirty(z,A){z>A&&(M=z,z=A,A=M),z<this.start&&(this.start=z),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(z){return 0<=z&&z<256}B=c([h(0,y.IBufferService)],B)},844:(_,i)=>{function n(c){for(const h of c)h.dispose();c.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const h=this._disposables.indexOf(c);h!==-1&&this._disposables.splice(h,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var h;this._isDisposed||c===this._value||((h=this._value)===null||h===void 0||h.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},i.toDisposable=function(c){return{dispose:c}},i.disposeArray=n,i.getDisposeArrayDisposable=function(c){return{dispose:()=>n(c)}}},1505:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(h,l,g){this._data[h]||(this._data[h]={}),this._data[h][l]=g}get(h,l){return this._data[h]?this._data[h][l]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(c,h,l,g,b){this._data.get(c,h)||this._data.set(c,h,new n),this._data.get(c,h).set(l,g,b)}get(c,h,l,g){var b;return(b=this._data.get(c,h))===null||b===void 0?void 0:b.get(l,g)}clear(){this._data.clear()}}},6114:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,c=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const h=n.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),i.isIpad=c==="iPad",i.isIphone=c==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),i.isLinux=c.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(n=this._search(this._getKey(c)),this._array.splice(n,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const h=this._getKey(c);if(h===void 0||(n=this._search(h),n===-1)||this._getKey(this._array[n])!==h)return!1;do if(this._array[n]===c)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===h);return!1}*getKeyIterator(c){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===c)}forEachByKey(c,h){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do h(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===c)}values(){return[...this._array].values()}_search(c){let h=0,l=this._array.length-1;for(;l>=h;){let g=h+l>>1;const b=this._getKey(this._array[g]);if(b>c)l=g-1;else{if(!(b<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}h=g+1}}return h}}},7226:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=n(6114);class h{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,v=0,o=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),v=Math.max(S,v),f=b.timeRemaining(),1.5*v>f)return o-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-S))}ms`),void this._start();o=f}this.clear()}}class l extends h{_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())}}}i.PriorityTaskQueue=l,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends h{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=n(643);i.updateWindowsModeWrappedState=function(h){const l=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),g=l?.get(h.cols-1),b=h.buffer.lines.get(h.buffer.ybase+h.buffer.y);b&&g&&(b.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new n;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=n;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,g=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=g}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=c},9092:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=n(6349),h=n(7226),l=n(3734),g=n(8437),b=n(4634),S=n(511),v=n(643),o=n(4863),f=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,u,x){this._hasScrollback=d,this._optionsService=u,this._bufferService=x,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,v.NULL_CELL_CHAR,v.NULL_CELL_WIDTH,v.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,v.WHITESPACE_CELL_CHAR,v.WHITESPACE_CELL_WIDTH,v.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.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 l.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 l.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,u){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),u)}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 u=d+this._optionsService.rawOptions.scrollback;return u>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:u}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA);let y=0;const k=this._getCorrectBufferLength(u);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)y+=+this.lines.get(w).resize(d,x);let j=0;if(this._rows<u)for(let w=this._rows;w<u;w++)this.lines.length<u+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,x)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,x)));else for(let w=this._rows;w>u;w--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,u-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(d,u),this._cols>d))for(let j=0;j<this.lines.length;j++)y+=+this.lines.get(j).resize(d,x);this._cols=d,this._rows=u,this._memoryCleanupQueue.clear(),y>.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 u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>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,u){this._cols!==d&&(d>this._cols?this._reflowLarger(d,u):this._reflowSmaller(d,u))}_reflowLarger(d,u){const x=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(x.length>0){const y=(0,b.reflowLargerCreateNewLayout)(this.lines,x);(0,b.reflowLargerApplyNewLayout)(this.lines,y.layout),this._reflowLargerAdjustViewport(d,u,y.countRemoved)}}_reflowLargerAdjustViewport(d,u,x){const y=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=x;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new g.BufferLine(d,y))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-x,0)}_reflowSmaller(d,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA),y=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let w=this.lines.get(j);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const E=[w];for(;w.isWrapped&&j>0;)w=this.lines.get(--j),E.unshift(w);const N=this.ybase+this.y;if(N>=j&&N<j+E.length)continue;const T=E[E.length-1].getTrimmedLength(),R=(0,b.reflowSmallerGetNewLineLengths)(E,this._cols,d),M=R.length-E.length;let O;O=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 B=[];for(let I=0;I<M;I++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);B.push($)}B.length>0&&(y.push({start:j+E.length+k,newLines:B}),k+=B.length),E.push(...B);let F=R.length-1,z=R[F];z===0&&(F--,z=R[F]);let A=E.length-M-1,L=T;for(;A>=0;){const I=Math.min(L,z);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[A],L-I,z-I,I,!0),z-=I,z===0&&(F--,z=R[F]),L-=I,L===0){A--;const $=Math.max(A,0);L=(0,b.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let I=0;I<E.length;I++)R[I]<d&&E[I].setCell(R[I],x);let P=M-O;for(;P-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+u-1)}if(y.length>0){const j=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const E=this.lines.length;let N=E-1,T=0,R=y[T];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(R&&R.start>N+M){for(let z=R.newLines.length-1;z>=0;z--)this.lines.set(F--,R.newLines[z]);F++,j.push({index:N+1,amount:R.newLines.length}),M+=R.newLines.length,R=y[++T]}else this.lines.set(F,w[N--]);let O=0;for(let F=j.length-1;F>=0;F--)j[F].index+=O,this.lines.onInsertEmitter.fire(j[F]),O+=j[F].amount;const B=Math.max(0,E+k-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(d,u,x=0,y){const k=this.lines.get(d);return k?k.translateToString(u,x,y):""}getWrappedRangeForLine(d){let u=d,x=d;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;x+1<this.lines.length&&this.lines.get(x+1).isWrapped;)x++;return{first:u,last:x}}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 u=0;u<this.markers.length;u++)this.markers[u].line===d&&(this.markers[u].dispose(),this.markers.splice(u--,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 u=new o.Marker(d);return this.markers.push(u),u.register(this.lines.onTrim((x=>{u.line-=x,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((x=>{u.line>=x.index&&(u.line+=x.amount)}))),u.register(this.lines.onDelete((x=>{u.line>=x.index&&u.line<x.index+x.amount&&u.dispose(),u.line>x.index&&(u.line-=x.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=n(3734),h=n(511),l=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let b=0;class S{constructor(o,f,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);const u=f||h.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let x=0;x<o;++x)this.setCell(x,u);this.length=o}get(o){const f=this._data[3*o+0],d=2097151&f;return[this._data[3*o+1],2097152&f?this._combined[o]:d?(0,g.stringFromCodePoint)(d):"",f>>22,2097152&f?this._combined[o].charCodeAt(this._combined[o].length-1):d]}set(o,f){this._data[3*o+1]=f[l.CHAR_DATA_ATTR_INDEX],f[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=f[1],this._data[3*o+0]=2097152|o|f[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=f[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){const f=this._data[3*o+0];return 2097152&f?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&f}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){const f=this._data[3*o+0];return 2097152&f?this._combined[o]:2097151&f?(0,g.stringFromCodePoint)(2097151&f):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,f){return b=3*o,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[o]),268435456&f.bg&&(f.extended=this._extendedAttrs[o]),f}setCell(o,f){2097152&f.content&&(this._combined[o]=f.combinedData),268435456&f.bg&&(this._extendedAttrs[o]=f.extended),this._data[3*o+0]=f.content,this._data[3*o+1]=f.fg,this._data[3*o+2]=f.bg}setCellFromCodePoint(o,f,d,u,x,y){268435456&x&&(this._extendedAttrs[o]=y),this._data[3*o+0]=f|d<<22,this._data[3*o+1]=u,this._data[3*o+2]=x}addCodepointToCell(o,f){let d=this._data[3*o+0];2097152&d?this._combined[o]+=(0,g.stringFromCodePoint)(f):(2097151&d?(this._combined[o]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(f),d&=-2097152,d|=2097152):d=f|4194304,this._data[3*o+0]=d)}insertCells(o,f,d,u){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length-o){const x=new h.CellData;for(let y=this.length-o-f-1;y>=0;--y)this.setCell(o+f+y,this.loadCell(o+y,x));for(let y=0;y<f;++y)this.setCell(o+y,d)}else for(let x=o;x<this.length;++x)this.setCell(x,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(o,f,d,u){if(o%=this.length,f<this.length-o){const x=new h.CellData;for(let y=0;y<this.length-o-f;++y)this.setCell(o+y,this.loadCell(o+f+y,x));for(let y=this.length-f;y<this.length;++y)this.setCell(y,d)}else for(let x=o;x<this.length;++x)this.setCell(x,d);o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodePoint(o,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(o,f,d,u,x=!1){if(x)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&!this.isProtected(f)&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);o<f&&o<this.length;)this.isProtected(o)||this.setCell(o,d),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);o<f&&o<this.length;)this.setCell(o++,d)}resize(o,f){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const u=new Uint32Array(d);u.set(this._data),this._data=u}for(let u=this.length;u<o;++u)this.setCell(u,f)}else{this._data=this._data.subarray(0,d);const u=Object.keys(this._combined);for(let y=0;y<u.length;y++){const k=parseInt(u[y],10);k>=o&&delete this._combined[k]}const x=Object.keys(this._extendedAttrs);for(let y=0;y<x.length;y++){const k=parseInt(x[y],10);k>=o&&delete this._extendedAttrs[k]}}return this.length=o,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,f=!1){if(f)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,o);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(const f in o._combined)this._combined[f]=o._combined[f];this._extendedAttrs={};for(const f in o._extendedAttrs)this._extendedAttrs[f]=o._extendedAttrs[f];this.isWrapped=o.isWrapped}clone(){const o=new S(0);o._data=new Uint32Array(this._data),o.length=this.length;for(const f in this._combined)o._combined[f]=this._combined[f];for(const f in this._extendedAttrs)o._extendedAttrs[f]=this._extendedAttrs[f];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,f,d,u,x){const y=o._data;if(x)for(let j=u-1;j>=0;j--){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=y[3*(f+j)+w];268435456&y[3*(f+j)+2]&&(this._extendedAttrs[d+j]=o._extendedAttrs[f+j])}else for(let j=0;j<u;j++){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=y[3*(f+j)+w];268435456&y[3*(f+j)+2]&&(this._extendedAttrs[d+j]=o._extendedAttrs[f+j])}const k=Object.keys(o._combined);for(let j=0;j<k.length;j++){const w=parseInt(k[j],10);w>=f&&(this._combined[w-f+d]=o._combined[w])}}translateToString(o=!1,f=0,d=this.length){o&&(d=Math.min(d,this.getTrimmedLength()));let u="";for(;f<d;){const x=this._data[3*f+0],y=2097151&x;u+=2097152&x?this._combined[f]:y?(0,g.stringFromCodePoint)(y):l.WHITESPACE_CELL_CHAR,f+=x>>22||1}return u}}i.BufferLine=S},4841:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,c){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return c*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(_,i)=>{function n(c,h,l){if(h===c.length-1)return c[h].getTrimmedLength();const g=!c[h].hasContent(l-1)&&c[h].getWidth(l-1)===1,b=c[h+1].getWidth(0)===2;return g&&b?l-1:l}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,h,l,g,b){const S=[];for(let v=0;v<c.length-1;v++){let o=v,f=c.get(++o);if(!f.isWrapped)continue;const d=[c.get(v)];for(;o<c.length&&f.isWrapped;)d.push(f),f=c.get(++o);if(g>=v&&g<o){v+=d.length-1;continue}let u=0,x=n(d,u,h),y=1,k=0;for(;y<d.length;){const w=n(d,y,h),E=w-k,N=l-x,T=Math.min(E,N);d[u].copyCellsFrom(d[y],k,x,T,!1),x+=T,x===l&&(u++,x=0),k+=T,k===w&&(y++,k=0),x===0&&u!==0&&d[u-1].getWidth(l-1)===2&&(d[u].copyCellsFrom(d[u-1],l-1,x++,1,!1),d[u-1].setCell(l-1,b))}d[u].replaceCells(x,l,b);let j=0;for(let w=d.length-1;w>0&&(w>u||d[w].getTrimmedLength()===0);w--)j++;j>0&&(S.push(v+d.length-j),S.push(j)),v+=d.length-1}return S},i.reflowLargerCreateNewLayout=function(c,h){const l=[];let g=0,b=h[g],S=0;for(let v=0;v<c.length;v++)if(b===v){const o=h[++g];c.onDeleteEmitter.fire({index:v-S,amount:o}),v+=o-1,S+=o,b=h[++g]}else l.push(v);return{layout:l,countRemoved:S}},i.reflowLargerApplyNewLayout=function(c,h){const l=[];for(let g=0;g<h.length;g++)l.push(c.get(h[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=h.length},i.reflowSmallerGetNewLineLengths=function(c,h,l){const g=[],b=c.map(((f,d)=>n(c,d,h))).reduce(((f,d)=>f+d));let S=0,v=0,o=0;for(;o<b;){if(b-o<l){g.push(b-o);break}S+=l;const f=n(c,v,h);S>f&&(S-=f,v++);const d=c[v].getWidth(S-1)===2;d&&S--;const u=d?l-1:l;g.push(u),o+=u}return g},i.getWrappedLineTrimmedLength=n},5295:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=n(8460),h=n(844),l=n(9092);class g extends h.Disposable{constructor(S,v){super(),this._optionsService=S,this._bufferService=v,this._onBufferActivate=this.register(new c.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 l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.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,v){this._normal.resize(S,v),this._alt.resize(S,v),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}i.BufferSet=g},511:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=n(482),h=n(643),l=n(3734);class g extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const v=new g;return v.setFromCharData(S),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(S[h.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(S[h.CHAR_DATA_CHAR_INDEX].length===2){const o=S[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){const f=S[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=f&&f<=57343?this.content=1024*(o-55296)+f-56320+65536|S[h.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=S[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[h.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=S[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[h.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=n(8460),h=n(844);class l{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,h.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}i.Marker=l,l._nextId=1},7116:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(_,i)=>{var n,c,h;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
|
|
24
|
+
`,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""})(n||(i.C0=n={})),(function(l){l.PAD="",l.HOP="",l.BPH="",l.NBH="",l.IND="",l.NEL="
",l.SSA="",l.ESA="",l.HTS="",l.HTJ="",l.VTS="",l.PLD="",l.PLU="",l.RI="",l.SS2="",l.SS3="",l.DCS="",l.PU1="",l.PU2="",l.STS="",l.CCH="",l.MW="",l.SPA="",l.EPA="",l.SOS="",l.SGCI="",l.SCI="",l.CSI="",l.ST="",l.OSC="",l.PM="",l.APC=""})(c||(i.C1=c={})),(function(l){l.ST=`${n.ESC}\\`})(h||(i.C1_ESCAPED=h={}))},7399:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=n(2584),h={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(l,g,b,S){const v={type:0,cancel:!1,key:void 0},o=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?v.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?v.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?v.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(v.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){v.key=c.C0.ESC+c.C0.DEL;break}v.key=c.C0.DEL;break;case 9:if(l.shiftKey){v.key=c.C0.ESC+"[Z";break}v.key=c.C0.HT,v.cancel=!0;break;case 13:v.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,v.cancel=!0;break;case 27:v.key=c.C0.ESC,l.altKey&&(v.key=c.C0.ESC+c.C0.ESC),v.cancel=!0;break;case 37:if(l.metaKey)break;o?(v.key=c.C0.ESC+"[1;"+(o+1)+"D",v.key===c.C0.ESC+"[1;3D"&&(v.key=c.C0.ESC+(b?"b":"[1;5D"))):v.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;o?(v.key=c.C0.ESC+"[1;"+(o+1)+"C",v.key===c.C0.ESC+"[1;3C"&&(v.key=c.C0.ESC+(b?"f":"[1;5C"))):v.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;o?(v.key=c.C0.ESC+"[1;"+(o+1)+"A",b||v.key!==c.C0.ESC+"[1;3A"||(v.key=c.C0.ESC+"[1;5A")):v.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;o?(v.key=c.C0.ESC+"[1;"+(o+1)+"B",b||v.key!==c.C0.ESC+"[1;3B"||(v.key=c.C0.ESC+"[1;5B")):v.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(v.key=c.C0.ESC+"[2~");break;case 46:v.key=o?c.C0.ESC+"[3;"+(o+1)+"~":c.C0.ESC+"[3~";break;case 36:v.key=o?c.C0.ESC+"[1;"+(o+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:v.key=o?c.C0.ESC+"[1;"+(o+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?v.type=2:l.ctrlKey?v.key=c.C0.ESC+"[5;"+(o+1)+"~":v.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?v.type=3:l.ctrlKey?v.key=c.C0.ESC+"[6;"+(o+1)+"~":v.key=c.C0.ESC+"[6~";break;case 112:v.key=o?c.C0.ESC+"[1;"+(o+1)+"P":c.C0.ESC+"OP";break;case 113:v.key=o?c.C0.ESC+"[1;"+(o+1)+"Q":c.C0.ESC+"OQ";break;case 114:v.key=o?c.C0.ESC+"[1;"+(o+1)+"R":c.C0.ESC+"OR";break;case 115:v.key=o?c.C0.ESC+"[1;"+(o+1)+"S":c.C0.ESC+"OS";break;case 116:v.key=o?c.C0.ESC+"[15;"+(o+1)+"~":c.C0.ESC+"[15~";break;case 117:v.key=o?c.C0.ESC+"[17;"+(o+1)+"~":c.C0.ESC+"[17~";break;case 118:v.key=o?c.C0.ESC+"[18;"+(o+1)+"~":c.C0.ESC+"[18~";break;case 119:v.key=o?c.C0.ESC+"[19;"+(o+1)+"~":c.C0.ESC+"[19~";break;case 120:v.key=o?c.C0.ESC+"[20;"+(o+1)+"~":c.C0.ESC+"[20~";break;case 121:v.key=o?c.C0.ESC+"[21;"+(o+1)+"~":c.C0.ESC+"[21~";break;case 122:v.key=o?c.C0.ESC+"[23;"+(o+1)+"~":c.C0.ESC+"[23~";break;case 123:v.key=o?c.C0.ESC+"[24;"+(o+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(b&&!S||!l.altKey||l.metaKey)!b||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?v.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(v.key=c.C0.US),l.key==="@"&&(v.key=c.C0.NUL)):l.keyCode===65&&(v.type=1);else{const f=h[l.keyCode],d=f?.[l.shiftKey?1:0];if(d)v.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const u=l.ctrlKey?l.keyCode-64:l.keyCode+32;let x=String.fromCharCode(u);l.shiftKey&&(x=x.toUpperCase()),v.key=c.C0.ESC+x}else if(l.keyCode===32)v.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let u=l.code.slice(3,4);l.shiftKey||(u=u.toLowerCase()),v.key=c.C0.ESC+u,v.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?v.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?v.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?v.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?v.key=c.C0.DEL:l.keyCode===219?v.key=c.C0.ESC:l.keyCode===220?v.key=c.C0.FS:l.keyCode===221&&(v.key=c.C0.GS)}return v}},482:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,c=0,h=n.length){let l="";for(let g=c;g<h;++g){let b=n[g];b>65535?(b-=65536,l+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):l+=String.fromCharCode(b)}return l},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,c){const h=n.length;if(!h)return 0;let l=0,g=0;if(this._interim){const b=n.charCodeAt(g++);56320<=b&&b<=57343?c[l++]=1024*(this._interim-55296)+b-56320+65536:(c[l++]=this._interim,c[l++]=b),this._interim=0}for(let b=g;b<h;++b){const S=n.charCodeAt(b);if(55296<=S&&S<=56319){if(++b>=h)return this._interim=S,l;const v=n.charCodeAt(b);56320<=v&&v<=57343?c[l++]=1024*(S-55296)+v-56320+65536:(c[l++]=S,c[l++]=v)}else S!==65279&&(c[l++]=S)}return l}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,c){const h=n.length;if(!h)return 0;let l,g,b,S,v=0,o=0,f=0;if(this.interim[0]){let x=!1,y=this.interim[0];y&=(224&y)==192?31:(240&y)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)y<<=6,y|=k;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=w-j;for(;f<E;){if(f>=h)return 0;if(k=n[f++],(192&k)!=128){f--,x=!0;break}this.interim[j++]=k,y<<=6,y|=63&k}x||(w===2?y<128?f--:c[v++]=y:w===3?y<2048||y>=55296&&y<=57343||y===65279||(c[v++]=y):y<65536||y>1114111||(c[v++]=y)),this.interim.fill(0)}const d=h-4;let u=f;for(;u<h;){for(;!(!(u<d)||128&(l=n[u])||128&(g=n[u+1])||128&(b=n[u+2])||128&(S=n[u+3]));)c[v++]=l,c[v++]=g,c[v++]=b,c[v++]=S,u+=4;if(l=n[u++],l<128)c[v++]=l;else if((224&l)==192){if(u>=h)return this.interim[0]=l,v;if(g=n[u++],(192&g)!=128){u--;continue}if(o=(31&l)<<6|63&g,o<128){u--;continue}c[v++]=o}else if((240&l)==224){if(u>=h)return this.interim[0]=l,v;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=h)return this.interim[0]=l,this.interim[1]=g,v;if(b=n[u++],(192&b)!=128){u--;continue}if(o=(15&l)<<12|(63&g)<<6|63&b,o<2048||o>=55296&&o<=57343||o===65279)continue;c[v++]=o}else if((248&l)==240){if(u>=h)return this.interim[0]=l,v;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=h)return this.interim[0]=l,this.interim[1]=g,v;if(b=n[u++],(192&b)!=128){u--;continue}if(u>=h)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=b,v;if(S=n[u++],(192&S)!=128){u--;continue}if(o=(7&l)<<18|(63&g)<<12|(63&b)<<6|63&S,o<65536||o>1114111)continue;c[v++]=o}}return v}}},225:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],c=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let h;i.UnicodeV6=class{constructor(){if(this.version="6",!h){h=new Uint8Array(65536),h.fill(1),h[0]=0,h.fill(0,1,32),h.fill(0,127,160),h.fill(2,4352,4448),h[9001]=2,h[9002]=2,h.fill(2,11904,42192),h[12351]=1,h.fill(2,44032,55204),h.fill(2,63744,64256),h.fill(2,65040,65050),h.fill(2,65072,65136),h.fill(2,65280,65377),h.fill(2,65504,65511);for(let l=0;l<n.length;++l)h.fill(0,n[l][0],n[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?h[l]:(function(g,b){let S,v=0,o=b.length-1;if(g<b[0][0]||g>b[o][1])return!1;for(;o>=v;)if(S=v+o>>1,g>b[S][1])v=S+1;else{if(!(g<b[S][0]))return!0;o=S-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=n(8460),h=n(844);class l extends h.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 c.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 v;for(this._isSyncWriting=!0;v=this._writeBuffer.shift();){this._action(v);const o=this._callbacks.shift();o&&o()}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 v=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const o=this._writeBuffer[this._bufferOffset],f=this._action(o,S);if(f){const u=x=>Date.now()-v>=12?setTimeout((()=>this._innerWrite(0,x))):this._innerWrite(v,x);return void f.catch((x=>(queueMicrotask((()=>{throw x})),Promise.resolve(!1)))).then(u)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=o.length,Date.now()-v>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=l},5941:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c=/^[\da-f]+$/;function h(l,g){const b=l.toString(16),S=b.length<2?"0"+b:b;switch(g){case 4:return b[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}i.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const b=n.exec(g);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(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const b=g.length/3,S=[0,0,0];for(let v=0;v<3;++v){const o=parseInt(g.slice(b*v,b*v+b),16);S[v]=b===1?o<<4:b===2?o:b===3?o>>4:o>>8}return S}},i.toRgbString=function(l,g=16){const[b,S,v]=l;return`rgb:${h(b,g)}/${h(S,g)}/${h(v,g)}`}},5770:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=n(482),h=n(8742),l=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(S,v){this._handlers[S]===void 0&&(this._handlers[S]=[]);const o=this._handlers[S];return o.push(v),{dispose:()=>{const f=o.indexOf(v);f!==-1&&o.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=g,this._ident=0}hook(S,v){if(this.reset(),this._ident=S,this._active=this._handlers[S]||g,this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].hook(v);else this._handlerFb(this._ident,"HOOK",v)}put(S,v,o){if(this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].put(S,v,o);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(S,v,o))}unhook(S,v=!0){if(this._active.length){let o=!1,f=this._active.length-1,d=!1;if(this._stack.paused&&(f=this._stack.loopPosition-1,o=v,d=this._stack.fallThrough,this._stack.paused=!1),!d&&o===!1){for(;f>=0&&(o=this._active[f].unhook(S),o!==!0);f--)if(o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!1,o;f--}for(;f>=0;f--)if(o=this._active[f].unhook(!1),o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!0,o}else this._handlerFb(this._ident,"UNHOOK",S);this._active=g,this._ident=0}};const b=new h.Params;b.addParam(0),i.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,v,o){this._hitLimit||(this._data+=(0,c.utf32ToString)(S,v,o),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let v=!1;if(this._hitLimit)v=!1;else if(S&&(v=this._handler(this._data,this._params),v instanceof Promise))return v.then((o=>(this._params=b,this._data="",this._hitLimit=!1,o)));return this._params=b,this._data="",this._hitLimit=!1,v}}},2015:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=n(844),h=n(8742),l=n(6242),g=n(6351);class b{constructor(f){this.table=new Uint8Array(f)}setDefault(f,d){this.table.fill(f<<4|d)}add(f,d,u,x){this.table[d<<8|f]=u<<4|x}addMany(f,d,u,x){for(let y=0;y<f.length;y++)this.table[d<<8|f[y]]=u<<4|x}}i.TransitionTable=b;const S=160;i.VT500_TRANSITION_TABLE=(function(){const o=new b(4095),f=Array.apply(null,Array(256)).map(((j,w)=>w)),d=(j,w)=>f.slice(j,w),u=d(32,127),x=d(0,24);x.push(25),x.push.apply(x,d(28,32));const y=d(0,14);let k;for(k in o.setDefault(1,0),o.addMany(u,0,2,0),y)o.addMany([24,26,153,154],k,3,0),o.addMany(d(128,144),k,3,0),o.addMany(d(144,152),k,3,0),o.add(156,k,0,0),o.add(27,k,11,1),o.add(157,k,4,8),o.addMany([152,158,159],k,0,7),o.add(155,k,11,3),o.add(144,k,11,9);return o.addMany(x,0,3,0),o.addMany(x,1,3,1),o.add(127,1,0,1),o.addMany(x,8,0,8),o.addMany(x,3,3,3),o.add(127,3,0,3),o.addMany(x,4,3,4),o.add(127,4,0,4),o.addMany(x,6,3,6),o.addMany(x,5,3,5),o.add(127,5,0,5),o.addMany(x,2,3,2),o.add(127,2,0,2),o.add(93,1,4,8),o.addMany(u,8,5,8),o.add(127,8,5,8),o.addMany([156,27,24,26,7],8,6,0),o.addMany(d(28,32),8,0,8),o.addMany([88,94,95],1,0,7),o.addMany(u,7,0,7),o.addMany(x,7,0,7),o.add(156,7,0,0),o.add(127,7,0,7),o.add(91,1,11,3),o.addMany(d(64,127),3,7,0),o.addMany(d(48,60),3,8,4),o.addMany([60,61,62,63],3,9,4),o.addMany(d(48,60),4,8,4),o.addMany(d(64,127),4,7,0),o.addMany([60,61,62,63],4,0,6),o.addMany(d(32,64),6,0,6),o.add(127,6,0,6),o.addMany(d(64,127),6,0,0),o.addMany(d(32,48),3,9,5),o.addMany(d(32,48),5,9,5),o.addMany(d(48,64),5,0,6),o.addMany(d(64,127),5,7,0),o.addMany(d(32,48),4,9,5),o.addMany(d(32,48),1,9,2),o.addMany(d(32,48),2,9,2),o.addMany(d(48,127),2,10,0),o.addMany(d(48,80),1,10,0),o.addMany(d(81,88),1,10,0),o.addMany([89,90,92],1,10,0),o.addMany(d(96,127),1,10,0),o.add(80,1,11,9),o.addMany(x,9,0,9),o.add(127,9,0,9),o.addMany(d(28,32),9,0,9),o.addMany(d(32,48),9,9,12),o.addMany(d(48,60),9,8,10),o.addMany([60,61,62,63],9,9,10),o.addMany(x,11,0,11),o.addMany(d(32,128),11,0,11),o.addMany(d(28,32),11,0,11),o.addMany(x,10,0,10),o.add(127,10,0,10),o.addMany(d(28,32),10,0,10),o.addMany(d(48,60),10,8,10),o.addMany([60,61,62,63],10,0,11),o.addMany(d(32,48),10,9,12),o.addMany(x,12,0,12),o.add(127,12,0,12),o.addMany(d(28,32),12,0,12),o.addMany(d(32,48),12,9,12),o.addMany(d(48,64),12,0,11),o.addMany(d(64,127),12,12,13),o.addMany(d(64,127),10,12,13),o.addMany(d(64,127),9,12,13),o.addMany(x,13,13,13),o.addMany(u,13,13,13),o.add(127,13,0,13),o.addMany([27,156,24,26],13,14,0),o.add(S,0,2,0),o.add(S,8,5,8),o.add(S,6,0,6),o.add(S,11,0,11),o.add(S,13,13,13),o})();class v extends c.Disposable{constructor(f=i.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 h.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,u,x)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,u)=>{},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,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(f,d=[64,126]){let u=0;if(f.prefix){if(f.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=f.prefix.charCodeAt(0),u&&60>u||u>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 y=0;y<f.intermediates.length;++y){const k=f.intermediates.charCodeAt(y);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=k}}if(f.final.length!==1)throw new Error("final must be a single byte");const x=f.final.charCodeAt(0);if(d[0]>x||x>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return u<<=8,u|=x,u}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 u=this._identifier(f,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const x=this._escHandlers[u];return x.push(d),{dispose:()=>{const y=x.indexOf(d);y!==-1&&x.splice(y,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 u=this._identifier(f);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const x=this._csiHandlers[u];return x.push(d),{dispose:()=>{const y=x.indexOf(d);y!==-1&&x.splice(y,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,u,x,y){this._parseStack.state=f,this._parseStack.handlers=d,this._parseStack.handlerPos=u,this._parseStack.transition=x,this._parseStack.chunkPos=y}parse(f,d,u){let x,y=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(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&E>-1){for(;E>=0&&(x=w[E](this._params),x!==!0);E--)if(x instanceof Promise)return this._parseStack.handlerPos=E,x}this._parseStack.handlers=[];break;case 4:if(u===!1&&E>-1){for(;E>=0&&(x=w[E](),x!==!0);E--)if(x instanceof Promise)return this._parseStack.handlerPos=E,x}this._parseStack.handlers=[];break;case 6:if(y=f[this._parseStack.chunkPos],x=this._dcsParser.unhook(y!==24&&y!==26,u),x)return x;y===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(y=f[this._parseStack.chunkPos],x=this._oscParser.end(y!==24&&y!==26,u),x)return x;y===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 w=j;w<d;++w){switch(y=f[w],k=this._transitions.table[this.currentState<<8|(y<160?y:S)],k>>4){case 2:for(let M=w+1;;++M){if(M>=d||(y=f[M])<32||y>126&&y<S){this._printHandler(f,w,M),w=M-1;break}if(++M>=d||(y=f[M])<32||y>126&&y<S){this._printHandler(f,w,M),w=M-1;break}if(++M>=d||(y=f[M])<32||y>126&&y<S){this._printHandler(f,w,M),w=M-1;break}if(++M>=d||(y=f[M])<32||y>126&&y<S){this._printHandler(f,w,M),w=M-1;break}}break;case 3:this._executeHandlers[y]?this._executeHandlers[y]():this._executeHandlerFb(y),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:w,code:y,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|y];let N=E?E.length-1:-1;for(;N>=0&&(x=E[N](this._params),x!==!0);N--)if(x instanceof Promise)return this._preserveStack(3,E,N,k,w),x;N<0&&this._csiHandlerFb(this._collect<<8|y,this._params),this.precedingCodepoint=0;break;case 8:do switch(y){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(y-48)}while(++w<d&&(y=f[w])>47&&y<60);w--;break;case 9:this._collect<<=8,this._collect|=y;break;case 10:const T=this._escHandlers[this._collect<<8|y];let R=T?T.length-1:-1;for(;R>=0&&(x=T[R](),x!==!0);R--)if(x instanceof Promise)return this._preserveStack(4,T,R,k,w),x;R<0&&this._escHandlerFb(this._collect<<8|y),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|y,this._params);break;case 13:for(let M=w+1;;++M)if(M>=d||(y=f[M])===24||y===26||y===27||y>127&&y<S){this._dcsParser.put(f,w,M),w=M-1;break}break;case 14:if(x=this._dcsParser.unhook(y!==24&&y!==26),x)return this._preserveStack(6,[],0,k,w),x;y===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=w+1;;M++)if(M>=d||(y=f[M])<32||y>127&&y<S){this._oscParser.put(f,w,M),w=M-1;break}break;case 6:if(x=this._oscParser.end(y!==24&&y!==26),x)return this._preserveStack(5,[],0,k,w),x;y===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=v},6242:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=n(5770),h=n(482),l=[];i.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,b){this._handlers[g]===void 0&&(this._handlers[g]=[]);const S=this._handlers[g];return S.push(b),{dispose:()=>{const v=S.indexOf(b);v!==-1&&S.splice(v,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,b,S){if(this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].put(g,b,S);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(g,b,S))}start(){this.reset(),this._state=1}put(g,b,S){if(this._state!==3){if(this._state===1)for(;b<S;){const v=g[b++];if(v===59){this._state=2,this._start();break}if(v<48||57<v)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+v-48}this._state===2&&S-b>0&&this._put(g,b,S)}}end(g,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,v=this._active.length-1,o=!1;if(this._stack.paused&&(v=this._stack.loopPosition-1,S=b,o=this._stack.fallThrough,this._stack.paused=!1),!o&&S===!1){for(;v>=0&&(S=this._active[v].end(g),S!==!0);v--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!1,S;v--}for(;v>=0;v--)if(S=this._active[v].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",g);this._active=l,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,b,S){this._hitLimit||(this._data+=(0,h.utf32ToString)(g,b,S),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let b=!1;if(this._hitLimit)b=!1;else if(g&&(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:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let b=Array.isArray(l[0])?1:0;b<l.length;++b){const S=l[b];if(Array.isArray(S))for(let v=0;v<S.length;++v)g.addSubParam(S[v]);else g.addParam(S)}return g}constructor(l=32,g=32){if(this.maxLength=l,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new c(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let g=0;g<this.length;++g){l.push(this.params[g]);const b=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-b>0&&l.push(Array.prototype.slice.call(this._subParams,b,S))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>n?n:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>n?n:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const g=this._subParamsIdx[l]>>8,b=255&this._subParamsIdx[l];return b-g>0?this._subParams.subarray(g,b):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const b=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-b>0&&(l[g]=this._subParams.slice(b,S))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,S=b[g-1];b[g-1]=~S?Math.min(10*S+l,n):l}}i.Params=c},5741:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,c){const h={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(h),c.dispose=()=>this._wrappedAddonDispose(h),c.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let c=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===n){c=h;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(c,1)}}},8771:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=n(3785),h=n(511);i.BufferApiView=class{constructor(l,g){this._buffer=l,this.type=g}init(l){return this._buffer=l,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(l){const g=this._buffer.lines.get(l);if(g)return new c.BufferLineApiView(g)}getNullCell(){return new h.CellData}}},3785:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=n(511);i.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,l){if(!(h<0||h>=this._line.length))return l?(this._line.loadCell(h,l),l):this._line.loadCell(h,new c.CellData)}translateToString(h,l,g){return this._line.translateToString(h,l,g)}}},8285:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=n(8771),h=n(8460),l=n(844);class g extends l.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new h.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}i.BufferNamespaceApi=g},7975:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,c){return this._core.registerCsiHandler(n,(h=>c(h.toArray())))}addCsiHandler(n,c){return this.registerCsiHandler(n,c)}registerDcsHandler(n,c){return this._core.registerDcsHandler(n,((h,l)=>c(h,l.toArray())))}addDcsHandler(n,c){return this.registerDcsHandler(n,c)}registerEscHandler(n,c){return this._core.registerEscHandler(n,c)}addEscHandler(n,c){return this.registerEscHandler(n,c)}registerOscHandler(n,c){return this._core.registerOscHandler(n,c)}addOscHandler(n,c){return this.registerOscHandler(n,c)}}},7090:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(_,i,n){var c=this&&this.__decorate||function(o,f,d,u){var x,y=arguments.length,k=y<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,f,d,u);else for(var j=o.length-1;j>=0;j--)(x=o[j])&&(k=(y<3?x(k):y>3?x(f,d,k):x(f,d))||k);return y>3&&k&&Object.defineProperty(f,d,k),k},h=this&&this.__param||function(o,f){return function(d,u){f(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const l=n(8460),g=n(844),b=n(5295),S=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let v=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(o){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(o.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(o.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(o,this))}resize(o,f){this.cols=o,this.rows=f,this.buffers.resize(o,f),this._onResize.fire({cols:o,rows:f})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(o,f=!1){const d=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===o.fg&&u.getBg(0)===o.bg||(u=d.getBlankLine(o,f),this._cachedBlankLine=u),u.isWrapped=f;const x=d.ybase+d.scrollTop,y=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;y===d.lines.length-1?k?d.lines.recycle().copyFrom(u):d.lines.push(u.clone()):d.lines.splice(y+1,0,u.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=y-x+1;d.lines.shiftElements(x+1,k-1,-1),d.lines.set(y,u.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(o,f,d){const u=this.buffer;if(o<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else o+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const x=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+o,u.ybase),0),x!==u.ydisp&&(f||this._onScroll.fire(u.ydisp))}};i.BufferService=v=c([h(0,S.IOptionsService)],v)},7994:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,c){this._charsets[n]=c,this.glevel===n&&(this.charset=c)}}},1753:function(_,i,n){var c=this&&this.__decorate||function(u,x,y,k){var j,w=arguments.length,E=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,x,y,k);else for(var N=u.length-1;N>=0;N--)(j=u[N])&&(E=(w<3?j(E):w>3?j(x,y,E):j(x,y))||E);return w>3&&E&&Object.defineProperty(x,y,E),E},h=this&&this.__param||function(u,x){return function(y,k){x(y,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const l=n(2585),g=n(8460),b=n(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function v(u,x){let y=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(y|=64,y|=u.action):(y|=3&u.button,4&u.button&&(y|=64),8&u.button&&(y|=128),u.action===32?y|=32:u.action!==0||x||(y|=3)),y}const o=String.fromCharCode,f={DEFAULT:u=>{const x=[v(u,!1)+32,u.col+32,u.row+32];return x[0]>255||x[1]>255||x[2]>255?"":`\x1B[M${o(x[0])}${o(x[1])}${o(x[2])}`},SGR:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${v(u,!0)};${u.col};${u.row}${x}`},SGR_PIXELS:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${v(u,!0)};${u.x};${u.y}${x}`}};let d=i.CoreMouseService=class extends b.Disposable{constructor(u,x){super(),this._bufferService=u,this._coreService=x,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const y of Object.keys(S))this.addProtocol(y,S[y]);for(const y of Object.keys(f))this.addEncoding(y,f[y]);this.reset()}addProtocol(u,x){this._protocols[u]=x}addEncoding(u,x){this._encodings[u]=x}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const x=this._encodings[this._activeEncoding](u);return x&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(x):this._coreService.triggerDataEvent(x,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,x,y){if(y){if(u.x!==x.x||u.y!==x.y)return!1}else if(u.col!==x.col||u.row!==x.row)return!1;return u.button===x.button&&u.action===x.action&&u.ctrl===x.ctrl&&u.alt===x.alt&&u.shift===x.shift}};i.CoreMouseService=d=c([h(0,l.IBufferService),h(1,l.ICoreService)],d)},6975:function(_,i,n){var c=this&&this.__decorate||function(d,u,x,y){var k,j=arguments.length,w=j<3?u:y===null?y=Object.getOwnPropertyDescriptor(u,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,u,x,y);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(w=(j<3?k(w):j>3?k(u,x,w):k(u,x))||w);return j>3&&w&&Object.defineProperty(u,x,w),w},h=this&&this.__param||function(d,u){return function(x,y){u(x,y,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const l=n(1439),g=n(8460),b=n(844),S=n(2585),v=Object.freeze({insertMode:!1}),o=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let f=i.CoreService=class extends b.Disposable{constructor(d,u,x){super(),this._bufferService=d,this._logService=u,this._optionsService=x,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(v),this.decPrivateModes=(0,l.clone)(o)}reset(){this.modes=(0,l.clone)(v),this.decPrivateModes=(0,l.clone)(o)}triggerDataEvent(d,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const x=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&x.ybase!==x.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((y=>y.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=f=c([h(0,S.IBufferService),h(1,S.ILogService),h(2,S.IOptionsService)],f)},9074:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=n(8055),h=n(8460),l=n(844),g=n(6106);let b=0,S=0;class v extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const u=new o(d);if(u){const x=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),x.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,u,x){var y,k,j;let w=0,E=0;for(const N of this._decorations.getKeyIterator(u))w=(y=N.options.x)!==null&&y!==void 0?y:0,E=w+((k=N.options.width)!==null&&k!==void 0?k:1),d>=w&&d<E&&(!x||((j=N.options.layer)!==null&&j!==void 0?j:"bottom")===x)&&(yield N)}forEachDecorationAtCell(d,u,x,y){this._decorations.forEachByKey(u,(k=>{var j,w,E;b=(j=k.options.x)!==null&&j!==void 0?j:0,S=b+((w=k.options.width)!==null&&w!==void 0?w:1),d>=b&&d<S&&(!x||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===x)&&y(k)}))}}i.DecorationService=v;class o extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=n(2585),h=n(8343);class l{constructor(...b){this._entries=new Map;for(const[S,v]of b)this.set(S,v)}set(b,S){const v=this._entries.get(b);return this._entries.set(b,S),v}forEach(b){for(const[S,v]of this._entries.entries())b(S,v)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}i.ServiceCollection=l,i.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,b){this._services.set(g,b)}getService(g){return this._services.get(g)}createInstance(g,...b){const S=(0,h.getServiceDependencies)(g).sort(((f,d)=>f.index-d.index)),v=[];for(const f of S){const d=this._services.get(f.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${f.id}.`);v.push(d)}const o=S.length>0?S[0].index:b.length;if(b.length!==o)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${o+1} conflicts with ${b.length} static arguments`);return new g(...b,...v)}}},7866:function(_,i,n){var c=this&&this.__decorate||function(o,f,d,u){var x,y=arguments.length,k=y<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,f,d,u);else for(var j=o.length-1;j>=0;j--)(x=o[j])&&(k=(y<3?x(k):y>3?x(f,d,k):x(f,d))||k);return y>3&&k&&Object.defineProperty(f,d,k),k},h=this&&this.__param||function(o,f){return function(d,u){f(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const l=n(844),g=n(2585),b={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let S,v=i.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(o){super(),this._optionsService=o,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(o){for(let f=0;f<o.length;f++)typeof o[f]=="function"&&(o[f]=o[f]())}_log(o,f,d){this._evalLazyOptionalParams(d),o.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+f,...d)}trace(o,...f){var d,u;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,o,f)}debug(o,...f){var d,u;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,o,f)}info(o,...f){var d,u;this._logLevel<=g.LogLevelEnum.INFO&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,o,f)}warn(o,...f){var d,u;this._logLevel<=g.LogLevelEnum.WARN&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,o,f)}error(o,...f){var d,u;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,o,f)}};i.LogService=v=c([h(0,g.IOptionsService)],v),i.setTraceLogger=function(o){S=o},i.traceCall=function(o,f,d){if(typeof d.value!="function")throw new Error("not supported");const u=d.value;d.value=function(...x){if(S.logLevel!==g.LogLevelEnum.TRACE)return u.apply(this,x);S.trace(`GlyphRenderer#${u.name}(${x.map((k=>JSON.stringify(k))).join(", ")})`);const y=u.apply(this,x);return S.trace(`GlyphRenderer#${u.name} return`,y),y}}},7302:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=n(8460),h=n(844),l=n(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class b extends h.Disposable{constructor(v){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const o=Object.assign({},i.DEFAULT_OPTIONS);for(const f in v)if(f in o)try{const d=v[f];o[f]=this._sanitizeAndValidateOption(f,d)}catch(d){console.error(d)}this.rawOptions=o,this.options=Object.assign({},o),this._setupOptions()}onSpecificOptionChange(v,o){return this.onOptionChange((f=>{f===v&&o(this.rawOptions[v])}))}onMultipleOptionChange(v,o){return this.onOptionChange((f=>{v.indexOf(f)!==-1&&o()}))}_setupOptions(){const v=f=>{if(!(f in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);return this.rawOptions[f]},o=(f,d)=>{if(!(f in i.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:v.bind(this,f),set:o.bind(this,f)};Object.defineProperty(this.options,f,d)}}_sanitizeAndValidateOption(v,o){switch(v){case"cursorStyle":if(o||(o=i.DEFAULT_OPTIONS[v]),!(function(f){return f==="block"||f==="underline"||f==="bar"})(o))throw new Error(`"${o}" is not a valid value for ${v}`);break;case"wordSeparator":o||(o=i.DEFAULT_OPTIONS[v]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1e3)break;o=g.includes(o)?o:i.DEFAULT_OPTIONS[v];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw new Error(`${v} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw new Error(`${v} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw new Error(`${v} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw new Error(`${v} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}i.OptionsService=b},2660:function(_,i,n){var c=this&&this.__decorate||function(b,S,v,o){var f,d=arguments.length,u=d<3?S:o===null?o=Object.getOwnPropertyDescriptor(S,v):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(b,S,v,o);else for(var x=b.length-1;x>=0;x--)(f=b[x])&&(u=(d<3?f(u):d>3?f(S,v,u):f(S,v))||u);return d>3&&u&&Object.defineProperty(S,v,u),u},h=this&&this.__param||function(b,S){return function(v,o){S(v,o,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const l=n(2585);let g=i.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 x=S.addMarker(S.ybase+S.y),y={data:b,id:this._nextId++,lines:[x]};return x.onDispose((()=>this._removeMarkerFromLink(y,x))),this._dataByLinkId.set(y.id,y),y.id}const v=b,o=this._getEntryIdKey(v),f=this._entriesWithId.get(o);if(f)return this.addLineToLink(f.id,S.ybase+S.y),f.id;const d=S.addMarker(S.ybase+S.y),u={id:this._nextId++,key:this._getEntryIdKey(v),data:v,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(u,d))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(b,S){const v=this._dataByLinkId.get(b);if(v&&v.lines.every((o=>o.line!==S))){const o=this._bufferService.buffer.addMarker(S);v.lines.push(o),o.onDispose((()=>this._removeMarkerFromLink(v,o)))}}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 v=b.lines.indexOf(S);v!==-1&&(b.lines.splice(v,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};i.OscLinkService=g=c([h(0,l.IBufferService)],g)},8343:(_,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(h){return h[c]||[]},i.createDecorator=function(h){if(i.serviceRegistry.has(h))return i.serviceRegistry.get(h);const l=function(g,b,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(v,o,f){o[n]===o?o[c].push({id:v,index:f}):(o[c]=[{id:v,index:f}],o[n]=o)})(l,g,S)};return l.toString=()=>h,i.serviceRegistry.set(h,l),l}},2585:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const c=n(8343);var h;i.IBufferService=(0,c.createDecorator)("BufferService"),i.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),i.ICoreService=(0,c.createDecorator)("CoreService"),i.ICharsetService=(0,c.createDecorator)("CharsetService"),i.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"})(h||(i.LogLevelEnum=h={})),i.ILogService=(0,c.createDecorator)("LogService"),i.IOptionsService=(0,c.createDecorator)("OptionsService"),i.IOscLinkService=(0,c.createDecorator)("OscLinkService"),i.IUnicodeService=(0,c.createDecorator)("UnicodeService"),i.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(_,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=n(8460),h=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new h.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let g=0;const b=l.length;for(let S=0;S<b;++S){let v=l.charCodeAt(S);if(55296<=v&&v<=56319){if(++S>=b)return g+this.wcwidth(v);const o=l.charCodeAt(S);56320<=o&&o<=57343?v=1024*(v-55296)+o-56320+65536:g+=this.wcwidth(o)}g+=this.wcwidth(v)}return g}}}},a={};function m(_){var i=a[_];if(i!==void 0)return i.exports;var n=a[_]={exports:{}};return r[_].call(n.exports,n,n.exports,m),n.exports}var p={};return(()=>{var _=p;Object.defineProperty(_,"__esModule",{value:!0}),_.Terminal=void 0;const i=m(9042),n=m(3236),c=m(844),h=m(5741),l=m(8285),g=m(7975),b=m(7090),S=["cols","rows"];class v extends c.Disposable{constructor(f){super(),this._core=this.register(new n.Terminal(f)),this._addonManager=this.register(new h.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=x=>this._core.options[x],u=(x,y)=>{this._checkReadonlyOptions(x),this._core.options[x]=y};for(const x in this._core.options){const y={get:d.bind(this,x),set:u.bind(this,x)};Object.defineProperty(this._publicOptions,x,y)}}_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 g.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 l.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,u,x;return this._checkProposedApi(),this._verifyPositiveIntegers((d=f.x)!==null&&d!==void 0?d:0,(u=f.width)!==null&&u!==void 0?u:0,(x=f.height)!==null&&x!==void 0?x:0),this._core.registerDecoration(f)}hasSelection(){return this._core.hasSelection()}select(f,d,u){this._verifyIntegers(f,d,u),this._core.select(f,d,u)}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
|
|
25
|
+
`,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 i}_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")}}_.Terminal=v})(),p})()))})(ii)),ii.exports}var kf=Cf();var Ef=2,jf=1,Nf=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._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 t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(r.getPropertyValue("height")),m=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),_={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},i=_.top+_.bottom,n=_.right+_.left,c=a-i,h=m-n-t;return{cols:Math.max(Ef,Math.floor(h/e.css.cell.width)),rows:Math.max(jf,Math.floor(c/e.css.cell.height))}}};function Rf(e={}){const{cwd:t,cols:r,rows:a,onOutput:m,onExit:p}=e,[_,i]=C.useState(null),[n,c]=C.useState(()=>Yt.isConnected()),[h,l]=C.useState(!1),[g,b]=C.useState(!1),[S,v]=C.useState(!1),o=C.useRef({onOutput:m,onExit:p});o.current={onOutput:m,onExit:p};const f=C.useRef(null);f.current=_,C.useEffect(()=>{if(!_)return;const k=Yt.getSocket(),j=()=>{c(!0),l(!1),i(null),v(!0)},w=()=>{c(!1),l(!1)},E=M=>{M.terminalId===_&&o.current.onOutput?.(M.data)},N=M=>{M.terminalId===_&&(l(!1),o.current.onExit?.(M.exitCode),i(null))},T=M=>{M.terminalId===_&&l(!0)},R=M=>{M.terminalId===_&&l(!1)};return k.on("connect",j),k.on("disconnect",w),k.on(it.TERMINAL_STDOUT,E),k.on(it.TERMINAL_EXIT,N),k.on(it.TERMINAL_SUBSCRIBED,T),k.on(it.TERMINAL_UNSUBSCRIBED,R),c(k.connected),k.connected&&k.emit(ds.SUBSCRIBE,{topic:"terminal",id:_},M=>{M.success&&l(!0)}),()=>{k.off("connect",j),k.off("disconnect",w),k.off(it.TERMINAL_STDOUT,E),k.off(it.TERMINAL_EXIT,N),k.off(it.TERMINAL_SUBSCRIBED,T),k.off(it.TERMINAL_UNSUBSCRIBED,R),k.emit(ds.UNSUBSCRIBE,{topic:"terminal",id:_})}},[_]);const d=C.useCallback(async()=>{const k=Yt.getSocket();if(!k.connected)return null;b(!0);try{const j=await _e.post("/terminals",{socketId:k.id,cwd:t,cols:r,rows:a});return i(j.terminalId),v(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{b(!1)}},[t,r,a]),u=C.useCallback(async()=>{const k=f.current;if(k){try{await _e.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),l(!1)}},[]),x=C.useCallback(k=>{const j=f.current;if(!j)return;Yt.getSocket().emit(ds.TERMINAL_INPUT,{terminalId:j,data:k})},[]),y=C.useCallback((k,j)=>{const w=f.current;if(!w)return;Yt.getSocket().emit(ds.TERMINAL_RESIZE,{terminalId:w,cols:k,rows:j})},[]);return C.useEffect(()=>()=>{const k=f.current;k&&_e.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:_,isConnected:n,isAttached:h,isCreating:g,needsRecreate:S,create:d,destroy:u,sendInput:x,resize:y}}const Af={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"},Tf=ne.memo(function({cwd:t,isVisible:r=!0,onExit:a,onReady:m}){const p=C.useRef(null),_=C.useRef(null),i=C.useRef(null),n=C.useRef(!1),{terminalId:c,isAttached:h,needsRecreate:l,create:g,sendInput:b,resize:S}=Rf({cwd:t,onOutput:C.useCallback(v=>{_.current?.write(v)},[]),onExit:C.useCallback(v=>{_.current?.writeln(`\r
|
|
26
|
+
\x1B[90m[Process exited with code ${v}]\x1B[0m`),a?.(v)},[a])});return C.useEffect(()=>{if(!l)return;const v=_.current;v&&v.writeln(`\r
|
|
27
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[l,g]),C.useLayoutEffect(()=>{if(!p.current)return;const v=new kf.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Af,scrollback:5e3,convertEol:!0}),o=new Nf;v.loadAddon(o),v.open(p.current);const f=(d=0)=>{if(!(d>=5))try{const x=p.current;if(!x||x.clientWidth===0||x.clientHeight===0){setTimeout(()=>f(d+1),50);return}o.fit(),S(v.cols,v.rows)}catch{setTimeout(()=>f(d+1),50)}};return f(0),setTimeout(()=>f(1),100),_.current=v,i.current=o,()=>{v.dispose(),_.current=null,i.current=null}},[S]),C.useEffect(()=>{n.current||(n.current=!0,g())},[g]),C.useEffect(()=>{const v=_.current;if(!v||!h)return;const o=v.onData(f=>{b(f)});return()=>o.dispose()},[b,h]),C.useEffect(()=>{h&&m?.({sendInput:b})},[h,b,m]),C.useEffect(()=>{if(!r)return;const v=i.current,o=_.current,f=p.current;if(!v||!o||!f)return;let d=!1,u;const x=y=>{d||y>=5||(u=requestAnimationFrame(()=>{if(!d)if(f.clientWidth>0&&f.clientHeight>0)try{v.fit(),S(o.cols,o.rows)}catch{}else setTimeout(()=>x(y+1),30)}))};return x(0),()=>{d=!0,u!=null&&cancelAnimationFrame(u)}},[r,S]),C.useEffect(()=>{if(!p.current)return;const v=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const o=i.current,f=_.current,d=p.current;o&&f&&d&&d.clientWidth>0&&d.clientHeight>0&&(o.fit(),S(f.cols,f.rows))}catch{}})});return v.observe(p.current),()=>v.disconnect()},[S]),s.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),s.jsx("div",{ref:p,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Mf=ne.memo(function({commands:t,onSelect:r}){const{t:a}=ce(),[m,p]=C.useState(!1),_=C.useRef(null),i=C.useRef(null);return C.useEffect(()=>{if(!m)return;const n=c=>{_.current&&!_.current.contains(c.target)&&i.current&&!i.current.contains(c.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[m]),t.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{ref:i,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:[s.jsx(Zo,{size:12}),s.jsx("span",{children:a("快捷命令")}),s.jsx(lt,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&s.jsx("div",{ref:_,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:s.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((n,c)=>s.jsxs("button",{onClick:()=>{r(n.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:[s.jsx(rs,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),s.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},c))})})]})]})});let ni=0;function Qn(){return ni+=1,{id:`shell-${ni}`,order:ni}}const Df=ne.memo(function({cwd:t,isVisible:r=!0,quickCommands:a=[]}){const{t:m}=ce(),[p,_]=C.useState(()=>[Qn()]),[i,n]=C.useState(()=>p[0].id),c=C.useRef(new Map),h=C.useCallback(()=>{const v=Qn();_(o=>[...o,v]),n(v.id)},[]),l=C.useCallback((v,o)=>{o.stopPropagation(),c.current.delete(v),_(f=>{const d=f.filter(u=>u.id!==v);return v===i&&d.length>0&&n(d[d.length-1].id),d})},[i]),g=C.useCallback(v=>{c.current.delete(v),_(o=>{const f=o.filter(d=>d.id!==v);return v===i&&f.length>0&&n(f[f.length-1].id),f})},[i]),b=C.useCallback((v,o)=>{c.current.set(v,o.sendInput)},[]),S=C.useCallback(v=>{const o=c.current.get(i);o&&o(v+"\r")},[i]);return s.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[s.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[s.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:p.map(v=>s.jsxs("button",{onClick:()=>n(v.id),className:J("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",v.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[s.jsx(cr,{size:11,className:"shrink-0"}),s.jsx("span",{children:m("Shell {count}",{count:v.order})}),p.length>1&&s.jsx("span",{onClick:o=>l(v.id,o),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:s.jsx(Ot,{size:10})})]},v.id))}),s.jsx("button",{onClick:h,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:s.jsx(vs,{size:14})}),a.length>0&&s.jsx(Mf,{commands:a,onSelect:S})]}),s.jsx("div",{className:"flex-1 overflow-hidden relative",children:p.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(cr,{size:28}),s.jsx("span",{className:"text-xs",children:m("No terminals open")}),s.jsx("button",{onClick:h,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(v=>s.jsx("div",{className:"absolute inset-0",style:{display:v.id===i?"block":"none"},children:s.jsx(Tf,{cwd:t,isVisible:r&&v.id===i,onExit:()=>g(v.id),onReady:o=>b(v.id,o)})},v.id))})]})});function Zn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function Lf(e){if(Array.isArray(e))return e}function Pf(e,t,r){return(t=Wf(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Of(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,m,p,_,i=[],n=!0,c=!1;try{if(p=(r=r.call(e)).next,t!==0)for(;!(n=(a=p.call(r)).done)&&(i.push(a.value),i.length!==t);n=!0);}catch(h){c=!0,m=h}finally{try{if(!n&&r.return!=null&&(_=r.return(),Object(_)!==_))return}finally{if(c)throw m}}return i}}function If(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
28
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,a)}return r}function eo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Jn(Object(r),!0).forEach(function(a){Pf(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Jn(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function Bf(e,t){if(e==null)return{};var r,a,m=Ff(e,t);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(a=0;a<p.length;a++)r=p[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(m[r]=e[r])}return m}function Ff(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}function zf(e,t){return Lf(e)||Of(e,t)||$f(e,t)||If()}function Hf(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Wf(e){var t=Hf(e,"string");return typeof t=="symbol"?t:t+""}function $f(e,t){if(e){if(typeof e=="string")return Zn(e,t);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)?Zn(e,t):void 0}}function Uf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,a)}return r}function so(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(a){Uf(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function qf(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(a){return t.reduceRight(function(m,p){return p(m)},a)}}function js(e){return function t(){for(var r=this,a=arguments.length,m=new Array(a),p=0;p<a;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var _=arguments.length,i=new Array(_),n=0;n<_;n++)i[n]=arguments[n];return t.apply(r,[].concat(m,i))}}}function vr(e){return{}.toString.call(e).includes("Object")}function Kf(e){return!Object.keys(e).length}function Fs(e){return typeof e=="function"}function Xf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Yf(e,t){return vr(t)||Zt("changeType"),Object.keys(t).some(function(r){return!Xf(e,r)})&&Zt("changeField"),t}function Vf(e){Fs(e)||Zt("selectorType")}function Gf(e){Fs(e)||vr(e)||Zt("handlerType"),vr(e)&&Object.values(e).some(function(t){return!Fs(t)})&&Zt("handlersType")}function Qf(e){e||Zt("initialIsRequired"),vr(e)||Zt("initialType"),Kf(e)&&Zt("initialContent")}function Zf(e,t){throw new Error(e[t]||e.default)}var Jf={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"},Zt=js(Zf)(Jf),er={changes:Yf,selector:Vf,handler:Gf,initial:Qf};function em(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};er.initial(e),er.handler(t);var r={current:e},a=js(rm)(r,t),m=js(sm)(r),p=js(er.changes)(e),_=js(tm)(r);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return er.selector(c),c(r.current)}function n(c){qf(a,m,p,_)(c)}return[i,n]}function tm(e,t){return Fs(t)?t(e.current):t}function sm(e,t){return e.current=so(so({},e.current),t),t}function rm(e,t,r){return Fs(t)?t(e.current):Object.keys(r).forEach(function(a){var m;return(m=t[a])===null||m===void 0?void 0:m.call(t,e.current[a])}),r}var im={create:em},nm={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function om(e){return function t(){for(var r=this,a=arguments.length,m=new Array(a),p=0;p<a;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var _=arguments.length,i=new Array(_),n=0;n<_;n++)i[n]=arguments[n];return t.apply(r,[].concat(m,i))}}}function am(e){return{}.toString.call(e).includes("Object")}function lm(e){return e||ro("configIsRequired"),am(e)||ro("configType"),e.urls?(cm(),{paths:{vs:e.urls.monacoBase}}):e}function cm(){console.warn(Aa.deprecation)}function dm(e,t){throw new Error(e[t]||e.default)}var Aa={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!
|
|
29
|
+
You are using deprecated way of configuration.
|
|
30
|
+
|
|
31
|
+
Instead of using
|
|
32
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
33
|
+
use
|
|
34
|
+
monaco.config({ paths: { vs: '...' } })
|
|
35
|
+
|
|
36
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
37
|
+
`},ro=om(dm)(Aa),um={config:lm},hm=function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return function(m){return r.reduceRight(function(p,_){return _(p)},m)}};function Ta(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],Ta(e[r],t[r]))}),eo(eo({},e),t)}var fm={type:"cancelation",msg:"operation is manually canceled"};function oi(e){var t=!1,r=new Promise(function(a,m){e.then(function(p){return t?m(fm):a(p)}),e.catch(m)});return r.cancel=function(){return t=!0},r}var mm=["monaco"],pm=im.create({config:nm,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ma=zf(pm,2),Xs=Ma[0],Pr=Ma[1];function gm(e){var t=um.config(e),r=t.monaco,a=Bf(t,mm);Pr(function(m){return{config:Ta(m.config,a),monaco:r}})}function vm(){var e=Xs(function(t){var r=t.monaco,a=t.isInitialized,m=t.resolve;return{monaco:r,isInitialized:a,resolve:m}});if(!e.isInitialized){if(Pr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),oi(ai);if(window.monaco&&window.monaco.editor)return Da(window.monaco),e.resolve(window.monaco),oi(ai);hm(_m,bm)(ym)}return oi(ai)}function _m(e){return document.body.appendChild(e)}function xm(e){var t=document.createElement("script");return e&&(t.src=e),t}function bm(e){var t=Xs(function(a){var m=a.config,p=a.reject;return{config:m,reject:p}}),r=xm("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function ym(){var e=Xs(function(r){var a=r.config,m=r.resolve,p=r.reject;return{config:a,resolve:m,reject:p}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var a=r.m||r;Da(a),e.resolve(a)},function(r){e.reject(r)})}function Da(e){Xs().monaco||Pr({monaco:e})}function Sm(){return Xs(function(e){var t=e.monaco;return t})}var ai=new Promise(function(e,t){return Pr({resolve:e,reject:t})}),La={config:gm,init:vm,__getMonacoInstance:Sm},wm={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},li=wm,Cm={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},km=Cm;function Em({children:e}){return ne.createElement("div",{style:km.container},e)}var jm=Em,Nm=jm;function Rm({width:e,height:t,isEditorReady:r,loading:a,_ref:m,className:p,wrapperProps:_}){return ne.createElement("section",{style:{...li.wrapper,width:e,height:t},..._},!r&&ne.createElement(Nm,null,a),ne.createElement("div",{ref:m,style:{...li.fullWidth,...!r&&li.hide},className:p}))}var Am=Rm,Pa=C.memo(Am);function Tm(e){C.useEffect(e,[])}var Oa=Tm;function Mm(e,t,r=!0){let a=C.useRef(!0);C.useEffect(a.current||!r?()=>{a.current=!1}:e,t)}var bt=Mm;function Ts(){}function hs(e,t,r,a){return Dm(e,a)||Lm(e,t,r,a)}function Dm(e,t){return e.editor.getModel(Ia(e,t))}function Lm(e,t,r,a){return e.editor.createModel(t,r,a?Ia(e,a):void 0)}function Ia(e,t){return e.Uri.parse(t)}function Pm({original:e,modified:t,language:r,originalLanguage:a,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:_,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:c="light",loading:h="Loading...",options:l={},height:g="100%",width:b="100%",className:S,wrapperProps:v={},beforeMount:o=Ts,onMount:f=Ts}){let[d,u]=C.useState(!1),[x,y]=C.useState(!0),k=C.useRef(null),j=C.useRef(null),w=C.useRef(null),E=C.useRef(f),N=C.useRef(o),T=C.useRef(!1);Oa(()=>{let B=La.init();return B.then(F=>(j.current=F)&&y(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?O():B.cancel()}),bt(()=>{if(k.current&&j.current){let B=k.current.getOriginalEditor(),F=hs(j.current,e||"",a||r||"text",p||"");F!==B.getModel()&&B.setModel(F)}},[p],d),bt(()=>{if(k.current&&j.current){let B=k.current.getModifiedEditor(),F=hs(j.current,t||"",m||r||"text",_||"");F!==B.getModel()&&B.setModel(F)}},[_],d),bt(()=>{let B=k.current.getModifiedEditor();B.getOption(j.current.editor.EditorOption.readOnly)?B.setValue(t||""):t!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[t],d),bt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),bt(()=>{let{original:B,modified:F}=k.current.getModel();j.current.editor.setModelLanguage(B,a||r||"text"),j.current.editor.setModelLanguage(F,m||r||"text")},[r,a,m],d),bt(()=>{j.current?.editor.setTheme(c)},[c],d),bt(()=>{k.current?.updateOptions(l)},[l],d);let R=C.useCallback(()=>{if(!j.current)return;N.current(j.current);let B=hs(j.current,e||"",a||r||"text",p||""),F=hs(j.current,t||"",m||r||"text",_||"");k.current?.setModel({original:B,modified:F})},[r,t,m,e,a,p,_]),M=C.useCallback(()=>{!T.current&&w.current&&(k.current=j.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...l}),R(),j.current?.editor.setTheme(c),u(!0),T.current=!0)},[l,c,R]);C.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),C.useEffect(()=>{!x&&!d&&M()},[x,d,M]);function O(){let B=k.current?.getModel();i||B?.original?.dispose(),n||B?.modified?.dispose(),k.current?.dispose()}return ne.createElement(Pa,{width:b,height:g,isEditorReady:d,loading:h,_ref:w,className:S,wrapperProps:v})}var Om=Pm;C.memo(Om);function Im(e){let t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}var Bm=Im,tr=new Map;function Fm({defaultValue:e,defaultLanguage:t,defaultPath:r,value:a,language:m,path:p,theme:_="light",line:i,loading:n="Loading...",options:c={},overrideServices:h={},saveViewState:l=!0,keepCurrentModel:g=!1,width:b="100%",height:S="100%",className:v,wrapperProps:o={},beforeMount:f=Ts,onMount:d=Ts,onChange:u,onValidate:x=Ts}){let[y,k]=C.useState(!1),[j,w]=C.useState(!0),E=C.useRef(null),N=C.useRef(null),T=C.useRef(null),R=C.useRef(d),M=C.useRef(f),O=C.useRef(),B=C.useRef(a),F=Bm(p),z=C.useRef(!1),A=C.useRef(!1);Oa(()=>{let I=La.init();return I.then($=>(E.current=$)&&w(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>N.current?P():I.cancel()}),bt(()=>{let I=hs(E.current,e||a||"",t||m||"",p||r||"");I!==N.current?.getModel()&&(l&&tr.set(F,N.current?.saveViewState()),N.current?.setModel(I),l&&N.current?.restoreViewState(tr.get(p)))},[p],y),bt(()=>{N.current?.updateOptions(c)},[c],y),bt(()=>{!N.current||a===void 0||(N.current.getOption(E.current.editor.EditorOption.readOnly)?N.current.setValue(a):a!==N.current.getValue()&&(A.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),N.current.pushUndoStop(),A.current=!1))},[a],y),bt(()=>{let I=N.current?.getModel();I&&m&&E.current?.editor.setModelLanguage(I,m)},[m],y),bt(()=>{i!==void 0&&N.current?.revealLine(i)},[i],y),bt(()=>{E.current?.editor.setTheme(_)},[_],y);let L=C.useCallback(()=>{if(!(!T.current||!E.current)&&!z.current){M.current(E.current);let I=p||r,$=hs(E.current,a||e||"",t||m||"",I||"");N.current=E.current?.editor.create(T.current,{model:$,automaticLayout:!0,...c},h),l&&N.current.restoreViewState(tr.get(I)),E.current.editor.setTheme(_),i!==void 0&&N.current.revealLine(i),k(!0),z.current=!0}},[e,t,r,a,m,p,c,h,l,_,i]);C.useEffect(()=>{y&&R.current(N.current,E.current)},[y]),C.useEffect(()=>{!j&&!y&&L()},[j,y,L]),B.current=a,C.useEffect(()=>{y&&u&&(O.current?.dispose(),O.current=N.current?.onDidChangeModelContent(I=>{A.current||u(N.current.getValue(),I)}))},[y,u]),C.useEffect(()=>{if(y){let I=E.current.editor.onDidChangeMarkers($=>{let X=N.current.getModel()?.uri;if(X&&$.find(V=>V.path===X.path)){let V=E.current.editor.getModelMarkers({resource:X});x?.(V)}});return()=>{I?.dispose()}}return()=>{}},[y,x]);function P(){O.current?.dispose(),g?l&&tr.set(p,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return ne.createElement(Pa,{width:b,height:S,isEditorReady:y,loading:n,_ref:T,className:v,wrapperProps:o})}var zm=Fm,Hm=C.memo(zm),Wm=Hm,Et=function(e,t){return Number(e.toFixed(t))},$m=function(e,t){return typeof e=="number"?e:t},$e=function(e,t,r){r&&typeof r=="function"&&r(e,t)},Um=function(e){return-Math.cos(e*Math.PI)/2+.5},qm=function(e){return e},Km=function(e){return e*e},Xm=function(e){return e*(2-e)},Ym=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Vm=function(e){return e*e*e},Gm=function(e){return--e*e*e+1},Qm=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Zm=function(e){return e*e*e*e},Jm=function(e){return 1- --e*e*e*e},ep=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},tp=function(e){return e*e*e*e*e},sp=function(e){return 1+--e*e*e*e*e},rp=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Ba={easeOut:Um,linear:qm,easeInQuad:Km,easeOutQuad:Xm,easeInOutQuad:Ym,easeInCubic:Vm,easeOutCubic:Gm,easeInOutCubic:Qm,easeInQuart:Zm,easeOutQuart:Jm,easeInOutQuart:ep,easeInQuint:tp,easeOutQuint:sp,easeInOutQuint:rp},Fa=function(e){typeof e=="number"&&cancelAnimationFrame(e)},At=function(e){e.mounted&&(Fa(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function za(e,t,r,a){if(e.mounted){var m=new Date().getTime(),p=1;At(e),e.animation=function(){if(!e.mounted)return Fa(e.animation);var _=new Date().getTime()-m,i=_/r,n=Ba[t],c=n(i);_>=r?(a(p),e.animation=null):e.animation&&(a(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ip(e){var t=e.scale,r=e.positionX,a=e.positionY;return!(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(a))}function ts(e,t,r,a){var m=ip(t);if(!(!e.mounted||!m)){var p=e.setTransformState,_=e.transformState,i=_.scale,n=_.positionX,c=_.positionY,h=t.scale-i,l=t.positionX-n,g=t.positionY-c;r===0?p(t.scale,t.positionX,t.positionY):za(e,a,r,function(b){var S=i+h*b,v=n+l*b,o=c+g*b;p(S,v,o)})}}function np(e,t,r){var a=e.offsetWidth,m=e.offsetHeight,p=t.offsetWidth,_=t.offsetHeight,i=p*r,n=_*r,c=a-i,h=m-n;return{wrapperWidth:a,wrapperHeight:m,newContentWidth:i,newDiffWidth:c,newContentHeight:n,newDiffHeight:h}}var op=function(e,t,r,a,m,p,_){var i=e>t?r*(_?1:.5):0,n=a>m?p*(_?1:.5):0,c=e-t-i,h=i,l=a-m-n,g=n;return{minPositionX:c,maxPositionX:h,minPositionY:l,maxPositionY:g}},an=function(e,t){var r=e.wrapperComponent,a=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!a)throw new Error("Components are not mounted");var p=np(r,a,t),_=p.wrapperWidth,i=p.wrapperHeight,n=p.newContentWidth,c=p.newDiffWidth,h=p.newContentHeight,l=p.newDiffHeight,g=op(_,n,c,i,h,l,!!m);return g},Si=function(e,t,r,a){return a?e<t?Et(t,2):e>r?Et(r,2):Et(e,2):Et(e,2)},is=function(e,t){var r=an(e,t);return e.bounds=r,r};function Ys(e,t,r,a,m,p,_){var i=r.minPositionX,n=r.minPositionY,c=r.maxPositionX,h=r.maxPositionY,l=0,g=0;_&&(l=m,g=p);var b=Si(e,i-l,c+l,a),S=Si(t,n-g,h+g,a);return{x:b,y:S}}function Or(e,t,r,a,m,p){var _=e.transformState,i=_.scale,n=_.positionX,c=_.positionY,h=a-i;if(typeof t!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:c};var l=n-t*h,g=c-r*h,b=Ys(l,g,m,p,0,0,null);return b}function Vs(e,t,r,a,m){var p=m?a:0,_=t-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(t)&&e<=_?_:e}var io=function(e,t){var r=e.setup.panning.excluded,a=e.isInitialized,m=e.wrapperComponent,p=t.target,_="shadowRoot"in p&&"composedPath"in t,i=_?t.composedPath().some(function(h){return h instanceof Element?m?.contains(h):!1}):m?.contains(p),n=a&&p&&i;if(!n)return!1;var c=Ir(p,r);return!c},no=function(e){var t=e.isInitialized,r=e.isPanning,a=e.setup,m=a.panning.disabled,p=t&&r&&!m;return!!p},ap=function(e,t){var r=e.transformState,a=r.positionX,m=r.positionY;e.isPanning=!0;var p=t.clientX,_=t.clientY;e.startCoords={x:p-a,y:_-m}},lp=function(e,t){var r=t.touches,a=e.transformState,m=a.positionX,p=a.positionY;e.isPanning=!0;var _=r.length===1;if(_){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-m,y:n-p}}};function cp(e){var t=e.transformState,r=t.positionX,a=t.positionY,m=t.scale,p=e.setup,_=p.disabled,i=p.limitToBounds,n=p.centerZoomedOut,c=e.wrapperComponent;if(!(_||!c||!e.bounds)){var h=e.bounds,l=h.maxPositionX,g=h.minPositionX,b=h.maxPositionY,S=h.minPositionY,v=r>l||r<g,o=a>b||a<S,f=r>l?c.offsetWidth:e.setup.minPositionX||0,d=a>b?c.offsetHeight:e.setup.minPositionY||0,u=Or(e,f,d,m,e.bounds,i||n),x=u.x,y=u.y;return{scale:m,positionX:v?x:r,positionY:o?y:a}}}function Ha(e,t,r,a,m){var p=e.setup.limitToBounds,_=e.wrapperComponent,i=e.bounds,n=e.transformState,c=n.scale,h=n.positionX,l=n.positionY;if(!(_===null||i===null||t===h&&r===l)){var g=Ys(t,r,i,p,a,m,_),b=g.x,S=g.y;e.setTransformState(c,b,S)}}var dp=function(e,t,r){var a=e.startCoords,m=e.transformState,p=e.setup.panning,_=p.lockAxisX,i=p.lockAxisY,n=m.positionX,c=m.positionY;if(!a)return{x:n,y:c};var h=t-a.x,l=r-a.y,g=_?n:h,b=i?c:l;return{x:g,y:b}},es=function(e,t){var r=e.setup,a=e.transformState,m=a.scale,p=r.minScale,_=r.disablePadding;return t>0&&m>=p&&!_?t:0},up=function(e){var t=e.mounted,r=e.setup,a=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,_=m.disabled,i=!_||p>1||!a||t;return!!i},hp=function(e){var t=e.mounted,r=e.velocity,a=e.bounds,m=e.setup,p=m.disabled,_=m.velocityAnimation,i=e.transformState.scale,n=_.disabled,c=!n||i>1||!p||t;return!(!c||!r||!a)};function fp(e,t){var r=e.setup.velocityAnimation,a=r.equalToMove,m=r.animationTime,p=r.sensitivity;return a?m*t*p:m}function oo(e,t,r,a,m,p,_,i,n,c){if(m){if(t>_&&r>_){var h=_+(e-_)*c;return h>n?n:h<_?_:h}if(t<p&&r<p){var h=p+(e-p)*c;return h<i?i:h>p?p:h}}return a?t:Si(e,p,_,m)}function mp(e,t){var r=1;return t?Math.min(r,e.offsetWidth/window.innerWidth):r}function pp(e,t){var r=up(e);if(r){var a=e.lastMousePosition,m=e.velocityTime,p=e.setup,_=e.wrapperComponent,i=p.velocityAnimation.equalToMove,n=Date.now();if(a&&m&&_){var c=mp(_,i),h=t.x-a.x,l=t.y-a.y,g=h/c,b=l/c,S=n-m,v=h*h+l*l,o=Math.sqrt(v)/S;e.velocity={velocityX:g,velocityY:b,total:o}}e.lastMousePosition=t,e.velocityTime=n}}function gp(e){var t=e.velocity,r=e.bounds,a=e.setup,m=e.wrapperComponent,p=hp(e);if(!(!p||!t||!r||!m)){var _=t.velocityX,i=t.velocityY,n=t.total,c=r.maxPositionX,h=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,b=a.limitToBounds,S=a.alignmentAnimation,v=a.zoomAnimation,o=a.panning,f=o.lockAxisY,d=o.lockAxisX,u=v.animationType,x=S.sizeX,y=S.sizeY,k=S.velocityAlignmentTime,j=k,w=fp(e,n),E=Math.max(w,j),N=es(e,x),T=es(e,y),R=N*m.offsetWidth/100,M=T*m.offsetHeight/100,O=c+R,B=h-R,F=l+M,z=g-M,A=e.transformState,L=new Date().getTime();za(e,u,E,function(P){var I=e.transformState,$=I.scale,X=I.positionX,V=I.positionY,se=new Date().getTime()-L,ae=se/j,D=Ba[S.animationType],H=1-D(Math.min(1,ae)),q=1-P,W=X+_*q,Y=V+i*q,Q=oo(W,A.positionX,X,d,b,h,c,B,O,H),oe=oo(Y,A.positionY,V,f,b,g,l,z,F,H);(X!==W||V!==Y)&&e.setTransformState($,Q,oe)})}}function ao(e,t){var r=e.transformState.scale;At(e),is(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?lp(e,t):ap(e,t)}function ln(e,t){var r=e.transformState.scale,a=e.setup,m=a.minScale,p=a.alignmentAnimation,_=p.disabled,i=p.sizeX,n=p.sizeY,c=p.animationTime,h=p.animationType,l=_||r<m||!i&&!n;if(!l){var g=cp(e);g&&ts(e,g,t??c,h)}}function lo(e,t,r){var a=e.startCoords,m=e.setup,p=m.alignmentAnimation,_=p.sizeX,i=p.sizeY;if(a){var n=dp(e,t,r),c=n.x,h=n.y,l=es(e,_),g=es(e,i);pp(e,{x:c,y:h}),Ha(e,c,h,l,g)}}function vp(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,r=e.velocity,a=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=a?.getBoundingClientRect(),_=m?.getBoundingClientRect(),i=p?.width||0,n=p?.height||0,c=_?.width||0,h=_?.height||0,l=i<c||n<h,g=!t&&r&&r?.total>.1&&l;g?gp(e):ln(e)}}function cn(e,t,r,a){var m=e.setup,p=m.minScale,_=m.maxScale,i=m.limitToBounds,n=Vs(Et(t,2),p,_,0,!1),c=is(e,n),h=Or(e,r,a,n,c,i),l=h.x,g=h.y;return{scale:n,positionX:l,positionY:g}}function Wa(e,t,r){var a=e.transformState.scale,m=e.wrapperComponent,p=e.setup,_=p.minScale,i=p.limitToBounds,n=p.zoomAnimation,c=n.disabled,h=n.animationTime,l=n.animationType,g=c||a>=_;if((a>=1||i)&&ln(e),!(g||!m||!e.mounted)){var b=t||m.offsetWidth/2,S=r||m.offsetHeight/2,v=cn(e,_,b,S);v&&ts(e,v,h,l)}}var Jt=function(){return Jt=Object.assign||function(t){for(var r,a=1,m=arguments.length;a<m;a++){r=arguments[a];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(t[p]=r[p])}return t},Jt.apply(this,arguments)};function co(e,t,r){for(var a=0,m=t.length,p;a<m;a++)(p||!(a in t))&&(p||(p=Array.prototype.slice.call(t,0,a)),p[a]=t[a]);return e.concat(p||Array.prototype.slice.call(t))}var sr={scale:1,positionX:0,positionY:0},ks={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}},wi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},$a=function(e){var t,r,a,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:sr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:sr.scale,positionX:(a=e.initialPositionX)!==null&&a!==void 0?a:sr.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:sr.positionY}},uo=function(e){var t=Jt({},ks);return Object.keys(e).forEach(function(r){var a=typeof e[r]<"u",m=typeof ks[r]<"u";if(m&&a){var p=Object.prototype.toString.call(ks[r]),_=p==="[object Object]",i=p==="[object Array]";_?t[r]=Jt(Jt({},ks[r]),e[r]):i?t[r]=co(co([],ks[r],!0),e[r]):t[r]=e[r]}}),t},Ua=function(e,t,r){var a=e.transformState.scale,m=e.wrapperComponent,p=e.setup,_=p.maxScale,i=p.minScale,n=p.zoomAnimation,c=p.smooth,h=n.size;if(!m)throw new Error("Wrapper is not mounted");var l=c?a*Math.exp(t*r):a+t*r,g=Vs(Et(l,3),i,_,h,!1);return g};function qa(e,t,r,a,m){var p=e.wrapperComponent,_=e.transformState,i=_.scale,n=_.positionX,c=_.positionY;if(!p)return console.error("No WrapperComponent found");var h=p.offsetWidth,l=p.offsetHeight,g=(h/2-n)/i,b=(l/2-c)/i,S=Ua(e,t,r),v=cn(e,S,g,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");ts(e,v,a,m)}function Ka(e,t,r,a){var m=e.setup,p=e.wrapperComponent,_=m.limitToBounds,i=$a(e.props),n=e.transformState,c=n.scale,h=n.positionX,l=n.positionY;if(p){var g=an(e,i.scale),b=Ys(i.positionX,i.positionY,g,_,0,0,p),S={scale:i.scale,positionX:b.x,positionY:b.y};c===i.scale&&h===i.positionX&&l===i.positionY||(a?.(),ts(e,S,t,r))}}function _p(e,t,r,a){var m=e.getBoundingClientRect(),p=t.getBoundingClientRect(),_=r.getBoundingClientRect(),i=p.x*a.scale,n=p.y*a.scale;return{x:(m.x-_.x+i)/a.scale,y:(m.y-_.y+n)/a.scale}}function xp(e,t,r){var a=e.wrapperComponent,m=e.contentComponent,p=e.transformState,_=e.setup,i=_.limitToBounds,n=_.minScale,c=_.maxScale;if(!a||!m)return p;var h=a.getBoundingClientRect(),l=t.getBoundingClientRect(),g=_p(t,a,m,p),b=g.x,S=g.y,v=l.width/p.scale,o=l.height/p.scale,f=a.offsetWidth/v,d=a.offsetHeight/o,u=Vs(r||Math.min(f,d),n,c,0,!1),x=(h.width-v*u)/2,y=(h.height-o*u)/2,k=(h.left-b)*u+x,j=(h.top-S)*u+y,w=an(e,u),E=Ys(k,j,w,i,0,0,a),N=E.x,T=E.y;return{positionX:N,positionY:T,scale:u}}var bp=function(e){return function(t,r,a){t===void 0&&(t=.5),r===void 0&&(r=300),a===void 0&&(a="easeOut"),qa(e,1,t,r,a)}},yp=function(e){return function(t,r,a){t===void 0&&(t=.5),r===void 0&&(r=300),a===void 0&&(a="easeOut"),qa(e,-1,t,r,a)}},Sp=function(e){return function(t,r,a,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var _=e.transformState,i=_.positionX,n=_.positionY,c=_.scale,h=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!h||!l)){var b={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(a)?c:a};ts(e,b,m,p)}}},wp=function(e){return function(t,r){t===void 0&&(t=200),r===void 0&&(r="easeOut"),Ka(e,t,r)}},Cp=function(e){return function(t,r,a){r===void 0&&(r=200),a===void 0&&(a="easeOut");var m=e.transformState,p=e.wrapperComponent,_=e.contentComponent;if(p&&_){var i=Xa(t||m.scale,p,_);ts(e,i,r,a)}}},kp=function(e){return function(t,r,a,m){a===void 0&&(a=600),m===void 0&&(m="easeOut"),At(e);var p=e.wrapperComponent,_=typeof t=="string"?document.getElementById(t):t;if(p&&_&&p.contains(_)){var i=xp(e,_,r);ts(e,i,a,m)}}},_r=function(e){return{instance:e,zoomIn:bp(e),zoomOut:yp(e),setTransform:Sp(e),resetTransform:wp(e),centerView:Cp(e),zoomToElement:kp(e)}},Ci=function(e){return{instance:e,state:e.transformState}},Be=function(e){var t={};return Object.assign(t,Ci(e)),Object.assign(t,_r(e)),t},ci=!1;function di(){try{var e={get passive(){return ci=!0,!1}};return e}catch{return ci=!1,ci}}var rr=".".concat(wi.wrapperClass),Ir=function(e,t){return t.some(function(r){return e.matches("".concat(rr," ").concat(r,", ").concat(rr," .").concat(r,", ").concat(rr," ").concat(r," *, ").concat(rr," .").concat(r," *"))})},ki=function(e){e&&clearTimeout(e)},Ep=function(e,t,r){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},Xa=function(e,t,r){var a=r.offsetWidth*e,m=r.offsetHeight*e,p=(t.offsetWidth-a)/2,_=(t.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:_}};function jp(e){return function(t){e.forEach(function(r){typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var Np=function(e,t){var r=e.setup.wheel,a=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,_=r.excluded,i=e.isInitialized,n=e.isPanning,c=t.target,h=i&&!n&&!a&&c;if(!h||m&&!t.ctrlKey||p&&t.ctrlKey)return!1;var l=Ir(c,_);return!l},Rp=function(e){return e?e.deltaY<0?1:-1:0};function Ap(e,t){var r=Rp(e),a=$m(t,r);return a}function Ya(e,t,r){var a=t.getBoundingClientRect(),m=0,p=0;if("clientX"in e)m=(e.clientX-a.left)/r,p=(e.clientY-a.top)/r;else{var _=e.touches[0];m=(_.clientX-a.left)/r,p=(_.clientY-a.top)/r}return(Number.isNaN(m)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:m,y:p}}var Tp=function(e,t,r,a,m){var p=e.transformState.scale,_=e.wrapperComponent,i=e.setup,n=i.maxScale,c=i.minScale,h=i.zoomAnimation,l=i.disablePadding,g=h.size,b=h.disabled;if(!_)throw new Error("Wrapper is not mounted");var S=p+t*r,v=a?!1:!b,o=Vs(Et(S,3),c,n,g,v&&!l);return o},Mp=function(e,t){var r=e.previousWheelEvent,a=e.transformState.scale,m=e.setup,p=m.maxScale,_=m.minScale;return r?a<p||a>_||Math.sign(r.deltaY)!==Math.sign(t.deltaY)||r.deltaY>0&&r.deltaY<t.deltaY||r.deltaY<0&&r.deltaY>t.deltaY||Math.sign(r.deltaY)!==Math.sign(t.deltaY):!1},Dp=function(e,t){var r=e.setup.pinch,a=r.disabled,m=r.excluded,p=e.isInitialized,_=t.target,i=p&&!a&&_;if(!i)return!1;var n=Ir(_,m);return!n},Lp=function(e){var t=e.setup.pinch.disabled,r=e.isInitialized,a=e.pinchStartDistance,m=r&&!t&&a;return!!m},Pp=function(e,t,r){var a=r.getBoundingClientRect(),m=e.touches,p=Et(m[0].clientX-a.left,5),_=Et(m[0].clientY-a.top,5),i=Et(m[1].clientX-a.left,5),n=Et(m[1].clientY-a.top,5);return{x:(p+i)/2/t,y:(_+n)/2/t}},Va=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))},Op=function(e,t){var r=e.pinchStartScale,a=e.pinchStartDistance,m=e.setup,p=m.maxScale,_=m.minScale,i=m.zoomAnimation,n=m.disablePadding,c=i.size,h=i.disabled;if(!r||a===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var l=t/a,g=l*r;return Vs(Et(g,2),_,p,c,!h&&!n)},Ip=160,Bp=100,Fp=function(e,t){var r=e.props,a=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(At(e),$e(Be(e),t,a),$e(Be(e),t,m))},zp=function(e,t){var r=e.props,a=r.onWheel,m=r.onZoom,p=e.contentComponent,_=e.setup,i=e.transformState,n=i.scale,c=_.limitToBounds,h=_.centerZoomedOut,l=_.zoomAnimation,g=_.wheel,b=_.disablePadding,S=_.smooth,v=l.size,o=l.disabled,f=g.step,d=g.smoothStep;if(!p)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=Ap(t,null),x=S?d*Math.abs(t.deltaY):f,y=Tp(e,u,x,!t.ctrlKey);if(n!==y){var k=is(e,y),j=Ya(t,p,n),w=o||v===0||h||b,E=c&&w,N=Or(e,j.x,j.y,y,k,E),T=N.x,R=N.y;e.previousWheelEvent=t,e.setTransformState(y,T,R),$e(Be(e),t,a),$e(Be(e),t,m)}},Hp=function(e,t){var r=e.props,a=r.onWheelStop,m=r.onZoomStop;ki(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Wa(e,t.x,t.y),e.wheelAnimationTimer=null)},Bp);var p=Mp(e,t);p&&(ki(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,$e(Be(e),t,a),$e(Be(e),t,m))},Ip))},Ga=function(e){for(var t=0,r=0,a=0;a<2;a+=1)t+=e.touches[a].clientX,r+=e.touches[a].clientY;var m=t/2,p=r/2;return{x:m,y:p}},Wp=function(e,t){var r=Va(t);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var a=Ga(t);e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y,At(e)},$p=function(e,t){var r=e.contentComponent,a=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,_=e.setup,i=_.limitToBounds,n=_.centerZoomedOut,c=_.zoomAnimation,h=_.alignmentAnimation,l=c.disabled,g=c.size;if(!(a===null||!r)){var b=Pp(t,p,r);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var S=Va(t),v=Op(e,S),o=Ga(t),f=o.x-(e.pinchLastCenterX||0),d=o.y-(e.pinchLastCenterY||0);if(!(v===p&&f===0&&d===0)){e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y;var u=is(e,v),x=l||g===0||n,y=i&&x,k=Or(e,b.x,b.y,v,u,y),j=k.x,w=k.y;e.pinchMidpoint=b,e.lastDistance=S;var E=h.sizeX,N=h.sizeY,T=es(e,E),R=es(e,N),M=j+f,O=w+d,B=Ys(M,O,u,i,T,R,m),F=B.x,z=B.y;e.setTransformState(v,F,z)}}}},Up=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Wa(e,t?.x,t?.y)},Qa=function(e,t){var r=e.props.onZoomStop,a=e.setup.doubleClick.animationTime;ki(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,$e(Be(e),t,r)},a)},qp=function(e,t){var r=e.props,a=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,_=p.animationTime,i=p.animationType;$e(Be(e),t,a),Ka(e,_,i,function(){return $e(Be(e),t,m)}),Qa(e,t)};function Kp(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Xp(e,t){var r=e.setup,a=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,_=m.scale,i=e.props,n=i.onZoomStart,c=i.onZoom,h=r.doubleClick,l=h.disabled,g=h.mode,b=h.step,S=h.animationTime,v=h.animationType;if(!l&&!a){if(g==="reset")return qp(e,t);if(!p)return console.error("No ContentComponent found");var o=Kp(g,e.transformState.scale),f=Ua(e,o,b);if(_!==f){$e(Be(e),t,n);var d=Ya(t,p,_),u=cn(e,f,d.x,d.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");$e(Be(e),t,c),ts(e,u,S,v),Qa(e,t)}}}var Yp=function(e,t){var r=e.isInitialized,a=e.setup,m=e.wrapperComponent,p=a.doubleClick,_=p.disabled,i=p.excluded,n=t.target,c=m?.contains(n),h=r&&n&&c&&!_;if(!h)return!1;var l=Ir(n,i);return!l},Vp=(function(){function e(t){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(a){r.props=a,is(r,r.transformState.scale),r.setup=uo(a)},this.initializeWindowEvents=function(){var a,m,p=di(),_=(a=r.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=_?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),i?.addEventListener("mousedown",r.onPanningStart,p),i?.addEventListener("mousemove",r.onPanning,p),i?.addEventListener("mouseup",r.onPanningStop,p),_?.addEventListener("mouseleave",r.clearPanning,p),i?.addEventListener("keyup",r.setKeyUnPressed,p),i?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var a,m,p=di(),_=(a=r.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=_?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,p),i?.removeEventListener("mousemove",r.onPanning,p),i?.removeEventListener("mouseup",r.onPanningStop,p),_?.removeEventListener("mouseleave",r.clearPanning,p),i?.removeEventListener("keyup",r.setKeyUnPressed,p),i?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),At(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(a){var m=di();a.addEventListener("wheel",r.onWheelZoom,m),a.addEventListener("dblclick",r.onDoubleClick,m),a.addEventListener("touchstart",r.onTouchPanningStart,m),a.addEventListener("touchmove",r.onTouchPanning,m),a.addEventListener("touchend",r.onTouchPanningStop,m)},this.handleInitialize=function(a,m){var p=!1,_=r.setup.centerOnInit,i=function(n,c){for(var h=0,l=n;h<l.length;h++){var g=l[h];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Be(r))}),r.observer=new ResizeObserver(function(n){if(i(n,a)||i(n,m))if(_&&!p){var c=m.offsetWidth,h=m.offsetHeight;(c>0||h>0)&&(p=!0,r.setCenter())}else At(r),is(r,r.transformState.scale),ln(r,0)}),r.observer.observe(a),r.observer.observe(m)},this.onWheelZoom=function(a){var m=r.setup.disabled;if(!m){var p=Np(r,a);if(p){var _=r.isPressingKeys(r.setup.wheel.activationKeys);_&&(Fp(r,a),zp(r,a),Hp(r,a))}}},this.onWheelPanning=function(a){var m=r.setup,p=m.disabled,_=m.wheel,i=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!_.wheelDisabled||i.disabled||!i.wheelPanning||a.ctrlKey)){a.preventDefault(),a.stopPropagation();var n=r.transformState,c=n.positionX,h=n.positionY,l=c-a.deltaX,g=h-a.deltaY,b=i.lockAxisX?c:l,S=i.lockAxisY?h:g,v=r.setup.alignmentAnimation,o=v.sizeX,f=v.sizeY,d=es(r,o),u=es(r,f);b===c&&S===h||Ha(r,b,S,d,u)}},this.onPanningStart=function(a){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var _=io(r,a);if(_){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(a.button===0&&!r.setup.panning.allowLeftClickPan||a.button===1&&!r.setup.panning.allowMiddleClickPan||a.button===2&&!r.setup.panning.allowRightClickPan||(a.preventDefault(),a.stopPropagation(),At(r),ao(r,a),$e(Be(r),a,p)))}}},this.onPanning=function(a){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var _=no(r);if(_){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(a.preventDefault(),a.stopPropagation(),lo(r,a.clientX,a.clientY),$e(Be(r),a,p))}}},this.onPanningStop=function(a){var m=r.props.onPanningStop;r.isPanning&&(vp(r),$e(Be(r),a,m))},this.onPinchStart=function(a){var m=r.setup.disabled,p=r.props,_=p.onPinchingStart,i=p.onZoomStart;if(!m){var n=Dp(r,a);n&&(Wp(r,a),At(r),$e(Be(r),a,_),$e(Be(r),a,i))}},this.onPinch=function(a){var m=r.setup.disabled,p=r.props,_=p.onPinching,i=p.onZoom;if(!m){var n=Lp(r);n&&(a.preventDefault(),a.stopPropagation(),$p(r,a),$e(Be(r),a,_),$e(Be(r),a,i))}},this.onPinchStop=function(a){var m=r.props,p=m.onPinchingStop,_=m.onZoomStop;r.pinchStartScale&&(Up(r),$e(Be(r),a,p),$e(Be(r),a,_))},this.onTouchPanningStart=function(a){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var _=io(r,a);if(_){var i=r.lastTouch&&+new Date-r.lastTouch<200&&a.touches.length===1;if(!i){r.lastTouch=+new Date,At(r);var n=a.touches,c=n.length===1,h=n.length===2;c&&(At(r),ao(r,a),$e(Be(r),a,p)),h&&r.onPinchStart(a)}}}},this.onTouchPanning=function(a){var m=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&a.touches.length===1){if(m)return;var _=no(r);if(!_)return;a.preventDefault(),a.stopPropagation();var i=a.touches[0];lo(r,i.clientX,i.clientY),$e(Be(r),a,p)}else a.touches.length>1&&r.onPinch(a)},this.onTouchPanningStop=function(a){r.onPanningStop(a),r.onPinchStop(a)},this.onDoubleClick=function(a){var m=r.setup.disabled;if(!m){var p=Yp(r,a);p&&Xp(r,a)}},this.clearPanning=function(a){r.isPanning&&r.onPanningStop(a)},this.setKeyPressed=function(a){r.pressedKeys[a.key]=!0},this.setKeyUnPressed=function(a){r.pressedKeys[a.key]=!1},this.isPressingKeys=function(a){return a.length?!!a.find(function(m){return r.pressedKeys[m]}):!0},this.setTransformState=function(a,m,p){var _=r.props.onTransformed;if(!Number.isNaN(a)&&!Number.isNaN(m)&&!Number.isNaN(p)){a!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=a),r.transformState.positionX=m,r.transformState.positionY=p,r.applyTransformation();var i=Be(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),$e(i,{scale:a,positionX:m,positionY:p},_)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var a=Xa(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(a.scale,a.positionX,a.positionY)}},this.handleTransformStyles=function(a,m,p){return r.props.customTransform?r.props.customTransform(a,m,p):Ep(a,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var a=r.transformState,m=a.scale,p=a.positionX,_=a.positionY,i=r.handleTransformStyles(p,_,m);r.contentComponent.style.transform=i}},this.getContext=function(){return Be(r)},this.onChange=function(a){return r.onChangeCallbacks.has(a)||r.onChangeCallbacks.add(a),function(){r.onChangeCallbacks.delete(a)}},this.onInit=function(a){return r.onInitCallbacks.has(a)||r.onInitCallbacks.add(a),function(){r.onInitCallbacks.delete(a)}},this.init=function(a,m){r.cleanupWindowEvents(),r.wrapperComponent=a,r.contentComponent=m,is(r,r.transformState.scale),r.handleInitializeWrapperEvents(a),r.handleInitialize(a,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=Be(r);$e(p,void 0,r.props.onInit)},this.props=t,this.setup=uo(this.props),this.transformState=$a(this.props)}return e})(),Br=ne.createContext(null),Gp=function(e,t){return typeof e=="function"?e(t):e},Qp=ne.forwardRef(function(e,t){var r=C.useRef(new Vp(e)).current,a=Gp(e.children,_r(r));return C.useImperativeHandle(t,function(){return _r(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ne.createElement(Br.Provider,{value:r},a)});ne.forwardRef(function(e,t){var r=C.useRef(null),a=C.useContext(Br);return C.useEffect(function(){return a.onChange(function(m){if(r.current){var p=0,_=0;r.current.style.transform=a.handleTransformStyles(p,_,1/m.instance.transformState.scale)}})},[a]),ne.createElement("div",Jt({},e,{ref:jp([r,t])}))});function Zp(e,t){t===void 0&&(t={});var r=t.insertAt;if(!(typeof document>"u")){var a=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",r==="top"&&a.firstChild?a.insertBefore(m,a.firstChild):a.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var Jp=`.transform-component-module_wrapper__SPB86 {
|
|
38
|
+
position: relative;
|
|
39
|
+
width: -moz-fit-content;
|
|
40
|
+
width: fit-content;
|
|
41
|
+
height: -moz-fit-content;
|
|
42
|
+
height: fit-content;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
45
|
+
-webkit-user-select: none; /* Safari */
|
|
46
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
47
|
+
-moz-user-select: none; /* Firefox */
|
|
48
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
49
|
+
user-select: none;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
transform: translate3d(0, 0, 0);
|
|
53
|
+
}
|
|
54
|
+
.transform-component-module_content__FBWxo {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-wrap: wrap;
|
|
57
|
+
width: -moz-fit-content;
|
|
58
|
+
width: fit-content;
|
|
59
|
+
height: -moz-fit-content;
|
|
60
|
+
height: fit-content;
|
|
61
|
+
margin: 0;
|
|
62
|
+
padding: 0;
|
|
63
|
+
transform-origin: 0% 0%;
|
|
64
|
+
}
|
|
65
|
+
.transform-component-module_content__FBWxo img {
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
}
|
|
68
|
+
`,ho={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Zp(Jp);var e0=function(e){var t=e.children,r=e.wrapperClass,a=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,_=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,c=n===void 0?{}:n,h=e.contentProps,l=h===void 0?{}:h,g=C.useContext(Br),b=g.init,S=g.cleanupWindowEvents,v=C.useRef(null),o=C.useRef(null);return C.useEffect(function(){var f=v.current,d=o.current;return f!==null&&d!==null&&b&&b?.(f,d),function(){S?.()}},[]),ne.createElement("div",Jt({},c,{ref:v,className:"".concat(wi.wrapperClass," ").concat(ho.wrapper," ").concat(a),style:_}),ne.createElement("div",Jt({},l,{ref:o,className:"".concat(wi.contentClass," ").concat(ho.content," ").concat(p),style:i}),t))},Za=function(){var e=C.useContext(Br);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},t0=function(){var e=Za();return _r(e)};function s0(e){var t=Za(),r=C.useState(e(Ci(t))),a=r[0],m=r[1];return C.useEffect(function(){var p=!0,_=t.onChange(function(i){p&&m(e(Ci(i.instance)))});return function(){_(),p=!1}},[e,t]),a}function r0(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 i0(e,t){return yt({queryKey:le.files.tree(e||"",t),queryFn:()=>_e.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function n0(e,t){return yt({queryKey:le.files.content(e||"",t||""),queryFn:()=>_e.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function o0(e){const t=et();return C.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function a0(){const e=et();return ft({mutationFn:t=>_e.post("/files/write",t),onSuccess:(t,r)=>{const a=le.files.content(r.workingDir,r.path),m=e.getQueryData(a);e.setQueryData(a,{content:r.content,language:m?.language||r0(r.path)})}})}function l0(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function c0(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const d0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function u0(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&d0.has(t)?$i:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?Ls:t==="json"?Hc:t==="md"||t==="mdx"||t==="txt"?Hi:pc}const fo=({depth:e,active:t,onClick:r,leftIcon:a,rightIcon:m,label:p})=>s.jsxs("button",{type:"button",onClick:r,className:J("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",t&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[s.jsx("span",{className:"shrink-0",children:m}),s.jsx("span",{className:"shrink-0 text-neutral-500",children:a}),s.jsx("span",{className:"truncate text-neutral-700",children:p})]}),Ja=({workingDir:e,path:t,depth:r,expanded:a,toggleDir:m,onFileSelect:p,selectedFilePath:_})=>{const{t:i}=ce(),{data:n,isLoading:c,isError:h}=i0(e,t),l=C.useMemo(()=>n?.items??[],[n?.items]);return c?s.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):h?s.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):s.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const f=l0(t,g.name),d=a.has(f);return s.jsxs("div",{children:[s.jsx(fo,{depth:r,onClick:()=>m(f),rightIcon:d?s.jsx(lt,{size:14,className:"text-neutral-400"}):s.jsx(It,{size:14,className:"text-neutral-400"}),leftIcon:d?s.jsx(Cr,{size:14,className:"text-amber-500"}):s.jsx(mc,{size:14,className:"text-amber-500"}),label:g.name}),d&&s.jsx(Ja,{workingDir:e,path:f,depth:r+1,expanded:a,toggleDir:m,onFileSelect:p,selectedFilePath:_})]},f)}const b=c0(t,g.name),S=u0(g),v=_===b,o=S===$i;return s.jsx(fo,{depth:r,active:v,onClick:()=>p(b),rightIcon:s.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?s.jsx(S,{size:14,className:o?"text-emerald-600":"text-sky-600"}):null,label:g.name},b)})})},h0=({workingDir:e,className:t,onFileSelect:r,selectedFilePath:a,onCollapse:m})=>{const{t:p}=ce(),[_,i]=C.useState(()=>new Set),n=o0(e),c=C.useCallback(h=>{i(l=>{const g=new Set(l);return g.has(h)?g.delete(h):g.add(h),g})},[]);return s.jsxs("div",{className:J("h-full flex flex-col",t),children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),s.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&s.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:s.jsx(kr,{size:13})}),m&&s.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:s.jsx(ad,{size:13})})]})]}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?s.jsx(Ja,{workingDir:e,path:"/",depth:0,expanded:_,toggleDir:c,onFileSelect:r,selectedFilePath:a}):s.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},f0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function m0(e){const t=e.split(".").pop()?.toLowerCase();return t?f0.has(t):!1}function p0(e,t){const r="/api",a=new URLSearchParams({workingDir:e,path:t});return`${r}/files/image?${a.toString()}`}const g0=({filePath:e})=>{const{t}=ce(),{zoomIn:r,zoomOut:a,centerView:m}=t0(),p=s0(i=>i.state.scale),_=Math.round(p*100);return s.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:[s.jsx("button",{type:"button",onClick:()=>a(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom out"),children:s.jsx(Cd,{size:14})}),s.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:t("Reset zoom"),children:[_,"%"]}),s.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:t("Zoom in"),children:s.jsx(Sd,{size:14})}),s.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:t("Fit to view"),children:s.jsx(nd,{size:13})}),s.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},v0=({workingDir:e,filePath:t})=>{const{t:r}=ce(),[a,m]=C.useState(!1),p=p0(e,t);return a?s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):s.jsx(Qp,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx(g0,{filePath:t}),s.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:s.jsx(e0,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:s.jsx("img",{src:p,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function _0(e){const t=e.split("/");return t[t.length-1]||e}function x0(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 b0=({active:e,name:t,isDirty:r,onClick:a,onClose:m})=>{const{t:p}=ce();return s.jsxs("button",{type:"button",onClick:a,className:J("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:[s.jsx("span",{className:J("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),s.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),s.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:s.jsx(Ot,{size:12})})]})},y0=({workingDir:e,className:t,readOnly:r=!1})=>{const{t:a}=ce(),[m,p]=C.useState([]),[_,i]=C.useState(null),n=a0(),[c,h]=C.useState(280),[l,g]=C.useState(!1),[b,S]=C.useState(!1),v=C.useRef(280),o=C.useCallback(()=>{g(M=>(M?h(v.current):v.current=c,!M))},[c]),f=C.useCallback(M=>{M.preventDefault(),S(!0);const O=M.clientX,B=c,F=A=>{const L=A.clientX-O,P=Math.min(480,Math.max(160,B+L));h(P)},z=()=>{S(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);C.useEffect(()=>{p([]),i(null)},[e]);const d=C.useMemo(()=>m.find(M=>M.path===_)||null,[m,_]),{data:u,isFetching:x,isError:y,error:k}=n0(e,d?.isImage?null:_);C.useEffect(()=>{!_||!u||p(M=>M.map(O=>O.path!==_||O.isDirty||O.loaded?O:{...O,language:u.language||O.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[_,u]);const j=C.useCallback(M=>{p(O=>{if(O.find(z=>z.path===M))return O;const F=m0(M);return[...O,{path:M,name:_0(M),language:x0(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(M)},[]),w=C.useCallback(M=>{p(O=>{const B=O.filter(F=>F.path!==M);return i(F=>F!==M?F:B.length?B[B.length-1].path:null),B})},[]),E=C.useCallback(M=>{p(O=>O.map(B=>{if(B.path!==_)return B;const F=M!==B.savedContent;return{...B,content:M,isDirty:F}}))},[_]),N=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(M=>M.map(O=>O.path===d.path?{...O,savedContent:O.content,isDirty:!1,loaded:!0}:O)))},[d,r,n,e]),T=C.useRef(()=>{});C.useEffect(()=>{T.current=()=>{N().catch(()=>{})}},[N]),C.useEffect(()=>{const M=O=>{r||(O.metaKey||O.ctrlKey)&&O.key.toLowerCase()==="s"&&(O.preventDefault(),T.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const R=C.useCallback((M,O)=>{M.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.KeyS,()=>{T.current()})},[]);return s.jsxs("div",{className:J("flex h-full overflow-hidden bg-white",t),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:c,transition:b?"none":"width 0.15s ease"},children:l?s.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:s.jsx("button",{type:"button",onClick:o,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:a("Expand file tree"),children:s.jsx(cd,{size:16})})}):s.jsx(s.Fragment,{children:s.jsx(h0,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:o},e||"no-working-dir")})}),!l&&s.jsx("div",{onMouseDown:f,className:J("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.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?s.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:a("No open files")}):m.map(M=>s.jsx(b0,{active:M.path===_,name:M.name,isDirty:M.isDirty,onClick:()=>i(M.path),onClose:O=>{O.stopPropagation(),w(M.path)}},M.path)),s.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&s.jsx("span",{className:"text-[11px] text-neutral-400",children:a("Read-only")}),n.isPending&&s.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),a("Saving")]}),d?.isDirty&&!n.isPending&&s.jsx("span",{className:"text-[11px] text-amber-600",children:a("Unsaved")})]})]}),s.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?s.jsx(v0,{workingDir:e,filePath:d.path}):s.jsxs(s.Fragment,{children:[s.jsx(Wm,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>E(M??""),onMount:R,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),x&&!d.loaded&&s.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:s.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),a("Loading file...")]})}),y&&s.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:[a("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:a("Select a file from the tree to open.")}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:a("No workspace selected.")})})]})]})};function dn(e){return yt({queryKey:le.git.changes(e||""),queryFn:()=>_e.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function el(e,t,r){return yt({queryKey:le.git.diff(e||"",t||"",r),queryFn:()=>_e.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:r}}),enabled:!!e&&!!t})}function tl(e,t){return yt({queryKey:le.git.commitFiles(e||"",t||""),queryFn:()=>_e.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function sl(e,t,r){return yt({queryKey:le.git.commitDiff(e||"",t||"",r||""),queryFn:()=>_e.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:r||""}}),enabled:!!e&&!!t&&!!r})}function cs(e,t){const r=e[t];return typeof r=="string"&&r.length>0?r:void 0}function S0(e){if(!(e instanceof Fo)||e.status!==409)return;const t=e.details;if(t.code!=="MERGE_CONFLICT"||t.conflictOp!==Ms.REBASE&&t.conflictOp!==Ms.MERGE||!Array.isArray(t.conflictedFiles)||!t.conflictedFiles.every(a=>typeof a=="string"))return;const r=t.mergeStrategy==="squash"||t.mergeStrategy==="no_ff"?t.mergeStrategy:void 0;return{conflictOp:t.conflictOp,conflictedFiles:t.conflictedFiles,mergeAborted:typeof t.mergeAborted=="boolean"?t.mergeAborted:void 0,mergeStrategy:r,sourceBranch:cs(t,"sourceBranch"),targetBranch:cs(t,"targetBranch"),sourceWorktreePath:cs(t,"sourceWorktreePath"),targetWorktreePath:cs(t,"targetWorktreePath"),sourceWorkspaceId:cs(t,"sourceWorkspaceId"),targetWorkspaceId:cs(t,"targetWorkspaceId")}}function mo(e,t,r,a){const m=S0(e);if(m){r(m);return}a(e instanceof Error?e.message:t)}function rl({workspaceId:e,branchName:t,targetBranch:r,commitMessage:a,committedFileCount:m,onRefreshCommitMessage:p,onConflict:_,onResolveConflicts:i}){const{t:n}=ce(),{data:c,isLoading:h}=en(e),l=lh(),g=oh(),b=ya(),[S,v]=C.useState(!1),[o,f]=C.useState(null),[d,u]=C.useState(""),[x,y]=C.useState(!1);if(C.useEffect(()=>{x||u(a??"")},[a,x]),C.useEffect(()=>{S&&p?.()},[S,p]),h||!c)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-neutral-400 border-b border-neutral-100",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const k=c.conflictedFiles.length>0,j=c.operation!=="idle",w=c.hasUncommittedChanges||c.untrackedCount>0,E=c.uncommittedCount+c.untrackedCount,N=!k&&!j&&!w,T=c.operation==="idle"&&c.ahead===0&&c.behind===0&&!w&&!k,R=()=>{f(null),l.mutate(e,{onError:F=>{mo(F,n("更新失败,请稍后重试"),z=>_(z),f)}})},M=()=>{f(null),y(!1),u(a??""),v(!0)},O=()=>{f(null);const F=d.trim()||void 0;g.mutate({id:e,commitMessage:F},{onSuccess:()=>v(!1),onError:z=>{mo(z,n("提交失败,请稍后重试"),A=>{v(!1),_(A)},f)}})},B=()=>{g.isPending||(v(!1),f(null))};return T?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-neutral-400 border-b border-neutral-100",children:[s.jsx(ed,{size:13}),s.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-b border-neutral-200 bg-white",children:s.jsxs("div",{className:"px-3 py-2",children:[o&&s.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:o}),w&&s.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:[s.jsx(Uc,{size:12,className:"shrink-0"}),s.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),k&&s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[s.jsx(Bi,{size:13,className:"shrink-0"}),s.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:c.conflictedFiles.length})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:n("处理冲突")}),s.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-neutral-600 hover:bg-neutral-100 border border-neutral-200 transition-colors disabled:opacity-50",children:b.isPending?n("正在撤销..."):n("撤销操作")})]})]}),j&&!k&&s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-700",children:[s.jsx(Fe,{size:13,className:"animate-spin shrink-0"}),s.jsx("span",{children:c.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),s.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-neutral-600 hover:bg-neutral-100 border border-neutral-200 transition-colors disabled:opacity-50",children:[s.jsx(bc,{size:12}),b.isPending?n("正在撤销..."):n("撤销操作")]})]}),!k&&!j&&(c.behind>0||c.ahead>0)&&s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.behind>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-neutral-600",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:c.behind})}),s.jsxs("button",{onClick:R,disabled:!N||l.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 transition-colors disabled:opacity-50",children:[s.jsx(kr,{size:12}),l.isPending?n("正在同步..."):n("同步更新")]})]}),c.ahead>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-neutral-600",children:n("{count} 个文件变更,可以安全提交",{count:m??c.ahead})}),c.behind===0&&!w?s.jsxs("button",{onClick:M,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:[s.jsx(Gr,{size:12}),n("提交变更")]}):s.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-neutral-400 bg-neutral-50 border border-neutral-200 cursor-not-allowed",title:n(w?"需要先处理本地改动":"需要先同步源分支更新"),children:[s.jsx(Gr,{size:12}),n("提交变更")]})]})]})]})}),s.jsx(zs,{isOpen:S,onClose:B,title:n("提交变更"),className:"max-w-md",action:s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:B,disabled:g.isPending,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:n("取消")}),s.jsx("button",{onClick:O,disabled:g.isPending,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 rounded-lg transition-colors disabled:opacity-50",children:g.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:14,className:"animate-spin"}),n("正在提交...")]}):s.jsxs(s.Fragment,{children:[s.jsx(Gr,{size:14}),n("确认提交")]})})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2 py-0.5 rounded bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),s.jsx(Nc,{size:14,className:"text-neutral-400 shrink-0"}),s.jsx("span",{className:"px-2 py-0.5 rounded bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1.5",children:n("提交消息")}),s.jsx("textarea",{value:d,onChange:F=>{y(!0),u(F.target.value)},placeholder:n("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-lg border border-neutral-200 text-sm font-mono text-neutral-800 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-300 resize-none"}),s.jsx("p",{className:"mt-1.5 text-[11px] text-neutral-400 leading-relaxed",children:n("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!d.trim()&&s.jsx("p",{className:"mt-1 text-[11px] text-neutral-400",children:n("留空将使用默认消息")})]}),o&&s.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-50 border border-red-200 text-sm text-red-700",children:o})]})})]})}const po={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"},w0={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function C0(e){const t=e.split("/");return t[t.length-1]||e}function k0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const E0=({entry:e,selected:t,onClick:r})=>{const{t:a}=ce(),m=po[e.status]||po.M,p=w0[e.status]||e.status,_=k0(e.path);return s.jsxs("button",{type:"button",onClick:r,className:J("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",t?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:J("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:a(p),children:e.status}),s.jsx("span",{className:"text-xs text-neutral-900 truncate",children:C0(e.path)}),_&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:_})]})},go=({title:e,entries:t,type:r,selectedKey:a,onSelect:m})=>{const{t:p}=ce();return t.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),s.jsx("div",{className:"space-y-0.5",children:t.map(_=>{const i=`${r}:${_.path}`;return s.jsx(E0,{entry:_,selected:a===i,onClick:()=>m(_.path,r)},i)})})]})},j0=({line:e,lineNum:t})=>{let r="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",a="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),s.jsxs("div",{className:J("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:J("pl-2 whitespace-pre",a),children:e})]})},N0=({workingDir:e,filePath:t,type:r})=>{const{t:a}=ce(),{data:m,isLoading:p,isError:_}=el(e,t,r);if(p)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(_)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:a("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const n=i.split(`
|
|
69
|
+
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,h)=>s.jsx(j0,{line:c,lineNum:h+1},h))})},R0=({workingDir:e,workspaceId:t,branchName:r,targetBranch:a,commitMessage:m,canRunGitOperations:p,onRefreshCommitMessage:_,onConflict:i,onResolveConflicts:n})=>{const{t:c}=ce(),{data:h,isLoading:l,isError:g}=dn(e),[b,S]=C.useState(null),[v,o]=C.useState(260),[f,d]=C.useState(!1),u=C.useCallback(N=>{N.preventDefault(),d(!0);const T=N.clientX,R=v,M=B=>{const F=B.clientX-T,z=Math.min(480,Math.max(160,R+F));o(z)},O=()=>{d(!1),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",O)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",O)},[v]),x=b?`${b.type}:${b.path}`:null,y=(N,T)=>{S({path:N,type:T})};if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:c("No workspace selected.")});if(l)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:c("Loading changes...")})]});if(g)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:c("Failed to load changes.")});const k=h?.uncommitted||[],j=h?.committed||[],w=k.length+j.length,E=p&&t&&r&&a;return s.jsxs("div",{className:"flex flex-col h-full bg-white",children:[E&&i&&n&&s.jsx(rl,{workspaceId:t,branchName:r,targetBranch:a,commitMessage:m,committedFileCount:j.length,onRefreshCommitMessage:_,onConflict:i,onResolveConflicts:n}),s.jsxs("div",{className:"flex flex-1 min-h-0",style:f?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:v},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_s,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:c("Changes")}),w>0&&s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:w})]})}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:w===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[s.jsx(_s,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:c("No pending changes")})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(go,{title:"Uncommitted",entries:k,type:"uncommitted",selectedKey:x,onSelect:y}),s.jsx(go,{title:"Committed",entries:j,type:"committed",selectedKey:x,onSelect:y})]})})]}),s.jsx("div",{onMouseDown:u,className:J("w-1 shrink-0 cursor-col-resize transition-colors",f?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:b?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(Ls,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:b.path}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",c(b.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),s.jsx(N0,{workingDir:e,filePath:b.path,type:b.type})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Ls,{size:28}),s.jsx("span",{className:"text-xs",children:c("Select a file to view diff")})]})})})]})]})},ui=50,vo={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 A0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Gt("{count}s ago",{count:r}):r<3600?Gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function T0(e){const t=e.split("/");return t[t.length-1]||e}function M0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const D0=({line:e,lineNum:t})=>{let r="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",a="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),s.jsxs("div",{className:J("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:J("pl-2 whitespace-pre",a),children:e})]})},L0=({workingDir:e,hash:t,filePath:r})=>{const{t:a}=ce(),{data:m,isLoading:p,isError:_}=sl(e,t,r);if(p)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(_)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:a("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const n=i.split(`
|
|
70
|
+
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,h)=>s.jsx(D0,{line:c,lineNum:h+1},h))})},P0=({workingDir:e,hash:t,selectedPath:r,onSelectFile:a})=>{const{t:m}=ce(),{data:p,isLoading:_}=tl(e,t);if(_)return s.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[s.jsx(Fe,{size:12,className:"animate-spin"}),s.jsx("span",{children:m("Loading...")})]});const i=p?.files||[];return i.length===0?s.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):s.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const c=vo[n.status]||vo.M,h=M0(n.path);return s.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),a(n.path)},className:J("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",r===n.path?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:J("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:n.status}),s.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:T0(n.path)}),h&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:h})]},n.path)})})},O0=({workingDir:e})=>{const{t}=ce(),{data:r,isLoading:a,isError:m,fetchNextPage:p,hasNextPage:_,isFetchingNextPage:i}=Yo({queryKey:le.git.log(e||""),queryFn:({pageParam:y=0})=>_e.get("/git/log",{params:{workingDir:e||"",limit:String(ui),skip:String(y)}}),initialPageParam:0,getNextPageParam:(y,k)=>y.commits.length<ui?void 0:k.length*ui,enabled:!!e}),n=r?.pages.flatMap(y=>y.commits)||[],[c,h]=C.useState(null),[l,g]=C.useState(null),[b,S]=C.useState(280),[v,o]=C.useState(!1),f=C.useCallback(y=>{y.preventDefault(),o(!0);const k=y.clientX,j=b,w=N=>{const T=Math.min(480,Math.max(180,j+(N.clientX-k)));S(T)},E=()=>{o(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)},[b]),d=y=>{c===y?(h(null),g(null)):(h(y),g(null))},u=C.useRef(null);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(a)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(n.length===0)return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[s.jsx(xs,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No commit history")})]});const x=n.find(y=>y.hash===c);return s.jsxs("div",{className:"flex h-full bg-white",style:v?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:b},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xs,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n.length})]})}),s.jsxs("div",{ref:u,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(y=>{const k=c===y.hash;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>d(y.hash),className:J("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",k?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:s.jsx("div",{className:J("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:y.shortHash}),s.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:y.message}),s.jsx(It,{size:12,className:J("shrink-0 text-neutral-400 transition-transform",k&&"rotate-90")})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:y.author}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:A0(y.timestamp)})]})]})]}),k&&s.jsxs(s.Fragment,{children:[y.body&&s.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-neutral-600 whitespace-pre-wrap leading-4 border-l-2 border-blue-100 ml-3",children:y.body}),s.jsx(P0,{workingDir:e,hash:y.hash,selectedPath:l,onSelectFile:g})]})]},y.hash)}),_&&s.jsx("button",{type:"button",onClick:()=>p(),disabled:i,className:"w-full py-2 text-xs text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded transition-colors flex items-center justify-center gap-1.5",children:i?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),s.jsx("div",{onMouseDown:f,className:J("w-1 shrink-0 cursor-col-resize transition-colors",v?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(Ls,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:l}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",x?.shortHash,")"]})]}),s.jsx(L0,{workingDir:e,hash:c,filePath:l})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Ls,{size:28}),s.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function I0(e){return yt({queryKey:le.previews.status(e??""),queryFn:async()=>{const t=await _e.get(`/previews/${e}/status`);return{...t,viewUrl:t.viewUrl?t.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function B0(e){const t=et();return ft({mutationFn:r=>_e.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(t.invalidateQueries({queryKey:le.previews.status(e)}),t.invalidateQueries({queryKey:le.workspaces.all}))}})}function F0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function z0({workspaceId:e,readOnly:t}){const{t:r}=ce(),{data:a,isLoading:m,refetch:p,isFetching:_}=I0(e),i=B0(e),[n,c]=C.useState(""),[h,l]=C.useState(0);C.useEffect(()=>{c(a?.target??"")},[a?.target]);const g=C.useMemo(()=>!a?.ready||!a.viewUrl?null:`${a.viewUrl}?_=${h}`,[h,a?.ready,a?.viewUrl]),b=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),l(v=>v+1),Rt.success(r("Preview target saved"))}catch(v){const o=v instanceof Error?v.message:r("Failed to save preview target");Rt.error(o)}},S=async()=>{await p(),l(v=>v+1)};return e?s.jsxs("div",{className:"h-full flex flex-col bg-white",children:[s.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:n,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.nativeEvent.isComposing&&(v.preventDefault(),b())},disabled:t||i.isPending,placeholder:F0(),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"}),s.jsxs(Ve,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:t||i.isPending,title:r("Save preview target"),children:[i.isPending?s.jsx(Fe,{className:"animate-spin"}):s.jsx(gd,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),s.jsxs(Ve,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:_,title:r("Refresh preview"),children:[_?s.jsx(Fe,{className:"animate-spin"}):s.jsx(kr,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),a?.ready&&a.viewUrl&&s.jsx(Ve,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:s.jsx("a",{href:a.viewUrl,target:"_blank",rel:"noopener noreferrer",children:s.jsx(zi,{})})})]}),s.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[s.jsx("span",{className:"truncate text-neutral-500",children:m?r("Checking preview target..."):a?.ready?`${r("Proxying")} ${a.target}`:a?.configured?`${r("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),s.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?s.jsx("iframe",{src:g,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"},g):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):s.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function H0(e){switch(e){case kt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case kt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case kt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case kt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function _o(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 W0(e){return e.length<=34?e:`...${e.slice(-31)}`}function il({workspaces:e,teamRun:t,selectedWorkspaceId:r,onSelectWorkspace:a,disabled:m,className:p,buttonClassName:_}){const{t:i}=ce(),[n,c]=C.useState(!1),h=C.useRef(null),l=C.useMemo(()=>on(e,t),[e,t]),g=l.find(b=>b.workspace.id===r)??l[0];return C.useEffect(()=>{if(!n)return;const b=S=>{h.current&&!h.current.contains(S.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]),l.length<=1?null:s.jsxs("div",{ref:h,className:J("relative",p),children:[s.jsxs("button",{type:"button",onClick:()=>c(b=>!b),disabled:m,className:J("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",_),title:i("Workspace"),children:[s.jsx(Ps,{size:14,className:"shrink-0 text-neutral-500"}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",_o(g.roleLabel)),children:i(g.roleLabel)}),s.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),s.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:W0(ns(g.workspace))}),s.jsx(lt,{size:13,className:J("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&s.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:l.map(b=>{const S=b.workspace.id===g.workspace.id;return s.jsxs("button",{type:"button",onClick:()=>{a(b.workspace.id),c(!1)},className:J("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",S&&"bg-neutral-50"),children:[s.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?s.jsx(ht,{size:13}):s.jsx(Wi,{size:13})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(b.displayName)}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",_o(b.roleLabel)),children:i(b.roleLabel)}),s.jsx("span",{className:J("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",H0(b.workspace.status)),children:b.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:ns(b.workspace)}),s.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&&s.jsxs("span",{children:[i("Owner"),": ",b.ownerName]}),b.parentBranchName&&s.jsxs("span",{children:[i("Parent"),": ",b.parentBranchName]}),s.jsx("span",{children:b.workspace.id.slice(0,8)})]})]})]},b.workspace.id)})})]})}const $0=[{key:"changes",label:"Changes",icon:s.jsx(_s,{size:14})},{key:"history",label:"History",icon:s.jsx(xs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ws,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(cr,{size:14})},{key:"preview",label:"Preview",icon:s.jsx($o,{size:14})}],U0=[{key:"history",label:"History",icon:s.jsx(xs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ws,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(cr,{size:14})},{key:"preview",label:"Preview",icon:s.jsx($o,{size:14})}],q0=({active:e,onClick:t,icon:r,label:a})=>s.jsxs("button",{onClick:t,className:J("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,s.jsx("span",{children:a})]}),nl=ne.memo(function({className:t,sessionId:r,workspaceId:a,workingDir:m,projectId:p,hideChanges:_,readOnly:i,repoDeleted:n,teamRun:c,teamStatus:h,gitProps:l,workspaces:g,selectedWorkspaceId:b,onSelectWorkspace:S,tabRef:v}){const{t:o}=ce(),f=C.useMemo(()=>{const N=_?U0:$0,T=i?N.filter(R=>R.key!=="terminal"):N;return c?[{key:"team-status",label:"Team Status",icon:s.jsx(ps,{size:14})},...T]:T},[_,i,c]),[d,u]=C.useState(_?"history":"changes");C.useImperativeHandle(v,()=>({setTab:N=>u(N)}),[]);const{data:x}=gc(p??""),y=C.useMemo(()=>{if(!x?.quickCommands)return[];try{return JSON.parse(x.quickCommands)}catch{return[]}},[x?.quickCommands]),[k,j]=C.useState([]),w=C.useRef(void 0);C.useEffect(()=>{m&&m!==w.current&&(w.current=m,j(N=>N.includes(m)?N:[...N,m]))},[m]),C.useEffect(()=>{i&&d==="terminal"&&u(_?"history":"changes")},[d,_,i]),C.useEffect(()=>{c||d!=="team-status"||u(_?"history":"changes")},[d,_,c]);const E=!!S&&on(g,c).length>1;return s.jsxs("div",{className:J("flex flex-col h-full bg-white",t),children:[i&&s.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:o(n?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),s.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:f.map(N=>s.jsx(q0,{active:d===N.key,onClick:()=>u(N.key),icon:N.icon,label:o(N.label)},N.key))}),s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[E&&s.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:s.jsx(il,{workspaces:g,teamRun:c,selectedWorkspaceId:b,onSelectWorkspace:S,buttonClassName:"h-7 text-[11px]"})}),s.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[d==="team-status"&&c&&h,d==="editor"&&s.jsx(y0,{workingDir:m,readOnly:i}),k.map(N=>{const T=d==="terminal"&&m===N;return s.jsx("div",{className:"h-full absolute inset-0",style:{display:T?"block":"none"},children:s.jsx(Df,{cwd:N,isVisible:T,quickCommands:y})},N)}),d==="preview"&&s.jsx(z0,{workspaceId:a,readOnly:i}),d==="changes"&&s.jsx(R0,{workingDir:m,workspaceId:a,branchName:l?.branchName,targetBranch:l?.targetBranch,commitMessage:l?.commitMessage,canRunGitOperations:l?.canRunGitOperations,onRefreshCommitMessage:l?.onRefreshCommitMessage,onConflict:l?.onConflict,onResolveConflicts:l?.onResolveConflicts}),d==="history"&&s.jsx(O0,{workingDir:m})]})]})]})}),xo=1500,K0=3e3;function X0(e){const[t,r]=C.useState(null),a=C.useRef(0),m=C.useRef(null),p=C.useRef(null);return C.useEffect(()=>{if(!e)return;const _=()=>{p.current&&(clearTimeout(p.current),p.current=null)},i=Yt.connect(),n=h=>{r(h),p.current=setTimeout(()=>r(null),K0)},c=h=>{if(h.taskId!==e)return;const l={status:h.status,currentCommand:h.currentCommand,currentIndex:h.currentIndex,totalCommands:h.totalCommands,error:h.error};if(h.status==="running"){_(),m.current=null,a.current===0&&(a.current=Date.now()),r(l);return}const g=a.current>0?Date.now()-a.current:0,b=xo-g;a.current===0?(a.current=Date.now(),r({status:"running",totalCommands:h.totalCommands,currentIndex:h.totalCommands}),m.current=l,p.current=setTimeout(()=>n(l),xo)):b>0?(m.current=l,_(),p.current=setTimeout(()=>n(l),b)):n(l)};return i.on(it.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(it.WORKSPACE_SETUP_PROGRESS,c),_(),a.current=0,m.current=null}},[e]),t}function un(){const e=et();return ft({mutationFn:t=>_e.post(`/sessions/${t}/start`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)}),e.invalidateQueries({queryKey:le.tasks.all})}})}function ol(){const e=et();return ft({mutationFn:t=>_e.post(`/sessions/${t}/stop`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)})}})}function hn(){const e=et();return ft({mutationFn:({id:t,message:r,providerId:a})=>_e.post(`/sessions/${t}/message`,{message:r,providerId:a}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function al(e,t){return C.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.tokenUsage&&typeof a.tokenUsage.totalTokens=="number"&&a.tokenUsage.totalTokens>0)return{totalTokens:a.tokenUsage.totalTokens,modelContextWindow:a.tokenUsage.modelContextWindow}}return t??null},[e,t])}function ll({isOpen:e,onClose:t,taskId:r,taskTitle:a,taskDescription:m}){const{t:p}=ce(),[_,i]=C.useState(""),[n,c]=C.useState(""),[h,l]=C.useState(rt.WORKTREE),[g,b]=C.useState("idle"),[S,v]=C.useState(null),o=et(),f=ba(r),d=un(),{data:u,isLoading:x}=Hs();C.useEffect(()=>{if(!e||!u)return;const N=u.find(T=>T.availability.type!=="NOT_FOUND");N&&i(N.provider.id)},[e,u]),C.useEffect(()=>{if(e){const N=[a];m&&N.push(m),c(N.join(`
|
|
71
|
+
|
|
72
|
+
`)),l(rt.WORKTREE),b("idle"),v(null)}},[e,a,m]);const y=g!=="idle",k=async()=>{if(!(!_||!n.trim())){v(null);try{b("creating-workspace");const N=await f.mutateAsync({workspaceKind:h});b("creating-session");const T=await _e.post(`/workspaces/${N.id}/sessions`,{providerId:_,prompt:n.trim()});b("starting-session"),await d.mutateAsync(T.id),await o.invalidateQueries({queryKey:le.workspaces.list(r)}),b("idle"),t()}catch(N){b("idle"),v(N instanceof Error?N.message:p("启动失败,请重试"))}}},j={idle:p("启动"),"creating-workspace":p("创建工作空间..."),"creating-session":p("创建会话..."),"starting-session":p("启动 Agent...")},w=(u??[]).map(({provider:N,availability:T})=>{const R=T.type!=="NOT_FOUND";return{value:N.id,label:R?N.name:`${N.name}${p(" (不可用)")}`,disabled:!R}}),E=[{value:rt.WORKTREE,label:p("工作树模式")},{value:rt.MAIN_DIRECTORY,label:p("本地模式")}];return s.jsx(zs,{isOpen:e,onClose:y?()=>{}:t,title:p("启动 Agent"),action:s.jsxs(s.Fragment,{children:[s.jsx(Ve,{variant:"outline",onClick:t,disabled:y,children:p("取消")}),s.jsx(Ve,{onClick:k,disabled:y||!_||!n.trim(),children:j[g]})]}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("Agent")}),s.jsx(En,{value:_,onChange:i,options:w,placeholder:p(x?"加载中...":"选择 Agent"),disabled:y||x})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("模式")}),s.jsx(En,{value:h,onChange:N=>l(N),options:E,disabled:y})]})]}),h===rt.MAIN_DIRECTORY&&s.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:p("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("任务描述")}),s.jsx("textarea",{value:n,onChange:N=>c(N.target.value),rows:5,disabled:y,placeholder:p("描述你想让 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"})]}),S&&s.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:S})]})})}function cl(e){const t=e?.tokenUsage;if(!(!t||typeof t.totalTokens!="number"))return t}function Y0(e,t,r){const a=e?.providerId??r?.providerId??null,m=a?t?.find(i=>i.provider.id===a)?.provider:null,p=m?.name??a??e?.agentType??r?.agentType??null;if(!p)return null;const _=a&&m?.name&&a!==m.name?`${m.name} (${a})`:p;return{label:p,title:_}}function dl({session:e,providers:t,usage:r,compact:a=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:_="top"}){const{t:i}=ce(),n=Y0(e,t,{providerId:m,agentType:p});return!n&&!r?null:s.jsxs("div",{className:`flex shrink-0 items-center ${a?"gap-1":"gap-2"}`,children:[n&&s.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${a?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${n.title}`,children:[s.jsx(Ws,{size:a?12:14,className:"shrink-0 text-neutral-400"}),s.jsx("span",{className:"min-w-0 truncate",children:vi(n.label,a?12:18)})]}),s.jsx(rn,{usage:r,tooltipSide:_})]})}function bo(e,t,r,a){if(r.filter(_=>_===a).length<=1)return e;const p=r.slice(0,t+1).filter(_=>_===a).length;return`${e} #${p}`}function V0(e){return Object.values(e).filter(Boolean).length}function ul({mode:e,setMode:t,selectedTemplateId:r,setSelectedTemplateId:a,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:_=!1}){const{t:i}=ce(),{data:n}=Hs(),{data:c,isError:h,isFetching:l,isLoading:g,refetch:b}=ac(),{data:S,isError:v,isFetching:o,isLoading:f,refetch:d}=lc(),u=C.useMemo(()=>new Map((n??[]).map(({provider:N,availability:T})=>[N.id,N.name+(T.type==="NOT_FOUND"?i(" (不可用)"):"")])),[n,i]),x=C.useMemo(()=>new Map((c??[]).map(N=>[N.id,N])),[c]),y=C.useMemo(()=>new Map((S??[]).map(N=>[N.id,N])),[S]),k=C.useMemo(()=>m.map(N=>x.get(N)).filter(N=>!!N),[x,m]);C.useEffect(()=>{c!==void 0&&p(N=>{const T=N.filter(R=>x.has(R));return T.length===N.length&&T.every((R,M)=>R===N[M])?N:T})},[c,x,p]),C.useEffect(()=>{S!==void 0&&a(N=>!N||y.has(N)?N:null)},[a,y,S]);const j=N=>{_||a(T=>T===N?null:N)},w=N=>{_||p(T=>[...T,N])},E=N=>{_||p(T=>T.filter((R,M)=>M!==N))};return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-[11px] text-neutral-500 shrink-0",children:i("执行模式")}),s.jsxs("div",{className:"inline-flex rounded-md bg-white p-0.5 shadow-sm",children:[s.jsxs("button",{type:"button",onClick:()=>!_&&t("AUTO"),disabled:_,className:J("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:[s.jsx(Zo,{size:11}),i("自动模式")]}),s.jsxs("button",{type:"button",onClick:()=>!_&&t("CONFIRM"),disabled:_,className:J("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:[s.jsx(Qo,{size:11}),i("确认模式")]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.jsxs("section",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-medium text-neutral-500 mb-1.5",children:i("团队模板")}),v?s.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[s.jsx("span",{children:i("团队模板加载失败")}),s.jsx("button",{type:"button",onClick:()=>{d()},disabled:_||o,className:"ml-2 underline hover:no-underline",children:i("重试")})]}):f?s.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[s.jsx(Fe,{size:12,className:"animate-spin"}),i("加载中...")]}):(S??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[i("当前没有团队模板"),s.jsx(yn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:i("去创建")})]}):s.jsx("div",{className:"space-y-1.5",children:(S??[]).map(N=>{const T=N.id===r,R=N.members?.length??0,M=N.members?.map(B=>B.memberPresetId)??[],O=N.members?.slice(0,3).map((B,F)=>bo(B.memberPreset?.name??B.memberPresetId,F,M,B.memberPresetId)).join(", ");return s.jsx("button",{type:"button",onClick:()=>j(N.id),disabled:_,className:J("w-full rounded-lg px-3 py-2 text-left transition-all disabled:cursor-not-allowed disabled:opacity-60",T?"bg-blue-50 ring-1 ring-blue-200":"bg-white hover:bg-white/80"),children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:J("text-xs truncate",T?"font-medium text-blue-800":"text-neutral-800"),children:N.name}),s.jsxs("span",{className:"text-[10px] text-neutral-400 shrink-0",children:[R,i("人")]})]}),O&&s.jsx("div",{className:"mt-0.5 text-[10px] text-neutral-400 truncate",children:O})]}),T&&s.jsx(ht,{size:13,className:"shrink-0 text-blue-600"})]})},N.id)})})]}),s.jsxs("section",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:i("追加成员")}),k.length>0&&s.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&&s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:k.map((N,T)=>{const R=bo(N.name,T,m,N.id);return s.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:[s.jsx(zt,{name:N.name,avatar:N.avatar,className:"h-3.5 w-3.5 text-[7px]"}),s.jsx("span",{className:"max-w-[80px] truncate",children:R}),s.jsx("button",{type:"button",onClick:()=>E(T),disabled:_,className:"p-0.5 text-neutral-400 hover:text-red-500 disabled:opacity-30 rounded",children:s.jsx(Ot,{size:9})})]},`${N.id}-${T}`)})}),h?s.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[s.jsx("span",{children:i("成员预设加载失败")}),s.jsx("button",{type:"button",onClick:()=>{b()},disabled:_||l,className:"ml-2 underline hover:no-underline",children:i("重试")})]}):g?s.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[s.jsx(Fe,{size:12,className:"animate-spin"}),i("加载中...")]}):(c??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[i("当前没有成员预设"),s.jsx(yn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:i("去创建")})]}):s.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:(c??[]).map(N=>{const T=m.filter(O=>O===N.id).length,R=u.get(N.providerId)??N.providerId,M=V0(N.capabilities);return s.jsxs("button",{type:"button",onClick:()=>w(N.id),disabled:_,className:J("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left transition-all",_&&"cursor-not-allowed opacity-60","bg-white hover:bg-white/80"),children:[s.jsx(zt,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-neutral-800 truncate",children:N.name}),s.jsxs("div",{className:"text-[10px] text-neutral-400 truncate",children:[R," · ",M,"/10"]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[T>0&&s.jsxs("span",{className:"text-[9px] text-blue-600 font-medium",children:["×",T]}),s.jsx(vs,{size:12,className:"text-neutral-300"})]})]},N.id)})})]})]})]})}function G0({isOpen:e,onClose:t,taskId:r}){const{t:a}=ce(),[m,p]=C.useState("AUTO"),[_,i]=C.useState(null),[n,c]=C.useState([]),[h,l]=C.useState(null),g=zo();C.useEffect(()=>{e&&(p("AUTO"),i(null),c([]),l(null))},[e]);const b=g.isPending,S=!!_||n.length>0,v=async()=>{if(!b){if(!_&&n.length===0){l(a("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:m,..._?{teamTemplateId:_}:{},...n.length>0?{memberPresetIds:n}:{}}),t()}catch(f){if(f instanceof Fo&&f.status===409){l(a("该任务已经存在 TeamRun。请刷新后再试。"));return}l(f instanceof Error?f.message:a("创建 TeamRun 失败"))}}},o=b||!S;return s.jsxs(zs,{isOpen:e,onClose:b?()=>{}:t,title:a("创建 TeamRun"),className:"max-w-5xl",action:s.jsxs(s.Fragment,{children:[s.jsx(Ve,{type:"button",variant:"outline",onClick:t,disabled:b,children:a("取消")}),s.jsx(Ve,{type:"button",onClick:v,disabled:o,children:a(b?"处理中...":"创建 TeamRun")})]}),children:[s.jsx(ul,{mode:m,setMode:p,selectedTemplateId:_,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:c,disabled:b}),h&&s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:h})]})}function hl({providers:e,currentProviderId:t,agentType:r,onSelect:a}){const{t:m}=ce(),[p,_]=C.useState(!1),i=C.useRef(null),n=e.filter(h=>String(h.provider.agentType)===r),c=e.find(h=>h.provider.id===t);return C.useEffect(()=>{function h(l){i.current&&!i.current.contains(l.target)&&_(!1)}if(p)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[p]),n.length<=1?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[s.jsx(Sn,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?vi(c.provider.name,12):r})]}):s.jsxs("div",{className:"relative",ref:i,children:[s.jsxs("button",{onClick:()=>_(!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: ${c?.provider.name??r} (click to change)`,children:[s.jsx(Sn,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?vi(c.provider.name,12):r}),s.jsx(lt,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&s.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:[s.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),n.map(h=>s.jsxs("button",{onClick:()=>{a(h.provider.id),_(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${h.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate max-w-[120px]",children:h.provider.name}),h.provider.isDefault&&s.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),h.provider.id===t&&s.jsx(ht,{size:14,className:"shrink-0"})]},h.provider.id))]})]})}function Q0({commands:e,selectedIndex:t,query:r,hasCatalog:a,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:_="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:c=!1,onSelect:h}){const l=c?"px-1.5 pb-1.5":"px-2 pb-2",g=c?"px-2 py-1.5":"px-2.5 py-2",b=c?"max-h-36":"max-h-48";return s.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[s.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[s.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?s.jsx("div",{className:`${c?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:a?i??`No matches for ${p}${r}`:_}):s.jsx("div",{className:`${l} ${b} overflow-y-auto`,children:e.map((S,v)=>s.jsxs("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>h(S),className:`w-full rounded-lg border text-left transition-colors ${v===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:S.command}),S.kind&&S.kind!=="builtin"?s.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]}),s.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:S.description})]},S.command))})]})}const Kt=12,ir=8;function xr({open:e,anchorRef:t,commands:r,selectedIndex:a,query:m,hasCatalog:p,title:_,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:h,compact:l=!1,onSelect:g}){const b=C.useRef(null),[S,v]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){v(null);return}const o=t.current;if(!o)return;let f=0;const d=()=>{const y=t.current;if(!y)return;const k=y.getBoundingClientRect(),j=window.innerWidth,w=window.innerHeight,E=l?260:320,N=l?j-Kt*2:560,T=Math.min(Math.max(k.width,E),Math.max(E,N)),R=Math.min(Math.max(Kt,k.left),Math.max(Kt,j-Kt-T)),M=w-k.bottom-ir-Kt,O=k.top-ir-Kt,B=b.current?.offsetHeight??(l?220:280),F=l?240:320,z=M<180&&O>M,L=Math.max(120,Math.min(F,z?O:M)),P=z?Math.max(Kt,k.top-ir-Math.min(B,L)):Math.min(w-Kt-Math.min(B,L),k.bottom+ir);v({top:P,left:R,width:T,maxHeight:L})},u=()=>{cancelAnimationFrame(f),f=requestAnimationFrame(d)};u();const x=new ResizeObserver(u);return x.observe(o),b.current&&x.observe(b.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(f),x.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,r.length,l,e,m,a]),!e||!S||typeof document>"u"?null:Vt.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:s.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:s.jsx(Q0,{commands:r,selectedIndex:a,query:m,hasCatalog:p,title:_,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:h,compact:l,onSelect:g})})}),document.body)}function Z0({workspaceId:e,gitStatus:t,onResolve:r}){const{t:a}=ce(),m=ya();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const p=t.operation==="rebase"?"Rebase":"Merge";return s.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:[s.jsx(Bi,{size:18,className:"text-amber-600 shrink-0"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:t.conflictedFiles.length})})}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Ve,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:a("中止操作")}),s.jsx(Ve,{size:"sm",onClick:r,children:a("解决冲突")})]})]})}function fl(e){return e.length>0?e.map(t=>`- ${t}`).join(`
|
|
73
|
+
`):"- 未获取到冲突文件列表"}function ml(e){if(!e)return[];const t=[];return e.workspaceId&&t.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&t.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&t.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&t.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&t.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&t.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&t.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&t.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&t.push("- Merge state: conflict detected and already aborted by Agent Tower"),t}function J0(e,t){if(!t?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=t.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,a=t.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. 执行 ${a} 完成合并`]}function eg(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const t=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;请在${t}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function tg(e,t,r,a,m){const p=fl(r),_=ml(m);return a===Ms.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,..._.length>0?["","### 上下文",..._]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
74
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,..._.length>0?["","### 上下文",..._]:[],"","### 冲突文件",p,"","### 解决步骤",...J0(e,m)].join(`
|
|
75
|
+
`)}function sg(e){const t=e.conflictOp===Ms.REBASE?"Rebase":"Merge",r=fl(e.conflictedFiles),a=[...ml(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${t} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${t} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...a,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Ms.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":eg(e)].join(`
|
|
76
|
+
`)}function rg(e){if(e.teamRunId)return{type:"team_room",message:sg(e)};const t=e.currentSessionId||e.selectedSessionId;return t?{type:"session",sessionId:t,message:tg(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function pl({open:e,onOpenChange:t,workspaceId:r,conflictOp:a,conflictedFiles:m,sourceBranch:p,targetBranch:_,operation:i,worktreePath:n,mergeAborted:c,mergeStrategy:h,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:S,sessions:v,currentSessionId:o,teamRunId:f}){const{t:d}=ce(),[u,x]=C.useState(""),y=hn(),k=Ri(f??""),j=Ji(),w=!!f,E=o||u,N=w?k.isPending:y.isPending,T=()=>{const F=rg({workspaceId:r,worktreePath:n,operation:i,mergeAborted:c,mergeStrategy:h,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:S,sourceBranch:p,targetBranch:_,conflictedFiles:m,conflictOp:a,teamRunId:f,currentSessionId:o,selectedSessionId:u});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{Rt.success(d("已发送到 Team Room")),t(!1)}});return}F.type==="session"&&y.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>t(!1)})},R=()=>{j.mutate({workspaceId:r},{onSuccess:()=>t(!1)})},M=a==="REBASE"?"Rebase":"Merge",O=!w&&!o&&v.length>0,B=w||!!E;return s.jsx(zs,{isOpen:e,onClose:()=>t(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ve,{variant:"outline",onClick:R,children:d("在 IDE 中打开")}),s.jsx(Ve,{onClick:T,disabled:!B||N,children:d(N?"发送中...":"AI 辅助解决")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:m.length})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>s.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))})]}),w&&s.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,由团队调度处理。")}),O&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),s.jsxs("select",{value:u,onChange:F=>x(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:[s.jsx("option",{value:"",children:d("选择一个 Session...")}),v.map(F=>s.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!E&&v.length===0&&s.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function ig({agentType:e,workingDir:t}){return yt({queryKey:le.system.slashCommandCatalog(e,t),queryFn:async()=>(await _e.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function ng(e,t){const r=new Set,a=[];for(const m of[...e,...t]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),a.push(m.kind?m:{...m,kind:"builtin"}))}return a}function Fr(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function og(e){return Fr(e.command)}function ag(e,t){if(!t)return 1e3;const r=og(e),a=e.aliases?.map(Fr)??[],m=[r,...a];let p=0;for(const i of m)i===t?p=Math.max(p,500):i.startsWith(t)?p=Math.max(p,400-(i.length-t.length)):i.includes(t)&&(p=Math.max(p,250-i.indexOf(t)));return p>0?p:`${r} ${a.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function yo(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const r=t.index+t[1].length;return{query:Fr(t[2]),replaceStart:r}}function gl(e,t){const r=Fr(t);return r?e.map((a,m)=>({command:a,index:m,score:ag(a,r)})).filter(a=>a.score>0).sort((a,m)=>m.score-a.score||a.index-m.index||a.command.command.localeCompare(m.command.command)).map(a=>a.command):e.slice()}const lg=[{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"}],cg=[{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"}],dg=[{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"}],ug=[{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"}],hg={[Pt.CODEX]:lg,[Pt.CLAUDE_CODE]:cg,[Pt.GEMINI_CLI]:dg,[Pt.CURSOR_AGENT]:ug};function vl(e){return e.trim().toLowerCase().replace(/^\//,"")}function fg(e){return e?(hg[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function mg(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?vl(t[1]):null}function pg(e,t){return gl(e,vl(t))}function gg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function _l({agentType:e,workingDir:t,input:r,setInput:a,textareaRef:m,minHeight:p,maxHeight:_}){const[i,n]=C.useState(0),{data:c=[]}=ig({agentType:e,workingDir:t}),h=C.useMemo(()=>ng(fg(e),c),[e,c]),l=C.useMemo(()=>mg(r),[r]),g=C.useMemo(()=>l===null?[]:pg(h,l),[h,l]),b=C.useCallback(()=>{const o=m.current;o&&(o.style.height="auto",o.style.height=`${Math.max(p,Math.min(o.scrollHeight,_))}px`)},[_,p,m]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const S=C.useCallback(o=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${o.command} `;a(d),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,a,m]),v=C.useCallback(o=>l===null||g.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(f=>(f+1)%g.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(f=>(f-1+g.length)%g.length),!0):gg(o)?(o.preventDefault(),S(g[i]??g[0]),!0):!1,[S,g,l,i]);return{allCommands:h,query:l,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:S,handleKeyDown:v}}function vg({agentType:e,workingDir:t}){return yt({queryKey:le.system.skillCatalog(e,t),queryFn:async()=>(await _e.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===Pt.CODEX,staleTime:3e4})}function _g(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function xl({agentType:e,workingDir:t,input:r,setInput:a,textareaRef:m,minHeight:p,maxHeight:_}){const[i,n]=C.useState(0),{data:c=[]}=vg({agentType:e,workingDir:t}),l=C.useMemo(()=>e===Pt.CODEX?yo(r):null,[e,r])?.query??null,g=C.useMemo(()=>l===null?[]:gl(c,l),[l,c]),b=C.useCallback(()=>{const o=m.current;o&&(o.style.height="auto",o.style.height=`${Math.max(p,Math.min(o.scrollHeight,_))}px`)},[_,p,m]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const S=C.useCallback(o=>{const f=yo(r);if(!f)return;const d=`${r.slice(0,f.replaceStart)}${o.command} `;a(d),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,a,m]),v=C.useCallback(o=>l===null||g.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(f=>(f+1)%g.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(f=>(f-1+g.length)%g.length),!0):_g(o)?(o.preventDefault(),S(g[i]??g[0]),!0):!1,[S,g,l,i]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:S,handleKeyDown:v}}const xg="/api",bg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${xg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,yg=675,So=320,wo=1200;function Sg(){const{t:e}=ce();return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[s.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-300",children:[s.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),s.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),s.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Co=[{status:me.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:s.jsx(Ai,{className:"w-3 h-3"})},{status:me.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:s.jsx(Ti,{className:"w-3 h-3"})},{status:me.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:s.jsx(Mi,{className:"w-3 h-3"})},{status:me.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:s.jsx(Di,{className:"w-3 h-3"})},{status:me.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:s.jsx(Li,{className:"w-3 h-3"})}];function wg({status:e,onChangeStatus:t}){const{t:r}=ce(),[a,m]=C.useState(!1),p=C.useRef(null);C.useEffect(()=>{if(!a)return;const i=n=>{p.current&&!p.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]);const _=Co.find(i=>i.status===e);return s.jsxs("div",{className:"relative",ref:p,children:[s.jsxs("button",{onClick:()=>t&&m(i=>!i),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${_.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[_.icon,s.jsx("span",{children:r(e)}),t&&s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${a?"rotate-180":""}`,children:s.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),a&&s.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:Co.filter(i=>i.status!==e).map(i=>s.jsxs("button",{onClick:()=>{t?.(i.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[s.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),s.jsx("span",{className:"text-neutral-700",children:r(i.status)})]},i.status))})]})}function Cg({task:e,onDeleteTask:t,isDeleting:r,onTaskStatusChange:a}){const{t:m}=ce(),[p,_]=C.useState(""),[i,n]=C.useState(!1),[c,h]=C.useState(!1),[l,g]=C.useState(!1),[b,S]=C.useState(!1),[v,o]=C.useState(!1),[f,d]=C.useState(!1),[u,x]=C.useState(null),y=C.useRef(null),[k,j]=C.useState(!1),[w,E]=C.useState(null),[N,T]=C.useState(void 0),[R,M]=C.useState(!1),O=C.useRef(null),B=C.useRef(null),F=C.useRef(null),z=C.useRef(null),{scrollRef:A,contentRef:L,isAtBottom:P,scrollToBottom:I}=sn({resize:"smooth",initial:"instant"}),[$,X]=C.useState(yg),[V,se]=C.useState(!0),[ae,D]=C.useState(!1),H=C.useRef(0),q=C.useRef(0),W=C.useRef(null),{data:Y,isLoading:Q}=Zi(e?.id??""),oe=X0(e?.id),{data:de}=Ho(e?.id??""),{data:je}=Wo(de?.id??""),ze=Ri(de?.id??""),re=de??null,Te=!!re,Ue=de===null;C.useEffect(()=>{M(!1),E(null),T(void 0)},[e?.id]);const Ae=C.useMemo(()=>ka(Y,re,N),[N,re,Y]);C.useEffect(()=>{N&&!Y?.some(Z=>Z.id===N)&&T(void 0)},[N,Y]);const Se=C.useMemo(()=>Y?.find(Z=>Z.id===Ae),[Ae,Y]),U=Se?.status===kt.ACTIVE?Se.id:void 0,ee=Ea(Se,re);C.useEffect(()=>{if(!R||!Y)return;Y.some(ue=>ue.status==="ACTIVE"&&ue.sessions&&ue.sessions.length>0)&&M(!1)},[Y,R]);const ie=C.useMemo(()=>{if(R||!Y)return null;const Z=at=>{const Vr=at.createdAt,Cs=at.endedAt??at.startedAt??Vr;if(!Cs)return 0;const ls=Date.parse(Cs);return Number.isNaN(ls)?0:ls},ue=(at,Vr)=>{const Cs=at.filter(ls=>Vr.includes(ls.status));return Cs.length===0?null:Cs.sort((ls,Kl)=>Z(Kl)-Z(ls))[0]??null},De=Y.filter(at=>at.status==="ACTIVE"&&Array.isArray(at.sessions)).flatMap(at=>at.sessions??[]),_t=ue(De,[Ye.RUNNING])??ue(De,[Ye.PENDING])??ue(De,[Ye.COMPLETED,Ye.FAILED,Ye.CANCELLED]);if(_t)return _t;const xt=Y.filter(at=>(at.status==="MERGED"||at.status==="ABANDONED"||at.status==="HIBERNATED")&&Array.isArray(at.sessions)).flatMap(at=>at.sessions??[]);return ue(xt,[Ye.COMPLETED,Ye.FAILED,Ye.CANCELLED])},[Y,R]),pe=ie?.id??"",he=Te?w??"":pe,qe=C.useMemo(()=>{if(!w||!Y)return null;for(const Z of Y){const ue=Z.sessions?.find(De=>De.id===w);if(ue)return ue}return null},[w,Y]),we=C.useMemo(()=>{if(!w||!re?.invocations)return null;const Z=re.invocations.filter(ue=>ue.sessionId===w);return Z.length===0?null:Z.sort((ue,De)=>{const _t=Date.parse(ue.updatedAt??ue.createdAt??""),xt=Date.parse(De.updatedAt??De.createdAt??"");return(Number.isNaN(xt)?0:xt)-(Number.isNaN(_t)?0:_t)})[0]??null},[w,re?.invocations]),Ge=C.useMemo(()=>!we?.memberId||!re?.members?null:re.members.find(Z=>Z.id===we.memberId)??null,[we?.memberId,re?.members]),Ce=w?qe:ie??null,K=Ce?.status===Ye.RUNNING||Ce?.status===Ye.PENDING,G=!!e?.projectArchivedAt,fe=!!e?.projectRepoDeletedAt,ge=m(fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:xe}=Hs(),[Ne,Ze]=C.useState(null);C.useEffect(()=>{Ze(ie?.providerId??null)},[ie?.providerId]);const Mt=C.useMemo(()=>!ie||!Y?!1:!Y.some(ue=>ue.status==="ACTIVE"&&ue.sessions?.some(De=>De.id===ie.id)),[ie,Y]),Oe=C.useMemo(()=>{if(!(!Y||R)){if(Se)return Qt(Se);for(const Z of Y)if(Z.status==="ACTIVE"&&Qt(Z))return Qt(Z);return Qt(Y[0])}},[R,Se,Y]),Ke=_l({agentType:ie?.agentType,workingDir:Oe,input:p,setInput:_,textareaRef:F,minHeight:60,maxHeight:300}),He=xl({agentType:ie?.agentType,workingDir:Oe,input:p,setInput:_,textareaRef:F,minHeight:60,maxHeight:300}),{data:ke}=en(ee?U??"":""),tt=Se?.sessions??[],Qe=ns(Se),mt=Se?.commitMessage,st=C.useMemo(()=>ja(Se,Y,e?.mainBranch??""),[Se,e?.mainBranch,Y]),Ee=C.useMemo(()=>ke?.conflictOp&&ke.conflictedFiles.length>0?{conflictOp:ke.conflictOp,conflictedFiles:ke.conflictedFiles}:u,[ke?.conflictOp,ke?.conflictedFiles,u]),ct=Ee?.targetWorkspaceId??U,pt=Ee?.targetWorktreePath??Se?.worktreePath,We=Ee?.sourceBranch??Qe,St=Ee?.targetBranch??st,Re=et(),gt=C.useCallback(()=>e?.id?Re.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Re]);C.useEffect(()=>{if(!k)return;const Z=ue=>{B.current&&!B.current.contains(ue.target)&&j(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[k]);const jt=hn(),Nt=Ji(),ot=cc(),vt=ba(e?.id??""),Wt=un(),as=ah(),$t=C.useMemo(()=>!Y||Y.some(ue=>ue.status==="ACTIVE")?null:Y.find(ue=>ue.status==="HIBERNATED")??null,[Y]),ss=C.useRef(null);C.useEffect(()=>{$t&&ss.current!==$t.id&&(as.isPending||(ss.current=$t.id,as.mutate($t.id,{onSettled:()=>{ss.current=null}})))},[$t,as]);const Gs=C.useCallback(async()=>{if(!e?.id)return;const Z=ie?.providerId??xe?.find(De=>De.availability.type!=="NOT_FOUND")?.provider.id;if(!Z)return;const ue=[e.title,e.description].filter(Boolean).join(`
|
|
77
|
+
|
|
78
|
+
`);S(!1),o(!0);try{await ot.mutateAsync(e.id),M(!0);const De=await vt.mutateAsync({}),_t=await _e.post(`/workspaces/${De.id}/sessions`,{providerId:Z,prompt:ue});await Wt.mutateAsync(_t.id),await Re.invalidateQueries({queryKey:le.workspaces.list(e.id)})}catch(De){console.error("[retry] failed:",De),M(!1)}finally{o(!1)}},[e?.id,e?.title,e?.description,ie?.providerId,xe,ot,vt,Wt,Re]),zr=C.useCallback(()=>{Se?.id&&Nt.mutate({workspaceId:Se.id})},[Nt,Se?.id]),Hr=C.useCallback(()=>{!e?.id||!t||(t(e.id),g(!1))},[e?.id,t]),Ss=C.useCallback(Z=>{E(Z),requestAnimationFrame(()=>{I()})},[I]),Wr=C.useCallback(()=>{E(null)},[]),ws=C.useCallback(Z=>{x(Z??null),d(!0)},[]),$r=C.useCallback(Z=>ze.mutateAsync(Z),[ze]),Ut=C.useCallback(()=>{Re.invalidateQueries({queryKey:dc.all})},[Re]),{isConnected:Qs,isLoadingSnapshot:qt,logs:te,entries:ve,attach:Le}=Uo({sessionId:he,sessionStatus:Ce?.status,onExit:C.useCallback(()=>{Re.invalidateQueries({queryKey:["workspaces"]})},[Re])});C.useEffect(()=>{if(!e?.id)return;const Z=Yt.connect();Z.emit(ds.SUBSCRIBE,{topic:"task",id:e.id});const ue=xt=>{xt.taskId===e.id&&(Re.invalidateQueries({queryKey:["tasks"]}),Ut())},De=xt=>{xt.taskId===e.id&&(Re.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Ut())},_t=xt=>{xt.taskId===e.id&&(Re.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Ut())};return Z.on(it.TASK_UPDATED,ue),Z.on(it.WORKSPACE_COMMIT_MESSAGE_UPDATED,De),Z.on(it.WORKSPACE_HIBERNATED,_t),()=>{Z.off(it.TASK_UPDATED,ue),Z.off(it.WORKSPACE_COMMIT_MESSAGE_UPDATED,De),Z.off(it.WORKSPACE_HIBERNATED,_t),Z.emit(ds.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Re,Ut]),C.useEffect(()=>{if(!he)return;const Z=Yt.connect(),ue=De=>{De.sessionId===he&&(Re.invalidateQueries({queryKey:["workspaces"]}),Ut())};return Z.on(it.SESSION_COMPLETED,ue),()=>{Z.off(it.SESSION_COMPLETED,ue)}},[he,Re,Ut]);const{todos:Me}=qo(ve),{files:wt,addFiles:dt,removeFile:Pe,clear:Bt,buildMarkdownLinks:Ft,hasFiles:Dt,isUploading:Zs}=Mr(),Ol=C.useMemo(()=>cl(Ce),[Ce?.tokenUsage]),mn=al(te,Ol);C.useEffect(()=>{he&&Qs&&Le()},[he,Qs,Le]);const pn=C.useRef(e?.id);C.useEffect(()=>{if(pn.current!==e?.id&&A.current){const Z=A.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}pn.current=e?.id},[e?.id,A]);const Ur=ol(),qr=C.useRef(!1),gn=C.useCallback(async()=>{if(!p.trim()&&!Dt||!he||qr.current||Zs)return;qr.current=!0;const Z=Ft(),ue=[p.trim(),Z].filter(Boolean).join(`
|
|
79
|
+
|
|
80
|
+
`);_(""),Bt(),F.current&&(F.current.style.height="60px"),jt.mutate({id:he,message:ue,providerId:Ne??void 0},{onSuccess:()=>{Le()},onSettled:()=>{qr.current=!1}})},[p,he,jt,Le,Dt,Zs,Ft,Bt,Ne]),Il=C.useCallback(async()=>{he&&(await Ur.mutateAsync(he),Re.invalidateQueries({queryKey:["workspaces"]}))},[he,Ur,Re]),Bl=C.useCallback(Z=>{const ue=Z.target.files;ue&&ue.length>0&&dt(Array.from(ue)),Z.target.value=""},[dt]),Fl=C.useCallback(Z=>{const ue=Z.clipboardData.items,De=[];for(const _t of ue)if(_t.kind==="file"){const xt=_t.getAsFile();xt&&De.push(xt)}De.length>0&&(Z.preventDefault(),dt(De))},[dt]),[vn,Kr]=C.useState(!1),zl=C.useCallback(Z=>{Z.preventDefault(),Kr(!0)},[]),Hl=C.useCallback(Z=>{Z.preventDefault(),Kr(!1)},[]),Wl=C.useCallback(Z=>{Z.preventDefault(),Kr(!1);const ue=Z.dataTransfer.files;ue.length>0&&dt(Array.from(ue))},[dt]),Xr=C.useCallback(Z=>{const ue=Z.clientX-H.current,De=Math.max(So,Math.min(q.current+ue,wo));W.current&&(W.current.style.width=`${De}px`)},[]),Yr=C.useCallback(()=>{if(D(!1),W.current){const Z=W.current.getBoundingClientRect().width;X(Math.max(So,Math.min(Math.round(Z),wo)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(ae)return document.addEventListener("mousemove",Xr),document.addEventListener("mouseup",Yr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Xr),document.removeEventListener("mouseup",Yr),document.body.style.cursor="",document.body.style.userSelect=""}},[ae,Xr,Yr]);const $l=C.useCallback(Z=>{Z.preventDefault(),H.current=Z.clientX,q.current=$,D(!0)},[$]),Ul=C.useCallback(()=>{se(Z=>!Z)},[]),ql=C.useCallback(Z=>{_(Z.target.value);const ue=Z.target;ue.style.height="auto";const De=ue.scrollHeight;ue.style.height=`${Math.max(60,Math.min(De,300))}px`},[]);return e?s.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[s.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-neutral-100 bg-white/80 backdrop-blur-sm z-20 flex-shrink-0",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[s.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),s.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),s.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),s.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(wg,{status:e.status,onChangeStatus:!G&&a?Z=>a(e.id,Z):void 0}),s.jsx("button",{onClick:zr,disabled:!Oe||G,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:s.jsx(Ws,{size:18})}),s.jsx("button",{onClick:Ul,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:V?s.jsx(ud,{size:18}):s.jsx(lr,{size:18})}),Ue&&!G&&s.jsxs("button",{onClick:()=>h(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:m("创建 TeamRun"),children:[s.jsx(vs,{size:14}),s.jsx("span",{children:m("创建 TeamRun")})]}),t&&!G&&s.jsxs("div",{className:"relative",ref:B,children:[s.jsx("button",{onClick:()=>j(Z=>!Z),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:s.jsx(Go,{size:18})}),k&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[s.jsxs("button",{onClick:()=>{S(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[s.jsx(yc,{size:15}),s.jsx("span",{children:m("重新开始")})]}),s.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[s.jsx(Ko,{size:15}),s.jsx("span",{children:m("删除任务")})]})]})]})]})]}),ee&&U&&ke&&s.jsx(Z0,{workspaceId:U,gitStatus:ke,onResolve:()=>ws()}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsx("div",{ref:W,className:`flex flex-col bg-white relative ${V?"flex-shrink-0":"flex-1"}`,style:{width:V?$:"100%"},children:Te&&re?w?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:w})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(dl,{session:Ce,providers:xe,usage:mn,providerIdFallback:Ge?.providerId,agentTypeFallback:Ce?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ve,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-2 text-xs font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900",onClick:Wr,children:[s.jsx(_i,{size:13}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsx("div",{ref:L,className:`w-full ${V?"":"max-w-5xl mx-auto"}`,children:qt?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):te.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(K?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(or,{logs:te})})}),!P&&s.jsxs("button",{onClick:()=>I(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Ds,{size:14}),s.jsx("span",{children:m("回到底部")})]})]}),Me.length>0&&s.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:s.jsx(ar,{todos:Me})})})]}):s.jsx(Ca,{teamRun:re,messages:je??re.messages??[],readOnly:G,readOnlyMessage:ge,onSendMessage:$r,onViewInvocationSession:Ss,centered:!V}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsxs("div",{ref:L,className:`w-full ${V?"":"max-w-5xl mx-auto"}`,children:[s.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(Pi,{urlTransform:bg,components:Oi,children:e.description})}):s.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),oe&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[oe.status==="running"&&s.jsxs(s.Fragment,{children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&s.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),oe.status==="failed"&&s.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:oe.error})})]}),Q?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading...")})]}):pe?qt?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):te.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(K?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(or,{logs:te}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:s.jsx(rs,{size:24,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(G?"项目为只读历史":"尚未启动 Agent")}),s.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:G?ge:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!G&&s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[s.jsxs(Ve,{onClick:()=>n(!0),children:[s.jsx(rs,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),Ue&&s.jsxs(Ve,{variant:"outline",onClick:()=>h(!0),children:[s.jsx(vs,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!P&&s.jsxs("button",{onClick:()=>I(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Ds,{size:14}),s.jsx("span",{children:m("回到底部")})]})]}),Me.length>0&&s.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:s.jsx(ar,{todos:Me})})}),G?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:s.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:ge})})}):Mt?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:s.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[s.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ve,{size:"sm",onClick:()=>n(!0),children:[s.jsx(rs,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})})}):s.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:zl,onDragLeave:Hl,onDrop:Wl,children:[s.jsx("div",{className:`${V?"":"max-w-5xl mx-auto"}`,children:s.jsxs("div",{ref:O,className:`relative bg-white rounded-xl border shadow-sm hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300 transition-all duration-200 ${vn?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[s.jsx(Dr,{files:wt,onRemove:Pe}),s.jsx("textarea",{ref:F,value:p,onChange:ql,onPaste:Fl,onKeyDown:Z=>{He.handleKeyDown(Z)||Ke.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),gn())},rows:1,placeholder:m(vn?"Drop files here...":pe&&!K?"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-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),s.jsx("input",{ref:z,type:"file",multiple:!0,className:"hidden",onChange:Bl}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[s.jsx("div",{className:"flex items-center gap-1",children:s.jsx("button",{onClick:()=>z.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:s.jsx(Sr,{size:18})})}),s.jsxs("div",{className:"flex items-center gap-2",children:[ie&&xe&&s.jsx(hl,{providers:xe,currentProviderId:Ne,agentType:ie.agentType,onSelect:Ze}),s.jsx(rn,{usage:mn}),K&&!p.trim()&&!Dt?s.jsx("button",{onClick:Il,disabled:Ur.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-red-500 text-white hover:bg-red-600 shadow-md disabled:opacity-50",children:s.jsx(gs,{size:14})}):s.jsx("button",{onClick:gn,disabled:!p.trim()&&!Dt||Zs,className:`p-2 rounded-lg transition-all duration-200 ${(p.trim()||Dt)&&!Zs?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:s.jsx(wr,{size:18})})]})]})]})}),s.jsx(xr,{open:Ke.query!==null,anchorRef:O,commands:Ke.filteredCommands,selectedIndex:Ke.selectedIndex,query:Ke.query??"",hasCatalog:Ke.allCommands.length>0,onSelect:Ke.applyCommand}),s.jsx(xr,{open:He.query!==null,anchorRef:O,commands:He.filteredSkills,selectedIndex:He.selectedIndex,query:He.query??"",hasCatalog:He.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:He.applySkill})]})]})}),V&&s.jsx("div",{className:"w-1 cursor-col-resize hover:bg-neutral-200 active:bg-blue-400 transition-colors z-30 flex-shrink-0 border-l border-neutral-200",onMouseDown:$l}),V&&s.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:s.jsx(nl,{sessionId:pe||void 0,workspaceId:Ae,workingDir:Oe,projectId:e.projectId,readOnly:G,repoDeleted:fe,teamRun:re,teamStatus:re?s.jsx(Na,{teamRun:re,workspaces:Y,selectedWorkspaceId:Ae,onSelectWorkspace:T,onViewInvocationSession:Ss}):void 0,workspaces:Y,selectedWorkspaceId:Ae,onSelectWorkspace:T,tabRef:y,gitProps:ee&&U?{branchName:Qe,targetBranch:st,commitMessage:mt,canRunGitOperations:!0,onRefreshCommitMessage:gt,onConflict:ws,onResolveConflicts:()=>ws()}:void 0})})]}),!G&&s.jsx(ll,{isOpen:i,onClose:()=>n(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),Ue&&!G&&s.jsx(G0,{isOpen:c,onClose:()=>h(!1),taskId:e.id}),ee&&ct&&Ee&&s.jsx(pl,{open:f,onOpenChange:Z=>{d(Z),Z||x(null)},workspaceId:ct,conflictOp:Ee.conflictOp,conflictedFiles:Ee.conflictedFiles,sourceBranch:We,targetBranch:St,operation:ke?.operation,worktreePath:pt,mergeAborted:Ee.mergeAborted,mergeStrategy:Ee.mergeStrategy,sourceWorkspaceId:Ee.sourceWorkspaceId,targetWorkspaceId:Ee.targetWorkspaceId,sourceWorktreePath:Ee.sourceWorktreePath,targetWorktreePath:Ee.targetWorktreePath,sessions:tt,currentSessionId:Te?void 0:pe,teamRunId:re?.id}),s.jsx(Ii,{isOpen:b,onClose:()=>S(!1),onConfirm:Gs,title:m("重新开始任务"),description:s.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:v}),s.jsx(tn,{isOpen:l,onClose:()=>g(!1),onConfirm:Hr,taskId:e.id,taskTitle:e.title,workspaces:Y,isLoading:r})]}):s.jsx(Sg,{})}function fn(e){switch(e){case Lt.TODO:return me.Pending;case Lt.IN_PROGRESS:return me.Running;case Lt.IN_REVIEW:return me.Review;case Lt.DONE:return me.Done;case Lt.CANCELLED:return me.Cancelled}}function kg(e){switch(e){case me.Pending:return Lt.TODO;case me.Running:return Lt.IN_PROGRESS;case me.Review:return Lt.IN_REVIEW;case me.Done:return Lt.DONE;case me.Cancelled:return Lt.CANCELLED}}function Eg(e){switch(e){case Pt.CLAUDE_CODE:return"Claude Code";case Pt.GEMINI_CLI:return"Gemini CLI";case Pt.CURSOR_AGENT:return"Cursor Agent";case Pt.CODEX:return"Codex"}}const br=["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 bl(e,t){let r=0;for(let a=0;a<e.length;a++)r=(r<<5)-r+e.charCodeAt(a)|0;return Math.abs(r)%t}function yl(e,t){return t??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Sl(e){return e?e.workspaceKind===rt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function jg(e){return{id:e.id,name:e.name,color:e.color||br[bl(e.name,br.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Ng(e){const t=yl(e);if(!t)return{agent:"—",branch:"—"};const r=Sl(t),a=t.sessions;if(a&&a.length>0){const m=a[a.length-1];return{agent:Eg(m.agentType),branch:r}}return{agent:"—",branch:r}}function Rg(e){const{agent:t,branch:r}=Ng(e.workspaces),a=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:fn(e.status),agent:t,branch:r,description:e.description??"",projectArchivedAt:a?.archivedAt??null,projectRepoDeletedAt:a?.repoDeletedAt??null}}function Ag(e,t,r){const a=yl(e.workspaces,r),m=Sl(a);return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||br[bl(t.name,br.length)],title:e.title,status:fn(e.status),branch:m,mainBranch:a?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const ko={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 Tg(e){const t=e.split("/");return t[t.length-1]||e}function Mg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Dg({workingDir:e,filePath:t,type:r}){const{t:a}=ce(),{data:m,isLoading:p,isError:_}=el(e,t,r);if(p)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(_)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:a("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const n=i.split(`
|
|
81
|
+
`);return s.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((c,h)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),s.jsx("div",{className:J("px-3 whitespace-pre",l,g),children:c},h)})})}function Lg({entry:e,type:t,workingDir:r}){const[a,m]=C.useState(!1),p=ko[e.status]||ko.M,_=Mg(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(i=>!i),className:J("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("span",{className:J("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Tg(e.path)}),_&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:_})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:a?s.jsx(lt,{size:14}):s.jsx(It,{size:14})})]}),a&&s.jsx(Dg,{workingDir:r,filePath:e.path,type:t})]})}function Eo({title:e,entries:t,type:r,workingDir:a,defaultOpen:m}){const{t:p}=ce(),[_,i]=C.useState(m);return t.length===0?null:s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[s.jsx("span",{className:"text-neutral-400",children:_?s.jsx(lt,{size:14}):s.jsx(It,{size:14})}),s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),_&&s.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(n=>s.jsx(Lg,{entry:n,type:r,workingDir:a},`${r}:${n.path}`))})]})}function Pg({workingDir:e}){const{t}=ce(),{data:r,isLoading:a,isError:m}=dn(e);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(a)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const p=r?.uncommitted||[],_=r?.committed||[];return p.length+_.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(_s,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx(Eo,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),s.jsx(Eo,{title:"Committed",entries:_,type:"committed",workingDir:e,defaultOpen:!1})]})}const hi=50,jo={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 Og(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Gt("{count}s ago",{count:r}):r<3600?Gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ig(e){const t=e.split("/");return t[t.length-1]||e}function Bg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Fg({workingDir:e,hash:t,filePath:r}){const{t:a}=ce(),{data:m,isLoading:p,isError:_}=sl(e,t,r);if(p)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(_)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:a("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const n=i.split(`
|
|
82
|
+
`);return s.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((c,h)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),s.jsx("div",{className:J("px-3 whitespace-pre",l,g),children:c},h)})})}function zg({entry:e,workingDir:t,hash:r}){const[a,m]=C.useState(!1),p=jo[e.status]||jo.M,_=Bg(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(i=>!i),className:J("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("span",{className:J("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Ig(e.path)}),_&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:_})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:a?s.jsx(lt,{size:14}):s.jsx(It,{size:14})})]}),a&&s.jsx(Fg,{workingDir:t,hash:r,filePath:e.path})]})}function Hg({commit:e,workingDir:t}){const{t:r}=ce(),[a,m]=C.useState(!1),{data:p,isLoading:_}=tl(t,a?e.hash:null),i=p?.files||[];return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(n=>!n),className:J("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:s.jsx("div",{className:J("w-2.5 h-2.5 rounded-full shrink-0",a?"bg-blue-500":"bg-neutral-300")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),s.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),s.jsx("span",{className:"text-[11px] text-neutral-400",children:Og(e.timestamp)})]})]}),s.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:a?s.jsx(lt,{size:14}):s.jsx(It,{size:14})})]}),a&&s.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&s.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),_?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):s.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>s.jsx(zg,{entry:n,workingDir:t,hash:e.hash},n.path))})]})]})}function Wg({workingDir:e}){const{t}=ce(),{data:r,isLoading:a,isError:m,fetchNextPage:p,hasNextPage:_,isFetchingNextPage:i}=Yo({queryKey:le.git.log(e||""),queryFn:({pageParam:c=0})=>_e.get("/git/log",{params:{workingDir:e||"",limit:String(hi),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,h)=>c.commits.length<hi?void 0:h.length*hi,enabled:!!e}),n=r?.pages.flatMap(c=>c.commits)||[];return e?a?s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx(Fe,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):n.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(xs,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No commit history")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(c=>s.jsx(Hg,{commit:c,workingDir:e},c.hash))}),_&&s.jsx("button",{type:"button",onClick:()=>p(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const $g="/api",Ug=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${$g}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function qg({status:e}){const t={[me.Running]:"bg-blue-500",[me.Review]:"bg-amber-500",[me.Pending]:"bg-neutral-400",[me.Done]:"bg-emerald-500",[me.Cancelled]:"bg-neutral-400"};return s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Kg=[{key:"chat",label:"Chat",icon:Fi},{key:"changes",label:"Changes",icon:_s},{key:"history",label:"History",icon:xs},{key:"workspace",label:"Workspace",icon:Cr}],Xg=[{key:"chat",label:"Team room",icon:Fi},{key:"team-status",label:"Team Status",icon:ps},{key:"changes",label:"Changes",icon:_s},{key:"workspace",label:"Workspace",icon:Cr}];function Yg({task:e,onBack:t,onDeleteTask:r,isDeleting:a}){const{t:m}=ce(),[p,_]=C.useState("chat"),[i,n]=C.useState(""),[c,h]=C.useState(!1),[l,g]=C.useState(!1),[b,S]=C.useState(!1),[v,o]=C.useState(null),[f,d]=C.useState(void 0),u=C.useRef(null),x=C.useRef(null),y=C.useRef(null),k=C.useRef(null),{scrollRef:j,contentRef:w,isAtBottom:E,scrollToBottom:N}=sn({resize:"smooth",initial:"instant"}),T=et();C.useEffect(()=>{if(!b)return;const te=ve=>{x.current&&!x.current.contains(ve.target)&&S(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[b]);const{data:R,isLoading:M}=Zi(e.id),{data:O}=Ho(e.id),{data:B}=Wo(O?.id??""),F=Ri(O?.id??""),z=O??null,A=z?Xg:Kg;C.useEffect(()=>{d(void 0),o(null)},[e.id]),C.useEffect(()=>{z&&p==="history"&&_("chat"),!z&&p==="team-status"&&_("chat")},[p,z]);const L=C.useMemo(()=>ka(R,z,f),[f,z,R]);C.useEffect(()=>{f&&!R?.some(te=>te.id===f)&&d(void 0)},[f,R]);const P=C.useMemo(()=>R?.find(te=>te.id===L),[L,R]),I=C.useMemo(()=>{if(R){if(P)return Qt(P);for(const te of R)if(te.status==="ACTIVE"&&Qt(te))return Qt(te);return Qt(R[0])}},[P,R]),$=P?.status===kt.ACTIVE?P.id:void 0,X=Ea(P,z),V=P?.branchName??"",se=P?.commitMessage,ae=C.useMemo(()=>ja(P,R,e?.mainBranch??""),[P,e?.mainBranch,R]),{data:D}=en($??""),{data:H}=dn(I),q=H?.committed?.length,[W,Y]=C.useState(!1),[Q,oe]=C.useState(null),de=C.useMemo(()=>D?.conflictOp&&D.conflictedFiles.length>0?{conflictOp:D.conflictOp,conflictedFiles:D.conflictedFiles}:Q,[D?.conflictOp,D?.conflictedFiles,Q]),je=de?.targetWorkspaceId??$,ze=de?.targetWorktreePath??P?.worktreePath,re=de?.sourceBranch??V,Te=de?.targetBranch??ae,Ue=P?.sessions??[],Ae=C.useCallback(te=>{oe(te??null),Y(!0)},[]),Se=C.useCallback(()=>e?.id?T.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,T]),U=C.useMemo(()=>{if(!R)return null;const te=R.filter(Pe=>Pe.status==="ACTIVE"&&Array.isArray(Pe.sessions)).flatMap(Pe=>Pe.sessions??[]),ve=Pe=>{const Bt=Pe.createdAt,Ft=Pe.endedAt??Pe.startedAt??Bt;if(!Ft)return 0;const Dt=Date.parse(Ft);return Number.isNaN(Dt)?0:Dt},Le=Pe=>{const Bt=te.filter(Ft=>Pe.includes(Ft.status));return Bt.length===0?null:Bt.sort((Ft,Dt)=>ve(Dt)-ve(Ft))[0]??null},Me=Le([Ye.RUNNING])??Le([Ye.PENDING])??Le([Ye.COMPLETED,Ye.FAILED,Ye.CANCELLED]);if(Me)return Me;const dt=R.filter(Pe=>(Pe.status==="ABANDONED"||Pe.status==="MERGED"||Pe.status==="HIBERNATED")&&Array.isArray(Pe.sessions)).flatMap(Pe=>Pe.sessions??[]).filter(Pe=>[Ye.COMPLETED,Ye.FAILED,Ye.CANCELLED].includes(Pe.status));return dt.length===0?null:dt.sort((Pe,Bt)=>ve(Bt)-ve(Pe))[0]??null},[R]),ee=U?.id??"",ie=z?v??"":ee,pe=C.useMemo(()=>{if(!v||!R)return null;for(const te of R){const ve=te.sessions?.find(Le=>Le.id===v);if(ve)return ve}return null},[v,R]),he=C.useMemo(()=>{if(!v||!z?.invocations)return null;const te=z.invocations.filter(ve=>ve.sessionId===v);return te.length===0?null:te.sort((ve,Le)=>{const Me=Date.parse(ve.updatedAt??ve.createdAt??""),wt=Date.parse(Le.updatedAt??Le.createdAt??"");return(Number.isNaN(wt)?0:wt)-(Number.isNaN(Me)?0:Me)})[0]??null},[v,z?.invocations]),qe=C.useMemo(()=>!he?.memberId||!z?.members?null:z.members.find(te=>te.id===he.memberId)??null,[he?.memberId,z?.members]),we=v?pe:U??null,Ge=we?.status===Ye.RUNNING||we?.status===Ye.PENDING,Ce=!!e.projectArchivedAt,K=!!e.projectRepoDeletedAt,G=m(K?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),fe=C.useMemo(()=>!U||!R?!1:!R.some(ve=>ve.status==="ACTIVE"&&ve.sessions?.some(Le=>Le.id===U.id)),[U,R]),{data:ge}=Hs(),[xe,Ne]=C.useState(null),Ze=xe?.sessionId===ee?xe.providerId:U?.providerId??null,Mt=C.useCallback(te=>{Ne({sessionId:ee,providerId:te})},[ee]),Oe=_l({agentType:U?.agentType,workingDir:I,input:i,setInput:n,textareaRef:y,minHeight:40,maxHeight:140}),Ke=xl({agentType:U?.agentType,workingDir:I,input:i,setInput:n,textareaRef:y,minHeight:40,maxHeight:140}),He=I&&P?P.id:void 0,ke=hn(),tt=Ji(),Qe=ol(),{isConnected:mt,isLoadingSnapshot:st,logs:Ee,entries:ct,attach:pt}=Uo({sessionId:ie,sessionStatus:we?.status,onExit:C.useCallback(()=>{T.invalidateQueries({queryKey:["workspaces"]})},[T])}),{todos:We}=qo(ct),{files:St,addFiles:Re,removeFile:gt,clear:jt,buildMarkdownLinks:Nt,hasFiles:ot,isUploading:vt}=Mr(),Wt=C.useMemo(()=>cl(we),[we?.tokenUsage]),as=al(Ee,Wt);C.useEffect(()=>{ie&&mt&&pt()},[ie,mt,pt]);const $t=C.useRef(null);C.useEffect(()=>{if($t.current!==e.id&&j.current){const te=j.current;requestAnimationFrame(()=>{te.scrollTop=te.scrollHeight})}$t.current=e.id},[e.id,j]);const ss=C.useRef(!1),Gs=C.useCallback(async()=>{if(!i.trim()&&!ot||!ee||ss.current||vt)return;ss.current=!0;const te=Nt(),ve=[i.trim(),te].filter(Boolean).join(`
|
|
83
|
+
|
|
84
|
+
`);n(""),jt(),y.current&&(y.current.style.height="40px"),ke.mutate({id:ee,message:ve,providerId:Ze??void 0},{onSuccess:()=>pt(),onSettled:()=>{ss.current=!1}})},[i,ee,ke,pt,ot,vt,Nt,jt,Ze]),zr=C.useCallback(async()=>{ee&&(await Qe.mutateAsync(ee),T.invalidateQueries({queryKey:["workspaces"]}))},[ee,Qe,T]),Hr=C.useCallback(te=>F.mutateAsync(te),[F]),Ss=C.useCallback(te=>{o(te),_("chat"),requestAnimationFrame(()=>{N()})},[N]),Wr=C.useCallback(()=>{o(null)},[]),ws=C.useCallback(te=>{const ve=te.target.files;ve&&ve.length>0&&Re(Array.from(ve)),te.target.value=""},[Re]),$r=C.useCallback(te=>{const ve=te.clipboardData.items,Le=[];for(const Me of ve)if(Me.kind==="file"){const wt=Me.getAsFile();wt&&Le.push(wt)}Le.length>0&&(te.preventDefault(),Re(Le))},[Re]),Ut=C.useCallback(te=>{n(te.target.value);const ve=te.target;ve.style.height="auto",ve.style.height=`${Math.max(40,Math.min(ve.scrollHeight,140))}px`},[]),Qs=C.useCallback(()=>{He&&tt.mutate({workspaceId:He})},[tt,He]),qt=C.useRef(null);return C.useEffect(()=>{const te=window.visualViewport;if(!te)return;let ve=!1;const Le=()=>{qt.current&&(qt.current.style.height=`${te.height}px`,qt.current.style.top=`${te.offsetTop}px`)},Me=()=>Le(),wt=()=>{ve||Le()},dt=()=>{ve=!0},Pe=()=>{ve=!1,requestAnimationFrame(Le)};return te.addEventListener("resize",Me),te.addEventListener("scroll",wt),document.addEventListener("touchstart",dt,{passive:!0}),document.addEventListener("touchend",Pe,{passive:!0}),document.addEventListener("touchcancel",Pe,{passive:!0}),()=>{te.removeEventListener("resize",Me),te.removeEventListener("scroll",wt),document.removeEventListener("touchstart",dt),document.removeEventListener("touchend",Pe),document.removeEventListener("touchcancel",Pe)}},[]),C.useEffect(()=>{const te=qt.current;if(!te)return;const ve=Le=>{let Me=Le.target;for(;Me&&Me!==te;){if(Me.tagName==="TEXTAREA"){if(Me.scrollHeight>Me.clientHeight)return;Me=Me.parentElement;continue}const dt=window.getComputedStyle(Me).overflowY;if((dt==="auto"||dt==="scroll")&&Me.scrollHeight>Me.clientHeight)return;Me=Me.parentElement}Le.preventDefault()};return te.addEventListener("touchmove",ve,{passive:!1}),()=>te.removeEventListener("touchmove",ve)},[]),s.jsxs("div",{ref:qt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[s.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[s.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[s.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:s.jsx(_i,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),s.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[s.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),s.jsx("span",{className:"text-neutral-300",children:"/"}),s.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),s.jsx(qg,{status:e.status}),s.jsx("button",{onClick:Qs,disabled:!He||Ce,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:s.jsx(Ws,{size:16})}),r&&!Ce&&s.jsxs("div",{className:"relative",ref:x,children:[s.jsx("button",{onClick:()=>S(te=>!te),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:s.jsx(Go,{size:16})}),b&&s.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:s.jsxs("button",{onClick:()=>{g(!0),S(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[s.jsx(Ko,{size:15}),s.jsx("span",{children:m("删除任务")})]})})]})]}),s.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:te,label:ve,icon:Le})=>s.jsxs("button",{onClick:()=>_(te),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${p===te?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[s.jsx(Le,{size:13,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:m(ve)})]},te))})]}),p==="chat"&&(z?s.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:v?s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:v})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(dl,{session:we,providers:ge,usage:as,compact:!0,providerIdFallback:qe?.providerId,agentTypeFallback:we?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ve,{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:Wr,children:[s.jsx(_i,{size:12}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:j,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsx("div",{ref:w,children:st?s.jsx(fi,{label:m("Loading logs...")}):Ee.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:m(Ge?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(or,{logs:Ee})})}),!E&&s.jsxs("button",{onClick:()=>N(),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":m("Scroll to bottom"),children:[s.jsx(Ds,{size:12}),s.jsx("span",{children:m("回到底部")})]})]}),We.length>0&&s.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:s.jsx(ar,{todos:We,compact:!0})})]}):s.jsx(Ca,{teamRun:z,messages:B??z.messages??[],readOnly:Ce,readOnlyMessage:G,onSendMessage:Hr,onViewInvocationSession:Ss,compactComposer:!0})}):s.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:j,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsxs("div",{ref:w,children:[s.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(Pi,{urlTransform:Ug,components:Oi,children:e.description})}):s.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),M?s.jsx(fi,{label:"Loading..."}):ee?st?s.jsx(fi,{label:"Loading logs..."}):Ee.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:Ge?"Waiting for agent output...":"No logs recorded."}):s.jsx(or,{logs:Ee}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:s.jsx(rs,{size:20,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),s.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:Ce?G:m("选择一个 Agent 来执行此任务")}),!Ce&&s.jsxs(Ve,{onClick:()=>h(!0),children:[s.jsx(rs,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!E&&s.jsxs("button",{onClick:()=>N(),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:[s.jsx(Ds,{size:12}),s.jsx("span",{children:m("回到底部")})]})]}),We.length>0&&s.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:s.jsx(ar,{todos:We,compact:!0})}),Ce?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:G})}):fe?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ve,{size:"sm",onClick:()=>h(!0),children:[s.jsx(rs,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):ee&&s.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[s.jsxs("div",{ref:u,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[s.jsx(Dr,{files:St,onRemove:gt}),s.jsx("textarea",{ref:y,value:i,onChange:Ut,onPaste:$r,onKeyDown:te=>{Ke.handleKeyDown(te)||Oe.handleKeyDown(te)||te.key==="Enter"&&!te.shiftKey&&!te.repeat&&!te.nativeEvent.isComposing&&te.nativeEvent.keyCode!==229&&(te.preventDefault(),Gs())},rows:1,placeholder:Ge?"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}}),s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:ws}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:s.jsx("button",{onClick:()=>k.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:s.jsx(Sr,{size:15})})}),s.jsxs("div",{className:"flex items-center gap-1",children:[U&&ge&&s.jsx(hl,{providers:ge,currentProviderId:Ze,agentType:U.agentType,onSelect:Mt}),s.jsx(rn,{usage:as}),Ge&&!i.trim()&&!ot?s.jsx("button",{onClick:zr,disabled:Qe.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:s.jsx(gs,{size:12})}):s.jsx("button",{onClick:Gs,disabled:!i.trim()&&!ot||vt,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||ot)&&!vt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:s.jsx(wr,{size:15})})]})]})]}),s.jsx(xr,{open:Oe.query!==null,anchorRef:u,commands:Oe.filteredCommands,selectedIndex:Oe.selectedIndex,query:Oe.query??"",hasCatalog:Oe.allCommands.length>0,compact:!0,onSelect:Oe.applyCommand}),s.jsx(xr,{open:Ke.query!==null,anchorRef:u,commands:Ke.filteredSkills,selectedIndex:Ke.selectedIndex,query:Ke.query??"",hasCatalog:Ke.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Ke.applySkill})]})]})),p==="team-status"&&z&&s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:s.jsx(Na,{teamRun:z,workspaces:R,selectedWorkspaceId:L,onSelectWorkspace:d,onViewInvocationSession:Ss})}),p==="changes"&&s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[R&&R.length>1&&s.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:s.jsx(il,{workspaces:R,teamRun:z,selectedWorkspaceId:L,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),X&&$&&s.jsx("div",{className:"shrink-0",children:s.jsx(rl,{workspaceId:$,branchName:V,targetBranch:ae,commitMessage:se,committedFileCount:q,onRefreshCommitMessage:Se,onConflict:Ae,onResolveConflicts:()=>Ae()})}),s.jsx(Pg,{workingDir:I})]}),p==="history"&&s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:s.jsx(Wg,{workingDir:I})}),p==="workspace"&&s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(nl,{sessionId:ee||void 0,workspaceId:L,workingDir:I,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:Ce,repoDeleted:K})}),!Ce&&s.jsx(ll,{isOpen:c,onClose:()=>h(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),s.jsx(tn,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},taskId:e.id,taskTitle:e.title,workspaces:R,isLoading:a}),W&&de&&je&&s.jsx(pl,{open:W,onOpenChange:te=>{Y(te),te||oe(null)},workspaceId:je,conflictOp:de.conflictOp,conflictedFiles:de.conflictedFiles,sourceBranch:re,targetBranch:Te,operation:D?.operation,worktreePath:ze,mergeAborted:de.mergeAborted,mergeStrategy:de.mergeStrategy,sourceWorkspaceId:de.sourceWorkspaceId,targetWorkspaceId:de.targetWorkspaceId,sourceWorktreePath:de.sourceWorktreePath,targetWorktreePath:de.targetWorktreePath,sessions:Ue,currentSessionId:z?void 0:ee,teamRunId:z?.id})]})}function fi({label:e}){return s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:e})]})}var Vg=Object.defineProperty,yr=Object.getOwnPropertySymbols,wl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,No=(e,t,r)=>t in e?Vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ei=(e,t)=>{for(var r in t||(t={}))wl.call(t,r)&&No(e,r,t[r]);if(yr)for(var r of yr(t))Cl.call(t,r)&&No(e,r,t[r]);return e},ji=(e,t)=>{var r={};for(var a in e)wl.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&yr)for(var a of yr(e))t.indexOf(a)<0&&Cl.call(e,a)&&(r[a]=e[a]);return r};var os;(e=>{const t=class ye{constructor(n,c,h,l){if(this.version=n,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],n<ye.MIN_VERSION||n>ye.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let S=0;S<this.size;S++)g.push(!1);for(let S=0;S<this.size;S++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(h);if(this.drawCodewords(b),l==-1){let S=1e9;for(let v=0;v<8;v++){this.applyMask(v),this.drawFormatBits(v);const o=this.getPenaltyScore();o<S&&(l=v,S=o),this.applyMask(v)}}m(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(n,c){const h=e.QrSegment.makeSegments(n);return ye.encodeSegments(h,c)}static encodeBinary(n,c){const h=e.QrSegment.makeBytes(n);return ye.encodeSegments([h],c)}static encodeSegments(n,c,h=1,l=40,g=-1,b=!0){if(!(ye.MIN_VERSION<=h&&h<=l&&l<=ye.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let S,v;for(S=h;;S++){const u=ye.getNumDataCodewords(S,c)*8,x=_.getTotalBits(n,S);if(x<=u){v=x;break}if(S>=l)throw new RangeError("Data too long")}for(const u of[ye.Ecc.MEDIUM,ye.Ecc.QUARTILE,ye.Ecc.HIGH])b&&v<=ye.getNumDataCodewords(S,u)*8&&(c=u);let o=[];for(const u of n){r(u.mode.modeBits,4,o),r(u.numChars,u.mode.numCharCountBits(S),o);for(const x of u.getData())o.push(x)}m(o.length==v);const f=ye.getNumDataCodewords(S,c)*8;m(o.length<=f),r(0,Math.min(4,f-o.length),o),r(0,(8-o.length%8)%8,o),m(o.length%8==0);for(let u=236;o.length<f;u^=253)r(u,8,o);let d=[];for(;d.length*8<o.length;)d.push(0);return o.forEach((u,x)=>d[x>>>3]|=u<<7-(x&7)),new ye(S,c,d,g)}getModule(n,c){return 0<=n&&n<this.size&&0<=c&&c<this.size&&this.modules[c][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),c=n.length;for(let h=0;h<c;h++)for(let l=0;l<c;l++)h==0&&l==0||h==0&&l==c-1||h==c-1&&l==0||this.drawAlignmentPattern(n[h],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const c=this.errorCorrectionLevel.formatBits<<3|n;let h=c;for(let g=0;g<10;g++)h=h<<1^(h>>>9)*1335;const l=(c<<10|h)^21522;m(l>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,a(l,g));this.setFunctionModule(8,7,a(l,6)),this.setFunctionModule(8,8,a(l,7)),this.setFunctionModule(7,8,a(l,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,a(l,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,a(l,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,a(l,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let h=0;h<12;h++)n=n<<1^(n>>>11)*7973;const c=this.version<<12|n;m(c>>>18==0);for(let h=0;h<18;h++){const l=a(c,h),g=this.size-11+h%3,b=Math.floor(h/3);this.setFunctionModule(g,b,l),this.setFunctionModule(b,g,l)}}drawFinderPattern(n,c){for(let h=-4;h<=4;h++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(h)),b=n+l,S=c+h;0<=b&&b<this.size&&0<=S&&S<this.size&&this.setFunctionModule(b,S,g!=2&&g!=4)}}drawAlignmentPattern(n,c){for(let h=-2;h<=2;h++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,c+h,Math.max(Math.abs(l),Math.abs(h))!=1)}setFunctionModule(n,c,h){this.modules[c][n]=h,this.isFunction[c][n]=!0}addEccAndInterleave(n){const c=this.version,h=this.errorCorrectionLevel;if(n.length!=ye.getNumDataCodewords(c,h))throw new RangeError("Invalid argument");const l=ye.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c],g=ye.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c],b=Math.floor(ye.getNumRawDataModules(c)/8),S=l-b%l,v=Math.floor(b/l);let o=[];const f=ye.reedSolomonComputeDivisor(g);for(let u=0,x=0;u<l;u++){let y=n.slice(x,x+v-g+(u<S?0:1));x+=y.length;const k=ye.reedSolomonComputeRemainder(y,f);u<S&&y.push(0),o.push(y.concat(k))}let d=[];for(let u=0;u<o[0].length;u++)o.forEach((x,y)=>{(u!=v-g||y>=S)&&d.push(x[u])});return m(d.length==b),d}drawCodewords(n){if(n.length!=Math.floor(ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const b=h-g,v=(h+1&2)==0?this.size-1-l:l;!this.isFunction[v][b]&&c<n.length*8&&(this.modules[v][b]=a(n[c>>>3],7-(c&7)),c++)}}m(c==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let h=0;h<this.size;h++){let l;switch(n){case 0:l=(h+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=h%3==0;break;case 3:l=(h+c)%3==0;break;case 4:l=(Math.floor(h/3)+Math.floor(c/2))%2==0;break;case 5:l=h*c%2+h*c%3==0;break;case 6:l=(h*c%2+h*c%3)%2==0;break;case 7:l=((h+c)%2+h*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][h]&&l&&(this.modules[c][h]=!this.modules[c][h])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let b=!1,S=0,v=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[g][o]==b?(S++,S==5?n+=ye.PENALTY_N1:S>5&&n++):(this.finderPenaltyAddHistory(S,v),b||(n+=this.finderPenaltyCountPatterns(v)*ye.PENALTY_N3),b=this.modules[g][o],S=1);n+=this.finderPenaltyTerminateAndCount(b,S,v)*ye.PENALTY_N3}for(let g=0;g<this.size;g++){let b=!1,S=0,v=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][g]==b?(S++,S==5?n+=ye.PENALTY_N1:S>5&&n++):(this.finderPenaltyAddHistory(S,v),b||(n+=this.finderPenaltyCountPatterns(v)*ye.PENALTY_N3),b=this.modules[o][g],S=1);n+=this.finderPenaltyTerminateAndCount(b,S,v)*ye.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let b=0;b<this.size-1;b++){const S=this.modules[g][b];S==this.modules[g][b+1]&&S==this.modules[g+1][b]&&S==this.modules[g+1][b+1]&&(n+=ye.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((b,S)=>b+(S?1:0),c);const h=this.size*this.size,l=Math.ceil(Math.abs(c*20-h*10)/h)-1;return m(0<=l&&l<=9),n+=l*ye.PENALTY_N4,m(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let h=[6];for(let l=this.size-7;h.length<n;l-=c)h.splice(1,0,l);return h}}static getNumRawDataModules(n){if(n<ye.MIN_VERSION||n>ye.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*n+128)*n+64;if(n>=2){const h=Math.floor(n/7)+2;c-=(25*h-10)*h-55,n>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(n,c){return Math.floor(ye.getNumRawDataModules(n)/8)-ye.ECC_CODEWORDS_PER_BLOCK[c.ordinal][n]*ye.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let c=[];for(let l=0;l<n-1;l++)c.push(0);c.push(1);let h=1;for(let l=0;l<n;l++){for(let g=0;g<c.length;g++)c[g]=ye.reedSolomonMultiply(c[g],h),g+1<c.length&&(c[g]^=c[g+1]);h=ye.reedSolomonMultiply(h,2)}return c}static reedSolomonComputeRemainder(n,c){let h=c.map(l=>0);for(const l of n){const g=l^h.shift();h.push(0),c.forEach((b,S)=>h[S]^=ye.reedSolomonMultiply(b,g))}return h}static reedSolomonMultiply(n,c){if(n>>>8||c>>>8)throw new RangeError("Byte out of range");let h=0;for(let l=7;l>=0;l--)h=h<<1^(h>>>7)*285,h^=(c>>>l&1)*n;return m(h>>>8==0),h}finderPenaltyCountPatterns(n){const c=n[1];m(c<=this.size*3);const h=c>0&&n[2]==c&&n[3]==c*3&&n[4]==c&&n[5]==c;return(h&&n[0]>=c*4&&n[6]>=c?1:0)+(h&&n[6]>=c*4&&n[0]>=c?1:0)}finderPenaltyTerminateAndCount(n,c,h){return n&&(this.finderPenaltyAddHistory(c,h),c=0),c+=this.size,this.finderPenaltyAddHistory(c,h),this.finderPenaltyCountPatterns(h)}finderPenaltyAddHistory(n,c){c[0]==0&&(n+=this.size),c.pop(),c.unshift(n)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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=t;function r(i,n,c){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let h=n-1;h>=0;h--)c.push(i>>>h&1)}function a(i,n){return(i>>>n&1)!=0}function m(i){if(!i)throw new Error("Assertion error")}const p=class Xe{constructor(n,c,h){if(this.mode=n,this.numChars=c,this.bitData=h,c<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(n){let c=[];for(const h of n)r(h,8,c);return new Xe(Xe.Mode.BYTE,n.length,c)}static makeNumeric(n){if(!Xe.isNumeric(n))throw new RangeError("String contains non-numeric characters");let c=[];for(let h=0;h<n.length;){const l=Math.min(n.length-h,3);r(parseInt(n.substring(h,h+l),10),l*3+1,c),h+=l}return new Xe(Xe.Mode.NUMERIC,n.length,c)}static makeAlphanumeric(n){if(!Xe.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],h;for(h=0;h+2<=n.length;h+=2){let l=Xe.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h))*45;l+=Xe.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h+1)),r(l,11,c)}return h<n.length&&r(Xe.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h)),6,c),new Xe(Xe.Mode.ALPHANUMERIC,n.length,c)}static makeSegments(n){return n==""?[]:Xe.isNumeric(n)?[Xe.makeNumeric(n)]:Xe.isAlphanumeric(n)?[Xe.makeAlphanumeric(n)]:[Xe.makeBytes(Xe.toUtf8ByteArray(n))]}static makeEci(n){let c=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,c);else if(n<16384)r(2,2,c),r(n,14,c);else if(n<1e6)r(6,3,c),r(n,21,c);else throw new RangeError("ECI assignment value out of range");return new Xe(Xe.Mode.ECI,0,c)}static isNumeric(n){return Xe.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return Xe.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,c){let h=0;for(const l of n){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;h+=4+g+l.bitData.length}return h}static toUtf8ByteArray(n){n=encodeURI(n);let c=[];for(let h=0;h<n.length;h++)n.charAt(h)!="%"?c.push(n.charCodeAt(h)):(c.push(parseInt(n.substring(h+1,h+3),16)),h+=2);return c}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let _=p;e.QrSegment=p})(os||(os={}));(e=>{(t=>{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),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(os||(os={}));(e=>{(t=>{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]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(os||(os={}));var fs=os;var Gg={L:fs.QrCode.Ecc.LOW,M:fs.QrCode.Ecc.MEDIUM,Q:fs.QrCode.Ecc.QUARTILE,H:fs.QrCode.Ecc.HIGH},kl=128,El="L",jl="#FFFFFF",Nl="#000000",Rl=!1,Al=1,Qg=4,Zg=0,Jg=.1;function Tl(e,t=0){const r=[];return e.forEach(function(a,m){let p=null;a.forEach(function(_,i){if(!_&&p!==null){r.push(`M${p+t} ${m+t}h${i-p}v1H${p+t}z`),p=null;return}if(i===a.length-1){if(!_)return;p===null?r.push(`M${i+t},${m+t} h1v1H${i+t}z`):r.push(`M${p+t},${m+t} h${i+1-p}v1H${p+t}z`);return}_&&p===null&&(p=i)})}),r.join("")}function Ml(e,t){return e.slice().map((r,a)=>a<t.y||a>=t.y+t.h?r:r.map((m,p)=>p<t.x||p>=t.x+t.w?m:!1))}function ev(e,t,r,a){if(a==null)return null;const m=e.length+r*2,p=Math.floor(t*Jg),_=m/t,i=(a.width||p)*_,n=(a.height||p)*_,c=a.x==null?e.length/2-i/2:a.x*_,h=a.y==null?e.length/2-n/2:a.y*_,l=a.opacity==null?1:a.opacity;let g=null;if(a.excavate){let S=Math.floor(c),v=Math.floor(h),o=Math.ceil(i+c-S),f=Math.ceil(n+h-v);g={x:S,y:v,w:o,h:f}}const b=a.crossOrigin;return{x:c,y:h,h:n,w:i,excavation:g,opacity:l,crossOrigin:b}}function tv(e,t){return t!=null?Math.max(Math.floor(t),0):e?Qg:Zg}function Dl({value:e,level:t,minVersion:r,includeMargin:a,marginSize:m,imageSettings:p,size:_,boostLevel:i}){let n=ne.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((v,o)=>(v.push(...fs.QrSegment.makeSegments(o)),v),[]);return fs.QrCode.encodeSegments(S,Gg[t],r,void 0,void 0,i)},[e,t,r,i]);const{cells:c,margin:h,numCells:l,calculatedImageSettings:g}=ne.useMemo(()=>{let b=n.getModules();const S=tv(a,m),v=b.length+S*2,o=ev(b,_,S,p);return{cells:b,margin:S,numCells:v,calculatedImageSettings:o}},[n,_,p,a,m]);return{qrcode:n,margin:h,cells:c,numCells:l,calculatedImageSettings:g}}var sv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),rv=ne.forwardRef(function(t,r){const a=t,{value:m,size:p=kl,level:_=El,bgColor:i=jl,fgColor:n=Nl,includeMargin:c=Rl,minVersion:h=Al,boostLevel:l,marginSize:g,imageSettings:b}=a,v=ji(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:o}=v,f=ji(v,["style"]),d=b?.src,u=ne.useRef(null),x=ne.useRef(null),y=ne.useCallback(O=>{u.current=O,typeof r=="function"?r(O):r&&(r.current=O)},[r]),[k,j]=ne.useState(!1),{margin:w,cells:E,numCells:N,calculatedImageSettings:T}=Dl({value:m,level:_,minVersion:h,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:b,size:p});ne.useEffect(()=>{if(u.current!=null){const O=u.current,B=O.getContext("2d");if(!B)return;let F=E;const z=x.current,A=T!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&T.excavation!=null&&(F=Ml(E,T.excavation));const L=window.devicePixelRatio||1;O.height=O.width=p*L;const P=p/N*L;B.scale(P,P),B.fillStyle=i,B.fillRect(0,0,N,N),B.fillStyle=n,sv?B.fill(new Path2D(Tl(F,w))):E.forEach(function(I,$){I.forEach(function(X,V){X&&B.fillRect(V+w,$+w,1,1)})}),T&&(B.globalAlpha=T.opacity),A&&B.drawImage(z,T.x+w,T.y+w,T.w,T.h)}}),ne.useEffect(()=>{j(!1)},[d]);const R=Ei({height:p,width:p},o);let M=null;return d!=null&&(M=ne.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:x,crossOrigin:T?.crossOrigin})),ne.createElement(ne.Fragment,null,ne.createElement("canvas",Ei({style:R,height:p,width:p,ref:y,role:"img"},f)),M)});rv.displayName="QRCodeCanvas";var Ll=ne.forwardRef(function(t,r){const a=t,{value:m,size:p=kl,level:_=El,bgColor:i=jl,fgColor:n=Nl,includeMargin:c=Rl,minVersion:h=Al,boostLevel:l,title:g,marginSize:b,imageSettings:S}=a,v=ji(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:o,cells:f,numCells:d,calculatedImageSettings:u}=Dl({value:m,level:_,minVersion:h,boostLevel:l,includeMargin:c,marginSize:b,imageSettings:S,size:p});let x=f,y=null;S!=null&&u!=null&&(u.excavation!=null&&(x=Ml(f,u.excavation)),y=ne.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+o,y:u.y+o,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const k=Tl(x,o);return ne.createElement("svg",Ei({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},v),!!g&&ne.createElement("title",null,g),ne.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ne.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),y)});Ll.displayName="QRCodeSVG";function Pl(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function iv(){return yt({queryKey:le.tunnel.status,queryFn:()=>_e.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function nv(){const e=et();return ft({mutationFn:()=>_e.post("/tunnel/start",{port:Pl()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function ov(){const e=et();return ft({mutationFn:()=>_e.post("/tunnel/regenerate",{port:Pl()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function av(){const e=et();return ft({mutationFn:()=>_e.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function lv(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 cv(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 dv(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 Ro(e){if(!e)return"Never";const t=new Date(e).getTime();if(!Number.isFinite(t))return e;const r=Math.max(0,Math.round((Date.now()-t)/1e3));if(r<60)return`${r}s ago`;const a=Math.round(r/60);if(a<60)return`${a}m ago`;const m=Math.round(a/60);return m<24?`${m}h ago`:`${Math.round(m/24)}d ago`}function Es(e){const t=e?.trim();return t||null}function uv(e){if(!e)return"";const t=[Es(e.lastLocalError),Es(e.lastRemoteError),Es(e.lastError)].filter(m=>m!==null),r=Es(e.lastProcessOutput),a=!!r&&(e.status==="error"||e.status==="exited"||!!Es(e.lastError));return r&&a&&t.push(r),t.join(`
|
|
85
|
+
`)}function Ao(){const{t:e}=ce(),{data:t}=iv(),r=nv(),a=av(),m=ov(),[p,_]=C.useState(!1),[i,n]=C.useState(null),c=C.useRef(null),[h,l]=C.useState({top:0,right:0}),[g,b]=C.useState(!1),[S,v]=C.useState(!1),o=t?.status!==void 0&&t.status!=="stopped",f=r.isPending||t?.status==="starting",d=m.isPending,u=t?.shareableUrl,x=t?.token,y=lv(t),k=cv(t),j=uv(t);C.useEffect(()=>{if(p&&c.current){const O=c.current.getBoundingClientRect();l({top:O.bottom+8,right:window.innerWidth-O.right})}},[p]);const w=C.useCallback(()=>{_(!0)},[o]),E=C.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>_(!0)})},[r]),N=C.useCallback(()=>{u&&(navigator.clipboard.writeText(u),n("url"),setTimeout(()=>n(null),2e3))},[u]),T=C.useCallback(()=>{x&&(navigator.clipboard.writeText(x),n("token"),setTimeout(()=>n(null),2e3))},[x]),R=C.useCallback(()=>{a.mutate(),_(!1),b(!1),v(!1)},[a]),M=C.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{v(!1),_(!0)}})},[m]);return s.jsxs("div",{className:"relative",children:[s.jsx("button",{ref:c,onClick:w,disabled:f,className:`p-1.5 rounded-md transition-colors ${y.button}`,title:e(y.label),children:f?s.jsx(Fe,{size:16,className:"animate-spin"}):y.icon==="warn"?s.jsx(Bi,{size:16}):s.jsx(Rn,{size:16})}),o&&!f&&s.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${y.dot} rounded-full`}),p&&!o&&Vt.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>_(!1)}),s.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:s.jsx(Rn,{size:16})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),s.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.")})]})]}),s.jsx("button",{onClick:()=>_(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:s.jsx(Ot,{size:14})})]}),s.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&&s.jsx(Fe,{size:13,className:"animate-spin"}),e(f?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&o&&Vt.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>_(!1)}),s.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{children:[s.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${t?.status==="healthy"||t?.status==="checking"?"text-emerald-600":t?.status==="exited"||t?.status==="error"?"text-red-600":"text-amber-600"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 ${y.dot} rounded-full inline-block`}),e(k)]}),s.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(dv(t))})]}),s.jsx("button",{onClick:()=>_(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:s.jsx(Ot,{size:14})})]}),x&&s.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:[s.jsx(Qo,{size:12}),s.jsx("span",{children:e("Token protected")})]}),u&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(Ll,{value:u,size:160})}),u||t?.url?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{readOnly:!0,value:u??t?.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:O=>O.target.select()}),s.jsx("button",{onClick:N,disabled:!u,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?s.jsx(ht,{size:14,className:"text-emerald-500"}):s.jsx(Nn,{size:14})})]}):s.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")}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ro(t?.lastCheckedAt)})]}),s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ro(t?.lastHealthyAt)})]})]}),j&&s.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}),t?.status==="degraded"&&s.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.")}),t?.status==="linkReplaced"&&s.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.")}),x&&s.jsxs("div",{className:"mt-2",children:[s.jsx("button",{onClick:()=>b(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.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:x}),s.jsx("button",{onClick:T,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?s.jsx(ht,{size:14,className:"text-emerald-500"}):s.jsx(Nn,{size:14})})]})]}),S&&s.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[s.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx("button",{onClick:()=>v(!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")}),s.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&&s.jsxs("button",{onClick:()=>v(!0),disabled:d||t?.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:[s.jsx(kr,{size:13}),e("Regenerate link")]}),s.jsx("button",{onClick:R,disabled:a.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:a.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function mi({isOpen:e,onClose:t}){const{t:r}=ce(),a=vc(),[m,p]=C.useState(""),[_,i]=C.useState(""),[n,c]=C.useState(null),[h,l]=C.useState(!1),[g,b]=C.useState(!1),S=m.trim(),v=_.trim(),o=h||a.isPending,f=C.useMemo(()=>!!(S&&v&&!o),[S,v,o]),d=C.useCallback(()=>{p(""),i(""),c(null),b(!1)},[]),u=C.useCallback(()=>{o||(d(),t())},[o,t,d]);C.useEffect(()=>{e||d()},[e,d]);const x=C.useCallback(async j=>{try{await a.mutateAsync({name:S,repoPath:v,initEmptyRepo:j}),d(),t()}catch(w){const E=w instanceof Error?w.message:r("Failed to create project");c(E),Rt.error(E)}},[a,t,d,r,S,v]),y=C.useCallback(async()=>{if(!(!S||!v||o)){c(null),l(!0);try{const j=await _e.get("/filesystem/validate",{params:{path:v}});if(j.valid){await x(!1);return}if(j.reason==="no_git"&&j.isEmpty){b(!0);return}if(j.reason==="no_git"){c(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}c(j.error??r("Selected path is not a valid directory"))}catch(j){c(j instanceof Error?j.message:r("Could not check repository path"))}finally{l(!1)}}},[x,o,r,S,v]),k=C.useCallback(()=>{b(!1),x(!0)},[x]);return s.jsxs(s.Fragment,{children:[s.jsx(zs,{isOpen:e,onClose:u,title:r("Create New Project"),action:s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:u,disabled:o,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),s.jsx("button",{onClick:y,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:h?r("Checking..."):a.isPending?r("Creating..."):r("Create Project")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),s.jsx("input",{type:"text",value:m,onChange:j=>p(j.target.value),placeholder:r("e.g., Agent Tower"),disabled:o,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),s.jsx(_c,{value:_,onChange:i,validationMode:"directory"})]}),n&&s.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),s.jsx(Ii,{isOpen:g,onClose:()=>{a.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:a.isPending})]})}const hv="/assets/agent-tower-logo-COx9gy77.png";function To({className:e="h-7 w-7"}){return s.jsx("img",{src:hv,alt:"Agent Tower",className:`block shrink-0 object-contain ${e}`})}const fv={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Mo({projects:e,providers:t,isProvidersLoading:r,onSubmit:a,defaultProjectId:m="",defaultProviderId:p="",createStep:_}){const{t:i}=ce(),[n,c]=C.useState(""),[h,l]=C.useState(m),[g,b]=C.useState(p),[S,v]=C.useState("SOLO"),[o,f]=C.useState(rt.WORKTREE),[d,u]=C.useState("AUTO"),[x,y]=C.useState(null),[k,j]=C.useState([]),[w,E]=C.useState(!1),[N,T]=C.useState(!1),[R,M]=C.useState(!1),[O,B]=C.useState(!1),F=C.useRef(null),z=C.useRef(null),A=C.useRef(null),L=C.useRef(null),P=C.useRef(null),{files:I,addFiles:$,removeFile:X,clear:V,buildMarkdownLinks:se,isUploading:ae}=Mr();C.useEffect(()=>{l(m)},[m]),C.useEffect(()=>{b(p)},[p]),C.useEffect(()=>{if(!N)return;const U=ee=>{F.current&&!F.current.contains(ee.target)&&T(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[N]),C.useEffect(()=>{if(!R)return;const U=ee=>{z.current&&!z.current.contains(ee.target)&&M(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[R]),C.useEffect(()=>{if(!O)return;const U=ee=>{A.current&&!A.current.contains(ee.target)&&B(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[O]);const D=C.useMemo(()=>e.find(U=>U.id===h),[e,h]),H=C.useMemo(()=>t.find(U=>U.id===g),[t,g]),q=o===rt.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),W=_!=="idle",Y=!!x||k.length>0,Q=!W&&!ae&&n.trim().length>0&&!!h&&(S==="TEAM"?Y:!!g),oe=C.useCallback(async()=>{if(!Q)return;const U=se();try{await a({title:n.trim(),description:"",projectId:h,providerId:g,mode:S,workspaceMode:S==="SOLO"?o:rt.WORKTREE,teamRunMode:d,teamTemplateId:x,memberPresetIds:k,attachmentLinks:U}),c(""),V()}catch{}},[Q,n,h,g,S,o,d,x,k,a,se,V]),de=C.useCallback(U=>{U.key==="Enter"&&!U.shiftKey&&!U.nativeEvent.isComposing&&U.nativeEvent.keyCode!==229&&(U.preventDefault(),oe())},[oe]),je=C.useCallback(U=>{const ee=U.target.files;ee&&ee.length>0&&$(Array.from(ee)),U.target.value=""},[$]),ze=C.useCallback(U=>{const ee=U.clipboardData.items,ie=[];for(const pe of ee)if(pe.kind==="file"){const he=pe.getAsFile();he&&ie.push(he)}ie.length>0&&(U.preventDefault(),$(ie))},[$]),[re,Te]=C.useState(!1),Ue=C.useCallback(U=>{U.preventDefault(),Te(!0)},[]),Ae=C.useCallback(U=>{U.preventDefault(),Te(!1)},[]),Se=C.useCallback(U=>{U.preventDefault(),Te(!1);const ee=U.dataTransfer.files;ee.length>0&&$(Array.from(ee))},[$]);return s.jsxs("div",{className:"w-full",children:[s.jsxs("div",{className:J("relative bg-white rounded-xl border shadow-sm transition-all duration-200","hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300",re?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200",W&&"opacity-80"),onDragOver:Ue,onDragLeave:Ae,onDrop:Se,children:[I.length>0&&s.jsx("div",{className:"px-4 pt-3",children:s.jsx(Dr,{files:I,onRemove:X})}),s.jsx("textarea",{ref:L,value:n,onChange:U=>c(U.target.value),onKeyDown:de,onPaste:ze,placeholder:i("Describe your task..."),disabled:W,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"72px",maxHeight:"200px",fieldSizing:"content"}}),re&&s.jsx("div",{className:"px-4 pb-2",children:s.jsx("div",{className:"flex items-center justify-center py-3 border-2 border-dashed border-neutral-300 rounded-lg text-sm text-neutral-500",children:i("Drop files here")})}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>P.current?.click(),disabled:W||ae,className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:s.jsx(Sr,{size:18})}),s.jsx("input",{ref:P,type:"file",multiple:!0,onChange:je,className:"hidden"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[ae&&s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-500",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),i("Uploading...")]}),W&&s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-500",children:[s.jsx(Fe,{size:14,className:"animate-spin"}),i(fv[_])]}),!W&&!ae&&S==="TEAM"&&!Y&&n.trim().length>0&&s.jsx("span",{className:"text-[11px] text-amber-600",children:i("请选择团队模板或追加成员")}),s.jsx("button",{type:"button",onClick:oe,disabled:!Q,className:J("p-2 rounded-lg transition-all duration-200",Q?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"),title:i("Create & Start"),children:s.jsx(wr,{size:16})})]})]})]}),s.jsxs("div",{className:"flex items-center flex-wrap gap-1 mt-3 px-1",children:[s.jsxs("div",{className:"relative",ref:F,children:[s.jsxs("button",{type:"button",onClick:()=>{W||T(U=>!U)},disabled:W,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed",D?"text-neutral-700":"text-neutral-400"),children:[s.jsx(Cr,{size:14}),s.jsx("span",{className:"max-w-[120px] truncate",children:D?.name??i("Project")}),s.jsx(lt,{size:12,className:J("transition-transform",N&&"rotate-180")})]}),N&&s.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[240px] overflow-y-auto z-50",children:e.map(U=>s.jsxs("button",{type:"button",onClick:()=>{l(U.id),T(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[s.jsx(ht,{size:14,className:J("mr-2 shrink-0",U.id===h?"opacity-100":"opacity-0")}),s.jsx("span",{className:J("truncate",U.id===h?"text-neutral-900 font-medium":"text-neutral-600"),children:U.name})]},U.id))})]}),S==="SOLO"&&s.jsxs("div",{className:"relative",ref:z,children:[s.jsxs("button",{type:"button",onClick:()=>{W||M(U=>!U)},disabled:W,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed",H?"text-neutral-700":"text-neutral-400"),children:[s.jsx(Mc,{size:14}),s.jsx("span",{className:"max-w-[120px] truncate",children:H?.name??i(r?"Loading...":"Agent")}),s.jsx(lt,{size:12,className:J("transition-transform",R&&"rotate-180")})]}),R&&s.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[240px] overflow-y-auto z-50",children:t.map(U=>s.jsxs("button",{type:"button",disabled:!U.available,onClick:()=>{b(U.id),M(!1)},className:J("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",!U.available&&"opacity-40 cursor-not-allowed"),children:[s.jsx(ht,{size:14,className:J("mr-2 shrink-0",U.id===g?"opacity-100":"opacity-0")}),s.jsxs("span",{className:J("truncate",U.id===g?"text-neutral-900 font-medium":"text-neutral-600"),children:[U.name,U.available?"":i(" (unavailable)")]})]},U.id))})]}),S==="SOLO"&&s.jsxs("div",{className:"relative",ref:A,children:[s.jsxs("button",{type:"button",onClick:()=>{W||B(U=>!U)},disabled:W,className:J("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-neutral-100 disabled:opacity-40 disabled:cursor-not-allowed","text-neutral-700"),children:[s.jsx(Wi,{size:14}),s.jsx("span",{className:"max-w-[96px] truncate",children:q}),s.jsx(lt,{size:12,className:J("transition-transform",O&&"rotate-180")})]}),O&&s.jsxs("div",{className:"absolute top-full left-0 mt-1 w-40 bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 z-50",children:[s.jsxs("button",{type:"button",onClick:()=>{f(rt.WORKTREE),B(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[s.jsx(ht,{size:14,className:J("mr-2 shrink-0",o===rt.WORKTREE?"opacity-100":"opacity-0")}),s.jsx("span",{className:J("truncate",o===rt.WORKTREE?"text-neutral-900 font-medium":"text-neutral-600"),children:i("工作树模式")})]}),s.jsxs("button",{type:"button",onClick:()=>{f(rt.MAIN_DIRECTORY),B(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-neutral-50 transition-colors",children:[s.jsx(ht,{size:14,className:J("mr-2 shrink-0",o===rt.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),s.jsx("span",{className:J("truncate",o===rt.MAIN_DIRECTORY?"text-neutral-900 font-medium":"text-neutral-600"),children:i("本地模式")})]})]})]}),s.jsxs("button",{type:"button",onClick:()=>{if(W)return;const U=S==="SOLO"?"TEAM":"SOLO";v(U),B(!1),U==="TEAM"?(f(rt.WORKTREE),E(!0)):E(!1)},disabled:W,className:J("flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium transition-colors","disabled:opacity-40 disabled:cursor-not-allowed",S==="TEAM"?"text-blue-600 bg-neutral-50 rounded-t-lg rounded-b-none":"text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded-lg"),title:i(S==="SOLO"?"Switch to TeamRun":"Switch to Solo Agent"),children:[s.jsx(ps,{size:14}),s.jsx("span",{children:i("团队协作")})]})]}),S==="SOLO"&&o===rt.MAIN_DIRECTORY&&s.jsx("div",{className:"mt-2 px-1",children:s.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11px] leading-relaxed text-amber-800",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),S==="TEAM"&&w&&s.jsxs("div",{className:"rounded-b-xl rounded-tr-xl bg-neutral-50 px-4 pt-3 pb-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:i("团队协作配置")}),s.jsx("button",{type:"button",onClick:()=>{v("SOLO"),E(!1)},className:"text-[11px] text-neutral-400 hover:text-neutral-600 transition-colors",children:i("切换回单 Agent")})]}),s.jsx(ul,{mode:d,setMode:u,selectedTemplateId:x,setSelectedTemplateId:y,selectedMemberPresetIds:k,setSelectedMemberPresetIds:j,disabled:W})]})]})}function Do({text:e,className:t}){const[r,a]=C.useState(""),[m,p]=C.useState(!1);return C.useEffect(()=>{a(""),p(!1);let _=0;const i=setInterval(()=>{_++,_>=e.length?(a(e),p(!0),clearInterval(i)):a(e.slice(0,_))},50);return()=>clearInterval(i)},[e]),s.jsxs("p",{className:t,children:[r,!m&&s.jsx("span",{className:"inline-block w-[2px] h-[1em] bg-neutral-400 ml-0.5 align-middle animate-pulse"})]})}const Lo=s.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),mv=260,pv=600,Po=400,gv=100,pi=1e3;function Bv(){const{t:e}=ce(),[t,r]=C.useState(null),[a,m]=C.useState(null),[p,_]=C.useState(Po),[i,n]=C.useState(!1),[c,h]=C.useState("idle"),l=C.useRef(!1),g=C.useRef(0),b=C.useRef(Po),S=C.useRef(null),v=et(),{data:o,isLoading:f}=Hs(),{data:d,isLoading:u}=xc({limit:gv}),x=C.useMemo(()=>d?.data??[],[d?.data]),y=C.useMemo(()=>x.map(jg),[x]),k=a&&x.some(U=>U.id===a)?a:null,{data:j,isLoading:w}=uc(k??"",{limit:pi}),E=kc({queries:k?[]:x.map(U=>({queryKey:le.tasks.list(U.id,{limit:pi}),queryFn:()=>_e.get(`/projects/${U.id}/tasks`,{params:{limit:String(pi)}})}))}),N=!k&&E.some(U=>U.isLoading),T=C.useMemo(()=>{if(k)return j?.data??[];const U=[];for(const ee of E)ee.data?.data&&U.push(...ee.data.data);return U},[k,j,E]),[R,M]=C.useState(null),O=C.useMemo(()=>t&&T.some(U=>U.id===t)?t:R&&t===R?R:null,[t,T,R]);C.useEffect(()=>{R&&T.some(U=>U.id===R)&&M(null)},[R,T]);const B=C.useMemo(()=>{const U=new Map;for(const ee of T){const ie=ee.createdAt?new Date(ee.createdAt).getTime():0,pe=U.get(ee.projectId)??0;ie>pe&&U.set(ee.projectId,ie)}return[...x].sort((ee,ie)=>{const pe=U.get(ee.id)??(ee.createdAt?new Date(ee.createdAt).getTime():0);return(U.get(ie.id)??(ie.createdAt?new Date(ie.createdAt).getTime():0))-pe})},[x,T]),F=C.useMemo(()=>B.filter(U=>!U.archivedAt),[B]),z=C.useMemo(()=>{if(!o)return[];const U=localStorage.getItem("providerUsageCount"),ee=U?JSON.parse(U):{};return[...o].sort((ie,pe)=>{const he=ie.availability.type!=="NOT_FOUND",qe=pe.availability.type!=="NOT_FOUND";if(he!==qe)return he?-1:1;const we=ee[ie.provider.id]??0;return(ee[pe.provider.id]??0)-we})},[o]),A=C.useMemo(()=>T.map(Rg),[T]),L=C.useMemo(()=>new Set,[]),P=C.useMemo(()=>{if(!O)return null;const U=T.find(ie=>ie.id===O);if(!U)return null;const ee=x.find(ie=>ie.id===U.projectId);if(!ee){const ie=ns(U.workspaces?.find(pe=>pe.status==="ACTIVE")??U.workspaces?.[0]);return{id:U.id,projectId:U.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:U.title,status:fn(U.status),branch:ie,mainBranch:"main",description:U.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Ag(U,ee)},[O,T,x]),I=zo(),$=hc(),X=fc(),V=C.useCallback(U=>{$.mutate(U,{onSuccess:()=>{O===U&&r(null),v.invalidateQueries({queryKey:le.tasks.all})},onError:()=>{Rt.error(e("删除任务失败"))}})},[$,O,v,e]),se=C.useCallback((U,ee)=>{X.mutate({id:U,status:kg(ee)},{onError:()=>{Rt.error(e("状态变更失败,该操作不被允许"))}})},[X,e]),ae=C.useCallback(U=>{U.preventDefault(),l.current=!0,g.current=U.clientX,b.current=p,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[p]);C.useEffect(()=>{const U=ie=>{if(!l.current)return;const pe=ie.clientX-g.current,he=Math.max(mv,Math.min(pv,b.current+pe));_(he)},ee=()=>{l.current&&(l.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",U),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",ee)}},[]);const D=C.useCallback(()=>{n(!0)},[]),H=C.useCallback(()=>{if(F.length===0){Rt.error(e("没有可用项目,请先创建或恢复项目"));return}r(null)},[F,e]),q=C.useCallback(()=>{n(!1)},[]),W=un(),Y=C.useCallback(async U=>{const{title:ee,description:ie,projectId:pe,providerId:he,mode:qe,workspaceMode:we,teamRunMode:Ge,teamTemplateId:Ce,memberPresetIds:K,attachmentLinks:G}=U,fe=[ie,G].filter(Boolean).join(`
|
|
86
|
+
|
|
87
|
+
`);let ge=null;try{if(h("creating-task"),ge=await _e.post(`/projects/${pe}/tasks`,{title:ee,description:fe||void 0}),localStorage.setItem("lastSelectedProjectId",pe),qe==="SOLO"&&he){localStorage.setItem("lastSelectedProviderId",he);const xe=localStorage.getItem("providerUsageCount"),Ne=xe?JSON.parse(xe):{};Ne[he]=(Ne[he]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Ne))}if(qe==="TEAM")h("creating-teamrun"),await I.mutateAsync({taskId:ge.id,mode:Ge,...Ce?{teamTemplateId:Ce}:{},...K.length>0?{memberPresetIds:K}:{}});else if(he){const xe=[ee,fe].filter(Boolean).join(`
|
|
88
|
+
|
|
89
|
+
`);h("creating-workspace");const Ne=await _e.post(`/tasks/${ge.id}/workspaces`,{workspaceKind:we});h("creating-session");const Ze=await _e.post(`/workspaces/${Ne.id}/sessions`,{providerId:he,prompt:xe});h("starting-session"),await W.mutateAsync(Ze.id),await v.invalidateQueries({queryKey:le.workspaces.list(ge.id)})}k&&pe!==k&&m(null),M(ge.id),r(ge.id),h("idle"),v.invalidateQueries({queryKey:le.tasks.all}),v.invalidateQueries({queryKey:le.projects.all})}catch(xe){if(h("idle"),ge&&qe==="TEAM"){try{await $.mutateAsync(ge.id)}catch{}throw Rt.error(e("TeamRun 创建失败,请检查团队配置后重试")),xe}else if(ge)k&&pe!==k&&m(null),M(ge.id),r(ge.id),v.invalidateQueries({queryKey:le.tasks.all}),v.invalidateQueries({queryKey:le.projects.all}),Rt.error(e("任务已创建,但启动 Agent 失败,可在详情中重试"));else throw Rt.error(xe instanceof Error?xe.message:e("Failed to create task")),xe}},[I,W,$,v,e,k]),Q=u||w||N,oe=C.useMemo(()=>F.map(U=>({id:U.id,name:U.name})),[F]),de=C.useMemo(()=>z.map(({provider:U,availability:ee})=>({id:U.id,name:U.name,available:ee.type!=="NOT_FOUND"})),[z]),je=C.useMemo(()=>{if(k&&F.find(ee=>ee.id===k))return k;const U=localStorage.getItem("lastSelectedProjectId");return U&&F.find(ee=>ee.id===U)?U:F[0]?.id??""},[F,k]),ze=C.useMemo(()=>{const U=localStorage.getItem("lastSelectedProviderId");return U&&z.find(ie=>ie.provider.id===U&&ie.availability.type!=="NOT_FOUND")?U:z.find(ie=>ie.availability.type!=="NOT_FOUND")?.provider.id??""},[z]),re=xa(),[Te,Ue]=C.useState(!1),Ae=C.useCallback(()=>{if(F.length===0){Rt.error(e("没有可用项目,请先创建或恢复项目"));return}Ue(!0)},[F,e]),Se=C.useCallback(async U=>{await Y(U),Ue(!1)},[Y]);return re?Te?s.jsxs("div",{className:"flex flex-col h-dvh bg-white overflow-hidden text-sm",children:[s.jsx("header",{className:"h-12 border-b border-neutral-200 flex items-center px-4 shrink-0",children:s.jsx("button",{onClick:()=>Ue(!1),className:"text-sm text-neutral-600 active:text-neutral-900",children:e("Cancel")})}),s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4",children:[s.jsx("h1",{className:"text-xl text-neutral-900 mb-1.5 tracking-tight",children:e("欢迎使用 Agent Tower")}),s.jsx(Do,{text:e("描述任务,选择 Agent 或团队,即刻开始"),className:"text-[13px] text-neutral-400 mb-6"}),s.jsx(Mo,{projects:oe,providers:de,isProvidersLoading:f,onSubmit:Se,defaultProjectId:je,defaultProviderId:ze,createStep:c})]})]}):O&&P?s.jsxs(s.Fragment,{children:[s.jsx(Yg,{task:P,onBack:()=>r(null),onDeleteTask:P.projectArchivedAt?void 0:V,isDeleting:$.isPending}),s.jsx(mi,{isOpen:i,onClose:q})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(To,{}),Lo]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ao,{}),s.jsx("button",{onClick:()=>Cn.getState().openSettings(),className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:s.jsx(wn,{size:16})})]})]}),Q&&A.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):s.jsx(Wn,{tasks:A,projects:y,selectedTaskId:null,onSelectTask:r,filterProjectId:k,setFilterProjectId:m,width:"100%",onCreateProject:D,onCreateTask:Ae,activeTaskIds:L,onTaskStatusChange:se})]}),s.jsx(mi,{isOpen:i,onClose:q})]}):s.jsxs("div",{ref:S,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(To,{}),Lo]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ao,{}),s.jsx("button",{onClick:()=>Cn.getState().openSettings(),className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:s.jsx(wn,{size:16})})]})]}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Q&&A.length===0?s.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:p},children:e("Loading...")}):s.jsx(Wn,{tasks:A,projects:y,selectedTaskId:O,onSelectTask:r,filterProjectId:k,setFilterProjectId:m,width:p,onCreateProject:D,onCreateTask:H,activeTaskIds:L,onTaskStatusChange:se,onDeleteTask:V}),s.jsx("div",{onMouseDown:ae,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),O&&P?s.jsx(Cg,{task:P,onDeleteTask:P.projectArchivedAt?void 0:V,isDeleting:$.isPending,onTaskStatusChange:P.projectArchivedAt?void 0:se}):O&&!P?s.jsx("div",{className:"flex-1 flex items-center justify-center bg-white min-w-0",children:s.jsx("span",{className:"text-sm text-neutral-400",children:e("Loading...")})}):s.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-white min-w-0 px-8",children:s.jsxs("div",{className:"w-full max-w-3xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[s.jsx("h1",{className:"text-2xl text-neutral-900 mb-1.5 tracking-tight",children:e("欢迎使用 Agent Tower")}),s.jsx(Do,{text:e("描述任务,选择 Agent 或团队,即刻开始"),className:"text-[13px] text-neutral-400 mb-8"}),s.jsx(Mo,{projects:oe,providers:de,isProvidersLoading:f,onSubmit:Y,defaultProjectId:je,defaultProviderId:ze,createStep:c})]})})]}),s.jsx(mi,{isOpen:i,onClose:q})]})}export{Bv as ProjectKanbanPage};
|