agent-tower 0.3.13 → 0.3.15
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/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +31 -1
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +53 -0
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +9 -0
- package/dist/routes/tasks.js.map +1 -1
- package/dist/services/project-guards.d.ts +9 -0
- package/dist/services/project-guards.d.ts.map +1 -0
- package/dist/services/project-guards.js +15 -0
- package/dist/services/project-guards.js.map +1 -0
- package/dist/services/project.service.d.ts +42 -3
- package/dist/services/project.service.d.ts.map +1 -1
- package/dist/services/project.service.js +159 -20
- package/dist/services/project.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +10 -10
- package/dist/services/task.service.d.ts +36 -2
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +67 -5
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts +20 -11
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +8 -1
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-HesErDgP.js +1 -0
- package/dist/web/assets/{DemoPage-CJ38nIO8.js → DemoPage-_JvTlAiA.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-B7VYEpgr.js → GeneralSettingsPage-CJ9zjMoZ.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-CHD4DBUP.js → NotificationSettingsPage-DulSelTy.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-qmtWRC95.js → ProfileSettingsPage-D6bXZqqi.js} +2 -2
- package/dist/web/assets/ProjectKanbanPage-CMIFryFy.js +87 -0
- package/dist/web/assets/ProjectSettingsPage-w-ch_TzQ.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-BHH0jqW4.js → ProviderSettingsPage-fdnDecHo.js} +3 -3
- package/dist/web/assets/{button-CljdSOa6.js → button-DWEfhrOb.js} +1 -1
- package/dist/web/assets/{chevron-down-BYofhuN2.js → chevron-down-r1WqxE7T.js} +1 -1
- package/dist/web/assets/chevron-right-BoX1HZb8.js +1 -0
- package/dist/web/assets/{circle-alert-mZUTomft.js → circle-alert-Dsf4sjes.js} +1 -1
- package/dist/web/assets/{circle-check-CE93UcTb.js → circle-check-ClwRPrUg.js} +1 -1
- package/dist/web/assets/code-block-OCS4YCEC-DgzIFFQa.js +2 -0
- package/dist/web/assets/{confirm-dialog-nNRI_61i.js → confirm-dialog-CHgJE4TL.js} +1 -1
- package/dist/web/assets/folder-picker-CWyzaOjA.js +1 -0
- package/dist/web/assets/index-CnQr7qh9.css +1 -0
- package/dist/web/assets/index-Dz23RytL.js +13 -0
- package/dist/web/assets/{loader-circle-C9xqhRQy.js → loader-circle-6llnjfOV.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DCP6uuN7.js → mermaid-NOHMQCX5-DFcKyU--.js} +44 -44
- package/dist/web/assets/modal-BlrEFlKt.js +1 -0
- package/dist/web/assets/{pencil-Ch8xuc6u.js → pencil-BYLehKfm.js} +1 -1
- package/dist/web/assets/rotate-ccw-Ca8el0Vt.js +1 -0
- package/dist/web/assets/{select-BzwBaSER.js → select-BSrh_Wca.js} +1 -1
- package/dist/web/assets/{use-profiles-B5A7JdZj.js → use-profiles-D0vf97yX.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +4 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260403000000_add_project_archival/migration.sql +10 -0
- package/prisma/schema.prisma +6 -0
- package/dist/web/assets/AgentDemoPage-CTlnJyU5.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-BlLvUJHU.js +0 -85
- package/dist/web/assets/ProjectSettingsPage-jenb_WWg.js +0 -2
- package/dist/web/assets/code-block-OCS4YCEC-BFgaKpDI.js +0 -2
- package/dist/web/assets/folder-picker-DBgAK0Ax.js +0 -1
- package/dist/web/assets/index-8kxJ66vL.js +0 -13
- package/dist/web/assets/index-HqeZJR3B.css +0 -1
- package/dist/web/assets/modal-BoAiDPtT.js +0 -1
- package/dist/web/assets/use-projects-CEI8i-dO.js +0 -1
- package/dist/web/assets/x-nkgvEsnZ.js +0 -1
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-BoAiDPtT.js","assets/index-8kxJ66vL.js","assets/index-HqeZJR3B.css","assets/utils-CkSf8FUe.js","assets/x-nkgvEsnZ.js","assets/folder-picker-DBgAK0Ax.js","assets/mermaid-NOHMQCX5-DCP6uuN7.js","assets/log-adapter-50wgehrc.js","assets/chevron-down-BYofhuN2.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/loader-circle-C9xqhRQy.js","assets/circle-alert-mZUTomft.js","assets/use-projects-CEI8i-dO.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{Q as Cr,i as Kr,h as Wo,g as $o,k as Uo,n as dr,l as qo,m as Ko,b as Fe,o as Xo,p as Yo,r as k,v as Vo,w as Go,x as Qo,y as Zo,z as Xr,A as Yr,B as Jo,D as ea,E as ta,e as be,R as ee,G as jt,u as ue,j as l,s as vt,S as Be,C as ut,d as ge,c as Ge,q as he,a as st,f as Ct,H as Vr,I as sa,t as ra,L as Gr,_ as Zi}from"./index-8kxJ66vL.js";import{C as Nt,h as wr,b as Er,d as kr,c as Rr,i as Dr,G as Ns,u as Ji,a as en,Q as tn,e as sn,T as rn,P as xs,f as nn,S as Qr}from"./mermaid-NOHMQCX5-DCP6uuN7.js";import{C as _t,a as Zt}from"./chevron-down-BYofhuN2.js";import{P as fr,X as Ps}from"./x-nkgvEsnZ.js";import{u as Os,T as on,g as ia,A as dt,S as Pe,C as an,h as ht}from"./confirm-dialog-nNRI_61i.js";import"./log-adapter-50wgehrc.js";import{B as ft}from"./button-CljdSOa6.js";import{c as Se,t as Zr}from"./utils-CkSf8FUe.js";import{F as na,a as oa,c as aa,u as la,d as ca}from"./use-projects-CEI8i-dO.js";import{L as Ie}from"./loader-circle-C9xqhRQy.js";import{M as Tr,T as ln}from"./modal-BoAiDPtT.js";import{S as ds}from"./select-BzwBaSER.js";var ha=class extends Cr{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:Kr()})}getOptimisticResult(e){return e.behavior=Kr(),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:s}=e,a=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:C,isRefetchError:i}=a,r=s.fetchMeta?.fetchMore?.direction,c=C&&r==="forward",f=m&&r==="forward",o=C&&r==="backward",p=m&&r==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:$o(t,s.data),hasPreviousPage:Wo(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:i&&!c&&!o,isRefetching:v&&!f&&!p}}};function Jr(e,t){const s=new Set(t);return e.filter(a=>!s.has(a))}function ua(e,t,s){const a=e.slice(0);return a[t]=s,a}var da=class extends Uo{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,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,dr.batch(()=>{const s=this.#t,a=this.#d(this.#i);a.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=a.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),C=s.length!==m.length,i=m.some((f,o)=>f!==s[o]),r=C||i,c=r?!0:v.some((f,o)=>{const p=this.#e[o];return!p||!qo(f,p)});!r&&!c||(r&&(this.#c=a,this.#t=m),this.#e=v,this.hasListeners()&&(r&&(Jr(s,m).forEach(f=>{f.destroy()}),Jr(m,s).forEach(f=>{f.subscribe(o=>{this.#f(f,o)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),a=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[a,v=>this.#u(v??a,t,m),()=>this.#h(a,s)]}#h(e,t){return t.map((s,a)=>{const m=e[a];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(C=>{C.observer.trackProp(v)})})})}#u(e,t,s){if(t){const a=this.#l,m=s!==void 0&&a!==void 0&&(a.length!==s.length||s.some((v,C)=>v!==a[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Ko(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(a=>{const m=a.options.queryHash;if(!m)return;const v=t.get(m);v?v.push(a):t.set(m,[a])});const s=[];return e.forEach(a=>{const m=this.#r.defaultQueryOptions(a),C=t.get(m.queryHash)?.shift()??new Cr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ua(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&dr.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function fa({queries:e,...t},s){const a=Fe(),m=Xo(),v=Yo(),C=k.useMemo(()=>e.map(g=>{const n=a.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,a,m]);C.forEach(g=>{Vo(g);const n=a.getQueryCache().get(g.queryHash);Go(g,v,n)}),Qo(v);const[i]=k.useState(()=>new da(a,C,t)),[r,c,f]=i.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?i.subscribe(dr.batchCalls(g)):Zo,[i,o]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),k.useEffect(()=>{i.setQueries(C,t)},[C,t,i]);const b=r.some((g,n)=>Xr(C[n],g))?r.flatMap((g,n)=>{const d=C[n];if(d){const h=new Cr(a,d);if(Xr(d,g))return Yr(d,h,v);Jo(g,m)&&Yr(d,h,v)}return[]}):[];if(b.length>0)throw Promise.all(b);const S=r.find((g,n)=>{const d=C[n];return d&&ea({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:a.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(S?.error)throw S.error;return c(f())}function cn(e,t){return ta(e,ha)}const ma=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],hn=be("arrow-down",ma);const pa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],un=be("arrow-right",pa);const va=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],dn=be("arrow-up",va);const ga=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ei=be("circle-check-big",ga);const _a=[["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"}]],Bs=be("code-xml",_a);const ba=[["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"}]],ti=be("copy",ba);const xa=[["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"}]],fn=be("ellipsis-vertical",xa);const Sa=[["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"}]],ya=be("file-braces-corner",Sa);const Ca=[["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"}]],Jt=be("file-code-corner",Ca);const wa=[["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"}]],Ea=be("file-exclamation-point",wa);const ka=[["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"}]],mn=be("file-text",ka);const Ra=[["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"}]],pn=be("folder-open",Ra);const Da=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ta=be("gauge",Da);const La=[["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"}]],ja=be("git-branch",La);const Aa=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Ma=be("git-fork",Aa);const Na=[["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"}]],es=be("git-graph",Na);const Pa=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],vn=be("git-merge",Pa);const Oa=[["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"}]],Ht=be("history",Oa);const Ba=[["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"}]],Lr=be("image",Ba);const Ia=[["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"}]],si=be("layers",Ia);const Fa=[["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"}]],Ha=be("maximize",Fa);const za=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Wa=be("message-square",za);const $a=[["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"}]],Ua=be("panel-left-close",$a);const qa=[["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"}]],Ka=be("panel-left-open",qa);const Xa=[["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"}]],Ya=be("panel-right-close",Xa);const Va=[["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"}]],Ga=be("panel-right-open",Va);const Qa=[["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"}]],It=be("play",Qa);const Za=[["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"}]],Ja=be("refresh-cw",Za);const el=[["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"}]],tl=be("shield",el);const sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ss=be("terminal",sl);const rl=[["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"}]],il=be("zap",rl);const nl=[["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"}]],ol=be("zoom-in",nl);const al=[["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"}]],ll=be("zoom-out",al),Is=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function jr(e){return"nodeType"in e}function Ve(e){var t,s;return e?zt(e)?e:jr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Ar(e){const{Document:t}=Ve(e);return e instanceof t}function ns(e){return zt(e)?!1:e instanceof Ve(e).HTMLElement}function gn(e){return e instanceof Ve(e).SVGElement}function Wt(e){return e?zt(e)?e.document:jr(e)?Ar(e)?e:ns(e)||gn(e)?e.ownerDocument:document:document:document}const gt=Is?k.useLayoutEffect:k.useEffect;function Fs(e){const t=k.useRef(e);return gt(()=>{t.current=e}),k.useCallback(function(){for(var s=arguments.length,a=new Array(s),m=0;m<s;m++)a[m]=arguments[m];return t.current==null?void 0:t.current(...a)},[])}function cl(){const e=k.useRef(null),t=k.useCallback((a,m)=>{e.current=setInterval(a,m)},[]),s=k.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function ts(e,t){t===void 0&&(t=[e]);const s=k.useRef(e);return gt(()=>{s.current!==e&&(s.current=e)},t),s}function os(e,t){const s=k.useRef();return k.useMemo(()=>{const a=e(s.current);return s.current=a,a},[...t])}function ys(e){const t=Fs(e),s=k.useRef(null),a=k.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,a]}function Cs(e){const t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}let Gs={};function Hs(e,t){return k.useMemo(()=>{if(t)return t;const s=Gs[e]==null?0:Gs[e]+1;return Gs[e]=s,e+"-"+s},[e,t])}function _n(e){return function(t){for(var s=arguments.length,a=new Array(s>1?s-1:0),m=1;m<s;m++)a[m-1]=arguments[m];return a.reduce((v,C)=>{const i=Object.entries(C);for(const[r,c]of i){const f=v[r];f!=null&&(v[r]=f+e*c)}return v},{...t})}}const Ft=_n(1),ws=_n(-1);function hl(e){return"clientX"in e&&"clientY"in e}function Mr(e){if(!e)return!1;const{KeyboardEvent:t}=Ve(e.target);return t&&e instanceof t}function ul(e){if(!e)return!1;const{TouchEvent:t}=Ve(e.target);return t&&e instanceof t}function Es(e){if(ul(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return hl(e)?{x:e.clientX,y:e.clientY}:null}const ss=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[ss.Translate.toString(e),ss.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:a}=e;return t+" "+s+"ms "+a}}}),ri="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function dl(e){return e.matches(ri)?e:e.querySelector(ri)}const fl={display:"none"};function ml(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:fl},s)}function pl(e){let{id:t,announcement:s,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 ee.createElement("div",{id:t,style:m,role:"status","aria-live":a,"aria-atomic":!0},s)}function vl(){const[e,t]=k.useState("");return{announce:k.useCallback(a=>{a!=null&&t(a)},[]),announcement:e}}const bn=k.createContext(null);function gl(e){const t=k.useContext(bn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function _l(){const[e]=k.useState(()=>new Set),t=k.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]);return[k.useCallback(a=>{let{type:m,event:v}=a;e.forEach(C=>{var i;return(i=C[m])==null?void 0:i.call(C,v)})},[e]),t]}const bl={draggable:`
|
|
3
|
-
To pick up a draggable item, press the space bar.
|
|
4
|
-
While dragging, use the arrow keys to move the item.
|
|
5
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},xl={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Sl(e){let{announcements:t=xl,container:s,hiddenTextDescribedById:a,screenReaderInstructions:m=bl}=e;const{announce:v,announcement:C}=vl(),i=Hs("DndLiveRegion"),[r,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),gl(k.useMemo(()=>({onDragStart(o){let{active:p}=o;v(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:b}=o;t.onDragMove&&v(t.onDragMove({active:p,over:b}))},onDragOver(o){let{active:p,over:b}=o;v(t.onDragOver({active:p,over:b}))},onDragEnd(o){let{active:p,over:b}=o;v(t.onDragEnd({active:p,over:b}))},onDragCancel(o){let{active:p,over:b}=o;v(t.onDragCancel({active:p,over:b}))}}),[v,t])),!r)return null;const f=ee.createElement(ee.Fragment,null,ee.createElement(ml,{id:a,value:m.draggable}),ee.createElement(pl,{id:i,announcement:C}));return s?jt.createPortal(f,s):f}var ze;(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"})(ze||(ze={}));function ks(){}function yl(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Cl(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return k.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const ot=Object.freeze({x:0,y:0});function wl(e,t){const s=Es(e);if(!s)return"0 0";const a={x:(s.x-t.left)/t.width*100,y:(s.y-t.top)/t.height*100};return a.x+"% "+a.y+"%"}function El(e,t){let{data:{value:s}}=e,{data:{value:a}}=t;return a-s}function kl(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function Rl(e,t){const s=Math.max(t.top,e.top),a=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),v=Math.min(t.top+t.height,e.top+e.height),C=m-a,i=v-s;if(a<m&&s<v){const r=t.width*t.height,c=e.width*e.height,f=C*i,o=f/(r+c-f);return Number(o.toFixed(4))}return 0}const Dl=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:a}=e;const m=[];for(const v of a){const{id:C}=v,i=s.get(C);if(i){const r=Rl(i,t);r>0&&m.push({id:C,data:{droppableContainer:v,value:r}})}}return m.sort(El)};function Tl(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function xn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ot}function Ll(e){return function(s){for(var a=arguments.length,m=new Array(a>1?a-1:0),v=1;v<a;v++)m[v-1]=arguments[v];return m.reduce((C,i)=>({...C,top:C.top+e*i.y,bottom:C.bottom+e*i.y,left:C.left+e*i.x,right:C.right+e*i.x}),{...s})}}const jl=Ll(1);function Sn(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 Al(e,t,s){const a=Sn(t);if(!a)return e;const{scaleX:m,scaleY:v,x:C,y:i}=a,r=e.left-C-(1-m)*parseFloat(s),c=e.top-i-(1-v)*parseFloat(s.slice(s.indexOf(" ")+1)),f=m?e.width/m:e.width,o=v?e.height/v:e.height;return{width:f,height:o,top:c,right:r+f,bottom:c+o,left:r}}const Ml={ignoreTransform:!1};function as(e,t){t===void 0&&(t=Ml);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=Ve(e).getComputedStyle(e);c&&(s=Al(s,c,f))}const{top:a,left:m,width:v,height:C,bottom:i,right:r}=s;return{top:a,left:m,width:v,height:C,bottom:i,right:r}}function ii(e){return as(e,{ignoreTransform:!0})}function Nl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function Pl(e,t){return t===void 0&&(t=Ve(e).getComputedStyle(e)),t.position==="fixed"}function Ol(e,t){t===void 0&&(t=Ve(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const v=t[m];return typeof v=="string"?s.test(v):!1})}function Nr(e,t){const s=[];function a(m){if(t!=null&&s.length>=t||!m)return s;if(Ar(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!ns(m)||gn(m)||s.includes(m))return s;const v=Ve(e).getComputedStyle(m);return m!==e&&Ol(m,v)&&s.push(m),Pl(m,v)?s:a(m.parentNode)}return e?a(e):s}function yn(e){const[t]=Nr(e,1);return t??null}function Qs(e){return!Is||!e?null:zt(e)?e:jr(e)?Ar(e)||e===Wt(e).scrollingElement?window:ns(e)?e:null:null}function Cn(e){return zt(e)?e.scrollX:e.scrollLeft}function wn(e){return zt(e)?e.scrollY:e.scrollTop}function mr(e){return{x:Cn(e),y:wn(e)}}var Ue;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ue||(Ue={}));function En(e){return!Is||!e?!1:e===document.scrollingElement}function kn(e){const t={x:0,y:0},s=En(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},m=e.scrollTop<=t.y,v=e.scrollLeft<=t.x,C=e.scrollTop>=a.y,i=e.scrollLeft>=a.x;return{isTop:m,isLeft:v,isBottom:C,isRight:i,maxScroll:a,minScroll:t}}const Bl={x:.2,y:.2};function Il(e,t,s,a,m){let{top:v,left:C,right:i,bottom:r}=s;a===void 0&&(a=10),m===void 0&&(m=Bl);const{isTop:c,isBottom:f,isLeft:o,isRight:p}=kn(e),b={x:0,y:0},S={x:0,y:0},g={height:t.height*m.y,width:t.width*m.x};return!c&&v<=t.top+g.height?(b.y=Ue.Backward,S.y=a*Math.abs((t.top+g.height-v)/g.height)):!f&&r>=t.bottom-g.height&&(b.y=Ue.Forward,S.y=a*Math.abs((t.bottom-g.height-r)/g.height)),!p&&i>=t.right-g.width?(b.x=Ue.Forward,S.x=a*Math.abs((t.right-g.width-i)/g.width)):!o&&C<=t.left+g.width&&(b.x=Ue.Backward,S.x=a*Math.abs((t.left+g.width-C)/g.width)),{direction:b,speed:S}}function Fl(e){if(e===document.scrollingElement){const{innerWidth:v,innerHeight:C}=window;return{top:0,left:0,right:v,bottom:C,width:v,height:C}}const{top:t,left:s,right:a,bottom:m}=e.getBoundingClientRect();return{top:t,left:s,right:a,bottom:m,width:e.clientWidth,height:e.clientHeight}}function Rn(e){return e.reduce((t,s)=>Ft(t,mr(s)),ot)}function Hl(e){return e.reduce((t,s)=>t+Cn(s),0)}function zl(e){return e.reduce((t,s)=>t+wn(s),0)}function Dn(e,t){if(t===void 0&&(t=as),!e)return;const{top:s,left:a,bottom:m,right:v}=t(e);yn(e)&&(m<=0||v<=0||s>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Wl=[["x",["left","right"],Hl],["y",["top","bottom"],zl]];class Pr{constructor(t,s){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=Nr(s),m=Rn(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[v,C,i]of Wl)for(const r of C)Object.defineProperty(this,r,{get:()=>{const c=i(a),f=m[v]-c;return this.rect[r]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Yt{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...s)})},this.target=t}add(t,s,a){var m;(m=this.target)==null||m.addEventListener(t,s,a),this.listeners.push([t,s,a])}}function $l(e){const{EventTarget:t}=Ve(e);return e instanceof t?e:Wt(e)}function Zs(e,t){const s=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+a**2)>t:"x"in t&&"y"in t?s>t.x&&a>t.y:"x"in t?s>t.x:"y"in t?a>t.y:!1}var et;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(et||(et={}));function ni(e){e.preventDefault()}function Ul(e){e.stopPropagation()}var we;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(we||(we={}));const Tn={start:[we.Space,we.Enter],cancel:[we.Esc],end:[we.Space,we.Enter,we.Tab]},ql=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case we.Right:return{...s,x:s.x+25};case we.Left:return{...s,x:s.x-25};case we.Down:return{...s,y:s.y+25};case we.Up:return{...s,y:s.y-25}}};class Ln{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:s}}=t;this.props=t,this.listeners=new Yt(Wt(s)),this.windowListeners=new Yt(Ve(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(et.Resize,this.handleCancel),this.windowListeners.add(et.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(et.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,a=t.node.current;a&&Dn(a),s(ot)}handleKeyDown(t){if(Mr(t)){const{active:s,context:a,options:m}=this.props,{keyboardCodes:v=Tn,coordinateGetter:C=ql,scrollBehavior:i="smooth"}=m,{code:r}=t;if(v.end.includes(r)){this.handleEnd(t);return}if(v.cancel.includes(r)){this.handleCancel(t);return}const{collisionRect:c}=a.current,f=c?{x:c.left,y:c.top}:ot;this.referenceCoordinates||(this.referenceCoordinates=f);const o=C(t,{active:s,context:a.current,currentCoordinates:f});if(o){const p=ws(o,f),b={x:0,y:0},{scrollableAncestors:S}=a.current;for(const g of S){const n=t.code,{isTop:d,isRight:h,isLeft:u,isBottom:_,maxScroll:y,minScroll:w}=kn(g),E=Fl(g),x={x:Math.min(n===we.Right?E.right-E.width/2:E.right,Math.max(n===we.Right?E.left:E.left+E.width/2,o.x)),y:Math.min(n===we.Down?E.bottom-E.height/2:E.bottom,Math.max(n===we.Down?E.top:E.top+E.height/2,o.y))},R=n===we.Right&&!h||n===we.Left&&!u,T=n===we.Down&&!_||n===we.Up&&!d;if(R&&x.x!==o.x){const A=g.scrollLeft+p.x,j=n===we.Right&&A<=y.x||n===we.Left&&A>=w.x;if(j&&!p.y){g.scrollTo({left:A,behavior:i});return}j?b.x=g.scrollLeft-A:b.x=n===we.Right?g.scrollLeft-y.x:g.scrollLeft-w.x,b.x&&g.scrollBy({left:-b.x,behavior:i});break}else if(T&&x.y!==o.y){const A=g.scrollTop+p.y,j=n===we.Down&&A<=y.y||n===we.Up&&A>=w.y;if(j&&!p.x){g.scrollTo({top:A,behavior:i});return}j?b.y=g.scrollTop-A:b.y=n===we.Down?g.scrollTop-y.y:g.scrollTop-w.y,b.y&&g.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(t,Ft(ws(o,this.referenceCoordinates),b))}}}handleMove(t,s){const{onMove:a}=this.props;t.preventDefault(),a(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ln.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:a=Tn,onActivation:m}=t,{active:v}=s;const{code:C}=e.nativeEvent;if(a.start.includes(C)){const i=v.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function oi(e){return!!(e&&"distance"in e)}function ai(e){return!!(e&&"delay"in e)}class Or{constructor(t,s,a){var m;a===void 0&&(a=$l(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=s;const{event:v}=t,{target:C}=v;this.props=t,this.events=s,this.document=Wt(C),this.documentListeners=new Yt(this.document),this.listeners=new Yt(a),this.windowListeners=new Yt(Ve(C)),this.initialCoordinates=(m=Es(v))!=null?m:ot,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:s,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(et.Resize,this.handleCancel),this.windowListeners.add(et.DragStart,ni),this.windowListeners.add(et.VisibilityChange,this.handleCancel),this.windowListeners.add(et.ContextMenu,ni),this.documentListeners.add(et.Keydown,this.handleKeydown),s){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ai(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(oi(s)){this.handlePending(s);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,s){const{active:a,onPending:m}=this.props;m(a,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(et.Click,Ul,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(et.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:a,initialCoordinates:m,props:v}=this,{onMove:C,options:{activationConstraint:i}}=v;if(!m)return;const r=(s=Es(t))!=null?s:ot,c=ws(m,r);if(!a&&i){if(oi(i)){if(i.tolerance!=null&&Zs(c,i.tolerance))return this.handleCancel();if(Zs(c,i.distance))return this.handleStart()}if(ai(i)&&Zs(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),C(r)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===we.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Kl={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Br extends Or{constructor(t){const{event:s}=t,a=Wt(s.target);super(t,Kl,a)}}Br.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;return!s.isPrimary||s.button!==0?!1:(a?.({event:s}),!0)}}];const Xl={move:{name:"mousemove"},end:{name:"mouseup"}};var pr;(function(e){e[e.RightClick=2]="RightClick"})(pr||(pr={}));class Yl extends Or{constructor(t){super(t,Xl,Wt(t.event.target))}}Yl.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;return s.button===pr.RightClick?!1:(a?.({event:s}),!0)}}];const Js={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Vl extends Or{constructor(t){super(t,Js)}static setup(){return window.addEventListener(Js.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Js.move.name,t)};function t(){}}}Vl.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;const{touches:m}=s;return m.length>1?!1:(a?.({event:s}),!0)}}];var Vt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Vt||(Vt={}));var Rs;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rs||(Rs={}));function Gl(e){let{acceleration:t,activator:s=Vt.Pointer,canScroll:a,draggingRect:m,enabled:v,interval:C=5,order:i=Rs.TreeOrder,pointerCoordinates:r,scrollableAncestors:c,scrollableAncestorRects:f,delta:o,threshold:p}=e;const b=Zl({delta:o,disabled:!v}),[S,g]=cl(),n=k.useRef({x:0,y:0}),d=k.useRef({x:0,y:0}),h=k.useMemo(()=>{switch(s){case Vt.Pointer:return r?{top:r.y,bottom:r.y,left:r.x,right:r.x}:null;case Vt.DraggableRect:return m}},[s,m,r]),u=k.useRef(null),_=k.useCallback(()=>{const w=u.current;if(!w)return;const E=n.current.x*d.current.x,x=n.current.y*d.current.y;w.scrollBy(E,x)},[]),y=k.useMemo(()=>i===Rs.TreeOrder?[...c].reverse():c,[i,c]);k.useEffect(()=>{if(!v||!c.length||!h){g();return}for(const w of y){if(a?.(w)===!1)continue;const E=c.indexOf(w),x=f[E];if(!x)continue;const{direction:R,speed:T}=Il(w,x,h,t,p);for(const A of["x","y"])b[A][R[A]]||(T[A]=0,R[A]=0);if(T.x>0||T.y>0){g(),u.current=w,S(_,C),n.current=T,d.current=R;return}}n.current={x:0,y:0},d.current={x:0,y:0},g()},[t,_,a,g,v,C,JSON.stringify(h),JSON.stringify(b),S,c,y,f,JSON.stringify(p)])}const Ql={x:{[Ue.Backward]:!1,[Ue.Forward]:!1},y:{[Ue.Backward]:!1,[Ue.Forward]:!1}};function Zl(e){let{delta:t,disabled:s}=e;const a=Cs(t);return os(m=>{if(s||!a||!m)return Ql;const v={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[Ue.Backward]:m.x[Ue.Backward]||v.x===-1,[Ue.Forward]:m.x[Ue.Forward]||v.x===1},y:{[Ue.Backward]:m.y[Ue.Backward]||v.y===-1,[Ue.Forward]:m.y[Ue.Forward]||v.y===1}}},[s,t,a])}function Jl(e,t){const s=t!=null?e.get(t):void 0,a=s?s.node.current:null;return os(m=>{var v;return t==null?null:(v=a??m)!=null?v:null},[a,t])}function ec(e,t){return k.useMemo(()=>e.reduce((s,a)=>{const{sensor:m}=a,v=m.activators.map(C=>({eventName:C.eventName,handler:t(C.handler,a)}));return[...s,...v]},[]),[e,t])}var rs;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(rs||(rs={}));var vr;(function(e){e.Optimized="optimized"})(vr||(vr={}));const li=new Map;function tc(e,t){let{dragging:s,dependencies:a,config:m}=t;const[v,C]=k.useState(null),{frequency:i,measure:r,strategy:c}=m,f=k.useRef(e),o=n(),p=ts(o),b=k.useCallback(function(d){d===void 0&&(d=[]),!p.current&&C(h=>h===null?d:h.concat(d.filter(u=>!h.includes(u))))},[p]),S=k.useRef(null),g=os(d=>{if(o&&!s)return li;if(!d||d===li||f.current!==e||v!=null){const h=new Map;for(let u of e){if(!u)continue;if(v&&v.length>0&&!v.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const _=u.node.current,y=_?new Pr(r(_),_):null;u.rect.current=y,y&&h.set(u.id,y)}return h}return d},[e,v,s,o,r]);return k.useEffect(()=>{f.current=e},[e]),k.useEffect(()=>{o||b()},[s,o]),k.useEffect(()=>{v&&v.length>0&&C(null)},[JSON.stringify(v)]),k.useEffect(()=>{o||typeof i!="number"||S.current!==null||(S.current=setTimeout(()=>{b(),S.current=null},i))},[i,o,b,...a]),{droppableRects:g,measureDroppableContainers:b,measuringScheduled:v!=null};function n(){switch(c){case rs.Always:return!1;case rs.BeforeDragging:return s;default:return!s}}}function Ir(e,t){return os(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function sc(e,t){return Ir(e,t)}function rc(e){let{callback:t,disabled:s}=e;const a=Fs(t),m=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:v}=window;return new v(a)},[a,s]);return k.useEffect(()=>()=>m?.disconnect(),[m]),m}function zs(e){let{callback:t,disabled:s}=e;const a=Fs(t),m=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:v}=window;return new v(a)},[s]);return k.useEffect(()=>()=>m?.disconnect(),[m]),m}function ic(e){return new Pr(as(e),e)}function ci(e,t,s){t===void 0&&(t=ic);const[a,m]=k.useState(null);function v(){m(r=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=r??s)!=null?c:null}const f=t(e);return JSON.stringify(r)===JSON.stringify(f)?r:f})}const C=rc({callback(r){if(e)for(const c of r){const{type:f,target:o}=c;if(f==="childList"&&o instanceof HTMLElement&&o.contains(e)){v();break}}}}),i=zs({callback:v});return gt(()=>{v(),e?(i?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),C?.disconnect())},[e]),a}function nc(e){const t=Ir(e);return xn(e,t)}const hi=[];function oc(e){const t=k.useRef(e),s=os(a=>e?a&&a!==hi&&e&&t.current&&e.parentNode===t.current.parentNode?a:Nr(e):hi,[e]);return k.useEffect(()=>{t.current=e},[e]),s}function ac(e){const[t,s]=k.useState(null),a=k.useRef(e),m=k.useCallback(v=>{const C=Qs(v.target);C&&s(i=>i?(i.set(C,mr(C)),new Map(i)):null)},[]);return k.useEffect(()=>{const v=a.current;if(e!==v){C(v);const i=e.map(r=>{const c=Qs(r);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,mr(c)]):null}).filter(r=>r!=null);s(i.length?new Map(i):null),a.current=e}return()=>{C(e),C(v)};function C(i){i.forEach(r=>{const c=Qs(r);c?.removeEventListener("scroll",m)})}},[m,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((v,C)=>Ft(v,C),ot):Rn(e):ot,[e,t])}function ui(e,t){t===void 0&&(t=[]);const s=k.useRef(null);return k.useEffect(()=>{s.current=null},t),k.useEffect(()=>{const a=e!==ot;a&&!s.current&&(s.current=e),!a&&s.current&&(s.current=null)},[e]),s.current?ws(e,s.current):ot}function lc(e){k.useEffect(()=>{if(!Is)return;const t=e.map(s=>{let{sensor:a}=s;return a.setup==null?void 0:a.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function cc(e,t){return k.useMemo(()=>e.reduce((s,a)=>{let{eventName:m,handler:v}=a;return s[m]=C=>{v(C,t)},s},{}),[e,t])}function jn(e){return k.useMemo(()=>e?Nl(e):null,[e])}const di=[];function hc(e,t){t===void 0&&(t=as);const[s]=e,a=jn(s?Ve(s):null),[m,v]=k.useState(di);function C(){v(()=>e.length?e.map(r=>En(r)?a:new Pr(t(r),r)):di)}const i=zs({callback:C});return gt(()=>{i?.disconnect(),C(),e.forEach(r=>i?.observe(r))},[e]),m}function An(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ns(t)?t:e}function uc(e){let{measure:t}=e;const[s,a]=k.useState(null),m=k.useCallback(c=>{for(const{target:f}of c)if(ns(f)){a(o=>{const p=t(f);return o?{...o,width:p.width,height:p.height}:p});break}},[t]),v=zs({callback:m}),C=k.useCallback(c=>{const f=An(c);v?.disconnect(),f&&v?.observe(f),a(f?t(f):null)},[t,v]),[i,r]=ys(C);return k.useMemo(()=>({nodeRef:i,rect:s,setRef:r}),[s,i,r])}const dc=[{sensor:Br,options:{}},{sensor:Ln,options:{}}],fc={current:{}},bs={draggable:{measure:ii},droppable:{measure:ii,strategy:rs.WhileDragging,frequency:vr.Optimized},dragOverlay:{measure:as}};class Gt extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,a;return(s=(a=this.get(t))==null?void 0:a.node.current)!=null?s:void 0}}const mc={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Gt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ks},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:bs,measureDroppableContainers:ks,windowRect:null,measuringScheduled:!1},Mn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ks,draggableNodes:new Map,over:null,measureDroppableContainers:ks},ls=k.createContext(Mn),Nn=k.createContext(mc);function pc(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Gt}}}function vc(e,t){switch(t.type){case ze.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ze.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 ze.DragEnd:case ze.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ze.RegisterDroppable:{const{element:s}=t,{id:a}=s,m=new Gt(e.droppable.containers);return m.set(a,s),{...e,droppable:{...e.droppable,containers:m}}}case ze.SetDroppableDisabled:{const{id:s,key:a,disabled:m}=t,v=e.droppable.containers.get(s);if(!v||a!==v.key)return e;const C=new Gt(e.droppable.containers);return C.set(s,{...v,disabled:m}),{...e,droppable:{...e.droppable,containers:C}}}case ze.UnregisterDroppable:{const{id:s,key:a}=t,m=e.droppable.containers.get(s);if(!m||a!==m.key)return e;const v=new Gt(e.droppable.containers);return v.delete(s),{...e,droppable:{...e.droppable,containers:v}}}default:return e}}function gc(e){let{disabled:t}=e;const{active:s,activatorEvent:a,draggableNodes:m}=k.useContext(ls),v=Cs(a),C=Cs(s?.id);return k.useEffect(()=>{if(!t&&!a&&v&&C!=null){if(!Mr(v)||document.activeElement===v.target)return;const i=m.get(C);if(!i)return;const{activatorNode:r,node:c}=i;if(!r.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[r.current,c.current]){if(!f)continue;const o=dl(f);if(o){o.focus();break}}})}},[a,t,m,C,v]),null}function Pn(e,t){let{transform:s,...a}=t;return e!=null&&e.length?e.reduce((m,v)=>v({transform:m,...a}),s):s}function _c(e){return k.useMemo(()=>({draggable:{...bs.draggable,...e?.draggable},droppable:{...bs.droppable,...e?.droppable},dragOverlay:{...bs.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function bc(e){let{activeNode:t,measure:s,initialRect:a,config:m=!0}=e;const v=k.useRef(!1),{x:C,y:i}=typeof m=="boolean"?{x:m,y:m}:m;gt(()=>{if(!C&&!i||!t){v.current=!1;return}if(v.current||!a)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=s(c),o=xn(f,a);if(C||(o.x=0),i||(o.y=0),v.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const p=yn(c);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,i,a,s])}const Ws=k.createContext({...ot,scaleX:1,scaleY:1});var yt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(yt||(yt={}));const xc=k.memo(function(t){var s,a,m,v;let{id:C,accessibility:i,autoScroll:r=!0,children:c,sensors:f=dc,collisionDetection:o=Dl,measuring:p,modifiers:b,...S}=t;const g=k.useReducer(vc,void 0,pc),[n,d]=g,[h,u]=_l(),[_,y]=k.useState(yt.Uninitialized),w=_===yt.Initialized,{draggable:{active:E,nodes:x,translate:R},droppable:{containers:T}}=n,A=E!=null?x.get(E):null,j=k.useRef({initial:null,translated:null}),M=k.useMemo(()=>{var J;return E!=null?{id:E,data:(J=A?.data)!=null?J:fc,rect:j}:null},[E,A]),I=k.useRef(null),[B,H]=k.useState(null),[z,D]=k.useState(null),N=ts(S,Object.values(S)),P=Hs("DndDescribedBy",C),O=k.useMemo(()=>T.getEnabled(),[T]),$=_c(p),{droppableRects:K,measureDroppableContainers:Q,measuringScheduled:G}=tc(O,{dragging:w,dependencies:[R.x,R.y],config:$.droppable}),ne=Jl(x,E),L=k.useMemo(()=>z?Es(z):null,[z]),F=q(),U=sc(ne,$.draggable.measure);bc({activeNode:E!=null?x.get(E):null,config:F.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const W=ci(ne,$.draggable.measure,U),Z=ci(ne?ne.parentElement:null),X=k.useRef({activatorEvent:null,active:null,activeNode:ne,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:x,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=T.getNodeFor((s=X.current.over)==null?void 0:s.id),me=uc({measure:$.dragOverlay.measure}),xe=(a=me.nodeRef.current)!=null?a:ne,_e=w?(m=me.rect)!=null?m:W:null,ie=!!(me.nodeRef.current&&me.rect),Ce=nc(ie?null:W),Oe=jn(xe?Ve(xe):null),Le=oc(w?oe??ne:null),Xe=hc(Le),We=Pn(b,{transform:{x:R.x-Ce.x,y:R.y-Ce.y,scaleX:1,scaleY:1},activatorEvent:z,active:M,activeNodeRect:W,containerNodeRect:Z,draggingNodeRect:_e,over:X.current.over,overlayNodeRect:me.rect,scrollableAncestors:Le,scrollableAncestorRects:Xe,windowRect:Oe}),Te=L?Ft(L,R):null,Ke=ac(Le),He=ui(Ke),Me=ui(Ke,[W]),Y=Ft(We,He),se=_e?jl(_e,We):null,fe=M&&se?o({active:M,collisionRect:se,droppableRects:K,droppableContainers:O,pointerCoordinates:Te}):null,re=kl(fe,"id"),[de,ae]=k.useState(null),je=ie?We:Ft(We,Me),rt=Tl(je,(v=de?.rect)!=null?v:null,W),mt=k.useRef(null),Dt=k.useCallback((J,le)=>{let{sensor:pe,options:ye}=le;if(I.current==null)return;const Re=x.get(I.current);if(!Re)return;const qe=J.nativeEvent,Qe=new pe({active:I.current,activeNode:Re,event:qe,options:ye,context:X,onAbort(Ne){if(!x.get(Ne))return;const{onDragAbort:Je}=N.current,it={id:Ne};Je?.(it),h({type:"onDragAbort",event:it})},onPending(Ne,lt,Je,it){if(!x.get(Ne))return;const{onDragPending:V}=N.current,te={id:Ne,constraint:lt,initialCoordinates:Je,offset:it};V?.(te),h({type:"onDragPending",event:te})},onStart(Ne){const lt=I.current;if(lt==null)return;const Je=x.get(lt);if(!Je)return;const{onDragStart:it}=N.current,xt={activatorEvent:qe,active:{id:lt,data:Je.data,rect:j}};jt.unstable_batchedUpdates(()=>{it?.(xt),y(yt.Initializing),d({type:ze.DragStart,initialCoordinates:Ne,active:lt}),h({type:"onDragStart",event:xt}),H(mt.current),D(qe)})},onMove(Ne){d({type:ze.DragMove,coordinates:Ne})},onEnd:at(ze.DragEnd),onCancel:at(ze.DragCancel)});mt.current=Qe;function at(Ne){return async function(){const{active:Je,collisions:it,over:xt,scrollAdjustedTranslate:V}=X.current;let te=null;if(Je&&V){const{cancelDrop:Ee}=N.current;te={activatorEvent:qe,active:Je,collisions:it,delta:V,over:xt},Ne===ze.DragEnd&&typeof Ee=="function"&&await Promise.resolve(Ee(te))&&(Ne=ze.DragCancel)}I.current=null,jt.unstable_batchedUpdates(()=>{d({type:Ne}),y(yt.Uninitialized),ae(null),H(null),D(null),mt.current=null;const Ee=Ne===ze.DragEnd?"onDragEnd":"onDragCancel";if(te){const Ye=N.current[Ee];Ye?.(te),h({type:Ee,event:te})}})}}},[x]),Tt=k.useCallback((J,le)=>(pe,ye)=>{const Re=pe.nativeEvent,qe=x.get(ye);if(I.current!==null||!qe||Re.dndKit||Re.defaultPrevented)return;const Qe={active:qe};J(pe,le.options,Qe)===!0&&(Re.dndKit={capturedBy:le.sensor},I.current=ye,Dt(pe,le))},[x,Dt]),pt=ec(f,Tt);lc(f),gt(()=>{W&&_===yt.Initializing&&y(yt.Initialized)},[W,_]),k.useEffect(()=>{const{onDragMove:J}=N.current,{active:le,activatorEvent:pe,collisions:ye,over:Re}=X.current;if(!le||!pe)return;const qe={active:le,activatorEvent:pe,collisions:ye,delta:{x:Y.x,y:Y.y},over:Re};jt.unstable_batchedUpdates(()=>{J?.(qe),h({type:"onDragMove",event:qe})})},[Y.x,Y.y]),k.useEffect(()=>{const{active:J,activatorEvent:le,collisions:pe,droppableContainers:ye,scrollAdjustedTranslate:Re}=X.current;if(!J||I.current==null||!le||!Re)return;const{onDragOver:qe}=N.current,Qe=ye.get(re),at=Qe&&Qe.rect.current?{id:Qe.id,rect:Qe.rect.current,data:Qe.data,disabled:Qe.disabled}:null,Ne={active:J,activatorEvent:le,collisions:pe,delta:{x:Re.x,y:Re.y},over:at};jt.unstable_batchedUpdates(()=>{ae(at),qe?.(Ne),h({type:"onDragOver",event:Ne})})},[re]),gt(()=>{X.current={activatorEvent:z,active:M,activeNode:ne,collisionRect:se,collisions:fe,droppableRects:K,draggableNodes:x,draggingNode:xe,draggingNodeRect:_e,droppableContainers:T,over:de,scrollableAncestors:Le,scrollAdjustedTranslate:Y},j.current={initial:_e,translated:se}},[M,ne,fe,se,x,xe,_e,K,T,de,Le,Y]),Gl({...F,delta:R,draggingRect:se,pointerCoordinates:Te,scrollableAncestors:Le,scrollableAncestorRects:Xe});const bt=k.useMemo(()=>({active:M,activeNode:ne,activeNodeRect:W,activatorEvent:z,collisions:fe,containerNodeRect:Z,dragOverlay:me,draggableNodes:x,droppableContainers:T,droppableRects:K,over:de,measureDroppableContainers:Q,scrollableAncestors:Le,scrollableAncestorRects:Xe,measuringConfiguration:$,measuringScheduled:G,windowRect:Oe}),[M,ne,W,z,fe,Z,me,x,T,K,de,Q,Le,Xe,$,G,Oe]),$t=k.useMemo(()=>({activatorEvent:z,activators:pt,active:M,activeNodeRect:W,ariaDescribedById:{draggable:P},dispatch:d,draggableNodes:x,over:de,measureDroppableContainers:Q}),[z,pt,M,W,d,P,x,de,Q]);return ee.createElement(bn.Provider,{value:u},ee.createElement(ls.Provider,{value:$t},ee.createElement(Nn.Provider,{value:bt},ee.createElement(Ws.Provider,{value:rt},c)),ee.createElement(gc,{disabled:i?.restoreFocus===!1})),ee.createElement(Sl,{...i,hiddenTextDescribedById:P}));function q(){const J=B?.autoScrollEnabled===!1,le=typeof r=="object"?r.enabled===!1:r===!1,pe=w&&!J&&!le;return typeof r=="object"?{...r,enabled:pe}:{enabled:pe}}}),Sc=k.createContext(null),fi="button",yc="Draggable";function Cc(e){let{id:t,data:s,disabled:a=!1,attributes:m}=e;const v=Hs(yc),{activators:C,activatorEvent:i,active:r,activeNodeRect:c,ariaDescribedById:f,draggableNodes:o,over:p}=k.useContext(ls),{role:b=fi,roleDescription:S="draggable",tabIndex:g=0}=m??{},n=r?.id===t,d=k.useContext(n?Ws:Sc),[h,u]=ys(),[_,y]=ys(),w=cc(C,t),E=ts(s);gt(()=>(o.set(t,{id:t,key:v,node:h,activatorNode:_,data:E}),()=>{const R=o.get(t);R&&R.key===v&&o.delete(t)}),[o,t]);const x=k.useMemo(()=>({role:b,tabIndex:g,"aria-disabled":a,"aria-pressed":n&&b===fi?!0:void 0,"aria-roledescription":S,"aria-describedby":f.draggable}),[a,b,g,n,S,f.draggable]);return{active:r,activatorEvent:i,activeNodeRect:c,attributes:x,isDragging:n,listeners:a?void 0:w,node:h,over:p,setNodeRef:u,setActivatorNodeRef:y,transform:d}}function wc(){return k.useContext(Nn)}const Ec="Droppable",kc={timeout:25};function Rc(e){let{data:t,disabled:s=!1,id:a,resizeObserverConfig:m}=e;const v=Hs(Ec),{active:C,dispatch:i,over:r,measureDroppableContainers:c}=k.useContext(ls),f=k.useRef({disabled:s}),o=k.useRef(!1),p=k.useRef(null),b=k.useRef(null),{disabled:S,updateMeasurementsFor:g,timeout:n}={...kc,...m},d=ts(g??a),h=k.useCallback(()=>{if(!o.current){o.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{c(Array.isArray(d.current)?d.current:[d.current]),b.current=null},n)},[n]),u=zs({callback:h,disabled:S||!C}),_=k.useCallback((x,R)=>{u&&(R&&(u.unobserve(R),o.current=!1),x&&u.observe(x))},[u]),[y,w]=ys(_),E=ts(t);return k.useEffect(()=>{!u||!y.current||(u.disconnect(),o.current=!1,u.observe(y.current))},[y,u]),k.useEffect(()=>(i({type:ze.RegisterDroppable,element:{id:a,key:v,disabled:s,node:y,rect:p,data:E}}),()=>i({type:ze.UnregisterDroppable,key:v,id:a})),[a]),k.useEffect(()=>{s!==f.current.disabled&&(i({type:ze.SetDroppableDisabled,id:a,key:v,disabled:s}),f.current.disabled=s)},[a,v,s,i]),{active:C,rect:p,isOver:r?.id===a,node:y,over:r,setNodeRef:w}}function Dc(e){let{animation:t,children:s}=e;const[a,m]=k.useState(null),[v,C]=k.useState(null),i=Cs(s);return!s&&!a&&i&&m(i),gt(()=>{if(!v)return;const r=a?.key,c=a?.props.id;if(r==null||c==null){m(null);return}Promise.resolve(t(c,v)).then(()=>{m(null)})},[t,a,v]),ee.createElement(ee.Fragment,null,s,a?k.cloneElement(a,{ref:C}):null)}const Tc={x:0,y:0,scaleX:1,scaleY:1};function Lc(e){let{children:t}=e;return ee.createElement(ls.Provider,{value:Mn},ee.createElement(Ws.Provider,{value:Tc},t))}const jc={position:"fixed",touchAction:"none"},Ac=e=>Mr(e)?"transform 250ms ease":void 0,Mc=k.forwardRef((e,t)=>{let{as:s,activatorEvent:a,adjustScale:m,children:v,className:C,rect:i,style:r,transform:c,transition:f=Ac}=e;if(!i)return null;const o=m?c:{...c,scaleX:1,scaleY:1},p={...jc,width:i.width,height:i.height,top:i.top,left:i.left,transform:ss.Transform.toString(o),transformOrigin:m&&a?wl(a,i):void 0,transition:typeof f=="function"?f(a):f,...r};return ee.createElement(s,{className:C,style:p,ref:t},v)}),Nc=e=>t=>{let{active:s,dragOverlay:a}=t;const m={},{styles:v,className:C}=e;if(v!=null&&v.active)for(const[i,r]of Object.entries(v.active))r!==void 0&&(m[i]=s.node.style.getPropertyValue(i),s.node.style.setProperty(i,r));if(v!=null&&v.dragOverlay)for(const[i,r]of Object.entries(v.dragOverlay))r!==void 0&&a.node.style.setProperty(i,r);return C!=null&&C.active&&s.node.classList.add(C.active),C!=null&&C.dragOverlay&&a.node.classList.add(C.dragOverlay),function(){for(const[r,c]of Object.entries(m))s.node.style.setProperty(r,c);C!=null&&C.active&&s.node.classList.remove(C.active)}},Pc=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:ss.Transform.toString(t)},{transform:ss.Transform.toString(s)}]},Oc={duration:250,easing:"ease",keyframes:Pc,sideEffects:Nc({styles:{active:{opacity:"0"}}})};function Bc(e){let{config:t,draggableNodes:s,droppableContainers:a,measuringConfiguration:m}=e;return Fs((v,C)=>{if(t===null)return;const i=s.get(v);if(!i)return;const r=i.node.current;if(!r)return;const c=An(C);if(!c)return;const{transform:f}=Ve(C).getComputedStyle(C),o=Sn(f);if(!o)return;const p=typeof t=="function"?t:Ic(t);return Dn(r,m.draggable.measure),p({active:{id:v,data:i.data,node:r,rect:m.draggable.measure(r)},draggableNodes:s,dragOverlay:{node:C,rect:m.dragOverlay.measure(c)},droppableContainers:a,measuringConfiguration:m,transform:o})})}function Ic(e){const{duration:t,easing:s,sideEffects:a,keyframes:m}={...Oc,...e};return v=>{let{active:C,dragOverlay:i,transform:r,...c}=v;if(!t)return;const f={x:i.rect.left-C.rect.left,y:i.rect.top-C.rect.top},o={scaleX:r.scaleX!==1?C.rect.width*r.scaleX/i.rect.width:1,scaleY:r.scaleY!==1?C.rect.height*r.scaleY/i.rect.height:1},p={x:r.x-f.x,y:r.y-f.y,...o},b=m({...c,active:C,dragOverlay:i,transform:{initial:r,final:p}}),[S]=b,g=b[b.length-1];if(JSON.stringify(S)===JSON.stringify(g))return;const n=a?.({active:C,dragOverlay:i,...c}),d=i.node.animate(b,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{d.onfinish=()=>{n?.(),h()}})}}let mi=0;function Fc(e){return k.useMemo(()=>{if(e!=null)return mi++,mi},[e])}const Hc=ee.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:a,style:m,transition:v,modifiers:C,wrapperElement:i="div",className:r,zIndex:c=999}=e;const{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:b,draggableNodes:S,droppableContainers:g,dragOverlay:n,over:d,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:_,windowRect:y}=wc(),w=k.useContext(Ws),E=Fc(o?.id),x=Pn(C,{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:b,draggingNodeRect:n.rect,over:d,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:_,transform:w,windowRect:y}),R=Ir(p),T=Bc({config:a,draggableNodes:S,droppableContainers:g,measuringConfiguration:h}),A=R?n.setRef:void 0;return ee.createElement(Lc,null,ee.createElement(Dc,{animation:T},o&&E?ee.createElement(Mc,{key:E,id:o.id,ref:A,as:i,activatorEvent:f,adjustScale:t,className:r,transition:v,rect:R,style:{zIndex:c,...m},transform:x},s):null))}),ce={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},zc=[{status:ce.Review,label:"Review",icon:wr,color:"text-amber-600"},{status:ce.Running,label:"Running",icon:Er,color:"text-blue-600"},{status:ce.Pending,label:"Pending",icon:kr,color:"text-neutral-600"},{status:ce.Done,label:"Done",icon:Rr,color:"text-emerald-600"},{status:ce.Cancelled,label:"Cancelled",icon:Dr,color:"text-neutral-500"}];function Wc({task:e,status:t,isSelected:s,isAgentActive:a,project:m,onSelectTask:v,onTaskStatusChange:C,onDeleteTask:i}){const{t:r}=ue(),{attributes:c,listeners:f,setNodeRef:o,isDragging:p}=Cc({id:e.id,data:{task:e,fromStatus:t}}),[b,S]=k.useState(null),g=k.useRef(null),n=k.useCallback(d=>{!C&&!i||(d.preventDefault(),S({x:d.clientX,y:d.clientY}))},[C,i]);return k.useEffect(()=>{if(!b)return;const d=h=>{g.current&&!g.current.contains(h.target)&&S(null)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[b]),l.jsxs(l.Fragment,{children:[l.jsxs("button",{ref:o,onClick:()=>v(e.id),onContextMenu:n,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
7
|
-
${p?"opacity-30":""}
|
|
8
|
-
${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...f,...c,children:[l.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ce.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ce.Review&&l.jsx(wr,{className:s?"text-amber-600":"text-neutral-500"}),t===ce.Running&&l.jsx(Er,{className:"animate-pulse"}),t===ce.Pending&&l.jsx(kr,{}),t===ce.Done&&l.jsx(Rr,{className:"text-neutral-400"}),t===ce.Cancelled&&l.jsx(Dr,{className:"text-neutral-400"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"mb-0.5",children:[l.jsx("span",{className:`font-medium mr-1 ${m?.color||"text-neutral-500"}`,children:m?.name}),l.jsx("span",{className:"text-neutral-400",children:"/"}),l.jsx("span",{className:`ml-1 ${s?"text-neutral-900":"text-neutral-700"}`,children:e.title}),a&&l.jsxs("span",{className:"relative inline-flex h-2 w-2 ml-1.5 align-middle",children:[l.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),l.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),l.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${s?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),b&&l.jsxs("div",{ref:g,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:b.x,top:b.y},children:[C&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:r("Move to")}),zc.filter(d=>d.status!==t).map(d=>{const h=d.icon;return l.jsxs("button",{onClick:()=>{C(e.id,d.status),S(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[l.jsx(h,{className:`w-3.5 h-3.5 ${d.color}`}),l.jsx("span",{className:"text-neutral-700",children:r(d.label)})]},d.status)})]}),i&&l.jsxs(l.Fragment,{children:[C&&l.jsx("div",{className:"my-1 border-t border-neutral-100"}),l.jsxs("button",{onClick:()=>{i(e.id),S(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:[l.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:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),l.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),l.jsx("span",{children:r("Delete Task")})]})]})]})]})}const $c=k.memo(function({title:t,tasks:s,status:a,defaultOpen:m,selectedTaskId:v,onSelectTask:C,projects:i,activeTaskIds:r,isDragging:c,dragFromStatus:f,onTaskStatusChange:o,onDeleteTask:p}){const{t:b}=ue(),[S,g]=k.useState(m),n=s.length===0,d=c&&f===a,h=c&&f!==a,{setNodeRef:u,isOver:_}=Rc({id:`group-${a}`,data:{status:a}}),y=a===ce.Review,w=b(t),E=c?d&&(S||!0):S;return l.jsxs("div",{className:"mb-2",children:[l.jsxs("button",{onClick:()=>!c&&g(x=>!x),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:[l.jsx("span",{className:"mr-2 text-neutral-400",children:E?l.jsx(_t,{size:14}):l.jsx(Nt,{size:14})}),l.jsx("span",{className:"flex-1 text-left",children:w}),y&&!n?l.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:s.length}):l.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",s.length,")"]})]}),h&&l.jsx("div",{ref:u,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
-
${_?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:l.jsx("span",{className:"text-xs font-medium",children:_?b("Drop into {title}",{title:w}):b("Drop here")})}),E&&!h&&l.jsx("div",{ref:d?void 0:u,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
|
|
10
|
-
${_&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
|
|
11
|
-
${n&&c?"border border-dashed border-neutral-300":""}`,children:n?l.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:b("No tasks")}):s.map(x=>{const R=i.find(j=>j.id===x.projectId),T=v===x.id,A=r?.has(x.id)??!1;return l.jsx(Wc,{task:x,status:a,isSelected:T,isAgentActive:A,project:R,onSelectTask:C,onTaskStatusChange:o,onDeleteTask:p},x.id)})})]})});function Uc(e){const t={[ce.Review]:[],[ce.Running]:[],[ce.Pending]:[],[ce.Done]:[],[ce.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const qc=[{status:ce.Review,title:"Review",defaultOpen:!0},{status:ce.Running,title:"Running",defaultOpen:!0},{status:ce.Pending,title:"Pending",defaultOpen:!1},{status:ce.Done,title:"Done",defaultOpen:!1},{status:ce.Cancelled,title:"Cancelled",defaultOpen:!1}];function pi({tasks:e=[],projects:t=[],selectedTaskId:s,onSelectTask:a,filterProjectId:m,setFilterProjectId:v,width:C=320,onCreateProject:i,onCreateTask:r,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:o}){const{t:p}=ue(),[b,S]=k.useState(!1),[g,n]=k.useState(null),[d,h]=k.useState(null),u=Cl(yl(Br,{activationConstraint:{distance:8}})),_=k.useCallback(T=>{const A=T.active.data.current?.task,j=T.active.data.current?.fromStatus;A&&n(A),j&&h(j)},[]),y=k.useCallback(T=>{n(null),h(null);const{active:A,over:j}=T;if(!j)return;const M=A.data.current?.task,I=A.data.current?.fromStatus,B=j.data.current?.status;!M||!I||!B||I!==B&&f?.(M.id,B)},[f]),w=m?e.filter(T=>T.projectId===m):e,E=m?t.find(T=>T.id===m)??null:null,x=Uc(w),R=C==="100%";return l.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${R?"":"border-r border-neutral-200"}`,style:{width:C},children:[l.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[l.jsxs("div",{className:"relative flex-1 mr-2",children:[l.jsxs("button",{onClick:()=>S(T=>!T),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&&E?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${E.color.replace("text-","bg-")}`}),l.jsx("span",{className:"truncate",children:E.name})]}):l.jsxs(l.Fragment,{children:[l.jsx(si,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),l.jsx("span",{children:p("All Projects")})]}),l.jsx(_t,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${b?"rotate-180":""}`})]}),b?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>S(!1)}),l.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:[l.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:p("Select View")}),l.jsxs("button",{onClick:()=>{v(null),S(!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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:l.jsx(si,{size:12})}),l.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:p("All Projects")})]}),m===null?l.jsx(Zt,{size:14,className:"text-neutral-900"}):null]}),l.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),t.map(T=>{const A=m===T.id,j=T.color.replace("text-","bg-");return l.jsxs("button",{onClick:()=>{v(T.id),S(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${j}`}),l.jsx("span",{className:A?"text-neutral-900 font-medium":"text-neutral-600",children:T.name})]}),A?l.jsx(Zt,{size:14,className:"text-neutral-900"}):null]},T.id)}),l.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),l.jsxs("button",{onClick:()=>{S(!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:[l.jsx(fr,{size:14}),l.jsx("span",{children:p("Create New Project...")})]})]})]}):null]}),l.jsx("button",{onClick:r,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0",title:p("New Task"),children:l.jsx(fr,{size:18})})]}),l.jsxs(xc,{sensors:u,onDragStart:_,onDragEnd:y,children:[l.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:qc.map(({status:T,title:A,defaultOpen:j})=>l.jsx($c,{title:A,tasks:x[T],status:T,defaultOpen:j,selectedTaskId:s,onSelectTask:a,projects:t,activeTaskIds:c,isDragging:g!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:o},T))}),l.jsx(Hc,{dropAnimation:null,children:g?l.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:l.jsx("span",{className:"text-neutral-700 font-medium",children:g.title})}):null})]}),w.length>0?l.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[l.jsx("span",{children:p("{count} tasks",{count:w.length})}),m?l.jsx("button",{onClick:()=>v(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:p("Clear filter")}):null]}):l.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:l.jsx("span",{children:p("{count} tasks",{count:0})})})]})}const Kc={damping:.7,stiffness:.05,mass:1.25},Xc=70,Yc=1e3/60,Vc=350;let $s=!1;globalThis.document?.addEventListener("mousedown",()=>{$s=!0});globalThis.document?.addEventListener("mouseup",()=>{$s=!1});globalThis.document?.addEventListener("click",()=>{$s=!1});const On=(e={})=>{const[t,s]=k.useState(!1),[a,m]=k.useState(e.initial!==!1),[v,C]=k.useState(!1),i=k.useRef(null);i.current=e;const r=k.useCallback(()=>{if(!$s)return!1;const h=window.getSelection();if(!h||!h.rangeCount)return!1;const u=h.getRangeAt(0);return u.commonAncestorContainer.contains(n.current)||n.current?.contains(u.commonAncestorContainer)},[]),c=k.useCallback(h=>{o.isAtBottom=h,m(h)},[]),f=k.useCallback(h=>{o.escapedFromLock=h,s(h)},[]),o=k.useMemo(()=>{let h;return{escapedFromLock:t,isAtBottom:a,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return n.current?.scrollTop??0},set scrollTop(u){n.current&&(n.current.scrollTop=u,o.ignoreScrollToTop=n.current.scrollTop)},get targetScrollTop(){return!n.current||!d.current?0:n.current.scrollHeight-1-n.current.clientHeight},get calculatedTargetScrollTop(){if(!n.current||!d.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(h?.targetScrollTop===u)return h.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:n.current,contentElement:d.current}),u),0);return h={targetScrollTop:u,calculatedScrollTop:_},requestAnimationFrame(()=>{h=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Xc}}},[]),p=k.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||c(!0);const u=Date.now()+(Number(h.wait)||0),_=tr(i.current,h.animation),{ignoreEscapes:y=!1}=h;let w,E=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const x=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:T}=o,A=performance.now(),j=(A-(o.lastTick??A))/Yc;if(o.animation||(o.animation={behavior:_,promise:R,ignoreEscapes:y}),o.animation.behavior===_&&(o.lastTick=A),r()||u>Date.now())return x();if(T<Math.min(E,o.calculatedTargetScrollTop)){if(o.animation?.behavior===_){if(_==="instant")return o.scrollTop=o.calculatedTargetScrollTop,x();o.velocity=(_.damping*o.velocity+_.stiffness*o.scrollDifference)/_.mass,o.accumulated+=o.velocity*j,o.scrollTop+=o.accumulated,o.scrollTop!==T&&(o.accumulated=0)}return x()}return w>Date.now()?(E=o.calculatedTargetScrollTop,x()):(o.animation=void 0,o.scrollTop<o.calculatedTargetScrollTop?p({animation:tr(i.current,i.current.resize),ignoreEscapes:y,duration:Math.max(0,w-Date.now())||void 0}):o.isAtBottom)});return R.then(T=>(requestAnimationFrame(()=>{o.animation||(o.lastTick=void 0,o.velocity=0)}),T))};return h.wait!==!0&&(o.animation=void 0),o.animation?.behavior===_?o.animation.promise:x()},[c,r,o]),b=k.useCallback(()=>{f(!0),c(!1)},[f,c]),S=k.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:_}=o;let{lastScrollTop:y=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,_&&_>u&&(y=_),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===_)return;if(r()){f(!0),c(!1);return}const w=u>y,E=u<y;if(o.animation?.ignoreEscapes){o.scrollTop=y;return}E&&(f(!0),c(!1)),w&&f(!1),!o.escapedFromLock&&o.isNearBottom&&c(!0)},1)},[f,c,r,o]),g=k.useCallback(({target:h,deltaY:u})=>{let _=h;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===n.current&&u<0&&n.current.scrollHeight>n.current.clientHeight&&!o.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,o]),n=vi(h=>{n.current?.removeEventListener("scroll",S),n.current?.removeEventListener("wheel",g),h?.addEventListener("scroll",S,{passive:!0}),h?.addEventListener("wheel",g,{passive:!0})},[]),d=vi(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([_])=>{const{height:y}=_.contentRect,w=y-(u??y);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const E=tr(i.current,u?i.current.resize:i.current.initial);p({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:Vc})}else o.isNearBottom&&(f(!1),c(!0));u=y,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:d,scrollRef:n,scrollToBottom:p,stopScroll:b,isAtBottom:a||v,isNearBottom:v,escapedFromLock:t,state:o}};function vi(e,t){const s=k.useCallback(a=>(s.current=a,e(a)),t);return s}const er=new Map;function tr(...e){const t={...Kc};let s=!1;for(const m of e){if(m==="instant"){s=!0;continue}typeof m=="object"&&(s=!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 er.has(a)||er.set(a,Object.freeze(t)),s?"instant":er.get(a)}function Gc({content:e,children:t,className:s=""}){return l.jsxs("div",{className:`group/tooltip relative ${s}`,children:[t,l.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-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-50 shadow-lg",children:[e,l.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-neutral-900"})]})]})}function fs(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Qc(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Bn({usage:e}){const{t}=ue();if(!e)return null;const s=e.modelContextWindow,a=s?e.totalTokens/s:0,m=s?Math.min(Math.round(a*100),100):null,v=s?Qc(a):"text-neutral-400",C=s?l.jsx("span",{children:t("上下文: {used} / {max} tokens",{used:fs(e.totalTokens),max:fs(s)})}):l.jsx("span",{children:t("已使用: {used} tokens",{used:fs(e.totalTokens)})});return l.jsx(Gc,{content:C,children:l.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:[l.jsx(Ta,{size:14,className:v}),l.jsxs("span",{className:`tabular-nums ${v}`,children:[fs(e.totalTokens),m!==null&&l.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",m,"%"]})]})]})})}var sr={exports:{}},gi;function Zc(){return gi||(gi=1,(function(e,t){(function(s,a){e.exports=a()})(self,(()=>(()=>{var s={4567:function(C,i,r){var c=this&&this.__decorate||function(u,_,y,w){var E,x=arguments.length,R=x<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,y):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,y,w);else for(var T=u.length-1;T>=0;T--)(E=u[T])&&(R=(x<3?E(R):x>3?E(_,y,R):E(_,y))||R);return x>3&&R&&Object.defineProperty(_,y,R),R},f=this&&this.__param||function(u,_){return function(y,w){_(y,w,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const o=r(9042),p=r(6114),b=r(9924),S=r(844),g=r(5596),n=r(4725),d=r(3656);let h=i.AccessibilityManager=class extends S.Disposable{constructor(u,_){super(),this._terminal=u,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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(`
|
|
12
|
-
`)))),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 g.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,d.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let _=0;_<u;_++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
|
|
13
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=o.tooMuchOutput)),p.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,p.isMac&&this._liveRegion.remove()}_handleKey(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,_){this._liveRegionDebouncer.refresh(u,_,this._terminal.rows)}_renderRows(u,_){const y=this._terminal.buffer,w=y.lines.length.toString();for(let E=u;E<=_;E++){const x=y.translateBufferLineToString(y.ydisp+E,!0),R=(y.ydisp+E+1).toString(),T=this._rowElements[E];T&&(x.length===0?T.innerText=" ":T.textContent=x,T.setAttribute("aria-posinset",R),T.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,_){const y=u.target,w=this._rowElements[_===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==w)return;let E,x;if(_===0?(E=y,x=this._rowElements.pop(),this._rowContainer.removeChild(x)):(E=this._rowElements.shift(),x=y,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),x.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const R=this._createAccessibilityTreeNode();this._rowElements.unshift(R),this._rowContainer.insertAdjacentElement("afterbegin",R)}else{const R=this._createAccessibilityTreeNode();this._rowElements.push(R),this._rowContainer.appendChild(R)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>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=h=c([f(1,n.IRenderService)],h)},3614:(C,i)=>{function r(p){return p.replace(/\r?\n/g,"\r")}function c(p,b){return b?"\x1B[200~"+p+"\x1B[201~":p}function f(p,b,S,g){p=c(p=r(p),S.decPrivateModes.bracketedPasteMode&&g.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(p,!0),b.value=""}function o(p,b,S){const g=S.getBoundingClientRect(),n=p.clientX-g.left-10,d=p.clientY-g.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${n}px`,b.style.top=`${d}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=r,i.bracketTextForPaste=c,i.copyHandler=function(p,b){p.clipboardData&&p.clipboardData.setData("text/plain",b.selectionText),p.preventDefault()},i.handlePasteEvent=function(p,b,S,g){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),b,S,g)},i.paste=f,i.moveTextAreaUnderMouseCursor=o,i.rightClickHandler=function(p,b,S,g,n){o(p,b,S),n&&g.rightClickSelect(p),b.value=g.selectionText,b.select()}},7239:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=r(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,o,p){this._css.set(f,o,p)}getCss(f,o){return this._css.get(f,o)}setColor(f,o,p){this._color.set(f,o,p)}getColor(f,o){return this._color.get(f,o)}clear(){this._color.clear(),this._css.clear()}}},3656:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(r,c,f,o){r.addEventListener(c,f,o);let p=!1;return{dispose:()=>{p||(p=!0,r.removeEventListener(c,f,o))}}}},6465:function(C,i,r){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const o=r(3656),p=r(8460),b=r(844),S=r(2585);let g=i.Linkifier2=class extends b.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.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(n){return this._linkProviders.push(n),{dispose:()=>{const d=this._linkProviders.indexOf(n);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(n,d,h){this._element=n,this._mouseService=d,this._renderService=h,this.register((0,o.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,o.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const h=n.composedPath();for(let u=0;u<h.length;u++){const _=h[u];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,d){var h,u;this._activeProviderReplies&&d||((h=this._activeProviderReplies)===null||h===void 0||h.forEach((y=>{y?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let _=!1;for(const[y,w]of this._linkProviders.entries())d?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(y)&&(_=this._checkLinkProviderResult(y,n,_)):w.provideLinks(n.y,(E=>{var x,R;if(this._isMouseOut)return;const T=E?.map((A=>({link:A})));(x=this._activeProviderReplies)===null||x===void 0||x.set(y,T),_=this._checkLinkProviderResult(y,n,_),((R=this._activeProviderReplies)===null||R===void 0?void 0:R.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,d){const h=new Set;for(let u=0;u<d.size;u++){const _=d.get(u);if(_)for(let y=0;y<_.length;y++){const w=_[y],E=w.link.range.start.y<n?0:w.link.range.start.x,x=w.link.range.end.y>n?this._bufferService.cols:w.link.range.end.x;for(let R=E;R<=x;R++){if(h.has(R)){_.splice(y--,1);break}h.add(R)}}}}_checkLinkProviderResult(n,d,h){var u;if(!this._activeProviderReplies)return h;const _=this._activeProviderReplies.get(n);let y=!1;for(let w=0;w<n;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(y=!0);if(!y&&_){const w=_.find((E=>this._linkAtPosition(E.link,d)));w&&(h=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviders.length&&!h)for(let w=0;w<this._activeProviderReplies.size;w++){const E=(u=this._activeProviderReplies.get(w))===null||u===void 0?void 0:u.find((x=>this._linkAtPosition(x.link,d)));if(E){h=!0,this._handleNewLink(E);break}}return h}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!d||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,b.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(n.link,d)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:h=>{var u,_;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==h&&(this._currentLink.state.decorations.pointerCursor=h,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",h)))}},underline:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.underline},set:h=>{var u,_,y;!((u=this._currentLink)===null||u===void 0)&&u.state&&((y=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||y===void 0?void 0:y.decorations.underline)!==h&&(this._currentLink.state.decorations.underline=h,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,h))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((h=>{if(!this._currentLink)return;const u=h.start===0?0:h.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+h.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(u,_),this._lastMouseEvent&&this._element)){const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._askForLink(y,!1)}}))))}_linkHover(n,d,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(h,d.text)}_fireUnderlineEvent(n,d){const h=n.range,u=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(h.start.x-1,h.start.y-u-1,h.end.x,h.end.y-u-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(n,d,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(h,d.text)}_linkAtPosition(n,d){const h=n.range.start.y*this._bufferService.cols+n.range.start.x,u=n.range.end.y*this._bufferService.cols+n.range.end.x,_=d.y*this._bufferService.cols+d.x;return h<=_&&_<=u}_positionFromMouseEvent(n,d,h){const u=h.getCoords(n,d,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,d,h,u,_){return{x1:n,y1:d,x2:h,y2:u,cols:this._bufferService.cols,fg:_}}};i.Linkifier2=g=c([f(0,S.IBufferService)],g)},9042:(C,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(C,i,r){var c=this&&this.__decorate||function(g,n,d,h){var u,_=arguments.length,y=_<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(g,n,d,h);else for(var w=g.length-1;w>=0;w--)(u=g[w])&&(y=(_<3?u(y):_>3?u(n,d,y):u(n,d))||y);return _>3&&y&&Object.defineProperty(n,d,y),y},f=this&&this.__param||function(g,n){return function(d,h){n(d,h,g)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const o=r(511),p=r(2585);let b=i.OscLinkProvider=class{constructor(g,n,d){this._bufferService=g,this._optionsService=n,this._oscLinkService=d}provideLinks(g,n){var d;const h=this._bufferService.buffer.lines.get(g-1);if(!h)return void n(void 0);const u=[],_=this._optionsService.rawOptions.linkHandler,y=new o.CellData,w=h.getTrimmedLength();let E=-1,x=-1,R=!1;for(let T=0;T<w;T++)if(x!==-1||h.hasContent(T)){if(h.loadCell(T,y),y.hasExtendedAttrs()&&y.extended.urlId){if(x===-1){x=T,E=y.extended.urlId;continue}R=y.extended.urlId!==E}else x!==-1&&(R=!0);if(R||x!==-1&&T===w-1){const A=(d=this._oscLinkService.getLinkData(E))===null||d===void 0?void 0:d.uri;if(A){const j={start:{x:x+1,y:g},end:{x:T+(R||T!==w-1?0:1),y:g}};let M=!1;if(!_?.allowNonHttpProtocols)try{const I=new URL(A);["http:","https:"].includes(I.protocol)||(M=!0)}catch{M=!0}M||u.push({text:A,range:j,activate:(I,B)=>_?_.activate(I,B,j):S(0,B),hover:(I,B)=>{var H;return(H=_?.hover)===null||H===void 0?void 0:H.call(_,I,B,j)},leave:(I,B)=>{var H;return(H=_?.leave)===null||H===void 0?void 0:H.call(_,I,B,j)}})}R=!1,y.hasExtendedAttrs()&&y.extended.urlId?(x=T,E=y.extended.urlId):(x=-1,E=-1)}}n(u)}};function S(g,n){if(confirm(`Do you want to navigate to ${n}?
|
|
14
|
-
|
|
15
|
-
WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=b=c([f(0,p.IBufferService),f(1,p.IOptionsService),f(2,p.IOscLinkService)],b)},6193:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(r,c){this._parentWindow=r,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(r){return this._refreshCallbacks.push(r),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(r,c,f){this._rowCount=f,r=r!==void 0?r:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,r):r,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 r=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(r,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const r of this._refreshCallbacks)r(0);this._refreshCallbacks=[]}}},5596:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=r(844);class f extends c.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,c.toDisposable)((()=>{this.clearListener()})))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.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=f},3236:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=r(3614),f=r(3656),o=r(6465),p=r(9042),b=r(3730),S=r(1680),g=r(3107),n=r(5744),d=r(2950),h=r(1296),u=r(428),_=r(4269),y=r(5114),w=r(8934),E=r(3230),x=r(9312),R=r(4725),T=r(6731),A=r(8055),j=r(8969),M=r(8460),I=r(844),B=r(6114),H=r(8437),z=r(2584),D=r(7399),N=r(5941),P=r(9074),O=r(2585),$=r(5435),K=r(4567),Q=typeof window<"u"?window.document:null;class G extends j.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(L={}){super(L),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(o.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,U)=>this.refresh(F,U)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,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((F=>this._afterResize(F.cols,F.rows)))),this.register((0,I.toDisposable)((()=>{var F,U;this._customKeyEventHandler=void 0,(U=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||U===void 0||U.removeChild(this.element)})))}_handleColorEvent(L){if(this._themeService)for(const F of L){let U,W="";switch(F.index){case 256:U="foreground",W="10";break;case 257:U="background",W="11";break;case 258:U="cursor",W="12";break;default:U="ansi",W="4;"+F.index}switch(F.type){case 0:const Z=A.color.toColorRGB(U==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[U]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,N.toRgbString)(Z)}${z.C1_ESCAPED.ST}`);break;case 1:if(U==="ansi")this._themeService.modifyColors((X=>X.ansi[F.index]=A.rgba.toColor(...F.color)));else{const X=U;this._themeService.modifyColors((oe=>oe[X]=A.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(L){L?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(L){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(L),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var L;return(L=this.textarea)===null||L===void 0?void 0:L.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 L=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(L);if(!F)return;const U=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,Z=F.getWidth(U),X=this._renderService.dimensions.css.cell.width*Z,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,me=U*this._renderService.dimensions.css.cell.width;this.textarea.style.left=me+"px",this.textarea.style.top=oe+"px",this.textarea.style.width=X+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,c.copyHandler)(F,this._selectionService)})));const L=F=>(0,c.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",L)),this.register((0,f.addDisposableDomListener)(this.element,"paste",L)),B.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,c.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,c.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,c.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(L=>this._keyUp(L)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(L=>this._keyDown(L)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(L=>this._keyPress(L)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(L=>this._compositionHelper.compositionupdate(L)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(L=>this._inputEvent(L)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(L){var F;if(!L)throw new Error("Terminal requires a parent element.");L.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=L.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),L.appendChild(this.element);const U=Q.createDocumentFragment();this._viewportElement=Q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),U.appendChild(this._viewportElement),this._viewportScrollArea=Q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=Q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=Q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),U.appendChild(this.screenElement),this.textarea=Q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.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,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(R.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,f.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(R.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(T.ThemeService),this._instantiationService.setService(R.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(R.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(R.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=Q.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(U);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(w.MouseService),this._instantiationService.setService(R.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(x.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(R.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,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(g.BufferDecorationRenderer,this.screenElement)),this.register((0,f.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(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(h.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const L=this,F=this.element;function U(X){const oe=L._mouseService.getMouseReportCoords(X,L.screenElement);if(!oe)return!1;let me,xe;switch(X.overrideType||X.type){case"mousemove":xe=32,X.buttons===void 0?(me=3,X.button!==void 0&&(me=X.button<3?X.button:3)):me=1&X.buttons?0:4&X.buttons?1:2&X.buttons?2:3;break;case"mouseup":xe=0,me=X.button<3?X.button:3;break;case"mousedown":xe=1,me=X.button<3?X.button:3;break;case"wheel":if(L.viewport.getLinesScrolled(X)===0)return!1;xe=X.deltaY<0?0:1,me=4;break;default:return!1}return!(xe===void 0||me===void 0||me>4)&&L.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:me,action:xe,ctrl:X.ctrlKey,alt:X.altKey,shift:X.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Z={mouseup:X=>(U(X),X.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(X)),wheel:X=>(U(X),this.cancel(X,!0)),mousedrag:X=>{X.buttons&&U(X)},mousemove:X=>{X.buttons||U(X)}};this.register(this.coreMouseService.onProtocolChange((X=>{X?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(X)),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&X?W.mousemove||(F.addEventListener("mousemove",Z.mousemove),W.mousemove=Z.mousemove):(F.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&X?W.wheel||(F.addEventListener("wheel",Z.wheel,{passive:!1}),W.wheel=Z.wheel):(F.removeEventListener("wheel",W.wheel),W.wheel=null),2&X?W.mouseup||(F.addEventListener("mouseup",Z.mouseup),W.mouseup=Z.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),F.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&X?W.mousedrag||(W.mousedrag=Z.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(F,"mousedown",(X=>{if(X.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(X))return U(X),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(X)}))),this.register((0,f.addDisposableDomListener)(F,"wheel",(X=>{if(!W.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(X);if(oe===0)return;const me=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(X.deltaY<0?"A":"B");let xe="";for(let _e=0;_e<Math.abs(oe);_e++)xe+=me;return this.coreService.triggerDataEvent(xe,!0),this.cancel(X,!0)}return this.viewport.handleWheel(X)?this.cancel(X):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(F,"touchstart",(X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(X),this.cancel(X)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(F,"touchmove",(X=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(X)?void 0:this.cancel(X)}),{passive:!1}))}refresh(L,F){var U;(U=this._renderService)===null||U===void 0||U.refreshRows(L,F)}updateCursorStyle(L){var F;!((F=this._selectionService)===null||F===void 0)&&F.shouldColumnSelect(L)?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(L,F,U=0){var W;U===1?(super.scrollLines(L,F,U),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(L)}paste(L){(0,c.paste)(L,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(L){this._customKeyEventHandler=L}registerLinkProvider(L){return this.linkifier2.registerLinkProvider(L)}registerCharacterJoiner(L){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(L);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(L){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(L)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(L){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+L)}registerDecoration(L){return this._decorationService.registerDecoration(L)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(L,F,U){this._selectionService.setSelection(L,F,U)}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 L;(L=this._selectionService)===null||L===void 0||L.clearSelection()}selectAll(){var L;(L=this._selectionService)===null||L===void 0||L.selectAll()}selectLines(L,F){var U;(U=this._selectionService)===null||U===void 0||U.selectLines(L,F)}_keyDown(L){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&L.altKey;if(!F&&!this._compositionHelper.keydown(L))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||L.key!=="Dead"&&L.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const U=(0,D.evaluateKeyboardEvent)(L,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(L),U.type===3||U.type===2){const W=this.rows-1;return this.scrollLines(U.type===2?-W:W),this.cancel(L,!0)}return U.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,L)||(U.cancel&&this.cancel(L,!0),!U.key||!!(L.key&&!L.ctrlKey&&!L.altKey&&!L.metaKey&&L.key.length===1&&L.key.charCodeAt(0)>=65&&L.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(U.key!==z.C0.ETX&&U.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:U.key,domEvent:L}),this._showCursor(),this.coreService.triggerDataEvent(U.key,!0),!this.optionsService.rawOptions.screenReaderMode||L.altKey||L.ctrlKey?this.cancel(L,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(L,F){const U=L.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||L.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||L.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?U:U&&(!F.keyCode||F.keyCode>47)}_keyUp(L){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(L)||this.focus(),this.updateCursorStyle(L),this._keyPressHandled=!1)}_keyPress(L){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1)return!1;if(this.cancel(L),L.charCode)F=L.charCode;else if(L.which===null||L.which===void 0)F=L.keyCode;else{if(L.which===0||L.charCode===0)return!1;F=L.which}return!(!F||(L.altKey||L.ctrlKey||L.metaKey)&&!this._isThirdLevelShift(this.browser,L)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:L}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(L){if(L.data&&L.inputType==="insertText"&&(!L.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=L.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(L),!0}return!1}resize(L,F){L!==this.cols||F!==this.rows?super.resize(L,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(L,F){var U,W;(U=this._charSizeService)===null||U===void 0||U.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var L;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(L=this.viewport)===null||L===void 0||L.reset(),this.refresh(0,this.rows-1)}}reset(){var L,F;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(L=this._selectionService)===null||L===void 0||L.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var L;(L=this._renderService)===null||L===void 0||L.clearTextureAtlas()}_reportFocus(){var L;!((L=this.element)===null||L===void 0)&&L.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(L){if(this._renderService)switch(L){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),U=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${U};${F}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),Z=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${Z};${W}t`)}}cancel(L,F){if(this.options.cancelEvents||F)return L.preventDefault(),L.stopPropagation(),!1}}i.Terminal=G},9924:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(r,c=1e3){this._renderCallback=r,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(r,c,f){this._rowCount=f,r=r!==void 0?r:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,r):r,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const o=Date.now();if(o-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=o,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=o-this._lastRefreshMs,b=this._debounceThresholdMS-p;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 r=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(r,c)}}},1680:function(C,i,r){var c=this&&this.__decorate||function(d,h,u,_){var y,w=arguments.length,E=w<3?h:_===null?_=Object.getOwnPropertyDescriptor(h,u):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,h,u,_);else for(var x=d.length-1;x>=0;x--)(y=d[x])&&(E=(w<3?y(E):w>3?y(h,u,E):y(h,u))||E);return w>3&&E&&Object.defineProperty(h,u,E),E},f=this&&this.__param||function(d,h){return function(u,_){h(u,_,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const o=r(3656),p=r(4725),b=r(8460),S=r(844),g=r(2585);let n=i.Viewport=class extends S.Disposable{constructor(d,h,u,_,y,w,E,x){super(),this._viewportElement=d,this._scrollArea=h,this._bufferService=u,this._optionsService=_,this._charSizeService=y,this._renderService=w,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,o.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((R=>this._renderDimensions=R))),this._handleThemeChange(x.colors),this.register(x.onChangeColors((R=>this._handleThemeChange(R)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(d){this._viewportElement.style.backgroundColor=d.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(d){if(d)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 h=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==h&&(this._lastRecordedBufferHeight=h,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const d=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==d&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=d),this._refreshAnimationFrame=null}syncScrollArea(d=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(d);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(d)}_handleScroll(d){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 h=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const d=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(d*(this._smoothScrollState.target-this._smoothScrollState.origin)),d<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(d,h){const u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(h<0&&this._viewportElement.scrollTop!==0||h>0&&u<this._lastRecordedBufferHeight)||(d.cancelable&&d.preventDefault(),!1)}handleWheel(d){const h=this._getPixelsScrolled(d);return h!==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+h:this._smoothScrollState.target+=h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=h,this._bubbleScroll(d,h))}scrollLines(d){if(d!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const h=d*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!1})}_getPixelsScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let h=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_LINE?h*=this._currentRowHeight:d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._currentRowHeight*this._bufferService.rows),h}getBufferElements(d,h){var u;let _,y="";const w=[],E=h??this._bufferService.buffer.lines.length,x=this._bufferService.buffer.lines;for(let R=d;R<E;R++){const T=x.get(R);if(!T)continue;const A=(u=x.get(R+1))===null||u===void 0?void 0:u.isWrapped;if(y+=T.translateToString(!A),!A||R===x.length-1){const j=document.createElement("div");j.textContent=y,w.push(j),y.length>0&&(_=j),y=""}}return{bufferElements:w,cursorElement:_}}getLinesScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let h=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(h/=this._currentRowHeight+0,this._wheelPartialScroll+=h,h=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._bufferService.rows),h}_applyScrollModifier(d,h){const u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&h.altKey||u==="ctrl"&&h.ctrlKey||u==="shift"&&h.shiftKey?d*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:d*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(d){this._lastTouchY=d.touches[0].pageY}handleTouchMove(d){const h=this._lastTouchY-d.touches[0].pageY;return this._lastTouchY=d.touches[0].pageY,h!==0&&(this._viewportElement.scrollTop+=h,this._bubbleScroll(d,h))}};i.Viewport=n=c([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,p.ICharSizeService),f(5,p.IRenderService),f(6,p.ICoreBrowserService),f(7,p.IThemeService)],n)},3107:function(C,i,r){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const o=r(3656),p=r(4725),b=r(844),S=r(2585);let g=i.BufferDecorationRenderer=class extends b.Disposable{constructor(n,d,h,u){super(),this._screenElement=n,this._bufferService=d,this._decorationService=h,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,o.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,b.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var d,h;const u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((d=n?.options)===null||d===void 0?void 0:d.layer)==="top"),u.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(n.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 _=(h=n.options.x)!==null&&h!==void 0?h:0;return _&&_>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(n,u),u}_refreshStyle(n){const d=n.marker.line-this._bufferService.buffers.active.ydisp;if(d<0||d>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let h=this._decorationElements.get(n);h||(h=this._createElement(n),n.element=h,this._decorationElements.set(n,h),this._container.appendChild(h),n.onDispose((()=>{this._decorationElements.delete(n),h.remove()}))),h.style.top=d*this._renderService.dimensions.css.cell.height+"px",h.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(h)}}_refreshXPosition(n,d=n.element){var h;if(!d)return;const u=(h=n.options.x)!==null&&h!==void 0?h:0;(n.options.anchor||"left")==="right"?d.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":d.style.left=u?u*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var d;(d=this._decorationElements.get(n))===null||d===void 0||d.remove(),this._decorationElements.delete(n),n.dispose()}};i.BufferDecorationRenderer=g=c([f(1,S.IBufferService),f(2,S.IDecorationService),f(3,p.IRenderService)],g)},5871:(C,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(r){if(r.options.overviewRulerOptions){for(const c of this._zones)if(c.color===r.options.overviewRulerOptions.color&&c.position===r.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,r.marker.line))return;if(this._lineAdjacentToZone(c,r.marker.line,r.options.overviewRulerOptions.position))return void this._addLineToZone(c,r.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=r.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=r.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=r.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=r.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:r.options.overviewRulerOptions.color,position:r.options.overviewRulerOptions.position,startBufferLine:r.marker.line,endBufferLine:r.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(r){this._linePadding=r}_lineIntersectsZone(r,c){return c>=r.startBufferLine&&c<=r.endBufferLine}_lineAdjacentToZone(r,c,f){return c>=r.startBufferLine-this._linePadding[f||"full"]&&c<=r.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(r,c){r.startBufferLine=Math.min(r.startBufferLine,c),r.endBufferLine=Math.max(r.endBufferLine,c)}}},5744:function(C,i,r){var c=this&&this.__decorate||function(_,y,w,E){var x,R=arguments.length,T=R<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,w):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,y,w,E);else for(var A=_.length-1;A>=0;A--)(x=_[A])&&(T=(R<3?x(T):R>3?x(y,w,T):x(y,w))||T);return R>3&&T&&Object.defineProperty(y,w,T),T},f=this&&this.__param||function(_,y){return function(w,E){y(w,E,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const o=r(5871),p=r(3656),b=r(4725),S=r(844),g=r(2585),n={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},h={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(_,y,w,E,x,R,T){var A;super(),this._viewportElement=_,this._screenElement=y,this._bufferService=w,this._decorationService=E,this._renderService=x,this._optionsService=R,this._coreBrowseService=T,this._colorZoneStore=new o.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(),(A=this._viewportElement.parentElement)===null||A===void 0||A.insertBefore(this._canvas,this._viewportElement);const j=this._canvas.getContext("2d");if(!j)throw new Error("Ctx cannot be null");this._ctx=j,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,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),y=Math.ceil(this._canvas.width/3);d.full=this._canvas.width,d.left=_,d.center=y,d.right=_,this._refreshDrawHeightConstants(),h.full=0,h.left=0,h.center=d.left,h.right=d.left+d.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,y=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);n.left=y,n.center=y,n.right=y}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.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 _=this._colorZoneStore.zones;for(const y of _)y.position!=="full"&&this._renderColorZone(y);for(const y of _)y.position==="full"&&this._renderColorZone(y);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(h[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-n[_.position||"full"]/2),d[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[_.position||"full"]))}_queueRefresh(_,y){this._shouldUpdateDimensions=_||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([f(2,g.IBufferService),f(3,g.IDecorationService),f(4,b.IRenderService),f(5,g.IOptionsService),f(6,b.ICoreBrowserService)],u)},2950:function(C,i,r){var c=this&&this.__decorate||function(g,n,d,h){var u,_=arguments.length,y=_<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(g,n,d,h);else for(var w=g.length-1;w>=0;w--)(u=g[w])&&(y=(_<3?u(y):_>3?u(n,d,y):u(n,d))||y);return _>3&&y&&Object.defineProperty(n,d,y),y},f=this&&this.__param||function(g,n){return function(d,h){n(d,h,g)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const o=r(4725),p=r(2585),b=r(2584);let S=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(g,n,d,h,u,_){this._textarea=g,this._compositionView=n,this._bufferService=d,this._optionsService=h,this._coreService=u,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(g){this._compositionView.textContent=g.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(g){if(this._isComposing||this._isSendingComposition){if(g.keyCode===229||g.keyCode===16||g.keyCode===17||g.keyCode===18)return!1;this._finalizeComposition(!1)}return g.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(g){if(this._compositionView.classList.remove("active"),this._isComposing=!1,g){const n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let d;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,d=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),d.length>0&&this._coreService.triggerDataEvent(d,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const g=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,d=n.replace(g,"");this._dataAlreadySent=d,n.length>g.length?this._coreService.triggerDataEvent(d,!0):n.length<g.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):n.length===g.length&&n!==g&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(g){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),d=this._renderService.dimensions.css.cell.height,h=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,u=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"px",this._compositionView.style.top=h+"px",this._compositionView.style.height=d+"px",this._compositionView.style.lineHeight=d+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=h+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}g||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=S=c([f(2,p.IBufferService),f(3,p.IOptionsService),f(4,p.ICoreService),f(5,o.IRenderService)],S)},9806:(C,i)=>{function r(c,f,o){const p=o.getBoundingClientRect(),b=c.getComputedStyle(o),S=parseInt(b.getPropertyValue("padding-left")),g=parseInt(b.getPropertyValue("padding-top"));return[f.clientX-p.left-S,f.clientY-p.top-g]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=r,i.getCoords=function(c,f,o,p,b,S,g,n,d){if(!S)return;const h=r(c,f,o);return h?(h[0]=Math.ceil((h[0]+(d?g/2:0))/g),h[1]=Math.ceil(h[1]/n),h[0]=Math.min(Math.max(h[0],1),p+(d?1:0)),h[1]=Math.min(Math.max(h[1],1),b),h):void 0}},9504:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=r(2584);function f(n,d,h,u){const _=n-o(n,h),y=d-o(d,h),w=Math.abs(_-y)-(function(E,x,R){let T=0;const A=E-o(E,R),j=x-o(x,R);for(let M=0;M<Math.abs(A-j);M++){const I=p(E,x)==="A"?-1:1,B=R.buffer.lines.get(A+I*M);B?.isWrapped&&T++}return T})(n,d,h);return g(w,S(p(n,d),u))}function o(n,d){let h=0,u=d.buffer.lines.get(n),_=u?.isWrapped;for(;_&&n>=0&&n<d.rows;)h++,u=d.buffer.lines.get(--n),_=u?.isWrapped;return h}function p(n,d){return n>d?"A":"B"}function b(n,d,h,u,_,y){let w=n,E=d,x="";for(;w!==h||E!==u;)w+=_?1:-1,_&&w>y.cols-1?(x+=y.buffer.translateBufferLineToString(E,!1,n,w),w=0,n=0,E++):!_&&w<0&&(x+=y.buffer.translateBufferLineToString(E,!1,0,n+1),w=y.cols-1,n=w,E--);return x+y.buffer.translateBufferLineToString(E,!1,n,w)}function S(n,d){const h=d?"O":"[";return c.C0.ESC+h+n}function g(n,d){n=Math.floor(n);let h="";for(let u=0;u<n;u++)h+=d;return h}i.moveToCellSequence=function(n,d,h,u){const _=h.buffer.x,y=h.buffer.y;if(!h.buffer.hasScrollback)return(function(x,R,T,A,j,M){return f(R,A,j,M).length===0?"":g(b(x,R,x,R-o(R,j),!1,j).length,S("D",M))})(_,y,0,d,h,u)+f(y,d,h,u)+(function(x,R,T,A,j,M){let I;I=f(R,A,j,M).length>0?A-o(A,j):R;const B=A,H=(function(z,D,N,P,O,$){let K;return K=f(N,P,O,$).length>0?P-o(P,O):D,z<N&&K<=P||z>=N&&K<P?"C":"D"})(x,R,T,A,j,M);return g(b(x,I,T,B,H==="C",j).length,S(H,M))})(_,y,n,d,h,u);let w;if(y===d)return w=_>n?"D":"C",g(Math.abs(_-n),S(w,u));w=y>d?"D":"C";const E=Math.abs(y-d);return g((function(x,R){return R.cols-x})(y>d?n:_,h)+(E-1)*h.cols+1+((y>d?_:n)-1),S(w,u))}},1296:function(C,i,r){var c=this&&this.__decorate||function(j,M,I,B){var H,z=arguments.length,D=z<3?M:B===null?B=Object.getOwnPropertyDescriptor(M,I):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(j,M,I,B);else for(var N=j.length-1;N>=0;N--)(H=j[N])&&(D=(z<3?H(D):z>3?H(M,I,D):H(M,I))||D);return z>3&&D&&Object.defineProperty(M,I,D),D},f=this&&this.__param||function(j,M){return function(I,B){M(I,B,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const o=r(3787),p=r(2550),b=r(2223),S=r(6171),g=r(4725),n=r(8055),d=r(8460),h=r(844),u=r(2585),_="xterm-dom-renderer-owner-",y="xterm-rows",w="xterm-fg-",E="xterm-bg-",x="xterm-focus",R="xterm-selection";let T=1,A=i.DomRenderer=class extends h.Disposable{constructor(j,M,I,B,H,z,D,N,P,O){super(),this._element=j,this._screenElement=M,this._viewportElement=I,this._linkifier2=B,this._charSizeService=z,this._optionsService=D,this._bufferService=N,this._coreBrowserService=P,this._themeService=O,this._terminalClass=T++,this._rowElements=[],this.onRequestRedraw=this.register(new d.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(R),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=H.createInstance(o.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,h.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new p.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 j=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*j,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*j),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/j),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/j),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${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(j){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${y} { color: ${j.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: ${n.color.multiplyOpacity(j.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: ${j.cursor.css}; color: ${j.cursorAccent.css}; } 50% { background-color: inherit; color: ${j.cursor.css}; }}`,M+=`${this._terminalSelector} .${y}.${x} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${y}.${x} .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: ${j.cursor.css}; color: ${j.cursorAccent.css};}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${j.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${j.cursor.css} inset;}${this._terminalSelector} .${y} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${j.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${R} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${R} div { position: absolute; background-color: ${j.selectionBackgroundOpaque.css};}${this._terminalSelector} .${R} div { position: absolute; background-color: ${j.selectionInactiveBackgroundOpaque.css};}`;for(const[I,B]of j.ansi.entries())M+=`${this._terminalSelector} .${w}${I} { color: ${B.css}; }${this._terminalSelector} .${w}${I}.xterm-dim { color: ${n.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${E}${I} { background-color: ${B.css}; }`;M+=`${this._terminalSelector} .${w}${b.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(j.background).css}; }${this._terminalSelector} .${w}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(j.background),.5).css}; }${this._terminalSelector} .${E}${b.INVERTED_DEFAULT_COLOR} { background-color: ${j.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const j=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${j}px`,this._rowFactory.defaultSpacing=j}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(j,M){for(let I=this._rowElements.length;I<=M;I++){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(j,M){this._refreshRowElements(j,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(x)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(j,M,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(j,M,I),this.renderRows(0,this._bufferService.rows-1),!j||!M)return;const B=j[1]-this._bufferService.buffer.ydisp,H=M[1]-this._bufferService.buffer.ydisp,z=Math.max(B,0),D=Math.min(H,this._bufferService.rows-1);if(z>=this._bufferService.rows||D<0)return;const N=document.createDocumentFragment();if(I){const P=j[0]>M[0];N.appendChild(this._createSelectionElement(z,P?M[0]:j[0],P?j[0]:M[0],D-z+1))}else{const P=B===z?j[0]:0,O=z===H?M[0]:this._bufferService.cols;N.appendChild(this._createSelectionElement(z,P,O));const $=D-z-1;if(N.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,$)),z!==D){const K=H===D?M[0]:this._bufferService.cols;N.appendChild(this._createSelectionElement(D,0,K))}}this._selectionContainer.appendChild(N)}_createSelectionElement(j,M,I,B=1){const H=document.createElement("div");return H.style.height=B*this.dimensions.css.cell.height+"px",H.style.top=j*this.dimensions.css.cell.height+"px",H.style.left=M*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(I-M)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const j of this._rowElements)j.replaceChildren()}renderRows(j,M){const I=this._bufferService.buffer,B=I.ybase+I.y,H=Math.min(I.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,D=this._optionsService.rawOptions.cursorStyle,N=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=j;P<=M;P++){const O=P+I.ydisp,$=this._rowElements[P],K=I.lines.get(O);if(!$||!K)break;$.replaceChildren(...this._rowFactory.createRow(K,O,O===B,D,N,H,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(j){this._setCellUnderline(j.x1,j.x2,j.y1,j.y2,j.cols,!0)}_handleLinkLeave(j){this._setCellUnderline(j.x1,j.x2,j.y1,j.y2,j.cols,!1)}_setCellUnderline(j,M,I,B,H,z){I<0&&(j=0),B<0&&(M=0);const D=this._bufferService.rows-1;I=Math.max(Math.min(I,D),0),B=Math.max(Math.min(B,D),0),H=Math.min(H,this._bufferService.cols);const N=this._bufferService.buffer,P=N.ybase+N.y,O=Math.min(N.x,H-1),$=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let G=I;G<=B;++G){const ne=G+N.ydisp,L=this._rowElements[G],F=N.lines.get(ne);if(!L||!F)break;L.replaceChildren(...this._rowFactory.createRow(F,ne,ne===P,K,Q,O,$,this.dimensions.css.cell.width,this._widthCache,z?G===I?j:0:-1,z?(G===B?M:H)-1:-1))}}};i.DomRenderer=A=c([f(4,u.IInstantiationService),f(5,g.ICharSizeService),f(6,u.IOptionsService),f(7,u.IBufferService),f(8,g.ICoreBrowserService),f(9,g.IThemeService)],A)},3787:function(C,i,r){var c=this&&this.__decorate||function(w,E,x,R){var T,A=arguments.length,j=A<3?E:R===null?R=Object.getOwnPropertyDescriptor(E,x):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(w,E,x,R);else for(var M=w.length-1;M>=0;M--)(T=w[M])&&(j=(A<3?T(j):A>3?T(E,x,j):T(E,x))||j);return A>3&&j&&Object.defineProperty(E,x,j),j},f=this&&this.__param||function(w,E){return function(x,R){E(x,R,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const o=r(2223),p=r(643),b=r(511),S=r(2585),g=r(8055),n=r(4725),d=r(4269),h=r(6171),u=r(3734);let _=i.DomRendererRowFactory=class{constructor(w,E,x,R,T,A,j){this._document=w,this._characterJoinerService=E,this._optionsService=x,this._coreBrowserService=R,this._coreService=T,this._decorationService=A,this._themeService=j,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(w,E,x){this._selectionStart=w,this._selectionEnd=E,this._columnSelectMode=x}createRow(w,E,x,R,T,A,j,M,I,B,H){const z=[],D=this._characterJoinerService.getJoinedCharacters(E),N=this._themeService.colors;let P,O=w.getNoBgTrimmedLength();x&&O<A+1&&(O=A+1);let $=0,K="",Q=0,G=0,ne=0,L=!1,F=0,U=!1,W=0;const Z=[],X=B!==-1&&H!==-1;for(let oe=0;oe<O;oe++){w.loadCell(oe,this._workCell);let me=this._workCell.getWidth();if(me===0)continue;let xe=!1,_e=oe,ie=this._workCell;if(D.length>0&&oe===D[0][0]){xe=!0;const ae=D.shift();ie=new d.JoinedCellData(this._workCell,w.translateToString(!0,ae[0],ae[1]),ae[1]-ae[0]),_e=ae[1]-1,me=ie.getWidth()}const Ce=this._isCellInSelection(oe,E),Oe=x&&oe===A,Le=X&&oe>=B&&oe<=H;let Xe=!1;this._decorationService.forEachDecorationAtCell(oe,E,void 0,(ae=>{Xe=!0}));let We=ie.getChars()||p.WHITESPACE_CELL_CHAR;if(We===" "&&(ie.isUnderline()||ie.isOverline())&&(We=" "),W=me*M-I.get(We,ie.isBold(),ie.isItalic()),P){if($&&(Ce&&U||!Ce&&!U&&ie.bg===Q)&&(Ce&&U&&N.selectionForeground||ie.fg===G)&&ie.extended.ext===ne&&Le===L&&W===F&&!Oe&&!xe&&!Xe){K+=We,$++;continue}$&&(P.textContent=K),P=this._document.createElement("span"),$=0,K=""}else P=this._document.createElement("span");if(Q=ie.bg,G=ie.fg,ne=ie.extended.ext,L=Le,F=W,U=Ce,xe&&A>=oe&&A<=_e&&(A=oe),!this._coreService.isCursorHidden&&Oe){if(Z.push("xterm-cursor"),this._coreBrowserService.isFocused)j&&Z.push("xterm-cursor-blink"),Z.push(R==="bar"?"xterm-cursor-bar":R==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(T)switch(T){case"outline":Z.push("xterm-cursor-outline");break;case"block":Z.push("xterm-cursor-block");break;case"bar":Z.push("xterm-cursor-bar");break;case"underline":Z.push("xterm-cursor-underline")}}if(ie.isBold()&&Z.push("xterm-bold"),ie.isItalic()&&Z.push("xterm-italic"),ie.isDim()&&Z.push("xterm-dim"),K=ie.isInvisible()?p.WHITESPACE_CELL_CHAR:ie.getChars()||p.WHITESPACE_CELL_CHAR,ie.isUnderline()&&(Z.push(`xterm-underline-${ie.extended.underlineStyle}`),K===" "&&(K=" "),!ie.isUnderlineColorDefault()))if(ie.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(ie.getUnderlineColor()).join(",")})`;else{let ae=ie.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ie.isBold()&&ae<8&&(ae+=8),P.style.textDecorationColor=N.ansi[ae].css}ie.isOverline()&&(Z.push("xterm-overline"),K===" "&&(K=" ")),ie.isStrikethrough()&&Z.push("xterm-strikethrough"),Le&&(P.style.textDecoration="underline");let Te=ie.getFgColor(),Ke=ie.getFgColorMode(),He=ie.getBgColor(),Me=ie.getBgColorMode();const Y=!!ie.isInverse();if(Y){const ae=Te;Te=He,He=ae;const je=Ke;Ke=Me,Me=je}let se,fe,re,de=!1;switch(this._decorationService.forEachDecorationAtCell(oe,E,void 0,(ae=>{ae.options.layer!=="top"&&de||(ae.backgroundColorRGB&&(Me=50331648,He=ae.backgroundColorRGB.rgba>>8&16777215,se=ae.backgroundColorRGB),ae.foregroundColorRGB&&(Ke=50331648,Te=ae.foregroundColorRGB.rgba>>8&16777215,fe=ae.foregroundColorRGB),de=ae.options.layer==="top")})),!de&&Ce&&(se=this._coreBrowserService.isFocused?N.selectionBackgroundOpaque:N.selectionInactiveBackgroundOpaque,He=se.rgba>>8&16777215,Me=50331648,de=!0,N.selectionForeground&&(Ke=50331648,Te=N.selectionForeground.rgba>>8&16777215,fe=N.selectionForeground)),de&&Z.push("xterm-decoration-top"),Me){case 16777216:case 33554432:re=N.ansi[He],Z.push(`xterm-bg-${He}`);break;case 50331648:re=g.rgba.toColor(He>>16,He>>8&255,255&He),this._addStyle(P,`background-color:#${y((He>>>0).toString(16),"0",6)}`);break;default:Y?(re=N.foreground,Z.push(`xterm-bg-${o.INVERTED_DEFAULT_COLOR}`)):re=N.background}switch(se||ie.isDim()&&(se=g.color.multiplyOpacity(re,.5)),Ke){case 16777216:case 33554432:ie.isBold()&&Te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Te+=8),this._applyMinimumContrast(P,re,N.ansi[Te],ie,se,void 0)||Z.push(`xterm-fg-${Te}`);break;case 50331648:const ae=g.rgba.toColor(Te>>16&255,Te>>8&255,255&Te);this._applyMinimumContrast(P,re,ae,ie,se,fe)||this._addStyle(P,`color:#${y(Te.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,re,N.foreground,ie,se,void 0)||Y&&Z.push(`xterm-fg-${o.INVERTED_DEFAULT_COLOR}`)}Z.length&&(P.className=Z.join(" "),Z.length=0),Oe||xe||Xe?P.textContent=K:$++,W!==this.defaultSpacing&&(P.style.letterSpacing=`${W}px`),z.push(P),oe=_e}return P&&$&&(P.textContent=K),z}_applyMinimumContrast(w,E,x,R,T,A){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,h.excludeFromContrastRatioDemands)(R.getCode()))return!1;const j=this._getContrastCache(R);let M;if(T||A||(M=j.getColor(E.rgba,x.rgba)),M===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(R.isDim()?2:1);M=g.color.ensureContrastRatio(T||E,A||x,I),j.setColor((T||E).rgba,(A||x).rgba,M??null)}return!!M&&(this._addStyle(w,`color:${M.css}`),!0)}_getContrastCache(w){return w.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(w,E){w.setAttribute("style",`${w.getAttribute("style")||""}${E};`)}_isCellInSelection(w,E){const x=this._selectionStart,R=this._selectionEnd;return!(!x||!R)&&(this._columnSelectMode?x[0]<=R[0]?w>=x[0]&&E>=x[1]&&w<R[0]&&E<=R[1]:w<x[0]&&E>=x[1]&&w>=R[0]&&E<=R[1]:E>x[1]&&E<R[1]||x[1]===R[1]&&E===x[1]&&w>=x[0]&&w<R[0]||x[1]<R[1]&&E===R[1]&&w<R[0]||x[1]<R[1]&&E===x[1]&&w>=x[0])}};function y(w,E,x){for(;w.length<x;)w=E+w;return w}i.DomRendererRowFactory=_=c([f(1,n.ICharacterJoinerService),f(2,S.IOptionsService),f(3,n.ICoreBrowserService),f(4,S.ICoreService),f(5,S.IDecorationService),f(6,n.IThemeService)],_)},2550:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(r){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=r.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=r.createElement("span"),f=r.createElement("span");f.style.fontWeight="bold";const o=r.createElement("span");o.style.fontStyle="italic";const p=r.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[c,f,o,p],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(o),this._container.appendChild(p),r.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(r,c,f,o){r===this._font&&c===this._fontSize&&f===this._weight&&o===this._weightBold||(this._font=r,this._fontSize=c,this._weight=f,this._weightBold=o,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${o}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${o}`,this.clear())}get(r,c,f){let o=0;if(!c&&!f&&r.length===1&&(o=r.charCodeAt(0))<256)return this._flat[o]!==-9999?this._flat[o]:this._flat[o]=this._measure(r,0);let p=r;c&&(p+="B"),f&&(p+="I");let b=this._holey.get(p);if(b===void 0){let S=0;c&&(S|=1),f&&(S|=2),b=this._measure(r,S),this._holey.set(p,b)}return b}_measure(r,c){const f=this._measureElements[c];return f.textContent=r.repeat(32),f.offsetWidth/32}}},2223:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=r(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(C,i)=>{function r(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=r,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return r(c)||(function(f){return 9472<=f&&f<=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:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(r){this._bufferService=r,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 r=this.selectionStart[0]+this.selectionStartLength;return r>this._bufferService.cols?r%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(r/this._bufferService.cols)-1]:[r%this._bufferService.cols,this.selectionStart[1]+Math.floor(r/this._bufferService.cols)]:[r,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const r=this.selectionStart[0]+this.selectionStartLength;return r>this._bufferService.cols?[r%this._bufferService.cols,this.selectionStart[1]+Math.floor(r/this._bufferService.cols)]:[Math.max(r,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const r=this.selectionStart,c=this.selectionEnd;return!(!r||!c)&&(r[1]>c[1]||r[1]===c[1]&&r[0]>c[0])}handleTrim(r){return this.selectionStart&&(this.selectionStart[1]-=r),this.selectionEnd&&(this.selectionEnd[1]-=r),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(C,i,r){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const o=r(2585),p=r(8460),b=r(844);let S=i.CharSizeService=class extends b.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,d,h){super(),this._optionsService=h,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new g(n,d,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};i.CharSizeService=S=c([f(2,o.IOptionsService)],S);class g{constructor(d,h,u){this._document=d,this._parentElement=h,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 d={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return d.width!==0&&d.height!==0&&(this._result.width=d.width/32,this._result.height=Math.ceil(d.height)),this._result}}},4269:function(C,i,r){var c=this&&this.__decorate||function(d,h,u,_){var y,w=arguments.length,E=w<3?h:_===null?_=Object.getOwnPropertyDescriptor(h,u):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,h,u,_);else for(var x=d.length-1;x>=0;x--)(y=d[x])&&(E=(w<3?y(E):w>3?y(h,u,E):y(h,u))||E);return w>3&&E&&Object.defineProperty(h,u,E),E},f=this&&this.__param||function(d,h){return function(u,_){h(u,_,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const o=r(3734),p=r(643),b=r(511),S=r(2585);class g extends o.AttributeData{constructor(h,u,_){super(),this.content=0,this.combinedData="",this.fg=h.fg,this.bg=h.bg,this.combinedData=u,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(h){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=g;let n=i.CharacterJoinerService=class In{constructor(h){this._bufferService=h,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(h){const u={id:this._nextCharacterJoinerId++,handler:h};return this._characterJoiners.push(u),u.id}deregister(h){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===h)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(h){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(h);if(!u||u.length===0)return[];const _=[],y=u.translateToString(!0);let w=0,E=0,x=0,R=u.getFg(0),T=u.getBg(0);for(let A=0;A<u.getTrimmedLength();A++)if(u.loadCell(A,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==R||this._workCell.bg!==T){if(A-w>1){const j=this._getJoinedRanges(y,x,E,u,w);for(let M=0;M<j.length;M++)_.push(j[M])}w=A,x=E,R=this._workCell.fg,T=this._workCell.bg}E+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-w>1){const A=this._getJoinedRanges(y,x,E,u,w);for(let j=0;j<A.length;j++)_.push(A[j])}return _}_getJoinedRanges(h,u,_,y,w){const E=h.substring(u,_);let x=[];try{x=this._characterJoiners[0].handler(E)}catch(R){console.error(R)}for(let R=1;R<this._characterJoiners.length;R++)try{const T=this._characterJoiners[R].handler(E);for(let A=0;A<T.length;A++)In._mergeRanges(x,T[A])}catch(T){console.error(T)}return this._stringRangesToCellRanges(x,y,w),x}_stringRangesToCellRanges(h,u,_){let y=0,w=!1,E=0,x=h[y];if(x){for(let R=_;R<this._bufferService.cols;R++){const T=u.getWidth(R),A=u.getString(R).length||p.WHITESPACE_CELL_CHAR.length;if(T!==0){if(!w&&x[0]<=E&&(x[0]=R,w=!0),x[1]<=E){if(x[1]=R,x=h[++y],!x)break;x[0]<=E?(x[0]=R,w=!0):w=!1}E+=A}}x&&(x[1]=this._bufferService.cols)}}static _mergeRanges(h,u){let _=!1;for(let y=0;y<h.length;y++){const w=h[y];if(_){if(u[1]<=w[0])return h[y-1][1]=u[1],h;if(u[1]<=w[1])return h[y-1][1]=Math.max(u[1],w[1]),h.splice(y,1),h;h.splice(y,1),y--}else{if(u[1]<=w[0])return h.splice(y,0,u),h;if(u[1]<=w[1])return w[0]=Math.min(u[0],w[0]),h;u[0]<w[1]&&(w[0]=Math.min(u[0],w[0]),_=!0)}}return _?h[h.length-1][1]=u[1]:h.push(u),h}};i.CharacterJoinerService=n=c([f(0,S.IBufferService)],n)},5114:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(r,c){this._textarea=r,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(C,i,r){var c=this&&this.__decorate||function(S,g,n,d){var h,u=arguments.length,_=u<3?g:d===null?d=Object.getOwnPropertyDescriptor(g,n):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(S,g,n,d);else for(var y=S.length-1;y>=0;y--)(h=S[y])&&(_=(u<3?h(_):u>3?h(g,n,_):h(g,n))||_);return u>3&&_&&Object.defineProperty(g,n,_),_},f=this&&this.__param||function(S,g){return function(n,d){g(n,d,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const o=r(4725),p=r(9806);let b=i.MouseService=class{constructor(S,g){this._renderService=S,this._charSizeService=g}getCoords(S,g,n,d,h){return(0,p.getCoords)(window,S,g,n,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,h)}getMouseReportCoords(S,g){const n=(0,p.getCoordsRelativeToElement)(window,S,g);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};i.MouseService=b=c([f(0,o.IRenderService),f(1,o.ICharSizeService)],b)},3230:function(C,i,r){var c=this&&this.__decorate||function(_,y,w,E){var x,R=arguments.length,T=R<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,w):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,y,w,E);else for(var A=_.length-1;A>=0;A--)(x=_[A])&&(T=(R<3?x(T):R>3?x(y,w,T):x(y,w))||T);return R>3&&T&&Object.defineProperty(y,w,T),T},f=this&&this.__param||function(_,y){return function(w,E){y(w,E,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const o=r(3656),p=r(6193),b=r(5596),S=r(4725),g=r(8460),n=r(844),d=r(7226),h=r(2585);let u=i.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,y,w,E,x,R,T,A){if(super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new d.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 g.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new g.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new g.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new g.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(T.window,((j,M)=>this._renderRows(j,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new b.ScreenDprMonitor(T.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(R.onResize((()=>this._fullRefresh()))),this.register(R.buffers.onBufferActivate((()=>{var j;return(j=this._renderer.value)===null||j===void 0?void 0:j.clear()}))),this.register(w.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(x.onDecorationRegistered((()=>this._fullRefresh()))),this.register(x.onDecorationRemoved((()=>this._fullRefresh()))),this.register(w.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(R.cols,R.rows),this._fullRefresh()}))),this.register(w.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(R.buffer.y,R.buffer.y,!0)))),this.register((0,o.addDisposableDomListener)(T.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(A.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in T.window){const j=new T.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});j.observe(y),this.register({dispose:()=>j.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,y,w=!1){this._isPaused?this._needsFullRefresh=!0:(w||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,y,this._rowCount))}_renderRows(_,y){this._renderer.value&&(_=Math.min(_,this._rowCount-1),y=Math.min(y,this._rowCount-1),this._renderer.value.renderRows(_,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:_,end:y}),this._onRender.fire({start:_,end:y}),this._isNextRenderRedrawOnly=!0)}resize(_,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(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((y=>this.refreshRows(y.start,y.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,y;this._renderer.value&&((y=(_=this._renderer.value).clearTextureAtlas)===null||y===void 0||y.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,y){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,y))):this._renderer.value.handleResize(_,y),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,y,w){var E;this._selectionState.start=_,this._selectionState.end=y,this._selectionState.columnSelectMode=w,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(_,y,w)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};i.RenderService=u=c([f(2,h.IOptionsService),f(3,S.ICharSizeService),f(4,h.IDecorationService),f(5,h.IBufferService),f(6,S.ICoreBrowserService),f(7,S.IThemeService)],u)},9312:function(C,i,r){var c=this&&this.__decorate||function(x,R,T,A){var j,M=arguments.length,I=M<3?R:A===null?A=Object.getOwnPropertyDescriptor(R,T):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(x,R,T,A);else for(var B=x.length-1;B>=0;B--)(j=x[B])&&(I=(M<3?j(I):M>3?j(R,T,I):j(R,T))||I);return M>3&&I&&Object.defineProperty(R,T,I),I},f=this&&this.__param||function(x,R){return function(T,A){R(T,A,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const o=r(9806),p=r(9504),b=r(456),S=r(4725),g=r(8460),n=r(844),d=r(6114),h=r(4841),u=r(511),_=r(2585),y=" ",w=new RegExp(y,"g");let E=i.SelectionService=class extends n.Disposable{constructor(x,R,T,A,j,M,I,B,H){super(),this._element=x,this._screenElement=R,this._linkifier=T,this._bufferService=A,this._coreService=j,this._mouseService=M,this._optionsService=I,this._renderService=B,this._coreBrowserService=H,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 g.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new g.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new g.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new g.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,n.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 x=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;return!(!x||!R||x[0]===R[0]&&x[1]===R[1])}get selectionText(){const x=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;if(!x||!R)return"";const T=this._bufferService.buffer,A=[];if(this._activeSelectionMode===3){if(x[0]===R[0])return"";const j=x[0]<R[0]?x[0]:R[0],M=x[0]<R[0]?R[0]:x[0];for(let I=x[1];I<=R[1];I++){const B=T.translateBufferLineToString(I,!0,j,M);A.push(B)}}else{const j=x[1]===R[1]?R[0]:void 0;A.push(T.translateBufferLineToString(x[1],!0,x[0],j));for(let M=x[1]+1;M<=R[1]-1;M++){const I=T.lines.get(M),B=T.translateBufferLineToString(M,!0);I?.isWrapped?A[A.length-1]+=B:A.push(B)}if(x[1]!==R[1]){const M=T.lines.get(R[1]),I=T.translateBufferLineToString(R[1],!0,0,R[0]);M&&M.isWrapped?A[A.length-1]+=I:A.push(I)}}return A.map((j=>j.replace(w," "))).join(d.isWindows?`\r
|
|
16
|
-
`:`
|
|
17
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(x){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),d.isLinux&&x&&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(x){const R=this._getMouseBufferCoords(x),T=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!!(T&&A&&R)&&this._areCoordsInSelection(R,T,A)}isCellInSelection(x,R){const T=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!(!T||!A)&&this._areCoordsInSelection([x,R],T,A)}_areCoordsInSelection(x,R,T){return x[1]>R[1]&&x[1]<T[1]||R[1]===T[1]&&x[1]===R[1]&&x[0]>=R[0]&&x[0]<T[0]||R[1]<T[1]&&x[1]===T[1]&&x[0]<T[0]||R[1]<T[1]&&x[1]===R[1]&&x[0]>=R[0]}_selectWordAtCursor(x,R){var T,A;const j=(A=(T=this._linkifier.currentLink)===null||T===void 0?void 0:T.link)===null||A===void 0?void 0:A.range;if(j)return this._model.selectionStart=[j.start.x-1,j.start.y-1],this._model.selectionStartLength=(0,h.getRangeLength)(j,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(x);return!!M&&(this._selectWordAt(M,R),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(x,R){this._model.clearSelection(),x=Math.max(x,0),R=Math.min(R,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,x],this._model.selectionEnd=[this._bufferService.cols,R],this.refresh(),this._onSelectionChange.fire()}_handleTrim(x){this._model.handleTrim(x)&&this.refresh()}_getMouseBufferCoords(x){const R=this._mouseService.getCoords(x,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(R)return R[0]--,R[1]--,R[1]+=this._bufferService.buffer.ydisp,R}_getMouseEventScrollAmount(x){let R=(0,o.getCoordsRelativeToElement)(this._coreBrowserService.window,x,this._screenElement)[1];const T=this._renderService.dimensions.css.canvas.height;return R>=0&&R<=T?0:(R>T&&(R-=T),R=Math.min(Math.max(R,-50),50),R/=50,R/Math.abs(R)+Math.round(14*R))}shouldForceSelection(x){return d.isMac?x.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:x.shiftKey}handleMouseDown(x){if(this._mouseDownTimeStamp=x.timeStamp,(x.button!==2||!this.hasSelection)&&x.button===0){if(!this._enabled){if(!this.shouldForceSelection(x))return;x.stopPropagation()}x.preventDefault(),this._dragScrollAmount=0,this._enabled&&x.shiftKey?this._handleIncrementalClick(x):x.detail===1?this._handleSingleClick(x):x.detail===2?this._handleDoubleClick(x):x.detail===3&&this._handleTripleClick(x),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(x){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(x))}_handleSingleClick(x){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(x)?3:0,this._model.selectionStart=this._getMouseBufferCoords(x),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const R=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);R&&R.length!==this._model.selectionStart[0]&&R.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(x){this._selectWordAtCursor(x,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(x){const R=this._getMouseBufferCoords(x);R&&(this._activeSelectionMode=2,this._selectLineAt(R[1]))}shouldColumnSelect(x){return x.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(x){if(x.stopImmediatePropagation(),!this._model.selectionStart)return;const R=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(x),!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(x),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const T=this._bufferService.buffer;if(this._model.selectionEnd[1]<T.lines.length){const A=T.lines.get(this._model.selectionEnd[1]);A&&A.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}R&&R[0]===this._model.selectionEnd[0]&&R[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 x=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(x.ydisp+this._bufferService.rows,x.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=x.ydisp),this.refresh()}}_handleMouseUp(x){const R=x.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&R<500&&x.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const T=this._mouseService.getCoords(x,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(T&&T[0]!==void 0&&T[1]!==void 0){const A=(0,p.moveToCellSequence)(T[0]-1,T[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(A,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const x=this._model.finalSelectionStart,R=this._model.finalSelectionEnd,T=!(!x||!R||x[0]===R[0]&&x[1]===R[1]);T?x&&R&&(this._oldSelectionStart&&this._oldSelectionEnd&&x[0]===this._oldSelectionStart[0]&&x[1]===this._oldSelectionStart[1]&&R[0]===this._oldSelectionEnd[0]&&R[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(x,R,T)):this._oldHasSelection&&this._fireOnSelectionChange(x,R,T)}_fireOnSelectionChange(x,R,T){this._oldSelectionStart=x,this._oldSelectionEnd=R,this._oldHasSelection=T,this._onSelectionChange.fire()}_handleBufferActivate(x){this.clearSelection(),this._trimListener.dispose(),this._trimListener=x.activeBuffer.lines.onTrim((R=>this._handleTrim(R)))}_convertViewportColToCharacterIndex(x,R){let T=R;for(let A=0;R>=A;A++){const j=x.loadCell(A,this._workCell).getChars().length;this._workCell.getWidth()===0?T--:j>1&&R!==A&&(T+=j-1)}return T}setSelection(x,R,T){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[x,R],this._model.selectionStartLength=T,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(x){this._isClickInSelection(x)||(this._selectWordAtCursor(x,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(x,R,T=!0,A=!0){if(x[0]>=this._bufferService.cols)return;const j=this._bufferService.buffer,M=j.lines.get(x[1]);if(!M)return;const I=j.translateBufferLineToString(x[1],!1);let B=this._convertViewportColToCharacterIndex(M,x[0]),H=B;const z=x[0]-B;let D=0,N=0,P=0,O=0;if(I.charAt(B)===" "){for(;B>0&&I.charAt(B-1)===" ";)B--;for(;H<I.length&&I.charAt(H+1)===" ";)H++}else{let Q=x[0],G=x[0];M.getWidth(Q)===0&&(D++,Q--),M.getWidth(G)===2&&(N++,G++);const ne=M.getString(G).length;for(ne>1&&(O+=ne-1,H+=ne-1);Q>0&&B>0&&!this._isCharWordSeparator(M.loadCell(Q-1,this._workCell));){M.loadCell(Q-1,this._workCell);const L=this._workCell.getChars().length;this._workCell.getWidth()===0?(D++,Q--):L>1&&(P+=L-1,B-=L-1),B--,Q--}for(;G<M.length&&H+1<I.length&&!this._isCharWordSeparator(M.loadCell(G+1,this._workCell));){M.loadCell(G+1,this._workCell);const L=this._workCell.getChars().length;this._workCell.getWidth()===2?(N++,G++):L>1&&(O+=L-1,H+=L-1),H++,G++}}H++;let $=B+z-D+P,K=Math.min(this._bufferService.cols,H-B+D+N-P-O);if(R||I.slice(B,H).trim()!==""){if(T&&$===0&&M.getCodePoint(0)!==32){const Q=j.lines.get(x[1]-1);if(Q&&M.isWrapped&&Q.getCodePoint(this._bufferService.cols-1)!==32){const G=this._getWordAt([this._bufferService.cols-1,x[1]-1],!1,!0,!1);if(G){const ne=this._bufferService.cols-G.start;$-=ne,K+=ne}}}if(A&&$+K===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const Q=j.lines.get(x[1]+1);if(Q?.isWrapped&&Q.getCodePoint(0)!==32){const G=this._getWordAt([0,x[1]+1],!1,!1,!0);G&&(K+=G.length)}}return{start:$,length:K}}}_selectWordAt(x,R){const T=this._getWordAt(x,R);if(T){for(;T.start<0;)T.start+=this._bufferService.cols,x[1]--;this._model.selectionStart=[T.start,x[1]],this._model.selectionStartLength=T.length}}_selectToWordAt(x){const R=this._getWordAt(x,!0);if(R){let T=x[1];for(;R.start<0;)R.start+=this._bufferService.cols,T--;if(!this._model.areSelectionValuesReversed())for(;R.start+R.length>this._bufferService.cols;)R.length-=this._bufferService.cols,T++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?R.start:R.start+R.length,T]}}_isCharWordSeparator(x){return x.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(x.getChars())>=0}_selectLineAt(x){const R=this._bufferService.buffer.getWrappedRangeForLine(x),T={start:{x:0,y:R.first},end:{x:this._bufferService.cols-1,y:R.last}};this._model.selectionStart=[0,R.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,h.getRangeLength)(T,this._bufferService.cols)}};i.SelectionService=E=c([f(3,_.IBufferService),f(4,_.ICoreService),f(5,S.IMouseService),f(6,_.IOptionsService),f(7,S.IRenderService),f(8,S.ICoreBrowserService)],E)},4725:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const c=r(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(C,i,r){var c=this&&this.__decorate||function(E,x,R,T){var A,j=arguments.length,M=j<3?x:T===null?T=Object.getOwnPropertyDescriptor(x,R):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(E,x,R,T);else for(var I=E.length-1;I>=0;I--)(A=E[I])&&(M=(j<3?A(M):j>3?A(x,R,M):A(x,R))||M);return j>3&&M&&Object.defineProperty(x,R,M),M},f=this&&this.__param||function(E,x){return function(R,T){x(R,T,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const o=r(7239),p=r(8055),b=r(8460),S=r(844),g=r(2585),n=p.css.toColor("#ffffff"),d=p.css.toColor("#000000"),h=p.css.toColor("#ffffff"),u=p.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],x=[0,95,135,175,215,255];for(let R=0;R<216;R++){const T=x[R/36%6|0],A=x[R/6%6|0],j=x[R%6];E.push({css:p.channels.toCss(T,A,j),rgba:p.channels.toRgba(T,A,j)})}for(let R=0;R<24;R++){const T=8+10*R;E.push({css:p.channels.toCss(T,T,T),rgba:p.channels.toRgba(T,T,T)})}return E})());let y=i.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new o.ColorContrastCache,this._halfContrastCache=new o.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:d,cursor:h,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:p.color.blend(d,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:p.color.blend(d,_),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const x=this._colors;if(x.foreground=w(E.foreground,n),x.background=w(E.background,d),x.cursor=w(E.cursor,h),x.cursorAccent=w(E.cursorAccent,u),x.selectionBackgroundTransparent=w(E.selectionBackground,_),x.selectionBackgroundOpaque=p.color.blend(x.background,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundTransparent=w(E.selectionInactiveBackground,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundOpaque=p.color.blend(x.background,x.selectionInactiveBackgroundTransparent),x.selectionForeground=E.selectionForeground?w(E.selectionForeground,p.NULL_COLOR):void 0,x.selectionForeground===p.NULL_COLOR&&(x.selectionForeground=void 0),p.color.isOpaque(x.selectionBackgroundTransparent)&&(x.selectionBackgroundTransparent=p.color.opacity(x.selectionBackgroundTransparent,.3)),p.color.isOpaque(x.selectionInactiveBackgroundTransparent)&&(x.selectionInactiveBackgroundTransparent=p.color.opacity(x.selectionInactiveBackgroundTransparent,.3)),x.ansi=i.DEFAULT_ANSI_COLORS.slice(),x.ansi[0]=w(E.black,i.DEFAULT_ANSI_COLORS[0]),x.ansi[1]=w(E.red,i.DEFAULT_ANSI_COLORS[1]),x.ansi[2]=w(E.green,i.DEFAULT_ANSI_COLORS[2]),x.ansi[3]=w(E.yellow,i.DEFAULT_ANSI_COLORS[3]),x.ansi[4]=w(E.blue,i.DEFAULT_ANSI_COLORS[4]),x.ansi[5]=w(E.magenta,i.DEFAULT_ANSI_COLORS[5]),x.ansi[6]=w(E.cyan,i.DEFAULT_ANSI_COLORS[6]),x.ansi[7]=w(E.white,i.DEFAULT_ANSI_COLORS[7]),x.ansi[8]=w(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),x.ansi[9]=w(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),x.ansi[10]=w(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),x.ansi[11]=w(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),x.ansi[12]=w(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),x.ansi[13]=w(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),x.ansi[14]=w(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),x.ansi[15]=w(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const R=Math.min(x.ansi.length-16,E.extendedAnsi.length);for(let T=0;T<R;T++)x.ansi[T+16]=w(E.extendedAnsi[T],i.DEFAULT_ANSI_COLORS[T+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let x=0;x<this._restoreColors.ansi.length;++x)this._colors.ansi[x]=this._restoreColors.ansi[x]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function w(E,x){if(E!==void 0)try{return p.css.toColor(E)}catch{}return x}i.ThemeService=y=c([f(0,g.IOptionsService)],y)},6349:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=r(8460),f=r(844);class o extends f.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 g=0;g<Math.min(b,this.length);g++)S[g]=this._array[this._getCyclicIndex(g)];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,...g){if(S){for(let n=b;n<this._length-S;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+S)];this._length-=S,this.onDeleteEmitter.fire({index:b,amount:S})}for(let n=this._length-1;n>=b;n--)this._array[this._getCyclicIndex(n+g.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<g.length;n++)this._array[this._getCyclicIndex(b+n)]=g[n];if(g.length&&this.onInsertEmitter.fire({index:b,amount:g.length}),this._length+g.length>this._maxLength){const n=this._length+g.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=g.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,S,g){if(!(S<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+g<0)throw new Error("Cannot shift elements in list beyond index 0");if(g>0){for(let d=S-1;d>=0;d--)this.set(b+d+g,this.get(b+d));const n=b+S+g-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<S;n++)this.set(b+n+g,this.get(b+n))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}i.CircularList=o},1439:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function r(c,f=5){if(typeof c!="object")return c;const o=Array.isArray(c)?[]:{};for(const p in c)o[p]=f<=1?c[p]:c[p]&&r(c[p],f-1);return o}},8055:(C,i,r)=>{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=r(6114);let f=0,o=0,p=0,b=0;var S,g,n,d,h;function u(y){const w=y.toString(16);return w.length<2?"0"+w:w}function _(y,w){return y<w?(w+.05)/(y+.05):(y+.05)/(w+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(y){y.toCss=function(w,E,x,R){return R!==void 0?`#${u(w)}${u(E)}${u(x)}${u(R)}`:`#${u(w)}${u(E)}${u(x)}`},y.toRgba=function(w,E,x,R=255){return(w<<24|E<<16|x<<8|R)>>>0}})(S||(i.channels=S={})),(function(y){function w(E,x){return b=Math.round(255*x),[f,o,p]=h.toChannels(E.rgba),{css:S.toCss(f,o,p,b),rgba:S.toRgba(f,o,p,b)}}y.blend=function(E,x){if(b=(255&x.rgba)/255,b===1)return{css:x.css,rgba:x.rgba};const R=x.rgba>>24&255,T=x.rgba>>16&255,A=x.rgba>>8&255,j=E.rgba>>24&255,M=E.rgba>>16&255,I=E.rgba>>8&255;return f=j+Math.round((R-j)*b),o=M+Math.round((T-M)*b),p=I+Math.round((A-I)*b),{css:S.toCss(f,o,p),rgba:S.toRgba(f,o,p)}},y.isOpaque=function(E){return(255&E.rgba)==255},y.ensureContrastRatio=function(E,x,R){const T=h.ensureContrastRatio(E.rgba,x.rgba,R);if(T)return h.toColor(T>>24&255,T>>16&255,T>>8&255)},y.opaque=function(E){const x=(255|E.rgba)>>>0;return[f,o,p]=h.toChannels(x),{css:S.toCss(f,o,p),rgba:x}},y.opacity=w,y.multiplyOpacity=function(E,x){return b=255&E.rgba,w(E,b*x/255)},y.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(g||(i.color=g={})),(function(y){let w,E;if(!c.isNode){const x=document.createElement("canvas");x.width=1,x.height=1;const R=x.getContext("2d",{willReadFrequently:!0});R&&(w=R,w.globalCompositeOperation="copy",E=w.createLinearGradient(0,0,1,1))}y.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return f=parseInt(x.slice(1,2).repeat(2),16),o=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),h.toColor(f,o,p);case 5:return f=parseInt(x.slice(1,2).repeat(2),16),o=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),b=parseInt(x.slice(4,5).repeat(2),16),h.toColor(f,o,p,b);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const R=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(R)return f=parseInt(R[1]),o=parseInt(R[2]),p=parseInt(R[3]),b=Math.round(255*(R[5]===void 0?1:parseFloat(R[5]))),h.toColor(f,o,p,b);if(!w||!E)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=E,w.fillStyle=x,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[f,o,p,b]=w.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(f,o,p,b),css:x}}})(n||(i.css=n={})),(function(y){function w(E,x,R){const T=E/255,A=x/255,j=R/255;return .2126*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.7152*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.0722*(j<=.03928?j/12.92:Math.pow((j+.055)/1.055,2.4))}y.relativeLuminance=function(E){return w(E>>16&255,E>>8&255,255&E)},y.relativeLuminance2=w})(d||(i.rgb=d={})),(function(y){function w(x,R,T){const A=x>>24&255,j=x>>16&255,M=x>>8&255;let I=R>>24&255,B=R>>16&255,H=R>>8&255,z=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(A,j,M));for(;z<T&&(I>0||B>0||H>0);)I-=Math.max(0,Math.ceil(.1*I)),B-=Math.max(0,Math.ceil(.1*B)),H-=Math.max(0,Math.ceil(.1*H)),z=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(A,j,M));return(I<<24|B<<16|H<<8|255)>>>0}function E(x,R,T){const A=x>>24&255,j=x>>16&255,M=x>>8&255;let I=R>>24&255,B=R>>16&255,H=R>>8&255,z=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(A,j,M));for(;z<T&&(I<255||B<255||H<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),B=Math.min(255,B+Math.ceil(.1*(255-B))),H=Math.min(255,H+Math.ceil(.1*(255-H))),z=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(A,j,M));return(I<<24|B<<16|H<<8|255)>>>0}y.ensureContrastRatio=function(x,R,T){const A=d.relativeLuminance(x>>8),j=d.relativeLuminance(R>>8);if(_(A,j)<T){if(j<A){const B=w(x,R,T),H=_(A,d.relativeLuminance(B>>8));if(H<T){const z=E(x,R,T);return H>_(A,d.relativeLuminance(z>>8))?B:z}return B}const M=E(x,R,T),I=_(A,d.relativeLuminance(M>>8));if(I<T){const B=w(x,R,T);return I>_(A,d.relativeLuminance(B>>8))?M:B}return M}},y.reduceLuminance=w,y.increaseLuminance=E,y.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]},y.toColor=function(x,R,T,A){return{css:S.toCss(x,R,T,A),rgba:S.toRgba(x,R,T,A)}}})(h||(i.rgba=h={})),i.toPaddedHex=u,i.contrastRatio=_},8969:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=r(844),f=r(2585),o=r(4348),p=r(7866),b=r(744),S=r(7302),g=r(6975),n=r(8460),d=r(1753),h=r(1480),u=r(7994),_=r(9282),y=r(5435),w=r(5981),E=r(2660);let x=!1;class R extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((A=>{var j;(j=this._onScrollApi)===null||j===void 0||j.fire(A.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(A){for(const j in A)this.optionsService.options[j]=A[j]}constructor(A){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new o.InstantiationService,this.optionsService=this.register(new S.OptionsService(A)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(g.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(h.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.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,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.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((j=>{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((j=>{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 w.WriteBuffer(((j,M)=>this._inputHandler.parse(j,M)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(A,j){this._writeBuffer.write(A,j)}writeSync(A,j){this._logService.logLevel<=f.LogLevelEnum.WARN&&!x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),x=!0),this._writeBuffer.writeSync(A,j)}resize(A,j){isNaN(A)||isNaN(j)||(A=Math.max(A,b.MINIMUM_COLS),j=Math.max(j,b.MINIMUM_ROWS),this._bufferService.resize(A,j))}scroll(A,j=!1){this._bufferService.scroll(A,j)}scrollLines(A,j,M){this._bufferService.scrollLines(A,j,M)}scrollPages(A){this.scrollLines(A*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(A){const j=A-this._bufferService.buffer.ydisp;j!==0&&this.scrollLines(j)}registerEscHandler(A,j){return this._inputHandler.registerEscHandler(A,j)}registerDcsHandler(A,j){return this._inputHandler.registerDcsHandler(A,j)}registerCsiHandler(A,j){return this._inputHandler.registerCsiHandler(A,j)}registerOscHandler(A,j){return this._inputHandler.registerOscHandler(A,j)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let A=!1;const j=this.optionsService.rawOptions.windowsPty;j&&j.buildNumber!==void 0&&j.buildNumber!==void 0?A=j.backend==="conpty"&&j.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(A=!0),A?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const A=[];A.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),A.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const j of A)j.dispose()}))}}}i.CoreTerminal=R},8460:(C,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=r=>(this._listeners.push(r),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===r)return void this._listeners.splice(c,1)}}})),this._event}fire(r,c){const f=[];for(let o=0;o<this._listeners.length;o++)f.push(this._listeners[o]);for(let o=0;o<f.length;o++)f[o].call(void 0,r,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(r,c){return r((f=>c.fire(f)))}},5435:function(C,i,r){var c=this&&this.__decorate||function(z,D,N,P){var O,$=arguments.length,K=$<3?D:P===null?P=Object.getOwnPropertyDescriptor(D,N):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(z,D,N,P);else for(var Q=z.length-1;Q>=0;Q--)(O=z[Q])&&(K=($<3?O(K):$>3?O(D,N,K):O(D,N))||K);return $>3&&K&&Object.defineProperty(D,N,K),K},f=this&&this.__param||function(z,D){return function(N,P){D(N,P,z)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const o=r(2584),p=r(7116),b=r(2015),S=r(844),g=r(482),n=r(8437),d=r(8460),h=r(643),u=r(511),_=r(3734),y=r(2585),w=r(6242),E=r(6351),x=r(5941),R={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function A(z,D){if(z>24)return D.setWinLines||!1;switch(z){case 1:return!!D.restoreWin;case 2:return!!D.minimizeWin;case 3:return!!D.setWinPosition;case 4:return!!D.setWinSizePixels;case 5:return!!D.raiseWin;case 6:return!!D.lowerWin;case 7:return!!D.refreshWin;case 8:return!!D.setWinSizeChars;case 9:return!!D.maximizeWin;case 10:return!!D.fullscreenWin;case 11:return!!D.getWinState;case 13:return!!D.getWinPosition;case 14:return!!D.getWinSizePixels;case 15:return!!D.getScreenSizePixels;case 16:return!!D.getCellSizePixels;case 18:return!!D.getWinSizeChars;case 19:return!!D.getScreenSizeChars;case 20:return!!D.getIconTitle;case 21:return!!D.getWinTitle;case 22:return!!D.pushTitle;case 23:return!!D.popTitle;case 24:return!!D.setWinLines}return!1}var j;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(j||(i.WindowsOptionsReportType=j={}));let M=0;class I extends S.Disposable{getAttrData(){return this._curAttrData}constructor(D,N,P,O,$,K,Q,G,ne=new b.EscapeSequenceParser){super(),this._bufferService=D,this._charsetService=N,this._coreService=P,this._logService=O,this._optionsService=$,this._oscLinkService=K,this._coreMouseService=Q,this._unicodeService=G,this._parser=ne,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new g.StringToUtf32,this._utf8Decoder=new g.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.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((L=>this._activeBuffer=L.activeBuffer))),this._parser.setCsiHandlerFallback(((L,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(L),params:F.toArray()})})),this._parser.setEscHandlerFallback((L=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(L)})})),this._parser.setExecuteHandlerFallback((L=>{this._logService.debug("Unknown EXECUTE code: ",{code:L})})),this._parser.setOscHandlerFallback(((L,F,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:L,action:F,data:U})})),this._parser.setDcsHandlerFallback(((L,F,U)=>{F==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(L),action:F,payload:U})})),this._parser.setPrintHandler(((L,F,U)=>this.print(L,F,U))),this._parser.registerCsiHandler({final:"@"},(L=>this.insertChars(L))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(L=>this.scrollLeft(L))),this._parser.registerCsiHandler({final:"A"},(L=>this.cursorUp(L))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(L=>this.scrollRight(L))),this._parser.registerCsiHandler({final:"B"},(L=>this.cursorDown(L))),this._parser.registerCsiHandler({final:"C"},(L=>this.cursorForward(L))),this._parser.registerCsiHandler({final:"D"},(L=>this.cursorBackward(L))),this._parser.registerCsiHandler({final:"E"},(L=>this.cursorNextLine(L))),this._parser.registerCsiHandler({final:"F"},(L=>this.cursorPrecedingLine(L))),this._parser.registerCsiHandler({final:"G"},(L=>this.cursorCharAbsolute(L))),this._parser.registerCsiHandler({final:"H"},(L=>this.cursorPosition(L))),this._parser.registerCsiHandler({final:"I"},(L=>this.cursorForwardTab(L))),this._parser.registerCsiHandler({final:"J"},(L=>this.eraseInDisplay(L,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(L=>this.eraseInDisplay(L,!0))),this._parser.registerCsiHandler({final:"K"},(L=>this.eraseInLine(L,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(L=>this.eraseInLine(L,!0))),this._parser.registerCsiHandler({final:"L"},(L=>this.insertLines(L))),this._parser.registerCsiHandler({final:"M"},(L=>this.deleteLines(L))),this._parser.registerCsiHandler({final:"P"},(L=>this.deleteChars(L))),this._parser.registerCsiHandler({final:"S"},(L=>this.scrollUp(L))),this._parser.registerCsiHandler({final:"T"},(L=>this.scrollDown(L))),this._parser.registerCsiHandler({final:"X"},(L=>this.eraseChars(L))),this._parser.registerCsiHandler({final:"Z"},(L=>this.cursorBackwardTab(L))),this._parser.registerCsiHandler({final:"`"},(L=>this.charPosAbsolute(L))),this._parser.registerCsiHandler({final:"a"},(L=>this.hPositionRelative(L))),this._parser.registerCsiHandler({final:"b"},(L=>this.repeatPrecedingCharacter(L))),this._parser.registerCsiHandler({final:"c"},(L=>this.sendDeviceAttributesPrimary(L))),this._parser.registerCsiHandler({prefix:">",final:"c"},(L=>this.sendDeviceAttributesSecondary(L))),this._parser.registerCsiHandler({final:"d"},(L=>this.linePosAbsolute(L))),this._parser.registerCsiHandler({final:"e"},(L=>this.vPositionRelative(L))),this._parser.registerCsiHandler({final:"f"},(L=>this.hVPosition(L))),this._parser.registerCsiHandler({final:"g"},(L=>this.tabClear(L))),this._parser.registerCsiHandler({final:"h"},(L=>this.setMode(L))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(L=>this.setModePrivate(L))),this._parser.registerCsiHandler({final:"l"},(L=>this.resetMode(L))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(L=>this.resetModePrivate(L))),this._parser.registerCsiHandler({final:"m"},(L=>this.charAttributes(L))),this._parser.registerCsiHandler({final:"n"},(L=>this.deviceStatus(L))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(L=>this.deviceStatusPrivate(L))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(L=>this.softReset(L))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(L=>this.setCursorStyle(L))),this._parser.registerCsiHandler({final:"r"},(L=>this.setScrollRegion(L))),this._parser.registerCsiHandler({final:"s"},(L=>this.saveCursor(L))),this._parser.registerCsiHandler({final:"t"},(L=>this.windowOptions(L))),this._parser.registerCsiHandler({final:"u"},(L=>this.restoreCursor(L))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(L=>this.insertColumns(L))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(L=>this.deleteColumns(L))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(L=>this.selectProtected(L))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(L=>this.requestMode(L,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(L=>this.requestMode(L,!1))),this._parser.setExecuteHandler(o.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(o.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(o.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(o.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(o.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(o.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(o.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(o.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(o.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new w.OscHandler((L=>(this.setTitle(L),this.setIconName(L),!0)))),this._parser.registerOscHandler(1,new w.OscHandler((L=>this.setIconName(L)))),this._parser.registerOscHandler(2,new w.OscHandler((L=>this.setTitle(L)))),this._parser.registerOscHandler(4,new w.OscHandler((L=>this.setOrReportIndexedColor(L)))),this._parser.registerOscHandler(8,new w.OscHandler((L=>this.setHyperlink(L)))),this._parser.registerOscHandler(10,new w.OscHandler((L=>this.setOrReportFgColor(L)))),this._parser.registerOscHandler(11,new w.OscHandler((L=>this.setOrReportBgColor(L)))),this._parser.registerOscHandler(12,new w.OscHandler((L=>this.setOrReportCursorColor(L)))),this._parser.registerOscHandler(104,new w.OscHandler((L=>this.restoreIndexedColor(L)))),this._parser.registerOscHandler(110,new w.OscHandler((L=>this.restoreFgColor(L)))),this._parser.registerOscHandler(111,new w.OscHandler((L=>this.restoreBgColor(L)))),this._parser.registerOscHandler(112,new w.OscHandler((L=>this.restoreCursorColor(L)))),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 L in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:L},(()=>this.selectCharset("("+L))),this._parser.registerEscHandler({intermediates:")",final:L},(()=>this.selectCharset(")"+L))),this._parser.registerEscHandler({intermediates:"*",final:L},(()=>this.selectCharset("*"+L))),this._parser.registerEscHandler({intermediates:"+",final:L},(()=>this.selectCharset("+"+L))),this._parser.registerEscHandler({intermediates:"-",final:L},(()=>this.selectCharset("-"+L))),this._parser.registerEscHandler({intermediates:".",final:L},(()=>this.selectCharset("."+L))),this._parser.registerEscHandler({intermediates:"/",final:L},(()=>this.selectCharset("/"+L)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((L=>(this._logService.error("Parsing error: ",L),L))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((L,F)=>this.requestStatusString(L,F))))}_preserveStack(D,N,P,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=D,this._parseStack.cursorStartY=N,this._parseStack.decodedLength=P,this._parseStack.position=O}_logSlowResolvingAsync(D){this._logService.logLevel<=y.LogLevelEnum.WARN&&Promise.race([D,new Promise(((N,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((N=>{if(N!=="#SLOW_TIMEOUT")throw N;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(D,N){let P,O=this._activeBuffer.x,$=this._activeBuffer.y,K=0;const Q=this._parseStack.paused;if(Q){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,N))return this._logSlowResolvingAsync(P),P;O=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,D.length>T&&(K=this._parseStack.position+T)}if(this._logService.logLevel<=y.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof D=="string"?` "${D}"`:` "${Array.prototype.map.call(D,(G=>String.fromCharCode(G))).join("")}"`),typeof D=="string"?D.split("").map((G=>G.charCodeAt(0))):D),this._parseBuffer.length<D.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(D.length,T))),Q||this._dirtyRowTracker.clearRange(),D.length>T)for(let G=K;G<D.length;G+=T){const ne=G+T<D.length?G+T:D.length,L=typeof D=="string"?this._stringDecoder.decode(D.substring(G,ne),this._parseBuffer):this._utf8Decoder.decode(D.subarray(G,ne),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,L))return this._preserveStack(O,$,L,G),this._logSlowResolvingAsync(P),P}else if(!Q){const G=typeof D=="string"?this._stringDecoder.decode(D,this._parseBuffer):this._utf8Decoder.decode(D,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,G))return this._preserveStack(O,$,G,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===O&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(D,N,P){let O,$;const K=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,G=this._bufferService.cols,ne=this._coreService.decPrivateModes.wraparound,L=this._coreService.modes.insertMode,F=this._curAttrData;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-N>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let W=N;W<P;++W){if(O=D[W],$=this._unicodeService.wcwidth(O),O<127&&K){const Z=K[String.fromCharCode(O)];Z&&(O=Z.charCodeAt(0))}if(Q&&this._onA11yChar.fire((0,g.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=G){if(ne){for(;this._activeBuffer.x<G;)U.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=G-1,$===2)continue}if(L&&(U.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(F),F),U.getWidth(G-1)===2&&U.setCellFromCodePoint(G-1,h.NULL_CELL_CODE,h.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),U.setCellFromCodePoint(this._activeBuffer.x++,O,$,F.fg,F.bg,F.extended),$>0)for(;--$;)U.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else U.getWidth(this._activeBuffer.x-1)?U.addCodepointToCell(this._activeBuffer.x-1,O):U.addCodepointToCell(this._activeBuffer.x-2,O)}P-N>0&&(U.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<G&&P-N>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(D,N){return D.final!=="t"||D.prefix||D.intermediates?this._parser.registerCsiHandler(D,N):this._parser.registerCsiHandler(D,(P=>!A(P.params[0],this._optionsService.rawOptions.windowOptions)||N(P)))}registerDcsHandler(D,N){return this._parser.registerDcsHandler(D,new E.DcsHandler(N))}registerEscHandler(D,N){return this._parser.registerEscHandler(D,N)}registerOscHandler(D,N){return this._parser.registerOscHandler(D,new w.OscHandler(N))}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 D;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&&(!((D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||D===void 0)&&D.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);N.hasWidth(this._activeBuffer.x)&&!N.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const D=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-D),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(D=this._bufferService.cols-1){this._activeBuffer.x=Math.min(D,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(D,N){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=D,this._activeBuffer.y=this._activeBuffer.scrollTop+N):(this._activeBuffer.x=D,this._activeBuffer.y=N),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(D,N){this._restrictCursor(),this._setCursor(this._activeBuffer.x+D,this._activeBuffer.y+N)}cursorUp(D){const N=this._activeBuffer.y-this._activeBuffer.scrollTop;return N>=0?this._moveCursor(0,-Math.min(N,D.params[0]||1)):this._moveCursor(0,-(D.params[0]||1)),!0}cursorDown(D){const N=this._activeBuffer.scrollBottom-this._activeBuffer.y;return N>=0?this._moveCursor(0,Math.min(N,D.params[0]||1)):this._moveCursor(0,D.params[0]||1),!0}cursorForward(D){return this._moveCursor(D.params[0]||1,0),!0}cursorBackward(D){return this._moveCursor(-(D.params[0]||1),0),!0}cursorNextLine(D){return this.cursorDown(D),this._activeBuffer.x=0,!0}cursorPrecedingLine(D){return this.cursorUp(D),this._activeBuffer.x=0,!0}cursorCharAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(D){return this._setCursor(D.length>=2?(D.params[1]||1)-1:0,(D.params[0]||1)-1),!0}charPosAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(D){return this._moveCursor(D.params[0]||1,0),!0}linePosAbsolute(D){return this._setCursor(this._activeBuffer.x,(D.params[0]||1)-1),!0}vPositionRelative(D){return this._moveCursor(0,D.params[0]||1),!0}hVPosition(D){return this.cursorPosition(D),!0}tabClear(D){const N=D.params[0];return N===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:N===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=D.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=D.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(D){const N=D.params[0];return N===1&&(this._curAttrData.bg|=536870912),N!==2&&N!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(D,N,P,O=!1,$=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);K.replaceCells(N,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),O&&(K.isWrapped=!1)}_resetBufferLine(D,N=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),N),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+D),P.isWrapped=!1)}eraseInDisplay(D,N=!1){let P;switch(this._restrictCursor(this._bufferService.cols),D.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,N);P<this._bufferService.rows;P++)this._resetBufferLine(P,N);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,N),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,N);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,N);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(D,N=!1){switch(this._restrictCursor(this._bufferService.cols),D.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,N);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,N);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,N)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(D){this._restrictCursor();let N=D.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,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;N--;)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(D){this._restrictCursor();let N=D.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 O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;N--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(D){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.insertCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(D){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.deleteCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(D){let N=D.params[0]||1;for(;N--;)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(D){let N=D.params[0]||1;for(;N--;)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(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(D){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(D.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(D){if(!this._parser.precedingCodepoint)return!0;const N=D.params[0]||1,P=new Uint32Array(N);for(let O=0;O<N;++O)P[O]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(D){return D.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(D){return D.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(D.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0}_is(D){return(this._optionsService.rawOptions.termName+"").indexOf(D)===0}setMode(D){for(let N=0;N<D.length;N++)switch(D.params[N]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(D){for(let N=0;N<D.length;N++)switch(D.params[N]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.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(D){for(let N=0;N<D.length;N++)switch(D.params[N]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(D){for(let N=0;N<D.length;N++)switch(D.params[N]){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(),D.params[N]===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(D,N){const P=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:$}=this._coreMouseService,K=this._coreService,{buffers:Q,cols:G}=this._bufferService,{active:ne,alt:L}=Q,F=this._optionsService.rawOptions,U=oe=>oe?1:2,W=D.params[0];return Z=W,X=N?W===2?4:W===4?U(K.modes.insertMode):W===12?3:W===20?U(F.convertEol):0:W===1?U(P.applicationCursorKeys):W===3?F.windowOptions.setWinLines?G===80?2:G===132?1:0:0:W===6?U(P.origin):W===7?U(P.wraparound):W===8?3:W===9?U(O==="X10"):W===12?U(F.cursorBlink):W===25?U(!K.isCursorHidden):W===45?U(P.reverseWraparound):W===66?U(P.applicationKeypad):W===67?4:W===1e3?U(O==="VT200"):W===1002?U(O==="DRAG"):W===1003?U(O==="ANY"):W===1004?U(P.sendFocus):W===1005?4:W===1006?U($==="SGR"):W===1015?4:W===1016?U($==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?U(ne===L):W===2004?U(P.bracketedPasteMode):0,K.triggerDataEvent(`${o.C0.ESC}[${N?"":"?"}${Z};${X}$y`),!0;var Z,X}_updateAttrColor(D,N,P,O,$){return N===2?(D|=50331648,D&=-16777216,D|=_.AttributeData.fromColorRGB([P,O,$])):N===5&&(D&=-50331904,D|=33554432|255&P),D}_extractColor(D,N,P){const O=[0,0,-1,0,0,0];let $=0,K=0;do{if(O[K+$]=D.params[N+K],D.hasSubParams(N+K)){const Q=D.getSubParams(N+K);let G=0;do O[1]===5&&($=1),O[K+G+1+$]=Q[G];while(++G<Q.length&&G+K+1+$<O.length);break}if(O[1]===5&&K+$>=2||O[1]===2&&K+$>=5)break;O[1]&&($=1)}while(++K+N<D.length&&K+$<O.length);for(let Q=2;Q<O.length;++Q)O[Q]===-1&&(O[Q]=0);switch(O[0]){case 38:P.fg=this._updateAttrColor(P.fg,O[1],O[3],O[4],O[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,O[1],O[3],O[4],O[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,O[1],O[3],O[4],O[5])}return K}_processUnderline(D,N){N.extended=N.extended.clone(),(!~D||D>5)&&(D=1),N.extended.underlineStyle=D,N.fg|=268435456,D===0&&(N.fg&=-268435457),N.updateExtended()}_processSGR0(D){D.fg=n.DEFAULT_ATTR_DATA.fg,D.bg=n.DEFAULT_ATTR_DATA.bg,D.extended=D.extended.clone(),D.extended.underlineStyle=0,D.extended.underlineColor&=-67108864,D.updateExtended()}charAttributes(D){if(D.length===1&&D.params[0]===0)return this._processSGR0(this._curAttrData),!0;const N=D.length;let P;const O=this._curAttrData;for(let $=0;$<N;$++)P=D.params[$],P>=30&&P<=37?(O.fg&=-50331904,O.fg|=16777216|P-30):P>=40&&P<=47?(O.bg&=-50331904,O.bg|=16777216|P-40):P>=90&&P<=97?(O.fg&=-50331904,O.fg|=16777224|P-90):P>=100&&P<=107?(O.bg&=-50331904,O.bg|=16777224|P-100):P===0?this._processSGR0(O):P===1?O.fg|=134217728:P===3?O.bg|=67108864:P===4?(O.fg|=268435456,this._processUnderline(D.hasSubParams($)?D.getSubParams($)[0]:1,O)):P===5?O.fg|=536870912:P===7?O.fg|=67108864:P===8?O.fg|=1073741824:P===9?O.fg|=2147483648:P===2?O.bg|=134217728:P===21?this._processUnderline(2,O):P===22?(O.fg&=-134217729,O.bg&=-134217729):P===23?O.bg&=-67108865:P===24?(O.fg&=-268435457,this._processUnderline(0,O)):P===25?O.fg&=-536870913:P===27?O.fg&=-67108865:P===28?O.fg&=-1073741825:P===29?O.fg&=2147483647:P===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):P===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(D,$,O):P===53?O.bg|=1073741824:P===55?O.bg&=-1073741825:P===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):P===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(D){switch(D.params[0]){case 5:this._coreService.triggerDataEvent(`${o.C0.ESC}[0n`);break;case 6:const N=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[${N};${P}R`)}return!0}deviceStatusPrivate(D){if(D.params[0]===6){const N=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[?${N};${P}R`)}return!0}softReset(D){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=n.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(D){const N=D.params[0]||1;switch(N){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=N%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(D){const N=D.params[0]||1;let P;return(D.length<2||(P=D.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>N&&(this._activeBuffer.scrollTop=N-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(D){if(!A(D.params[0],this._optionsService.rawOptions.windowOptions))return!0;const N=D.length>1?D.params[1]:0;switch(D.params[0]){case 14:N!==2&&this._onRequestWindowsOptionsReport.fire(j.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(j.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${o.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:N!==0&&N!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),N!==0&&N!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:N!==0&&N!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),N!==0&&N!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(D){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(D){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(D){return this._windowTitle=D,this._onTitleChange.fire(D),!0}setIconName(D){return this._iconName=D,!0}setOrReportIndexedColor(D){const N=[],P=D.split(";");for(;P.length>1;){const O=P.shift(),$=P.shift();if(/^\d+$/.exec(O)){const K=parseInt(O);if(H(K))if($==="?")N.push({type:0,index:K});else{const Q=(0,x.parseColor)($);Q&&N.push({type:1,index:K,color:Q})}}}return N.length&&this._onColor.fire(N),!0}setHyperlink(D){const N=D.split(";");return!(N.length<2)&&(N[1]?this._createHyperlink(N[0],N[1]):!N[0]&&this._finishHyperlink())}_createHyperlink(D,N){this._getCurrentLinkId()&&this._finishHyperlink();const P=D.split(":");let O;const $=P.findIndex((K=>K.startsWith("id=")));return $!==-1&&(O=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:N}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(D,N){const P=D.split(";");for(let O=0;O<P.length&&!(N>=this._specialColors.length);++O,++N)if(P[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[N]}]);else{const $=(0,x.parseColor)(P[O]);$&&this._onColor.fire([{type:1,index:this._specialColors[N],color:$}])}return!0}setOrReportFgColor(D){return this._setOrReportSpecialColor(D,0)}setOrReportBgColor(D){return this._setOrReportSpecialColor(D,1)}setOrReportCursorColor(D){return this._setOrReportSpecialColor(D,2)}restoreIndexedColor(D){if(!D)return this._onColor.fire([{type:2}]),!0;const N=[],P=D.split(";");for(let O=0;O<P.length;++O)if(/^\d+$/.exec(P[O])){const $=parseInt(P[O]);H($)&&N.push({type:2,index:$})}return N.length&&this._onColor.fire(N),!0}restoreFgColor(D){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(D){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(D){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,p.DEFAULT_CHARSET),!0}selectCharset(D){return D.length!==2?(this.selectDefaultCharset(),!0):(D[0]==="/"||this._charsetService.setgCharset(R[D[0]],p.CHARSETS[D[1]]||p.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 D=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,D,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=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(D){return this._charsetService.setgLevel(D),!0}screenAlignmentPattern(){const D=new u.CellData;D.content=4194373,D.fg=this._curAttrData.fg,D.bg=this._curAttrData.bg,this._setCursor(0,0);for(let N=0;N<this._bufferService.rows;++N){const P=this._activeBuffer.ybase+this._activeBuffer.y+N,O=this._activeBuffer.lines.get(P);O&&(O.fill(D),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(D,N){const P=this._bufferService.buffer,O=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${o.C0.ESC}${$}${o.C0.ESC}\\`),!0))(D==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:D==='"p'?'P1$r61;1"p':D==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:D==="m"?"P1$r0m":D===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(D,N){this._dirtyRowTracker.markRangeDirty(D,N)}}i.InputHandler=I;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,D){z>D&&(M=z,z=D,D=M),z<this.start&&(this.start=z),D>this.end&&(this.end=D)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(z){return 0<=z&&z<256}B=c([f(0,y.IBufferService)],B)},844:(C,i)=>{function r(c){for(const f of c)f.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 f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.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=r,i.getDisposeArrayDisposable=function(c){return{dispose:()=>r(c)}}},1505:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class r{constructor(){this._data={}}set(f,o,p){this._data[f]||(this._data[f]={}),this._data[f][o]=p}get(f,o){return this._data[f]?this._data[f][o]:void 0}clear(){this._data={}}}i.TwoKeyMap=r,i.FourKeyMap=class{constructor(){this._data=new r}set(c,f,o,p,b){this._data.get(c,f)||this._data.set(c,f,new r),this._data.get(c,f).set(o,p,b)}get(c,f,o,p){var b;return(b=this._data.get(c,f))===null||b===void 0?void 0:b.get(o,p)}clear(){this._data.clear()}}},6114:(C,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 r=i.isNode?"node":navigator.userAgent,c=i.isNode?"node":navigator.platform;i.isFirefox=r.includes("Firefox"),i.isLegacyEdge=r.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(r),i.getSafariVersion=function(){if(!i.isSafari)return 0;const f=r.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[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(r)},6106:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let r=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(r=this._search(this._getKey(c)),this._array.splice(r,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(r=this._search(f),r===-1)||this._getKey(this._array[r])!==f)return!1;do if(this._array[r]===c)return this._array.splice(r,1),!0;while(++r<this._array.length&&this._getKey(this._array[r])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(r=this._search(c),!(r<0||r>=this._array.length)&&this._getKey(this._array[r])===c))do yield this._array[r];while(++r<this._array.length&&this._getKey(this._array[r])===c)}forEachByKey(c,f){if(this._array.length!==0&&(r=this._search(c),!(r<0||r>=this._array.length)&&this._getKey(this._array[r])===c))do f(this._array[r]);while(++r<this._array.length&&this._getKey(this._array[r])===c)}values(){return[...this._array].values()}_search(c){let f=0,o=this._array.length-1;for(;o>=f;){let p=f+o>>1;const b=this._getKey(this._array[p]);if(b>c)o=p-1;else{if(!(b<c)){for(;p>0&&this._getKey(this._array[p-1])===c;)p--;return p}f=p+1}}return f}}},7226:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=r(6114);class f{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,g=0,n=b.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),g=Math.max(S,g),d=b.timeRemaining(),1.5*g>d)return n-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-S))}ms`),void this._start();n=d}this.clear()}}class o extends f{_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=o,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:o,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=r(643);i.updateWindowsModeWrappedState=function(f){const o=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=o?.get(f.cols-1),b=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);b&&p&&(b.isWrapped=p[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&p[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class r{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(o){return[o>>>16&255,o>>>8&255,255&o]}static fromColorRGB(o){return(255&o[0])<<16|(255&o[1])<<8|255&o[2]}clone(){const o=new r;return o.fg=this.fg,o.bg=this.bg,o.extended=this.extended.clone(),o}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=r;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(o){this._ext=o}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(o){this._ext&=-469762049,this._ext|=o<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(o){this._ext&=-67108864,this._ext|=67108863&o}get urlId(){return this._urlId}set urlId(o){this._urlId=o}constructor(o=0,p=0){this._ext=0,this._urlId=0,this._ext=o,this._urlId=p}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=c},9092:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=r(6349),f=r(7226),o=r(3734),p=r(8437),b=r(4634),S=r(511),g=r(643),n=r(4863),d=r(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(h,u,_){this._hasScrollback=h,this._optionsService=u,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,g.WHITESPACE_CELL_CHAR,g.WHITESPACE_CELL_WIDTH,g.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.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(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new o.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new o.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,u){return new p.BufferLine(this._bufferService.cols,this.getNullCell(h),u)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;const u=h+this._optionsService.rawOptions.scrollback;return u>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:u}fillViewportRows(h){if(this.lines.length===0){h===void 0&&(h=p.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(h))}}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(h,u){const _=this.getNullCell(p.DEFAULT_ATTR_DATA);let y=0;const w=this._getCorrectBufferLength(u);if(w>this.lines.maxLength&&(this.lines.maxLength=w),this.lines.length>0){if(this._cols<h)for(let x=0;x<this.lines.length;x++)y+=+this.lines.get(x).resize(h,_);let E=0;if(this._rows<u)for(let x=this._rows;x<u;x++)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 p.BufferLine(h,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(h,_)));else for(let x=this._rows;x>u;x--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(w<this.lines.maxLength){const x=this.lines.length-w;x>0&&(this.lines.trimStart(x),this.ybase=Math.max(this.ybase-x,0),this.ydisp=Math.max(this.ydisp-x,0),this.savedY=Math.max(this.savedY-x,0)),this.lines.maxLength=w}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,u-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(h,u),this._cols>h))for(let E=0;E<this.lines.length;E++)y+=+this.lines.get(E).resize(h,_);this._cols=h,this._rows=u,this._memoryCleanupQueue.clear(),y>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let h=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,h=!1);let u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>100)return!0;return h}get _isReflowEnabled(){const h=this._optionsService.rawOptions.windowsPty;return h&&h.buildNumber?this._hasScrollback&&h.backend==="conpty"&&h.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(h,u){this._cols!==h&&(h>this._cols?this._reflowLarger(h,u):this._reflowSmaller(h,u))}_reflowLarger(h,u){const _=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(_.length>0){const y=(0,b.reflowLargerCreateNewLayout)(this.lines,_);(0,b.reflowLargerApplyNewLayout)(this.lines,y.layout),this._reflowLargerAdjustViewport(h,u,y.countRemoved)}}_reflowLargerAdjustViewport(h,u,_){const y=this.getNullCell(p.DEFAULT_ATTR_DATA);let w=_;for(;w-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new p.BufferLine(h,y))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(h,u){const _=this.getNullCell(p.DEFAULT_ATTR_DATA),y=[];let w=0;for(let E=this.lines.length-1;E>=0;E--){let x=this.lines.get(E);if(!x||!x.isWrapped&&x.getTrimmedLength()<=h)continue;const R=[x];for(;x.isWrapped&&E>0;)x=this.lines.get(--E),R.unshift(x);const T=this.ybase+this.y;if(T>=E&&T<E+R.length)continue;const A=R[R.length-1].getTrimmedLength(),j=(0,b.reflowSmallerGetNewLineLengths)(R,this._cols,h),M=j.length-R.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const B=[];for(let O=0;O<M;O++){const $=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);B.push($)}B.length>0&&(y.push({start:E+R.length+w,newLines:B}),w+=B.length),R.push(...B);let H=j.length-1,z=j[H];z===0&&(H--,z=j[H]);let D=R.length-M-1,N=A;for(;D>=0;){const O=Math.min(N,z);if(R[H]===void 0)break;if(R[H].copyCellsFrom(R[D],N-O,z-O,O,!0),z-=O,z===0&&(H--,z=j[H]),N-=O,N===0){D--;const $=Math.max(D,0);N=(0,b.getWrappedLineTrimmedLength)(R,$,this._cols)}}for(let O=0;O<R.length;O++)j[O]<h&&R[O].setCell(j[O],_);let P=M-I;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+w)-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 E=[],x=[];for(let H=0;H<this.lines.length;H++)x.push(this.lines.get(H));const R=this.lines.length;let T=R-1,A=0,j=y[A];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+w);let M=0;for(let H=Math.min(this.lines.maxLength-1,R+w-1);H>=0;H--)if(j&&j.start>T+M){for(let z=j.newLines.length-1;z>=0;z--)this.lines.set(H--,j.newLines[z]);H++,E.push({index:T+1,amount:j.newLines.length}),M+=j.newLines.length,j=y[++A]}else this.lines.set(H,x[T--]);let I=0;for(let H=E.length-1;H>=0;H--)E[H].index+=I,this.lines.onInsertEmitter.fire(E[H]),I+=E[H].amount;const B=Math.max(0,R+w-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(h,u,_=0,y){const w=this.lines.get(h);return w?w.translateToString(u,_,y):""}getWrappedRangeForLine(h){let u=h,_=h;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:u,last:_}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].line===h&&(this.markers[u].dispose(),this.markers.splice(u--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose(),this.markers.splice(h--,1);this._isClearing=!1}addMarker(h){const u=new n.Marker(h);return this.markers.push(u),u.register(this.lines.onTrim((_=>{u.line-=_,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((_=>{u.line>=_.index&&(u.line+=_.amount)}))),u.register(this.lines.onDelete((_=>{u.line>=_.index&&u.line<_.index+_.amount&&u.dispose(),u.line>_.index&&(u.line-=_.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},8437:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=r(3734),f=r(511),o=r(643),p=r(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let b=0;class S{constructor(n,d,h=!1){this.isWrapped=h,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const u=d||f.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]);for(let _=0;_<n;++_)this.setCell(_,u);this.length=n}get(n){const d=this._data[3*n+0],h=2097151&d;return[this._data[3*n+1],2097152&d?this._combined[n]:h?(0,p.stringFromCodePoint)(h):"",d>>22,2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):h]}set(n,d){this._data[3*n+1]=d[o.CHAR_DATA_ATTR_INDEX],d[o.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=d[1],this._data[3*n+0]=2097152|n|d[o.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=d[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[o.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&d}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n]:2097151&d?(0,p.stringFromCodePoint)(2097151&d):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,d){return b=3*n,d.content=this._data[b+0],d.fg=this._data[b+1],d.bg=this._data[b+2],2097152&d.content&&(d.combinedData=this._combined[n]),268435456&d.bg&&(d.extended=this._extendedAttrs[n]),d}setCell(n,d){2097152&d.content&&(this._combined[n]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[n]=d.extended),this._data[3*n+0]=d.content,this._data[3*n+1]=d.fg,this._data[3*n+2]=d.bg}setCellFromCodePoint(n,d,h,u,_,y){268435456&_&&(this._extendedAttrs[n]=y),this._data[3*n+0]=d|h<<22,this._data[3*n+1]=u,this._data[3*n+2]=_}addCodepointToCell(n,d){let h=this._data[3*n+0];2097152&h?this._combined[n]+=(0,p.stringFromCodePoint)(d):(2097151&h?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&h)+(0,p.stringFromCodePoint)(d),h&=-2097152,h|=2097152):h=d|4194304,this._data[3*n+0]=h)}insertCells(n,d,h,u){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length-n){const _=new f.CellData;for(let y=this.length-n-d-1;y>=0;--y)this.setCell(n+d+y,this.loadCell(n+y,_));for(let y=0;y<d;++y)this.setCell(n+y,h)}else for(let _=n;_<this.length;++_)this.setCell(_,h);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(n,d,h,u){if(n%=this.length,d<this.length-n){const _=new f.CellData;for(let y=0;y<this.length-n-d;++y)this.setCell(n+y,this.loadCell(n+d+y,_));for(let y=this.length-d;y<this.length;++y)this.setCell(y,h)}else for(let _=n;_<this.length;++_)this.setCell(_,h);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(n,d,h,u,_=!1){if(_)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<d&&n<this.length;)this.isProtected(n)||this.setCell(n,h),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<d&&n<this.length;)this.setCell(n++,h)}resize(n,d){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const h=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*h)this._data=new Uint32Array(this._data.buffer,0,h);else{const u=new Uint32Array(h);u.set(this._data),this._data=u}for(let u=this.length;u<n;++u)this.setCell(u,d)}else{this._data=this._data.subarray(0,h);const u=Object.keys(this._combined);for(let y=0;y<u.length;y++){const w=parseInt(u[y],10);w>=n&&delete this._combined[w]}const _=Object.keys(this._extendedAttrs);for(let y=0;y<_.length;y++){const w=parseInt(_[y],10);w>=n&&delete this._extendedAttrs[w]}}return this.length=n,4*h*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,d=!1){if(d)for(let h=0;h<this.length;++h)this.isProtected(h)||this.setCell(h,n);else{this._combined={},this._extendedAttrs={};for(let h=0;h<this.length;++h)this.setCell(h,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const d in n._combined)this._combined[d]=n._combined[d];this._extendedAttrs={};for(const d in n._extendedAttrs)this._extendedAttrs[d]=n._extendedAttrs[d];this.isWrapped=n.isWrapped}clone(){const n=new S(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const d in this._combined)n._combined[d]=this._combined[d];for(const d in this._extendedAttrs)n._extendedAttrs[d]=this._extendedAttrs[d];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,d,h,u,_){const y=n._data;if(_)for(let E=u-1;E>=0;E--){for(let x=0;x<3;x++)this._data[3*(h+E)+x]=y[3*(d+E)+x];268435456&y[3*(d+E)+2]&&(this._extendedAttrs[h+E]=n._extendedAttrs[d+E])}else for(let E=0;E<u;E++){for(let x=0;x<3;x++)this._data[3*(h+E)+x]=y[3*(d+E)+x];268435456&y[3*(d+E)+2]&&(this._extendedAttrs[h+E]=n._extendedAttrs[d+E])}const w=Object.keys(n._combined);for(let E=0;E<w.length;E++){const x=parseInt(w[E],10);x>=d&&(this._combined[x-d+h]=n._combined[x])}}translateToString(n=!1,d=0,h=this.length){n&&(h=Math.min(h,this.getTrimmedLength()));let u="";for(;d<h;){const _=this._data[3*d+0],y=2097151&_;u+=2097152&_?this._combined[d]:y?(0,p.stringFromCodePoint)(y):o.WHITESPACE_CELL_CHAR,d+=_>>22||1}return u}}i.BufferLine=S},4841:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(r,c){if(r.start.y>r.end.y)throw new Error(`Buffer range end (${r.end.x}, ${r.end.y}) cannot be before start (${r.start.x}, ${r.start.y})`);return c*(r.end.y-r.start.y)+(r.end.x-r.start.x+1)}},4634:(C,i)=>{function r(c,f,o){if(f===c.length-1)return c[f].getTrimmedLength();const p=!c[f].hasContent(o-1)&&c[f].getWidth(o-1)===1,b=c[f+1].getWidth(0)===2;return p&&b?o-1:o}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,f,o,p,b){const S=[];for(let g=0;g<c.length-1;g++){let n=g,d=c.get(++n);if(!d.isWrapped)continue;const h=[c.get(g)];for(;n<c.length&&d.isWrapped;)h.push(d),d=c.get(++n);if(p>=g&&p<n){g+=h.length-1;continue}let u=0,_=r(h,u,f),y=1,w=0;for(;y<h.length;){const x=r(h,y,f),R=x-w,T=o-_,A=Math.min(R,T);h[u].copyCellsFrom(h[y],w,_,A,!1),_+=A,_===o&&(u++,_=0),w+=A,w===x&&(y++,w=0),_===0&&u!==0&&h[u-1].getWidth(o-1)===2&&(h[u].copyCellsFrom(h[u-1],o-1,_++,1,!1),h[u-1].setCell(o-1,b))}h[u].replaceCells(_,o,b);let E=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)E++;E>0&&(S.push(g+h.length-E),S.push(E)),g+=h.length-1}return S},i.reflowLargerCreateNewLayout=function(c,f){const o=[];let p=0,b=f[p],S=0;for(let g=0;g<c.length;g++)if(b===g){const n=f[++p];c.onDeleteEmitter.fire({index:g-S,amount:n}),g+=n-1,S+=n,b=f[++p]}else o.push(g);return{layout:o,countRemoved:S}},i.reflowLargerApplyNewLayout=function(c,f){const o=[];for(let p=0;p<f.length;p++)o.push(c.get(f[p]));for(let p=0;p<o.length;p++)c.set(p,o[p]);c.length=f.length},i.reflowSmallerGetNewLineLengths=function(c,f,o){const p=[],b=c.map(((d,h)=>r(c,h,f))).reduce(((d,h)=>d+h));let S=0,g=0,n=0;for(;n<b;){if(b-n<o){p.push(b-n);break}S+=o;const d=r(c,g,f);S>d&&(S-=d,g++);const h=c[g].getWidth(S-1)===2;h&&S--;const u=h?o-1:o;p.push(u),n+=u}return p},i.getWrappedLineTrimmedLength=r},5295:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=r(8460),f=r(844),o=r(9092);class p extends f.Disposable{constructor(S,g){super(),this._optionsService=S,this._bufferService=g,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 o.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.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,g){this._normal.resize(S,g),this._alt.resize(S,g),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}i.BufferSet=p},511:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=r(482),f=r(643),o=r(3734);class p extends o.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new o.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const g=new p;return g.setFromCharData(S),g}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[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let g=!1;if(S[f.CHAR_DATA_CHAR_INDEX].length>2)g=!0;else if(S[f.CHAR_DATA_CHAR_INDEX].length===2){const n=S[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const d=S[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(n-55296)+d-56320+65536|S[f.CHAR_DATA_WIDTH_INDEX]<<22:g=!0}else g=!0}else this.content=S[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[f.CHAR_DATA_WIDTH_INDEX]<<22;g&&(this.combinedData=S[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=p},643:(C,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:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=r(8460),f=r(844);class o{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=o._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,f.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}i.Marker=o,o._nextId=1},7116:(C,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:(C,i)=>{var r,c,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(o){o.NUL="\0",o.SOH="",o.STX="",o.ETX="",o.EOT="",o.ENQ="",o.ACK="",o.BEL="\x07",o.BS="\b",o.HT=" ",o.LF=`
|
|
18
|
-
`,o.VT="\v",o.FF="\f",o.CR="\r",o.SO="",o.SI="",o.DLE="",o.DC1="",o.DC2="",o.DC3="",o.DC4="",o.NAK="",o.SYN="",o.ETB="",o.CAN="",o.EM="",o.SUB="",o.ESC="\x1B",o.FS="",o.GS="",o.RS="",o.US="",o.SP=" ",o.DEL=""})(r||(i.C0=r={})),(function(o){o.PAD="",o.HOP="",o.BPH="",o.NBH="",o.IND="",o.NEL="
",o.SSA="",o.ESA="",o.HTS="",o.HTJ="",o.VTS="",o.PLD="",o.PLU="",o.RI="",o.SS2="",o.SS3="",o.DCS="",o.PU1="",o.PU2="",o.STS="",o.CCH="",o.MW="",o.SPA="",o.EPA="",o.SOS="",o.SGCI="",o.SCI="",o.CSI="",o.ST="",o.OSC="",o.PM="",o.APC=""})(c||(i.C1=c={})),(function(o){o.ST=`${r.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=r(2584),f={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(o,p,b,S){const g={type:0,cancel:!1,key:void 0},n=(o.shiftKey?1:0)|(o.altKey?2:0)|(o.ctrlKey?4:0)|(o.metaKey?8:0);switch(o.keyCode){case 0:o.key==="UIKeyInputUpArrow"?g.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A":o.key==="UIKeyInputLeftArrow"?g.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D":o.key==="UIKeyInputRightArrow"?g.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C":o.key==="UIKeyInputDownArrow"&&(g.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(o.altKey){g.key=c.C0.ESC+c.C0.DEL;break}g.key=c.C0.DEL;break;case 9:if(o.shiftKey){g.key=c.C0.ESC+"[Z";break}g.key=c.C0.HT,g.cancel=!0;break;case 13:g.key=o.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,g.cancel=!0;break;case 27:g.key=c.C0.ESC,o.altKey&&(g.key=c.C0.ESC+c.C0.ESC),g.cancel=!0;break;case 37:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"D",g.key===c.C0.ESC+"[1;3D"&&(g.key=c.C0.ESC+(b?"b":"[1;5D"))):g.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"C",g.key===c.C0.ESC+"[1;3C"&&(g.key=c.C0.ESC+(b?"f":"[1;5C"))):g.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"A",b||g.key!==c.C0.ESC+"[1;3A"||(g.key=c.C0.ESC+"[1;5A")):g.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"B",b||g.key!==c.C0.ESC+"[1;3B"||(g.key=c.C0.ESC+"[1;5B")):g.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:o.shiftKey||o.ctrlKey||(g.key=c.C0.ESC+"[2~");break;case 46:g.key=n?c.C0.ESC+"[3;"+(n+1)+"~":c.C0.ESC+"[3~";break;case 36:g.key=n?c.C0.ESC+"[1;"+(n+1)+"H":p?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:g.key=n?c.C0.ESC+"[1;"+(n+1)+"F":p?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:o.shiftKey?g.type=2:o.ctrlKey?g.key=c.C0.ESC+"[5;"+(n+1)+"~":g.key=c.C0.ESC+"[5~";break;case 34:o.shiftKey?g.type=3:o.ctrlKey?g.key=c.C0.ESC+"[6;"+(n+1)+"~":g.key=c.C0.ESC+"[6~";break;case 112:g.key=n?c.C0.ESC+"[1;"+(n+1)+"P":c.C0.ESC+"OP";break;case 113:g.key=n?c.C0.ESC+"[1;"+(n+1)+"Q":c.C0.ESC+"OQ";break;case 114:g.key=n?c.C0.ESC+"[1;"+(n+1)+"R":c.C0.ESC+"OR";break;case 115:g.key=n?c.C0.ESC+"[1;"+(n+1)+"S":c.C0.ESC+"OS";break;case 116:g.key=n?c.C0.ESC+"[15;"+(n+1)+"~":c.C0.ESC+"[15~";break;case 117:g.key=n?c.C0.ESC+"[17;"+(n+1)+"~":c.C0.ESC+"[17~";break;case 118:g.key=n?c.C0.ESC+"[18;"+(n+1)+"~":c.C0.ESC+"[18~";break;case 119:g.key=n?c.C0.ESC+"[19;"+(n+1)+"~":c.C0.ESC+"[19~";break;case 120:g.key=n?c.C0.ESC+"[20;"+(n+1)+"~":c.C0.ESC+"[20~";break;case 121:g.key=n?c.C0.ESC+"[21;"+(n+1)+"~":c.C0.ESC+"[21~";break;case 122:g.key=n?c.C0.ESC+"[23;"+(n+1)+"~":c.C0.ESC+"[23~";break;case 123:g.key=n?c.C0.ESC+"[24;"+(n+1)+"~":c.C0.ESC+"[24~";break;default:if(!o.ctrlKey||o.shiftKey||o.altKey||o.metaKey)if(b&&!S||!o.altKey||o.metaKey)!b||o.altKey||o.ctrlKey||o.shiftKey||!o.metaKey?o.key&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&o.keyCode>=48&&o.key.length===1?g.key=o.key:o.key&&o.ctrlKey&&(o.key==="_"&&(g.key=c.C0.US),o.key==="@"&&(g.key=c.C0.NUL)):o.keyCode===65&&(g.type=1);else{const d=f[o.keyCode],h=d?.[o.shiftKey?1:0];if(h)g.key=c.C0.ESC+h;else if(o.keyCode>=65&&o.keyCode<=90){const u=o.ctrlKey?o.keyCode-64:o.keyCode+32;let _=String.fromCharCode(u);o.shiftKey&&(_=_.toUpperCase()),g.key=c.C0.ESC+_}else if(o.keyCode===32)g.key=c.C0.ESC+(o.ctrlKey?c.C0.NUL:" ");else if(o.key==="Dead"&&o.code.startsWith("Key")){let u=o.code.slice(3,4);o.shiftKey||(u=u.toLowerCase()),g.key=c.C0.ESC+u,g.cancel=!0}}else o.keyCode>=65&&o.keyCode<=90?g.key=String.fromCharCode(o.keyCode-64):o.keyCode===32?g.key=c.C0.NUL:o.keyCode>=51&&o.keyCode<=55?g.key=String.fromCharCode(o.keyCode-51+27):o.keyCode===56?g.key=c.C0.DEL:o.keyCode===219?g.key=c.C0.ESC:o.keyCode===220?g.key=c.C0.FS:o.keyCode===221&&(g.key=c.C0.GS)}return g}},482:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(r){return r>65535?(r-=65536,String.fromCharCode(55296+(r>>10))+String.fromCharCode(r%1024+56320)):String.fromCharCode(r)},i.utf32ToString=function(r,c=0,f=r.length){let o="";for(let p=c;p<f;++p){let b=r[p];b>65535?(b-=65536,o+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):o+=String.fromCharCode(b)}return o},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(r,c){const f=r.length;if(!f)return 0;let o=0,p=0;if(this._interim){const b=r.charCodeAt(p++);56320<=b&&b<=57343?c[o++]=1024*(this._interim-55296)+b-56320+65536:(c[o++]=this._interim,c[o++]=b),this._interim=0}for(let b=p;b<f;++b){const S=r.charCodeAt(b);if(55296<=S&&S<=56319){if(++b>=f)return this._interim=S,o;const g=r.charCodeAt(b);56320<=g&&g<=57343?c[o++]=1024*(S-55296)+g-56320+65536:(c[o++]=S,c[o++]=g)}else S!==65279&&(c[o++]=S)}return o}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(r,c){const f=r.length;if(!f)return 0;let o,p,b,S,g=0,n=0,d=0;if(this.interim[0]){let _=!1,y=this.interim[0];y&=(224&y)==192?31:(240&y)==224?15:7;let w,E=0;for(;(w=63&this.interim[++E])&&E<4;)y<<=6,y|=w;const x=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,R=x-E;for(;d<R;){if(d>=f)return 0;if(w=r[d++],(192&w)!=128){d--,_=!0;break}this.interim[E++]=w,y<<=6,y|=63&w}_||(x===2?y<128?d--:c[g++]=y:x===3?y<2048||y>=55296&&y<=57343||y===65279||(c[g++]=y):y<65536||y>1114111||(c[g++]=y)),this.interim.fill(0)}const h=f-4;let u=d;for(;u<f;){for(;!(!(u<h)||128&(o=r[u])||128&(p=r[u+1])||128&(b=r[u+2])||128&(S=r[u+3]));)c[g++]=o,c[g++]=p,c[g++]=b,c[g++]=S,u+=4;if(o=r[u++],o<128)c[g++]=o;else if((224&o)==192){if(u>=f)return this.interim[0]=o,g;if(p=r[u++],(192&p)!=128){u--;continue}if(n=(31&o)<<6|63&p,n<128){u--;continue}c[g++]=n}else if((240&o)==224){if(u>=f)return this.interim[0]=o,g;if(p=r[u++],(192&p)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,g;if(b=r[u++],(192&b)!=128){u--;continue}if(n=(15&o)<<12|(63&p)<<6|63&b,n<2048||n>=55296&&n<=57343||n===65279)continue;c[g++]=n}else if((248&o)==240){if(u>=f)return this.interim[0]=o,g;if(p=r[u++],(192&p)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,g;if(b=r[u++],(192&b)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,this.interim[2]=b,g;if(S=r[u++],(192&S)!=128){u--;continue}if(n=(7&o)<<18|(63&p)<<12|(63&b)<<6|63&S,n<65536||n>1114111)continue;c[g++]=n}}return g}}},225:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const r=[[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 f;i.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let o=0;o<r.length;++o)f.fill(0,r[o][0],r[o][1]+1)}}wcwidth(o){return o<32?0:o<127?1:o<65536?f[o]:(function(p,b){let S,g=0,n=b.length-1;if(p<b[0][0]||p>b[n][1])return!1;for(;n>=g;)if(S=g+n>>1,p>b[S][1])g=S+1;else{if(!(p<b[S][0]))return!0;n=S-1}return!1})(o,c)?0:o>=131072&&o<=196605||o>=196608&&o<=262141?2:1}}},5981:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=r(8460),f=r(844);class o extends f.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 g;for(this._isSyncWriting=!0;g=this._writeBuffer.shift();){this._action(g);const n=this._callbacks.shift();n&&n()}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 g=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],d=this._action(n,S);if(d){const u=_=>Date.now()-g>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(g,_);return void d.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(u)}const h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-g>=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=o},5941:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const r=/^([\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 f(o,p){const b=o.toString(16),S=b.length<2?"0"+b:b;switch(p){case 4:return b[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}i.parseColor=function(o){if(!o)return;let p=o.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const b=r.exec(p);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(p.indexOf("#")===0&&(p=p.slice(1),c.exec(p)&&[3,6,9,12].includes(p.length))){const b=p.length/3,S=[0,0,0];for(let g=0;g<3;++g){const n=parseInt(p.slice(b*g,b*g+b),16);S[g]=b===1?n<<4:b===2?n:b===3?n>>4:n>>8}return S}},i.toRgbString=function(o,p=16){const[b,S,g]=o;return`rgb:${f(b,p)}/${f(S,p)}/${f(g,p)}`}},5770:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=r(482),f=r(8742),o=r(5770),p=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(S,g){this._handlers[S]===void 0&&(this._handlers[S]=[]);const n=this._handlers[S];return n.push(g),{dispose:()=>{const d=n.indexOf(g);d!==-1&&n.splice(d,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=p,this._ident=0}hook(S,g){if(this.reset(),this._ident=S,this._active=this._handlers[S]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(g);else this._handlerFb(this._ident,"HOOK",g)}put(S,g,n){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(S,g,n);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(S,g,n))}unhook(S,g=!0){if(this._active.length){let n=!1,d=this._active.length-1,h=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,n=g,h=this._stack.fallThrough,this._stack.paused=!1),!h&&n===!1){for(;d>=0&&(n=this._active[d].unhook(S),n!==!0);d--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,n;d--}for(;d>=0;d--)if(n=this._active[d].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",S);this._active=p,this._ident=0}};const b=new f.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,g,n){this._hitLimit||(this._data+=(0,c.utf32ToString)(S,g,n),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let g=!1;if(this._hitLimit)g=!1;else if(S&&(g=this._handler(this._data,this._params),g instanceof Promise))return g.then((n=>(this._params=b,this._data="",this._hitLimit=!1,n)));return this._params=b,this._data="",this._hitLimit=!1,g}}},2015:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=r(844),f=r(8742),o=r(6242),p=r(6351);class b{constructor(d){this.table=new Uint8Array(d)}setDefault(d,h){this.table.fill(d<<4|h)}add(d,h,u,_){this.table[h<<8|d]=u<<4|_}addMany(d,h,u,_){for(let y=0;y<d.length;y++)this.table[h<<8|d[y]]=u<<4|_}}i.TransitionTable=b;const S=160;i.VT500_TRANSITION_TABLE=(function(){const n=new b(4095),d=Array.apply(null,Array(256)).map(((E,x)=>x)),h=(E,x)=>d.slice(E,x),u=h(32,127),_=h(0,24);_.push(25),_.push.apply(_,h(28,32));const y=h(0,14);let w;for(w in n.setDefault(1,0),n.addMany(u,0,2,0),y)n.addMany([24,26,153,154],w,3,0),n.addMany(h(128,144),w,3,0),n.addMany(h(144,152),w,3,0),n.add(156,w,0,0),n.add(27,w,11,1),n.add(157,w,4,8),n.addMany([152,158,159],w,0,7),n.add(155,w,11,3),n.add(144,w,11,9);return n.addMany(_,0,3,0),n.addMany(_,1,3,1),n.add(127,1,0,1),n.addMany(_,8,0,8),n.addMany(_,3,3,3),n.add(127,3,0,3),n.addMany(_,4,3,4),n.add(127,4,0,4),n.addMany(_,6,3,6),n.addMany(_,5,3,5),n.add(127,5,0,5),n.addMany(_,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(u,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(h(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(u,7,0,7),n.addMany(_,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(h(64,127),3,7,0),n.addMany(h(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(h(48,60),4,8,4),n.addMany(h(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(h(32,64),6,0,6),n.add(127,6,0,6),n.addMany(h(64,127),6,0,0),n.addMany(h(32,48),3,9,5),n.addMany(h(32,48),5,9,5),n.addMany(h(48,64),5,0,6),n.addMany(h(64,127),5,7,0),n.addMany(h(32,48),4,9,5),n.addMany(h(32,48),1,9,2),n.addMany(h(32,48),2,9,2),n.addMany(h(48,127),2,10,0),n.addMany(h(48,80),1,10,0),n.addMany(h(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(h(96,127),1,10,0),n.add(80,1,11,9),n.addMany(_,9,0,9),n.add(127,9,0,9),n.addMany(h(28,32),9,0,9),n.addMany(h(32,48),9,9,12),n.addMany(h(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(_,11,0,11),n.addMany(h(32,128),11,0,11),n.addMany(h(28,32),11,0,11),n.addMany(_,10,0,10),n.add(127,10,0,10),n.addMany(h(28,32),10,0,10),n.addMany(h(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(h(32,48),10,9,12),n.addMany(_,12,0,12),n.add(127,12,0,12),n.addMany(h(28,32),12,0,12),n.addMany(h(32,48),12,9,12),n.addMany(h(48,64),12,0,11),n.addMany(h(64,127),12,12,13),n.addMany(h(64,127),10,12,13),n.addMany(h(64,127),9,12,13),n.addMany(_,13,13,13),n.addMany(u,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(S,0,2,0),n.add(S,8,5,8),n.add(S,6,0,6),n.add(S,11,0,11),n.add(S,13,13,13),n})();class g extends c.Disposable{constructor(d=i.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(h,u,_)=>{},this._executeHandlerFb=h=>{},this._csiHandlerFb=(h,u)=>{},this._escHandlerFb=h=>{},this._errorHandlerFb=h=>h,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 o.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(d,h=[64,126]){let u=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=d.prefix.charCodeAt(0),u&&60>u||u>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let y=0;y<d.intermediates.length;++y){const w=d.intermediates.charCodeAt(y);if(32>w||w>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=w}}if(d.final.length!==1)throw new Error("final must be a single byte");const _=d.final.charCodeAt(0);if(h[0]>_||_>h[1])throw new Error(`final must be in range ${h[0]} .. ${h[1]}`);return u<<=8,u|=_,u}identToString(d){const h=[];for(;d;)h.push(String.fromCharCode(255&d)),d>>=8;return h.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,h){const u=this._identifier(d,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const _=this._escHandlers[u];return _.push(h),{dispose:()=>{const y=_.indexOf(h);y!==-1&&_.splice(y,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,h){this._executeHandlers[d.charCodeAt(0)]=h}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,h){const u=this._identifier(d);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const _=this._csiHandlers[u];return _.push(h),{dispose:()=>{const y=_.indexOf(h);y!==-1&&_.splice(y,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,h){return this._dcsParser.registerHandler(this._identifier(d),h)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,h){return this._oscParser.registerHandler(d,h)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}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(d,h,u,_,y){this._parseStack.state=d,this._parseStack.handlers=h,this._parseStack.handlerPos=u,this._parseStack.transition=_,this._parseStack.chunkPos=y}parse(d,h,u){let _,y=0,w=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=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 x=this._parseStack.handlers;let R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&R>-1){for(;R>=0&&(_=x[R](this._params),_!==!0);R--)if(_ instanceof Promise)return this._parseStack.handlerPos=R,_}this._parseStack.handlers=[];break;case 4:if(u===!1&&R>-1){for(;R>=0&&(_=x[R](),_!==!0);R--)if(_ instanceof Promise)return this._parseStack.handlerPos=R,_}this._parseStack.handlers=[];break;case 6:if(y=d[this._parseStack.chunkPos],_=this._dcsParser.unhook(y!==24&&y!==26,u),_)return _;y===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(y=d[this._parseStack.chunkPos],_=this._oscParser.end(y!==24&&y!==26,u),_)return _;y===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let x=E;x<h;++x){switch(y=d[x],w=this._transitions.table[this.currentState<<8|(y<160?y:S)],w>>4){case 2:for(let M=x+1;;++M){if(M>=h||(y=d[M])<32||y>126&&y<S){this._printHandler(d,x,M),x=M-1;break}if(++M>=h||(y=d[M])<32||y>126&&y<S){this._printHandler(d,x,M),x=M-1;break}if(++M>=h||(y=d[M])<32||y>126&&y<S){this._printHandler(d,x,M),x=M-1;break}if(++M>=h||(y=d[M])<32||y>126&&y<S){this._printHandler(d,x,M),x=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:x,code:y,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const R=this._csiHandlers[this._collect<<8|y];let T=R?R.length-1:-1;for(;T>=0&&(_=R[T](this._params),_!==!0);T--)if(_ instanceof Promise)return this._preserveStack(3,R,T,w,x),_;T<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(++x<h&&(y=d[x])>47&&y<60);x--;break;case 9:this._collect<<=8,this._collect|=y;break;case 10:const A=this._escHandlers[this._collect<<8|y];let j=A?A.length-1:-1;for(;j>=0&&(_=A[j](),_!==!0);j--)if(_ instanceof Promise)return this._preserveStack(4,A,j,w,x),_;j<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=x+1;;++M)if(M>=h||(y=d[M])===24||y===26||y===27||y>127&&y<S){this._dcsParser.put(d,x,M),x=M-1;break}break;case 14:if(_=this._dcsParser.unhook(y!==24&&y!==26),_)return this._preserveStack(6,[],0,w,x),_;y===27&&(w|=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=x+1;;M++)if(M>=h||(y=d[M])<32||y>127&&y<S){this._oscParser.put(d,x,M),x=M-1;break}break;case 6:if(_=this._oscParser.end(y!==24&&y!==26),_)return this._preserveStack(5,[],0,w,x),_;y===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&w}}}i.EscapeSequenceParser=g},6242:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=r(5770),f=r(482),o=[];i.OscParser=class{constructor(){this._state=0,this._active=o,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,b){this._handlers[p]===void 0&&(this._handlers[p]=[]);const S=this._handlers[p];return S.push(b),{dispose:()=>{const g=S.indexOf(b);g!==-1&&S.splice(g,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||o,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,b,S){if(this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].put(p,b,S);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,b,S))}start(){this.reset(),this._state=1}put(p,b,S){if(this._state!==3){if(this._state===1)for(;b<S;){const g=p[b++];if(g===59){this._state=2,this._start();break}if(g<48||57<g)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+g-48}this._state===2&&S-b>0&&this._put(p,b,S)}}end(p,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,g=this._active.length-1,n=!1;if(this._stack.paused&&(g=this._stack.loopPosition-1,S=b,n=this._stack.fallThrough,this._stack.paused=!1),!n&&S===!1){for(;g>=0&&(S=this._active[g].end(p),S!==!0);g--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!1,S;g--}for(;g>=0;g--)if(S=this._active[g].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",p);this._active=o,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,b,S){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,b,S),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let b=!1;if(this._hitLimit)b=!1;else if(p&&(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:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const r=2147483647;class c{static fromArray(o){const p=new c;if(!o.length)return p;for(let b=Array.isArray(o[0])?1:0;b<o.length;++b){const S=o[b];if(Array.isArray(S))for(let g=0;g<S.length;++g)p.addSubParam(S[g]);else p.addParam(S)}return p}constructor(o=32,p=32){if(this.maxLength=o,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(o),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(o),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const o=new c(this.maxLength,this.maxSubParamsLength);return o.params.set(this.params),o.length=this.length,o._subParams.set(this._subParams),o._subParamsLength=this._subParamsLength,o._subParamsIdx.set(this._subParamsIdx),o._rejectDigits=this._rejectDigits,o._rejectSubDigits=this._rejectSubDigits,o._digitIsSub=this._digitIsSub,o}toArray(){const o=[];for(let p=0;p<this.length;++p){o.push(this.params[p]);const b=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-b>0&&o.push(Array.prototype.slice.call(this._subParams,b,S))}return o}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(o){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=o>r?r:o}}addSubParam(o){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=o>r?r:o,this._subParamsIdx[this.length-1]++}}hasSubParams(o){return(255&this._subParamsIdx[o])-(this._subParamsIdx[o]>>8)>0}getSubParams(o){const p=this._subParamsIdx[o]>>8,b=255&this._subParamsIdx[o];return b-p>0?this._subParams.subarray(p,b):null}getSubParamsAll(){const o={};for(let p=0;p<this.length;++p){const b=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-b>0&&(o[p]=this._subParams.slice(b,S))}return o}addDigit(o){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,S=b[p-1];b[p-1]=~S?Math.min(10*S+o,r):o}}i.Params=c},5741:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let r=this._addons.length-1;r>=0;r--)this._addons[r].instance.dispose()}loadAddon(r,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(r)}_wrappedAddonDispose(r){if(r.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===r){c=f;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");r.isDisposed=!0,r.dispose.apply(r.instance),this._addons.splice(c,1)}}},8771:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=r(3785),f=r(511);i.BufferApiView=class{constructor(o,p){this._buffer=o,this.type=p}init(o){return this._buffer=o,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(o){const p=this._buffer.lines.get(o);if(p)return new c.BufferLineApiView(p)}getNullCell(){return new f.CellData}}},3785:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=r(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,o){if(!(f<0||f>=this._line.length))return o?(this._line.loadCell(f,o),o):this._line.loadCell(f,new c.CellData)}translateToString(f,o,p){return this._line.translateToString(f,o,p)}}},8285:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=r(8771),f=r(8460),o=r(844);class p extends o.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new f.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=p},7975:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(r){this._core=r}registerCsiHandler(r,c){return this._core.registerCsiHandler(r,(f=>c(f.toArray())))}addCsiHandler(r,c){return this.registerCsiHandler(r,c)}registerDcsHandler(r,c){return this._core.registerDcsHandler(r,((f,o)=>c(f,o.toArray())))}addDcsHandler(r,c){return this.registerDcsHandler(r,c)}registerEscHandler(r,c){return this._core.registerEscHandler(r,c)}addEscHandler(r,c){return this.registerEscHandler(r,c)}registerOscHandler(r,c){return this._core.registerOscHandler(r,c)}addOscHandler(r,c){return this.registerOscHandler(r,c)}}},7090:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(r){this._core=r}register(r){this._core.unicodeService.register(r)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(r){this._core.unicodeService.activeVersion=r}}},744:function(C,i,r){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const o=r(8460),p=r(844),b=r(5295),S=r(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let g=i.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new o.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(n,this))}resize(n,d){this.cols=n,this.rows=d,this.buffers.resize(n,d),this._onResize.fire({cols:n,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,d=!1){const h=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===n.fg&&u.getBg(0)===n.bg||(u=h.getBlankLine(n,d),this._cachedBlankLine=u),u.isWrapped=d;const _=h.ybase+h.scrollTop,y=h.ybase+h.scrollBottom;if(h.scrollTop===0){const w=h.lines.isFull;y===h.lines.length-1?w?h.lines.recycle().copyFrom(u):h.lines.push(u.clone()):h.lines.splice(y+1,0,u.clone()),w?this.isUserScrolling&&(h.ydisp=Math.max(h.ydisp-1,0)):(h.ybase++,this.isUserScrolling||h.ydisp++)}else{const w=y-_+1;h.lines.shiftElements(_+1,w-1,-1),h.lines.set(y,u.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(n,d,h){const u=this.buffer;if(n<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else n+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const _=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+n,u.ybase),0),_!==u.ydisp&&(d||this._onScroll.fire(u.ydisp))}};i.BufferService=g=c([f(0,S.IOptionsService)],g)},7994:(C,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(r){this.glevel=r,this.charset=this._charsets[r]}setgCharset(r,c){this._charsets[r]=c,this.glevel===r&&(this.charset=c)}}},1753:function(C,i,r){var c=this&&this.__decorate||function(u,_,y,w){var E,x=arguments.length,R=x<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,y):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,y,w);else for(var T=u.length-1;T>=0;T--)(E=u[T])&&(R=(x<3?E(R):x>3?E(_,y,R):E(_,y))||R);return x>3&&R&&Object.defineProperty(_,y,R),R},f=this&&this.__param||function(u,_){return function(y,w){_(y,w,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const o=r(2585),p=r(8460),b=r(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 g(u,_){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||_||(y|=3)),y}const n=String.fromCharCode,d={DEFAULT:u=>{const _=[g(u,!1)+32,u.col+32,u.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${n(_[0])}${n(_[1])}${n(_[2])}`},SGR:u=>{const _=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.col};${u.row}${_}`},SGR_PIXELS:u=>{const _=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.x};${u.y}${_}`}};let h=i.CoreMouseService=class extends b.Disposable{constructor(u,_){super(),this._bufferService=u,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const y of Object.keys(S))this.addProtocol(y,S[y]);for(const y of Object.keys(d))this.addEncoding(y,d[y]);this.reset()}addProtocol(u,_){this._protocols[u]=_}addEncoding(u,_){this._encodings[u]=_}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 _=this._encodings[this._activeEncoding](u);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!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,_,y){if(y){if(u.x!==_.x||u.y!==_.y)return!1}else if(u.col!==_.col||u.row!==_.row)return!1;return u.button===_.button&&u.action===_.action&&u.ctrl===_.ctrl&&u.alt===_.alt&&u.shift===_.shift}};i.CoreMouseService=h=c([f(0,o.IBufferService),f(1,o.ICoreService)],h)},6975:function(C,i,r){var c=this&&this.__decorate||function(h,u,_,y){var w,E=arguments.length,x=E<3?u:y===null?y=Object.getOwnPropertyDescriptor(u,_):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,u,_,y);else for(var R=h.length-1;R>=0;R--)(w=h[R])&&(x=(E<3?w(x):E>3?w(u,_,x):w(u,_))||x);return E>3&&x&&Object.defineProperty(u,_,x),x},f=this&&this.__param||function(h,u){return function(_,y){u(_,y,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const o=r(1439),p=r(8460),b=r(844),S=r(2585),g=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=i.CoreService=class extends b.Disposable{constructor(h,u,_){super(),this._bufferService=h,this._logService=u,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}reset(){this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}triggerDataEvent(h,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`,(()=>h.split("").map((y=>y.charCodeAt(0))))),this._onData.fire(h)}triggerBinaryEvent(h){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${h}"`,(()=>h.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(h))}};i.CoreService=d=c([f(0,S.IBufferService),f(1,S.ILogService),f(2,S.IOptionsService)],d)},9074:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=r(8055),f=r(8460),o=r(844),p=r(6106);let b=0,S=0;class g extends o.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((h=>h?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,o.toDisposable)((()=>this.reset())))}registerDecoration(h){if(h.marker.isDisposed)return;const u=new n(h);if(u){const _=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),_.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const h of this._decorations.values())h.dispose();this._decorations.clear()}*getDecorationsAtCell(h,u,_){var y,w,E;let x=0,R=0;for(const T of this._decorations.getKeyIterator(u))x=(y=T.options.x)!==null&&y!==void 0?y:0,R=x+((w=T.options.width)!==null&&w!==void 0?w:1),h>=x&&h<R&&(!_||((E=T.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&(yield T)}forEachDecorationAtCell(h,u,_,y){this._decorations.forEachByKey(u,(w=>{var E,x,R;b=(E=w.options.x)!==null&&E!==void 0?E:0,S=b+((x=w.options.width)!==null&&x!==void 0?x:1),h>=b&&h<S&&(!_||((R=w.options.layer)!==null&&R!==void 0?R:"bottom")===_)&&y(w)}))}}i.DecorationService=g;class n extends o.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(h){super(),this.options=h,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=h.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=r(2585),f=r(8343);class o{constructor(...b){this._entries=new Map;for(const[S,g]of b)this.set(S,g)}set(b,S){const g=this._entries.get(b);return this._entries.set(b,S),g}forEach(b){for(const[S,g]of this._entries.entries())b(S,g)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}i.ServiceCollection=o,i.InstantiationService=class{constructor(){this._services=new o,this._services.set(c.IInstantiationService,this)}setService(p,b){this._services.set(p,b)}getService(p){return this._services.get(p)}createInstance(p,...b){const S=(0,f.getServiceDependencies)(p).sort(((d,h)=>d.index-h.index)),g=[];for(const d of S){const h=this._services.get(d.id);if(!h)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${d.id}.`);g.push(h)}const n=S.length>0?S[0].index:b.length;if(b.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${b.length} static arguments`);return new p(...b,...g)}}},7866:function(C,i,r){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const o=r(844),p=r(2585),b={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let S,g=i.LogService=class extends o.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let d=0;d<n.length;d++)typeof n[d]=="function"&&(n[d]=n[d]())}_log(n,d,h){this._evalLazyOptionalParams(h),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...h)}trace(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,d)}debug(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,d)}info(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.INFO&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,n,d)}warn(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.WARN&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,n,d)}error(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,n,d)}};i.LogService=g=c([f(0,p.IOptionsService)],g),i.setTraceLogger=function(n){S=n},i.traceCall=function(n,d,h){if(typeof h.value!="function")throw new Error("not supported");const u=h.value;h.value=function(..._){if(S.logLevel!==p.LogLevelEnum.TRACE)return u.apply(this,_);S.trace(`GlyphRenderer#${u.name}(${_.map((w=>JSON.stringify(w))).join(", ")})`);const y=u.apply(this,_);return S.trace(`GlyphRenderer#${u.name} return`,y),y}}},7302:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=r(8460),f=r(844),o=r(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:o.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class b extends f.Disposable{constructor(g){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},i.DEFAULT_OPTIONS);for(const d in g)if(d in n)try{const h=g[d];n[d]=this._sanitizeAndValidateOption(d,h)}catch(h){console.error(h)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(g,n){return this.onOptionChange((d=>{d===g&&n(this.rawOptions[g])}))}onMultipleOptionChange(g,n){return this.onOptionChange((d=>{g.indexOf(d)!==-1&&n()}))}_setupOptions(){const g=d=>{if(!(d in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},n=(d,h)=>{if(!(d in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);h=this._sanitizeAndValidateOption(d,h),this.rawOptions[d]!==h&&(this.rawOptions[d]=h,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const h={get:g.bind(this,d),set:n.bind(this,d)};Object.defineProperty(this.options,d,h)}}_sanitizeAndValidateOption(g,n){switch(g){case"cursorStyle":if(n||(n=i.DEFAULT_OPTIONS[g]),!(function(d){return d==="block"||d==="underline"||d==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${g}`);break;case"wordSeparator":n||(n=i.DEFAULT_OPTIONS[g]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:i.DEFAULT_OPTIONS[g];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${g} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${g} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${g} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${g} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}i.OptionsService=b},2660:function(C,i,r){var c=this&&this.__decorate||function(b,S,g,n){var d,h=arguments.length,u=h<3?S:n===null?n=Object.getOwnPropertyDescriptor(S,g):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(b,S,g,n);else for(var _=b.length-1;_>=0;_--)(d=b[_])&&(u=(h<3?d(u):h>3?d(S,g,u):d(S,g))||u);return h>3&&u&&Object.defineProperty(S,g,u),u},f=this&&this.__param||function(b,S){return function(g,n){S(g,n,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const o=r(2585);let p=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 _=S.addMarker(S.ybase+S.y),y={data:b,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(y,_))),this._dataByLinkId.set(y.id,y),y.id}const g=b,n=this._getEntryIdKey(g),d=this._entriesWithId.get(n);if(d)return this.addLineToLink(d.id,S.ybase+S.y),d.id;const h=S.addMarker(S.ybase+S.y),u={id:this._nextId++,key:this._getEntryIdKey(g),data:g,lines:[h]};return h.onDispose((()=>this._removeMarkerFromLink(u,h))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(b,S){const g=this._dataByLinkId.get(b);if(g&&g.lines.every((n=>n.line!==S))){const n=this._bufferService.buffer.addMarker(S);g.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(g,n)))}}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 g=b.lines.indexOf(S);g!==-1&&(b.lines.splice(g,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};i.OscLinkService=p=c([f(0,o.IBufferService)],p)},8343:(C,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const r="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[c]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const o=function(p,b,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(g,n,d){n[r]===n?n[c].push({id:g,index:d}):(n[c]=[{id:g,index:d}],n[r]=n)})(o,p,S)};return o.toString=()=>f,i.serviceRegistry.set(f,o),o}},2585:(C,i,r)=>{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=r(8343);var f;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(o){o[o.TRACE=0]="TRACE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.ERROR=4]="ERROR",o[o.OFF=5]="OFF"})(f||(i.LogLevelEnum=f={})),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:(C,i,r)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=r(8460),f=r(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const o=new f.UnicodeV6;this.register(o),this._active=o.version,this._activeProvider=o}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(o){if(!this._providers[o])throw new Error(`unknown Unicode version "${o}"`);this._active=o,this._activeProvider=this._providers[o],this._onChange.fire(o)}register(o){this._providers[o.version]=o}wcwidth(o){return this._activeProvider.wcwidth(o)}getStringCellWidth(o){let p=0;const b=o.length;for(let S=0;S<b;++S){let g=o.charCodeAt(S);if(55296<=g&&g<=56319){if(++S>=b)return p+this.wcwidth(g);const n=o.charCodeAt(S);56320<=n&&n<=57343?g=1024*(g-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(g)}return p}}}},a={};function m(C){var i=a[C];if(i!==void 0)return i.exports;var r=a[C]={exports:{}};return s[C].call(r.exports,r,r.exports,m),r.exports}var v={};return(()=>{var C=v;Object.defineProperty(C,"__esModule",{value:!0}),C.Terminal=void 0;const i=m(9042),r=m(3236),c=m(844),f=m(5741),o=m(8285),p=m(7975),b=m(7090),S=["cols","rows"];class g extends c.Disposable{constructor(d){super(),this._core=this.register(new r.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const h=_=>this._core.options[_],u=(_,y)=>{this._checkReadonlyOptions(_),this._core.options[_]=y};for(const _ in this._core.options){const y={get:h.bind(this,_),set:u.bind(this,_)};Object.defineProperty(this._publicOptions,_,y)}}_checkReadonlyOptions(d){if(S.includes(d))throw new Error(`Option "${d}" 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 p.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 o.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let h="none";switch(this._core.coreMouseService.activeProtocol){case"X10":h="x10";break;case"VT200":h="vt200";break;case"DRAG":h="drag";break;case"ANY":h="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:h,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const h in d)this._publicOptions[h]=d[h]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,h){this._verifyIntegers(d,h),this._core.resize(d,h)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var h,u,_;return this._checkProposedApi(),this._verifyPositiveIntegers((h=d.x)!==null&&h!==void 0?h:0,(u=d.width)!==null&&u!==void 0?u:0,(_=d.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,h,u){this._verifyIntegers(d,h,u),this._core.select(d,h,u)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,h){this._verifyIntegers(d,h),this._core.selectLines(d,h)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,h){this._core.write(d,h)}writeln(d,h){this._core.write(d),this._core.write(`\r
|
|
19
|
-
`,h)}paste(d){this._core.paste(d)}refresh(d,h){this._verifyIntegers(d,h),this._core.refresh(d,h)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return i}_verifyIntegers(...d){for(const h of d)if(h===1/0||isNaN(h)||h%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const h of d)if(h&&(h===1/0||isNaN(h)||h%1!=0||h<0))throw new Error("This API only accepts positive integers")}}C.Terminal=g})(),v})()))})(sr)),sr.exports}var Jc=Zc();var eh=2,th=1,sh=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,s=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(s.getPropertyValue("height")),m=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),C={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},i=C.top+C.bottom,r=C.right+C.left,c=a-i,f=m-r-t;return{cols:Math.max(eh,Math.floor(f/e.css.cell.width)),rows:Math.max(th,Math.floor(c/e.css.cell.height))}}};function rh(e={}){const{cwd:t,cols:s,rows:a,onOutput:m,onExit:v}=e,[C,i]=k.useState(null),[r,c]=k.useState(()=>vt.isConnected()),[f,o]=k.useState(!1),[p,b]=k.useState(!1),[S,g]=k.useState(!1),n=k.useRef({onOutput:m,onExit:v});n.current={onOutput:m,onExit:v};const d=k.useRef(null);d.current=C,k.useEffect(()=>{if(!C)return;const w=vt.getSocket(),E=()=>{c(!0),o(!1),i(null),g(!0)},x=()=>{c(!1),o(!1)},R=M=>{M.terminalId===C&&n.current.onOutput?.(M.data)},T=M=>{M.terminalId===C&&(o(!1),n.current.onExit?.(M.exitCode),i(null))},A=M=>{M.terminalId===C&&o(!0)},j=M=>{M.terminalId===C&&o(!1)};return w.on("connect",E),w.on("disconnect",x),w.on(Be.TERMINAL_STDOUT,R),w.on(Be.TERMINAL_EXIT,T),w.on(Be.TERMINAL_SUBSCRIBED,A),w.on(Be.TERMINAL_UNSUBSCRIBED,j),c(w.connected),w.connected&&w.emit(ut.SUBSCRIBE,{topic:"terminal",id:C},M=>{M.success&&o(!0)}),()=>{w.off("connect",E),w.off("disconnect",x),w.off(Be.TERMINAL_STDOUT,R),w.off(Be.TERMINAL_EXIT,T),w.off(Be.TERMINAL_SUBSCRIBED,A),w.off(Be.TERMINAL_UNSUBSCRIBED,j),w.emit(ut.UNSUBSCRIBE,{topic:"terminal",id:C})}},[C]);const h=k.useCallback(async()=>{const w=vt.getSocket();if(!w.connected)return null;b(!0);try{const E=await ge.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:a});return i(E.terminalId),g(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{b(!1)}},[t,s,a]),u=k.useCallback(async()=>{const w=d.current;if(w){try{await ge.delete(`/terminals/${w}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),o(!1)}},[]),_=k.useCallback(w=>{const E=d.current;if(!E)return;vt.getSocket().emit(ut.TERMINAL_INPUT,{terminalId:E,data:w})},[]),y=k.useCallback((w,E)=>{const x=d.current;if(!x)return;vt.getSocket().emit(ut.TERMINAL_RESIZE,{terminalId:x,cols:w,rows:E})},[]);return k.useEffect(()=>()=>{const w=d.current;w&&ge.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:C,isConnected:r,isAttached:f,isCreating:p,needsRecreate:S,create:h,destroy:u,sendInput:_,resize:y}}const ih={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"},nh=ee.memo(function({cwd:t,onExit:s,onReady:a}){const m=k.useRef(null),v=k.useRef(null),C=k.useRef(null),i=k.useRef(!1),{terminalId:r,isAttached:c,needsRecreate:f,create:o,sendInput:p,resize:b}=rh({cwd:t,onOutput:k.useCallback(S=>{v.current?.write(S)},[]),onExit:k.useCallback(S=>{v.current?.writeln(`\r
|
|
20
|
-
\x1B[90m[Process exited with code ${S}]\x1B[0m`),s?.(S)},[s])});return k.useEffect(()=>{if(!f)return;const S=v.current;S&&S.writeln(`\r
|
|
21
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),o()},[f,o]),k.useLayoutEffect(()=>{if(!m.current)return;const S=new Jc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:ih,scrollback:5e3,convertEol:!0}),g=new sh;S.loadAddon(g),S.open(m.current);const n=(d=0)=>{if(!(d>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>n(d+1),50);return}g.fit(),b(S.cols,S.rows)}catch{setTimeout(()=>n(d+1),50)}};return n(0),setTimeout(()=>n(1),100),v.current=S,C.current=g,()=>{S.dispose(),v.current=null,C.current=null}},[b]),k.useEffect(()=>{i.current||(i.current=!0,o())},[o]),k.useEffect(()=>{const S=v.current;if(!S||!c)return;const g=S.onData(n=>{p(n)});return()=>g.dispose()},[p,c]),k.useEffect(()=>{c&&a?.({sendInput:p})},[c,p,a]),k.useEffect(()=>{if(!m.current)return;const S=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const g=C.current,n=v.current,d=m.current;g&&n&&d&&d.clientWidth>0&&d.clientHeight>0&&(g.fit(),b(n.cols,n.rows))}catch{}})});return S.observe(m.current),()=>S.disconnect()},[b]),l.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!r&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),l.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),oh=ee.memo(function({commands:t,onSelect:s}){const{t:a}=ue(),[m,v]=k.useState(!1),C=k.useRef(null),i=k.useRef(null);return k.useEffect(()=>{if(!m)return;const r=c=>{C.current&&!C.current.contains(c.target)&&i.current&&!i.current.contains(c.target)&&v(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[m]),t.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{ref:i,onClick:()=>v(!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:[l.jsx(il,{size:12}),l.jsx("span",{children:a("快捷命令")}),l.jsx(_t,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&l.jsx("div",{ref:C,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:l.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((r,c)=>l.jsxs("button",{onClick:()=>{s(r.command),v(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[l.jsx(It,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:r.name}),l.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:r.command})]})]},c))})})]})]})});let rr=0;function _i(){return rr+=1,{id:`shell-${rr}`,order:rr}}const ah=ee.memo(function({cwd:t,quickCommands:s=[]}){const{t:a}=ue(),[m,v]=k.useState(()=>[_i()]),[C,i]=k.useState(()=>m[0].id),r=k.useRef(new Map),c=k.useCallback(()=>{const S=_i();v(g=>[...g,S]),i(S.id)},[]),f=k.useCallback((S,g)=>{g.stopPropagation(),r.current.delete(S),v(n=>{const d=n.filter(h=>h.id!==S);return S===C&&d.length>0&&i(d[d.length-1].id),d})},[C]),o=k.useCallback(S=>{r.current.delete(S),v(g=>{const n=g.filter(d=>d.id!==S);return S===C&&n.length>0&&i(n[n.length-1].id),n})},[C]),p=k.useCallback((S,g)=>{r.current.set(S,g.sendInput)},[]),b=k.useCallback(S=>{const g=r.current.get(C);g&&g(S+"\r")},[C]);return l.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[l.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[l.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:m.map(S=>l.jsxs("button",{onClick:()=>i(S.id),className:Se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",S.id===C?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[l.jsx(Ss,{size:11,className:"shrink-0"}),l.jsx("span",{children:a("Shell {count}",{count:S.order})}),m.length>1&&l.jsx("span",{onClick:g=>f(S.id,g),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:l.jsx(Ps,{size:10})})]},S.id))}),l.jsx("button",{onClick:c,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:a("New Terminal"),children:l.jsx(fr,{size:14})}),s.length>0&&l.jsx(oh,{commands:s,onSelect:b})]}),l.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.length===0?l.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(Ss,{size:28}),l.jsx("span",{className:"text-xs",children:a("No terminals open")}),l.jsx("button",{onClick:c,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:a("New Terminal")})]})}):m.map(S=>l.jsx("div",{className:"absolute inset-0",style:{display:S.id===C?"block":"none"},children:l.jsx(nh,{cwd:t,onExit:()=>o(S.id),onReady:g=>p(S.id,g)})},S.id))})]})});function bi(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,a=Array(t);s<t;s++)a[s]=e[s];return a}function lh(e){if(Array.isArray(e))return e}function ch(e,t,s){return(t=vh(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function hh(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var a,m,v,C,i=[],r=!0,c=!1;try{if(v=(s=s.call(e)).next,t!==0)for(;!(r=(a=v.call(s)).done)&&(i.push(a.value),i.length!==t);r=!0);}catch(f){c=!0,m=f}finally{try{if(!r&&s.return!=null&&(C=s.return(),Object(C)!==C))return}finally{if(c)throw m}}return i}}function uh(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
22
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xi(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,a)}return s}function Si(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?xi(Object(s),!0).forEach(function(a){ch(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):xi(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function dh(e,t){if(e==null)return{};var s,a,m=fh(e,t);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(a=0;a<v.length;a++)s=v[a],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(m[s]=e[s])}return m}function fh(e,t){if(e==null)return{};var s={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;s[a]=e[a]}return s}function mh(e,t){return lh(e)||hh(e,t)||gh(e,t)||uh()}function ph(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var a=s.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 vh(e){var t=ph(e,"string");return typeof t=="symbol"?t:t+""}function gh(e,t){if(e){if(typeof e=="string")return bi(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?bi(e,t):void 0}}function _h(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function yi(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,a)}return s}function Ci(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?yi(Object(s),!0).forEach(function(a){_h(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):yi(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function bh(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(a){return t.reduceRight(function(m,v){return v(m)},a)}}function Xt(e){return function t(){for(var s=this,a=arguments.length,m=new Array(a),v=0;v<a;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,i=new Array(C),r=0;r<C;r++)i[r]=arguments[r];return t.apply(s,[].concat(m,i))}}}function Ds(e){return{}.toString.call(e).includes("Object")}function xh(e){return!Object.keys(e).length}function is(e){return typeof e=="function"}function Sh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function yh(e,t){return Ds(t)||wt("changeType"),Object.keys(t).some(function(s){return!Sh(e,s)})&&wt("changeField"),t}function Ch(e){is(e)||wt("selectorType")}function wh(e){is(e)||Ds(e)||wt("handlerType"),Ds(e)&&Object.values(e).some(function(t){return!is(t)})&&wt("handlersType")}function Eh(e){e||wt("initialIsRequired"),Ds(e)||wt("initialType"),xh(e)&&wt("initialContent")}function kh(e,t){throw new Error(e[t]||e.default)}var Rh={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"},wt=Xt(kh)(Rh),ms={changes:yh,selector:Ch,handler:wh,initial:Eh};function Dh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ms.initial(e),ms.handler(t);var s={current:e},a=Xt(jh)(s,t),m=Xt(Lh)(s),v=Xt(ms.changes)(e),C=Xt(Th)(s);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return ms.selector(c),c(s.current)}function r(c){bh(a,m,v,C)(c)}return[i,r]}function Th(e,t){return is(t)?t(e.current):t}function Lh(e,t){return e.current=Ci(Ci({},e.current),t),t}function jh(e,t,s){return is(t)?t(e.current):Object.keys(s).forEach(function(a){var m;return(m=t[a])===null||m===void 0?void 0:m.call(t,e.current[a])}),s}var Ah={create:Dh},Mh={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Nh(e){return function t(){for(var s=this,a=arguments.length,m=new Array(a),v=0;v<a;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,i=new Array(C),r=0;r<C;r++)i[r]=arguments[r];return t.apply(s,[].concat(m,i))}}}function Ph(e){return{}.toString.call(e).includes("Object")}function Oh(e){return e||wi("configIsRequired"),Ph(e)||wi("configType"),e.urls?(Bh(),{paths:{vs:e.urls.monacoBase}}):e}function Bh(){console.warn(Fn.deprecation)}function Ih(e,t){throw new Error(e[t]||e.default)}var Fn={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!
|
|
23
|
-
You are using deprecated way of configuration.
|
|
24
|
-
|
|
25
|
-
Instead of using
|
|
26
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
27
|
-
use
|
|
28
|
-
monaco.config({ paths: { vs: '...' } })
|
|
29
|
-
|
|
30
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
31
|
-
`},wi=Nh(Ih)(Fn),Fh={config:Oh},Hh=function(){for(var t=arguments.length,s=new Array(t),a=0;a<t;a++)s[a]=arguments[a];return function(m){return s.reduceRight(function(v,C){return C(v)},m)}};function Hn(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],Hn(e[s],t[s]))}),Si(Si({},e),t)}var zh={type:"cancelation",msg:"operation is manually canceled"};function ir(e){var t=!1,s=new Promise(function(a,m){e.then(function(v){return t?m(zh):a(v)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var Wh=["monaco"],$h=Ah.create({config:Mh,isInitialized:!1,resolve:null,reject:null,monaco:null}),zn=mh($h,2),cs=zn[0],Us=zn[1];function Uh(e){var t=Fh.config(e),s=t.monaco,a=dh(t,Wh);Us(function(m){return{config:Hn(m.config,a),monaco:s}})}function qh(){var e=cs(function(t){var s=t.monaco,a=t.isInitialized,m=t.resolve;return{monaco:s,isInitialized:a,resolve:m}});if(!e.isInitialized){if(Us({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ir(nr);if(window.monaco&&window.monaco.editor)return Wn(window.monaco),e.resolve(window.monaco),ir(nr);Hh(Kh,Yh)(Vh)}return ir(nr)}function Kh(e){return document.body.appendChild(e)}function Xh(e){var t=document.createElement("script");return e&&(t.src=e),t}function Yh(e){var t=cs(function(a){var m=a.config,v=a.reject;return{config:m,reject:v}}),s=Xh("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Vh(){var e=cs(function(s){var a=s.config,m=s.resolve,v=s.reject;return{config:a,resolve:m,reject:v}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var a=s.m||s;Wn(a),e.resolve(a)},function(s){e.reject(s)})}function Wn(e){cs().monaco||Us({monaco:e})}function Gh(){return cs(function(e){var t=e.monaco;return t})}var nr=new Promise(function(e,t){return Us({resolve:e,reject:t})}),$n={config:Uh,init:qh,__getMonacoInstance:Gh},Qh={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},or=Qh,Zh={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Jh=Zh;function eu({children:e}){return ee.createElement("div",{style:Jh.container},e)}var tu=eu,su=tu;function ru({width:e,height:t,isEditorReady:s,loading:a,_ref:m,className:v,wrapperProps:C}){return ee.createElement("section",{style:{...or.wrapper,width:e,height:t},...C},!s&&ee.createElement(su,null,a),ee.createElement("div",{ref:m,style:{...or.fullWidth,...!s&&or.hide},className:v}))}var iu=ru,Un=k.memo(iu);function nu(e){k.useEffect(e,[])}var qn=nu;function ou(e,t,s=!0){let a=k.useRef(!0);k.useEffect(a.current||!s?()=>{a.current=!1}:e,t)}var Ze=ou;function Qt(){}function Ot(e,t,s,a){return au(e,a)||lu(e,t,s,a)}function au(e,t){return e.editor.getModel(Kn(e,t))}function lu(e,t,s,a){return e.editor.createModel(t,s,a?Kn(e,a):void 0)}function Kn(e,t){return e.Uri.parse(t)}function cu({original:e,modified:t,language:s,originalLanguage:a,modifiedLanguage:m,originalModelPath:v,modifiedModelPath:C,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:r=!1,theme:c="light",loading:f="Loading...",options:o={},height:p="100%",width:b="100%",className:S,wrapperProps:g={},beforeMount:n=Qt,onMount:d=Qt}){let[h,u]=k.useState(!1),[_,y]=k.useState(!0),w=k.useRef(null),E=k.useRef(null),x=k.useRef(null),R=k.useRef(d),T=k.useRef(n),A=k.useRef(!1);qn(()=>{let B=$n.init();return B.then(H=>(E.current=H)&&y(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>w.current?I():B.cancel()}),Ze(()=>{if(w.current&&E.current){let B=w.current.getOriginalEditor(),H=Ot(E.current,e||"",a||s||"text",v||"");H!==B.getModel()&&B.setModel(H)}},[v],h),Ze(()=>{if(w.current&&E.current){let B=w.current.getModifiedEditor(),H=Ot(E.current,t||"",m||s||"text",C||"");H!==B.getModel()&&B.setModel(H)}},[C],h),Ze(()=>{let B=w.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(t||""):t!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[t],h),Ze(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],h),Ze(()=>{let{original:B,modified:H}=w.current.getModel();E.current.editor.setModelLanguage(B,a||s||"text"),E.current.editor.setModelLanguage(H,m||s||"text")},[s,a,m],h),Ze(()=>{E.current?.editor.setTheme(c)},[c],h),Ze(()=>{w.current?.updateOptions(o)},[o],h);let j=k.useCallback(()=>{if(!E.current)return;T.current(E.current);let B=Ot(E.current,e||"",a||s||"text",v||""),H=Ot(E.current,t||"",m||s||"text",C||"");w.current?.setModel({original:B,modified:H})},[s,t,m,e,a,v,C]),M=k.useCallback(()=>{!A.current&&x.current&&(w.current=E.current.editor.createDiffEditor(x.current,{automaticLayout:!0,...o}),j(),E.current?.editor.setTheme(c),u(!0),A.current=!0)},[o,c,j]);k.useEffect(()=>{h&&R.current(w.current,E.current)},[h]),k.useEffect(()=>{!_&&!h&&M()},[_,h,M]);function I(){let B=w.current?.getModel();i||B?.original?.dispose(),r||B?.modified?.dispose(),w.current?.dispose()}return ee.createElement(Un,{width:b,height:p,isEditorReady:h,loading:f,_ref:x,className:S,wrapperProps:g})}var hu=cu;k.memo(hu);function uu(e){let t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}var du=uu,ps=new Map;function fu({defaultValue:e,defaultLanguage:t,defaultPath:s,value:a,language:m,path:v,theme:C="light",line:i,loading:r="Loading...",options:c={},overrideServices:f={},saveViewState:o=!0,keepCurrentModel:p=!1,width:b="100%",height:S="100%",className:g,wrapperProps:n={},beforeMount:d=Qt,onMount:h=Qt,onChange:u,onValidate:_=Qt}){let[y,w]=k.useState(!1),[E,x]=k.useState(!0),R=k.useRef(null),T=k.useRef(null),A=k.useRef(null),j=k.useRef(h),M=k.useRef(d),I=k.useRef(),B=k.useRef(a),H=du(v),z=k.useRef(!1),D=k.useRef(!1);qn(()=>{let O=$n.init();return O.then($=>(R.current=$)&&x(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>T.current?P():O.cancel()}),Ze(()=>{let O=Ot(R.current,e||a||"",t||m||"",v||s||"");O!==T.current?.getModel()&&(o&&ps.set(H,T.current?.saveViewState()),T.current?.setModel(O),o&&T.current?.restoreViewState(ps.get(v)))},[v],y),Ze(()=>{T.current?.updateOptions(c)},[c],y),Ze(()=>{!T.current||a===void 0||(T.current.getOption(R.current.editor.EditorOption.readOnly)?T.current.setValue(a):a!==T.current.getValue()&&(D.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),T.current.pushUndoStop(),D.current=!1))},[a],y),Ze(()=>{let O=T.current?.getModel();O&&m&&R.current?.editor.setModelLanguage(O,m)},[m],y),Ze(()=>{i!==void 0&&T.current?.revealLine(i)},[i],y),Ze(()=>{R.current?.editor.setTheme(C)},[C],y);let N=k.useCallback(()=>{if(!(!A.current||!R.current)&&!z.current){M.current(R.current);let O=v||s,$=Ot(R.current,a||e||"",t||m||"",O||"");T.current=R.current?.editor.create(A.current,{model:$,automaticLayout:!0,...c},f),o&&T.current.restoreViewState(ps.get(O)),R.current.editor.setTheme(C),i!==void 0&&T.current.revealLine(i),w(!0),z.current=!0}},[e,t,s,a,m,v,c,f,o,C,i]);k.useEffect(()=>{y&&j.current(T.current,R.current)},[y]),k.useEffect(()=>{!E&&!y&&N()},[E,y,N]),B.current=a,k.useEffect(()=>{y&&u&&(I.current?.dispose(),I.current=T.current?.onDidChangeModelContent(O=>{D.current||u(T.current.getValue(),O)}))},[y,u]),k.useEffect(()=>{if(y){let O=R.current.editor.onDidChangeMarkers($=>{let K=T.current.getModel()?.uri;if(K&&$.find(Q=>Q.path===K.path)){let Q=R.current.editor.getModelMarkers({resource:K});_?.(Q)}});return()=>{O?.dispose()}}return()=>{}},[y,_]);function P(){I.current?.dispose(),p?o&&ps.set(v,T.current.saveViewState()):T.current.getModel()?.dispose(),T.current.dispose()}return ee.createElement(Un,{width:b,height:S,isEditorReady:y,loading:r,_ref:A,className:g,wrapperProps:n})}var mu=fu,pu=k.memo(mu),vu=pu,tt=function(e,t){return Number(e.toFixed(t))},gu=function(e,t){return typeof e=="number"?e:t},De=function(e,t,s){s&&typeof s=="function"&&s(e,t)},_u=function(e){return-Math.cos(e*Math.PI)/2+.5},bu=function(e){return e},xu=function(e){return e*e},Su=function(e){return e*(2-e)},yu=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Cu=function(e){return e*e*e},wu=function(e){return--e*e*e+1},Eu=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},ku=function(e){return e*e*e*e},Ru=function(e){return 1- --e*e*e*e},Du=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Tu=function(e){return e*e*e*e*e},Lu=function(e){return 1+--e*e*e*e*e},ju=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Xn={easeOut:_u,linear:bu,easeInQuad:xu,easeOutQuad:Su,easeInOutQuad:yu,easeInCubic:Cu,easeOutCubic:wu,easeInOutCubic:Eu,easeInQuart:ku,easeOutQuart:Ru,easeInOutQuart:Du,easeInQuint:Tu,easeOutQuint:Lu,easeInOutQuint:ju},Yn=function(e){typeof e=="number"&&cancelAnimationFrame(e)},nt=function(e){e.mounted&&(Yn(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Vn(e,t,s,a){if(e.mounted){var m=new Date().getTime(),v=1;nt(e),e.animation=function(){if(!e.mounted)return Yn(e.animation);var C=new Date().getTime()-m,i=C/s,r=Xn[t],c=r(i);C>=s?(a(v),e.animation=null):e.animation&&(a(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Au(e){var t=e.scale,s=e.positionX,a=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(a))}function Rt(e,t,s,a){var m=Au(t);if(!(!e.mounted||!m)){var v=e.setTransformState,C=e.transformState,i=C.scale,r=C.positionX,c=C.positionY,f=t.scale-i,o=t.positionX-r,p=t.positionY-c;s===0?v(t.scale,t.positionX,t.positionY):Vn(e,a,s,function(b){var S=i+f*b,g=r+o*b,n=c+p*b;v(S,g,n)})}}function Mu(e,t,s){var a=e.offsetWidth,m=e.offsetHeight,v=t.offsetWidth,C=t.offsetHeight,i=v*s,r=C*s,c=a-i,f=m-r;return{wrapperWidth:a,wrapperHeight:m,newContentWidth:i,newDiffWidth:c,newContentHeight:r,newDiffHeight:f}}var Nu=function(e,t,s,a,m,v,C){var i=e>t?s*(C?1:.5):0,r=a>m?v*(C?1:.5):0,c=e-t-i,f=i,o=a-m-r,p=r;return{minPositionX:c,maxPositionX:f,minPositionY:o,maxPositionY:p}},Fr=function(e,t){var s=e.wrapperComponent,a=e.contentComponent,m=e.setup.centerZoomedOut;if(!s||!a)throw new Error("Components are not mounted");var v=Mu(s,a,t),C=v.wrapperWidth,i=v.wrapperHeight,r=v.newContentWidth,c=v.newDiffWidth,f=v.newContentHeight,o=v.newDiffHeight,p=Nu(C,r,c,i,f,o,!!m);return p},gr=function(e,t,s,a){return a?e<t?tt(t,2):e>s?tt(s,2):tt(e,2):tt(e,2)},At=function(e,t){var s=Fr(e,t);return e.bounds=s,s};function hs(e,t,s,a,m,v,C){var i=s.minPositionX,r=s.minPositionY,c=s.maxPositionX,f=s.maxPositionY,o=0,p=0;C&&(o=m,p=v);var b=gr(e,i-o,c+o,a),S=gr(t,r-p,f+p,a);return{x:b,y:S}}function qs(e,t,s,a,m,v){var C=e.transformState,i=C.scale,r=C.positionX,c=C.positionY,f=a-i;if(typeof t!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:r,y:c};var o=r-t*f,p=c-s*f,b=hs(o,p,m,v,0,0,null);return b}function us(e,t,s,a,m){var v=m?a:0,C=t-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=C?C:e}var Ei=function(e,t){var s=e.setup.panning.excluded,a=e.isInitialized,m=e.wrapperComponent,v=t.target,C="shadowRoot"in v&&"composedPath"in t,i=C?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(v),r=a&&v&&i;if(!r)return!1;var c=Ks(v,s);return!c},ki=function(e){var t=e.isInitialized,s=e.isPanning,a=e.setup,m=a.panning.disabled,v=t&&s&&!m;return!!v},Pu=function(e,t){var s=e.transformState,a=s.positionX,m=s.positionY;e.isPanning=!0;var v=t.clientX,C=t.clientY;e.startCoords={x:v-a,y:C-m}},Ou=function(e,t){var s=t.touches,a=e.transformState,m=a.positionX,v=a.positionY;e.isPanning=!0;var C=s.length===1;if(C){var i=s[0].clientX,r=s[0].clientY;e.startCoords={x:i-m,y:r-v}}};function Bu(e){var t=e.transformState,s=t.positionX,a=t.positionY,m=t.scale,v=e.setup,C=v.disabled,i=v.limitToBounds,r=v.centerZoomedOut,c=e.wrapperComponent;if(!(C||!c||!e.bounds)){var f=e.bounds,o=f.maxPositionX,p=f.minPositionX,b=f.maxPositionY,S=f.minPositionY,g=s>o||s<p,n=a>b||a<S,d=s>o?c.offsetWidth:e.setup.minPositionX||0,h=a>b?c.offsetHeight:e.setup.minPositionY||0,u=qs(e,d,h,m,e.bounds,i||r),_=u.x,y=u.y;return{scale:m,positionX:g?_:s,positionY:n?y:a}}}function Gn(e,t,s,a,m){var v=e.setup.limitToBounds,C=e.wrapperComponent,i=e.bounds,r=e.transformState,c=r.scale,f=r.positionX,o=r.positionY;if(!(C===null||i===null||t===f&&s===o)){var p=hs(t,s,i,v,a,m,C),b=p.x,S=p.y;e.setTransformState(c,b,S)}}var Iu=function(e,t,s){var a=e.startCoords,m=e.transformState,v=e.setup.panning,C=v.lockAxisX,i=v.lockAxisY,r=m.positionX,c=m.positionY;if(!a)return{x:r,y:c};var f=t-a.x,o=s-a.y,p=C?r:f,b=i?c:o;return{x:p,y:b}},kt=function(e,t){var s=e.setup,a=e.transformState,m=a.scale,v=s.minScale,C=s.disablePadding;return t>0&&m>=v&&!C?t:0},Fu=function(e){var t=e.mounted,s=e.setup,a=s.disabled,m=s.velocityAnimation,v=e.transformState.scale,C=m.disabled,i=!C||v>1||!a||t;return!!i},Hu=function(e){var t=e.mounted,s=e.velocity,a=e.bounds,m=e.setup,v=m.disabled,C=m.velocityAnimation,i=e.transformState.scale,r=C.disabled,c=!r||i>1||!v||t;return!(!c||!s||!a)};function zu(e,t){var s=e.setup.velocityAnimation,a=s.equalToMove,m=s.animationTime,v=s.sensitivity;return a?m*t*v:m}function Ri(e,t,s,a,m,v,C,i,r,c){if(m){if(t>C&&s>C){var f=C+(e-C)*c;return f>r?r:f<C?C:f}if(t<v&&s<v){var f=v+(e-v)*c;return f<i?i:f>v?v:f}}return a?t:gr(e,v,C,m)}function Wu(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function $u(e,t){var s=Fu(e);if(s){var a=e.lastMousePosition,m=e.velocityTime,v=e.setup,C=e.wrapperComponent,i=v.velocityAnimation.equalToMove,r=Date.now();if(a&&m&&C){var c=Wu(C,i),f=t.x-a.x,o=t.y-a.y,p=f/c,b=o/c,S=r-m,g=f*f+o*o,n=Math.sqrt(g)/S;e.velocity={velocityX:p,velocityY:b,total:n}}e.lastMousePosition=t,e.velocityTime=r}}function Uu(e){var t=e.velocity,s=e.bounds,a=e.setup,m=e.wrapperComponent,v=Hu(e);if(!(!v||!t||!s||!m)){var C=t.velocityX,i=t.velocityY,r=t.total,c=s.maxPositionX,f=s.minPositionX,o=s.maxPositionY,p=s.minPositionY,b=a.limitToBounds,S=a.alignmentAnimation,g=a.zoomAnimation,n=a.panning,d=n.lockAxisY,h=n.lockAxisX,u=g.animationType,_=S.sizeX,y=S.sizeY,w=S.velocityAlignmentTime,E=w,x=zu(e,r),R=Math.max(x,E),T=kt(e,_),A=kt(e,y),j=T*m.offsetWidth/100,M=A*m.offsetHeight/100,I=c+j,B=f-j,H=o+M,z=p-M,D=e.transformState,N=new Date().getTime();Vn(e,u,R,function(P){var O=e.transformState,$=O.scale,K=O.positionX,Q=O.positionY,G=new Date().getTime()-N,ne=G/E,L=Xn[S.animationType],F=1-L(Math.min(1,ne)),U=1-P,W=K+C*U,Z=Q+i*U,X=Ri(W,D.positionX,K,h,b,f,c,B,I,F),oe=Ri(Z,D.positionY,Q,d,b,p,o,z,H,F);(K!==W||Q!==Z)&&e.setTransformState($,X,oe)})}}function Di(e,t){var s=e.transformState.scale;nt(e),At(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?Ou(e,t):Pu(e,t)}function Hr(e,t){var s=e.transformState.scale,a=e.setup,m=a.minScale,v=a.alignmentAnimation,C=v.disabled,i=v.sizeX,r=v.sizeY,c=v.animationTime,f=v.animationType,o=C||s<m||!i&&!r;if(!o){var p=Bu(e);p&&Rt(e,p,t??c,f)}}function Ti(e,t,s){var a=e.startCoords,m=e.setup,v=m.alignmentAnimation,C=v.sizeX,i=v.sizeY;if(a){var r=Iu(e,t,s),c=r.x,f=r.y,o=kt(e,C),p=kt(e,i);$u(e,{x:c,y:f}),Gn(e,c,f,o,p)}}function qu(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,s=e.velocity,a=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=a?.getBoundingClientRect(),C=m?.getBoundingClientRect(),i=v?.width||0,r=v?.height||0,c=C?.width||0,f=C?.height||0,o=i<c||r<f,p=!t&&s&&s?.total>.1&&o;p?Uu(e):Hr(e)}}function zr(e,t,s,a){var m=e.setup,v=m.minScale,C=m.maxScale,i=m.limitToBounds,r=us(tt(t,2),v,C,0,!1),c=At(e,r),f=qs(e,s,a,r,c,i),o=f.x,p=f.y;return{scale:r,positionX:o,positionY:p}}function Qn(e,t,s){var a=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.minScale,i=v.limitToBounds,r=v.zoomAnimation,c=r.disabled,f=r.animationTime,o=r.animationType,p=c||a>=C;if((a>=1||i)&&Hr(e),!(p||!m||!e.mounted)){var b=t||m.offsetWidth/2,S=s||m.offsetHeight/2,g=zr(e,C,b,S);g&&Rt(e,g,f,o)}}var Et=function(){return Et=Object.assign||function(t){for(var s,a=1,m=arguments.length;a<m;a++){s=arguments[a];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(t[v]=s[v])}return t},Et.apply(this,arguments)};function Li(e,t,s){for(var a=0,m=t.length,v;a<m;a++)(v||!(a in t))&&(v||(v=Array.prototype.slice.call(t,0,a)),v[a]=t[a]);return e.concat(v||Array.prototype.slice.call(t))}var vs={scale:1,positionX:0,positionY:0},qt={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}},_r={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Zn=function(e){var t,s,a,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:vs.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:vs.scale,positionX:(a=e.initialPositionX)!==null&&a!==void 0?a:vs.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:vs.positionY}},ji=function(e){var t=Et({},qt);return Object.keys(e).forEach(function(s){var a=typeof e[s]<"u",m=typeof qt[s]<"u";if(m&&a){var v=Object.prototype.toString.call(qt[s]),C=v==="[object Object]",i=v==="[object Array]";C?t[s]=Et(Et({},qt[s]),e[s]):i?t[s]=Li(Li([],qt[s],!0),e[s]):t[s]=e[s]}}),t},Jn=function(e,t,s){var a=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.maxScale,i=v.minScale,r=v.zoomAnimation,c=v.smooth,f=r.size;if(!m)throw new Error("Wrapper is not mounted");var o=c?a*Math.exp(t*s):a+t*s,p=us(tt(o,3),i,C,f,!1);return p};function eo(e,t,s,a,m){var v=e.wrapperComponent,C=e.transformState,i=C.scale,r=C.positionX,c=C.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,o=v.offsetHeight,p=(f/2-r)/i,b=(o/2-c)/i,S=Jn(e,t,s),g=zr(e,S,p,b);if(!g)return console.error("Error during zoom event. New transformation state was not calculated.");Rt(e,g,a,m)}function to(e,t,s,a){var m=e.setup,v=e.wrapperComponent,C=m.limitToBounds,i=Zn(e.props),r=e.transformState,c=r.scale,f=r.positionX,o=r.positionY;if(v){var p=Fr(e,i.scale),b=hs(i.positionX,i.positionY,p,C,0,0,v),S={scale:i.scale,positionX:b.x,positionY:b.y};c===i.scale&&f===i.positionX&&o===i.positionY||(a?.(),Rt(e,S,t,s))}}function Ku(e,t,s,a){var m=e.getBoundingClientRect(),v=t.getBoundingClientRect(),C=s.getBoundingClientRect(),i=v.x*a.scale,r=v.y*a.scale;return{x:(m.x-C.x+i)/a.scale,y:(m.y-C.y+r)/a.scale}}function Xu(e,t,s){var a=e.wrapperComponent,m=e.contentComponent,v=e.transformState,C=e.setup,i=C.limitToBounds,r=C.minScale,c=C.maxScale;if(!a||!m)return v;var f=a.getBoundingClientRect(),o=t.getBoundingClientRect(),p=Ku(t,a,m,v),b=p.x,S=p.y,g=o.width/v.scale,n=o.height/v.scale,d=a.offsetWidth/g,h=a.offsetHeight/n,u=us(s||Math.min(d,h),r,c,0,!1),_=(f.width-g*u)/2,y=(f.height-n*u)/2,w=(f.left-b)*u+_,E=(f.top-S)*u+y,x=Fr(e,u),R=hs(w,E,x,i,0,0,a),T=R.x,A=R.y;return{positionX:T,positionY:A,scale:u}}var Yu=function(e){return function(t,s,a){t===void 0&&(t=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),eo(e,1,t,s,a)}},Vu=function(e){return function(t,s,a){t===void 0&&(t=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),eo(e,-1,t,s,a)}},Gu=function(e){return function(t,s,a,m,v){m===void 0&&(m=300),v===void 0&&(v="easeOut");var C=e.transformState,i=C.positionX,r=C.positionY,c=C.scale,f=e.wrapperComponent,o=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!o)){var b={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(s)?r:s,scale:Number.isNaN(a)?c:a};Rt(e,b,m,v)}}},Qu=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),to(e,t,s)}},Zu=function(e){return function(t,s,a){s===void 0&&(s=200),a===void 0&&(a="easeOut");var m=e.transformState,v=e.wrapperComponent,C=e.contentComponent;if(v&&C){var i=so(t||m.scale,v,C);Rt(e,i,s,a)}}},Ju=function(e){return function(t,s,a,m){a===void 0&&(a=600),m===void 0&&(m="easeOut"),nt(e);var v=e.wrapperComponent,C=typeof t=="string"?document.getElementById(t):t;if(v&&C&&v.contains(C)){var i=Xu(e,C,s);Rt(e,i,a,m)}}},Ts=function(e){return{instance:e,zoomIn:Yu(e),zoomOut:Vu(e),setTransform:Gu(e),resetTransform:Qu(e),centerView:Zu(e),zoomToElement:Ju(e)}},br=function(e){return{instance:e,state:e.transformState}},ke=function(e){var t={};return Object.assign(t,br(e)),Object.assign(t,Ts(e)),t},ar=!1;function lr(){try{var e={get passive(){return ar=!0,!1}};return e}catch{return ar=!1,ar}}var gs=".".concat(_r.wrapperClass),Ks=function(e,t){return t.some(function(s){return e.matches("".concat(gs," ").concat(s,", ").concat(gs," .").concat(s,", ").concat(gs," ").concat(s," *, ").concat(gs," .").concat(s," *"))})},xr=function(e){e&&clearTimeout(e)},ed=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},so=function(e,t,s){var a=s.offsetWidth*e,m=s.offsetHeight*e,v=(t.offsetWidth-a)/2,C=(t.offsetHeight-m)/2;return{scale:e,positionX:v,positionY:C}};function td(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var sd=function(e,t){var s=e.setup.wheel,a=s.disabled,m=s.wheelDisabled,v=s.touchPadDisabled,C=s.excluded,i=e.isInitialized,r=e.isPanning,c=t.target,f=i&&!r&&!a&&c;if(!f||m&&!t.ctrlKey||v&&t.ctrlKey)return!1;var o=Ks(c,C);return!o},rd=function(e){return e?e.deltaY<0?1:-1:0};function id(e,t){var s=rd(e),a=gu(t,s);return a}function ro(e,t,s){var a=t.getBoundingClientRect(),m=0,v=0;if("clientX"in e)m=(e.clientX-a.left)/s,v=(e.clientY-a.top)/s;else{var C=e.touches[0];m=(C.clientX-a.left)/s,v=(C.clientY-a.top)/s}return(Number.isNaN(m)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:m,y:v}}var nd=function(e,t,s,a,m){var v=e.transformState.scale,C=e.wrapperComponent,i=e.setup,r=i.maxScale,c=i.minScale,f=i.zoomAnimation,o=i.disablePadding,p=f.size,b=f.disabled;if(!C)throw new Error("Wrapper is not mounted");var S=v+t*s,g=a?!1:!b,n=us(tt(S,3),c,r,p,g&&!o);return n},od=function(e,t){var s=e.previousWheelEvent,a=e.transformState.scale,m=e.setup,v=m.maxScale,C=m.minScale;return s?a<v||a>C||Math.sign(s.deltaY)!==Math.sign(t.deltaY)||s.deltaY>0&&s.deltaY<t.deltaY||s.deltaY<0&&s.deltaY>t.deltaY||Math.sign(s.deltaY)!==Math.sign(t.deltaY):!1},ad=function(e,t){var s=e.setup.pinch,a=s.disabled,m=s.excluded,v=e.isInitialized,C=t.target,i=v&&!a&&C;if(!i)return!1;var r=Ks(C,m);return!r},ld=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,a=e.pinchStartDistance,m=s&&!t&&a;return!!m},cd=function(e,t,s){var a=s.getBoundingClientRect(),m=e.touches,v=tt(m[0].clientX-a.left,5),C=tt(m[0].clientY-a.top,5),i=tt(m[1].clientX-a.left,5),r=tt(m[1].clientY-a.top,5);return{x:(v+i)/2/t,y:(C+r)/2/t}},io=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))},hd=function(e,t){var s=e.pinchStartScale,a=e.pinchStartDistance,m=e.setup,v=m.maxScale,C=m.minScale,i=m.zoomAnimation,r=m.disablePadding,c=i.size,f=i.disabled;if(!s||a===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var o=t/a,p=o*s;return us(tt(p,2),C,v,c,!f&&!r)},ud=160,dd=100,fd=function(e,t){var s=e.props,a=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(nt(e),De(ke(e),t,a),De(ke(e),t,m))},md=function(e,t){var s=e.props,a=s.onWheel,m=s.onZoom,v=e.contentComponent,C=e.setup,i=e.transformState,r=i.scale,c=C.limitToBounds,f=C.centerZoomedOut,o=C.zoomAnimation,p=C.wheel,b=C.disablePadding,S=C.smooth,g=o.size,n=o.disabled,d=p.step,h=p.smoothStep;if(!v)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=id(t,null),_=S?h*Math.abs(t.deltaY):d,y=nd(e,u,_,!t.ctrlKey);if(r!==y){var w=At(e,y),E=ro(t,v,r),x=n||g===0||f||b,R=c&&x,T=qs(e,E.x,E.y,y,w,R),A=T.x,j=T.y;e.previousWheelEvent=t,e.setTransformState(y,A,j),De(ke(e),t,a),De(ke(e),t,m)}},pd=function(e,t){var s=e.props,a=s.onWheelStop,m=s.onZoomStop;xr(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Qn(e,t.x,t.y),e.wheelAnimationTimer=null)},dd);var v=od(e,t);v&&(xr(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,De(ke(e),t,a),De(ke(e),t,m))},ud))},no=function(e){for(var t=0,s=0,a=0;a<2;a+=1)t+=e.touches[a].clientX,s+=e.touches[a].clientY;var m=t/2,v=s/2;return{x:m,y:v}},vd=function(e,t){var s=io(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var a=no(t);e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y,nt(e)},gd=function(e,t){var s=e.contentComponent,a=e.pinchStartDistance,m=e.wrapperComponent,v=e.transformState.scale,C=e.setup,i=C.limitToBounds,r=C.centerZoomedOut,c=C.zoomAnimation,f=C.alignmentAnimation,o=c.disabled,p=c.size;if(!(a===null||!s)){var b=cd(t,v,s);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var S=io(t),g=hd(e,S),n=no(t),d=n.x-(e.pinchLastCenterX||0),h=n.y-(e.pinchLastCenterY||0);if(!(g===v&&d===0&&h===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var u=At(e,g),_=o||p===0||r,y=i&&_,w=qs(e,b.x,b.y,g,u,y),E=w.x,x=w.y;e.pinchMidpoint=b,e.lastDistance=S;var R=f.sizeX,T=f.sizeY,A=kt(e,R),j=kt(e,T),M=E+d,I=x+h,B=hs(M,I,u,i,A,j,m),H=B.x,z=B.y;e.setTransformState(g,H,z)}}}},_d=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Qn(e,t?.x,t?.y)},oo=function(e,t){var s=e.props.onZoomStop,a=e.setup.doubleClick.animationTime;xr(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,De(ke(e),t,s)},a)},bd=function(e,t){var s=e.props,a=s.onZoomStart,m=s.onZoom,v=e.setup.doubleClick,C=v.animationTime,i=v.animationType;De(ke(e),t,a),to(e,C,i,function(){return De(ke(e),t,m)}),oo(e,t)};function xd(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Sd(e,t){var s=e.setup,a=e.doubleClickStopEventTimer,m=e.transformState,v=e.contentComponent,C=m.scale,i=e.props,r=i.onZoomStart,c=i.onZoom,f=s.doubleClick,o=f.disabled,p=f.mode,b=f.step,S=f.animationTime,g=f.animationType;if(!o&&!a){if(p==="reset")return bd(e,t);if(!v)return console.error("No ContentComponent found");var n=xd(p,e.transformState.scale),d=Jn(e,n,b);if(C!==d){De(ke(e),t,r);var h=ro(t,v,C),u=zr(e,d,h.x,h.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");De(ke(e),t,c),Rt(e,u,S,g),oo(e,t)}}}var yd=function(e,t){var s=e.isInitialized,a=e.setup,m=e.wrapperComponent,v=a.doubleClick,C=v.disabled,i=v.excluded,r=t.target,c=m?.contains(r),f=s&&r&&c&&!C;if(!f)return!1;var o=Ks(r,i);return!o},Cd=(function(){function e(t){var s=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(){s.initializeWindowEvents()},this.unmount=function(){s.cleanupWindowEvents()},this.update=function(a){s.props=a,At(s,s.transformState.scale),s.setup=ji(a)},this.initializeWindowEvents=function(){var a,m,v=lr(),C=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=C?.defaultView;(m=s.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",s.onWheelPanning,v),i?.addEventListener("mousedown",s.onPanningStart,v),i?.addEventListener("mousemove",s.onPanning,v),i?.addEventListener("mouseup",s.onPanningStop,v),C?.addEventListener("mouseleave",s.clearPanning,v),i?.addEventListener("keyup",s.setKeyUnPressed,v),i?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var a,m,v=lr(),C=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=C?.defaultView;i?.removeEventListener("mousedown",s.onPanningStart,v),i?.removeEventListener("mousemove",s.onPanning,v),i?.removeEventListener("mouseup",s.onPanningStop,v),C?.removeEventListener("mouseleave",s.clearPanning,v),i?.removeEventListener("keyup",s.setKeyUnPressed,v),i?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),nt(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(a){var m=lr();a.addEventListener("wheel",s.onWheelZoom,m),a.addEventListener("dblclick",s.onDoubleClick,m),a.addEventListener("touchstart",s.onTouchPanningStart,m),a.addEventListener("touchmove",s.onTouchPanning,m),a.addEventListener("touchend",s.onTouchPanningStop,m)},this.handleInitialize=function(a,m){var v=!1,C=s.setup.centerOnInit,i=function(r,c){for(var f=0,o=r;f<o.length;f++){var p=o[f];if(p.target===c)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(r){r(ke(s))}),s.observer=new ResizeObserver(function(r){if(i(r,a)||i(r,m))if(C&&!v){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(v=!0,s.setCenter())}else nt(s),At(s,s.transformState.scale),Hr(s,0)}),s.observer.observe(a),s.observer.observe(m)},this.onWheelZoom=function(a){var m=s.setup.disabled;if(!m){var v=sd(s,a);if(v){var C=s.isPressingKeys(s.setup.wheel.activationKeys);C&&(fd(s,a),md(s,a),pd(s,a))}}},this.onWheelPanning=function(a){var m=s.setup,v=m.disabled,C=m.wheel,i=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!C.wheelDisabled||i.disabled||!i.wheelPanning||a.ctrlKey)){a.preventDefault(),a.stopPropagation();var r=s.transformState,c=r.positionX,f=r.positionY,o=c-a.deltaX,p=f-a.deltaY,b=i.lockAxisX?c:o,S=i.lockAxisY?f:p,g=s.setup.alignmentAnimation,n=g.sizeX,d=g.sizeY,h=kt(s,n),u=kt(s,d);b===c&&S===f||Gn(s,b,S,h,u)}},this.onPanningStart=function(a){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Ei(s,a);if(C){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(a.button===0&&!s.setup.panning.allowLeftClickPan||a.button===1&&!s.setup.panning.allowMiddleClickPan||a.button===2&&!s.setup.panning.allowRightClickPan||(a.preventDefault(),a.stopPropagation(),nt(s),Di(s,a),De(ke(s),a,v)))}}},this.onPanning=function(a){var m=s.setup.disabled,v=s.props.onPanning;if(!m){var C=ki(s);if(C){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(a.preventDefault(),a.stopPropagation(),Ti(s,a.clientX,a.clientY),De(ke(s),a,v))}}},this.onPanningStop=function(a){var m=s.props.onPanningStop;s.isPanning&&(qu(s),De(ke(s),a,m))},this.onPinchStart=function(a){var m=s.setup.disabled,v=s.props,C=v.onPinchingStart,i=v.onZoomStart;if(!m){var r=ad(s,a);r&&(vd(s,a),nt(s),De(ke(s),a,C),De(ke(s),a,i))}},this.onPinch=function(a){var m=s.setup.disabled,v=s.props,C=v.onPinching,i=v.onZoom;if(!m){var r=ld(s);r&&(a.preventDefault(),a.stopPropagation(),gd(s,a),De(ke(s),a,C),De(ke(s),a,i))}},this.onPinchStop=function(a){var m=s.props,v=m.onPinchingStop,C=m.onZoomStop;s.pinchStartScale&&(_d(s),De(ke(s),a,v),De(ke(s),a,C))},this.onTouchPanningStart=function(a){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Ei(s,a);if(C){var i=s.lastTouch&&+new Date-s.lastTouch<200&&a.touches.length===1;if(!i){s.lastTouch=+new Date,nt(s);var r=a.touches,c=r.length===1,f=r.length===2;c&&(nt(s),Di(s,a),De(ke(s),a,v)),f&&s.onPinchStart(a)}}}},this.onTouchPanning=function(a){var m=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&a.touches.length===1){if(m)return;var C=ki(s);if(!C)return;a.preventDefault(),a.stopPropagation();var i=a.touches[0];Ti(s,i.clientX,i.clientY),De(ke(s),a,v)}else a.touches.length>1&&s.onPinch(a)},this.onTouchPanningStop=function(a){s.onPanningStop(a),s.onPinchStop(a)},this.onDoubleClick=function(a){var m=s.setup.disabled;if(!m){var v=yd(s,a);v&&Sd(s,a)}},this.clearPanning=function(a){s.isPanning&&s.onPanningStop(a)},this.setKeyPressed=function(a){s.pressedKeys[a.key]=!0},this.setKeyUnPressed=function(a){s.pressedKeys[a.key]=!1},this.isPressingKeys=function(a){return a.length?!!a.find(function(m){return s.pressedKeys[m]}):!0},this.setTransformState=function(a,m,v){var C=s.props.onTransformed;if(!Number.isNaN(a)&&!Number.isNaN(m)&&!Number.isNaN(v)){a!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=a),s.transformState.positionX=m,s.transformState.positionY=v,s.applyTransformation();var i=ke(s);s.onChangeCallbacks.forEach(function(r){return r(i)}),De(i,{scale:a,positionX:m,positionY:v},C)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var a=so(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(a.scale,a.positionX,a.positionY)}},this.handleTransformStyles=function(a,m,v){return s.props.customTransform?s.props.customTransform(a,m,v):ed(a,m,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var a=s.transformState,m=a.scale,v=a.positionX,C=a.positionY,i=s.handleTransformStyles(v,C,m);s.contentComponent.style.transform=i}},this.getContext=function(){return ke(s)},this.onChange=function(a){return s.onChangeCallbacks.has(a)||s.onChangeCallbacks.add(a),function(){s.onChangeCallbacks.delete(a)}},this.onInit=function(a){return s.onInitCallbacks.has(a)||s.onInitCallbacks.add(a),function(){s.onInitCallbacks.delete(a)}},this.init=function(a,m){s.cleanupWindowEvents(),s.wrapperComponent=a,s.contentComponent=m,At(s,s.transformState.scale),s.handleInitializeWrapperEvents(a),s.handleInitialize(a,m),s.initializeWindowEvents(),s.isInitialized=!0;var v=ke(s);De(v,void 0,s.props.onInit)},this.props=t,this.setup=ji(this.props),this.transformState=Zn(this.props)}return e})(),Xs=ee.createContext(null),wd=function(e,t){return typeof e=="function"?e(t):e},Ed=ee.forwardRef(function(e,t){var s=k.useRef(new Cd(e)).current,a=wd(e.children,Ts(s));return k.useImperativeHandle(t,function(){return Ts(s)},[s]),k.useEffect(function(){s.update(e)},[s,e]),ee.createElement(Xs.Provider,{value:s},a)});ee.forwardRef(function(e,t){var s=k.useRef(null),a=k.useContext(Xs);return k.useEffect(function(){return a.onChange(function(m){if(s.current){var v=0,C=0;s.current.style.transform=a.handleTransformStyles(v,C,1/m.instance.transformState.scale)}})},[a]),ee.createElement("div",Et({},e,{ref:td([s,t])}))});function kd(e,t){t===void 0&&(t={});var s=t.insertAt;if(!(typeof document>"u")){var a=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",s==="top"&&a.firstChild?a.insertBefore(m,a.firstChild):a.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var Rd=`.transform-component-module_wrapper__SPB86 {
|
|
32
|
-
position: relative;
|
|
33
|
-
width: -moz-fit-content;
|
|
34
|
-
width: fit-content;
|
|
35
|
-
height: -moz-fit-content;
|
|
36
|
-
height: fit-content;
|
|
37
|
-
overflow: hidden;
|
|
38
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
39
|
-
-webkit-user-select: none; /* Safari */
|
|
40
|
-
-khtml-user-select: none; /* Konqueror HTML */
|
|
41
|
-
-moz-user-select: none; /* Firefox */
|
|
42
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
43
|
-
user-select: none;
|
|
44
|
-
margin: 0;
|
|
45
|
-
padding: 0;
|
|
46
|
-
transform: translate3d(0, 0, 0);
|
|
47
|
-
}
|
|
48
|
-
.transform-component-module_content__FBWxo {
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-wrap: wrap;
|
|
51
|
-
width: -moz-fit-content;
|
|
52
|
-
width: fit-content;
|
|
53
|
-
height: -moz-fit-content;
|
|
54
|
-
height: fit-content;
|
|
55
|
-
margin: 0;
|
|
56
|
-
padding: 0;
|
|
57
|
-
transform-origin: 0% 0%;
|
|
58
|
-
}
|
|
59
|
-
.transform-component-module_content__FBWxo img {
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
}
|
|
62
|
-
`,Ai={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};kd(Rd);var Dd=function(e){var t=e.children,s=e.wrapperClass,a=s===void 0?"":s,m=e.contentClass,v=m===void 0?"":m,C=e.wrapperStyle,i=e.contentStyle,r=e.wrapperProps,c=r===void 0?{}:r,f=e.contentProps,o=f===void 0?{}:f,p=k.useContext(Xs),b=p.init,S=p.cleanupWindowEvents,g=k.useRef(null),n=k.useRef(null);return k.useEffect(function(){var d=g.current,h=n.current;return d!==null&&h!==null&&b&&b?.(d,h),function(){S?.()}},[]),ee.createElement("div",Et({},c,{ref:g,className:"".concat(_r.wrapperClass," ").concat(Ai.wrapper," ").concat(a),style:C}),ee.createElement("div",Et({},o,{ref:n,className:"".concat(_r.contentClass," ").concat(Ai.content," ").concat(v),style:i}),t))},ao=function(){var e=k.useContext(Xs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Td=function(){var e=ao();return Ts(e)};function Ld(e){var t=ao(),s=k.useState(e(br(t))),a=s[0],m=s[1];return k.useEffect(function(){var v=!0,C=t.onChange(function(i){v&&m(e(br(i.instance)))});return function(){C(),v=!1}},[e,t]),a}function jd(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 Ad(e,t){return st({queryKey:he.files.tree(e||"",t),queryFn:()=>ge.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Md(e,t){return st({queryKey:he.files.content(e||"",t||""),queryFn:()=>ge.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Nd(e){const t=Fe();return k.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Pd(){const e=Fe();return Ge({mutationFn:t=>ge.post("/files/write",t),onSuccess:(t,s)=>{const a=he.files.content(s.workingDir,s.path),m=e.getQueryData(a);e.setQueryData(a,{content:s.content,language:m?.language||jd(s.path)})}})}function Od(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Bd(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Id=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Fd(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Id.has(t)?Lr:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?Jt:t==="json"?ya:t==="md"||t==="mdx"||t==="txt"?mn:oa}const Mi=({depth:e,active:t,onClick:s,leftIcon:a,rightIcon:m,label:v})=>l.jsxs("button",{type:"button",onClick:s,className:Se("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:[l.jsx("span",{className:"shrink-0",children:m}),l.jsx("span",{className:"shrink-0 text-neutral-500",children:a}),l.jsx("span",{className:"truncate text-neutral-700",children:v})]}),lo=({workingDir:e,path:t,depth:s,expanded:a,toggleDir:m,onFileSelect:v,selectedFilePath:C})=>{const{t:i}=ue(),{data:r,isLoading:c,isError:f}=Ad(e,t),o=k.useMemo(()=>r?.items??[],[r?.items]);return c?l.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:i("Loading...")}):f?l.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:i("Failed to load")}):l.jsx("div",{className:"space-y-0.5",children:o.map(p=>{if(p.type==="directory"){const d=Od(t,p.name),h=a.has(d);return l.jsxs("div",{children:[l.jsx(Mi,{depth:s,onClick:()=>m(d),rightIcon:h?l.jsx(_t,{size:14,className:"text-neutral-400"}):l.jsx(Nt,{size:14,className:"text-neutral-400"}),leftIcon:h?l.jsx(pn,{size:14,className:"text-amber-500"}):l.jsx(na,{size:14,className:"text-amber-500"}),label:p.name}),h&&l.jsx(lo,{workingDir:e,path:d,depth:s+1,expanded:a,toggleDir:m,onFileSelect:v,selectedFilePath:C})]},d)}const b=Bd(t,p.name),S=Fd(p),g=C===b,n=S===Lr;return l.jsx(Mi,{depth:s,active:g,onClick:()=>v(b),rightIcon:l.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?l.jsx(S,{size:14,className:n?"text-emerald-600":"text-sky-600"}):null,label:p.name},b)})})},Hd=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:a,onCollapse:m})=>{const{t:v}=ue(),[C,i]=k.useState(()=>new Set),r=Nd(e),c=k.useCallback(f=>{i(o=>{const p=new Set(o);return p.has(f)?p.delete(f):p.add(f),p})},[]);return l.jsxs("div",{className:Se("h-full flex flex-col",t),children:[l.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:v("Files")}),l.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||v("No working directory")})]}),l.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&l.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:v("Refresh file tree"),children:l.jsx(Ja,{size:13})}),m&&l.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:v("Collapse file tree"),children:l.jsx(Ua,{size:13})})]})]}),l.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?l.jsx(lo,{workingDir:e,path:"/",depth:0,expanded:C,toggleDir:c,onFileSelect:s,selectedFilePath:a}):l.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:v("No workspace selected.")})})]})},zd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Wd(e){const t=e.split(".").pop()?.toLowerCase();return t?zd.has(t):!1}function $d(e,t){const s="/api",a=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${a.toString()}`}const Ud=({filePath:e})=>{const{t}=ue(),{zoomIn:s,zoomOut:a,centerView:m}=Td(),v=Ld(i=>i.state.scale),C=Math.round(v*100);return l.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:[l.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:l.jsx(ll,{size:14})}),l.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:[C,"%"]}),l.jsx("button",{type:"button",onClick:()=>s(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom in"),children:l.jsx(ol,{size:14})}),l.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:l.jsx(Ha,{size:13})}),l.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},qd=({workingDir:e,filePath:t})=>{const{t:s}=ue(),[a,m]=k.useState(!1),v=$d(e,t);return a?l.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("Failed to load image.")}):l.jsx(Ed,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsx(Ud,{filePath:t}),l.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:l.jsx(Dd,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx("img",{src:v,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function Kd(e){const t=e.split("/");return t[t.length-1]||e}function Xd(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 Yd=({active:e,name:t,isDirty:s,onClick:a,onClose:m})=>{const{t:v}=ue();return l.jsxs("button",{type:"button",onClick:a,className:Se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[l.jsx("span",{className:Se("w-2 h-2 rounded-full",s?"bg-amber-500":"bg-transparent")}),l.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),l.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":v("Close tab"),title:v("Close"),children:l.jsx(Ps,{size:12})})]})},Vd=({workingDir:e,className:t})=>{const{t:s}=ue(),[a,m]=k.useState([]),[v,C]=k.useState(null),i=Pd(),[r,c]=k.useState(280),[f,o]=k.useState(!1),[p,b]=k.useState(!1),S=k.useRef(280),g=k.useCallback(()=>{o(j=>(j?c(S.current):S.current=r,!j))},[r]),n=k.useCallback(j=>{j.preventDefault(),b(!0);const M=j.clientX,I=r,B=z=>{const D=z.clientX-M,N=Math.min(480,Math.max(160,I+D));c(N)},H=()=>{b(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",H)},[r]);k.useEffect(()=>{m([]),C(null)},[e]);const d=k.useMemo(()=>a.find(j=>j.path===v)||null,[a,v]),{data:h,isFetching:u,isError:_,error:y}=Md(e,d?.isImage?null:v);k.useEffect(()=>{!v||!h||m(j=>j.map(M=>M.path!==v||M.isDirty||M.loaded?M:{...M,language:h.language||M.language,content:h.content,savedContent:h.content,isDirty:!1,loaded:!0}))},[v,h]);const w=k.useCallback(j=>{m(M=>{if(M.find(H=>H.path===j))return M;const B=Wd(j);return[...M,{path:j,name:Kd(j),language:Xd(j),content:"",savedContent:"",isDirty:!1,loaded:B,isImage:B}]}),C(j)},[]),E=k.useCallback(j=>{m(M=>{const I=M.filter(B=>B.path!==j);return C(B=>B!==j?B:I.length?I[I.length-1].path:null),I})},[]),x=k.useCallback(j=>{m(M=>M.map(I=>{if(I.path!==v)return I;const B=j!==I.savedContent;return{...I,content:j,isDirty:B}}))},[v]),R=k.useCallback(async()=>{!e||!d||(await i.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(j=>j.map(M=>M.path===d.path?{...M,savedContent:M.content,isDirty:!1,loaded:!0}:M)))},[e,d,i]),T=k.useRef(()=>{});k.useEffect(()=>{T.current=()=>{R().catch(()=>{})}},[R]),k.useEffect(()=>{const j=M=>{(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="s"&&(M.preventDefault(),T.current())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const A=k.useCallback((j,M)=>{j.addCommand(M.KeyMod.CtrlCmd|M.KeyCode.KeyS,()=>{T.current()})},[]);return l.jsxs("div",{className:Se("flex h-full overflow-hidden bg-white",t),style:p?{userSelect:"none",cursor:"col-resize"}:void 0,children:[l.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:f?36:r,transition:p?"none":"width 0.15s ease"},children:f?l.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:l.jsx("button",{type:"button",onClick:g,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Expand file tree"),children:l.jsx(Ka,{size:16})})}):l.jsx(l.Fragment,{children:l.jsx(Hd,{workingDir:e,onFileSelect:w,selectedFilePath:d?.path||null,onCollapse:g},e||"no-working-dir")})}),!f&&l.jsx("div",{onMouseDown:n,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",p?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[l.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:[a.length===0?l.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:s("No open files")}):a.map(j=>l.jsx(Yd,{active:j.path===v,name:j.name,isDirty:j.isDirty,onClick:()=>C(j.path),onClose:M=>{M.stopPropagation(),E(j.path)}},j.path)),l.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[i.isPending&&l.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[l.jsx(Ie,{size:14,className:"animate-spin"}),s("Saving")]}),d?.isDirty&&!i.isPending&&l.jsx("span",{className:"text-[11px] text-amber-600",children:s("Unsaved")})]})]}),l.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?l.jsx(qd,{workingDir:e,filePath:d.path}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:j=>x(j??""),onMount:A,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0}}),u&&!d.loaded&&l.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:l.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[l.jsx(Ie,{size:14,className:"animate-spin"}),s("Loading file...")]})}),_&&l.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:[s("Failed to load file"),y instanceof Error?`: ${y.message}`:""]})]}):l.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("Select a file from the tree to open.")}):l.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("No workspace selected.")})})]})]})};function co(e){return st({queryKey:he.git.changes(e||""),queryFn:()=>ge.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function ho(e,t,s){return st({queryKey:he.git.diff(e||"",t||"",s),queryFn:()=>ge.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function uo(e,t){return st({queryKey:he.git.commitFiles(e||"",t||""),queryFn:()=>ge.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function fo(e,t,s){return st({queryKey:he.git.commitDiff(e||"",t||"",s||""),queryFn:()=>ge.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ni={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"},Gd={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function Qd(e){const t=e.split("/");return t[t.length-1]||e}function Zd(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Jd=({entry:e,selected:t,onClick:s})=>{const{t:a}=ue(),m=Ni[e.status]||Ni.M,v=Gd[e.status]||e.status,C=Zd(e.path);return l.jsxs("button",{type:"button",onClick:s,className:Se("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:[l.jsx("span",{className:Se("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:a(v),children:e.status}),l.jsx("span",{className:"text-xs text-neutral-900 truncate",children:Qd(e.path)}),C&&l.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:C})]})},Pi=({title:e,entries:t,type:s,selectedKey:a,onSelect:m})=>{const{t:v}=ue();return t.length===0?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[l.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),l.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),l.jsx("div",{className:"space-y-0.5",children:t.map(C=>{const i=`${s}:${C.path}`;return l.jsx(Jd,{entry:C,selected:a===i,onClick:()=>m(C.path,s)},i)})})]})},ef=({line:e,lineNum:t})=>{let s="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",a="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),l.jsxs("div",{className:Se("flex",s),children:[l.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),l.jsx("span",{className:Se("pl-2 whitespace-pre",a),children:e})]})},tf=({workingDir:e,filePath:t,type:s})=>{const{t:a}=ue(),{data:m,isLoading:v,isError:C}=ho(e,t,s);if(v)return l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(C)return l.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 l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const r=i.split(`
|
|
63
|
-
`);return l.jsx("div",{className:"flex-1 overflow-auto font-mono text-xs leading-5",children:r.map((c,f)=>l.jsx(ef,{line:c,lineNum:f+1},f))})},sf=({workingDir:e})=>{const{t}=ue(),{data:s,isLoading:a,isError:m}=co(e),[v,C]=k.useState(null),[i,r]=k.useState(260),[c,f]=k.useState(!1),o=k.useCallback(d=>{d.preventDefault(),f(!0);const h=d.clientX,u=i,_=w=>{const E=w.clientX-h,x=Math.min(480,Math.max(160,u+E));r(x)},y=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",y)},[i]),p=v?`${v.type}:${v.path}`:null,b=(d,h)=>{C({path:d,type:h})};if(!e)return l.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 l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return l.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load changes.")});const S=s?.uncommitted||[],g=s?.committed||[],n=S.length+g.length;return l.jsxs("div",{className:"flex h-full bg-white",style:c?{userSelect:"none",cursor:"col-resize"}:void 0,children:[l.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:i},children:[l.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(es,{size:14,className:"text-neutral-500"}),l.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("Changes")}),n>0&&l.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n})]})}),l.jsx("div",{className:"flex-1 overflow-auto p-1.5",children:n===0?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[l.jsx(es,{size:28,className:"mb-2"}),l.jsx("span",{className:"text-xs",children:t("No pending changes")})]}):l.jsxs("div",{className:"space-y-2",children:[l.jsx(Pi,{title:"Uncommitted",entries:S,type:"uncommitted",selectedKey:p,onSelect:b}),l.jsx(Pi,{title:"Committed",entries:g,type:"committed",selectedKey:p,onSelect:b})]})})]}),l.jsx("div",{onMouseDown:o,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",c?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),l.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[l.jsx(Jt,{size:14,className:"text-neutral-500"}),l.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:v.path}),l.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",t(v.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),l.jsx(tf,{workingDir:e,filePath:v.path,type:v.type})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(Jt,{size:28}),l.jsx("span",{className:"text-xs",children:t("Select a file to view diff")})]})})})]})},cr=50,Oi={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 rf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ct("{count}s ago",{count:s}):s<3600?Ct("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ct("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ct("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function nf(e){const t=e.split("/");return t[t.length-1]||e}function of(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const af=`
|
|
64
|
-
.history-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
|
|
65
|
-
.history-scroll::-webkit-scrollbar-track { background: transparent; }
|
|
66
|
-
.history-scroll::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 2px; }
|
|
67
|
-
.history-scroll::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }
|
|
68
|
-
`,lf=({line:e,lineNum:t})=>{let s="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",a="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),l.jsxs("div",{className:Se("flex",s),children:[l.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),l.jsx("span",{className:Se("pl-2 whitespace-pre",a),children:e})]})},cf=({workingDir:e,hash:t,filePath:s})=>{const{t:a}=ue(),{data:m,isLoading:v,isError:C}=fo(e,t,s);if(v)return l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(C)return l.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 l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const r=i.split(`
|
|
69
|
-
`);return l.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:r.map((c,f)=>l.jsx(lf,{line:c,lineNum:f+1},f))})},hf=({workingDir:e,hash:t,selectedPath:s,onSelectFile:a})=>{const{t:m}=ue(),{data:v,isLoading:C}=uo(e,t);if(C)return l.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[l.jsx(Ie,{size:12,className:"animate-spin"}),l.jsx("span",{children:m("Loading...")})]});const i=v?.files||[];return i.length===0?l.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):l.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(r=>{const c=Oi[r.status]||Oi.M,f=of(r.path);return l.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),a(r.path)},className:Se("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===r.path?"bg-blue-50":"hover:bg-neutral-50"),children:[l.jsx("span",{className:Se("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:r.status}),l.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:nf(r.path)}),f&&l.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},r.path)})})},uf=({workingDir:e})=>{const{t}=ue(),{data:s,isLoading:a,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:i}=cn({queryKey:he.git.log(e||""),queryFn:({pageParam:y=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(cr),skip:String(y)}}),initialPageParam:0,getNextPageParam:(y,w)=>y.commits.length<cr?void 0:w.length*cr,enabled:!!e}),r=s?.pages.flatMap(y=>y.commits)||[],[c,f]=k.useState(null),[o,p]=k.useState(null),[b,S]=k.useState(280),[g,n]=k.useState(!1),d=k.useCallback(y=>{y.preventDefault(),n(!0);const w=y.clientX,E=b,x=T=>{const A=Math.min(480,Math.max(180,E+(T.clientX-w)));S(A)},R=()=>{n(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",R)},[b]),h=y=>{c===y?(f(null),p(null)):(f(y),p(null))},u=k.useRef(null);if(!e)return l.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 l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return l.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(r.length===0)return l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[l.jsx(Ht,{size:28,className:"mb-2"}),l.jsx("span",{className:"text-xs",children:t("No commit history")})]});const _=r.find(y=>y.hash===c);return l.jsxs("div",{className:"flex h-full bg-white",style:g?{userSelect:"none",cursor:"col-resize"}:void 0,children:[l.jsx("style",{children:af}),l.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:b},children:[l.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ht,{size:14,className:"text-neutral-500"}),l.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),l.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:r.length})]})}),l.jsxs("div",{ref:u,className:"flex-1 overflow-auto history-scroll p-1.5",children:[r.map(y=>{const w=c===y.hash;return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>h(y.hash),className:Se("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",w?"bg-blue-50":"hover:bg-neutral-50"),children:[l.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:l.jsx("div",{className:Se("w-2 h-2 rounded-full shrink-0 transition-colors",w?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:y.shortHash}),l.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:y.message}),l.jsx(Nt,{size:12,className:Se("shrink-0 text-neutral-400 transition-transform",w&&"rotate-90")})]}),l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:y.author}),l.jsx("span",{className:"text-[10px] text-neutral-400",children:rf(y.timestamp)})]})]})]}),w&&l.jsxs(l.Fragment,{children:[y.body&&l.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}),l.jsx(hf,{workingDir:e,hash:y.hash,selectedPath:o,onSelectFile:p})]})]},y.hash)}),C&&l.jsx("button",{type:"button",onClick:()=>v(),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?l.jsxs(l.Fragment,{children:[l.jsx(Ie,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),l.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",g?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),l.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:o&&c?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[l.jsx(Jt,{size:14,className:"text-neutral-500"}),l.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:o}),l.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",_?.shortHash,")"]})]}),l.jsx(cf,{workingDir:e,hash:c,filePath:o})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(Jt,{size:28}),l.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},df=[{key:"changes",label:"Changes",icon:l.jsx(es,{size:14})},{key:"history",label:"History",icon:l.jsx(Ht,{size:14})},{key:"editor",label:"Editor",icon:l.jsx(Bs,{size:14})},{key:"terminal",label:"Terminal",icon:l.jsx(Ss,{size:14})},{key:"preview",label:"Preview",icon:l.jsx(Ns,{size:14})}],ff=[{key:"history",label:"History",icon:l.jsx(Ht,{size:14})},{key:"editor",label:"Editor",icon:l.jsx(Bs,{size:14})},{key:"terminal",label:"Terminal",icon:l.jsx(Ss,{size:14})},{key:"preview",label:"Preview",icon:l.jsx(Ns,{size:14})}],mf=({active:e,onClick:t,icon:s,label:a})=>l.jsxs("button",{onClick:t,className:Se("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:[s,l.jsx("span",{children:a})]}),pf=({icon:e,title:t})=>{const{t:s}=ue();return l.jsx("div",{className:"flex-1 flex items-center justify-center bg-white",children:l.jsxs("div",{className:"flex flex-col items-center gap-2 text-neutral-400",children:[e,l.jsx("span",{className:"text-sm font-medium text-neutral-500",children:s(t)}),l.jsx("span",{className:"text-xs",children:s("Coming soon...")})]})})},mo=ee.memo(function({className:t,sessionId:s,workingDir:a,projectId:m,hideChanges:v}){const{t:C}=ue(),i=v?ff:df,[r,c]=k.useState(v?"history":"changes"),{data:f}=aa(m??""),o=k.useMemo(()=>{if(!f?.quickCommands)return[];try{return JSON.parse(f.quickCommands)}catch{return[]}},[f?.quickCommands]),[p,b]=k.useState([]),S=k.useRef(void 0);return k.useEffect(()=>{a&&a!==S.current&&(S.current=a,b(g=>g.includes(a)?g:[...g,a]))},[a]),l.jsxs("div",{className:Se("flex flex-col h-full bg-white",t),children:[l.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:i.map(g=>l.jsx(mf,{active:r===g.key,onClick:()=>c(g.key),icon:g.icon,label:C(g.label)},g.key))}),l.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[r==="editor"&&l.jsx(Vd,{workingDir:a}),p.map(g=>l.jsx("div",{className:"h-full absolute inset-0",style:{display:r==="terminal"&&a===g?"block":"none"},children:l.jsx(ah,{cwd:g,quickCommands:o})},g)),r==="preview"&&l.jsx(pf,{icon:l.jsx(Ns,{size:32}),title:"Preview"}),r==="changes"&&l.jsx(sf,{workingDir:a}),r==="history"&&l.jsx(uf,{workingDir:a})]})]})});function po(e){return st({queryKey:he.workspaces.list(e),queryFn:()=>ge.get(`/tasks/${e}/workspaces`),enabled:!!e})}function vf(e){const t=Fe();return Ge({mutationFn:s=>ge.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:he.workspaces.list(e)}),t.invalidateQueries({queryKey:he.tasks.all})}})}function gf(){const e=Fe();return Ge({mutationFn:({id:t,commitMessage:s})=>ge.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:he.workspaces.all}),e.invalidateQueries({queryKey:he.tasks.all})}})}function Wr(){return Ge({mutationFn:({workspaceId:e,editorType:t})=>ge.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function vo(e){return st({queryKey:he.workspaces.gitStatus(e),queryFn:()=>ge.get(`/workspaces/${e}/git-status`),enabled:!!e})}function _f(){const e=Fe();return Ge({mutationFn:t=>ge.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})}})}function bf(){const e=Fe();return Ge({mutationFn:t=>ge.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})}})}const Bi=1500,xf=3e3;function Sf(e){const[t,s]=k.useState(null),a=k.useRef(0),m=k.useRef(null),v=k.useRef(null);return k.useEffect(()=>{if(!e)return;const C=()=>{v.current&&(clearTimeout(v.current),v.current=null)},i=vt.connect();i.emit(ut.SUBSCRIBE,{topic:"task",id:e},f=>{});const r=f=>{s(f),v.current=setTimeout(()=>s(null),xf)},c=f=>{if(f.taskId!==e)return;const o={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){C(),m.current=null,a.current===0&&(a.current=Date.now()),s(o);return}const p=a.current>0?Date.now()-a.current:0,b=Bi-p;a.current===0?(a.current=Date.now(),s({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=o,v.current=setTimeout(()=>r(o),Bi)):b>0?(m.current=o,C(),v.current=setTimeout(()=>r(o),b)):r(o)};return i.on(Be.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(Be.WORKSPACE_SETUP_PROGRESS,c),C(),a.current=0,m.current=null}},[e]),t}function go(){const e=Fe();return Ge({mutationFn:t=>ge.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.sessions.detail(s)})}})}function _o(){const e=Fe();return Ge({mutationFn:t=>ge.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.sessions.detail(s)})}})}function $r(){const e=Fe();return Ge({mutationFn:({id:t,message:s,providerId:a})=>ge.post(`/sessions/${t}/message`,{message:s,providerId:a}),onSuccess:()=>{e.invalidateQueries({queryKey:he.workspaces.all})}})}function bo(e,t){return k.useMemo(()=>{for(let s=e.length-1;s>=0;s--){const a=e[s];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])}const yf="/api";async function Cf(e){const t=new FormData;t.append("file",e);const s=await fetch(`${yf}/attachments/upload`,{method:"POST",body:t});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||`Upload failed (${s.status})`)}return s.json()}let wf=0;function Ur(){const[e,t]=k.useState([]),s=k.useRef(e);s.current=e;const a=k.useCallback(async c=>{const f=c.map(o=>({tempId:`tmp-${++wf}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...f]),await Promise.allSettled(f.map(async o=>{try{const p=await Cf(o.file);t(b=>b.map(S=>S.tempId===o.tempId?{...S,status:"done",progress:100,attachment:p}:S))}catch(p){t(b=>b.map(S=>S.tempId===o.tempId?{...S,status:"error",error:p instanceof Error?p.message:"Upload failed"}:S))}}))},[]),m=k.useCallback(c=>{t(f=>f.filter(o=>o.tempId!==c))},[]),v=k.useCallback(()=>{t([])},[]),C=k.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const o=f.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
|
|
70
|
-
`)},[]),i=e.length>0,r=e.some(c=>c.status==="uploading");return{files:e,addFiles:a,removeFile:m,clear:v,buildMarkdownLinks:C,hasFiles:i,isUploading:r}}const Ef="/api";function kf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Ls({files:e,onRemove:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(s=>l.jsx(Rf,{item:s,onRemove:t},s.tempId))})}function Rf({item:e,onRemove:t}){const s=e.file.type.startsWith("image/"),a=e.status==="error",m=e.status==="uploading";return l.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:[s&&e.status==="done"&&e.attachment?l.jsx("img",{src:`${Ef}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):l.jsx("span",{className:"flex-shrink-0",children:m?l.jsx(Ie,{size:16,className:"animate-spin text-neutral-400"}):s?l.jsx(Lr,{size:16,className:"text-neutral-400"}):l.jsx(mn,{size:16,className:"text-neutral-400"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-medium",children:e.file.name}),a?l.jsx("div",{className:"truncate text-red-500",children:e.error}):l.jsx("div",{className:"text-neutral-400",children:kf(e.file.size)})]}),l.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:l.jsx(Ps,{size:10})})]})}function xo({isOpen:e,onClose:t,taskId:s,taskTitle:a,taskDescription:m}){const{t:v}=ue(),[C,i]=k.useState(""),[r,c]=k.useState(""),[f,o]=k.useState("idle"),[p,b]=k.useState(null),S=Fe(),g=vf(s),n=go(),{data:d,isLoading:h}=Os();k.useEffect(()=>{if(!e||!d)return;const w=d.find(E=>E.availability.type!=="NOT_FOUND");w&&i(w.provider.id)},[e,d]),k.useEffect(()=>{if(e){const w=[a];m&&w.push(m),c(w.join(`
|
|
71
|
-
|
|
72
|
-
`)),o("idle"),b(null)}},[e,a,m]);const u=f!=="idle",_=async()=>{if(!(!C||!r.trim())){b(null);try{o("creating-workspace");const w=await g.mutateAsync({});o("creating-session");const E=await ge.post(`/workspaces/${w.id}/sessions`,{providerId:C,prompt:r.trim()});o("starting-session"),await n.mutateAsync(E.id),await S.invalidateQueries({queryKey:he.workspaces.list(s)}),o("idle"),t()}catch(w){o("idle"),b(w instanceof Error?w.message:v("启动失败,请重试"))}}},y={idle:v("启动"),"creating-workspace":v("创建工作空间..."),"creating-session":v("创建会话..."),"starting-session":v("启动 Agent...")};return l.jsx(Tr,{isOpen:e,onClose:u?()=>{}:t,title:v("启动 Agent"),action:l.jsxs(l.Fragment,{children:[l.jsx(ft,{variant:"outline",onClick:t,disabled:u,children:v("取消")}),l.jsx(ft,{onClick:_,disabled:u||!C||!r.trim(),children:y[f]})]}),children:l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("选择 Provider")}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[h&&l.jsx("span",{className:"text-sm text-neutral-400",children:v("加载中...")}),d?.map(({provider:w,availability:E})=>{const x=E.type!=="NOT_FOUND";return l.jsxs(ft,{variant:C===w.id?"default":"outline",size:"sm",disabled:!x||u,onClick:()=>i(w.id),children:[w.name,!x&&v(" (不可用)")]},w.id)})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("任务描述")}),l.jsx("textarea",{value:r,onChange:w=>c(w.target.value),rows:5,disabled:u,placeholder:v("描述你想让 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"})]}),p&&l.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:p})]})})}function So({providers:e,currentProviderId:t,agentType:s,onSelect:a}){const{t:m}=ue(),[v,C]=k.useState(!1),i=k.useRef(null),r=e.filter(f=>String(f.provider.agentType)===s),c=e.find(f=>f.provider.id===t);return k.useEffect(()=>{function f(o){i.current&&!i.current.contains(o.target)&&C(!1)}if(v)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[v]),r.length<=1?l.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[l.jsx(Vr,{size:14,className:"shrink-0"}),l.jsx("span",{children:c?.provider.name?Zr(c.provider.name,12):s})]}):l.jsxs("div",{className:"relative",ref:i,children:[l.jsxs("button",{onClick:()=>C(!v),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??s} (click to change)`,children:[l.jsx(Vr,{size:14,className:"shrink-0"}),l.jsx("span",{children:c?.provider.name?Zr(c.provider.name,12):s}),l.jsx(_t,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&l.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:[l.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),r.map(f=>l.jsxs("button",{onClick:()=>{a(f.provider.id),C(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${f.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&l.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===t&&l.jsx(Zt,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function Df({commands:e,selectedIndex:t,query:s,hasCatalog:a,title:m="Slash Commands",queryPrefix:v="/",emptyCatalogMessage:C="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:r="Enter / Tab to insert",compact:c=!1,onSelect:f}){const o=c?"px-1.5 pb-1.5":"px-2 pb-2",p=c?"px-2 py-1.5":"px-2.5 py-2",b=c?"max-h-36":"max-h-48";return l.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[l.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[l.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),l.jsx("span",{className:"text-[10px] text-neutral-400",children:r})]}),e.length===0?l.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 ${v}${s}`:C}):l.jsx("div",{className:`${o} ${b} overflow-y-auto`,children:e.map((S,g)=>l.jsxs("button",{type:"button",onMouseDown:n=>n.preventDefault(),onClick:()=>f(S),className:`w-full rounded-lg border text-left transition-colors ${g===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${p}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:S.command}),S.kind&&S.kind!=="builtin"?l.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]}),l.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:S.description})]},S.command))})]})}const St=12,_s=8;function js({open:e,anchorRef:t,commands:s,selectedIndex:a,query:m,hasCatalog:v,title:C,queryPrefix:i,emptyCatalogMessage:r,emptyQueryMessage:c,insertionHint:f,compact:o=!1,onSelect:p}){const b=k.useRef(null),[S,g]=k.useState(null);return k.useLayoutEffect(()=>{if(!e){g(null);return}const n=t.current;if(!n)return;let d=0;const h=()=>{const y=t.current;if(!y)return;const w=y.getBoundingClientRect(),E=window.innerWidth,x=window.innerHeight,R=o?260:320,T=o?E-St*2:560,A=Math.min(Math.max(w.width,R),Math.max(R,T)),j=Math.min(Math.max(St,w.left),Math.max(St,E-St-A)),M=x-w.bottom-_s-St,I=w.top-_s-St,B=b.current?.offsetHeight??(o?220:280),H=o?240:320,z=M<180&&I>M,N=Math.max(120,Math.min(H,z?I:M)),P=z?Math.max(St,w.top-_s-Math.min(B,N)):Math.min(x-St-Math.min(B,N),w.bottom+_s);g({top:P,left:j,width:A,maxHeight:N})},u=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(h)};u();const _=new ResizeObserver(u);return _.observe(n),b.current&&_.observe(b.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(d),_.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,s.length,o,e,m,a]),!e||!S||typeof document>"u"?null:jt.createPortal(l.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:l.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:l.jsx(Df,{commands:s,selectedIndex:a,query:m,hasCatalog:v,title:C,queryPrefix:i,emptyCatalogMessage:r,emptyQueryMessage:c,insertionHint:f,compact:o,onSelect:p})})}),document.body)}function Tf({workspaceId:e,gitStatus:t,onResolve:s}){const{t:a}=ue(),m=bf();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const v=t.operation==="rebase"?"Rebase":"Merge";return l.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:[l.jsx(on,{size:18,className:"text-amber-600 shrink-0"}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("{opLabel} 冲突 — {count} 个文件",{opLabel:v,count:t.conflictedFiles.length})})}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(ft,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:a("中止操作")}),l.jsx(ft,{size:"sm",onClick:s,children:a("解决冲突")})]})]})}function Lf(e,t,s,a){const m=s.map(v=>`- ${v}`).join(`
|
|
73
|
-
`);return a===ia.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
74
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"].join(`
|
|
75
|
-
`)}function jf({open:e,onOpenChange:t,workspaceId:s,conflictOp:a,conflictedFiles:m,sourceBranch:v,targetBranch:C,sessions:i}){const{t:r}=ue(),[c,f]=k.useState(""),o=$r(),p=Wr(),b=()=>{if(!c)return;const n=Lf(v,C,m,a);o.mutate({id:c,message:n},{onSuccess:()=>t(!1)})},S=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},g=a==="REBASE"?"Rebase":"Merge";return l.jsx(Tr,{isOpen:e,onClose:()=>t(!1),title:r("解决 {opLabel} 冲突",{opLabel:g}),action:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ft,{variant:"outline",onClick:S,children:r("在 IDE 中打开")}),l.jsx(ft,{onClick:b,disabled:!c||o.isPending,children:o.isPending?r("发送中..."):r("AI 辅助解决")})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:r("冲突文件({count})",{count:m.length})}),l.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(n=>l.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:n},n))})]}),i.length>0&&l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:r("选择 Session(AI 辅助解决)")}),l.jsxs("select",{value:c,onChange:n=>f(n.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:[l.jsx("option",{value:"",children:r("选择一个 Session...")}),i.map(n=>l.jsxs("option",{value:n.id,children:[n.agentType," — ",n.status]},n.id))]})]}),i.length===0&&l.jsx("p",{className:"text-sm text-neutral-500",children:r("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Lt({children:e,variant:t}){const s={success:"bg-emerald-50 text-emerald-700 border-emerald-200",warning:"bg-amber-50 text-amber-700 border-amber-200",info:"bg-blue-50 text-blue-700 border-blue-200",neutral:"bg-neutral-50 text-neutral-600 border-neutral-200",danger:"bg-red-50 text-red-700 border-red-200"};return l.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${s[t]}`,children:e})}function Af({gitStatus:e,branchName:t,targetBranch:s}){const{t:a}=ue();return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),l.jsx(un,{size:14,className:"text-neutral-400"}),l.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:s})]}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&l.jsxs(Lt,{variant:"danger",children:[l.jsx(Ea,{size:12}),a("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&l.jsxs(Lt,{variant:"warning",children:[l.jsx(on,{size:12}),a("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&l.jsxs(Lt,{variant:"warning",children:[l.jsx(Ie,{size:12,className:"animate-spin"}),a("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&l.jsxs(Lt,{variant:"warning",children:[l.jsx(Ie,{size:12,className:"animate-spin"}),a("合并进行中")]}),e.ahead>0&&l.jsxs(Lt,{variant:"success",children:[l.jsx(ei,{size:12}),a("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&l.jsx(Lt,{variant:"warning",children:a("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&l.jsxs(Lt,{variant:"neutral",children:[l.jsx(ei,{size:12}),a("已是最新")]})]}),e.hasUncommittedChanges&&l.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:a("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function Mf({open:e,onOpenChange:t,workspaceId:s,branchName:a,targetBranch:m,commitMessage:v,onRefreshCommitMessage:C,onConflict:i}){const{t:r}=ue(),{data:c,isLoading:f}=vo(s),o=_f(),p=gf(),[b,S]=k.useState(null),[g,n]=k.useState("select"),[d,h]=k.useState(""),[u,_]=k.useState(!1),y=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;k.useEffect(()=>{e&&(n("select"),S(null),_(!1),C?.())},[e,C]),k.useEffect(()=>{!e||u||h(v??"")},[e,v,u]);const x=M=>{_(!0),h(I=>typeof M=="function"?M(I):M)},R=()=>{S(null),o.mutate(s,{onSuccess:()=>t(!1),onError:M=>{const I=M;I.status===409?(t(!1),i()):S(I.message??r("变基失败"))}})},T=()=>{S(null),n("confirm")},A=()=>{S(null);const M=d.trim()||void 0;p.mutate({id:s,commitMessage:M},{onSuccess:()=>t(!1),onError:I=>{const B=I;B.status===409?(t(!1),i()):S(B.message??r("合并失败"))}})},j=r(g==="confirm"?"确认合并":"Git 操作");return l.jsx(Tr,{isOpen:e,onClose:()=>t(!1),title:j,children:f||!c?l.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[l.jsx(Ie,{size:18,className:"animate-spin"}),l.jsx("span",{className:"text-sm",children:r("加载分支状态...")})]}):g==="confirm"?l.jsx(Pf,{editableMessage:d,setEditableMessage:x,error:b,isPending:p.isPending,onConfirm:A,onBack:()=>n("select"),branchName:a,targetBranch:m}):l.jsx(Nf,{gitStatus:c,branchName:a,targetBranch:m,error:b,isDirty:E,hasConflicts:y,isOperationInProgress:w,rebasePending:o.isPending,mergePending:p.isPending,onRebase:R,onMerge:T})})}function Nf({gitStatus:e,branchName:t,targetBranch:s,error:a,isDirty:m,hasConflicts:v,isOperationInProgress:C,rebasePending:i,mergePending:r,onRebase:c,onMerge:f}){const{t:o}=ue();return l.jsxs("div",{className:"space-y-5",children:[l.jsx(Af,{gitStatus:e,branchName:t,targetBranch:s}),a&&l.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("button",{onClick:c,disabled:i||v||C||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[l.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:l.jsx(ja,{size:16,className:"text-blue-600"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-neutral-900",children:o(i?"变基中...":"变基 (Rebase)")}),l.jsx("div",{className:"text-xs text-neutral-500",children:o("将当前分支变基到最新的 {targetBranch}",{targetBranch:s})})]})]}),l.jsxs("button",{onClick:f,disabled:r||v||C||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[l.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:l.jsx(vn,{size:16,className:"text-emerald-600"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-neutral-900",children:o(r?"合并中...":"合并 (Merge)")}),l.jsx("div",{className:"text-xs text-neutral-500",children:o("Squash merge 到 {targetBranch}",{targetBranch:s})})]})]})]})]})}function Pf({editableMessage:e,setEditableMessage:t,error:s,isPending:a,onConfirm:m,onBack:v,branchName:C,targetBranch:i}){const{t:r}=ue();return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:C}),l.jsx(un,{size:14,className:"text-neutral-400"}),l.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:i})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:r("提交消息")}),l.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:r("输入提交消息..."),rows:4,className:"w-full px-3 py-2 rounded-md 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"}),!e.trim()&&l.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:r("留空将使用默认消息")})]}),s&&l.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:s}),l.jsxs("div",{className:"flex gap-2 justify-end",children:[l.jsx("button",{onClick:v,disabled:a,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:r("返回")}),l.jsx("button",{onClick:m,disabled:a,className:"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:a?l.jsxs(l.Fragment,{children:[l.jsx(Ie,{size:14,className:"animate-spin"}),r("合并中...")]}):l.jsxs(l.Fragment,{children:[l.jsx(vn,{size:14}),r("确认合并")]})})]})]})}function Of({agentType:e,workingDir:t}){return st({queryKey:he.system.slashCommandCatalog(e,t),queryFn:async()=>(await ge.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function Bf(e,t){const s=new Set,a=[];for(const m of[...e,...t]){const v=m.command.trim().toLowerCase();!v||s.has(v)||(s.add(v),a.push(m.kind?m:{...m,kind:"builtin"}))}return a}function Ys(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function If(e){return Ys(e.command)}function Ff(e,t){if(!t)return 1e3;const s=If(e),a=e.aliases?.map(Ys)??[],m=[s,...a];let v=0;for(const i of m)i===t?v=Math.max(v,500):i.startsWith(t)?v=Math.max(v,400-(i.length-t.length)):i.includes(t)&&(v=Math.max(v,250-i.indexOf(t)));return v>0?v:`${s} ${a.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function Ii(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const s=t.index+t[1].length;return{query:Ys(t[2]),replaceStart:s}}function yo(e,t){const s=Ys(t);return s?e.map((a,m)=>({command:a,index:m,score:Ff(a,s)})).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 Hf=[{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"}],zf=[{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"}],Wf=[{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"}],$f=[{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"}],Uf={[dt.CODEX]:Hf,[dt.CLAUDE_CODE]:zf,[dt.GEMINI_CLI]:Wf,[dt.CURSOR_AGENT]:$f};function Co(e){return e.trim().toLowerCase().replace(/^\//,"")}function qf(e){return e?(Uf[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function Kf(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Co(t[1]):null}function Xf(e,t){return yo(e,Co(t))}function Yf(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function wo({agentType:e,workingDir:t,input:s,setInput:a,textareaRef:m,minHeight:v,maxHeight:C}){const[i,r]=k.useState(0),{data:c=[]}=Of({agentType:e,workingDir:t}),f=k.useMemo(()=>Bf(qf(e),c),[e,c]),o=k.useMemo(()=>Kf(s),[s]),p=k.useMemo(()=>o===null?[]:Xf(f,o),[f,o]),b=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{r(0)},[e,o]),k.useEffect(()=>{i<p.length||r(0)},[p.length,i]);const S=k.useCallback(n=>{const h=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${n.command} `;a(h),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,b,a,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),r(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),r(d=>(d-1+p.length)%p.length),!0):Yf(n)?(n.preventDefault(),S(p[i]??p[0]),!0):!1,[S,p,o,i]);return{allCommands:f,query:o,filteredCommands:p,selectedIndex:i,setSelectedIndex:r,applyCommand:S,handleKeyDown:g}}function Vf({agentType:e,workingDir:t}){return st({queryKey:he.system.skillCatalog(e,t),queryFn:async()=>(await ge.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===dt.CODEX,staleTime:3e4})}function Gf(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function Eo({agentType:e,workingDir:t,input:s,setInput:a,textareaRef:m,minHeight:v,maxHeight:C}){const[i,r]=k.useState(0),{data:c=[]}=Vf({agentType:e,workingDir:t}),o=k.useMemo(()=>e===dt.CODEX?Ii(s):null,[e,s])?.query??null,p=k.useMemo(()=>o===null?[]:yo(c,o),[o,c]),b=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{r(0)},[e,o]),k.useEffect(()=>{i<p.length||r(0)},[p.length,i]);const S=k.useCallback(n=>{const d=Ii(s);if(!d)return;const h=`${s.slice(0,d.replaceStart)}${n.command} `;a(h),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,b,a,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),r(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),r(d=>(d-1+p.length)%p.length),!0):Gf(n)?(n.preventDefault(),S(p[i]??p[0]),!0):!1,[S,p,o,i]);return{allSkills:c,query:o,filteredSkills:p,selectedIndex:i,setSelectedIndex:r,applySkill:S,handleKeyDown:g}}const Qf="/api",Zf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Qf}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Jf=({src:e,alt:t,...s})=>l.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:l.jsx("img",{src:e,alt:t,...s,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer hover:opacity-90 transition-opacity"})}),em={img:Jf},tm=675,Fi=320,Hi=1200;function sm(){const{t:e}=ue();return l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[l.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:l.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:[l.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),l.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),l.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),l.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 zi=[{status:ce.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:l.jsx(wr,{className:"w-3 h-3"})},{status:ce.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:l.jsx(Er,{className:"w-3 h-3"})},{status:ce.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:l.jsx(kr,{className:"w-3 h-3"})},{status:ce.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:l.jsx(Rr,{className:"w-3 h-3"})},{status:ce.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:l.jsx(Dr,{className:"w-3 h-3"})}];function rm({status:e,onChangeStatus:t}){const{t:s}=ue(),[a,m]=k.useState(!1),v=k.useRef(null);k.useEffect(()=>{if(!a)return;const i=r=>{v.current&&!v.current.contains(r.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]);const C=zi.find(i=>i.status===e);return l.jsxs("div",{className:"relative",ref:v,children:[l.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 ${C.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[C.icon,l.jsx("span",{children:s(e)}),t&&l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${a?"rotate-180":""}`,children:l.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),a&&l.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:zi.filter(i=>i.status!==e).map(i=>l.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:[l.jsx("span",{className:i.className.split(" ").find(r=>r.startsWith("text-")),children:i.icon}),l.jsx("span",{className:"text-neutral-700",children:s(i.status)})]},i.status))})]})}function im({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:a}){const{t:m}=ue(),[v,C]=k.useState(""),[i,r]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[b,S]=k.useState(!1),[g,n]=k.useState(!1),d=k.useRef(null),h=k.useRef(null),u=k.useRef(null),_=k.useRef(null),{scrollRef:y,contentRef:w,isAtBottom:E,scrollToBottom:x}=On({resize:"smooth",initial:"instant"}),[R,T]=k.useState(tm),[A,j]=k.useState(!0),[M,I]=k.useState(!1),B=k.useRef(0),H=k.useRef(0),z=k.useRef(null),{data:D,isLoading:N}=po(e?.id??""),P=Sf(e?.id),O=k.useMemo(()=>{if(!D)return null;const V=$e=>{const Vs=$e.createdAt,Ut=$e.endedAt??$e.startedAt??Vs;if(!Ut)return 0;const Pt=Date.parse(Ut);return Number.isNaN(Pt)?0:Pt},te=($e,Vs)=>{const Ut=$e.filter(Pt=>Vs.includes(Pt.status));return Ut.length===0?null:Ut.sort((Pt,zo)=>V(zo)-V(Pt))[0]??null},Ee=D.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),Ye=te(Ee,[Pe.RUNNING])??te(Ee,[Pe.PENDING])??te(Ee,[Pe.COMPLETED,Pe.FAILED,Pe.CANCELLED]);if(Ye)return Ye;const ct=D.filter($e=>$e.status==="MERGED"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]);return te(ct,[Pe.COMPLETED,Pe.FAILED,Pe.CANCELLED])},[D]),$=O?.id??"",K=O?.status===Pe.RUNNING||O?.status===Pe.PENDING,{data:Q}=Os(),[G,ne]=k.useState(null);k.useEffect(()=>{ne(O?.providerId??null)},[O?.providerId]);const L=k.useMemo(()=>!O||!D?!1:!D.some(te=>te.status==="ACTIVE"&&te.sessions?.some(Ee=>Ee.id===O.id)),[O,D]),F=k.useMemo(()=>{if(D){for(const V of D)if(V.status==="ACTIVE"&&V.worktreePath)return V.worktreePath;return D[0]?.worktreePath}},[D]),U=wo({agentType:O?.agentType,workingDir:F,input:v,setInput:C,textareaRef:u,minHeight:60,maxHeight:300}),W=Eo({agentType:O?.agentType,workingDir:F,input:v,setInput:C,textareaRef:u,minHeight:60,maxHeight:300}),Z=k.useMemo(()=>D?D.find(te=>te.status==="ACTIVE")?.id:void 0,[D]),{data:X}=vo(Z??""),oe=k.useMemo(()=>D?D.find(te=>te.status==="ACTIVE")?.sessions??[]:[],[D]),me=k.useMemo(()=>D?D.find(te=>te.status==="ACTIVE")?.branchName??"":"",[D]),xe=k.useMemo(()=>D?D.find(te=>te.status==="ACTIVE")?.commitMessage:void 0,[D]),_e=Fe(),ie=k.useCallback(()=>e?.id?_e.invalidateQueries({queryKey:he.workspaces.list(e.id)}):Promise.resolve(),[e?.id,_e]);k.useEffect(()=>{if(!g)return;const V=te=>{h.current&&!h.current.contains(te.target)&&n(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[g]);const Ce=$r(),Oe=Wr(),Le=k.useCallback(()=>{Z&&Oe.mutate({workspaceId:Z})},[Z,Oe]),Xe=k.useCallback(()=>{!e?.id||!t||(t(e.id),f(!1))},[e?.id,t]),{isConnected:We,isLoadingSnapshot:Te,logs:Ke,entries:He,attach:Me}=Ji({sessionId:$,onExit:k.useCallback(()=>{_e.invalidateQueries({queryKey:["workspaces"]})},[_e])});k.useEffect(()=>{if(!e?.id)return;const V=vt.connect();V.emit(ut.SUBSCRIBE,{topic:"task",id:e.id});const te=Ye=>{Ye.taskId===e.id&&_e.invalidateQueries({queryKey:["tasks"]})},Ee=Ye=>{Ye.taskId===e.id&&_e.invalidateQueries({queryKey:he.workspaces.list(e.id)})};return V.on(Be.TASK_UPDATED,te),V.on(Be.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ee),()=>{V.off(Be.TASK_UPDATED,te),V.off(Be.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ee),V.emit(ut.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,_e]),k.useEffect(()=>{if(!$)return;const V=vt.connect(),te=Ee=>{Ee.sessionId===$&&_e.invalidateQueries({queryKey:["workspaces"]})};return V.on(Be.SESSION_COMPLETED,te),()=>{V.off(Be.SESSION_COMPLETED,te)}},[$,_e]);const{todos:Y}=en(He),{files:se,addFiles:fe,removeFile:re,clear:de,buildMarkdownLinks:ae,hasFiles:je,isUploading:rt}=Ur(),mt=k.useMemo(()=>{if(!O?.tokenUsage)return;const V=O.tokenUsage;if(typeof V.totalTokens=="number")return V},[O?.tokenUsage]),Dt=bo(Ke,mt);k.useEffect(()=>{$&&We&&Me()},[$,We,Me]);const Tt=k.useRef(e?.id);k.useEffect(()=>{Tt.current!==e?.id&&x(),Tt.current=e?.id},[e?.id,x]);const pt=_o(),bt=k.useRef(!1),$t=k.useCallback(async()=>{if(!v.trim()&&!je||!$||bt.current||rt)return;bt.current=!0;const V=ae(),te=[v.trim(),V].filter(Boolean).join(`
|
|
76
|
-
|
|
77
|
-
`);C(""),de(),u.current&&(u.current.style.height="60px"),Ce.mutate({id:$,message:te,providerId:G??void 0},{onSuccess:()=>{Me()},onSettled:()=>{bt.current=!1}})},[v,$,Ce,Me,je,rt,ae,de,G]),q=k.useCallback(async()=>{$&&(await pt.mutateAsync($),_e.invalidateQueries({queryKey:["workspaces"]}))},[$,pt,_e]),J=k.useCallback(V=>{const te=V.target.files;te&&te.length>0&&fe(Array.from(te)),V.target.value=""},[fe]),le=k.useCallback(V=>{const te=V.clipboardData.items,Ee=[];for(const Ye of te)if(Ye.kind==="file"){const ct=Ye.getAsFile();ct&&Ee.push(ct)}Ee.length>0&&(V.preventDefault(),fe(Ee))},[fe]),[pe,ye]=k.useState(!1),Re=k.useCallback(V=>{V.preventDefault(),ye(!0)},[]),qe=k.useCallback(V=>{V.preventDefault(),ye(!1)},[]),Qe=k.useCallback(V=>{V.preventDefault(),ye(!1);const te=V.dataTransfer.files;te.length>0&&fe(Array.from(te))},[fe]),at=k.useCallback(V=>{const te=V.clientX-B.current,Ee=Math.max(Fi,Math.min(H.current+te,Hi));z.current&&(z.current.style.width=`${Ee}px`),H.current=H.current},[]),Ne=k.useCallback(()=>{if(I(!1),z.current){const V=z.current.getBoundingClientRect().width;T(Math.max(Fi,Math.min(Math.round(V),Hi)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);k.useEffect(()=>{if(M)return document.addEventListener("mousemove",at),document.addEventListener("mouseup",Ne),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",at),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect=""}},[M,at,Ne]);const lt=k.useCallback(V=>{V.preventDefault(),B.current=V.clientX,H.current=R,I(!0)},[R]),Je=k.useCallback(()=>{j(V=>!V)},[]),it=k.useCallback(V=>{C(V.target.value);const te=V.target;te.style.height="auto";const Ee=te.scrollHeight;te.style.height=`${Math.max(60,Math.min(Ee,300))}px`},[]),xt=k.useMemo(()=>{const V=[];if(D&&D.length>0){const te=D.some(ct=>ct.status==="ACTIVE"),Ee=D.some(ct=>ct.sessions?.some($e=>$e.status===Pe.RUNNING||$e.status===Pe.PENDING)),Ye=D.some(ct=>ct.status==="ACTIVE");Ee&&V.push(m("正在运行的 Agent 将被停止")),Ye&&V.push(m("分支上未合并的变更将丢失")),te&&V.push(m("关联的工作目录(worktree)将被清理"))}return V},[D,m]);return e?l.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[l.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:[l.jsxs("div",{className:"flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[l.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),l.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),l.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),l.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(rm,{status:e.status,onChangeStatus:a?V=>a(e.id,V):void 0}),Z&&l.jsx("button",{onClick:()=>S(!0),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("Git 操作"),children:l.jsx(Ma,{size:18})}),l.jsx("button",{onClick:Le,disabled:!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 disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:l.jsx(Bs,{size:18})}),l.jsx("button",{onClick:Je,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:A?l.jsx(Ya,{size:18}):l.jsx(Ga,{size:18})}),t&&l.jsxs("div",{className:"relative",ref:h,children:[l.jsx("button",{onClick:()=>n(V=>!V),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:l.jsx(fn,{size:18})}),g&&l.jsx("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:l.jsxs("button",{onClick:()=>{f(!0),n(!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:[l.jsx(ln,{size:15}),l.jsx("span",{children:m("删除任务")})]})})]})]})]}),Z&&X&&l.jsx(Tf,{workspaceId:Z,gitStatus:X,onResolve:()=>p(!0)}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsxs("div",{ref:z,className:`flex flex-col bg-white relative ${A?"flex-shrink-0":"flex-1"}`,style:{width:A?R:"100%"},children:[l.jsxs("div",{className:"relative flex-1 min-h-0",children:[l.jsx("div",{ref:y,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:l.jsxs("div",{ref:w,className:"w-full",children:[l.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?l.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:l.jsx(tn,{urlTransform:Zf,components:em,children:e.description})}):l.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),P&&l.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[P.status==="running"&&l.jsxs(l.Fragment,{children:[l.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:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:P.currentIndex,total:P.totalCommands,command:P.currentCommand})})]}),P.status==="completed"&&l.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),P.status==="failed"&&l.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:P.error})})]}),N?l.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[l.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l.jsx("span",{className:"text-sm",children:m("Loading...")})]}):$?Te?l.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[l.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):Ke.length===0?l.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(K?"Waiting for agent output...":"No logs recorded for this session.")}):l.jsx(sn,{logs:Ke}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[l.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:l.jsx(It,{size:24,className:"text-neutral-400 ml-0.5"})}),l.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m("尚未启动 Agent")}),l.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),l.jsxs(ft,{onClick:()=>r(!0),children:[l.jsx(It,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!E&&l.jsxs("button",{onClick:()=>x(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-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:[l.jsx(hn,{size:14}),l.jsx("span",{children:m("回到底部")})]})]}),Y.length>0&&l.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:l.jsx(rn,{todos:Y})}),L?l.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:l.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[l.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),l.jsxs(ft,{size:"sm",onClick:()=>r(!0),children:[l.jsx(It,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):l.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Re,onDragLeave:qe,onDrop:Qe,children:[l.jsxs("div",{ref:d,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 ${pe?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[l.jsx(Ls,{files:se,onRemove:re}),l.jsx("textarea",{ref:u,value:v,onChange:it,onPaste:le,onKeyDown:V=>{W.handleKeyDown(V)||U.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),$t())},rows:1,placeholder:m(pe?"Drop files here...":$&&!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"}}),l.jsx("input",{ref:_,type:"file",multiple:!0,className:"hidden",onChange:J}),l.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[l.jsx("div",{className:"flex items-center gap-1",children:l.jsx("button",{onClick:()=>_.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:l.jsx(xs,{size:18})})}),l.jsxs("div",{className:"flex items-center gap-2",children:[O&&Q&&l.jsx(So,{providers:Q,currentProviderId:G,agentType:O.agentType,onSelect:ne}),l.jsx(Bn,{usage:Dt}),K&&!v.trim()&&!je?l.jsx("button",{onClick:q,disabled:pt.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:l.jsx(nn,{size:14})}):l.jsx("button",{onClick:$t,disabled:!v.trim()&&!je||rt,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||je)&&!rt?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:l.jsx(dn,{size:18})})]})]})]}),l.jsx(js,{open:U.query!==null,anchorRef:d,commands:U.filteredCommands,selectedIndex:U.selectedIndex,query:U.query??"",hasCatalog:U.allCommands.length>0,onSelect:U.applyCommand}),l.jsx(js,{open:W.query!==null,anchorRef:d,commands:W.filteredSkills,selectedIndex:W.selectedIndex,query:W.query??"",hasCatalog:W.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:W.applySkill})]})]}),A&&l.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:lt}),A&&l.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:l.jsx(mo,{sessionId:$||void 0,workingDir:F,projectId:e.projectId})})]}),l.jsx(xo,{isOpen:i,onClose:()=>r(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),Z&&l.jsx(Mf,{open:b,onOpenChange:S,workspaceId:Z,branchName:me,targetBranch:e.mainBranch,commitMessage:xe,onRefreshCommitMessage:ie,onConflict:()=>p(!0)}),Z&&X&&X.conflictOp&&l.jsx(jf,{open:o,onOpenChange:p,workspaceId:Z,conflictOp:X.conflictOp,conflictedFiles:X.conflictedFiles,sourceBranch:me,targetBranch:e.mainBranch,sessions:oe}),l.jsx(an,{isOpen:c,onClose:()=>f(!1),onConfirm:Xe,title:m("删除任务"),description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),xt.length>0&&l.jsx("ul",{className:"mt-2 space-y-1",children:xt.map((V,te)=>l.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[l.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),l.jsx("span",{children:V})]},te))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):l.jsx(sm,{})}function qr(e){switch(e){case ht.TODO:return ce.Pending;case ht.IN_PROGRESS:return ce.Running;case ht.IN_REVIEW:return ce.Review;case ht.DONE:return ce.Done;case ht.CANCELLED:return ce.Cancelled}}function nm(e){switch(e){case ce.Pending:return ht.TODO;case ce.Running:return ht.IN_PROGRESS;case ce.Review:return ht.IN_REVIEW;case ce.Done:return ht.DONE;case ce.Cancelled:return ht.CANCELLED}}function om(e){switch(e){case dt.CLAUDE_CODE:return"Claude Code";case dt.GEMINI_CLI:return"Gemini CLI";case dt.CURSOR_AGENT:return"Cursor Agent";case dt.CODEX:return"Codex"}}const As=["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 ko(e,t){let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a)|0;return Math.abs(s)%t}function Ro(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function am(e){return{id:e.id,name:e.name,color:e.color||As[ko(e.name,As.length)]}}function lm(e){const t=Ro(e);if(!t)return{agent:"—",branch:"—"};const s=t.branchName,a=t.sessions;if(a&&a.length>0){const m=a[a.length-1];return{agent:om(m.agentType),branch:s}}return{agent:"—",branch:s}}function cm(e){const{agent:t,branch:s}=lm(e.workspaces);return{id:e.id,projectId:e.projectId,title:e.title,status:qr(e.status),agent:t,branch:s,description:e.description??""}}function hm(e,t,s){const a=Ro(e.workspaces,s),m=a?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||As[ko(t.name,As.length)],title:e.title,status:qr(e.status),branch:m,mainBranch:a?.baseBranch??t.mainBranch??"main",description:e.description??""}}function um(e,t){const s={};return st({queryKey:he.tasks.list(e,t),queryFn:()=>ge.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function dm(e){const t=Fe();return Ge({mutationFn:s=>ge.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:he.tasks.list(e)}),t.invalidateQueries({queryKey:he.tasks.stats(e)})}})}function fm(){const e=Fe();return Ge({mutationFn:({id:t,status:s})=>ge.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:he.tasks.all}),e.invalidateQueries({queryKey:he.tasks.detail(t.id)})}})}function mm(){const e=Fe();return Ge({mutationFn:t=>ge.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:he.tasks.all})}})}function pm(e){const t=Fe(),s=k.useRef(new Set);k.useEffect(()=>{if(e.length===0)return;const a=vt.connect(),m=s.current,v=new Set(e);for(const r of v)m.has(r)||a.emit(ut.SUBSCRIBE,{topic:"project",id:r},c=>{c.success&&m.add(r)});for(const r of m)v.has(r)||a.emit(ut.UNSUBSCRIBE,{topic:"project",id:r},()=>{m.delete(r)});const C=r=>{t.invalidateQueries({queryKey:he.tasks.list(r.projectId)}),t.invalidateQueries({queryKey:he.tasks.detail(r.taskId)})},i=r=>{t.invalidateQueries({queryKey:he.tasks.list(r.projectId)}),t.removeQueries({queryKey:he.tasks.detail(r.taskId)})};return a.on(Be.TASK_UPDATED,C),a.on(Be.TASK_DELETED,i),()=>{a.off(Be.TASK_UPDATED,C),a.off(Be.TASK_DELETED,i);for(const r of m)a.emit(ut.UNSUBSCRIBE,{topic:"project",id:r});m.clear()}},[e,t])}const Do=768;function vm(e){const t=window.matchMedia(`(max-width: ${Do-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function gm(){return window.innerWidth<Do}function _m(){return!1}function bm(){return k.useSyncExternalStore(vm,gm,_m)}const Wi={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 xm(e){const t=e.split("/");return t[t.length-1]||e}function Sm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function ym({workingDir:e,filePath:t,type:s}){const{t:a}=ue(),{data:m,isLoading:v,isError:C}=ho(e,t,s);if(v)return l.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[l.jsx(Ie,{size:14,className:"animate-spin"}),l.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(C)return l.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 l.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const r=i.split(`
|
|
78
|
-
`);return l.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),l.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function Cm({entry:e,type:t,workingDir:s}){const[a,m]=k.useState(!1),v=Wi[e.status]||Wi.M,C=Sm(e.path);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>m(i=>!i),className:Se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[l.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:xm(e.path)}),C&&l.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),l.jsx("span",{className:"text-neutral-400 shrink-0",children:a?l.jsx(_t,{size:14}):l.jsx(Nt,{size:14})})]}),a&&l.jsx(ym,{workingDir:s,filePath:e.path,type:t})]})}function $i({title:e,entries:t,type:s,workingDir:a,defaultOpen:m}){const{t:v}=ue(),[C,i]=k.useState(m);return t.length===0?null:l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>i(r=>!r),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[l.jsx("span",{className:"text-neutral-400",children:C?l.jsx(_t,{size:14}):l.jsx(Nt,{size:14})}),l.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),l.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),C&&l.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(r=>l.jsx(Cm,{entry:r,type:s,workingDir:a},`${s}:${r.path}`))})]})}function wm({workingDir:e}){const{t}=ue(),{data:s,isLoading:a,isError:m}=co(e);if(!e)return l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(a)return l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return l.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const v=s?.uncommitted||[],C=s?.committed||[];return v.length+C.length===0?l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[l.jsx(es,{size:28,className:"mb-3"}),l.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):l.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[l.jsx($i,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),l.jsx($i,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const hr=50,Ui={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 Em(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ct("{count}s ago",{count:s}):s<3600?Ct("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ct("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ct("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function km(e){const t=e.split("/");return t[t.length-1]||e}function Rm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Dm({workingDir:e,hash:t,filePath:s}){const{t:a}=ue(),{data:m,isLoading:v,isError:C}=fo(e,t,s);if(v)return l.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[l.jsx(Ie,{size:14,className:"animate-spin"}),l.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(C)return l.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 l.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const r=i.split(`
|
|
79
|
-
`);return l.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),l.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function Tm({entry:e,workingDir:t,hash:s}){const[a,m]=k.useState(!1),v=Ui[e.status]||Ui.M,C=Rm(e.path);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>m(i=>!i),className:Se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[l.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:km(e.path)}),C&&l.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),l.jsx("span",{className:"text-neutral-400 shrink-0",children:a?l.jsx(_t,{size:14}):l.jsx(Nt,{size:14})})]}),a&&l.jsx(Dm,{workingDir:t,hash:s,filePath:e.path})]})}function Lm({commit:e,workingDir:t}){const{t:s}=ue(),[a,m]=k.useState(!1),{data:v,isLoading:C}=uo(t,a?e.hash:null),i=v?.files||[];return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>m(r=>!r),className:Se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[l.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:l.jsx("div",{className:Se("w-2.5 h-2.5 rounded-full shrink-0",a?"bg-blue-500":"bg-neutral-300")})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),l.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[l.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),l.jsx("span",{className:"text-[11px] text-neutral-400",children:Em(e.timestamp)})]})]}),l.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:a?l.jsx(_t,{size:14}):l.jsx(Nt,{size:14})})]}),a&&l.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&l.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),C?l.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[l.jsx(Ie,{size:14,className:"animate-spin"}),l.jsx("span",{className:"text-xs",children:s("Loading files...")})]}):i.length===0?l.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:s("No files changed")}):l.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(r=>l.jsx(Tm,{entry:r,workingDir:t,hash:e.hash},r.path))})]})]})}function jm({workingDir:e}){const{t}=ue(),{data:s,isLoading:a,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:i}=cn({queryKey:he.git.log(e||""),queryFn:({pageParam:c=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(hr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<hr?void 0:f.length*hr,enabled:!!e}),r=s?.pages.flatMap(c=>c.commits)||[];return e?a?l.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[l.jsx(Ie,{size:16,className:"animate-spin mr-2"}),l.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?l.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):r.length===0?l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[l.jsx(Ht,{size:28,className:"mb-3"}),l.jsx("span",{className:"text-sm",children:t("No commit history")})]}):l.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[l.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(c=>l.jsx(Lm,{commit:c,workingDir:e},c.hash))}),C&&l.jsx("button",{type:"button",onClick:()=>v(),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?l.jsxs(l.Fragment,{children:[l.jsx(Ie,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const Am="/api",Mm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Am}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Nm=({src:e,alt:t,...s})=>l.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:l.jsx("img",{src:e,alt:t,...s,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer active:opacity-90 transition-opacity"})}),Pm={img:Nm};function Om({status:e}){const t={[ce.Running]:"bg-blue-500",[ce.Review]:"bg-amber-500",[ce.Pending]:"bg-neutral-400",[ce.Done]:"bg-emerald-500",[ce.Cancelled]:"bg-neutral-400"};return l.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Bm=[{key:"chat",label:"Chat",icon:Wa},{key:"changes",label:"Changes",icon:es},{key:"history",label:"History",icon:Ht},{key:"workspace",label:"Workspace",icon:pn}];function Im({task:e,onBack:t,onDeleteTask:s,isDeleting:a}){const{t:m}=ue(),[v,C]=k.useState("chat"),[i,r]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[b,S]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:y,scrollToBottom:w}=On({resize:"smooth",initial:"instant"}),E=Fe();k.useEffect(()=>{if(!b)return;const Y=se=>{n.current&&!n.current.contains(se.target)&&S(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[b]);const{data:x,isLoading:R}=po(e.id),T=k.useMemo(()=>{if(!x)return null;const Y=x.filter(re=>re.status==="ACTIVE"&&Array.isArray(re.sessions)).flatMap(re=>re.sessions??[]),se=re=>{const de=re.createdAt,ae=re.endedAt??re.startedAt??de;if(!ae)return 0;const je=Date.parse(ae);return Number.isNaN(je)?0:je},fe=re=>{const de=Y.filter(ae=>re.includes(ae.status));return de.length===0?null:de.sort((ae,je)=>se(je)-se(ae))[0]??null};return fe([Pe.RUNNING])??fe([Pe.PENDING])??fe([Pe.COMPLETED,Pe.FAILED,Pe.CANCELLED])},[x]),A=T?.id??"",j=T?.status===Pe.RUNNING||T?.status===Pe.PENDING,{data:M}=Os(),[I,B]=k.useState(null);k.useEffect(()=>{B(T?.providerId??null)},[T?.providerId]);const H=k.useMemo(()=>{if(x){for(const Y of x)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return x[0]?.worktreePath}},[x]),z=wo({agentType:T?.agentType,workingDir:H,input:i,setInput:r,textareaRef:d,minHeight:40,maxHeight:140}),D=Eo({agentType:T?.agentType,workingDir:H,input:i,setInput:r,textareaRef:d,minHeight:40,maxHeight:140}),N=k.useMemo(()=>{if(x)return x.find(Y=>Y.status==="ACTIVE")?.id},[x]),P=k.useMemo(()=>{const Y=[];if(x&&x.length>0){const se=x.some(re=>re.status==="ACTIVE");x.some(re=>re.sessions?.some(de=>de.status===Pe.RUNNING||de.status===Pe.PENDING))&&Y.push(m("正在运行的 Agent 将被停止")),se&&(Y.push(m("分支上未合并的变更将丢失")),Y.push(m("关联的工作目录(worktree)将被清理")))}return Y},[x,m]),O=$r(),$=Wr(),K=_o(),{isConnected:Q,isLoadingSnapshot:G,logs:ne,entries:L,attach:F}=Ji({sessionId:A,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:U}=en(L),{files:W,addFiles:Z,removeFile:X,clear:oe,buildMarkdownLinks:me,hasFiles:xe,isUploading:_e}=Ur(),ie=k.useMemo(()=>{if(!T?.tokenUsage)return;const Y=T.tokenUsage;if(typeof Y.totalTokens=="number")return Y},[T?.tokenUsage]),Ce=bo(ne,ie);k.useEffect(()=>{A&&Q&&F()},[A,Q,F]),k.useEffect(()=>{w()},[e.id,w]);const Oe=k.useRef(!1),Le=k.useCallback(async()=>{if(!i.trim()&&!xe||!A||Oe.current||_e)return;Oe.current=!0;const Y=me(),se=[i.trim(),Y].filter(Boolean).join(`
|
|
80
|
-
|
|
81
|
-
`);r(""),oe(),d.current&&(d.current.style.height="40px"),O.mutate({id:A,message:se,providerId:I??void 0},{onSuccess:()=>F(),onSettled:()=>{Oe.current=!1}})},[i,A,O,F,xe,_e,me,oe,I]),Xe=k.useCallback(async()=>{A&&(await K.mutateAsync(A),E.invalidateQueries({queryKey:["workspaces"]}))},[A,K,E]),We=k.useCallback(Y=>{const se=Y.target.files;se&&se.length>0&&Z(Array.from(se)),Y.target.value=""},[Z]),Te=k.useCallback(Y=>{const se=Y.clipboardData.items,fe=[];for(const re of se)if(re.kind==="file"){const de=re.getAsFile();de&&fe.push(de)}fe.length>0&&(Y.preventDefault(),Z(fe))},[Z]),Ke=k.useCallback(Y=>{r(Y.target.value);const se=Y.target;se.style.height="auto",se.style.height=`${Math.max(40,Math.min(se.scrollHeight,140))}px`},[]),He=k.useCallback(()=>{N&&$.mutate({workspaceId:N})},[N,$]),Me=k.useRef(null);return k.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let se=!1;const fe=()=>{Me.current&&(Me.current.style.height=`${Y.height}px`,Me.current.style.top=`${Y.offsetTop}px`)},re=()=>fe(),de=()=>{se||fe()},ae=()=>{se=!0},je=()=>{se=!1,requestAnimationFrame(fe)};return Y.addEventListener("resize",re),Y.addEventListener("scroll",de),document.addEventListener("touchstart",ae,{passive:!0}),document.addEventListener("touchend",je,{passive:!0}),document.addEventListener("touchcancel",je,{passive:!0}),()=>{Y.removeEventListener("resize",re),Y.removeEventListener("scroll",de),document.removeEventListener("touchstart",ae),document.removeEventListener("touchend",je),document.removeEventListener("touchcancel",je)}},[]),k.useEffect(()=>{const Y=Me.current;if(!Y)return;const se=fe=>{let re=fe.target;for(;re&&re!==Y;){if(re.tagName==="TEXTAREA"){if(re.scrollHeight>re.clientHeight)return;re=re.parentElement;continue}const ae=window.getComputedStyle(re).overflowY;if((ae==="auto"||ae==="scroll")&&re.scrollHeight>re.clientHeight)return;re=re.parentElement}fe.preventDefault()};return Y.addEventListener("touchmove",se,{passive:!1}),()=>Y.removeEventListener("touchmove",se)},[]),l.jsxs("div",{ref:Me,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[l.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[l.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[l.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:l.jsx(sa,{size:18})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),l.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[l.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),l.jsx("span",{className:"text-neutral-300",children:"/"}),l.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),l.jsx(Om,{status:e.status}),l.jsx("button",{onClick:He,disabled:!N,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:l.jsx(Bs,{size:16})}),s&&l.jsxs("div",{className:"relative",ref:n,children:[l.jsx("button",{onClick:()=>S(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:l.jsx(fn,{size:16})}),b&&l.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:l.jsxs("button",{onClick:()=>{p(!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:[l.jsx(ln,{size:15}),l.jsx("span",{children:m("删除任务")})]})})]})]}),l.jsx("div",{className:"flex border-t border-neutral-100",children:Bm.map(({key:Y,label:se,icon:fe})=>l.jsxs("button",{onClick:()=>C(Y),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[l.jsx(fe,{size:13}),l.jsx("span",{children:se})]},Y))})]}),v==="chat"&&l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{className:"relative flex-1 min-h-0",children:[l.jsx("div",{ref:u,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:l.jsxs("div",{ref:_,children:[l.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?l.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:l.jsx(tn,{urlTransform:Mm,components:Pm,children:e.description})}):l.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?l.jsx(qi,{label:"Loading..."}):A?G?l.jsx(qi,{label:"Loading logs..."}):ne.length===0?l.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:j?"Waiting for agent output...":"No logs recorded."}):l.jsx(sn,{logs:ne}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:l.jsx(It,{size:20,className:"text-neutral-400 ml-0.5"})}),l.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),l.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:m("选择一个 Agent 来执行此任务")}),l.jsxs(ft,{onClick:()=>f(!0),children:[l.jsx(It,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!y&&l.jsxs("button",{onClick:()=>w(),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:[l.jsx(hn,{size:12}),l.jsx("span",{children:m("回到底部")})]})]}),U.length>0&&l.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:l.jsx(rn,{todos:U,compact:!0})}),A&&l.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[l.jsxs("div",{ref:g,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[l.jsx(Ls,{files:W,onRemove:X}),l.jsx("textarea",{ref:d,value:i,onChange:Ke,onPaste:Te,onKeyDown:Y=>{D.handleKeyDown(Y)||z.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),Le())},rows:1,placeholder:j?"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}}),l.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:We}),l.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[l.jsx("div",{className:"flex items-center gap-0.5",children:l.jsx("button",{onClick:()=>h.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:l.jsx(xs,{size:15})})}),l.jsxs("div",{className:"flex items-center gap-1",children:[T&&M&&l.jsx(So,{providers:M,currentProviderId:I,agentType:T.agentType,onSelect:B}),l.jsx(Bn,{usage:Ce}),j&&!i.trim()&&!xe?l.jsx("button",{onClick:Xe,disabled:K.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:l.jsx(nn,{size:12})}):l.jsx("button",{onClick:Le,disabled:!i.trim()&&!xe||_e,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||xe)&&!_e?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:l.jsx(dn,{size:15})})]})]})]}),l.jsx(js,{open:z.query!==null,anchorRef:g,commands:z.filteredCommands,selectedIndex:z.selectedIndex,query:z.query??"",hasCatalog:z.allCommands.length>0,compact:!0,onSelect:z.applyCommand}),l.jsx(js,{open:D.query!==null,anchorRef:g,commands:D.filteredSkills,selectedIndex:D.selectedIndex,query:D.query??"",hasCatalog:D.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:D.applySkill})]})]}),v==="changes"&&l.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:l.jsx(wm,{workingDir:H})}),v==="history"&&l.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:l.jsx(jm,{workingDir:H})}),v==="workspace"&&l.jsx("div",{className:"flex-1 overflow-hidden",children:l.jsx(mo,{sessionId:A||void 0,workingDir:H,projectId:e.projectId,className:"h-full",hideChanges:!0})}),l.jsx(xo,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),l.jsx(an,{isOpen:o,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),P.length>0&&l.jsx("ul",{className:"mt-2 space-y-1",children:P.map((Y,se)=>l.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[l.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),l.jsx("span",{children:Y})]},se))})]}),confirmText:m("删除"),variant:"danger",isLoading:a})]})}function qi({label:e}){return l.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[l.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l.jsx("span",{className:"text-sm",children:e})]})}var Fm=Object.defineProperty,Ms=Object.getOwnPropertySymbols,To=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable,Ki=(e,t,s)=>t in e?Fm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Sr=(e,t)=>{for(var s in t||(t={}))To.call(t,s)&&Ki(e,s,t[s]);if(Ms)for(var s of Ms(t))Lo.call(t,s)&&Ki(e,s,t[s]);return e},yr=(e,t)=>{var s={};for(var a in e)To.call(e,a)&&t.indexOf(a)<0&&(s[a]=e[a]);if(e!=null&&Ms)for(var a of Ms(e))t.indexOf(a)<0&&Lo.call(e,a)&&(s[a]=e[a]);return s};var Mt;(e=>{const t=class ve{constructor(r,c,f,o){if(this.version=r,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],r<ve.MIN_VERSION||r>ve.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=r*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(f);if(this.drawCodewords(b),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(r,c){const f=e.QrSegment.makeSegments(r);return ve.encodeSegments(f,c)}static encodeBinary(r,c){const f=e.QrSegment.makeBytes(r);return ve.encodeSegments([f],c)}static encodeSegments(r,c,f=1,o=40,p=-1,b=!0){if(!(ve.MIN_VERSION<=f&&f<=o&&o<=ve.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=f;;S++){const u=ve.getNumDataCodewords(S,c)*8,_=C.getTotalBits(r,S);if(_<=u){g=_;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[ve.Ecc.MEDIUM,ve.Ecc.QUARTILE,ve.Ecc.HIGH])b&&g<=ve.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of r){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=ve.getNumDataCodewords(S,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new ve(S,c,h,p)}getModule(r,c){return 0<=r&&r<this.size&&0<=c&&c<this.size&&this.modules[c][r]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const r=this.getAlignmentPatternPositions(),c=r.length;for(let f=0;f<c;f++)for(let o=0;o<c;o++)f==0&&o==0||f==0&&o==c-1||f==c-1&&o==0||this.drawAlignmentPattern(r[f],r[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(r){const c=this.errorCorrectionLevel.formatBits<<3|r;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const o=(c<<10|f)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,a(o,p));this.setFunctionModule(8,7,a(o,6)),this.setFunctionModule(8,8,a(o,7)),this.setFunctionModule(7,8,a(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,a(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,a(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,a(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let r=this.version;for(let f=0;f<12;f++)r=r<<1^(r>>>11)*7973;const c=this.version<<12|r;m(c>>>18==0);for(let f=0;f<18;f++){const o=a(c,f),p=this.size-11+f%3,b=Math.floor(f/3);this.setFunctionModule(p,b,o),this.setFunctionModule(b,p,o)}}drawFinderPattern(r,c){for(let f=-4;f<=4;f++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(f)),b=r+o,S=c+f;0<=b&&b<this.size&&0<=S&&S<this.size&&this.setFunctionModule(b,S,p!=2&&p!=4)}}drawAlignmentPattern(r,c){for(let f=-2;f<=2;f++)for(let o=-2;o<=2;o++)this.setFunctionModule(r+o,c+f,Math.max(Math.abs(o),Math.abs(f))!=1)}setFunctionModule(r,c,f){this.modules[c][r]=f,this.isFunction[c][r]=!0}addEccAndInterleave(r){const c=this.version,f=this.errorCorrectionLevel;if(r.length!=ve.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const o=ve.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=ve.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],b=Math.floor(ve.getNumRawDataModules(c)/8),S=o-b%o,g=Math.floor(b/o);let n=[];const d=ve.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let y=r.slice(_,_+g-p+(u<S?0:1));_+=y.length;const w=ve.reedSolomonComputeRemainder(y,d);u<S&&y.push(0),n.push(y.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,y)=>{(u!=g-p||y>=S)&&h.push(_[u])});return m(h.length==b),h}drawCodewords(r){if(r.length!=Math.floor(ve.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const b=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][b]&&c<r.length*8&&(this.modules[g][b]=a(r[c>>>3],7-(c&7)),c++)}}m(c==r.length*8)}applyMask(r){if(r<0||r>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let o;switch(r){case 0:o=(f+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=f%3==0;break;case 3:o=(f+c)%3==0;break;case 4:o=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:o=f*c%2+f*c%3==0;break;case 6:o=(f*c%2+f*c%3)%2==0;break;case 7:o=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&o&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let r=0;for(let p=0;p<this.size;p++){let b=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==b?(S++,S==5?r+=ve.PENALTY_N1:S>5&&r++):(this.finderPenaltyAddHistory(S,g),b||(r+=this.finderPenaltyCountPatterns(g)*ve.PENALTY_N3),b=this.modules[p][n],S=1);r+=this.finderPenaltyTerminateAndCount(b,S,g)*ve.PENALTY_N3}for(let p=0;p<this.size;p++){let b=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==b?(S++,S==5?r+=ve.PENALTY_N1:S>5&&r++):(this.finderPenaltyAddHistory(S,g),b||(r+=this.finderPenaltyCountPatterns(g)*ve.PENALTY_N3),b=this.modules[n][p],S=1);r+=this.finderPenaltyTerminateAndCount(b,S,g)*ve.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let b=0;b<this.size-1;b++){const S=this.modules[p][b];S==this.modules[p][b+1]&&S==this.modules[p+1][b]&&S==this.modules[p+1][b+1]&&(r+=ve.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((b,S)=>b+(S?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),r+=o*ve.PENALTY_N4,m(0<=r&&r<=2568888),r}getAlignmentPatternPositions(){if(this.version==1)return[];{const r=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(r*2-2))*2;let f=[6];for(let o=this.size-7;f.length<r;o-=c)f.splice(1,0,o);return f}}static getNumRawDataModules(r){if(r<ve.MIN_VERSION||r>ve.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*r+128)*r+64;if(r>=2){const f=Math.floor(r/7)+2;c-=(25*f-10)*f-55,r>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(r,c){return Math.floor(ve.getNumRawDataModules(r)/8)-ve.ECC_CODEWORDS_PER_BLOCK[c.ordinal][r]*ve.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][r]}static reedSolomonComputeDivisor(r){if(r<1||r>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<r-1;o++)c.push(0);c.push(1);let f=1;for(let o=0;o<r;o++){for(let p=0;p<c.length;p++)c[p]=ve.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=ve.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(r,c){let f=c.map(o=>0);for(const o of r){const p=o^f.shift();f.push(0),c.forEach((b,S)=>f[S]^=ve.reedSolomonMultiply(b,p))}return f}static reedSolomonMultiply(r,c){if(r>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let o=7;o>=0;o--)f=f<<1^(f>>>7)*285,f^=(c>>>o&1)*r;return m(f>>>8==0),f}finderPenaltyCountPatterns(r){const c=r[1];m(c<=this.size*3);const f=c>0&&r[2]==c&&r[3]==c*3&&r[4]==c&&r[5]==c;return(f&&r[0]>=c*4&&r[6]>=c?1:0)+(f&&r[6]>=c*4&&r[0]>=c?1:0)}finderPenaltyTerminateAndCount(r,c,f){return r&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(r,c){c[0]==0&&(r+=this.size),c.pop(),c.unshift(r)}};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 s(i,r,c){if(r<0||r>31||i>>>r)throw new RangeError("Value out of range");for(let f=r-1;f>=0;f--)c.push(i>>>f&1)}function a(i,r){return(i>>>r&1)!=0}function m(i){if(!i)throw new Error("Assertion error")}const v=class Ae{constructor(r,c,f){if(this.mode=r,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(r){let c=[];for(const f of r)s(f,8,c);return new Ae(Ae.Mode.BYTE,r.length,c)}static makeNumeric(r){if(!Ae.isNumeric(r))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<r.length;){const o=Math.min(r.length-f,3);s(parseInt(r.substring(f,f+o),10),o*3+1,c),f+=o}return new Ae(Ae.Mode.NUMERIC,r.length,c)}static makeAlphanumeric(r){if(!Ae.isAlphanumeric(r))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=r.length;f+=2){let o=Ae.ALPHANUMERIC_CHARSET.indexOf(r.charAt(f))*45;o+=Ae.ALPHANUMERIC_CHARSET.indexOf(r.charAt(f+1)),s(o,11,c)}return f<r.length&&s(Ae.ALPHANUMERIC_CHARSET.indexOf(r.charAt(f)),6,c),new Ae(Ae.Mode.ALPHANUMERIC,r.length,c)}static makeSegments(r){return r==""?[]:Ae.isNumeric(r)?[Ae.makeNumeric(r)]:Ae.isAlphanumeric(r)?[Ae.makeAlphanumeric(r)]:[Ae.makeBytes(Ae.toUtf8ByteArray(r))]}static makeEci(r){let c=[];if(r<0)throw new RangeError("ECI assignment value out of range");if(r<128)s(r,8,c);else if(r<16384)s(2,2,c),s(r,14,c);else if(r<1e6)s(6,3,c),s(r,21,c);else throw new RangeError("ECI assignment value out of range");return new Ae(Ae.Mode.ECI,0,c)}static isNumeric(r){return Ae.NUMERIC_REGEX.test(r)}static isAlphanumeric(r){return Ae.ALPHANUMERIC_REGEX.test(r)}getData(){return this.bitData.slice()}static getTotalBits(r,c){let f=0;for(const o of r){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;f+=4+p+o.bitData.length}return f}static toUtf8ByteArray(r){r=encodeURI(r);let c=[];for(let f=0;f<r.length;f++)r.charAt(f)!="%"?c.push(r.charCodeAt(f)):(c.push(parseInt(r.substring(f+1,f+3),16)),f+=2);return c}};v.NUMERIC_REGEX=/^[0-9]*$/,v.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,v.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=v;e.QrSegment=v})(Mt||(Mt={}));(e=>{(t=>{const s=class{constructor(m,v){this.ordinal=m,this.formatBits=v}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(Mt||(Mt={}));(e=>{(t=>{const s=class{constructor(m,v){this.modeBits=m,this.numBitsCharCount=v}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(Mt||(Mt={}));var Bt=Mt;var Hm={L:Bt.QrCode.Ecc.LOW,M:Bt.QrCode.Ecc.MEDIUM,Q:Bt.QrCode.Ecc.QUARTILE,H:Bt.QrCode.Ecc.HIGH},jo=128,Ao="L",Mo="#FFFFFF",No="#000000",Po=!1,Oo=1,zm=4,Wm=0,$m=.1;function Bo(e,t=0){const s=[];return e.forEach(function(a,m){let v=null;a.forEach(function(C,i){if(!C&&v!==null){s.push(`M${v+t} ${m+t}h${i-v}v1H${v+t}z`),v=null;return}if(i===a.length-1){if(!C)return;v===null?s.push(`M${i+t},${m+t} h1v1H${i+t}z`):s.push(`M${v+t},${m+t} h${i+1-v}v1H${v+t}z`);return}C&&v===null&&(v=i)})}),s.join("")}function Io(e,t){return e.slice().map((s,a)=>a<t.y||a>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function Um(e,t,s,a){if(a==null)return null;const m=e.length+s*2,v=Math.floor(t*$m),C=m/t,i=(a.width||v)*C,r=(a.height||v)*C,c=a.x==null?e.length/2-i/2:a.x*C,f=a.y==null?e.length/2-r/2:a.y*C,o=a.opacity==null?1:a.opacity;let p=null;if(a.excavate){let S=Math.floor(c),g=Math.floor(f),n=Math.ceil(i+c-S),d=Math.ceil(r+f-g);p={x:S,y:g,w:n,h:d}}const b=a.crossOrigin;return{x:c,y:f,h:r,w:i,excavation:p,opacity:o,crossOrigin:b}}function qm(e,t){return t!=null?Math.max(Math.floor(t),0):e?zm:Wm}function Fo({value:e,level:t,minVersion:s,includeMargin:a,marginSize:m,imageSettings:v,size:C,boostLevel:i}){let r=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Bt.QrSegment.makeSegments(n)),g),[]);return Bt.QrCode.encodeSegments(S,Hm[t],s,void 0,void 0,i)},[e,t,s,i]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let b=r.getModules();const S=qm(a,m),g=b.length+S*2,n=Um(b,C,S,v);return{cells:b,margin:S,numCells:g,calculatedImageSettings:n}},[r,C,v,a,m]);return{qrcode:r,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var Km=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Xm=ee.forwardRef(function(t,s){const a=t,{value:m,size:v=jo,level:C=Ao,bgColor:i=Mo,fgColor:r=No,includeMargin:c=Po,minVersion:f=Oo,boostLevel:o,marginSize:p,imageSettings:b}=a,g=yr(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=yr(g,["style"]),h=b?.src,u=ee.useRef(null),_=ee.useRef(null),y=ee.useCallback(I=>{u.current=I,typeof s=="function"?s(I):s&&(s.current=I)},[s]),[w,E]=ee.useState(!1),{margin:x,cells:R,numCells:T,calculatedImageSettings:A}=Fo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:b,size:v});ee.useEffect(()=>{if(u.current!=null){const I=u.current,B=I.getContext("2d");if(!B)return;let H=R;const z=_.current,D=A!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;D&&A.excavation!=null&&(H=Io(R,A.excavation));const N=window.devicePixelRatio||1;I.height=I.width=v*N;const P=v/T*N;B.scale(P,P),B.fillStyle=i,B.fillRect(0,0,T,T),B.fillStyle=r,Km?B.fill(new Path2D(Bo(H,x))):R.forEach(function(O,$){O.forEach(function(K,Q){K&&B.fillRect(Q+x,$+x,1,1)})}),A&&(B.globalAlpha=A.opacity),D&&B.drawImage(z,A.x+x,A.y+x,A.w,A.h)}}),ee.useEffect(()=>{E(!1)},[h]);const j=Sr({height:v,width:v},n);let M=null;return h!=null&&(M=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:A?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",Sr({style:j,height:v,width:v,ref:y,role:"img"},d)),M)});Xm.displayName="QRCodeCanvas";var Ho=ee.forwardRef(function(t,s){const a=t,{value:m,size:v=jo,level:C=Ao,bgColor:i=Mo,fgColor:r=No,includeMargin:c=Po,minVersion:f=Oo,boostLevel:o,title:p,marginSize:b,imageSettings:S}=a,g=yr(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Fo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:b,imageSettings:S,size:v});let _=d,y=null;S!=null&&u!=null&&(u.excavation!=null&&(_=Io(d,u.excavation)),y=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Bo(_,n);return ee.createElement("svg",Sr({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:i,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:r,d:w,shapeRendering:"crispEdges"}),y)});Ho.displayName="QRCodeSVG";function Ym(){return st({queryKey:he.tunnel.status,queryFn:()=>ge.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function Vm(){const e=Fe();return Ge({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ge.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:he.tunnel.status})}})}function Gm(){const e=Fe();return Ge({mutationFn:()=>ge.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:he.tunnel.status})}})}function Xi(){const{t:e}=ue(),{data:t}=Ym(),s=Vm(),a=Gm(),[m,v]=k.useState(!1),[C,i]=k.useState(null),r=k.useRef(null),[c,f]=k.useState({top:0,right:0}),[o,p]=k.useState(!1),b=t?.running??!1,S=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&r.current){const y=r.current.getBoundingClientRect();f({top:y.bottom+8,right:window.innerWidth-y.right})}},[m]);const d=k.useCallback(()=>{b?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[b,s]),h=k.useCallback(()=>{g&&(navigator.clipboard.writeText(g),i("url"),setTimeout(()=>i(null),2e3))},[g]),u=k.useCallback(()=>{n&&(navigator.clipboard.writeText(n),i("token"),setTimeout(()=>i(null),2e3))},[n]),_=k.useCallback(()=>{a.mutate(),v(!1),p(!1)},[a]);return l.jsxs("div",{className:"relative",children:[l.jsx("button",{ref:r,onClick:d,disabled:S,className:`p-1.5 rounded-md transition-colors ${b?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(b?"Tunnel active":"Share via tunnel"),children:S?l.jsx(Ie,{size:16,className:"animate-spin"}):l.jsx(Ns,{size:16})}),b&&!S&&l.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&b&&jt.createPortal(l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),l.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:c.top,right:c.right},children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[l.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),e("Tunnel Active")]}),l.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:l.jsx(Ps,{size:14})})]}),n&&l.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[l.jsx(tl,{size:12}),l.jsx("span",{children:e("Token protected")})]}),g&&l.jsx("div",{className:"flex justify-center py-3",children:l.jsx(Ho,{value:g,size:160})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{readOnly:!0,value:g??t?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:y=>y.target.select()}),l.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:e("Copy shareable link"),children:C==="url"?l.jsx(Zt,{size:14,className:"text-emerald-500"}):l.jsx(ti,{size:14})})]}),n&&l.jsxs("div",{className:"mt-2",children:[l.jsx("button",{onClick:()=>p(!o),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(o?"Hide token":"Show token")}),o&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[l.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:n}),l.jsx("button",{onClick:u,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:C==="token"?l.jsx(Zt,{size:14,className:"text-emerald-500"}):l.jsx(ti,{size:14})})]})]}),l.jsx("button",{onClick:_,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)]})}const Yi={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Kt=k.lazy(()=>Zi(()=>import("./modal-BoAiDPtT.js").then(e=>e.m),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.Modal}))),ur=k.lazy(()=>Zi(()=>import("./folder-picker-DBgAK0Ax.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12])).then(e=>({default:e.FolderPicker}))),Vi=l.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[l.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),l.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Gi=l.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),Qm=260,Zm=600,Qi=400;function fp(){const{t:e}=ue(),[t,s]=k.useState(null),[a,m]=k.useState(null),[v,C]=k.useState(Qi),[i,r]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[b,S]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[y,w]=k.useState(""),[E,x]=k.useState("idle"),{files:R,addFiles:T,removeFile:A,clear:j,buildMarkdownLinks:M,isUploading:I}=Ur(),B=k.useRef(null),H=k.useRef(!1),z=k.useRef(0),D=k.useRef(Qi),N=k.useRef(null),P=Fe(),{data:O,isLoading:$}=Os(),{data:K,isLoading:Q}=la(),G=K?.data??[],ne=k.useMemo(()=>G.map(am),[G]),L=k.useMemo(()=>G.map(q=>q.id),[G]);pm(L);const{data:F,isLoading:U}=um(a??""),W=fa({queries:a?[]:G.map(q=>({queryKey:he.tasks.list(q.id),queryFn:()=>ge.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),Z=!a&&W.some(q=>q.isLoading),X=k.useMemo(()=>{if(a)return F?.data??[];const q=[];for(const J of W)J.data?.data&&q.push(...J.data.data);return q},[a,F,W]),oe=k.useMemo(()=>{const q=new Map;for(const J of X){const le=J.createdAt?new Date(J.createdAt).getTime():0,pe=q.get(J.projectId)??0;le>pe&&q.set(J.projectId,le)}return[...G].sort((J,le)=>{const pe=q.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(q.get(le.id)??(le.createdAt?new Date(le.createdAt).getTime():0))-pe})},[G,X]),me=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),J=q?JSON.parse(q):{};return[...O].sort((le,pe)=>{const ye=le.availability.type!=="NOT_FOUND",Re=pe.availability.type!=="NOT_FOUND";if(ye!==Re)return ye?-1:1;const qe=J[le.provider.id]??0;return(J[pe.provider.id]??0)-qe})},[O]),xe=k.useMemo(()=>X.map(cm),[X]),_e=k.useMemo(()=>new Set,[]),ie=k.useMemo(()=>{if(!t)return null;const q=X.find(le=>le.id===t);if(!q)return null;const J=G.find(le=>le.id===q.projectId);if(!J){const le=q.workspaces?.find(pe=>pe.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:qr(q.status),branch:le,mainBranch:"main",description:q.description??""}}return hm(q,J)},[t,X,G]),Ce=ca(),Oe=dm(u),Le=mm(),Xe=fm(),We=k.useCallback(q=>{Le.mutate(q,{onSuccess:()=>{t===q&&s(null),P.invalidateQueries({queryKey:he.tasks.all})}})},[Le,t,P]),Te=k.useCallback((q,J)=>{Xe.mutate({id:q,status:nm(J)},{onError:()=>{ra.error(e("状态变更失败,该操作不被允许"))}})},[Xe,e]),Ke=k.useCallback(q=>{q.preventDefault(),H.current=!0,z.current=q.clientX,D.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);k.useEffect(()=>{const q=le=>{if(!H.current)return;const pe=le.clientX-z.current,ye=Math.max(Qm,Math.min(Zm,D.current+pe));C(ye)},J=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",J)}},[]);const He=k.useCallback(()=>{r(!0)},[]),Me=k.useCallback(()=>{const q=localStorage.getItem("lastSelectedProjectId"),J=localStorage.getItem("lastSelectedProviderId"),le=q&&oe.find(Re=>Re.id===q)?q:a??oe[0]?.id??"";_(le);const pe=me?.find(Re=>Re.availability.type!=="NOT_FOUND"),ye=J&&me?.find(Re=>Re.provider.id===J&&Re.availability.type!=="NOT_FOUND")?J:pe?.provider.id??"";w(ye),x("idle"),f(!0)},[a,oe,me]),Y=k.useCallback(()=>{r(!1),p(""),S("")},[]),se=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),x("idle"),j())},[E,j]),fe=k.useCallback(async()=>{if(!(!o.trim()||!b.trim()))try{await Ce.mutateAsync({name:o.trim(),repoPath:b.trim()}),Y()}catch{}},[o,b,Ce,Y]),re=go(),de=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=M(),J=[d.trim(),q].filter(Boolean).join(`
|
|
82
|
-
|
|
83
|
-
`);x("creating-task");const le=await Oe.mutateAsync({title:g.trim(),description:J||void 0});if(localStorage.setItem("lastSelectedProjectId",u),y){localStorage.setItem("lastSelectedProviderId",y);const pe=localStorage.getItem("providerUsageCount"),ye=pe?JSON.parse(pe):{};ye[y]=(ye[y]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ye))}if(y){const pe=[g.trim(),J].filter(Boolean).join(`
|
|
84
|
-
|
|
85
|
-
`);x("creating-workspace");const ye=await ge.post(`/tasks/${le.id}/workspaces`,{});x("creating-session");const Re=await ge.post(`/workspaces/${ye.id}/sessions`,{providerId:y,prompt:pe});x("starting-session"),await re.mutateAsync(Re.id),await P.invalidateQueries({queryKey:he.workspaces.list(le.id)})}s(le.id),x("idle"),f(!1),n(""),h(""),_(""),w(""),j()}catch{x("idle")}},[g,d,u,y,Oe,re,P,M,j]),ae=k.useCallback(q=>{const J=q.target.files;J&&J.length>0&&T(Array.from(J)),q.target.value=""},[T]),je=k.useCallback(q=>{const J=q.clipboardData.items,le=[];for(const pe of J)if(pe.kind==="file"){const ye=pe.getAsFile();ye&&le.push(ye)}le.length>0&&(q.preventDefault(),T(le))},[T]),[rt,mt]=k.useState(!1),Dt=k.useCallback(q=>{q.preventDefault(),mt(!0)},[]),Tt=k.useCallback(q=>{q.preventDefault(),mt(!1)},[]),pt=k.useCallback(q=>{q.preventDefault(),mt(!1);const J=q.dataTransfer.files;J.length>0&&T(Array.from(J))},[T]),bt=Q||U||Z;return bm()?t&&ie?l.jsxs(l.Fragment,{children:[l.jsx(Im,{task:ie,onBack:()=>s(null),onDeleteTask:We,isDeleting:Le.isPending}),l.jsx(k.Suspense,{fallback:null,children:l.jsx(Kt,{isOpen:i,onClose:Y,title:e("Create New Project"),action:l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:Y,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),l.jsx("button",{onClick:fe,disabled:!o.trim()||!b.trim()||Ce.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&b.trim()&&!Ce.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ce.isPending?e("Creating..."):e("Create")})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),l.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),l.jsx(ur,{value:b,onChange:S})]})]})})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[l.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Vi,Gi]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Xi,{}),l.jsx(Gr,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:l.jsx(Qr,{size:16})})]})]}),bt&&xe.length===0?l.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):l.jsx(pi,{tasks:xe,projects:ne,selectedTaskId:null,onSelectTask:s,filterProjectId:a,setFilterProjectId:m,width:"100%",onCreateProject:He,onCreateTask:Me,activeTaskIds:_e,onTaskStatusChange:Te})]}),l.jsxs(k.Suspense,{fallback:null,children:[l.jsx(Kt,{isOpen:i,onClose:Y,title:e("Create New Project"),action:l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:Y,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),l.jsx("button",{onClick:fe,disabled:!o.trim()||!b.trim()||Ce.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&b.trim()&&!Ce.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ce.isPending?e("Creating..."):e("Create")})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),l.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),l.jsx(ur,{value:b,onChange:S})]})]})}),l.jsx(Kt,{isOpen:c,onClose:se,title:e("Create New Task"),action:l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:se,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 disabled:opacity-50",children:e("Cancel")}),l.jsx("button",{onClick:de,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(Yi[E])})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),l.jsx(ds,{value:u,onChange:_,options:oe.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Provider")}),l.jsx(ds,{value:y,onChange:w,options:me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),l.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",disabled:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&de()}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),l.jsxs("div",{className:`relative border rounded-lg transition-colors ${rt?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:Dt,onDragLeave:Tt,onDrop:pt,children:[l.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:je,placeholder:e("Optional..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&de()}}),rt&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:l.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),l.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:()=>B.current?.click(),disabled:E!=="idle"||I,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 active:text-neutral-900 active:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[l.jsx(xs,{size:14}),e("Attach files")]}),l.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste files")})]}),l.jsx("input",{ref:B,type:"file",multiple:!0,onChange:ae,className:"hidden"}),l.jsx(Ls,{files:R,onRemove:A})]})]})})]})]}):l.jsxs("div",{ref:N,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[Vi,Gi]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Xi,{}),l.jsx(Gr,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:l.jsx(Qr,{size:16})})]})]}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[bt&&xe.length===0?l.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:v},children:e("Loading...")}):l.jsx(pi,{tasks:xe,projects:ne,selectedTaskId:t,onSelectTask:s,filterProjectId:a,setFilterProjectId:m,width:v,onCreateProject:He,onCreateTask:Me,activeTaskIds:_e,onTaskStatusChange:Te,onDeleteTask:We}),l.jsx("div",{onMouseDown:Ke,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")}),l.jsx(im,{task:ie,onDeleteTask:We,isDeleting:Le.isPending,onTaskStatusChange:Te})]}),l.jsxs(k.Suspense,{fallback:null,children:[l.jsx(Kt,{isOpen:i,onClose:Y,title:e("Create New Project"),action:l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:Y,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:e("Cancel")}),l.jsx("button",{onClick:fe,disabled:!o.trim()||!b.trim()||Ce.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${o.trim()&&b.trim()&&!Ce.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ce.isPending?e("Creating..."):e("Create Project")})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),l.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",autoFocus:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),l.jsx(ur,{value:b,onChange:S})]}),Ce.isError&&l.jsx("p",{className:"text-xs text-red-500",children:Ce.error instanceof Error?Ce.error.message:e("Failed to create project")})]})}),l.jsx(Kt,{isOpen:c,onClose:se,title:e("Create New Task"),action:l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:se,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),l.jsx("button",{onClick:de,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(Yi[E])})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),l.jsx(ds,{value:u,onChange:_,options:oe.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),l.jsx(ds,{value:y,onChange:w,options:me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),l.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),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:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&de()}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),l.jsxs("div",{className:`relative border rounded-lg transition-colors ${rt?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:Dt,onDragLeave:Tt,onDrop:pt,children:[l.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:je,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&de()}}),rt&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:l.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),l.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:()=>B.current?.click(),disabled:E!=="idle"||I,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[l.jsx(xs,{size:14}),e("Attach files")]}),l.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),l.jsx("input",{ref:B,type:"file",multiple:!0,onChange:ae,className:"hidden"}),l.jsx(Ls,{files:R,onRemove:A})]}),Oe.isError&&l.jsx("p",{className:"text-xs text-red-500",children:Oe.error instanceof Error?Oe.error.message:"Failed to create task"})]})})]})]})}export{fp as ProjectKanbanPage};
|