agent-tower 0.4.15 → 0.4.16-beta.0

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.
Files changed (141) hide show
  1. package/dist/core/event-bus.d.ts +2 -0
  2. package/dist/core/event-bus.d.ts.map +1 -1
  3. package/dist/core/event-bus.js.map +1 -1
  4. package/dist/executors/__tests__/codex.executor.test.d.ts +2 -0
  5. package/dist/executors/__tests__/codex.executor.test.d.ts.map +1 -0
  6. package/dist/executors/__tests__/codex.executor.test.js +28 -0
  7. package/dist/executors/__tests__/codex.executor.test.js.map +1 -0
  8. package/dist/executors/codex.executor.d.ts +1 -0
  9. package/dist/executors/codex.executor.d.ts.map +1 -1
  10. package/dist/executors/codex.executor.js +19 -1
  11. package/dist/executors/codex.executor.js.map +1 -1
  12. package/dist/mcp/context.d.ts +3 -0
  13. package/dist/mcp/context.d.ts.map +1 -1
  14. package/dist/mcp/context.js +10 -1
  15. package/dist/mcp/context.js.map +1 -1
  16. package/dist/mcp/http-client.d.ts +24 -1
  17. package/dist/mcp/http-client.d.ts.map +1 -1
  18. package/dist/mcp/http-client.js +29 -2
  19. package/dist/mcp/http-client.js.map +1 -1
  20. package/dist/mcp/server.d.ts.map +1 -1
  21. package/dist/mcp/server.js +190 -0
  22. package/dist/mcp/server.js.map +1 -1
  23. package/dist/routes/index.d.ts.map +1 -1
  24. package/dist/routes/index.js +3 -0
  25. package/dist/routes/index.js.map +1 -1
  26. package/dist/routes/system.d.ts.map +1 -1
  27. package/dist/routes/system.js +35 -1
  28. package/dist/routes/system.js.map +1 -1
  29. package/dist/routes/team-runs.d.ts +11 -0
  30. package/dist/routes/team-runs.d.ts.map +1 -0
  31. package/dist/routes/team-runs.js +299 -0
  32. package/dist/routes/team-runs.js.map +1 -0
  33. package/dist/services/__tests__/session-manager.team-run.test.d.ts +2 -0
  34. package/dist/services/__tests__/session-manager.team-run.test.d.ts.map +1 -0
  35. package/dist/services/__tests__/session-manager.team-run.test.js +286 -0
  36. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -0
  37. package/dist/services/__tests__/team-lock.service.test.d.ts +2 -0
  38. package/dist/services/__tests__/team-lock.service.test.d.ts.map +1 -0
  39. package/dist/services/__tests__/team-lock.service.test.js +81 -0
  40. package/dist/services/__tests__/team-lock.service.test.js.map +1 -0
  41. package/dist/services/__tests__/team-reconciler.service.test.d.ts +2 -0
  42. package/dist/services/__tests__/team-reconciler.service.test.d.ts.map +1 -0
  43. package/dist/services/__tests__/team-reconciler.service.test.js +1038 -0
  44. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -0
  45. package/dist/services/__tests__/team-run.service.test.d.ts +2 -0
  46. package/dist/services/__tests__/team-run.service.test.d.ts.map +1 -0
  47. package/dist/services/__tests__/team-run.service.test.js +447 -0
  48. package/dist/services/__tests__/team-run.service.test.js.map +1 -0
  49. package/dist/services/__tests__/team-scheduler.service.test.d.ts +2 -0
  50. package/dist/services/__tests__/team-scheduler.service.test.d.ts.map +1 -0
  51. package/dist/services/__tests__/team-scheduler.service.test.js +1158 -0
  52. package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -0
  53. package/dist/services/session-manager.d.ts +31 -1
  54. package/dist/services/session-manager.d.ts.map +1 -1
  55. package/dist/services/session-manager.js +110 -2
  56. package/dist/services/session-manager.js.map +1 -1
  57. package/dist/services/team-lock.service.d.ts +22 -0
  58. package/dist/services/team-lock.service.d.ts.map +1 -0
  59. package/dist/services/team-lock.service.js +45 -0
  60. package/dist/services/team-lock.service.js.map +1 -0
  61. package/dist/services/team-reconciler.service.d.ts +44 -0
  62. package/dist/services/team-reconciler.service.d.ts.map +1 -0
  63. package/dist/services/team-reconciler.service.js +286 -0
  64. package/dist/services/team-reconciler.service.js.map +1 -0
  65. package/dist/services/team-run-events.d.ts +13 -0
  66. package/dist/services/team-run-events.d.ts.map +1 -0
  67. package/dist/services/team-run-events.js +27 -0
  68. package/dist/services/team-run-events.js.map +1 -0
  69. package/dist/services/team-run.service.d.ts +89 -0
  70. package/dist/services/team-run.service.d.ts.map +1 -0
  71. package/dist/services/team-run.service.js +577 -0
  72. package/dist/services/team-run.service.js.map +1 -0
  73. package/dist/services/team-scheduler.service.d.ts +89 -0
  74. package/dist/services/team-scheduler.service.d.ts.map +1 -0
  75. package/dist/services/team-scheduler.service.js +750 -0
  76. package/dist/services/team-scheduler.service.js.map +1 -0
  77. package/dist/socket/events.d.ts +1 -1
  78. package/dist/socket/events.d.ts.map +1 -1
  79. package/dist/socket/events.js.map +1 -1
  80. package/dist/socket/socket-gateway.d.ts.map +1 -1
  81. package/dist/socket/socket-gateway.js +5 -1
  82. package/dist/socket/socket-gateway.js.map +1 -1
  83. package/dist/web/assets/AgentDemoPage-p9YI4_l4.js +1 -0
  84. package/dist/web/assets/{DemoPage-XwuS8vNB.js → DemoPage-B5DTSEbS.js} +3 -3
  85. package/dist/web/assets/{GeneralSettingsPage-CliIgpwf.js → GeneralSettingsPage-Cspr7Vol.js} +1 -1
  86. package/dist/web/assets/{NotificationSettingsPage-y3vhVgPv.js → NotificationSettingsPage-C9VfrRr-.js} +1 -1
  87. package/dist/web/assets/{ProfileSettingsPage-CkU_kZKG.js → ProfileSettingsPage-CNugU40a.js} +1 -1
  88. package/dist/web/assets/ProjectKanbanPage-CkGNuqxq.js +87 -0
  89. package/dist/web/assets/{ProjectSettingsPage-B6xhbziO.js → ProjectSettingsPage-f1dg0XMf.js} +1 -1
  90. package/dist/web/assets/{ProviderSettingsPage-CfvdeoEU.js → ProviderSettingsPage-D_KWkgRM.js} +1 -1
  91. package/dist/web/assets/TeamSettingsPage-B6WciZyi.js +1 -0
  92. package/dist/web/assets/{button-BWFTEdOr.js → button-B6JaSbDB.js} +1 -1
  93. package/dist/web/assets/{chevron-down-CuPdBAx-.js → chevron-down-CACy4UFq.js} +1 -1
  94. package/dist/web/assets/{chevron-right-Cs8vYTMn.js → chevron-right-DFWfnDJY.js} +1 -1
  95. package/dist/web/assets/chevron-up-CGlf6jzw.js +1 -0
  96. package/dist/web/assets/{circle-alert-EUyZcWhp.js → circle-alert-BSAUEd9O.js} +1 -1
  97. package/dist/web/assets/{circle-check-BXZTzqw0.js → circle-check-DMK8auwb.js} +1 -1
  98. package/dist/web/assets/{code-block-OCS4YCEC-BxUpvXK_.js → code-block-OCS4YCEC-Hn75KHRK.js} +1 -1
  99. package/dist/web/assets/{confirm-dialog-CDLHRthd.js → confirm-dialog-DHI2f7Ni.js} +1 -1
  100. package/dist/web/assets/{folder-picker-CUbhsnhi.js → folder-picker-CtQkbWfa.js} +1 -1
  101. package/dist/web/assets/index-BFAA3PTl.js +13 -0
  102. package/dist/web/assets/index-mBCb67dB.css +1 -0
  103. package/dist/web/assets/{loader-circle-BHzDVpxt.js → loader-circle-CkDnf8ST.js} +1 -1
  104. package/dist/web/assets/{mermaid-NOHMQCX5-BOSwJqP0.js → mermaid-NOHMQCX5-DJFgrXPd.js} +44 -44
  105. package/dist/web/assets/modal-B5IRN7QI.js +1 -0
  106. package/dist/web/assets/{pencil-BMxBxIhw.js → pencil-CJY6Ahn7.js} +1 -1
  107. package/dist/web/assets/{select-BUmRG0LY.js → select-BPZZlla1.js} +1 -1
  108. package/dist/web/assets/{use-profiles-C1vlPE-2.js → use-profiles-C2k04ICZ.js} +1 -1
  109. package/dist/web/assets/{use-projects-Bcd5hIOY.js → use-projects-BxuE-ulT.js} +1 -1
  110. package/dist/web/assets/{use-providers-Cdxr4Jbz.js → use-providers-C7fIDWzP.js} +1 -1
  111. package/dist/web/index.html +2 -2
  112. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +10 -0
  113. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  114. package/node_modules/@agent-tower/shared/dist/socket/events.js +1 -0
  115. package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
  116. package/node_modules/@agent-tower/shared/dist/types.d.ts +153 -0
  117. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  118. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  119. package/node_modules/@prisma/client/.prisma/client/default.d.ts +1 -0
  120. package/node_modules/@prisma/client/.prisma/client/default.js +1 -0
  121. package/node_modules/@prisma/client/.prisma/client/edge.d.ts +1 -0
  122. package/node_modules/@prisma/client/.prisma/client/edge.js +392 -0
  123. package/node_modules/@prisma/client/.prisma/client/index-browser.js +381 -0
  124. package/node_modules/@prisma/client/.prisma/client/index.d.ts +25768 -0
  125. package/node_modules/@prisma/client/.prisma/client/index.js +417 -0
  126. package/node_modules/@prisma/client/.prisma/client/libquery_engine-darwin-arm64.dylib.node +0 -0
  127. package/node_modules/@prisma/client/.prisma/client/package.json +97 -0
  128. package/node_modules/@prisma/client/.prisma/client/query_engine-windows.dll.node +0 -0
  129. package/node_modules/@prisma/client/.prisma/client/schema.prisma +280 -0
  130. package/node_modules/@prisma/client/.prisma/client/wasm.d.ts +1 -0
  131. package/node_modules/@prisma/client/.prisma/client/wasm.js +381 -0
  132. package/node_modules/@prisma/client/package.json +3 -2
  133. package/package.json +2 -1
  134. package/prisma/migrations/20260518000000_add_team_run_collaboration/migration.sql +150 -0
  135. package/prisma/migrations/20260522000000_add_team_member_session_policy/migration.sql +2 -0
  136. package/prisma/schema.prisma +131 -1
  137. package/dist/web/assets/AgentDemoPage-ClnGPAV9.js +0 -1
  138. package/dist/web/assets/ProjectKanbanPage-BddzfZRV.js +0 -87
  139. package/dist/web/assets/index-BGvfX18x.css +0 -1
  140. package/dist/web/assets/index-CHN8jahE.js +0 -13
  141. package/dist/web/assets/modal-D_AU4URz.js +0 -1
@@ -0,0 +1,87 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-B5IRN7QI.js","assets/index-BFAA3PTl.js","assets/index-mBCb67dB.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CtQkbWfa.js","assets/chevron-right-DFWfnDJY.js","assets/loader-circle-CkDnf8ST.js","assets/circle-alert-BSAUEd9O.js","assets/use-projects-BxuE-ulT.js"])))=>i.map(i=>d[i]);
2
+ import{Q as Jr,x as Li,y as Wa,z as $a,A as Ua,B as Fr,D as qa,E as Ka,e as We,G as Xa,H as Ya,r as E,I as Va,J as Ga,K as Qa,M as Za,N as Pi,O as Oi,P as Ja,R as el,T as tl,h as ve,U as re,V as qt,u as ae,j as r,W as ps,X as sl,Y as rl,Z as Ii,_ as il,v as Pt,S as Je,C as Zt,g as ue,f as nt,q as oe,d as yt,w as Ot,i as nl,k as ol,L as Hs,$ as Yn,a0 as al,a1 as Bi,a2 as ll,a3 as cl,a4 as dl,a5 as ul,a6 as hl,t as Fi,a7 as Vn}from"./index-BFAA3PTl.js";import{h as ei,b as ti,d as si,c as ri,i as ii,A as Hi,Q as ni,f as zs,G as tr,u as Gn,a as Qn,e as Hr,T as Zn,P as oi,S as zi}from"./mermaid-NOHMQCX5-DJFgrXPd.js";import{C as jt,a as Yt}from"./chevron-down-CACy4UFq.js";import{C as Ht}from"./chevron-right-DFWfnDJY.js";import{P as vs,X as Cs,M as sr,T as Jn}from"./modal-B5IRN7QI.js";import{C as fl,A as Rt,S as Re,T as Nt}from"./log-adapter-CeKrvZcz.js";import{B as ze}from"./button-B6JaSbDB.js";import{c as ne,t as Wi}from"./utils-CkSf8FUe.js";import{F as ml,a as pl,e as vl,R as gl,u as _l,f as xl}from"./use-projects-BxuE-ulT.js";import{L as Pe}from"./loader-circle-CkDnf8ST.js";import{u as ws}from"./use-providers-C7fIDWzP.js";import{C as bl}from"./chevron-up-CGlf6jzw.js";import{T as eo,C as zr}from"./confirm-dialog-DHI2f7Ni.js";import{S as $i}from"./select-BPZZlla1.js";var Sl=class extends Jr{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:Li()})}getOptimisticResult(e){return e.behavior=Li(),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,l=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:x,isRefetchError:i}=l,n=s.fetchMeta?.fetchMore?.direction,c=x&&n==="forward",f=m&&n==="forward",a=x&&n==="backward",p=m&&n==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:$a(t,s.data),hasPreviousPage:Wa(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:a,isFetchingPreviousPage:p,isRefetchError:i&&!c&&!a,isRefetching:v&&!f&&!p}}};function Ui(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function yl(e,t,s){const l=e.slice(0);return l[t]=s,l}var Cl=class extends Ua{#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,Fr.batch(()=>{const s=this.#t,l=this.#h(this.#i);l.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=l.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),x=s.length!==m.length,i=m.some((f,a)=>f!==s[a]),n=x||i,c=n?!0:v.some((f,a)=>{const p=this.#e[a];return!p||!qa(f,p)});!n&&!c||(n&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(n&&(Ui(s,m).forEach(f=>{f.destroy()}),Ui(m,s).forEach(f=>{f.subscribe(a=>{this.#f(f,a)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#h(e),l=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[l,v=>this.#u(v??l,t,m),()=>this.#d(l,s)]}#d(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(x=>{x.observer.trackProp(v)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((v,x)=>v!==l[x]));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=Ka(this.#s,t(e))),this.#s}return e}#h(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const v=t.get(m);v?v.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),x=t.get(m.queryHash)?.shift()??new Jr(this.#r,m);s.push({defaultedQueryOptions:m,observer:x})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=yl(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&Fr.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function wl({queries:e,...t},s){const l=We(),m=Xa(),v=Ya(),x=E.useMemo(()=>e.map(_=>{const o=l.defaultQueryOptions(_);return o._optimisticResults=m?"isRestoring":"optimistic",o}),[e,l,m]);x.forEach(_=>{Va(_);const o=l.getQueryCache().get(_.queryHash);Ga(_,v,o)}),Qa(v);const[i]=E.useState(()=>new Cl(l,x,t)),[n,c,f]=i.getOptimisticResult(x,t.combine),a=!m&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(_=>a?i.subscribe(Fr.batchCalls(_)):Za,[i,a]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),E.useEffect(()=>{i.setQueries(x,t)},[x,t,i]);const S=n.some((_,o)=>Pi(x[o],_))?n.flatMap((_,o)=>{const h=x[o];if(h){const u=new Jr(l,h);if(Pi(h,_))return Oi(h,u,v);Ja(_,m)&&Oi(h,u,v)}return[]}):[];if(S.length>0)throw Promise.all(S);const y=n.find((_,o)=>{const h=x[o];return h&&el({result:_,errorResetBoundary:v,throwOnError:h.throwOnError,query:l.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return c(f())}function to(e,t){return tl(e,Sl)}const El=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ws=ve("arrow-down",El);const kl=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],so=ve("arrow-right",kl);const jl=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ai=ve("arrow-up",jl);const Nl=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Sr=ve("ban",Nl);const Rl=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Al=ve("bot",Rl);const Tl=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],qi=ve("circle-check-big",Tl);const Dl=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=ve("clock-3",Dl);const Ml=[["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"}]],rr=ve("code-xml",Ml);const Ll=[["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"}]],Ki=ve("copy",Ll);const Pl=[["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"}]],ro=ve("ellipsis-vertical",Pl);const Ol=[["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"}]],Il=ve("file-braces-corner",Ol);const Bl=[["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"}]],gs=ve("file-code-corner",Bl);const Fl=[["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"}]],Hl=ve("file-exclamation-point",Fl);const zl=[["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"}]],io=ve("file-text",zl);const Wl=[["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"}]],no=ve("folder-open",Wl);const $l=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ul=ve("gauge",$l);const ql=[["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"}]],Kl=ve("git-branch",ql);const Xl=[["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"}]],Yl=ve("git-fork",Xl);const Vl=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],_s=ve("git-graph",Vl);const Gl=[["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"}]],oo=ve("git-merge",Gl);const Ql=[["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"}]],ss=ve("history",Ql);const Zl=[["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"}]],li=ve("image",Zl);const Jl=[["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"}]],Wr=ve("layers",Jl);const ec=[["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"}]],tc=ve("maximize",ec);const sc=[["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"}]],ci=ve("message-square",sc);const rc=[["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"}]],ic=ve("panel-left-close",rc);const nc=[["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"}]],oc=ve("panel-left-open",nc);const ac=[["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"}]],lc=ve("panel-right-close",ac);const cc=[["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"}]],di=ve("panel-right-open",cc);const dc=[["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"}]],Kt=ve("play",dc);const uc=[["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"}]],$r=ve("refresh-cw",uc);const hc=[["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"}]],fc=ve("shield",hc);const mc=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],$s=ve("terminal",mc);const pc=[["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"}]],vc=ve("zap",pc);const gc=[["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"}]],_c=ve("zoom-in",gc);const xc=[["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"}]],bc=ve("zoom-out",xc),ir=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function rs(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ui(e){return"nodeType"in e}function lt(e){var t,s;return e?rs(e)?e:ui(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function hi(e){const{Document:t}=lt(e);return e instanceof t}function Es(e){return rs(e)?!1:e instanceof lt(e).HTMLElement}function ao(e){return e instanceof lt(e).SVGElement}function is(e){return e?rs(e)?e.document:ui(e)?hi(e)?e:Es(e)||ao(e)?e.ownerDocument:document:document:document}const At=ir?E.useLayoutEffect:E.useEffect;function nr(e){const t=E.useRef(e);return At(()=>{t.current=e}),E.useCallback(function(){for(var s=arguments.length,l=new Array(s),m=0;m<s;m++)l[m]=arguments[m];return t.current==null?void 0:t.current(...l)},[])}function Sc(){const e=E.useRef(null),t=E.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=E.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function xs(e,t){t===void 0&&(t=[e]);const s=E.useRef(e);return At(()=>{s.current!==e&&(s.current=e)},t),s}function ks(e,t){const s=E.useRef();return E.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function Us(e){const t=nr(e),s=E.useRef(null),l=E.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function qs(e){const t=E.useRef();return E.useEffect(()=>{t.current=e},[e]),t.current}let yr={};function or(e,t){return E.useMemo(()=>{if(t)return t;const s=yr[e]==null?0:yr[e]+1;return yr[e]=s,e+"-"+s},[e,t])}function lo(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((v,x)=>{const i=Object.entries(x);for(const[n,c]of i){const f=v[n];f!=null&&(v[n]=f+e*c)}return v},{...t})}}const ts=lo(1),Ks=lo(-1);function yc(e){return"clientX"in e&&"clientY"in e}function fi(e){if(!e)return!1;const{KeyboardEvent:t}=lt(e.target);return t&&e instanceof t}function Cc(e){if(!e)return!1;const{TouchEvent:t}=lt(e.target);return t&&e instanceof t}function Xs(e){if(Cc(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 yc(e)?{x:e.clientX,y:e.clientY}:null}const bs=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[bs.Translate.toString(e),bs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),Xi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function wc(e){return e.matches(Xi)?e:e.querySelector(Xi)}const Ec={display:"none"};function kc(e){let{id:t,value:s}=e;return re.createElement("div",{id:t,style:Ec},s)}function jc(e){let{id:t,announcement:s,ariaLiveType:l="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 re.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Nc(){const[e,t]=E.useState("");return{announce:E.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const co=E.createContext(null);function Rc(e){const t=E.useContext(co);E.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ac(){const[e]=E.useState(()=>new Set),t=E.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[E.useCallback(l=>{let{type:m,event:v}=l;e.forEach(x=>{var i;return(i=x[m])==null?void 0:i.call(x,v)})},[e]),t]}const Tc={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
+ `},Dc={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 Mc(e){let{announcements:t=Dc,container:s,hiddenTextDescribedById:l,screenReaderInstructions:m=Tc}=e;const{announce:v,announcement:x}=Nc(),i=or("DndLiveRegion"),[n,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),Rc(E.useMemo(()=>({onDragStart(a){let{active:p}=a;v(t.onDragStart({active:p}))},onDragMove(a){let{active:p,over:S}=a;t.onDragMove&&v(t.onDragMove({active:p,over:S}))},onDragOver(a){let{active:p,over:S}=a;v(t.onDragOver({active:p,over:S}))},onDragEnd(a){let{active:p,over:S}=a;v(t.onDragEnd({active:p,over:S}))},onDragCancel(a){let{active:p,over:S}=a;v(t.onDragCancel({active:p,over:S}))}}),[v,t])),!n)return null;const f=re.createElement(re.Fragment,null,re.createElement(kc,{id:l,value:m.draggable}),re.createElement(jc,{id:i,announcement:x}));return s?qt.createPortal(f,s):f}var Qe;(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"})(Qe||(Qe={}));function Ys(){}function Lc(e,t){return E.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Pc(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return E.useMemo(()=>[...t].filter(l=>l!=null),[...t])}const kt=Object.freeze({x:0,y:0});function Oc(e,t){const s=Xs(e);if(!s)return"0 0";const l={x:(s.x-t.left)/t.width*100,y:(s.y-t.top)/t.height*100};return l.x+"% "+l.y+"%"}function Ic(e,t){let{data:{value:s}}=e,{data:{value:l}}=t;return l-s}function Bc(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function Fc(e,t){const s=Math.max(t.top,e.top),l=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),x=m-l,i=v-s;if(l<m&&s<v){const n=t.width*t.height,c=e.width*e.height,f=x*i,a=f/(n+c-f);return Number(a.toFixed(4))}return 0}const Hc=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:l}=e;const m=[];for(const v of l){const{id:x}=v,i=s.get(x);if(i){const n=Fc(i,t);n>0&&m.push({id:x,data:{droppableContainer:v,value:n}})}}return m.sort(Ic)};function zc(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function uo(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:kt}function Wc(e){return function(s){for(var l=arguments.length,m=new Array(l>1?l-1:0),v=1;v<l;v++)m[v-1]=arguments[v];return m.reduce((x,i)=>({...x,top:x.top+e*i.y,bottom:x.bottom+e*i.y,left:x.left+e*i.x,right:x.right+e*i.x}),{...s})}}const $c=Wc(1);function ho(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 Uc(e,t,s){const l=ho(t);if(!l)return e;const{scaleX:m,scaleY:v,x,y:i}=l,n=e.left-x-(1-m)*parseFloat(s),c=e.top-i-(1-v)*parseFloat(s.slice(s.indexOf(" ")+1)),f=m?e.width/m:e.width,a=v?e.height/v:e.height;return{width:f,height:a,top:c,right:n+f,bottom:c+a,left:n}}const qc={ignoreTransform:!1};function js(e,t){t===void 0&&(t=qc);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=lt(e).getComputedStyle(e);c&&(s=Uc(s,c,f))}const{top:l,left:m,width:v,height:x,bottom:i,right:n}=s;return{top:l,left:m,width:v,height:x,bottom:i,right:n}}function Yi(e){return js(e,{ignoreTransform:!0})}function Kc(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function Xc(e,t){return t===void 0&&(t=lt(e).getComputedStyle(e)),t.position==="fixed"}function Yc(e,t){t===void 0&&(t=lt(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 mi(e,t){const s=[];function l(m){if(t!=null&&s.length>=t||!m)return s;if(hi(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!Es(m)||ao(m)||s.includes(m))return s;const v=lt(e).getComputedStyle(m);return m!==e&&Yc(m,v)&&s.push(m),Xc(m,v)?s:l(m.parentNode)}return e?l(e):s}function fo(e){const[t]=mi(e,1);return t??null}function Cr(e){return!ir||!e?null:rs(e)?e:ui(e)?hi(e)||e===is(e).scrollingElement?window:Es(e)?e:null:null}function mo(e){return rs(e)?e.scrollX:e.scrollLeft}function po(e){return rs(e)?e.scrollY:e.scrollTop}function Ur(e){return{x:mo(e),y:po(e)}}var et;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(et||(et={}));function vo(e){return!ir||!e?!1:e===document.scrollingElement}function go(e){const t={x:0,y:0},s=vo(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},l={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},m=e.scrollTop<=t.y,v=e.scrollLeft<=t.x,x=e.scrollTop>=l.y,i=e.scrollLeft>=l.x;return{isTop:m,isLeft:v,isBottom:x,isRight:i,maxScroll:l,minScroll:t}}const Vc={x:.2,y:.2};function Gc(e,t,s,l,m){let{top:v,left:x,right:i,bottom:n}=s;l===void 0&&(l=10),m===void 0&&(m=Vc);const{isTop:c,isBottom:f,isLeft:a,isRight:p}=go(e),S={x:0,y:0},y={x:0,y:0},_={height:t.height*m.y,width:t.width*m.x};return!c&&v<=t.top+_.height?(S.y=et.Backward,y.y=l*Math.abs((t.top+_.height-v)/_.height)):!f&&n>=t.bottom-_.height&&(S.y=et.Forward,y.y=l*Math.abs((t.bottom-_.height-n)/_.height)),!p&&i>=t.right-_.width?(S.x=et.Forward,y.x=l*Math.abs((t.right-_.width-i)/_.width)):!a&&x<=t.left+_.width&&(S.x=et.Backward,y.x=l*Math.abs((t.left+_.width-x)/_.width)),{direction:S,speed:y}}function Qc(e){if(e===document.scrollingElement){const{innerWidth:v,innerHeight:x}=window;return{top:0,left:0,right:v,bottom:x,width:v,height:x}}const{top:t,left:s,right:l,bottom:m}=e.getBoundingClientRect();return{top:t,left:s,right:l,bottom:m,width:e.clientWidth,height:e.clientHeight}}function _o(e){return e.reduce((t,s)=>ts(t,Ur(s)),kt)}function Zc(e){return e.reduce((t,s)=>t+mo(s),0)}function Jc(e){return e.reduce((t,s)=>t+po(s),0)}function xo(e,t){if(t===void 0&&(t=js),!e)return;const{top:s,left:l,bottom:m,right:v}=t(e);fo(e)&&(m<=0||v<=0||s>=window.innerHeight||l>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ed=[["x",["left","right"],Zc],["y",["top","bottom"],Jc]];class pi{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 l=mi(s),m=_o(l);this.rect={...t},this.width=t.width,this.height=t.height;for(const[v,x,i]of ed)for(const n of x)Object.defineProperty(this,n,{get:()=>{const c=i(l),f=m[v]-c;return this.rect[n]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class us{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var l;return(l=this.target)==null?void 0:l.removeEventListener(...s)})},this.target=t}add(t,s,l){var m;(m=this.target)==null||m.addEventListener(t,s,l),this.listeners.push([t,s,l])}}function td(e){const{EventTarget:t}=lt(e);return e instanceof t?e:is(e)}function wr(e,t){const s=Math.abs(e.x),l=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+l**2)>t:"x"in t&&"y"in t?s>t.x&&l>t.y:"x"in t?s>t.x:"y"in t?l>t.y:!1}var bt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bt||(bt={}));function Vi(e){e.preventDefault()}function sd(e){e.stopPropagation()}var Ee;(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"})(Ee||(Ee={}));const bo={start:[Ee.Space,Ee.Enter],cancel:[Ee.Esc],end:[Ee.Space,Ee.Enter,Ee.Tab]},rd=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case Ee.Right:return{...s,x:s.x+25};case Ee.Left:return{...s,x:s.x-25};case Ee.Down:return{...s,y:s.y+25};case Ee.Up:return{...s,y:s.y-25}}};class So{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 us(is(s)),this.windowListeners=new us(lt(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bt.Resize,this.handleCancel),this.windowListeners.add(bt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,l=t.node.current;l&&xo(l),s(kt)}handleKeyDown(t){if(fi(t)){const{active:s,context:l,options:m}=this.props,{keyboardCodes:v=bo,coordinateGetter:x=rd,scrollBehavior:i="smooth"}=m,{code:n}=t;if(v.end.includes(n)){this.handleEnd(t);return}if(v.cancel.includes(n)){this.handleCancel(t);return}const{collisionRect:c}=l.current,f=c?{x:c.left,y:c.top}:kt;this.referenceCoordinates||(this.referenceCoordinates=f);const a=x(t,{active:s,context:l.current,currentCoordinates:f});if(a){const p=Ks(a,f),S={x:0,y:0},{scrollableAncestors:y}=l.current;for(const _ of y){const o=t.code,{isTop:h,isRight:u,isLeft:d,isBottom:b,maxScroll:C,minScroll:w}=go(_),j=Qc(_),g={x:Math.min(o===Ee.Right?j.right-j.width/2:j.right,Math.max(o===Ee.Right?j.left:j.left+j.width/2,a.x)),y:Math.min(o===Ee.Down?j.bottom-j.height/2:j.bottom,Math.max(o===Ee.Down?j.top:j.top+j.height/2,a.y))},k=o===Ee.Right&&!u||o===Ee.Left&&!d,R=o===Ee.Down&&!b||o===Ee.Up&&!h;if(k&&g.x!==a.x){const D=_.scrollLeft+p.x,M=o===Ee.Right&&D<=C.x||o===Ee.Left&&D>=w.x;if(M&&!p.y){_.scrollTo({left:D,behavior:i});return}M?S.x=_.scrollLeft-D:S.x=o===Ee.Right?_.scrollLeft-C.x:_.scrollLeft-w.x,S.x&&_.scrollBy({left:-S.x,behavior:i});break}else if(R&&g.y!==a.y){const D=_.scrollTop+p.y,M=o===Ee.Down&&D<=C.y||o===Ee.Up&&D>=w.y;if(M&&!p.x){_.scrollTo({top:D,behavior:i});return}M?S.y=_.scrollTop-D:S.y=o===Ee.Down?_.scrollTop-C.y:_.scrollTop-w.y,S.y&&_.scrollBy({top:-S.y,behavior:i});break}}this.handleMove(t,ts(Ks(a,this.referenceCoordinates),S))}}}handleMove(t,s){const{onMove:l}=this.props;t.preventDefault(),l(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()}}So.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:l=bo,onActivation:m}=t,{active:v}=s;const{code:x}=e.nativeEvent;if(l.start.includes(x)){const i=v.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Gi(e){return!!(e&&"distance"in e)}function Qi(e){return!!(e&&"delay"in e)}class vi{constructor(t,s,l){var m;l===void 0&&(l=td(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:x}=v;this.props=t,this.events=s,this.document=is(x),this.documentListeners=new us(this.document),this.listeners=new us(l),this.windowListeners=new us(lt(x)),this.initialCoordinates=(m=Xs(v))!=null?m:kt,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:l}}}=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(bt.Resize,this.handleCancel),this.windowListeners.add(bt.DragStart,Vi),this.windowListeners.add(bt.VisibilityChange,this.handleCancel),this.windowListeners.add(bt.ContextMenu,Vi),this.documentListeners.add(bt.Keydown,this.handleKeydown),s){if(l!=null&&l({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qi(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Gi(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:l,onPending:m}=this.props;m(l,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(bt.Click,sd,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bt.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:l,initialCoordinates:m,props:v}=this,{onMove:x,options:{activationConstraint:i}}=v;if(!m)return;const n=(s=Xs(t))!=null?s:kt,c=Ks(m,n);if(!l&&i){if(Gi(i)){if(i.tolerance!=null&&wr(c,i.tolerance))return this.handleCancel();if(wr(c,i.distance))return this.handleStart()}if(Qi(i)&&wr(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),x(n)}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===Ee.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const id={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gi extends vi{constructor(t){const{event:s}=t,l=is(s.target);super(t,id,l)}}gi.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return!s.isPrimary||s.button!==0?!1:(l?.({event:s}),!0)}}];const nd={move:{name:"mousemove"},end:{name:"mouseup"}};var qr;(function(e){e[e.RightClick=2]="RightClick"})(qr||(qr={}));class od extends vi{constructor(t){super(t,nd,is(t.event.target))}}od.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return s.button===qr.RightClick?!1:(l?.({event:s}),!0)}}];const Er={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ad extends vi{constructor(t){super(t,Er)}static setup(){return window.addEventListener(Er.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Er.move.name,t)};function t(){}}}ad.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;const{touches:m}=s;return m.length>1?!1:(l?.({event:s}),!0)}}];var hs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(hs||(hs={}));var Vs;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Vs||(Vs={}));function ld(e){let{acceleration:t,activator:s=hs.Pointer,canScroll:l,draggingRect:m,enabled:v,interval:x=5,order:i=Vs.TreeOrder,pointerCoordinates:n,scrollableAncestors:c,scrollableAncestorRects:f,delta:a,threshold:p}=e;const S=dd({delta:a,disabled:!v}),[y,_]=Sc(),o=E.useRef({x:0,y:0}),h=E.useRef({x:0,y:0}),u=E.useMemo(()=>{switch(s){case hs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case hs.DraggableRect:return m}},[s,m,n]),d=E.useRef(null),b=E.useCallback(()=>{const w=d.current;if(!w)return;const j=o.current.x*h.current.x,g=o.current.y*h.current.y;w.scrollBy(j,g)},[]),C=E.useMemo(()=>i===Vs.TreeOrder?[...c].reverse():c,[i,c]);E.useEffect(()=>{if(!v||!c.length||!u){_();return}for(const w of C){if(l?.(w)===!1)continue;const j=c.indexOf(w),g=f[j];if(!g)continue;const{direction:k,speed:R}=Gc(w,g,u,t,p);for(const D of["x","y"])S[D][k[D]]||(R[D]=0,k[D]=0);if(R.x>0||R.y>0){_(),d.current=w,y(b,x),o.current=R,h.current=k;return}}o.current={x:0,y:0},h.current={x:0,y:0},_()},[t,b,l,_,v,x,JSON.stringify(u),JSON.stringify(S),y,c,C,f,JSON.stringify(p)])}const cd={x:{[et.Backward]:!1,[et.Forward]:!1},y:{[et.Backward]:!1,[et.Forward]:!1}};function dd(e){let{delta:t,disabled:s}=e;const l=qs(t);return ks(m=>{if(s||!l||!m)return cd;const v={x:Math.sign(t.x-l.x),y:Math.sign(t.y-l.y)};return{x:{[et.Backward]:m.x[et.Backward]||v.x===-1,[et.Forward]:m.x[et.Forward]||v.x===1},y:{[et.Backward]:m.y[et.Backward]||v.y===-1,[et.Forward]:m.y[et.Forward]||v.y===1}}},[s,t,l])}function ud(e,t){const s=t!=null?e.get(t):void 0,l=s?s.node.current:null;return ks(m=>{var v;return t==null?null:(v=l??m)!=null?v:null},[l,t])}function hd(e,t){return E.useMemo(()=>e.reduce((s,l)=>{const{sensor:m}=l,v=m.activators.map(x=>({eventName:x.eventName,handler:t(x.handler,l)}));return[...s,...v]},[]),[e,t])}var Ss;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ss||(Ss={}));var Kr;(function(e){e.Optimized="optimized"})(Kr||(Kr={}));const Zi=new Map;function fd(e,t){let{dragging:s,dependencies:l,config:m}=t;const[v,x]=E.useState(null),{frequency:i,measure:n,strategy:c}=m,f=E.useRef(e),a=o(),p=xs(a),S=E.useCallback(function(h){h===void 0&&(h=[]),!p.current&&x(u=>u===null?h:u.concat(h.filter(d=>!u.includes(d))))},[p]),y=E.useRef(null),_=ks(h=>{if(a&&!s)return Zi;if(!h||h===Zi||f.current!==e||v!=null){const u=new Map;for(let d of e){if(!d)continue;if(v&&v.length>0&&!v.includes(d.id)&&d.rect.current){u.set(d.id,d.rect.current);continue}const b=d.node.current,C=b?new pi(n(b),b):null;d.rect.current=C,C&&u.set(d.id,C)}return u}return h},[e,v,s,a,n]);return E.useEffect(()=>{f.current=e},[e]),E.useEffect(()=>{a||S()},[s,a]),E.useEffect(()=>{v&&v.length>0&&x(null)},[JSON.stringify(v)]),E.useEffect(()=>{a||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{S(),y.current=null},i))},[i,a,S,...l]),{droppableRects:_,measureDroppableContainers:S,measuringScheduled:v!=null};function o(){switch(c){case Ss.Always:return!1;case Ss.BeforeDragging:return s;default:return!s}}}function _i(e,t){return ks(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function md(e,t){return _i(e,t)}function pd(e){let{callback:t,disabled:s}=e;const l=nr(t),m=E.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:v}=window;return new v(l)},[l,s]);return E.useEffect(()=>()=>m?.disconnect(),[m]),m}function ar(e){let{callback:t,disabled:s}=e;const l=nr(t),m=E.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:v}=window;return new v(l)},[s]);return E.useEffect(()=>()=>m?.disconnect(),[m]),m}function vd(e){return new pi(js(e),e)}function Ji(e,t,s){t===void 0&&(t=vd);const[l,m]=E.useState(null);function v(){m(n=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=n??s)!=null?c:null}const f=t(e);return JSON.stringify(n)===JSON.stringify(f)?n:f})}const x=pd({callback(n){if(e)for(const c of n){const{type:f,target:a}=c;if(f==="childList"&&a instanceof HTMLElement&&a.contains(e)){v();break}}}}),i=ar({callback:v});return At(()=>{v(),e?(i?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),x?.disconnect())},[e]),l}function gd(e){const t=_i(e);return uo(e,t)}const en=[];function _d(e){const t=E.useRef(e),s=ks(l=>e?l&&l!==en&&e&&t.current&&e.parentNode===t.current.parentNode?l:mi(e):en,[e]);return E.useEffect(()=>{t.current=e},[e]),s}function xd(e){const[t,s]=E.useState(null),l=E.useRef(e),m=E.useCallback(v=>{const x=Cr(v.target);x&&s(i=>i?(i.set(x,Ur(x)),new Map(i)):null)},[]);return E.useEffect(()=>{const v=l.current;if(e!==v){x(v);const i=e.map(n=>{const c=Cr(n);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,Ur(c)]):null}).filter(n=>n!=null);s(i.length?new Map(i):null),l.current=e}return()=>{x(e),x(v)};function x(i){i.forEach(n=>{const c=Cr(n);c?.removeEventListener("scroll",m)})}},[m,e]),E.useMemo(()=>e.length?t?Array.from(t.values()).reduce((v,x)=>ts(v,x),kt):_o(e):kt,[e,t])}function tn(e,t){t===void 0&&(t=[]);const s=E.useRef(null);return E.useEffect(()=>{s.current=null},t),E.useEffect(()=>{const l=e!==kt;l&&!s.current&&(s.current=e),!l&&s.current&&(s.current=null)},[e]),s.current?Ks(e,s.current):kt}function bd(e){E.useEffect(()=>{if(!ir)return;const t=e.map(s=>{let{sensor:l}=s;return l.setup==null?void 0:l.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function Sd(e,t){return E.useMemo(()=>e.reduce((s,l)=>{let{eventName:m,handler:v}=l;return s[m]=x=>{v(x,t)},s},{}),[e,t])}function yo(e){return E.useMemo(()=>e?Kc(e):null,[e])}const sn=[];function yd(e,t){t===void 0&&(t=js);const[s]=e,l=yo(s?lt(s):null),[m,v]=E.useState(sn);function x(){v(()=>e.length?e.map(n=>vo(n)?l:new pi(t(n),n)):sn)}const i=ar({callback:x});return At(()=>{i?.disconnect(),x(),e.forEach(n=>i?.observe(n))},[e]),m}function Co(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Es(t)?t:e}function Cd(e){let{measure:t}=e;const[s,l]=E.useState(null),m=E.useCallback(c=>{for(const{target:f}of c)if(Es(f)){l(a=>{const p=t(f);return a?{...a,width:p.width,height:p.height}:p});break}},[t]),v=ar({callback:m}),x=E.useCallback(c=>{const f=Co(c);v?.disconnect(),f&&v?.observe(f),l(f?t(f):null)},[t,v]),[i,n]=Us(x);return E.useMemo(()=>({nodeRef:i,rect:s,setRef:n}),[s,i,n])}const wd=[{sensor:gi,options:{}},{sensor:So,options:{}}],Ed={current:{}},Fs={draggable:{measure:Yi},droppable:{measure:Yi,strategy:Ss.WhileDragging,frequency:Kr.Optimized},dragOverlay:{measure:js}};class fs 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,l;return(s=(l=this.get(t))==null?void 0:l.node.current)!=null?s:void 0}}const kd={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ys},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Fs,measureDroppableContainers:Ys,windowRect:null,measuringScheduled:!1},wo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ys,draggableNodes:new Map,over:null,measureDroppableContainers:Ys},Ns=E.createContext(wo),Eo=E.createContext(kd);function jd(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new fs}}}function Nd(e,t){switch(t.type){case Qe.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Qe.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 Qe.DragEnd:case Qe.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Qe.RegisterDroppable:{const{element:s}=t,{id:l}=s,m=new fs(e.droppable.containers);return m.set(l,s),{...e,droppable:{...e.droppable,containers:m}}}case Qe.SetDroppableDisabled:{const{id:s,key:l,disabled:m}=t,v=e.droppable.containers.get(s);if(!v||l!==v.key)return e;const x=new fs(e.droppable.containers);return x.set(s,{...v,disabled:m}),{...e,droppable:{...e.droppable,containers:x}}}case Qe.UnregisterDroppable:{const{id:s,key:l}=t,m=e.droppable.containers.get(s);if(!m||l!==m.key)return e;const v=new fs(e.droppable.containers);return v.delete(s),{...e,droppable:{...e.droppable,containers:v}}}default:return e}}function Rd(e){let{disabled:t}=e;const{active:s,activatorEvent:l,draggableNodes:m}=E.useContext(Ns),v=qs(l),x=qs(s?.id);return E.useEffect(()=>{if(!t&&!l&&v&&x!=null){if(!fi(v)||document.activeElement===v.target)return;const i=m.get(x);if(!i)return;const{activatorNode:n,node:c}=i;if(!n.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[n.current,c.current]){if(!f)continue;const a=wc(f);if(a){a.focus();break}}})}},[l,t,m,x,v]),null}function ko(e,t){let{transform:s,...l}=t;return e!=null&&e.length?e.reduce((m,v)=>v({transform:m,...l}),s):s}function Ad(e){return E.useMemo(()=>({draggable:{...Fs.draggable,...e?.draggable},droppable:{...Fs.droppable,...e?.droppable},dragOverlay:{...Fs.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Td(e){let{activeNode:t,measure:s,initialRect:l,config:m=!0}=e;const v=E.useRef(!1),{x,y:i}=typeof m=="boolean"?{x:m,y:m}:m;At(()=>{if(!x&&!i||!t){v.current=!1;return}if(v.current||!l)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=s(c),a=uo(f,l);if(x||(a.x=0),i||(a.y=0),v.current=!0,Math.abs(a.x)>0||Math.abs(a.y)>0){const p=fo(c);p&&p.scrollBy({top:a.y,left:a.x})}},[t,x,i,l,s])}const lr=E.createContext({...kt,scaleX:1,scaleY:1});var Lt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Lt||(Lt={}));const Dd=E.memo(function(t){var s,l,m,v;let{id:x,accessibility:i,autoScroll:n=!0,children:c,sensors:f=wd,collisionDetection:a=Hc,measuring:p,modifiers:S,...y}=t;const _=E.useReducer(Nd,void 0,jd),[o,h]=_,[u,d]=Ac(),[b,C]=E.useState(Lt.Uninitialized),w=b===Lt.Initialized,{draggable:{active:j,nodes:g,translate:k},droppable:{containers:R}}=o,D=j!=null?g.get(j):null,M=E.useRef({initial:null,translated:null}),N=E.useMemo(()=>{var ye;return j!=null?{id:j,data:(ye=D?.data)!=null?ye:Ed,rect:M}:null},[j,D]),P=E.useRef(null),[B,z]=E.useState(null),[W,A]=E.useState(null),L=xs(y,Object.values(y)),O=or("DndDescribedBy",x),I=E.useMemo(()=>R.getEnabled(),[R]),F=Ad(p),{droppableRects:U,measureDroppableContainers:X,measuringScheduled:Y}=fd(I,{dragging:w,dependencies:[k.x,k.y],config:F.droppable}),J=ud(g,j),T=E.useMemo(()=>W?Xs(W):null,[W]),H=_t(),q=md(J,F.draggable.measure);Td({activeNode:j!=null?g.get(j):null,config:H.layoutShiftCompensation,initialRect:q,measure:F.draggable.measure});const $=Ji(J,F.draggable.measure,q),ee=Ji(J?J.parentElement:null),Q=E.useRef({activatorEvent:null,active:null,activeNode:J,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:g,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),le=R.getNodeFor((s=Q.current.over)==null?void 0:s.id),he=Cd({measure:F.dragOverlay.measure}),Se=(l=he.nodeRef.current)!=null?l:J,Be=w?(m=he.rect)!=null?m:$:null,Z=!!(he.nodeRef.current&&he.rect),Ye=gd(Z?null:$),fe=yo(Se?lt(Se):null),Fe=_d(w?le??J:null),st=yd(Fe),$e=ko(S,{transform:{x:k.x-Ye.x,y:k.y-Ye.y,scaleX:1,scaleY:1},activatorEvent:W,active:N,activeNodeRect:$,containerNodeRect:ee,draggingNodeRect:Be,over:Q.current.over,overlayNodeRect:he.rect,scrollableAncestors:Fe,scrollableAncestorRects:st,windowRect:fe}),ge=T?ts(T,k):null,Ae=xd(Fe),we=tn(Ae),tt=tn(Ae,[$]),Te=ts($e,we),je=Be?$c(Be,$e):null,Ze=N&&je?a({active:N,collisionRect:je,droppableRects:U,droppableContainers:I,pointerCoordinates:ge}):null,Ue=Bc(Ze,"id"),[_e,K]=E.useState(null),te=Z?$e:ts($e,tt),xe=zc(te,(v=_e?.rect)!=null?v:null,$),pe=E.useRef(null),Ve=E.useCallback((ye,qe)=>{let{sensor:Ke,options:ot}=qe;if(P.current==null)return;const Oe=g.get(P.current);if(!Oe)return;const Ge=ye.nativeEvent,dt=new Ke({active:P.current,activeNode:Oe,event:Ge,options:ot,context:Q,onAbort(De){if(!g.get(De))return;const{onDragAbort:ut}=L.current,mt={id:De};ut?.(mt),u({type:"onDragAbort",event:mt})},onPending(De,ft,ut,mt){if(!g.get(De))return;const{onDragPending:wt}=L.current,pt={id:De,constraint:ft,initialCoordinates:ut,offset:mt};wt?.(pt),u({type:"onDragPending",event:pt})},onStart(De){const ft=P.current;if(ft==null)return;const ut=g.get(ft);if(!ut)return;const{onDragStart:mt}=L.current,at={activatorEvent:Ge,active:{id:ft,data:ut.data,rect:M}};qt.unstable_batchedUpdates(()=>{mt?.(at),C(Lt.Initializing),h({type:Qe.DragStart,initialCoordinates:De,active:ft}),u({type:"onDragStart",event:at}),z(pe.current),A(Ge)})},onMove(De){h({type:Qe.DragMove,coordinates:De})},onEnd:Ct(Qe.DragEnd),onCancel:Ct(Qe.DragCancel)});pe.current=dt;function Ct(De){return async function(){const{active:ut,collisions:mt,over:at,scrollAdjustedTranslate:wt}=Q.current;let pt=null;if(ut&&wt){const{cancelDrop:ht}=L.current;pt={activatorEvent:Ge,active:ut,collisions:mt,delta:wt,over:at},De===Qe.DragEnd&&typeof ht=="function"&&await Promise.resolve(ht(pt))&&(De=Qe.DragCancel)}P.current=null,qt.unstable_batchedUpdates(()=>{h({type:De}),C(Lt.Uninitialized),K(null),z(null),A(null),pe.current=null;const ht=De===Qe.DragEnd?"onDragEnd":"onDragCancel";if(pt){const Wt=L.current[ht];Wt?.(pt),u({type:ht,event:pt})}})}}},[g]),rt=E.useCallback((ye,qe)=>(Ke,ot)=>{const Oe=Ke.nativeEvent,Ge=g.get(ot);if(P.current!==null||!Ge||Oe.dndKit||Oe.defaultPrevented)return;const dt={active:Ge};ye(Ke,qe.options,dt)===!0&&(Oe.dndKit={capturedBy:qe.sensor},P.current=ot,Ve(Ke,qe))},[g,Ve]),ie=hd(f,rt);bd(f),At(()=>{$&&b===Lt.Initializing&&C(Lt.Initialized)},[$,b]),E.useEffect(()=>{const{onDragMove:ye}=L.current,{active:qe,activatorEvent:Ke,collisions:ot,over:Oe}=Q.current;if(!qe||!Ke)return;const Ge={active:qe,activatorEvent:Ke,collisions:ot,delta:{x:Te.x,y:Te.y},over:Oe};qt.unstable_batchedUpdates(()=>{ye?.(Ge),u({type:"onDragMove",event:Ge})})},[Te.x,Te.y]),E.useEffect(()=>{const{active:ye,activatorEvent:qe,collisions:Ke,droppableContainers:ot,scrollAdjustedTranslate:Oe}=Q.current;if(!ye||P.current==null||!qe||!Oe)return;const{onDragOver:Ge}=L.current,dt=ot.get(Ue),Ct=dt&&dt.rect.current?{id:dt.id,rect:dt.rect.current,data:dt.data,disabled:dt.disabled}:null,De={active:ye,activatorEvent:qe,collisions:Ke,delta:{x:Oe.x,y:Oe.y},over:Ct};qt.unstable_batchedUpdates(()=>{K(Ct),Ge?.(De),u({type:"onDragOver",event:De})})},[Ue]),At(()=>{Q.current={activatorEvent:W,active:N,activeNode:J,collisionRect:je,collisions:Ze,droppableRects:U,draggableNodes:g,draggingNode:Se,draggingNodeRect:Be,droppableContainers:R,over:_e,scrollableAncestors:Fe,scrollAdjustedTranslate:Te},M.current={initial:Be,translated:je}},[N,J,Ze,je,g,Se,Be,U,R,_e,Fe,Te]),ld({...H,delta:k,draggingRect:je,pointerCoordinates:ge,scrollableAncestors:Fe,scrollableAncestorRects:st});const gt=E.useMemo(()=>({active:N,activeNode:J,activeNodeRect:$,activatorEvent:W,collisions:Ze,containerNodeRect:ee,dragOverlay:he,draggableNodes:g,droppableContainers:R,droppableRects:U,over:_e,measureDroppableContainers:X,scrollableAncestors:Fe,scrollableAncestorRects:st,measuringConfiguration:F,measuringScheduled:Y,windowRect:fe}),[N,J,$,W,Ze,ee,he,g,R,U,_e,X,Fe,st,F,Y,fe]),ct=E.useMemo(()=>({activatorEvent:W,activators:ie,active:N,activeNodeRect:$,ariaDescribedById:{draggable:O},dispatch:h,draggableNodes:g,over:_e,measureDroppableContainers:X}),[W,ie,N,$,h,O,g,_e,X]);return re.createElement(co.Provider,{value:d},re.createElement(Ns.Provider,{value:ct},re.createElement(Eo.Provider,{value:gt},re.createElement(lr.Provider,{value:xe},c)),re.createElement(Rd,{disabled:i?.restoreFocus===!1})),re.createElement(Mc,{...i,hiddenTextDescribedById:O}));function _t(){const ye=B?.autoScrollEnabled===!1,qe=typeof n=="object"?n.enabled===!1:n===!1,Ke=w&&!ye&&!qe;return typeof n=="object"?{...n,enabled:Ke}:{enabled:Ke}}}),Md=E.createContext(null),rn="button",Ld="Draggable";function Pd(e){let{id:t,data:s,disabled:l=!1,attributes:m}=e;const v=or(Ld),{activators:x,activatorEvent:i,active:n,activeNodeRect:c,ariaDescribedById:f,draggableNodes:a,over:p}=E.useContext(Ns),{role:S=rn,roleDescription:y="draggable",tabIndex:_=0}=m??{},o=n?.id===t,h=E.useContext(o?lr:Md),[u,d]=Us(),[b,C]=Us(),w=Sd(x,t),j=xs(s);At(()=>(a.set(t,{id:t,key:v,node:u,activatorNode:b,data:j}),()=>{const k=a.get(t);k&&k.key===v&&a.delete(t)}),[a,t]);const g=E.useMemo(()=>({role:S,tabIndex:_,"aria-disabled":l,"aria-pressed":o&&S===rn?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[l,S,_,o,y,f.draggable]);return{active:n,activatorEvent:i,activeNodeRect:c,attributes:g,isDragging:o,listeners:l?void 0:w,node:u,over:p,setNodeRef:d,setActivatorNodeRef:C,transform:h}}function Od(){return E.useContext(Eo)}const Id="Droppable",Bd={timeout:25};function Fd(e){let{data:t,disabled:s=!1,id:l,resizeObserverConfig:m}=e;const v=or(Id),{active:x,dispatch:i,over:n,measureDroppableContainers:c}=E.useContext(Ns),f=E.useRef({disabled:s}),a=E.useRef(!1),p=E.useRef(null),S=E.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:o}={...Bd,...m},h=xs(_??l),u=E.useCallback(()=>{if(!a.current){a.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),S.current=null},o)},[o]),d=ar({callback:u,disabled:y||!x}),b=E.useCallback((g,k)=>{d&&(k&&(d.unobserve(k),a.current=!1),g&&d.observe(g))},[d]),[C,w]=Us(b),j=xs(t);return E.useEffect(()=>{!d||!C.current||(d.disconnect(),a.current=!1,d.observe(C.current))},[C,d]),E.useEffect(()=>(i({type:Qe.RegisterDroppable,element:{id:l,key:v,disabled:s,node:C,rect:p,data:j}}),()=>i({type:Qe.UnregisterDroppable,key:v,id:l})),[l]),E.useEffect(()=>{s!==f.current.disabled&&(i({type:Qe.SetDroppableDisabled,id:l,key:v,disabled:s}),f.current.disabled=s)},[l,v,s,i]),{active:x,rect:p,isOver:n?.id===l,node:C,over:n,setNodeRef:w}}function Hd(e){let{animation:t,children:s}=e;const[l,m]=E.useState(null),[v,x]=E.useState(null),i=qs(s);return!s&&!l&&i&&m(i),At(()=>{if(!v)return;const n=l?.key,c=l?.props.id;if(n==null||c==null){m(null);return}Promise.resolve(t(c,v)).then(()=>{m(null)})},[t,l,v]),re.createElement(re.Fragment,null,s,l?E.cloneElement(l,{ref:x}):null)}const zd={x:0,y:0,scaleX:1,scaleY:1};function Wd(e){let{children:t}=e;return re.createElement(Ns.Provider,{value:wo},re.createElement(lr.Provider,{value:zd},t))}const $d={position:"fixed",touchAction:"none"},Ud=e=>fi(e)?"transform 250ms ease":void 0,qd=E.forwardRef((e,t)=>{let{as:s,activatorEvent:l,adjustScale:m,children:v,className:x,rect:i,style:n,transform:c,transition:f=Ud}=e;if(!i)return null;const a=m?c:{...c,scaleX:1,scaleY:1},p={...$d,width:i.width,height:i.height,top:i.top,left:i.left,transform:bs.Transform.toString(a),transformOrigin:m&&l?Oc(l,i):void 0,transition:typeof f=="function"?f(l):f,...n};return re.createElement(s,{className:x,style:p,ref:t},v)}),Kd=e=>t=>{let{active:s,dragOverlay:l}=t;const m={},{styles:v,className:x}=e;if(v!=null&&v.active)for(const[i,n]of Object.entries(v.active))n!==void 0&&(m[i]=s.node.style.getPropertyValue(i),s.node.style.setProperty(i,n));if(v!=null&&v.dragOverlay)for(const[i,n]of Object.entries(v.dragOverlay))n!==void 0&&l.node.style.setProperty(i,n);return x!=null&&x.active&&s.node.classList.add(x.active),x!=null&&x.dragOverlay&&l.node.classList.add(x.dragOverlay),function(){for(const[n,c]of Object.entries(m))s.node.style.setProperty(n,c);x!=null&&x.active&&s.node.classList.remove(x.active)}},Xd=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:bs.Transform.toString(t)},{transform:bs.Transform.toString(s)}]},Yd={duration:250,easing:"ease",keyframes:Xd,sideEffects:Kd({styles:{active:{opacity:"0"}}})};function Vd(e){let{config:t,draggableNodes:s,droppableContainers:l,measuringConfiguration:m}=e;return nr((v,x)=>{if(t===null)return;const i=s.get(v);if(!i)return;const n=i.node.current;if(!n)return;const c=Co(x);if(!c)return;const{transform:f}=lt(x).getComputedStyle(x),a=ho(f);if(!a)return;const p=typeof t=="function"?t:Gd(t);return xo(n,m.draggable.measure),p({active:{id:v,data:i.data,node:n,rect:m.draggable.measure(n)},draggableNodes:s,dragOverlay:{node:x,rect:m.dragOverlay.measure(c)},droppableContainers:l,measuringConfiguration:m,transform:a})})}function Gd(e){const{duration:t,easing:s,sideEffects:l,keyframes:m}={...Yd,...e};return v=>{let{active:x,dragOverlay:i,transform:n,...c}=v;if(!t)return;const f={x:i.rect.left-x.rect.left,y:i.rect.top-x.rect.top},a={scaleX:n.scaleX!==1?x.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?x.rect.height*n.scaleY/i.rect.height:1},p={x:n.x-f.x,y:n.y-f.y,...a},S=m({...c,active:x,dragOverlay:i,transform:{initial:n,final:p}}),[y]=S,_=S[S.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const o=l?.({active:x,dragOverlay:i,...c}),h=i.node.animate(S,{duration:t,easing:s,fill:"forwards"});return new Promise(u=>{h.onfinish=()=>{o?.(),u()}})}}let nn=0;function Qd(e){return E.useMemo(()=>{if(e!=null)return nn++,nn},[e])}const Zd=re.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:l,style:m,transition:v,modifiers:x,wrapperElement:i="div",className:n,zIndex:c=999}=e;const{activatorEvent:f,active:a,activeNodeRect:p,containerNodeRect:S,draggableNodes:y,droppableContainers:_,dragOverlay:o,over:h,measuringConfiguration:u,scrollableAncestors:d,scrollableAncestorRects:b,windowRect:C}=Od(),w=E.useContext(lr),j=Qd(a?.id),g=ko(x,{activatorEvent:f,active:a,activeNodeRect:p,containerNodeRect:S,draggingNodeRect:o.rect,over:h,overlayNodeRect:o.rect,scrollableAncestors:d,scrollableAncestorRects:b,transform:w,windowRect:C}),k=_i(p),R=Vd({config:l,draggableNodes:y,droppableContainers:_,measuringConfiguration:u}),D=k?o.setRef:void 0;return re.createElement(Wd,null,re.createElement(Hd,{animation:R},a&&j?re.createElement(qd,{key:j,id:a.id,ref:D,as:i,activatorEvent:f,adjustScale:t,className:n,transition:v,rect:k,style:{zIndex:c,...m},transform:g},s):null))}),jo=768;function Jd(e){const t=window.matchMedia(`(max-width: ${jo-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function eu(){return window.innerWidth<jo}function tu(){return!1}function No(){return E.useSyncExternalStore(Jd,eu,tu)}const de={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},su=[{status:de.Review,label:"Review",icon:ei,color:"text-amber-600"},{status:de.Running,label:"Running",icon:ti,color:"text-blue-600"},{status:de.Pending,label:"Pending",icon:si,color:"text-neutral-600"},{status:de.Done,label:"Done",icon:ri,color:"text-emerald-600"},{status:de.Cancelled,label:"Cancelled",icon:ii,color:"text-neutral-500"}];function ru({task:e,status:t,isSelected:s,isAgentActive:l,project:m,onSelectTask:v,onTaskStatusChange:x,onDeleteTask:i,disableDrag:n}){const{t:c}=ae(),f=!!e.projectArchivedAt,a=f||!!n,{attributes:p,listeners:S,setNodeRef:y,isDragging:_}=Pd({id:e.id,data:{task:e,fromStatus:t},disabled:a}),[o,h]=E.useState(null),u=E.useRef(null),d=E.useRef(null),b=E.useCallback(j=>{f||!x&&!i||(j.preventDefault(),h({x:j.clientX,y:j.clientY}))},[f,x,i]),C=E.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),w=E.useCallback(j=>{if(!n||f||!x&&!i)return;const g=j.touches[0];if(!g)return;const{clientX:k,clientY:R}=g;d.current=setTimeout(()=>{d.current=null,h({x:k,y:R})},500)},[n,f,x,i]);return E.useEffect(()=>{if(!o)return;const j=g=>{u.current&&!u.current.contains(g.target)&&h(null)};return document.addEventListener("mousedown",j),document.addEventListener("touchstart",j),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("touchstart",j)}},[o]),r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:y,onClick:()=>v(e.id),onContextMenu:b,onTouchStart:w,onTouchEnd:C,onTouchMove:C,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
7
+ ${_?"opacity-30":""}
8
+ ${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...a?{}:S,...a?{}:p,children:[r.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===de.Running?"text-blue-600":"text-neutral-500"}`,children:[t===de.Review&&r.jsx(ei,{className:s?"text-amber-600":"text-neutral-500"}),t===de.Running&&r.jsx(ti,{className:"animate-pulse"}),t===de.Pending&&r.jsx(si,{}),t===de.Done&&r.jsx(ri,{className:"text-neutral-400"}),t===de.Cancelled&&r.jsx(ii,{className:"text-neutral-400"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"mb-0.5",children:[r.jsx("span",{className:`font-medium mr-1 ${m?.color||"text-neutral-500"}`,children:m?.name}),r.jsx("span",{className:"text-neutral-400",children:"/"}),r.jsx("span",{className:`ml-1 ${s?"text-neutral-900":"text-neutral-700"}`,children:e.title}),e.projectArchivedAt&&r.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),l&&r.jsxs("span",{className:"relative inline-flex h-2 w-2 ml-1.5 align-middle",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),r.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})]})]}),o&&r.jsxs("div",{ref:u,className:"fixed z-[100] w-44 bg-white rounded-lg border border-neutral-200 shadow-xl py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:o.x,top:o.y},children:[x&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:c("Move to")}),su.filter(j=>j.status!==t).map(j=>{const g=j.icon;return r.jsxs("button",{onClick:()=>{x(e.id,j.status),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[r.jsx(g,{className:`w-3.5 h-3.5 ${j.color}`}),r.jsx("span",{className:"text-neutral-700",children:c(j.label)})]},j.status)})]}),i&&r.jsxs(r.Fragment,{children:[x&&r.jsx("div",{className:"my-1 border-t border-neutral-100"}),r.jsxs("button",{onClick:()=>{i(e.id),h(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:[r.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:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),r.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),r.jsx("span",{children:c("Delete Task")})]})]})]})]})}const iu=E.memo(function({title:t,tasks:s,status:l,defaultOpen:m,selectedTaskId:v,onSelectTask:x,projects:i,activeTaskIds:n,isDragging:c,dragFromStatus:f,onTaskStatusChange:a,onDeleteTask:p,disableDrag:S}){const{t:y}=ae(),[_,o]=E.useState(m),h=s.length===0,u=c&&f===l,d=c&&f!==l,{setNodeRef:b,isOver:C}=Fd({id:`group-${l}`,data:{status:l}}),w=l===de.Review,j=y(t),g=c?u&&(_||!0):_;return r.jsxs("div",{className:"mb-2",children:[r.jsxs("button",{onClick:()=>!c&&o(k=>!k),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:[r.jsx("span",{className:"mr-2 text-neutral-400",children:g?r.jsx(jt,{size:14}):r.jsx(Ht,{size:14})}),r.jsx("span",{className:"flex-1 text-left",children:j}),w&&!h?r.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}):r.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",s.length,")"]})]}),d&&r.jsx("div",{ref:b,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
+ ${C?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:r.jsx("span",{className:"text-xs font-medium",children:C?y("Drop into {title}",{title:j}):y("Drop here")})}),g&&!d&&r.jsx("div",{ref:u?void 0:b,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
10
+ ${C&&!u?"bg-blue-50 ring-1 ring-blue-200":""}
11
+ ${h&&c?"border border-dashed border-neutral-300":""}`,children:h?r.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:y("No tasks")}):s.map(k=>{const R=i.find(N=>N.id===k.projectId),D=v===k.id,M=n?.has(k.id)??!1;return r.jsx(ru,{task:k,status:l,isSelected:D,isAgentActive:M,project:R,onSelectTask:x,onTaskStatusChange:k.projectArchivedAt?void 0:a,onDeleteTask:k.projectArchivedAt?void 0:p,disableDrag:S},k.id)})})]})});function nu(e){const t={[de.Review]:[],[de.Running]:[],[de.Pending]:[],[de.Done]:[],[de.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const ou=[{status:de.Review,title:"Review",defaultOpen:!0},{status:de.Running,title:"Running",defaultOpen:!0},{status:de.Pending,title:"Pending",defaultOpen:!1},{status:de.Done,title:"Done",defaultOpen:!1},{status:de.Cancelled,title:"Cancelled",defaultOpen:!1}];function on({tasks:e=[],projects:t=[],selectedTaskId:s,onSelectTask:l,filterProjectId:m,setFilterProjectId:v,width:x=320,onCreateProject:i,onCreateTask:n,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:a}){const{t:p}=ae(),S=No(),[y,_]=E.useState(!1),[o,h]=E.useState(null),[u,d]=E.useState(null),b=Pc(Lc(gi,{activationConstraint:{distance:8}})),C=E.useCallback(P=>{const B=P.active.data.current?.task,z=P.active.data.current?.fromStatus;B&&h(B),z&&d(z)},[]),w=E.useCallback(P=>{h(null),d(null);const{active:B,over:z}=P;if(!z)return;const W=B.data.current?.task,A=B.data.current?.fromStatus,L=z.data.current?.status;!W||!A||!L||W.projectArchivedAt||A!==L&&f?.(W.id,L)},[f]),j=m?e.filter(P=>P.projectId===m):e,g=m?t.find(P=>P.id===m)??null:null,k=t.filter(P=>!P.archivedAt),D=!!!g?.archivedAt,M=nu(j),N=x==="100%";return r.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${N?"":"border-r border-neutral-200"}`,style:{width:x},children:[r.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[r.jsxs("div",{className:"relative flex-1 mr-2",children:[r.jsxs("button",{onClick:()=>_(P=>!P),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&&g?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${g.color.replace("text-","bg-")}`}),r.jsx("span",{className:"truncate",children:g.name})]}):r.jsxs(r.Fragment,{children:[r.jsx(Wr,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),r.jsx("span",{children:p("All Projects")})]}),r.jsx(jt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${y?"rotate-180":""}`})]}),y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>_(!1)}),r.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:[r.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:p("Select View")}),r.jsxs("button",{onClick:()=>{v(null),_(!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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.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:r.jsx(Wr,{size:12})}),r.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:p("All Projects")})]}),m===null?r.jsx(Yt,{size:14,className:"text-neutral-900"}):null]}),r.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),k.map(P=>{const B=m===P.id,z=P.color.replace("text-","bg-");return r.jsxs("button",{onClick:()=>{v(P.id),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${z}`}),r.jsx("span",{className:B?"text-neutral-900 font-medium":"text-neutral-600",children:P.name})]}),B?r.jsx(Yt,{size:14,className:"text-neutral-900"}):null]},P.id)}),r.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),r.jsxs("button",{onClick:()=>{_(!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:[r.jsx(vs,{size:14}),r.jsx("span",{children:p("Create New Project...")})]})]})]}):null]}),r.jsx("button",{onClick:n,disabled:!D,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:p(D?"New Task":"Deleted projects are read-only"),children:r.jsx(vs,{size:18})})]}),r.jsxs(Dd,{sensors:b,onDragStart:C,onDragEnd:w,children:[r.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:ou.map(({status:P,title:B,defaultOpen:z})=>r.jsx(iu,{title:B,tasks:M[P],status:P,defaultOpen:z,selectedTaskId:s,onSelectTask:l,projects:t,activeTaskIds:c,isDragging:o!==null,dragFromStatus:u,onTaskStatusChange:f,onDeleteTask:a,disableDrag:S},P))}),r.jsx(Zd,{dropAnimation:null,children:o?r.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:r.jsx("span",{className:"text-neutral-700 font-medium",children:o.title})}):null})]}),j.length>0?r.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[r.jsx("span",{children:p("{count} tasks",{count:j.length})}),m?r.jsx("button",{onClick:()=>v(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:p("Clear filter")}):null]}):r.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:r.jsx("span",{children:p("{count} tasks",{count:0})})})]})}const au={damping:.7,stiffness:.05,mass:1.25},lu=70,cu=1e3/60,du=350;let cr=!1;globalThis.document?.addEventListener("mousedown",()=>{cr=!0});globalThis.document?.addEventListener("mouseup",()=>{cr=!1});globalThis.document?.addEventListener("click",()=>{cr=!1});const xi=(e={})=>{const[t,s]=E.useState(!1),[l,m]=E.useState(e.initial!==!1),[v,x]=E.useState(!1),i=E.useRef(null);i.current=e;const n=E.useCallback(()=>{if(!cr)return!1;const u=window.getSelection();if(!u||!u.rangeCount)return!1;const d=u.getRangeAt(0);return d.commonAncestorContainer.contains(o.current)||o.current?.contains(d.commonAncestorContainer)},[]),c=E.useCallback(u=>{a.isAtBottom=u,m(u)},[]),f=E.useCallback(u=>{a.escapedFromLock=u,s(u)},[]),a=E.useMemo(()=>{let u;return{escapedFromLock:t,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return o.current?.scrollTop??0},set scrollTop(d){o.current&&(o.current.scrollTop=d,a.ignoreScrollToTop=o.current.scrollTop)},get targetScrollTop(){return!o.current||!h.current?0:o.current.scrollHeight-1-o.current.clientHeight},get calculatedTargetScrollTop(){if(!o.current||!h.current)return 0;const{targetScrollTop:d}=this;if(!e.targetScrollTop)return d;if(u?.targetScrollTop===d)return u.calculatedScrollTop;const b=Math.max(Math.min(e.targetScrollTop(d,{scrollElement:o.current,contentElement:h.current}),d),0);return u={targetScrollTop:d,calculatedScrollTop:b},requestAnimationFrame(()=>{u=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=lu}}},[]),p=E.useCallback((u={})=>{typeof u=="string"&&(u={animation:u}),u.preserveScrollPosition||c(!0);const d=Date.now()+(Number(u.wait)||0),b=jr(i.current,u.animation),{ignoreEscapes:C=!1}=u;let w,j=a.calculatedTargetScrollTop;u.duration instanceof Promise?u.duration.finally(()=>{w=Date.now()}):w=d+(u.duration??0);const g=async()=>{const k=new Promise(requestAnimationFrame).then(()=>{if(!a.isAtBottom)return a.animation=void 0,!1;const{scrollTop:R}=a,D=performance.now(),M=(D-(a.lastTick??D))/cu;if(a.animation||(a.animation={behavior:b,promise:k,ignoreEscapes:C}),a.animation.behavior===b&&(a.lastTick=D),n()||d>Date.now())return g();if(R<Math.min(j,a.calculatedTargetScrollTop)){if(a.animation?.behavior===b){if(b==="instant")return a.scrollTop=a.calculatedTargetScrollTop,g();a.velocity=(b.damping*a.velocity+b.stiffness*a.scrollDifference)/b.mass,a.accumulated+=a.velocity*M,a.scrollTop+=a.accumulated,a.scrollTop!==R&&(a.accumulated=0)}return g()}return w>Date.now()?(j=a.calculatedTargetScrollTop,g()):(a.animation=void 0,a.scrollTop<a.calculatedTargetScrollTop?p({animation:jr(i.current,i.current.resize),ignoreEscapes:C,duration:Math.max(0,w-Date.now())||void 0}):a.isAtBottom)});return k.then(R=>(requestAnimationFrame(()=>{a.animation||(a.lastTick=void 0,a.velocity=0)}),R))};return u.wait!==!0&&(a.animation=void 0),a.animation?.behavior===b?a.animation.promise:g()},[c,n,a]),S=E.useCallback(()=>{f(!0),c(!1)},[f,c]),y=E.useCallback(({target:u})=>{if(u!==o.current)return;const{scrollTop:d,ignoreScrollToTop:b}=a;let{lastScrollTop:C=d}=a;a.lastScrollTop=d,a.ignoreScrollToTop=void 0,b&&b>d&&(C=b),x(a.isNearBottom),setTimeout(()=>{if(a.resizeDifference||d===b)return;if(n()){f(!0),c(!1);return}const w=d>C,j=d<C;if(a.animation?.ignoreEscapes){a.scrollTop=C;return}j&&(f(!0),c(!1)),w&&f(!1),!a.escapedFromLock&&a.isNearBottom&&c(!0)},1)},[f,c,n,a]),_=E.useCallback(({target:u,deltaY:d})=>{let b=u;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===o.current&&d<0&&o.current.scrollHeight>o.current.clientHeight&&!a.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,a]),o=an(u=>{o.current?.removeEventListener("scroll",y),o.current?.removeEventListener("wheel",_),u?.addEventListener("scroll",y,{passive:!0}),u?.addEventListener("wheel",_,{passive:!0})},[]),h=an(u=>{if(a.resizeObserver?.disconnect(),!u)return;let d;a.resizeObserver=new ResizeObserver(([b])=>{const{height:C}=b.contentRect,w=C-(d??C);if(a.resizeDifference=w,a.scrollTop>a.targetScrollTop&&(a.scrollTop=a.targetScrollTop),x(a.isNearBottom),w>=0){const j=jr(i.current,d?i.current.resize:i.current.initial);p({animation:j,wait:!0,preserveScrollPosition:!0,duration:j==="instant"?void 0:du})}else a.isNearBottom&&(f(!1),c(!0));d=C,requestAnimationFrame(()=>{setTimeout(()=>{a.resizeDifference===w&&(a.resizeDifference=0)},1)})}),a.resizeObserver?.observe(u)},[]);return{contentRef:h,scrollRef:o,scrollToBottom:p,stopScroll:S,isAtBottom:l||v,isNearBottom:v,escapedFromLock:t,state:a}};function an(e,t){const s=E.useCallback(l=>(s.current=l,e(l)),t);return s}const kr=new Map;function jr(...e){const t={...au};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 l=JSON.stringify(t);return kr.has(l)||kr.set(l,Object.freeze(t)),s?"instant":kr.get(l)}function uu({content:e,children:t,className:s=""}){return r.jsxs("div",{className:`group/tooltip relative ${s}`,children:[t,r.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,r.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-neutral-900"})]})]})}function Ds(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function hu(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Ro({usage:e}){const{t}=ae();if(!e)return null;const s=e.modelContextWindow,l=s?e.totalTokens/s:0,m=s?Math.min(Math.round(l*100),100):null,v=s?hu(l):"text-neutral-400",x=s?r.jsx("span",{children:t("上下文: {used} / {max} tokens",{used:Ds(e.totalTokens),max:Ds(s)})}):r.jsx("span",{children:t("已使用: {used} tokens",{used:Ds(e.totalTokens)})});return r.jsx(uu,{content:x,children:r.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:[r.jsx(Ul,{size:14,className:v}),r.jsxs("span",{className:`tabular-nums ${v}`,children:[Ds(e.totalTokens),m!==null&&r.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",m,"%"]})]})]})})}const fu=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED"]),mu="/api",pu=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${mu}/attachments/by-path?path=${encodeURIComponent(e)}`:e,vu=({src:e,alt:t,...s})=>r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:r.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"})}),gu={img:vu};function _u(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function xu(e,t){return e?.status==="RUNNING"?"running":e?.status==="WAITING_ROOM_REPLY"?"waiting room reply":e?.status==="QUEUED"?"queued":"idle"}function bu(e){const t=e.trim();if(!t)return"?";const s=t.split(/\s+/).filter(Boolean);return s.length>=2?`${s[0][0]??""}${s[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function Su(e,t){const l=e.slice(0,t).match(/(^|\s)@([^\s@]*)$/);return!l||l.index==null?null:{start:l.index+l[1].length,end:t,query:l[2]??""}}function yu(e,t){const s=t.trim().toLowerCase();return s?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(s)):!0}function Cu(e){return Array.from(new Set([e.name,...e.aliases??[]].map(t=>t.trim()).filter(Boolean)))}function wu(e,t){return Cu(t).some(s=>e.includes(`@${s}`))}function ln(e,t){return t.filter(s=>wu(e,s))}function Eu(e,t){return e.label??t.get(e.memberId)?.name??e.memberId}function ku(e,t){const s=e.mentions??[];if(s.length===0)return e.content;const l=s.map(v=>Eu(v,t)).filter(v=>v&&!e.content.includes(`@${v}`));if(l.length===0)return e.content;const m=l.map(v=>`@${v}`).join(" ");return e.content.trimEnd()?`${e.content.trimEnd()} ${m}`:m}function ju(e,t,s){if(e.senderType!=="agent")return null;if(e.senderId&&t.has(e.senderId))return t.get(e.senderId)??null;if(e.senderInvocationId){const l=s.get(e.senderInvocationId);if(l?.memberId&&t.has(l.memberId))return t.get(l.memberId)??null}return null}function cn({content:e,isUser:t}){return r.jsx("div",{className:ne("prose prose-sm max-w-none break-words","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0","prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5","prose-pre:my-2 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-lg prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs","prose-code:break-words prose-code:text-[0.92em]","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold","prose-hr:my-3",t?"text-neutral-900 prose-strong:text-neutral-900":"text-neutral-800 prose-strong:text-neutral-900"),children:r.jsx(ni,{urlTransform:pu,components:gu,children:e})})}function Ms({name:e,avatar:t,className:s}){const[l,m]=E.useState(!1),v=E.useMemo(()=>bu(e),[e]);return t&&!l?r.jsx("img",{src:t,alt:e,onError:()=>m(!0),className:ne("h-7 w-7 rounded-full border border-neutral-200 object-cover bg-white shrink-0",s)}):r.jsx("div",{className:ne("h-7 w-7 rounded-full border border-neutral-200 bg-neutral-100 text-neutral-600 flex items-center justify-center text-[10px] font-semibold shrink-0",s),children:v})}function Nu({teamRun:e,messages:t,readOnly:s,readOnlyMessage:l,onSendMessage:m,onViewInvocationSession:v}){const{t:x}=ae(),[i,n]=E.useState(""),[c,f]=E.useState(!1),[a,p]=E.useState(null),[S,y]=E.useState(0),[_,o]=E.useState([]),[h,u]=E.useState(!1),[d,b]=E.useState(null),C=E.useRef(null),{scrollRef:w,contentRef:j,isAtBottom:g,scrollToBottom:k}=xi({resize:"smooth",initial:"instant"}),R=E.useMemo(()=>new Map((e.members??[]).map(F=>[F.id,F])),[e.members]),D=E.useMemo(()=>new Map((e.invocations??[]).map(F=>[F.id,F])),[e.invocations]),M=E.useMemo(()=>[...t].sort((F,U)=>{const X=Date.parse(F.createdAt??""),Y=Date.parse(U.createdAt??"");return(Number.isNaN(X)?0:X)-(Number.isNaN(Y)?0:Y)}),[t]),N=E.useMemo(()=>(e.invocations??[]).filter(U=>fu.has(U.status)).sort((U,X)=>{const Y=Date.parse(U.updatedAt??U.createdAt??""),J=Date.parse(X.updatedAt??X.createdAt??"");return(Number.isNaN(J)?0:J)-(Number.isNaN(Y)?0:Y)}).map(U=>({invocation:U,member:R.get(U.memberId)??null})),[e.invocations,R]),P=E.useMemo(()=>_.map(F=>R.get(F)).filter(F=>!!F),[R,_]),B=E.useMemo(()=>{const F=a?.query??"";return(e.members??[]).filter(U=>yu(U,F)).sort((U,X)=>{const Y=_.includes(U.id),J=_.includes(X.id);return Y!==J?Y?1:-1:U.name.localeCompare(X.name)})},[a?.query,_,e.members]),z=!s&&(c||!!a)&&B.length>0,W=E.useCallback((F,U)=>{if(U==null){p(null);return}p(Su(F,U)),y(0)},[]),A=E.useCallback(F=>{o(T=>T.includes(F.id)?T:[...T,F.id]);const U=`@${F.name} `;if(a){const T=`${i.slice(0,a.start)}${U}${i.slice(a.end)}`,H=a.start+U.length;n(T),p(null),f(!1),requestAnimationFrame(()=>{C.current?.focus(),C.current?.setSelectionRange(H,H)});return}const X=i.length===0||/\s$/.test(i)?"":" ",Y=`${i}${X}${U}`,J=Y.length;n(Y),f(!1),requestAnimationFrame(()=>{C.current?.focus(),C.current?.setSelectionRange(J,J)})},[i,a]),L=E.useCallback(F=>{const U=F.target.value;n(U),b(null);const X=F.target;X.style.height="auto",X.style.height=`${Math.max(72,Math.min(X.scrollHeight,240))}px`,f(!1),o(ln(U,e.members??[]).map(Y=>Y.id)),W(U,X.selectionStart)},[W,e.members]),O=E.useCallback(async()=>{if(s||h)return;const F=i.trim();if(F){u(!0),b(null);try{const X=ln(F,e.members??[]).map(Y=>({memberId:Y.id,label:Y.name}));await m({content:F,mentions:X,senderType:"user"}),n(""),o([]),f(!1),p(null),C.current&&(C.current.style.height="72px"),requestAnimationFrame(()=>k())}catch(U){b(U instanceof Error?U.message:"Failed to send room message")}finally{u(!1)}}},[i,h,m,s,k,e.members]),I=E.useCallback(F=>{const U=F.nativeEvent.isComposing||F.nativeEvent.keyCode===229;if(z){if(F.key==="ArrowDown"){F.preventDefault(),y(X=>(X+1)%B.length);return}if(F.key==="ArrowUp"){F.preventDefault(),y(X=>(X-1+B.length)%B.length);return}if(F.key==="Enter"&&!U||F.key==="Tab"){F.preventDefault();const X=B[S]??B[0];X&&A(X);return}if(F.key==="Escape"){F.preventDefault(),p(null),f(!1);return}}F.key==="Enter"&&!F.shiftKey&&!F.repeat&&!U&&(F.preventDefault(),O())},[A,O,S,B,z]);return E.useEffect(()=>{n(""),o([]),f(!1),p(null),b(null),C.current&&(C.current.style.height="72px")},[e.id]),r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(ci,{size:14,className:"text-neutral-500 shrink-0"}),r.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:x("Team room")}),r.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] text-neutral-500",children:M.length})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-neutral-500 shrink-0",children:[r.jsx("span",{className:"rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 font-medium text-neutral-600",children:e.mode}),e.reviewReason&&r.jsx("span",{className:"rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 font-medium text-neutral-600",children:e.reviewReason})]})]}),N.length>0&&r.jsxs("div",{className:"border-b border-neutral-200 bg-neutral-50/70 px-4 py-3 shrink-0",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx(ps,{size:13}),r.jsx("span",{children:x("Active invocations")})]}),r.jsx("div",{className:"space-y-2",children:N.map(({invocation:F,member:U})=>{const X=!!(F.sessionId&&v),Y=xu(F);return r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Ms,{name:U?.name??x("Agent"),avatar:U?.avatar??null}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:U?.name??x("Agent")}),r.jsxs("div",{className:"truncate text-[11px] text-neutral-500",children:[x(Y),F.sessionId?` · ${F.sessionId.slice(0,8)}…`:""]})]})]}),r.jsxs(ze,{type:"button",size:"xs",variant:"outline",disabled:!X,onClick:()=>F.sessionId&&v?.(F.sessionId),children:[r.jsx(di,{size:12}),r.jsx("span",{children:x("View details")})]})]},F.id)})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{ref:w,className:"h-full overflow-y-auto bg-white px-4 py-4",children:r.jsx("div",{ref:j,className:"space-y-4",children:M.length===0?r.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-neutral-50 text-neutral-500",children:[r.jsx(ps,{size:24,className:"text-neutral-400"}),r.jsx("span",{className:"text-sm",children:x("No room messages yet")})]}):M.map(F=>{const U=ju(F,R,D),X=F.senderType==="user"?x("你"):F.senderType==="system"?x("System"):U?.name??x("Agent"),Y=F.senderType==="user",J=F.senderType==="system",T=F.mentions??[],H=F.workRequestIds?.length??0,q=ku(F,R);return J?r.jsx("div",{className:"flex justify-center",children:r.jsx("div",{className:"max-w-[min(100%,34rem)] rounded-2xl border border-amber-200 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 shadow-sm",children:r.jsx(cn,{content:q})})},F.id):r.jsxs("div",{className:ne("flex items-start gap-2",Y?"justify-end pl-10":"justify-start pr-10"),children:[!Y&&r.jsx(Ms,{name:X,avatar:U?.avatar??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),r.jsxs("div",{className:ne("max-w-[min(74%,42rem)]",Y?"items-end":"items-start"),children:[r.jsxs("div",{className:ne("mb-1 flex items-center gap-2 px-1 text-[11px] text-neutral-500",Y?"justify-end":"justify-start"),children:[r.jsx("span",{className:"truncate font-medium text-neutral-700",children:X}),r.jsx(cs,{size:11}),r.jsx("span",{children:_u(F.createdAt)})]}),r.jsxs("div",{className:ne("rounded-2xl px-3.5 py-2.5 text-sm leading-relaxed shadow-sm",Y?"rounded-tr-sm bg-neutral-200 text-neutral-900 shadow-none":"rounded-tl-sm border border-neutral-100 bg-white text-neutral-900 shadow-[0_1px_3px_rgba(15,23,42,0.04)]"),children:[r.jsx(cn,{content:q,isUser:Y}),H>0&&T.length===0&&r.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:r.jsxs("span",{className:ne("rounded-full px-2 py-0.5 text-[11px] font-medium",Y?"bg-neutral-300/70 text-neutral-700":"bg-blue-50 text-blue-700"),children:[x("Work requests"),": ",H]})})]})]}),Y&&r.jsx(Ms,{name:X,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-200 bg-neutral-100 text-neutral-600 text-[11px]"})]},F.id)})})}),!g&&r.jsxs("button",{type:"button",onClick:()=>k(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[r.jsx(Ws,{size:14}),r.jsx("span",{children:x("Back to bottom")})]})]}),r.jsx("div",{className:"shrink-0 border-t border-transparent bg-white px-6 pb-6 pt-2",children:s?r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:l??x("This project is read-only")}):r.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[z&&r.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[r.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:x(a?"Mention members":"Team members")}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:B.map((F,U)=>{const X=_.includes(F.id),Y=U===S;return r.jsxs("button",{type:"button",onMouseEnter:()=>y(U),onMouseDown:J=>{J.preventDefault(),A(F)},className:ne("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",Y?"bg-neutral-100":"hover:bg-neutral-50"),children:[r.jsx(Ms,{name:F.name,avatar:F.avatar,className:"h-8 w-8 text-[11px]"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:F.name}),X&&r.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:x("selected")})]}),r.jsx("div",{className:"truncate text-xs text-neutral-500",children:F.aliases.length>0?F.aliases.join(" / "):F.providerId})]}),r.jsx(Hi,{size:15,className:"text-neutral-400"})]},F.id)})})]}),r.jsx("textarea",{ref:C,value:i,onChange:L,onKeyDown:I,onClick:F=>W(i,F.currentTarget.selectionStart),onSelect:F=>W(i,F.currentTarget.selectionStart),placeholder:x("Message the team room..."),className:"w-full resize-none border-none bg-transparent px-4 pb-2 pt-4 text-sm leading-relaxed text-neutral-900 placeholder-neutral-400 focus:outline-none",style:{minHeight:60,maxHeight:220}}),r.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>{f(F=>!F),p(null),requestAnimationFrame(()=>C.current?.focus())},disabled:P.length===0&&(e.members??[]).length===0,title:x("Mention members"),"aria-label":x("Mention members"),className:ne("rounded-lg p-2 transition-colors",c?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",P.length===0&&(e.members??[]).length===0?"cursor-not-allowed opacity-50":""),children:r.jsx(Hi,{size:18})}),P.length>0&&r.jsxs("span",{className:"text-[11px] text-neutral-500",children:[P.length," ",x("selected")]})]}),r.jsx("button",{type:"button",onClick:()=>{O()},disabled:s||h||!i.trim(),title:x(h?"Sending...":"Send"),"aria-label":x(h?"Sending...":"Send"),className:ne("rounded-lg p-2 transition-all duration-200",i.trim()&&!s&&!h?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",h?"opacity-70":""),children:r.jsx(ai,{size:18})})]}),d&&r.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:d})]})})]})}const Ru=[],Au=[],Tu=[];function Qt(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Nr(e,t){return e instanceof Error?e.message:t}function Du(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"pending approval":return"Pending approval";case"idle":return"Idle"}}function Mu(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Lu(e){const t=e.trim();if(!t)return"?";const s=t.split(/\s+/).filter(Boolean);return s.length>=2?`${s[0][0]??""}${s[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function Pu(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Ou(e){switch(e){case"queue":return"Queue if busy";case"cancel_current_and_start":return"Cancel current if busy"}}function Iu(e){switch(e){case"new_per_request":return"New session per request";case"resume_last":return"Resume last session"}}function Bu(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Fu(e){return[...e].sort((t,s)=>Date.parse(s.updatedAt??s.createdAt??"")-Date.parse(t.updatedAt??t.createdAt??""))}function dn(e){return e?`${e.slice(0,8)}...`:""}function Hu({name:e,avatar:t}){const s=E.useMemo(()=>Lu(e),[e]);return t?r.jsx("img",{src:t,alt:e,className:"h-7 w-7 rounded-full border border-neutral-200 object-cover bg-white shrink-0"}):r.jsx("div",{className:"h-7 w-7 rounded-full border border-neutral-200 bg-neutral-100 text-neutral-600 flex items-center justify-center text-[10px] font-semibold shrink-0",children:s})}function zu(e,t,s){const l=t.filter(v=>v.memberId===e.id);if(l.some(v=>v.status==="RUNNING"))return"running";if(l.some(v=>v.status==="WAITING_ROOM_REPLY"))return"waiting room reply";if(l.some(v=>v.status==="QUEUED"))return"queued";const m=s.find(v=>v.targetMemberId===e.id&&(v.status==="PENDING_APPROVAL"||v.status==="QUEUED"));return m?.status==="PENDING_APPROVAL"?"pending approval":m?.status==="QUEUED"?"queued":"idle"}function Wu({teamRun:e,onViewInvocationSession:t}){const{t:s}=ae(),l=sl(e.id),m=rl(e.id),v=Ii(e.id),x=Ii(e.id),i=il(e.id),[n,c]=E.useState(null),[f,a]=E.useState(null),p=e.members??Ru,S=e.workRequests??Au,y=e.invocations??Tu,_=E.useMemo(()=>new Map(S.map(g=>[g.id,g])),[S]),o=E.useMemo(()=>y.filter(g=>g.status==="RUNNING"||g.status==="WAITING_ROOM_REPLY"||g.status==="QUEUED").sort((g,k)=>Date.parse(k.updatedAt??k.createdAt??"")-Date.parse(g.updatedAt??g.createdAt??"")),[y]),h=E.useMemo(()=>[...y].filter(g=>g.status==="COMPLETED"||g.status==="FAILED"||g.status==="CANCELLED").sort((g,k)=>Date.parse(k.updatedAt??k.createdAt??"")-Date.parse(g.updatedAt??g.createdAt??"")).slice(0,6),[y]),u=E.useMemo(()=>[...S].filter(g=>g.status==="PENDING_APPROVAL").sort((g,k)=>Date.parse(k.updatedAt??k.createdAt??"")-Date.parse(g.updatedAt??g.createdAt??"")),[S]),d=E.useMemo(()=>[...S].filter(g=>g.status==="QUEUED").sort((g,k)=>Date.parse(k.updatedAt??k.createdAt??"")-Date.parse(g.updatedAt??g.createdAt??"")),[S]),b=l.isError?l.error:m.isError?m.error:v.isError?v.error:null,C=x.isError?x.error:null,w=l.isPending||m.isPending||v.isPending,j=x.isPending;return r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Wr,{size:14,className:"text-neutral-500 shrink-0"}),r.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:s("Team Status")})]}),r.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[r.jsx("span",{children:s("Team mode")}),r.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4 space-y-4",children:[e.reviewReason&&r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-600",children:[r.jsx("div",{className:"mb-1 font-medium text-neutral-700",children:s("Review reason")}),r.jsx("div",{children:e.reviewReason})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx(cs,{size:13}),r.jsx("span",{children:s("Pending approval")})]}),r.jsx("div",{className:"space-y-2",children:u.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:s("No pending approvals")}):u.map(g=>{const k=p.find(N=>N.id===g.targetMemberId),R=l.isPending&&l.variables===g.id,D=m.isPending&&m.variables===g.id,M=v.isPending&&v.variables===g.id;return r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:k?.name??g.targetMemberId}),r.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-neutral-500 line-clamp-3",children:g.instruction})]}),r.jsx("span",{className:"shrink-0 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:s("Pending approval")})]}),r.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] text-neutral-500",children:[r.jsxs("span",{children:[s("Requester"),": ",s(Pu(g.requesterType))]}),r.jsx("span",{children:Qt(g.createdAt)}),r.jsx("span",{children:s(Ou(g.ifBusy))}),r.jsxs("span",{children:[s("Cancel queued"),": ",s(g.cancelQueued?"Yes":"No")]})]}),r.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[r.jsxs("button",{type:"button",onClick:()=>l.mutate(g.id),disabled:w,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("Approve"),children:[r.jsx(Yt,{size:11}),r.jsx("span",{className:"truncate",children:s(R?"Approving":"Approve")})]}),r.jsxs("button",{type:"button",onClick:()=>m.mutate(g.id),disabled:w,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("Reject"),children:[r.jsx(Cs,{size:11}),r.jsx("span",{className:"truncate",children:s(D?"Rejecting":"Reject")})]}),r.jsxs("button",{type:"button",onClick:()=>v.mutate(g.id),disabled:w,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("Cancel"),children:[r.jsx(Sr,{size:11}),r.jsx("span",{className:"truncate",children:s(M?"Cancelling":"Cancel")})]})]})]},g.id)})}),b&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Nr(b,s("Failed to update work request"))})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx(ps,{size:13}),r.jsx("span",{children:s("Members")})]}),r.jsx("div",{className:"space-y-2",children:p.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:s("No members")}):p.map(g=>{const k=zu(g,y,S),R=Fu(y.filter(N=>N.memberId===g.id)),D=R[0],M=f===g.id;return r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white",children:[r.jsxs("button",{type:"button",onClick:()=>a(M?null:g.id),className:"flex w-full items-start justify-between gap-3 px-3 py-2 text-left transition-colors hover:bg-neutral-50",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(Hu,{name:g.name,avatar:g.avatar}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:g.name}),r.jsxs("div",{className:"truncate text-[11px] text-neutral-500",children:[g.providerId," · ",g.workspacePolicy," · ",s(Iu(g.sessionPolicy))]}),D&&r.jsxs("div",{className:"mt-0.5 truncate text-[11px] text-neutral-400",children:[s("Latest"),": ",D.status," · ",Qt(D.updatedAt??D.createdAt)]})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.jsx("span",{className:ne("rounded-full border px-2 py-0.5 text-[10px] font-medium capitalize",Mu(k)),children:s(Du(k))}),M?r.jsx(jt,{size:14,className:"text-neutral-400"}):r.jsx(Ht,{size:14,className:"text-neutral-400"})]})]}),M&&r.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:s("Invocation history")}),r.jsx("span",{className:"text-[10px] text-neutral-400",children:R.length})]}),R.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-xs text-neutral-500",children:s("No invocation history")}):r.jsx("div",{className:"space-y-1.5",children:R.map(N=>{const P=_.get(N.workRequestId),B=!!(N.sessionId&&t);return r.jsx("div",{className:"rounded-md border border-neutral-100 bg-neutral-50/70 px-2.5 py-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:ne("rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Bu(N.status)),children:N.status}),r.jsx("span",{className:"text-[10px] text-neutral-400",children:Qt(N.updatedAt??N.createdAt)})]}),r.jsx("div",{className:"mt-1 truncate text-[11px] text-neutral-500",children:P?.instruction??N.workRequestId}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[r.jsxs("span",{children:[s("Invocation"),": ",dn(N.id)]}),N.sessionId&&r.jsxs("span",{children:[s("Session"),": ",dn(N.sessionId)]})]})]}),r.jsxs("button",{type:"button",onClick:()=>N.sessionId&&t?.(N.sessionId),disabled:!B,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("View details"),children:[r.jsx(di,{size:11}),r.jsx("span",{children:s("View log")})]})]})},N.id)})})]})]},g.id)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx(ci,{size:13}),r.jsx("span",{children:s("Queue")})]}),r.jsx("div",{className:"space-y-2",children:d.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:s("No queued work requests")}):d.map(g=>{const k=p.find(D=>D.id===g.targetMemberId),R=x.isPending&&x.variables===g.id;return r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:k?.name??g.targetMemberId}),r.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500 line-clamp-2",children:g.instruction})]}),r.jsxs("button",{type:"button",onClick:()=>x.mutate(g.id),disabled:j,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("Cancel"),children:[r.jsx(Sr,{size:11}),r.jsx("span",{children:s(R?"Cancelling":"Cancel")})]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[r.jsx(cs,{size:11}),r.jsx("span",{children:Qt(g.createdAt)})]})]},g.id)})}),C&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Nr(C,s("Failed to cancel work request"))})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx(Al,{size:13}),r.jsx("span",{children:s("Active invocations")})]}),r.jsx("div",{className:"space-y-2",children:o.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:s("No active invocations")}):o.map(g=>{const k=p.find(N=>N.id===g.memberId),R=g.status==="RUNNING"&&!!k,D=n===g.id,M=i.isPending&&i.variables?.memberId===k?.id;return r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:k?.name??g.memberId}),r.jsxs("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:[g.status," · ",g.sessionId?g.sessionId.slice(0,8):g.id.slice(0,8)]})]}),R?r.jsxs("button",{type:"button",onClick:()=>c(D?null:g.id),disabled:i.isPending,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:s("Stop"),children:[r.jsx(zs,{size:10}),r.jsx("span",{children:s("Stop")})]}):r.jsx($r,{size:12,className:"text-neutral-400 shrink-0"})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[r.jsx(cs,{size:11}),r.jsx("span",{children:Qt(g.updatedAt??g.createdAt)})]}),R&&D&&r.jsxs("div",{className:"mt-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[r.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:s("Stop running work?")}),r.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[r.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:k.id,cancelQueued:!1},{onSuccess:()=>c(null)})},disabled:i.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-neutral-200 bg-white px-2 py-1 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(zs,{size:10}),r.jsx("span",{children:M&&i.variables?.cancelQueued===!1?s("Stopping"):s("Stop only")})]}),r.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:k.id,cancelQueued:!0},{onSuccess:()=>c(null)})},disabled:i.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 py-1 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(Sr,{size:10}),r.jsx("span",{children:M&&i.variables?.cancelQueued===!0?s("Stopping"):s("Stop + clear queue")})]})]})]})]},g.id)})}),i.isError&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Nr(i.error,s("Failed to stop member work"))})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[r.jsx($r,{size:13}),r.jsx("span",{children:s("Recently completed")})]}),r.jsx("div",{className:"space-y-2",children:h.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:s("No completed invocations")}):h.map(g=>{const k=p.find(R=>R.id===g.memberId);return r.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:k?.name??g.memberId}),r.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:g.status})]}),r.jsx("span",{className:"rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-600",children:g.status})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[r.jsx(cs,{size:11}),r.jsx("span",{children:Qt(g.updatedAt??g.createdAt)})]})]},g.id)})})]})]})]})}var Rr={exports:{}},un;function $u(){return un||(un=1,(function(e,t){(function(s,l){e.exports=l()})(self,(()=>(()=>{var s={4567:function(x,i,n){var c=this&&this.__decorate||function(d,b,C,w){var j,g=arguments.length,k=g<3?b:w===null?w=Object.getOwnPropertyDescriptor(b,C):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(d,b,C,w);else for(var R=d.length-1;R>=0;R--)(j=d[R])&&(k=(g<3?j(k):g>3?j(b,C,k):j(b,C))||k);return g>3&&k&&Object.defineProperty(b,C,k),k},f=this&&this.__param||function(d,b){return function(C,w){b(C,w,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const a=n(9042),p=n(6114),S=n(9924),y=n(844),_=n(5596),o=n(4725),h=n(3656);let u=i.AccessibilityManager=class extends y.Disposable{constructor(d,b){super(),this._terminal=d,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new S.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
12
+ `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new _.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(d){for(let b=0;b<d;b++)this._handleChar(" ")}_handleChar(d){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==d&&(this._charsToAnnounce+=d):this._charsToAnnounce+=d,d===`
13
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.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(d){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(d)||this._charsToConsume.push(d)}_refreshRows(d,b){this._liveRegionDebouncer.refresh(d,b,this._terminal.rows)}_renderRows(d,b){const C=this._terminal.buffer,w=C.lines.length.toString();for(let j=d;j<=b;j++){const g=C.translateBufferLineToString(C.ydisp+j,!0),k=(C.ydisp+j+1).toString(),R=this._rowElements[j];R&&(g.length===0?R.innerText=" ":R.textContent=g,R.setAttribute("aria-posinset",k),R.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(d,b){const C=d.target,w=this._rowElements[b===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||d.relatedTarget!==w)return;let j,g;if(b===0?(j=C,g=this._rowElements.pop(),this._rowContainer.removeChild(g)):(j=this._rowElements.shift(),g=C,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),g.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const k=this._createAccessibilityTreeNode();this._rowElements.unshift(k),this._rowContainer.insertAdjacentElement("afterbegin",k)}else{const k=this._createAccessibilityTreeNode();this._rowElements.push(k),this._rowContainer.appendChild(k)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),d.preventDefault(),d.stopImmediatePropagation()}_handleResize(d){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>d;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const d=document.createElement("div");return d.setAttribute("role","listitem"),d.tabIndex=-1,this._refreshRowDimensions(d),d}_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 d=0;d<this._terminal.rows;d++)this._refreshRowDimensions(this._rowElements[d])}}_refreshRowDimensions(d){d.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=u=c([f(1,o.IRenderService)],u)},3614:(x,i)=>{function n(p){return p.replace(/\r?\n/g,"\r")}function c(p,S){return S?"\x1B[200~"+p+"\x1B[201~":p}function f(p,S,y,_){p=c(p=n(p),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),S.value=""}function a(p,S,y){const _=y.getBoundingClientRect(),o=p.clientX-_.left-10,h=p.clientY-_.top-10;S.style.width="20px",S.style.height="20px",S.style.left=`${o}px`,S.style.top=`${h}px`,S.style.zIndex="1000",S.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=c,i.copyHandler=function(p,S){p.clipboardData&&p.clipboardData.setData("text/plain",S.selectionText),p.preventDefault()},i.handlePasteEvent=function(p,S,y,_){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),S,y,_)},i.paste=f,i.moveTextAreaUnderMouseCursor=a,i.rightClickHandler=function(p,S,y,_,o){a(p,S,y),o&&_.rightClickSelect(p),S.value=_.selectionText,S.select()}},7239:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=n(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,a,p){this._css.set(f,a,p)}getCss(f,a){return this._css.get(f,a)}setColor(f,a,p){this._color.set(f,a,p)}getColor(f,a){return this._color.get(f,a)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,c,f,a){n.addEventListener(c,f,a);let p=!1;return{dispose:()=>{p||(p=!0,n.removeEventListener(c,f,a))}}}},6465:function(x,i,n){var c=this&&this.__decorate||function(o,h,u,d){var b,C=arguments.length,w=C<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(o,h,u,d);else for(var j=o.length-1;j>=0;j--)(b=o[j])&&(w=(C<3?b(w):C>3?b(h,u,w):b(h,u))||w);return C>3&&w&&Object.defineProperty(h,u,w),w},f=this&&this.__param||function(o,h){return function(u,d){h(u,d,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const a=n(3656),p=n(8460),S=n(844),y=n(2585);let _=i.Linkifier2=class extends S.Disposable{get currentLink(){return this._currentLink}constructor(o){super(),this._bufferService=o,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,S.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,S.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(o){return this._linkProviders.push(o),{dispose:()=>{const h=this._linkProviders.indexOf(o);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(o,h,u){this._element=o,this._mouseService=h,this._renderService=u,this.register((0,a.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(o){if(this._lastMouseEvent=o,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(o,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const u=o.composedPath();for(let d=0;d<u.length;d++){const b=u[d];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(o){if(this._activeLine!==o.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(o,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,o)||(this._clearCurrentLink(),this._askForLink(o,!0))}_askForLink(o,h){var u,d;this._activeProviderReplies&&h||((u=this._activeProviderReplies)===null||u===void 0||u.forEach((C=>{C?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=o.y);let b=!1;for(const[C,w]of this._linkProviders.entries())h?!((d=this._activeProviderReplies)===null||d===void 0)&&d.get(C)&&(b=this._checkLinkProviderResult(C,o,b)):w.provideLinks(o.y,(j=>{var g,k;if(this._isMouseOut)return;const R=j?.map((D=>({link:D})));(g=this._activeProviderReplies)===null||g===void 0||g.set(C,R),b=this._checkLinkProviderResult(C,o,b),((k=this._activeProviderReplies)===null||k===void 0?void 0:k.size)===this._linkProviders.length&&this._removeIntersectingLinks(o.y,this._activeProviderReplies)}))}_removeIntersectingLinks(o,h){const u=new Set;for(let d=0;d<h.size;d++){const b=h.get(d);if(b)for(let C=0;C<b.length;C++){const w=b[C],j=w.link.range.start.y<o?0:w.link.range.start.x,g=w.link.range.end.y>o?this._bufferService.cols:w.link.range.end.x;for(let k=j;k<=g;k++){if(u.has(k)){b.splice(C--,1);break}u.add(k)}}}}_checkLinkProviderResult(o,h,u){var d;if(!this._activeProviderReplies)return u;const b=this._activeProviderReplies.get(o);let C=!1;for(let w=0;w<o;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(C=!0);if(!C&&b){const w=b.find((j=>this._linkAtPosition(j.link,h)));w&&(u=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviders.length&&!u)for(let w=0;w<this._activeProviderReplies.size;w++){const j=(d=this._activeProviderReplies.get(w))===null||d===void 0?void 0:d.find((g=>this._linkAtPosition(g.link,h)));if(j){u=!0,this._handleNewLink(j);break}}return u}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(o){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(o,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(o,this._currentLink.link.text)}_clearCurrentLink(o,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!o||!h||this._currentLink.link.range.start.y>=o&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,S.disposeArray)(this._linkCacheDisposables))}_handleNewLink(o){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(o.link,h)&&(this._currentLink=o,this._currentLink.state={decorations:{underline:o.link.decorations===void 0||o.link.decorations.underline,pointerCursor:o.link.decorations===void 0||o.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,o.link,this._lastMouseEvent),o.link.decorations={},Object.defineProperties(o.link.decorations,{pointerCursor:{get:()=>{var u,d;return(d=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||d===void 0?void 0:d.decorations.pointerCursor},set:u=>{var d,b;!((d=this._currentLink)===null||d===void 0)&&d.state&&this._currentLink.state.decorations.pointerCursor!==u&&(this._currentLink.state.decorations.pointerCursor=u,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",u)))}},underline:{get:()=>{var u,d;return(d=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||d===void 0?void 0:d.decorations.underline},set:u=>{var d,b,C;!((d=this._currentLink)===null||d===void 0)&&d.state&&((C=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||C===void 0?void 0:C.decorations.underline)!==u&&(this._currentLink.state.decorations.underline=u,this._currentLink.state.isHovered&&this._fireUnderlineEvent(o.link,u))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((u=>{if(!this._currentLink)return;const d=u.start===0?0:u.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+u.end;if(this._currentLink.link.range.start.y>=d&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(d,b),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(o,h,u){var d;!((d=this._currentLink)===null||d===void 0)&&d.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&o.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(u,h.text)}_fireUnderlineEvent(o,h){const u=o.range,d=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(u.start.x-1,u.start.y-d-1,u.end.x,u.end.y-d-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(o,h,u){var d;!((d=this._currentLink)===null||d===void 0)&&d.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&o.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(u,h.text)}_linkAtPosition(o,h){const u=o.range.start.y*this._bufferService.cols+o.range.start.x,d=o.range.end.y*this._bufferService.cols+o.range.end.x,b=h.y*this._bufferService.cols+h.x;return u<=b&&b<=d}_positionFromMouseEvent(o,h,u){const d=u.getCoords(o,h,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(o,h,u,d,b){return{x1:o,y1:h,x2:u,y2:d,cols:this._bufferService.cols,fg:b}}};i.Linkifier2=_=c([f(0,y.IBufferService)],_)},9042:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(x,i,n){var c=this&&this.__decorate||function(_,o,h,u){var d,b=arguments.length,C=b<3?o:u===null?u=Object.getOwnPropertyDescriptor(o,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(_,o,h,u);else for(var w=_.length-1;w>=0;w--)(d=_[w])&&(C=(b<3?d(C):b>3?d(o,h,C):d(o,h))||C);return b>3&&C&&Object.defineProperty(o,h,C),C},f=this&&this.__param||function(_,o){return function(h,u){o(h,u,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const a=n(511),p=n(2585);let S=i.OscLinkProvider=class{constructor(_,o,h){this._bufferService=_,this._optionsService=o,this._oscLinkService=h}provideLinks(_,o){var h;const u=this._bufferService.buffer.lines.get(_-1);if(!u)return void o(void 0);const d=[],b=this._optionsService.rawOptions.linkHandler,C=new a.CellData,w=u.getTrimmedLength();let j=-1,g=-1,k=!1;for(let R=0;R<w;R++)if(g!==-1||u.hasContent(R)){if(u.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(g===-1){g=R,j=C.extended.urlId;continue}k=C.extended.urlId!==j}else g!==-1&&(k=!0);if(k||g!==-1&&R===w-1){const D=(h=this._oscLinkService.getLinkData(j))===null||h===void 0?void 0:h.uri;if(D){const M={start:{x:g+1,y:_},end:{x:R+(k||R!==w-1?0:1),y:_}};let N=!1;if(!b?.allowNonHttpProtocols)try{const P=new URL(D);["http:","https:"].includes(P.protocol)||(N=!0)}catch{N=!0}N||d.push({text:D,range:M,activate:(P,B)=>b?b.activate(P,B,M):y(0,B),hover:(P,B)=>{var z;return(z=b?.hover)===null||z===void 0?void 0:z.call(b,P,B,M)},leave:(P,B)=>{var z;return(z=b?.leave)===null||z===void 0?void 0:z.call(b,P,B,M)}})}k=!1,C.hasExtendedAttrs()&&C.extended.urlId?(g=R,j=C.extended.urlId):(g=-1,j=-1)}}o(d)}};function y(_,o){if(confirm(`Do you want to navigate to ${o}?
14
+
15
+ WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=o}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=S=c([f(0,p.IBufferService),f(1,p.IOptionsService),f(2,p.IOscLinkService)],S)},6193:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,c){this._parentWindow=n,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=n(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:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=n(3614),f=n(3656),a=n(6465),p=n(9042),S=n(3730),y=n(1680),_=n(3107),o=n(5744),h=n(2950),u=n(1296),d=n(428),b=n(4269),C=n(5114),w=n(8934),j=n(3230),g=n(9312),k=n(4725),R=n(6731),D=n(8055),M=n(8969),N=n(8460),P=n(844),B=n(6114),z=n(8437),W=n(2584),A=n(7399),L=n(5941),O=n(9074),I=n(2585),F=n(5435),U=n(4567),X=typeof window<"u"?window.document:null;class Y extends M.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(T={}){super(T),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new P.MutableDisposable),this._onCursorMove=this.register(new N.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new N.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new N.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new N.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new N.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new N.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new N.EventEmitter),this._onBlur=this.register(new N.EventEmitter),this._onA11yCharEmitter=this.register(new N.EventEmitter),this._onA11yTabEmitter=this.register(new N.EventEmitter),this._onWillOpen=this.register(new N.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(a.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(S.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,q)=>this.refresh(H,q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,N.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,N.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,P.toDisposable)((()=>{var H,q;this._customKeyEventHandler=void 0,(q=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||q===void 0||q.removeChild(this.element)})))}_handleColorEvent(T){if(this._themeService)for(const H of T){let q,$="";switch(H.index){case 256:q="foreground",$="10";break;case 257:q="background",$="11";break;case 258:q="cursor",$="12";break;default:q="ansi",$="4;"+H.index}switch(H.type){case 0:const ee=D.color.toColorRGB(q==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[q]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${$};${(0,L.toRgbString)(ee)}${W.C1_ESCAPED.ST}`);break;case 1:if(q==="ansi")this._themeService.modifyColors((Q=>Q.ansi[H.index]=D.rgba.toColor(...H.color)));else{const Q=q;this._themeService.modifyColors((le=>le[Q]=D.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(T){T?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(T){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[I"),this.updateCursorStyle(T),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var T;return(T=this.textarea)===null||T===void 0?void 0:T.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.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 T=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(T);if(!H)return;const q=Math.min(this.buffer.x,this.cols-1),$=this._renderService.dimensions.css.cell.height,ee=H.getWidth(q),Q=this._renderService.dimensions.css.cell.width*ee,le=this.buffer.y*this._renderService.dimensions.css.cell.height,he=q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=le+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=$+"px",this.textarea.style.lineHeight=$+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const T=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",T)),this.register((0,f.addDisposableDomListener)(this.element,"paste",T)),B.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(T=>this._keyUp(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(T=>this._keyDown(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(T=>this._keyPress(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(T=>this._compositionHelper.compositionupdate(T)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(T=>this._inputEvent(T)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(T){var H;if(!T)throw new Error("Terminal requires a parent element.");T.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=T.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),T.appendChild(this.element);const q=X.createDocumentFragment();this._viewportElement=X.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),q.appendChild(this._viewportElement),this._viewportScrollArea=X.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=X.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=X.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),q.appendChild(this.screenElement),this.textarea=X.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(C.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(k.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",($=>this._handleTextAreaFocus($)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(d.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(k.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(k.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(k.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(k.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(($=>this._onRender.fire($)))),this.onResize(($=>this._renderService.resize($.cols,$.rows))),this._compositionView=X.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(q);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(w.MouseService),this._instantiationService.setService(k.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(($=>this.scrollLines($.amount,$.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(g.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(k.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(($=>this.scrollLines($.amount,$.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw(($=>this._renderService.handleSelectionChanged($.start,$.end,$.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection(($=>{this.textarea.value=$,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event(($=>{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(_.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",($=>this._selectionService.handleMouseDown($)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",($=>this._handleScreenReaderModeOptionChange($)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",($=>{!this._overviewRulerRenderer&&$&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const T=this,H=this.element;function q(Q){const le=T._mouseService.getMouseReportCoords(Q,T.screenElement);if(!le)return!1;let he,Se;switch(Q.overrideType||Q.type){case"mousemove":Se=32,Q.buttons===void 0?(he=3,Q.button!==void 0&&(he=Q.button<3?Q.button:3)):he=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":Se=0,he=Q.button<3?Q.button:3;break;case"mousedown":Se=1,he=Q.button<3?Q.button:3;break;case"wheel":if(T.viewport.getLinesScrolled(Q)===0)return!1;Se=Q.deltaY<0?0:1,he=4;break;default:return!1}return!(Se===void 0||he===void 0||he>4)&&T.coreMouseService.triggerMouseEvent({col:le.col,row:le.row,x:le.x,y:le.y,button:he,action:Se,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const $={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ee={mouseup:Q=>(q(Q),Q.buttons||(this._document.removeEventListener("mouseup",$.mouseup),$.mousedrag&&this._document.removeEventListener("mousemove",$.mousedrag)),this.cancel(Q)),wheel:Q=>(q(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&q(Q)},mousemove:Q=>{Q.buttons||q(Q)}};this.register(this.coreMouseService.onProtocolChange((Q=>{Q?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Q)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&Q?$.mousemove||(H.addEventListener("mousemove",ee.mousemove),$.mousemove=ee.mousemove):(H.removeEventListener("mousemove",$.mousemove),$.mousemove=null),16&Q?$.wheel||(H.addEventListener("wheel",ee.wheel,{passive:!1}),$.wheel=ee.wheel):(H.removeEventListener("wheel",$.wheel),$.wheel=null),2&Q?$.mouseup||(H.addEventListener("mouseup",ee.mouseup),$.mouseup=ee.mouseup):(this._document.removeEventListener("mouseup",$.mouseup),H.removeEventListener("mouseup",$.mouseup),$.mouseup=null),4&Q?$.mousedrag||($.mousedrag=ee.mousedrag):(this._document.removeEventListener("mousemove",$.mousedrag),$.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(H,"mousedown",(Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return q(Q),$.mouseup&&this._document.addEventListener("mouseup",$.mouseup),$.mousedrag&&this._document.addEventListener("mousemove",$.mousedrag),this.cancel(Q)}))),this.register((0,f.addDisposableDomListener)(H,"wheel",(Q=>{if(!$.wheel){if(!this.buffer.hasScrollback){const le=this.viewport.getLinesScrolled(Q);if(le===0)return;const he=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let Se="";for(let Be=0;Be<Math.abs(le);Be++)Se+=he;return this.coreService.triggerDataEvent(Se,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(H,"touchstart",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(H,"touchmove",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)}),{passive:!1}))}refresh(T,H){var q;(q=this._renderService)===null||q===void 0||q.refreshRows(T,H)}updateCursorStyle(T){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(T)?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(T,H,q=0){var $;q===1?(super.scrollLines(T,H,q),this.refresh(0,this.rows-1)):($=this.viewport)===null||$===void 0||$.scrollLines(T)}paste(T){(0,c.paste)(T,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(T){this._customKeyEventHandler=T}registerLinkProvider(T){return this.linkifier2.registerLinkProvider(T)}registerCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(T);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(T)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(T){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+T)}registerDecoration(T){return this._decorationService.registerDecoration(T)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(T,H,q){this._selectionService.setSelection(T,H,q)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var T;(T=this._selectionService)===null||T===void 0||T.clearSelection()}selectAll(){var T;(T=this._selectionService)===null||T===void 0||T.selectAll()}selectLines(T,H){var q;(q=this._selectionService)===null||q===void 0||q.selectLines(T,H)}_keyDown(T){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&T.altKey;if(!H&&!this._compositionHelper.keydown(T))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||T.key!=="Dead"&&T.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const q=(0,A.evaluateKeyboardEvent)(T,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(T),q.type===3||q.type===2){const $=this.rows-1;return this.scrollLines(q.type===2?-$:$),this.cancel(T,!0)}return q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,T)||(q.cancel&&this.cancel(T,!0),!q.key||!!(T.key&&!T.ctrlKey&&!T.altKey&&!T.metaKey&&T.key.length===1&&T.key.charCodeAt(0)>=65&&T.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(q.key!==W.C0.ETX&&q.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:q.key,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(q.key,!0),!this.optionsService.rawOptions.screenReaderMode||T.altKey||T.ctrlKey?this.cancel(T,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(T,H){const q=T.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||T.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||T.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?q:q&&(!H.keyCode||H.keyCode>47)}_keyUp(T){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(T)||this.focus(),this.updateCursorStyle(T),this._keyPressHandled=!1)}_keyPress(T){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;if(this.cancel(T),T.charCode)H=T.charCode;else if(T.which===null||T.which===void 0)H=T.keyCode;else{if(T.which===0||T.charCode===0)return!1;H=T.which}return!(!H||(T.altKey||T.ctrlKey||T.metaKey)&&!this._isThirdLevelShift(this.browser,T)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(T){if(T.data&&T.inputType==="insertText"&&(!T.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=T.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(T),!0}return!1}resize(T,H){T!==this.cols||H!==this.rows?super.resize(T,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(T,H){var q,$;(q=this._charSizeService)===null||q===void 0||q.measure(),($=this.viewport)===null||$===void 0||$.syncScrollArea(!0)}clear(){var T;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(z.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(T=this.viewport)===null||T===void 0||T.reset(),this.refresh(0,this.rows-1)}}reset(){var T,H;this.options.rows=this.rows,this.options.cols=this.cols;const q=this._customKeyEventHandler;this._setup(),super.reset(),(T=this._selectionService)===null||T===void 0||T.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=q,this.refresh(0,this.rows-1)}clearTextureAtlas(){var T;(T=this._renderService)===null||T===void 0||T.clearTextureAtlas()}_reportFocus(){var T;!((T=this.element)===null||T===void 0)&&T.classList.contains("focus")?this.coreService.triggerDataEvent(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(T){if(this._renderService)switch(T){case F.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${q};${H}t`);break;case F.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const $=this._renderService.dimensions.css.cell.width.toFixed(0),ee=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ee};${$}t`)}}cancel(T,H){if(this.options.cancelEvents||H)return T.preventDefault(),T.stopPropagation(),!1}}i.Terminal=Y},9924:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,c=1e3){this._renderCallback=n,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const a=Date.now();if(a-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=a,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=a-this._lastRefreshMs,S=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),S)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c)}}},1680:function(x,i,n){var c=this&&this.__decorate||function(h,u,d,b){var C,w=arguments.length,j=w<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,d):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,u,d,b);else for(var g=h.length-1;g>=0;g--)(C=h[g])&&(j=(w<3?C(j):w>3?C(u,d,j):C(u,d))||j);return w>3&&j&&Object.defineProperty(u,d,j),j},f=this&&this.__param||function(h,u){return function(d,b){u(d,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const a=n(3656),p=n(4725),S=n(8460),y=n(844),_=n(2585);let o=i.Viewport=class extends y.Disposable{constructor(h,u,d,b,C,w,j,g){super(),this._viewportElement=h,this._scrollArea=u,this._bufferService=d,this._optionsService=b,this._charSizeService=C,this._renderService=w,this._coreBrowserService=j,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new S.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((k=>this._activeBuffer=k.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((k=>this._renderDimensions=k))),this._handleThemeChange(g.colors),this.register(g.onChangeColors((k=>this._handleThemeChange(k)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.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(h){if(h)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 u=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==u&&(this._lastRecordedBufferHeight=u,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){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 u=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<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(h,u){const d=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(u<0&&this._viewportElement.scrollTop!==0||u>0&&d<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const u=this._getPixelsScrolled(h);return u!==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+u:this._smoothScrollState.target+=u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const u=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?u*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._currentRowHeight*this._bufferService.rows),u}getBufferElements(h,u){var d;let b,C="";const w=[],j=u??this._bufferService.buffer.lines.length,g=this._bufferService.buffer.lines;for(let k=h;k<j;k++){const R=g.get(k);if(!R)continue;const D=(d=g.get(k+1))===null||d===void 0?void 0:d.isWrapped;if(C+=R.translateToString(!D),!D||k===g.length-1){const M=document.createElement("div");M.textContent=C,w.push(M),C.length>0&&(b=M),C=""}}return{bufferElements:w,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(u/=this._currentRowHeight+0,this._wheelPartialScroll+=u,u=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._bufferService.rows),u}_applyScrollModifier(h,u){const d=this._optionsService.rawOptions.fastScrollModifier;return d==="alt"&&u.altKey||d==="ctrl"&&u.ctrlKey||d==="shift"&&u.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const u=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,u!==0&&(this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}};i.Viewport=o=c([f(2,_.IBufferService),f(3,_.IOptionsService),f(4,p.ICharSizeService),f(5,p.IRenderService),f(6,p.ICoreBrowserService),f(7,p.IThemeService)],o)},3107:function(x,i,n){var c=this&&this.__decorate||function(o,h,u,d){var b,C=arguments.length,w=C<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(o,h,u,d);else for(var j=o.length-1;j>=0;j--)(b=o[j])&&(w=(C<3?b(w):C>3?b(h,u,w):b(h,u))||w);return C>3&&w&&Object.defineProperty(h,u,w),w},f=this&&this.__param||function(o,h){return function(u,d){h(u,d,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const a=n(3656),p=n(4725),S=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends S.Disposable{constructor(o,h,u,d){super(),this._screenElement=o,this._bufferService=h,this._decorationService=u,this._renderService=d,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,a.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((b=>this._removeDecoration(b)))),this.register((0,S.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const o of this._decorationService.decorations)this._renderDecoration(o);this._dimensionsChanged=!1}_renderDecoration(o){this._refreshStyle(o),this._dimensionsChanged&&this._refreshXPosition(o)}_createElement(o){var h,u;const d=document.createElement("div");d.classList.add("xterm-decoration"),d.classList.toggle("xterm-decoration-top-layer",((h=o?.options)===null||h===void 0?void 0:h.layer)==="top"),d.style.width=`${Math.round((o.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,d.style.height=(o.options.height||1)*this._renderService.dimensions.css.cell.height+"px",d.style.top=(o.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",d.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(u=o.options.x)!==null&&u!==void 0?u:0;return b&&b>this._bufferService.cols&&(d.style.display="none"),this._refreshXPosition(o,d),d}_refreshStyle(o){const h=o.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)o.element&&(o.element.style.display="none",o.onRenderEmitter.fire(o.element));else{let u=this._decorationElements.get(o);u||(u=this._createElement(o),o.element=u,this._decorationElements.set(o,u),this._container.appendChild(u),o.onDispose((()=>{this._decorationElements.delete(o),u.remove()}))),u.style.top=h*this._renderService.dimensions.css.cell.height+"px",u.style.display=this._altBufferIsActive?"none":"block",o.onRenderEmitter.fire(u)}}_refreshXPosition(o,h=o.element){var u;if(!h)return;const d=(u=o.options.x)!==null&&u!==void 0?u:0;(o.options.anchor||"left")==="right"?h.style.right=d?d*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=d?d*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(o){var h;(h=this._decorationElements.get(o))===null||h===void 0||h.remove(),this._decorationElements.delete(o),o.dispose()}};i.BufferDecorationRenderer=_=c([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,p.IRenderService)],_)},5871:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(n){if(n.options.overviewRulerOptions){for(const c of this._zones)if(c.color===n.options.overviewRulerOptions.color&&c.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,n.marker.line))return;if(this._lineAdjacentToZone(c,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(c,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,c){return c>=n.startBufferLine&&c<=n.endBufferLine}_lineAdjacentToZone(n,c,f){return c>=n.startBufferLine-this._linePadding[f||"full"]&&c<=n.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(n,c){n.startBufferLine=Math.min(n.startBufferLine,c),n.endBufferLine=Math.max(n.endBufferLine,c)}}},5744:function(x,i,n){var c=this&&this.__decorate||function(b,C,w,j){var g,k=arguments.length,R=k<3?C:j===null?j=Object.getOwnPropertyDescriptor(C,w):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,C,w,j);else for(var D=b.length-1;D>=0;D--)(g=b[D])&&(R=(k<3?g(R):k>3?g(C,w,R):g(C,w))||R);return k>3&&R&&Object.defineProperty(C,w,R),R},f=this&&this.__param||function(b,C){return function(w,j){C(w,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const a=n(5871),p=n(3656),S=n(4725),y=n(844),_=n(2585),o={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let d=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,C,w,j,g,k,R){var D;super(),this._viewportElement=b,this._screenElement=C,this._bufferService=w,this._decorationService=j,this._renderService=g,this._optionsService=k,this._coreBrowseService=R,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(D=this._viewportElement.parentElement)===null||D===void 0||D.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var N;(N=this._canvas)===null||N===void 0||N.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 b=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=C,h.right=b,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=h.left,u.right=h.left+h.center}_refreshDrawHeightConstants(){o.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);o.left=C,o.center=C,o.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const C of b)C.position!=="full"&&this._renderColorZone(C);for(const C of b)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(u[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-o[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+o[b.position||"full"]))}_queueRefresh(b,C){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=d=c([f(2,_.IBufferService),f(3,_.IDecorationService),f(4,S.IRenderService),f(5,_.IOptionsService),f(6,S.ICoreBrowserService)],d)},2950:function(x,i,n){var c=this&&this.__decorate||function(_,o,h,u){var d,b=arguments.length,C=b<3?o:u===null?u=Object.getOwnPropertyDescriptor(o,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(_,o,h,u);else for(var w=_.length-1;w>=0;w--)(d=_[w])&&(C=(b<3?d(C):b>3?d(o,h,C):d(o,h))||C);return b>3&&C&&Object.defineProperty(o,h,C),C},f=this&&this.__param||function(_,o){return function(h,u){o(h,u,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const a=n(4725),p=n(2585),S=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,o,h,u,d,b){this._textarea=_,this._compositionView=o,this._bufferService=h,this._optionsService=u,this._coreService=d,this._renderService=b,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){const o={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,o.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(o.start,o.end):this._textarea.value.substring(o.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const o=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(o,!0)}}_handleAnyTextareaChanges(){const _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const o=this._textarea.value,h=o.replace(_,"");this._dataAlreadySent=h,o.length>_.length?this._coreService.triggerDataEvent(h,!0):o.length<_.length?this._coreService.triggerDataEvent(`${S.C0.DEL}`,!0):o.length===_.length&&o!==_&&this._coreService.triggerDataEvent(o,!0)}}),0)}updateCompositionElements(_){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const o=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,u=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,d=o*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=d+"px",this._compositionView.style.top=u+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=d+"px",this._textarea.style.top=u+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=c([f(2,p.IBufferService),f(3,p.IOptionsService),f(4,p.ICoreService),f(5,a.IRenderService)],y)},9806:(x,i)=>{function n(c,f,a){const p=a.getBoundingClientRect(),S=c.getComputedStyle(a),y=parseInt(S.getPropertyValue("padding-left")),_=parseInt(S.getPropertyValue("padding-top"));return[f.clientX-p.left-y,f.clientY-p.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(c,f,a,p,S,y,_,o,h){if(!y)return;const u=n(c,f,a);return u?(u[0]=Math.ceil((u[0]+(h?_/2:0))/_),u[1]=Math.ceil(u[1]/o),u[0]=Math.min(Math.max(u[0],1),p+(h?1:0)),u[1]=Math.min(Math.max(u[1],1),S),u):void 0}},9504:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=n(2584);function f(o,h,u,d){const b=o-a(o,u),C=h-a(h,u),w=Math.abs(b-C)-(function(j,g,k){let R=0;const D=j-a(j,k),M=g-a(g,k);for(let N=0;N<Math.abs(D-M);N++){const P=p(j,g)==="A"?-1:1,B=k.buffer.lines.get(D+P*N);B?.isWrapped&&R++}return R})(o,h,u);return _(w,y(p(o,h),d))}function a(o,h){let u=0,d=h.buffer.lines.get(o),b=d?.isWrapped;for(;b&&o>=0&&o<h.rows;)u++,d=h.buffer.lines.get(--o),b=d?.isWrapped;return u}function p(o,h){return o>h?"A":"B"}function S(o,h,u,d,b,C){let w=o,j=h,g="";for(;w!==u||j!==d;)w+=b?1:-1,b&&w>C.cols-1?(g+=C.buffer.translateBufferLineToString(j,!1,o,w),w=0,o=0,j++):!b&&w<0&&(g+=C.buffer.translateBufferLineToString(j,!1,0,o+1),w=C.cols-1,o=w,j--);return g+C.buffer.translateBufferLineToString(j,!1,o,w)}function y(o,h){const u=h?"O":"[";return c.C0.ESC+u+o}function _(o,h){o=Math.floor(o);let u="";for(let d=0;d<o;d++)u+=h;return u}i.moveToCellSequence=function(o,h,u,d){const b=u.buffer.x,C=u.buffer.y;if(!u.buffer.hasScrollback)return(function(g,k,R,D,M,N){return f(k,D,M,N).length===0?"":_(S(g,k,g,k-a(k,M),!1,M).length,y("D",N))})(b,C,0,h,u,d)+f(C,h,u,d)+(function(g,k,R,D,M,N){let P;P=f(k,D,M,N).length>0?D-a(D,M):k;const B=D,z=(function(W,A,L,O,I,F){let U;return U=f(L,O,I,F).length>0?O-a(O,I):A,W<L&&U<=O||W>=L&&U<O?"C":"D"})(g,k,R,D,M,N);return _(S(g,P,R,B,z==="C",M).length,y(z,N))})(b,C,o,h,u,d);let w;if(C===h)return w=b>o?"D":"C",_(Math.abs(b-o),y(w,d));w=C>h?"D":"C";const j=Math.abs(C-h);return _((function(g,k){return k.cols-g})(C>h?o:b,u)+(j-1)*u.cols+1+((C>h?b:o)-1),y(w,d))}},1296:function(x,i,n){var c=this&&this.__decorate||function(M,N,P,B){var z,W=arguments.length,A=W<3?N:B===null?B=Object.getOwnPropertyDescriptor(N,P):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,N,P,B);else for(var L=M.length-1;L>=0;L--)(z=M[L])&&(A=(W<3?z(A):W>3?z(N,P,A):z(N,P))||A);return W>3&&A&&Object.defineProperty(N,P,A),A},f=this&&this.__param||function(M,N){return function(P,B){N(P,B,M)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const a=n(3787),p=n(2550),S=n(2223),y=n(6171),_=n(4725),o=n(8055),h=n(8460),u=n(844),d=n(2585),b="xterm-dom-renderer-owner-",C="xterm-rows",w="xterm-fg-",j="xterm-bg-",g="xterm-focus",k="xterm-selection";let R=1,D=i.DomRenderer=class extends u.Disposable{constructor(M,N,P,B,z,W,A,L,O,I){super(),this._element=M,this._screenElement=N,this._viewportElement=P,this._linkifier2=B,this._charSizeService=W,this._optionsService=A,this._bufferService=L,this._coreBrowserService=O,this._themeService=I,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(k),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((F=>this._injectCss(F)))),this._injectCss(this._themeService.colors),this._rowFactory=z.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((F=>this._handleLinkHover(F)))),this.register(this._linkifier2.onHideLinkUnderline((F=>this._handleLinkLeave(F)))),this.register((0,u.toDisposable)((()=>{this._element.classList.remove(b+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 M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const P of this._rowElements)P.style.width=`${this.dimensions.css.canvas.width}px`,P.style.height=`${this.dimensions.css.cell.height}px`,P.style.lineHeight=`${this.dimensions.css.cell.height}px`,P.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const N=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=N,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let N=`${this._terminalSelector} .${C} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;N+=`${this._terminalSelector} .${C} .xterm-dim { color: ${o.color.multiplyOpacity(M.foreground,.5).css};}`,N+=`${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;}`,N+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",N+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,N+=`${this._terminalSelector} .${C}.${g} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${g} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,N+=`${this._terminalSelector} .${k} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${k} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${k} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[P,B]of M.ansi.entries())N+=`${this._terminalSelector} .${w}${P} { color: ${B.css}; }${this._terminalSelector} .${w}${P}.xterm-dim { color: ${o.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${j}${P} { background-color: ${B.css}; }`;N+=`${this._terminalSelector} .${w}${S.INVERTED_DEFAULT_COLOR} { color: ${o.color.opaque(M.background).css}; }${this._terminalSelector} .${w}${S.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${o.color.multiplyOpacity(o.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${j}${S.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=N}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,N){for(let P=this._rowElements.length;P<=N;P++){const B=document.createElement("div");this._rowContainer.appendChild(B),this._rowElements.push(B)}for(;this._rowElements.length>N;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,N){this._refreshRowElements(M,N),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(g)}handleFocus(){this._rowContainer.classList.add(g),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,N,P){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,N,P),this.renderRows(0,this._bufferService.rows-1),!M||!N)return;const B=M[1]-this._bufferService.buffer.ydisp,z=N[1]-this._bufferService.buffer.ydisp,W=Math.max(B,0),A=Math.min(z,this._bufferService.rows-1);if(W>=this._bufferService.rows||A<0)return;const L=document.createDocumentFragment();if(P){const O=M[0]>N[0];L.appendChild(this._createSelectionElement(W,O?N[0]:M[0],O?M[0]:N[0],A-W+1))}else{const O=B===W?M[0]:0,I=W===z?N[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(W,O,I));const F=A-W-1;if(L.appendChild(this._createSelectionElement(W+1,0,this._bufferService.cols,F)),W!==A){const U=z===A?N[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(A,0,U))}}this._selectionContainer.appendChild(L)}_createSelectionElement(M,N,P,B=1){const z=document.createElement("div");return z.style.height=B*this.dimensions.css.cell.height+"px",z.style.top=M*this.dimensions.css.cell.height+"px",z.style.left=N*this.dimensions.css.cell.width+"px",z.style.width=this.dimensions.css.cell.width*(P-N)+"px",z}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const M of this._rowElements)M.replaceChildren()}renderRows(M,N){const P=this._bufferService.buffer,B=P.ybase+P.y,z=Math.min(P.x,this._bufferService.cols-1),W=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,L=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=M;O<=N;O++){const I=O+P.ydisp,F=this._rowElements[O],U=P.lines.get(I);if(!F||!U)break;F.replaceChildren(...this._rowFactory.createRow(U,I,I===B,A,L,z,W,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,N,P,B,z,W){P<0&&(M=0),B<0&&(N=0);const A=this._bufferService.rows-1;P=Math.max(Math.min(P,A),0),B=Math.max(Math.min(B,A),0),z=Math.min(z,this._bufferService.cols);const L=this._bufferService.buffer,O=L.ybase+L.y,I=Math.min(L.x,z-1),F=this._optionsService.rawOptions.cursorBlink,U=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let Y=P;Y<=B;++Y){const J=Y+L.ydisp,T=this._rowElements[Y],H=L.lines.get(J);if(!T||!H)break;T.replaceChildren(...this._rowFactory.createRow(H,J,J===O,U,X,I,F,this.dimensions.css.cell.width,this._widthCache,W?Y===P?M:0:-1,W?(Y===B?N:z)-1:-1))}}};i.DomRenderer=D=c([f(4,d.IInstantiationService),f(5,_.ICharSizeService),f(6,d.IOptionsService),f(7,d.IBufferService),f(8,_.ICoreBrowserService),f(9,_.IThemeService)],D)},3787:function(x,i,n){var c=this&&this.__decorate||function(w,j,g,k){var R,D=arguments.length,M=D<3?j:k===null?k=Object.getOwnPropertyDescriptor(j,g):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(w,j,g,k);else for(var N=w.length-1;N>=0;N--)(R=w[N])&&(M=(D<3?R(M):D>3?R(j,g,M):R(j,g))||M);return D>3&&M&&Object.defineProperty(j,g,M),M},f=this&&this.__param||function(w,j){return function(g,k){j(g,k,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const a=n(2223),p=n(643),S=n(511),y=n(2585),_=n(8055),o=n(4725),h=n(4269),u=n(6171),d=n(3734);let b=i.DomRendererRowFactory=class{constructor(w,j,g,k,R,D,M){this._document=w,this._characterJoinerService=j,this._optionsService=g,this._coreBrowserService=k,this._coreService=R,this._decorationService=D,this._themeService=M,this._workCell=new S.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(w,j,g){this._selectionStart=w,this._selectionEnd=j,this._columnSelectMode=g}createRow(w,j,g,k,R,D,M,N,P,B,z){const W=[],A=this._characterJoinerService.getJoinedCharacters(j),L=this._themeService.colors;let O,I=w.getNoBgTrimmedLength();g&&I<D+1&&(I=D+1);let F=0,U="",X=0,Y=0,J=0,T=!1,H=0,q=!1,$=0;const ee=[],Q=B!==-1&&z!==-1;for(let le=0;le<I;le++){w.loadCell(le,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let Se=!1,Be=le,Z=this._workCell;if(A.length>0&&le===A[0][0]){Se=!0;const K=A.shift();Z=new h.JoinedCellData(this._workCell,w.translateToString(!0,K[0],K[1]),K[1]-K[0]),Be=K[1]-1,he=Z.getWidth()}const Ye=this._isCellInSelection(le,j),fe=g&&le===D,Fe=Q&&le>=B&&le<=z;let st=!1;this._decorationService.forEachDecorationAtCell(le,j,void 0,(K=>{st=!0}));let $e=Z.getChars()||p.WHITESPACE_CELL_CHAR;if($e===" "&&(Z.isUnderline()||Z.isOverline())&&($e=" "),$=he*N-P.get($e,Z.isBold(),Z.isItalic()),O){if(F&&(Ye&&q||!Ye&&!q&&Z.bg===X)&&(Ye&&q&&L.selectionForeground||Z.fg===Y)&&Z.extended.ext===J&&Fe===T&&$===H&&!fe&&!Se&&!st){U+=$e,F++;continue}F&&(O.textContent=U),O=this._document.createElement("span"),F=0,U=""}else O=this._document.createElement("span");if(X=Z.bg,Y=Z.fg,J=Z.extended.ext,T=Fe,H=$,q=Ye,Se&&D>=le&&D<=Be&&(D=le),!this._coreService.isCursorHidden&&fe){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&ee.push("xterm-cursor-blink"),ee.push(k==="bar"?"xterm-cursor-bar":k==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline")}}if(Z.isBold()&&ee.push("xterm-bold"),Z.isItalic()&&ee.push("xterm-italic"),Z.isDim()&&ee.push("xterm-dim"),U=Z.isInvisible()?p.WHITESPACE_CELL_CHAR:Z.getChars()||p.WHITESPACE_CELL_CHAR,Z.isUnderline()&&(ee.push(`xterm-underline-${Z.extended.underlineStyle}`),U===" "&&(U=" "),!Z.isUnderlineColorDefault()))if(Z.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${d.AttributeData.toColorRGB(Z.getUnderlineColor()).join(",")})`;else{let K=Z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Z.isBold()&&K<8&&(K+=8),O.style.textDecorationColor=L.ansi[K].css}Z.isOverline()&&(ee.push("xterm-overline"),U===" "&&(U=" ")),Z.isStrikethrough()&&ee.push("xterm-strikethrough"),Fe&&(O.style.textDecoration="underline");let ge=Z.getFgColor(),Ae=Z.getFgColorMode(),we=Z.getBgColor(),tt=Z.getBgColorMode();const Te=!!Z.isInverse();if(Te){const K=ge;ge=we,we=K;const te=Ae;Ae=tt,tt=te}let je,Ze,Ue,_e=!1;switch(this._decorationService.forEachDecorationAtCell(le,j,void 0,(K=>{K.options.layer!=="top"&&_e||(K.backgroundColorRGB&&(tt=50331648,we=K.backgroundColorRGB.rgba>>8&16777215,je=K.backgroundColorRGB),K.foregroundColorRGB&&(Ae=50331648,ge=K.foregroundColorRGB.rgba>>8&16777215,Ze=K.foregroundColorRGB),_e=K.options.layer==="top")})),!_e&&Ye&&(je=this._coreBrowserService.isFocused?L.selectionBackgroundOpaque:L.selectionInactiveBackgroundOpaque,we=je.rgba>>8&16777215,tt=50331648,_e=!0,L.selectionForeground&&(Ae=50331648,ge=L.selectionForeground.rgba>>8&16777215,Ze=L.selectionForeground)),_e&&ee.push("xterm-decoration-top"),tt){case 16777216:case 33554432:Ue=L.ansi[we],ee.push(`xterm-bg-${we}`);break;case 50331648:Ue=_.rgba.toColor(we>>16,we>>8&255,255&we),this._addStyle(O,`background-color:#${C((we>>>0).toString(16),"0",6)}`);break;default:Te?(Ue=L.foreground,ee.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):Ue=L.background}switch(je||Z.isDim()&&(je=_.color.multiplyOpacity(Ue,.5)),Ae){case 16777216:case 33554432:Z.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(O,Ue,L.ansi[ge],Z,je,void 0)||ee.push(`xterm-fg-${ge}`);break;case 50331648:const K=_.rgba.toColor(ge>>16&255,ge>>8&255,255&ge);this._applyMinimumContrast(O,Ue,K,Z,je,Ze)||this._addStyle(O,`color:#${C(ge.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,Ue,L.foreground,Z,je,void 0)||Te&&ee.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}ee.length&&(O.className=ee.join(" "),ee.length=0),fe||Se||st?O.textContent=U:F++,$!==this.defaultSpacing&&(O.style.letterSpacing=`${$}px`),W.push(O),le=Be}return O&&F&&(O.textContent=U),W}_applyMinimumContrast(w,j,g,k,R,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,u.excludeFromContrastRatioDemands)(k.getCode()))return!1;const M=this._getContrastCache(k);let N;if(R||D||(N=M.getColor(j.rgba,g.rgba)),N===void 0){const P=this._optionsService.rawOptions.minimumContrastRatio/(k.isDim()?2:1);N=_.color.ensureContrastRatio(R||j,D||g,P),M.setColor((R||j).rgba,(D||g).rgba,N??null)}return!!N&&(this._addStyle(w,`color:${N.css}`),!0)}_getContrastCache(w){return w.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(w,j){w.setAttribute("style",`${w.getAttribute("style")||""}${j};`)}_isCellInSelection(w,j){const g=this._selectionStart,k=this._selectionEnd;return!(!g||!k)&&(this._columnSelectMode?g[0]<=k[0]?w>=g[0]&&j>=g[1]&&w<k[0]&&j<=k[1]:w<g[0]&&j>=g[1]&&w>=k[0]&&j<=k[1]:j>g[1]&&j<k[1]||g[1]===k[1]&&j===g[1]&&w>=g[0]&&w<k[0]||g[1]<k[1]&&j===k[1]&&w<k[0]||g[1]<k[1]&&j===g[1]&&w>=g[0])}};function C(w,j,g){for(;w.length<g;)w=j+w;return w}i.DomRendererRowFactory=b=c([f(1,o.ICharacterJoinerService),f(2,y.IOptionsService),f(3,o.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,o.IThemeService)],b)},2550:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const c=n.createElement("span"),f=n.createElement("span");f.style.fontWeight="bold";const a=n.createElement("span");a.style.fontStyle="italic";const p=n.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[c,f,a,p],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(a),this._container.appendChild(p),n.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(n,c,f,a){n===this._font&&c===this._fontSize&&f===this._weight&&a===this._weightBold||(this._font=n,this._fontSize=c,this._weight=f,this._weightBold=a,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${a}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${a}`,this.clear())}get(n,c,f){let a=0;if(!c&&!f&&n.length===1&&(a=n.charCodeAt(0))<256)return this._flat[a]!==-9999?this._flat[a]:this._flat[a]=this._measure(n,0);let p=n;c&&(p+="B"),f&&(p+="I");let S=this._holey.get(p);if(S===void 0){let y=0;c&&(y|=1),f&&(y|=2),S=this._measure(n,y),this._holey.set(p,S)}return S}_measure(n,c){const f=this._measureElements[c];return f.textContent=n.repeat(32),f.offsetWidth/32}}},2223:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(x,i)=>{function n(c){return 57508<=c&&c<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return n(c)||(function(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:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,c=this.selectionEnd;return!(!n||!c)&&(n[1]>c[1]||n[1]===c[1]&&n[0]>c[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(x,i,n){var c=this&&this.__decorate||function(o,h,u,d){var b,C=arguments.length,w=C<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(o,h,u,d);else for(var j=o.length-1;j>=0;j--)(b=o[j])&&(w=(C<3?b(w):C>3?b(h,u,w):b(h,u))||w);return C>3&&w&&Object.defineProperty(h,u,w),w},f=this&&this.__param||function(o,h){return function(u,d){h(u,d,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const a=n(2585),p=n(8460),S=n(844);let y=i.CharSizeService=class extends S.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(o,h,u){super(),this._optionsService=u,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new _(o,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const o=this._measureStrategy.measure();o.width===this.width&&o.height===this.height||(this.width=o.width,this.height=o.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=c([f(2,a.IOptionsService)],y);class _{constructor(h,u,d){this._document=h,this._parentElement=u,this._optionsService=d,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 h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(x,i,n){var c=this&&this.__decorate||function(h,u,d,b){var C,w=arguments.length,j=w<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,d):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,u,d,b);else for(var g=h.length-1;g>=0;g--)(C=h[g])&&(j=(w<3?C(j):w>3?C(u,d,j):C(u,d))||j);return w>3&&j&&Object.defineProperty(u,d,j),j},f=this&&this.__param||function(h,u){return function(d,b){u(d,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const a=n(3734),p=n(643),S=n(511),y=n(2585);class _ extends a.AttributeData{constructor(u,d,b){super(),this.content=0,this.combinedData="",this.fg=u.fg,this.bg=u.bg,this.combinedData=d,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(u){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=_;let o=i.CharacterJoinerService=class Ao{constructor(u){this._bufferService=u,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new S.CellData}register(u){const d={id:this._nextCharacterJoinerId++,handler:u};return this._characterJoiners.push(d),d.id}deregister(u){for(let d=0;d<this._characterJoiners.length;d++)if(this._characterJoiners[d].id===u)return this._characterJoiners.splice(d,1),!0;return!1}getJoinedCharacters(u){if(this._characterJoiners.length===0)return[];const d=this._bufferService.buffer.lines.get(u);if(!d||d.length===0)return[];const b=[],C=d.translateToString(!0);let w=0,j=0,g=0,k=d.getFg(0),R=d.getBg(0);for(let D=0;D<d.getTrimmedLength();D++)if(d.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==k||this._workCell.bg!==R){if(D-w>1){const M=this._getJoinedRanges(C,g,j,d,w);for(let N=0;N<M.length;N++)b.push(M[N])}w=D,g=j,k=this._workCell.fg,R=this._workCell.bg}j+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-w>1){const D=this._getJoinedRanges(C,g,j,d,w);for(let M=0;M<D.length;M++)b.push(D[M])}return b}_getJoinedRanges(u,d,b,C,w){const j=u.substring(d,b);let g=[];try{g=this._characterJoiners[0].handler(j)}catch(k){console.error(k)}for(let k=1;k<this._characterJoiners.length;k++)try{const R=this._characterJoiners[k].handler(j);for(let D=0;D<R.length;D++)Ao._mergeRanges(g,R[D])}catch(R){console.error(R)}return this._stringRangesToCellRanges(g,C,w),g}_stringRangesToCellRanges(u,d,b){let C=0,w=!1,j=0,g=u[C];if(g){for(let k=b;k<this._bufferService.cols;k++){const R=d.getWidth(k),D=d.getString(k).length||p.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!w&&g[0]<=j&&(g[0]=k,w=!0),g[1]<=j){if(g[1]=k,g=u[++C],!g)break;g[0]<=j?(g[0]=k,w=!0):w=!1}j+=D}}g&&(g[1]=this._bufferService.cols)}}static _mergeRanges(u,d){let b=!1;for(let C=0;C<u.length;C++){const w=u[C];if(b){if(d[1]<=w[0])return u[C-1][1]=d[1],u;if(d[1]<=w[1])return u[C-1][1]=Math.max(d[1],w[1]),u.splice(C,1),u;u.splice(C,1),C--}else{if(d[1]<=w[0])return u.splice(C,0,d),u;if(d[1]<=w[1])return w[0]=Math.min(d[0],w[0]),u;d[0]<w[1]&&(w[0]=Math.min(d[0],w[0]),b=!0)}}return b?u[u.length-1][1]=d[1]:u.push(d),u}};i.CharacterJoinerService=o=c([f(0,y.IBufferService)],o)},5114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,c){this._textarea=n,this.window=c,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(x,i,n){var c=this&&this.__decorate||function(y,_,o,h){var u,d=arguments.length,b=d<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,o):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,_,o,h);else for(var C=y.length-1;C>=0;C--)(u=y[C])&&(b=(d<3?u(b):d>3?u(_,o,b):u(_,o))||b);return d>3&&b&&Object.defineProperty(_,o,b),b},f=this&&this.__param||function(y,_){return function(o,h){_(o,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const a=n(4725),p=n(9806);let S=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,o,h,u){return(0,p.getCoords)(window,y,_,o,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,u)}getMouseReportCoords(y,_){const o=(0,p.getCoordsRelativeToElement)(window,y,_);if(this._charSizeService.hasValidSize)return o[0]=Math.min(Math.max(o[0],0),this._renderService.dimensions.css.canvas.width-1),o[1]=Math.min(Math.max(o[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(o[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(o[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(o[0]),y:Math.floor(o[1])}}};i.MouseService=S=c([f(0,a.IRenderService),f(1,a.ICharSizeService)],S)},3230:function(x,i,n){var c=this&&this.__decorate||function(b,C,w,j){var g,k=arguments.length,R=k<3?C:j===null?j=Object.getOwnPropertyDescriptor(C,w):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,C,w,j);else for(var D=b.length-1;D>=0;D--)(g=b[D])&&(R=(k<3?g(R):k>3?g(C,w,R):g(C,w))||R);return k>3&&R&&Object.defineProperty(C,w,R),R},f=this&&this.__param||function(b,C){return function(w,j){C(w,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const a=n(3656),p=n(6193),S=n(5596),y=n(4725),_=n(8460),o=n(844),h=n(7226),u=n(2585);let d=i.RenderService=class extends o.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,C,w,j,g,k,R,D){if(super(),this._rowCount=b,this._charSizeService=j,this._renderer=this.register(new o.MutableDisposable),this._pausedResizeTask=new h.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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(R.window,((M,N)=>this._renderRows(M,N))),this.register(this._renderDebouncer),this._screenDprMonitor=new S.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(k.onResize((()=>this._fullRefresh()))),this.register(k.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(w.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(g.onDecorationRegistered((()=>this._fullRefresh()))),this.register(g.onDecorationRemoved((()=>this._fullRefresh()))),this.register(w.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(k.cols,k.rows),this._fullRefresh()}))),this.register(w.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(k.buffer.y,k.buffer.y,!0)))),this.register((0,a.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(D.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const M=new R.window.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});M.observe(C),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.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(b,C,w=!1){this._isPaused?this._needsFullRefresh=!0:(w||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,C,this._rowCount))}_renderRows(b,C){this._renderer.value&&(b=Math.min(b,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(b,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:C}),this._onRender.fire({start:b,end:C}),this._isNextRenderRedrawOnly=!0)}resize(b,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,C;this._renderer.value&&((C=(b=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,C))):this._renderer.value.handleResize(b,C),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,C,w){var j;this._selectionState.start=b,this._selectionState.end=C,this._selectionState.columnSelectMode=w,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(b,C,w)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};i.RenderService=d=c([f(2,u.IOptionsService),f(3,y.ICharSizeService),f(4,u.IDecorationService),f(5,u.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],d)},9312:function(x,i,n){var c=this&&this.__decorate||function(g,k,R,D){var M,N=arguments.length,P=N<3?k:D===null?D=Object.getOwnPropertyDescriptor(k,R):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(g,k,R,D);else for(var B=g.length-1;B>=0;B--)(M=g[B])&&(P=(N<3?M(P):N>3?M(k,R,P):M(k,R))||P);return N>3&&P&&Object.defineProperty(k,R,P),P},f=this&&this.__param||function(g,k){return function(R,D){k(R,D,g)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const a=n(9806),p=n(9504),S=n(456),y=n(4725),_=n(8460),o=n(844),h=n(6114),u=n(4841),d=n(511),b=n(2585),C=" ",w=new RegExp(C,"g");let j=i.SelectionService=class extends o.Disposable{constructor(g,k,R,D,M,N,P,B,z){super(),this._element=g,this._screenElement=k,this._linkifier=R,this._bufferService=D,this._coreService=M,this._mouseService=N,this._optionsService=P,this._renderService=B,this._coreBrowserService=z,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new d.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=W=>this._handleMouseMove(W),this._mouseUpListener=W=>this._handleMouseUp(W),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((W=>this._handleTrim(W))),this.register(this._bufferService.buffers.onBufferActivate((W=>this._handleBufferActivate(W)))),this.enable(),this._model=new S.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,o.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const g=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!g||!k||g[0]===k[0]&&g[1]===k[1])}get selectionText(){const g=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;if(!g||!k)return"";const R=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(g[0]===k[0])return"";const M=g[0]<k[0]?g[0]:k[0],N=g[0]<k[0]?k[0]:g[0];for(let P=g[1];P<=k[1];P++){const B=R.translateBufferLineToString(P,!0,M,N);D.push(B)}}else{const M=g[1]===k[1]?k[0]:void 0;D.push(R.translateBufferLineToString(g[1],!0,g[0],M));for(let N=g[1]+1;N<=k[1]-1;N++){const P=R.lines.get(N),B=R.translateBufferLineToString(N,!0);P?.isWrapped?D[D.length-1]+=B:D.push(B)}if(g[1]!==k[1]){const N=R.lines.get(k[1]),P=R.translateBufferLineToString(k[1],!0,0,k[0]);N&&N.isWrapped?D[D.length-1]+=P:D.push(P)}}return D.map((M=>M.replace(w," "))).join(h.isWindows?`\r
16
+ `:`
17
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(g){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&g&&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(g){const k=this._getMouseBufferCoords(g),R=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(R&&D&&k)&&this._areCoordsInSelection(k,R,D)}isCellInSelection(g,k){const R=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!R||!D)&&this._areCoordsInSelection([g,k],R,D)}_areCoordsInSelection(g,k,R){return g[1]>k[1]&&g[1]<R[1]||k[1]===R[1]&&g[1]===k[1]&&g[0]>=k[0]&&g[0]<R[0]||k[1]<R[1]&&g[1]===R[1]&&g[0]<R[0]||k[1]<R[1]&&g[1]===k[1]&&g[0]>=k[0]}_selectWordAtCursor(g,k){var R,D;const M=(D=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||D===void 0?void 0:D.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,u.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const N=this._getMouseBufferCoords(g);return!!N&&(this._selectWordAt(N,k),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(g,k){this._model.clearSelection(),g=Math.max(g,0),k=Math.min(k,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,g],this._model.selectionEnd=[this._bufferService.cols,k],this.refresh(),this._onSelectionChange.fire()}_handleTrim(g){this._model.handleTrim(g)&&this.refresh()}_getMouseBufferCoords(g){const k=this._mouseService.getCoords(g,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(k)return k[0]--,k[1]--,k[1]+=this._bufferService.buffer.ydisp,k}_getMouseEventScrollAmount(g){let k=(0,a.getCoordsRelativeToElement)(this._coreBrowserService.window,g,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return k>=0&&k<=R?0:(k>R&&(k-=R),k=Math.min(Math.max(k,-50),50),k/=50,k/Math.abs(k)+Math.round(14*k))}shouldForceSelection(g){return h.isMac?g.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:g.shiftKey}handleMouseDown(g){if(this._mouseDownTimeStamp=g.timeStamp,(g.button!==2||!this.hasSelection)&&g.button===0){if(!this._enabled){if(!this.shouldForceSelection(g))return;g.stopPropagation()}g.preventDefault(),this._dragScrollAmount=0,this._enabled&&g.shiftKey?this._handleIncrementalClick(g):g.detail===1?this._handleSingleClick(g):g.detail===2?this._handleDoubleClick(g):g.detail===3&&this._handleTripleClick(g),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(g){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(g))}_handleSingleClick(g){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(g)?3:0,this._model.selectionStart=this._getMouseBufferCoords(g),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const k=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);k&&k.length!==this._model.selectionStart[0]&&k.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(g){this._selectWordAtCursor(g,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(g){const k=this._getMouseBufferCoords(g);k&&(this._activeSelectionMode=2,this._selectLineAt(k[1]))}shouldColumnSelect(g){return g.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(g){if(g.stopImmediatePropagation(),!this._model.selectionStart)return;const k=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(g),!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(g),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const D=R.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}k&&k[0]===this._model.selectionEnd[0]&&k[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 g=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(g.ydisp+this._bufferService.rows,g.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=g.ydisp),this.refresh()}}_handleMouseUp(g){const k=g.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&k<500&&g.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(g,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const D=(0,p.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const g=this._model.finalSelectionStart,k=this._model.finalSelectionEnd,R=!(!g||!k||g[0]===k[0]&&g[1]===k[1]);R?g&&k&&(this._oldSelectionStart&&this._oldSelectionEnd&&g[0]===this._oldSelectionStart[0]&&g[1]===this._oldSelectionStart[1]&&k[0]===this._oldSelectionEnd[0]&&k[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(g,k,R)):this._oldHasSelection&&this._fireOnSelectionChange(g,k,R)}_fireOnSelectionChange(g,k,R){this._oldSelectionStart=g,this._oldSelectionEnd=k,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(g){this.clearSelection(),this._trimListener.dispose(),this._trimListener=g.activeBuffer.lines.onTrim((k=>this._handleTrim(k)))}_convertViewportColToCharacterIndex(g,k){let R=k;for(let D=0;k>=D;D++){const M=g.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&k!==D&&(R+=M-1)}return R}setSelection(g,k,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[g,k],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(g){this._isClickInSelection(g)||(this._selectWordAtCursor(g,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(g,k,R=!0,D=!0){if(g[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,N=M.lines.get(g[1]);if(!N)return;const P=M.translateBufferLineToString(g[1],!1);let B=this._convertViewportColToCharacterIndex(N,g[0]),z=B;const W=g[0]-B;let A=0,L=0,O=0,I=0;if(P.charAt(B)===" "){for(;B>0&&P.charAt(B-1)===" ";)B--;for(;z<P.length&&P.charAt(z+1)===" ";)z++}else{let X=g[0],Y=g[0];N.getWidth(X)===0&&(A++,X--),N.getWidth(Y)===2&&(L++,Y++);const J=N.getString(Y).length;for(J>1&&(I+=J-1,z+=J-1);X>0&&B>0&&!this._isCharWordSeparator(N.loadCell(X-1,this._workCell));){N.loadCell(X-1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,X--):T>1&&(O+=T-1,B-=T-1),B--,X--}for(;Y<N.length&&z+1<P.length&&!this._isCharWordSeparator(N.loadCell(Y+1,this._workCell));){N.loadCell(Y+1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===2?(L++,Y++):T>1&&(I+=T-1,z+=T-1),z++,Y++}}z++;let F=B+W-A+O,U=Math.min(this._bufferService.cols,z-B+A+L-O-I);if(k||P.slice(B,z).trim()!==""){if(R&&F===0&&N.getCodePoint(0)!==32){const X=M.lines.get(g[1]-1);if(X&&N.isWrapped&&X.getCodePoint(this._bufferService.cols-1)!==32){const Y=this._getWordAt([this._bufferService.cols-1,g[1]-1],!1,!0,!1);if(Y){const J=this._bufferService.cols-Y.start;F-=J,U+=J}}}if(D&&F+U===this._bufferService.cols&&N.getCodePoint(this._bufferService.cols-1)!==32){const X=M.lines.get(g[1]+1);if(X?.isWrapped&&X.getCodePoint(0)!==32){const Y=this._getWordAt([0,g[1]+1],!1,!1,!0);Y&&(U+=Y.length)}}return{start:F,length:U}}}_selectWordAt(g,k){const R=this._getWordAt(g,k);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,g[1]--;this._model.selectionStart=[R.start,g[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(g){const k=this._getWordAt(g,!0);if(k){let R=g[1];for(;k.start<0;)k.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;k.start+k.length>this._bufferService.cols;)k.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?k.start:k.start+k.length,R]}}_isCharWordSeparator(g){return g.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(g.getChars())>=0}_selectLineAt(g){const k=this._bufferService.buffer.getWrappedRangeForLine(g),R={start:{x:0,y:k.first},end:{x:this._bufferService.cols-1,y:k.last}};this._model.selectionStart=[0,k.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,u.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=j=c([f(3,b.IBufferService),f(4,b.ICoreService),f(5,y.IMouseService),f(6,b.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],j)},4725:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const c=n(8343);i.ICharSizeService=(0,c.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),i.IMouseService=(0,c.createDecorator)("MouseService"),i.IRenderService=(0,c.createDecorator)("RenderService"),i.ISelectionService=(0,c.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(x,i,n){var c=this&&this.__decorate||function(j,g,k,R){var D,M=arguments.length,N=M<3?g:R===null?R=Object.getOwnPropertyDescriptor(g,k):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(j,g,k,R);else for(var P=j.length-1;P>=0;P--)(D=j[P])&&(N=(M<3?D(N):M>3?D(g,k,N):D(g,k))||N);return M>3&&N&&Object.defineProperty(g,k,N),N},f=this&&this.__param||function(j,g){return function(k,R){g(k,R,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const a=n(7239),p=n(8055),S=n(8460),y=n(844),_=n(2585),o=p.css.toColor("#ffffff"),h=p.css.toColor("#000000"),u=p.css.toColor("#ffffff"),d=p.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[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")],g=[0,95,135,175,215,255];for(let k=0;k<216;k++){const R=g[k/36%6|0],D=g[k/6%6|0],M=g[k%6];j.push({css:p.channels.toCss(R,D,M),rgba:p.channels.toRgba(R,D,M)})}for(let k=0;k<24;k++){const R=8+10*k;j.push({css:p.channels.toCss(R,R,R),rgba:p.channels.toRgba(R,R,R)})}return j})());let C=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new S.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:o,background:h,cursor:u,cursorAccent:d,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:p.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:p.color.blend(h,b),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(j={}){const g=this._colors;if(g.foreground=w(j.foreground,o),g.background=w(j.background,h),g.cursor=w(j.cursor,u),g.cursorAccent=w(j.cursorAccent,d),g.selectionBackgroundTransparent=w(j.selectionBackground,b),g.selectionBackgroundOpaque=p.color.blend(g.background,g.selectionBackgroundTransparent),g.selectionInactiveBackgroundTransparent=w(j.selectionInactiveBackground,g.selectionBackgroundTransparent),g.selectionInactiveBackgroundOpaque=p.color.blend(g.background,g.selectionInactiveBackgroundTransparent),g.selectionForeground=j.selectionForeground?w(j.selectionForeground,p.NULL_COLOR):void 0,g.selectionForeground===p.NULL_COLOR&&(g.selectionForeground=void 0),p.color.isOpaque(g.selectionBackgroundTransparent)&&(g.selectionBackgroundTransparent=p.color.opacity(g.selectionBackgroundTransparent,.3)),p.color.isOpaque(g.selectionInactiveBackgroundTransparent)&&(g.selectionInactiveBackgroundTransparent=p.color.opacity(g.selectionInactiveBackgroundTransparent,.3)),g.ansi=i.DEFAULT_ANSI_COLORS.slice(),g.ansi[0]=w(j.black,i.DEFAULT_ANSI_COLORS[0]),g.ansi[1]=w(j.red,i.DEFAULT_ANSI_COLORS[1]),g.ansi[2]=w(j.green,i.DEFAULT_ANSI_COLORS[2]),g.ansi[3]=w(j.yellow,i.DEFAULT_ANSI_COLORS[3]),g.ansi[4]=w(j.blue,i.DEFAULT_ANSI_COLORS[4]),g.ansi[5]=w(j.magenta,i.DEFAULT_ANSI_COLORS[5]),g.ansi[6]=w(j.cyan,i.DEFAULT_ANSI_COLORS[6]),g.ansi[7]=w(j.white,i.DEFAULT_ANSI_COLORS[7]),g.ansi[8]=w(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),g.ansi[9]=w(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),g.ansi[10]=w(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),g.ansi[11]=w(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),g.ansi[12]=w(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),g.ansi[13]=w(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),g.ansi[14]=w(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),g.ansi[15]=w(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const k=Math.min(g.ansi.length-16,j.extendedAnsi.length);for(let R=0;R<k;R++)g.ansi[R+16]=w(j.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[j]=this._restoreColors.ansi[j]}else for(let g=0;g<this._restoreColors.ansi.length;++g)this._colors.ansi[g]=this._restoreColors.ansi[g]}modifyColors(j){j(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function w(j,g){if(j!==void 0)try{return p.css.toColor(j)}catch{}return g}i.ThemeService=C=c([f(0,_.IOptionsService)],C)},6349:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=n(8460),f=n(844);class a extends f.Disposable{constructor(S){super(),this._maxLength=S,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(S){if(this._maxLength===S)return;const y=new Array(S);for(let _=0;_<Math.min(S,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=S,this._startIndex=0}get length(){return this._length}set length(S){if(S>this._length)for(let y=this._length;y<S;y++)this._array[y]=void 0;this._length=S}get(S){return this._array[this._getCyclicIndex(S)]}set(S,y){this._array[this._getCyclicIndex(S)]=y}push(S){this._array[this._getCyclicIndex(this._length)]=S,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(S,y,..._){if(y){for(let o=S;o<this._length-y;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+y)];this._length-=y,this.onDeleteEmitter.fire({index:S,amount:y})}for(let o=this._length-1;o>=S;o--)this._array[this._getCyclicIndex(o+_.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<_.length;o++)this._array[this._getCyclicIndex(S+o)]=_[o];if(_.length&&this.onInsertEmitter.fire({index:S,amount:_.length}),this._length+_.length>this._maxLength){const o=this._length+_.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=_.length}trimStart(S){S>this._length&&(S=this._length),this._startIndex+=S,this._length-=S,this.onTrimEmitter.fire(S)}shiftElements(S,y,_){if(!(y<=0)){if(S<0||S>=this._length)throw new Error("start argument out of range");if(S+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let h=y-1;h>=0;h--)this.set(S+h+_,this.get(S+h));const o=S+y+_-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<y;o++)this.set(S+o+_,this.get(S+o))}}_getCyclicIndex(S){return(this._startIndex+S)%this._maxLength}}i.CircularList=a},1439:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(c,f=5){if(typeof c!="object")return c;const a=Array.isArray(c)?[]:{};for(const p in c)a[p]=f<=1?c[p]:c[p]&&n(c[p],f-1);return a}},8055:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const c=n(6114);let f=0,a=0,p=0,S=0;var y,_,o,h,u;function d(C){const w=C.toString(16);return w.length<2?"0"+w:w}function b(C,w){return C<w?(w+.05)/(C+.05):(C+.05)/(w+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(w,j,g,k){return k!==void 0?`#${d(w)}${d(j)}${d(g)}${d(k)}`:`#${d(w)}${d(j)}${d(g)}`},C.toRgba=function(w,j,g,k=255){return(w<<24|j<<16|g<<8|k)>>>0}})(y||(i.channels=y={})),(function(C){function w(j,g){return S=Math.round(255*g),[f,a,p]=u.toChannels(j.rgba),{css:y.toCss(f,a,p,S),rgba:y.toRgba(f,a,p,S)}}C.blend=function(j,g){if(S=(255&g.rgba)/255,S===1)return{css:g.css,rgba:g.rgba};const k=g.rgba>>24&255,R=g.rgba>>16&255,D=g.rgba>>8&255,M=j.rgba>>24&255,N=j.rgba>>16&255,P=j.rgba>>8&255;return f=M+Math.round((k-M)*S),a=N+Math.round((R-N)*S),p=P+Math.round((D-P)*S),{css:y.toCss(f,a,p),rgba:y.toRgba(f,a,p)}},C.isOpaque=function(j){return(255&j.rgba)==255},C.ensureContrastRatio=function(j,g,k){const R=u.ensureContrastRatio(j.rgba,g.rgba,k);if(R)return u.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(j){const g=(255|j.rgba)>>>0;return[f,a,p]=u.toChannels(g),{css:y.toCss(f,a,p),rgba:g}},C.opacity=w,C.multiplyOpacity=function(j,g){return S=255&j.rgba,w(j,S*g/255)},C.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(_||(i.color=_={})),(function(C){let w,j;if(!c.isNode){const g=document.createElement("canvas");g.width=1,g.height=1;const k=g.getContext("2d",{willReadFrequently:!0});k&&(w=k,w.globalCompositeOperation="copy",j=w.createLinearGradient(0,0,1,1))}C.toColor=function(g){if(g.match(/#[\da-f]{3,8}/i))switch(g.length){case 4:return f=parseInt(g.slice(1,2).repeat(2),16),a=parseInt(g.slice(2,3).repeat(2),16),p=parseInt(g.slice(3,4).repeat(2),16),u.toColor(f,a,p);case 5:return f=parseInt(g.slice(1,2).repeat(2),16),a=parseInt(g.slice(2,3).repeat(2),16),p=parseInt(g.slice(3,4).repeat(2),16),S=parseInt(g.slice(4,5).repeat(2),16),u.toColor(f,a,p,S);case 7:return{css:g,rgba:(parseInt(g.slice(1),16)<<8|255)>>>0};case 9:return{css:g,rgba:parseInt(g.slice(1),16)>>>0}}const k=g.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(k)return f=parseInt(k[1]),a=parseInt(k[2]),p=parseInt(k[3]),S=Math.round(255*(k[5]===void 0?1:parseFloat(k[5]))),u.toColor(f,a,p,S);if(!w||!j)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=j,w.fillStyle=g,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[f,a,p,S]=w.getImageData(0,0,1,1).data,S!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,a,p,S),css:g}}})(o||(i.css=o={})),(function(C){function w(j,g,k){const R=j/255,D=g/255,M=k/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}C.relativeLuminance=function(j){return w(j>>16&255,j>>8&255,255&j)},C.relativeLuminance2=w})(h||(i.rgb=h={})),(function(C){function w(g,k,R){const D=g>>24&255,M=g>>16&255,N=g>>8&255;let P=k>>24&255,B=k>>16&255,z=k>>8&255,W=b(h.relativeLuminance2(P,B,z),h.relativeLuminance2(D,M,N));for(;W<R&&(P>0||B>0||z>0);)P-=Math.max(0,Math.ceil(.1*P)),B-=Math.max(0,Math.ceil(.1*B)),z-=Math.max(0,Math.ceil(.1*z)),W=b(h.relativeLuminance2(P,B,z),h.relativeLuminance2(D,M,N));return(P<<24|B<<16|z<<8|255)>>>0}function j(g,k,R){const D=g>>24&255,M=g>>16&255,N=g>>8&255;let P=k>>24&255,B=k>>16&255,z=k>>8&255,W=b(h.relativeLuminance2(P,B,z),h.relativeLuminance2(D,M,N));for(;W<R&&(P<255||B<255||z<255);)P=Math.min(255,P+Math.ceil(.1*(255-P))),B=Math.min(255,B+Math.ceil(.1*(255-B))),z=Math.min(255,z+Math.ceil(.1*(255-z))),W=b(h.relativeLuminance2(P,B,z),h.relativeLuminance2(D,M,N));return(P<<24|B<<16|z<<8|255)>>>0}C.ensureContrastRatio=function(g,k,R){const D=h.relativeLuminance(g>>8),M=h.relativeLuminance(k>>8);if(b(D,M)<R){if(M<D){const B=w(g,k,R),z=b(D,h.relativeLuminance(B>>8));if(z<R){const W=j(g,k,R);return z>b(D,h.relativeLuminance(W>>8))?B:W}return B}const N=j(g,k,R),P=b(D,h.relativeLuminance(N>>8));if(P<R){const B=w(g,k,R);return P>b(D,h.relativeLuminance(B>>8))?N:B}return N}},C.reduceLuminance=w,C.increaseLuminance=j,C.toChannels=function(g){return[g>>24&255,g>>16&255,g>>8&255,255&g]},C.toColor=function(g,k,R,D){return{css:y.toCss(g,k,R,D),rgba:y.toRgba(g,k,R,D)}}})(u||(i.rgba=u={})),i.toPaddedHex=d,i.contrastRatio=b},8969:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=n(844),f=n(2585),a=n(4348),p=n(7866),S=n(744),y=n(7302),_=n(6975),o=n(8460),h=n(1753),u=n(1480),d=n(7994),b=n(9282),C=n(5435),w=n(5981),j=n(2660);let g=!1;class k extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new o.EventEmitter),this._onScroll.event((D=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(D.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(D){for(const M in D)this.optionsService.options[M]=D[M]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new o.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new o.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new o.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new y.OptionsService(D)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(S.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(_.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(u.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(d.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,o.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,o.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,o.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,o.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new w.WriteBuffer(((M,N)=>this._inputHandler.parse(M,N)))),this.register((0,o.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,M){this._writeBuffer.write(D,M)}writeSync(D,M){this._logService.logLevel<=f.LogLevelEnum.WARN&&!g&&(this._logService.warn("writeSync is unreliable and will be removed soon."),g=!0),this._writeBuffer.writeSync(D,M)}resize(D,M){isNaN(D)||isNaN(M)||(D=Math.max(D,S.MINIMUM_COLS),M=Math.max(M,S.MINIMUM_ROWS),this._bufferService.resize(D,M))}scroll(D,M=!1){this._bufferService.scroll(D,M)}scrollLines(D,M,N){this._bufferService.scrollLines(D,M,N)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const M=D-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(D,M){return this._inputHandler.registerEscHandler(D,M)}registerDcsHandler(D,M){return this._inputHandler.registerDcsHandler(D,M)}registerCsiHandler(D,M){return this._inputHandler.registerCsiHandler(D,M)}registerOscHandler(D,M){return this._inputHandler.registerOscHandler(D,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?D=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const M of D)M.dispose()}))}}}i.CoreTerminal=k},8460:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===n)return void this._listeners.splice(c,1)}}})),this._event}fire(n,c){const f=[];for(let a=0;a<this._listeners.length;a++)f.push(this._listeners[a]);for(let a=0;a<f.length;a++)f[a].call(void 0,n,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,c){return n((f=>c.fire(f)))}},5435:function(x,i,n){var c=this&&this.__decorate||function(W,A,L,O){var I,F=arguments.length,U=F<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,L):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(W,A,L,O);else for(var X=W.length-1;X>=0;X--)(I=W[X])&&(U=(F<3?I(U):F>3?I(A,L,U):I(A,L))||U);return F>3&&U&&Object.defineProperty(A,L,U),U},f=this&&this.__param||function(W,A){return function(L,O){A(L,O,W)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const a=n(2584),p=n(7116),S=n(2015),y=n(844),_=n(482),o=n(8437),h=n(8460),u=n(643),d=n(511),b=n(3734),C=n(2585),w=n(6242),j=n(6351),g=n(5941),k={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function D(W,A){if(W>24)return A.setWinLines||!1;switch(W){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(i.WindowsOptionsReportType=M={}));let N=0;class P extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,L,O,I,F,U,X,Y,J=new S.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=L,this._coreService=O,this._logService=I,this._optionsService=F,this._oscLinkService=U,this._coreMouseService=X,this._unicodeService=Y,this._parser=J,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new d.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.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((T=>this._activeBuffer=T.activeBuffer))),this._parser.setCsiHandlerFallback(((T,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(T),params:H.toArray()})})),this._parser.setEscHandlerFallback((T=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(T)})})),this._parser.setExecuteHandlerFallback((T=>{this._logService.debug("Unknown EXECUTE code: ",{code:T})})),this._parser.setOscHandlerFallback(((T,H,q)=>{this._logService.debug("Unknown OSC code: ",{identifier:T,action:H,data:q})})),this._parser.setDcsHandlerFallback(((T,H,q)=>{H==="HOOK"&&(q=q.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(T),action:H,payload:q})})),this._parser.setPrintHandler(((T,H,q)=>this.print(T,H,q))),this._parser.registerCsiHandler({final:"@"},(T=>this.insertChars(T))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(T=>this.scrollLeft(T))),this._parser.registerCsiHandler({final:"A"},(T=>this.cursorUp(T))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(T=>this.scrollRight(T))),this._parser.registerCsiHandler({final:"B"},(T=>this.cursorDown(T))),this._parser.registerCsiHandler({final:"C"},(T=>this.cursorForward(T))),this._parser.registerCsiHandler({final:"D"},(T=>this.cursorBackward(T))),this._parser.registerCsiHandler({final:"E"},(T=>this.cursorNextLine(T))),this._parser.registerCsiHandler({final:"F"},(T=>this.cursorPrecedingLine(T))),this._parser.registerCsiHandler({final:"G"},(T=>this.cursorCharAbsolute(T))),this._parser.registerCsiHandler({final:"H"},(T=>this.cursorPosition(T))),this._parser.registerCsiHandler({final:"I"},(T=>this.cursorForwardTab(T))),this._parser.registerCsiHandler({final:"J"},(T=>this.eraseInDisplay(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(T=>this.eraseInDisplay(T,!0))),this._parser.registerCsiHandler({final:"K"},(T=>this.eraseInLine(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(T=>this.eraseInLine(T,!0))),this._parser.registerCsiHandler({final:"L"},(T=>this.insertLines(T))),this._parser.registerCsiHandler({final:"M"},(T=>this.deleteLines(T))),this._parser.registerCsiHandler({final:"P"},(T=>this.deleteChars(T))),this._parser.registerCsiHandler({final:"S"},(T=>this.scrollUp(T))),this._parser.registerCsiHandler({final:"T"},(T=>this.scrollDown(T))),this._parser.registerCsiHandler({final:"X"},(T=>this.eraseChars(T))),this._parser.registerCsiHandler({final:"Z"},(T=>this.cursorBackwardTab(T))),this._parser.registerCsiHandler({final:"`"},(T=>this.charPosAbsolute(T))),this._parser.registerCsiHandler({final:"a"},(T=>this.hPositionRelative(T))),this._parser.registerCsiHandler({final:"b"},(T=>this.repeatPrecedingCharacter(T))),this._parser.registerCsiHandler({final:"c"},(T=>this.sendDeviceAttributesPrimary(T))),this._parser.registerCsiHandler({prefix:">",final:"c"},(T=>this.sendDeviceAttributesSecondary(T))),this._parser.registerCsiHandler({final:"d"},(T=>this.linePosAbsolute(T))),this._parser.registerCsiHandler({final:"e"},(T=>this.vPositionRelative(T))),this._parser.registerCsiHandler({final:"f"},(T=>this.hVPosition(T))),this._parser.registerCsiHandler({final:"g"},(T=>this.tabClear(T))),this._parser.registerCsiHandler({final:"h"},(T=>this.setMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(T=>this.setModePrivate(T))),this._parser.registerCsiHandler({final:"l"},(T=>this.resetMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(T=>this.resetModePrivate(T))),this._parser.registerCsiHandler({final:"m"},(T=>this.charAttributes(T))),this._parser.registerCsiHandler({final:"n"},(T=>this.deviceStatus(T))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(T=>this.deviceStatusPrivate(T))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(T=>this.softReset(T))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(T=>this.setCursorStyle(T))),this._parser.registerCsiHandler({final:"r"},(T=>this.setScrollRegion(T))),this._parser.registerCsiHandler({final:"s"},(T=>this.saveCursor(T))),this._parser.registerCsiHandler({final:"t"},(T=>this.windowOptions(T))),this._parser.registerCsiHandler({final:"u"},(T=>this.restoreCursor(T))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(T=>this.insertColumns(T))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(T=>this.deleteColumns(T))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(T=>this.selectProtected(T))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(T=>this.requestMode(T,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(T=>this.requestMode(T,!1))),this._parser.setExecuteHandler(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new w.OscHandler((T=>(this.setTitle(T),this.setIconName(T),!0)))),this._parser.registerOscHandler(1,new w.OscHandler((T=>this.setIconName(T)))),this._parser.registerOscHandler(2,new w.OscHandler((T=>this.setTitle(T)))),this._parser.registerOscHandler(4,new w.OscHandler((T=>this.setOrReportIndexedColor(T)))),this._parser.registerOscHandler(8,new w.OscHandler((T=>this.setHyperlink(T)))),this._parser.registerOscHandler(10,new w.OscHandler((T=>this.setOrReportFgColor(T)))),this._parser.registerOscHandler(11,new w.OscHandler((T=>this.setOrReportBgColor(T)))),this._parser.registerOscHandler(12,new w.OscHandler((T=>this.setOrReportCursorColor(T)))),this._parser.registerOscHandler(104,new w.OscHandler((T=>this.restoreIndexedColor(T)))),this._parser.registerOscHandler(110,new w.OscHandler((T=>this.restoreFgColor(T)))),this._parser.registerOscHandler(111,new w.OscHandler((T=>this.restoreBgColor(T)))),this._parser.registerOscHandler(112,new w.OscHandler((T=>this.restoreCursorColor(T)))),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 T in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:T},(()=>this.selectCharset("("+T))),this._parser.registerEscHandler({intermediates:")",final:T},(()=>this.selectCharset(")"+T))),this._parser.registerEscHandler({intermediates:"*",final:T},(()=>this.selectCharset("*"+T))),this._parser.registerEscHandler({intermediates:"+",final:T},(()=>this.selectCharset("+"+T))),this._parser.registerEscHandler({intermediates:"-",final:T},(()=>this.selectCharset("-"+T))),this._parser.registerEscHandler({intermediates:".",final:T},(()=>this.selectCharset("."+T))),this._parser.registerEscHandler({intermediates:"/",final:T},(()=>this.selectCharset("/"+T)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((T=>(this._logService.error("Parsing error: ",T),T))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((T,H)=>this.requestStatusString(T,H))))}_preserveStack(A,L,O,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=L,this._parseStack.decodedLength=O,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([A,new Promise(((L,O)=>setTimeout((()=>O("#SLOW_TIMEOUT")),5e3)))]).catch((L=>{if(L!=="#SLOW_TIMEOUT")throw L;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,L){let O,I=this._activeBuffer.x,F=this._activeBuffer.y,U=0;const X=this._parseStack.paused;if(X){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,L))return this._logSlowResolvingAsync(O),O;I=this._parseStack.cursorStartX,F=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(U=this._parseStack.position+R)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(Y=>String.fromCharCode(Y))).join("")}"`),typeof A=="string"?A.split("").map((Y=>Y.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),X||this._dirtyRowTracker.clearRange(),A.length>R)for(let Y=U;Y<A.length;Y+=R){const J=Y+R<A.length?Y+R:A.length,T=typeof A=="string"?this._stringDecoder.decode(A.substring(Y,J),this._parseBuffer):this._utf8Decoder.decode(A.subarray(Y,J),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,T))return this._preserveStack(I,F,T,Y),this._logSlowResolvingAsync(O),O}else if(!X){const Y=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,Y))return this._preserveStack(I,F,Y,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===I&&this._activeBuffer.y===F||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,L,O){let I,F;const U=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,Y=this._bufferService.cols,J=this._coreService.decPrivateModes.wraparound,T=this._coreService.modes.insertMode,H=this._curAttrData;let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-L>0&&q.getWidth(this._activeBuffer.x-1)===2&&q.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let $=L;$<O;++$){if(I=A[$],F=this._unicodeService.wcwidth(I),I<127&&U){const ee=U[String.fromCharCode(I)];ee&&(I=ee.charCodeAt(0))}if(X&&this._onA11yChar.fire((0,_.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),F||!this._activeBuffer.x){if(this._activeBuffer.x+F-1>=Y){if(J){for(;this._activeBuffer.x<Y;)q.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Y-1,F===2)continue}if(T&&(q.insertCells(this._activeBuffer.x,F,this._activeBuffer.getNullCell(H),H),q.getWidth(Y-1)===2&&q.setCellFromCodePoint(Y-1,u.NULL_CELL_CODE,u.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),q.setCellFromCodePoint(this._activeBuffer.x++,I,F,H.fg,H.bg,H.extended),F>0)for(;--F;)q.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else q.getWidth(this._activeBuffer.x-1)?q.addCodepointToCell(this._activeBuffer.x-1,I):q.addCodepointToCell(this._activeBuffer.x-2,I)}O-L>0&&(q.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<Y&&O-L>0&&q.getWidth(this._activeBuffer.x)===0&&!q.hasContent(this._activeBuffer.x)&&q.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,L){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,L):this._parser.registerCsiHandler(A,(O=>!D(O.params[0],this._optionsService.rawOptions.windowOptions)||L(O)))}registerDcsHandler(A,L){return this._parser.registerDcsHandler(A,new j.DcsHandler(L))}registerEscHandler(A,L){return this._parser.registerEscHandler(A,L)}registerOscHandler(A,L){return this._parser.registerOscHandler(A,new w.OscHandler(L))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);L.hasWidth(this._activeBuffer.x)&&!L.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,L){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+L):(this._activeBuffer.x=A,this._activeBuffer.y=L),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,L){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+L)}cursorUp(A){const L=this._activeBuffer.y-this._activeBuffer.scrollTop;return L>=0?this._moveCursor(0,-Math.min(L,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const L=this._activeBuffer.scrollBottom-this._activeBuffer.y;return L>=0?this._moveCursor(0,Math.min(L,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const L=A.params[0];return L===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:L===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=A.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=A.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const L=A.params[0];return L===1&&(this._curAttrData.bg|=536870912),L!==2&&L!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,L,O,I=!1,F=!1){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);U.replaceCells(L,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),F),I&&(U.isWrapped=!1)}_resetBufferLine(A,L=!1){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);O&&(O.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),L),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),O.isWrapped=!1)}eraseInDisplay(A,L=!1){let O;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);O<this._bufferService.rows;O++)this._resetBufferLine(O,L);this._dirtyRowTracker.markDirty(O);break;case 1:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O,0,this._activeBuffer.x+1,!0,L),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(O+1).isWrapped=!1);O--;)this._resetBufferLine(O,L);this._dirtyRowTracker.markDirty(0);break;case 2:for(O=this._bufferService.rows,this._dirtyRowTracker.markDirty(O-1);O--;)this._resetBufferLine(O,L);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(A,L=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,L);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,L)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let L=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,F=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;L--;)this._activeBuffer.lines.splice(F-1,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}deleteLines(A){this._restrictCursor();let L=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y;let I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;L--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let L=A.params[0]||1;for(;L--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let L=A.params[0]||1;for(;L--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(o.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.deleteCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.insertCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.insertCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.deleteCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const L=A.params[0]||1,O=new Uint32Array(L);for(let I=0;I<L;++I)O[I]=this._parser.precedingCodepoint;return this.print(O,0,O.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(a.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(a.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(a.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(a.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(a.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,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(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let L=0;L<A.length;L++)switch(A.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[L]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,L){const O=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:F}=this._coreMouseService,U=this._coreService,{buffers:X,cols:Y}=this._bufferService,{active:J,alt:T}=X,H=this._optionsService.rawOptions,q=le=>le?1:2,$=A.params[0];return ee=$,Q=L?$===2?4:$===4?q(U.modes.insertMode):$===12?3:$===20?q(H.convertEol):0:$===1?q(O.applicationCursorKeys):$===3?H.windowOptions.setWinLines?Y===80?2:Y===132?1:0:0:$===6?q(O.origin):$===7?q(O.wraparound):$===8?3:$===9?q(I==="X10"):$===12?q(H.cursorBlink):$===25?q(!U.isCursorHidden):$===45?q(O.reverseWraparound):$===66?q(O.applicationKeypad):$===67?4:$===1e3?q(I==="VT200"):$===1002?q(I==="DRAG"):$===1003?q(I==="ANY"):$===1004?q(O.sendFocus):$===1005?4:$===1006?q(F==="SGR"):$===1015?4:$===1016?q(F==="SGR_PIXELS"):$===1048?1:$===47||$===1047||$===1049?q(J===T):$===2004?q(O.bracketedPasteMode):0,U.triggerDataEvent(`${a.C0.ESC}[${L?"":"?"}${ee};${Q}$y`),!0;var ee,Q}_updateAttrColor(A,L,O,I,F){return L===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([O,I,F])):L===5&&(A&=-50331904,A|=33554432|255&O),A}_extractColor(A,L,O){const I=[0,0,-1,0,0,0];let F=0,U=0;do{if(I[U+F]=A.params[L+U],A.hasSubParams(L+U)){const X=A.getSubParams(L+U);let Y=0;do I[1]===5&&(F=1),I[U+Y+1+F]=X[Y];while(++Y<X.length&&Y+U+1+F<I.length);break}if(I[1]===5&&U+F>=2||I[1]===2&&U+F>=5)break;I[1]&&(F=1)}while(++U+L<A.length&&U+F<I.length);for(let X=2;X<I.length;++X)I[X]===-1&&(I[X]=0);switch(I[0]){case 38:O.fg=this._updateAttrColor(O.fg,I[1],I[3],I[4],I[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,I[1],I[3],I[4],I[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,I[1],I[3],I[4],I[5])}return U}_processUnderline(A,L){L.extended=L.extended.clone(),(!~A||A>5)&&(A=1),L.extended.underlineStyle=A,L.fg|=268435456,A===0&&(L.fg&=-268435457),L.updateExtended()}_processSGR0(A){A.fg=o.DEFAULT_ATTR_DATA.fg,A.bg=o.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const L=A.length;let O;const I=this._curAttrData;for(let F=0;F<L;F++)O=A.params[F],O>=30&&O<=37?(I.fg&=-50331904,I.fg|=16777216|O-30):O>=40&&O<=47?(I.bg&=-50331904,I.bg|=16777216|O-40):O>=90&&O<=97?(I.fg&=-50331904,I.fg|=16777224|O-90):O>=100&&O<=107?(I.bg&=-50331904,I.bg|=16777224|O-100):O===0?this._processSGR0(I):O===1?I.fg|=134217728:O===3?I.bg|=67108864:O===4?(I.fg|=268435456,this._processUnderline(A.hasSubParams(F)?A.getSubParams(F)[0]:1,I)):O===5?I.fg|=536870912:O===7?I.fg|=67108864:O===8?I.fg|=1073741824:O===9?I.fg|=2147483648:O===2?I.bg|=134217728:O===21?this._processUnderline(2,I):O===22?(I.fg&=-134217729,I.bg&=-134217729):O===23?I.bg&=-67108865:O===24?(I.fg&=-268435457,this._processUnderline(0,I)):O===25?I.fg&=-536870913:O===27?I.fg&=-67108865:O===28?I.fg&=-1073741825:O===29?I.fg&=2147483647:O===39?(I.fg&=-67108864,I.fg|=16777215&o.DEFAULT_ATTR_DATA.fg):O===49?(I.bg&=-67108864,I.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?F+=this._extractColor(A,F,I):O===53?I.bg|=1073741824:O===55?I.bg&=-1073741825:O===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):O===100?(I.fg&=-67108864,I.fg|=16777215&o.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",O);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:const L=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${L};${O}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const L=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${L};${O}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const L=A.params[0]||1;switch(L){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const O=L%2==1;return this._optionsService.options.cursorBlink=O,!0}setScrollRegion(A){const L=A.params[0]||1;let O;return(A.length<2||(O=A.params[1])>this._bufferService.rows||O===0)&&(O=this._bufferService.rows),O>L&&(this._activeBuffer.scrollTop=L-1,this._activeBuffer.scrollBottom=O-1,this._setCursor(0,0)),!0}windowOptions(A){if(!D(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const L=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:L!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:L!==0&&L!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),L!==0&&L!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:L!==0&&L!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),L!==0&&L!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const L=[],O=A.split(";");for(;O.length>1;){const I=O.shift(),F=O.shift();if(/^\d+$/.exec(I)){const U=parseInt(I);if(z(U))if(F==="?")L.push({type:0,index:U});else{const X=(0,g.parseColor)(F);X&&L.push({type:1,index:U,color:X})}}}return L.length&&this._onColor.fire(L),!0}setHyperlink(A){const L=A.split(";");return!(L.length<2)&&(L[1]?this._createHyperlink(L[0],L[1]):!L[0]&&this._finishHyperlink())}_createHyperlink(A,L){this._getCurrentLinkId()&&this._finishHyperlink();const O=A.split(":");let I;const F=O.findIndex((U=>U.startsWith("id=")));return F!==-1&&(I=O[F].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:L}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,L){const O=A.split(";");for(let I=0;I<O.length&&!(L>=this._specialColors.length);++I,++L)if(O[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[L]}]);else{const F=(0,g.parseColor)(O[I]);F&&this._onColor.fire([{type:1,index:this._specialColors[L],color:F}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const L=[],O=A.split(";");for(let I=0;I<O.length;++I)if(/^\d+$/.exec(O[I])){const F=parseInt(O[I]);z(F)&&L.push({type:2,index:F})}return L.length&&this._onColor.fire(L),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(k[A[0]],p.CHARSETS[A[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 A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new d.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let L=0;L<this._bufferService.rows;++L){const O=this._activeBuffer.ybase+this._activeBuffer.y+L,I=this._activeBuffer.lines.get(O);I&&(I.fill(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,L){const O=this._bufferService.buffer,I=this._optionsService.rawOptions;return(F=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${F}${a.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${O.scrollTop+1};${O.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,L){this._dirtyRowTracker.markRangeDirty(A,L)}}i.InputHandler=P;let B=class{constructor(W){this._bufferService=W,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(W){W<this.start?this.start=W:W>this.end&&(this.end=W)}markRangeDirty(W,A){W>A&&(N=W,W=A,A=N),W<this.start&&(this.start=W),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function z(W){return 0<=W&&W<256}B=c([f(0,C.IBufferService)],B)},844:(x,i)=>{function n(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=n,i.getDisposeArrayDisposable=function(c){return{dispose:()=>n(c)}}},1505:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(f,a,p){this._data[f]||(this._data[f]={}),this._data[f][a]=p}get(f,a){return this._data[f]?this._data[f][a]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(c,f,a,p,S){this._data.get(c,f)||this._data.set(c,f,new n),this._data.get(c,f).set(a,p,S)}get(c,f,a,p){var S;return(S=this._data.get(c,f))===null||S===void 0?void 0:S.get(a,p)}clear(){this._data.clear()}}},6114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,c=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const f=n.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(n)},6106:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(n=this._search(this._getKey(c)),this._array.splice(n,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(n=this._search(f),n===-1)||this._getKey(this._array[n])!==f)return!1;do if(this._array[n]===c)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===c)}forEachByKey(c,f){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do f(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===c)}values(){return[...this._array].values()}_search(c){let f=0,a=this._array.length-1;for(;a>=f;){let p=f+a>>1;const S=this._getKey(this._array[p]);if(S>c)a=p-1;else{if(!(S<c)){for(;p>0&&this._getKey(this._array[p-1])===c;)p--;return p}f=p+1}}return f}}},7226:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=n(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(S){this._tasks.push(S),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(S){this._idleCallback=void 0;let y=0,_=0,o=S.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),_=Math.max(y,_),h=S.timeRemaining(),1.5*_>h)return o-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-y))}ms`),void this._start();o=h}this.clear()}}class a extends f{_requestCallback(S){return setTimeout((()=>S(this._createDeadline(16))))}_cancelCallback(S){clearTimeout(S)}_createDeadline(S){const y=Date.now()+S;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=a,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:a,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=n(643);i.updateWindowsModeWrappedState=function(f){const a=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=a?.get(f.cols-1),S=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);S&&p&&(S.isWrapped=p[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&p[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(a){return[a>>>16&255,a>>>8&255,255&a]}static fromColorRGB(a){return(255&a[0])<<16|(255&a[1])<<8|255&a[2]}clone(){const a=new n;return a.fg=this.fg,a.bg=this.bg,a.extended=this.extended.clone(),a}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=n;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(a){this._ext=a}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(a){this._ext&=-469762049,this._ext|=a<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(a){this._ext&=-67108864,this._ext|=67108863&a}get urlId(){return this._urlId}set urlId(a){this._urlId=a}constructor(a=0,p=0){this._ext=0,this._urlId=0,this._ext=a,this._urlId=p}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=c},9092:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=n(6349),f=n(7226),a=n(3734),p=n(8437),S=n(4634),y=n(511),_=n(643),o=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(u,d,b){this._hasScrollback=u,this._optionsService=d,this._bufferService=b,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=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.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(u){return u?(this._nullCell.fg=u.fg,this._nullCell.bg=u.bg,this._nullCell.extended=u.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new a.ExtendedAttrs),this._nullCell}getWhitespaceCell(u){return u?(this._whitespaceCell.fg=u.fg,this._whitespaceCell.bg=u.bg,this._whitespaceCell.extended=u.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new a.ExtendedAttrs),this._whitespaceCell}getBlankLine(u,d){return new p.BufferLine(this._bufferService.cols,this.getNullCell(u),d)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const u=this.ybase+this.y-this.ydisp;return u>=0&&u<this._rows}_getCorrectBufferLength(u){if(!this._hasScrollback)return u;const d=u+this._optionsService.rawOptions.scrollback;return d>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:d}fillViewportRows(u){if(this.lines.length===0){u===void 0&&(u=p.DEFAULT_ATTR_DATA);let d=this._rows;for(;d--;)this.lines.push(this.getBlankLine(u))}}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(u,d){const b=this.getNullCell(p.DEFAULT_ATTR_DATA);let C=0;const w=this._getCorrectBufferLength(d);if(w>this.lines.maxLength&&(this.lines.maxLength=w),this.lines.length>0){if(this._cols<u)for(let g=0;g<this.lines.length;g++)C+=+this.lines.get(g).resize(u,b);let j=0;if(this._rows<d)for(let g=this._rows;g<d;g++)this.lines.length<d+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(u,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(u,b)));else for(let g=this._rows;g>d;g--)this.lines.length>d+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(w<this.lines.maxLength){const g=this.lines.length-w;g>0&&(this.lines.trimStart(g),this.ybase=Math.max(this.ybase-g,0),this.ydisp=Math.max(this.ydisp-g,0),this.savedY=Math.max(this.savedY-g,0)),this.lines.maxLength=w}this.x=Math.min(this.x,u-1),this.y=Math.min(this.y,d-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,u-1),this.scrollTop=0}if(this.scrollBottom=d-1,this._isReflowEnabled&&(this._reflow(u,d),this._cols>u))for(let j=0;j<this.lines.length;j++)C+=+this.lines.get(j).resize(u,b);this._cols=u,this._rows=d,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let u=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,u=!1);let d=0;for(;this._memoryCleanupPosition<this.lines.length;)if(d+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),d>100)return!0;return u}get _isReflowEnabled(){const u=this._optionsService.rawOptions.windowsPty;return u&&u.buildNumber?this._hasScrollback&&u.backend==="conpty"&&u.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(u,d){this._cols!==u&&(u>this._cols?this._reflowLarger(u,d):this._reflowSmaller(u,d))}_reflowLarger(u,d){const b=(0,S.reflowLargerGetLinesToRemove)(this.lines,this._cols,u,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(b.length>0){const C=(0,S.reflowLargerCreateNewLayout)(this.lines,b);(0,S.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(u,d,C.countRemoved)}}_reflowLargerAdjustViewport(u,d,b){const C=this.getNullCell(p.DEFAULT_ATTR_DATA);let w=b;for(;w-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<d&&this.lines.push(new p.BufferLine(u,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(u,d){const b=this.getNullCell(p.DEFAULT_ATTR_DATA),C=[];let w=0;for(let j=this.lines.length-1;j>=0;j--){let g=this.lines.get(j);if(!g||!g.isWrapped&&g.getTrimmedLength()<=u)continue;const k=[g];for(;g.isWrapped&&j>0;)g=this.lines.get(--j),k.unshift(g);const R=this.ybase+this.y;if(R>=j&&R<j+k.length)continue;const D=k[k.length-1].getTrimmedLength(),M=(0,S.reflowSmallerGetNewLineLengths)(k,this._cols,u),N=M.length-k.length;let P;P=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+N):Math.max(0,this.lines.length-this.lines.maxLength+N);const B=[];for(let I=0;I<N;I++){const F=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);B.push(F)}B.length>0&&(C.push({start:j+k.length+w,newLines:B}),w+=B.length),k.push(...B);let z=M.length-1,W=M[z];W===0&&(z--,W=M[z]);let A=k.length-N-1,L=D;for(;A>=0;){const I=Math.min(L,W);if(k[z]===void 0)break;if(k[z].copyCellsFrom(k[A],L-I,W-I,I,!0),W-=I,W===0&&(z--,W=M[z]),L-=I,L===0){A--;const F=Math.max(A,0);L=(0,S.getWrappedLineTrimmedLength)(k,F,this._cols)}}for(let I=0;I<k.length;I++)M[I]<u&&k[I].setCell(M[I],b);let O=N-P;for(;O-- >0;)this.ybase===0?this.y<d-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+w)-d&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+N,this.ybase+d-1)}if(C.length>0){const j=[],g=[];for(let z=0;z<this.lines.length;z++)g.push(this.lines.get(z));const k=this.lines.length;let R=k-1,D=0,M=C[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+w);let N=0;for(let z=Math.min(this.lines.maxLength-1,k+w-1);z>=0;z--)if(M&&M.start>R+N){for(let W=M.newLines.length-1;W>=0;W--)this.lines.set(z--,M.newLines[W]);z++,j.push({index:R+1,amount:M.newLines.length}),N+=M.newLines.length,M=C[++D]}else this.lines.set(z,g[R--]);let P=0;for(let z=j.length-1;z>=0;z--)j[z].index+=P,this.lines.onInsertEmitter.fire(j[z]),P+=j[z].amount;const B=Math.max(0,k+w-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(u,d,b=0,C){const w=this.lines.get(u);return w?w.translateToString(d,b,C):""}getWrappedRangeForLine(u){let d=u,b=u;for(;d>0&&this.lines.get(d).isWrapped;)d--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:d,last:b}}setupTabStops(u){for(u!=null?this.tabs[u]||(u=this.prevStop(u)):(this.tabs={},u=0);u<this._cols;u+=this._optionsService.rawOptions.tabStopWidth)this.tabs[u]=!0}prevStop(u){for(u==null&&(u=this.x);!this.tabs[--u]&&u>0;);return u>=this._cols?this._cols-1:u<0?0:u}nextStop(u){for(u==null&&(u=this.x);!this.tabs[++u]&&u<this._cols;);return u>=this._cols?this._cols-1:u<0?0:u}clearMarkers(u){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].line===u&&(this.markers[d].dispose(),this.markers.splice(d--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].dispose(),this.markers.splice(u--,1);this._isClearing=!1}addMarker(u){const d=new o.Marker(u);return this.markers.push(d),d.register(this.lines.onTrim((b=>{d.line-=b,d.line<0&&d.dispose()}))),d.register(this.lines.onInsert((b=>{d.line>=b.index&&(d.line+=b.amount)}))),d.register(this.lines.onDelete((b=>{d.line>=b.index&&d.line<b.index+b.amount&&d.dispose(),d.line>b.index&&(d.line-=b.amount)}))),d.register(d.onDispose((()=>this._removeMarker(d)))),d}_removeMarker(u){this._isClearing||this.markers.splice(this.markers.indexOf(u),1)}}},8437:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=n(3734),f=n(511),a=n(643),p=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let S=0;class y{constructor(o,h,u=!1){this.isWrapped=u,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);const d=h||f.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let b=0;b<o;++b)this.setCell(b,d);this.length=o}get(o){const h=this._data[3*o+0],u=2097151&h;return[this._data[3*o+1],2097152&h?this._combined[o]:u?(0,p.stringFromCodePoint)(u):"",h>>22,2097152&h?this._combined[o].charCodeAt(this._combined[o].length-1):u]}set(o,h){this._data[3*o+1]=h[a.CHAR_DATA_ATTR_INDEX],h[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=h[1],this._data[3*o+0]=2097152|o|h[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=h[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){const h=this._data[3*o+0];return 2097152&h?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&h}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){const h=this._data[3*o+0];return 2097152&h?this._combined[o]:2097151&h?(0,p.stringFromCodePoint)(2097151&h):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,h){return S=3*o,h.content=this._data[S+0],h.fg=this._data[S+1],h.bg=this._data[S+2],2097152&h.content&&(h.combinedData=this._combined[o]),268435456&h.bg&&(h.extended=this._extendedAttrs[o]),h}setCell(o,h){2097152&h.content&&(this._combined[o]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[o]=h.extended),this._data[3*o+0]=h.content,this._data[3*o+1]=h.fg,this._data[3*o+2]=h.bg}setCellFromCodePoint(o,h,u,d,b,C){268435456&b&&(this._extendedAttrs[o]=C),this._data[3*o+0]=h|u<<22,this._data[3*o+1]=d,this._data[3*o+2]=b}addCodepointToCell(o,h){let u=this._data[3*o+0];2097152&u?this._combined[o]+=(0,p.stringFromCodePoint)(h):(2097151&u?(this._combined[o]=(0,p.stringFromCodePoint)(2097151&u)+(0,p.stringFromCodePoint)(h),u&=-2097152,u|=2097152):u=h|4194304,this._data[3*o+0]=u)}insertCells(o,h,u,d){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs),h<this.length-o){const b=new f.CellData;for(let C=this.length-o-h-1;C>=0;--C)this.setCell(o+h+C,this.loadCell(o+C,b));for(let C=0;C<h;++C)this.setCell(o+C,u)}else for(let b=o;b<this.length;++b)this.setCell(b,u);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs)}deleteCells(o,h,u,d){if(o%=this.length,h<this.length-o){const b=new f.CellData;for(let C=0;C<this.length-o-h;++C)this.setCell(o+C,this.loadCell(o+h+C,b));for(let C=this.length-h;C<this.length;++C)this.setCell(C,u)}else for(let b=o;b<this.length;++b)this.setCell(b,u);o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodePoint(o,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs)}replaceCells(o,h,u,d,b=!1){if(b)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodePoint(o-1,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs);o<h&&o<this.length;)this.isProtected(o)||this.setCell(o,u),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,d?.fg||0,d?.bg||0,d?.extended||new c.ExtendedAttrs);o<h&&o<this.length;)this.setCell(o++,u)}resize(o,h){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const u=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*u)this._data=new Uint32Array(this._data.buffer,0,u);else{const d=new Uint32Array(u);d.set(this._data),this._data=d}for(let d=this.length;d<o;++d)this.setCell(d,h)}else{this._data=this._data.subarray(0,u);const d=Object.keys(this._combined);for(let C=0;C<d.length;C++){const w=parseInt(d[C],10);w>=o&&delete this._combined[w]}const b=Object.keys(this._extendedAttrs);for(let C=0;C<b.length;C++){const w=parseInt(b[C],10);w>=o&&delete this._extendedAttrs[w]}}return this.length=o,4*u*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,h=!1){if(h)for(let u=0;u<this.length;++u)this.isProtected(u)||this.setCell(u,o);else{this._combined={},this._extendedAttrs={};for(let u=0;u<this.length;++u)this.setCell(u,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(const h in o._combined)this._combined[h]=o._combined[h];this._extendedAttrs={};for(const h in o._extendedAttrs)this._extendedAttrs[h]=o._extendedAttrs[h];this.isWrapped=o.isWrapped}clone(){const o=new y(0);o._data=new Uint32Array(this._data),o.length=this.length;for(const h in this._combined)o._combined[h]=this._combined[h];for(const h in this._extendedAttrs)o._extendedAttrs[h]=this._extendedAttrs[h];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,h,u,d,b){const C=o._data;if(b)for(let j=d-1;j>=0;j--){for(let g=0;g<3;g++)this._data[3*(u+j)+g]=C[3*(h+j)+g];268435456&C[3*(h+j)+2]&&(this._extendedAttrs[u+j]=o._extendedAttrs[h+j])}else for(let j=0;j<d;j++){for(let g=0;g<3;g++)this._data[3*(u+j)+g]=C[3*(h+j)+g];268435456&C[3*(h+j)+2]&&(this._extendedAttrs[u+j]=o._extendedAttrs[h+j])}const w=Object.keys(o._combined);for(let j=0;j<w.length;j++){const g=parseInt(w[j],10);g>=h&&(this._combined[g-h+u]=o._combined[g])}}translateToString(o=!1,h=0,u=this.length){o&&(u=Math.min(u,this.getTrimmedLength()));let d="";for(;h<u;){const b=this._data[3*h+0],C=2097151&b;d+=2097152&b?this._combined[h]:C?(0,p.stringFromCodePoint)(C):a.WHITESPACE_CELL_CHAR,h+=b>>22||1}return d}}i.BufferLine=y},4841:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,c){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return c*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(x,i)=>{function n(c,f,a){if(f===c.length-1)return c[f].getTrimmedLength();const p=!c[f].hasContent(a-1)&&c[f].getWidth(a-1)===1,S=c[f+1].getWidth(0)===2;return p&&S?a-1:a}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,f,a,p,S){const y=[];for(let _=0;_<c.length-1;_++){let o=_,h=c.get(++o);if(!h.isWrapped)continue;const u=[c.get(_)];for(;o<c.length&&h.isWrapped;)u.push(h),h=c.get(++o);if(p>=_&&p<o){_+=u.length-1;continue}let d=0,b=n(u,d,f),C=1,w=0;for(;C<u.length;){const g=n(u,C,f),k=g-w,R=a-b,D=Math.min(k,R);u[d].copyCellsFrom(u[C],w,b,D,!1),b+=D,b===a&&(d++,b=0),w+=D,w===g&&(C++,w=0),b===0&&d!==0&&u[d-1].getWidth(a-1)===2&&(u[d].copyCellsFrom(u[d-1],a-1,b++,1,!1),u[d-1].setCell(a-1,S))}u[d].replaceCells(b,a,S);let j=0;for(let g=u.length-1;g>0&&(g>d||u[g].getTrimmedLength()===0);g--)j++;j>0&&(y.push(_+u.length-j),y.push(j)),_+=u.length-1}return y},i.reflowLargerCreateNewLayout=function(c,f){const a=[];let p=0,S=f[p],y=0;for(let _=0;_<c.length;_++)if(S===_){const o=f[++p];c.onDeleteEmitter.fire({index:_-y,amount:o}),_+=o-1,y+=o,S=f[++p]}else a.push(_);return{layout:a,countRemoved:y}},i.reflowLargerApplyNewLayout=function(c,f){const a=[];for(let p=0;p<f.length;p++)a.push(c.get(f[p]));for(let p=0;p<a.length;p++)c.set(p,a[p]);c.length=f.length},i.reflowSmallerGetNewLineLengths=function(c,f,a){const p=[],S=c.map(((h,u)=>n(c,u,f))).reduce(((h,u)=>h+u));let y=0,_=0,o=0;for(;o<S;){if(S-o<a){p.push(S-o);break}y+=a;const h=n(c,_,f);y>h&&(y-=h,_++);const u=c[_].getWidth(y-1)===2;u&&y--;const d=u?a-1:a;p.push(d),o+=d}return p},i.getWrappedLineTrimmedLength=n},5295:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=n(8460),f=n(844),a=n(9092);class p extends f.Disposable{constructor(y,_){super(),this._optionsService=y,this._bufferService=_,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 a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.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(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),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(y,_){this._normal.resize(y,_),this._alt.resize(y,_),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=p},511:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=n(482),f=n(643),a=n(3734);class p extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const _=new p;return _.setFromCharData(y),_}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(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const o=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(o-55296)+h-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=p},643:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=n(8460),f=n(844);class a{get id(){return this._id}constructor(S){this.line=S,this.isDisposed=!1,this._disposables=[],this._id=a._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(S){return this._disposables.push(S),S}}i.Marker=a,a._nextId=1},7116:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(x,i)=>{var n,c,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(a){a.NUL="\0",a.SOH="",a.STX="",a.ETX="",a.EOT="",a.ENQ="",a.ACK="",a.BEL="\x07",a.BS="\b",a.HT=" ",a.LF=`
18
+ `,a.VT="\v",a.FF="\f",a.CR="\r",a.SO="",a.SI="",a.DLE="",a.DC1="",a.DC2="",a.DC3="",a.DC4="",a.NAK="",a.SYN="",a.ETB="",a.CAN="",a.EM="",a.SUB="",a.ESC="\x1B",a.FS="",a.GS="",a.RS="",a.US="",a.SP=" ",a.DEL=""})(n||(i.C0=n={})),(function(a){a.PAD="€",a.HOP="",a.BPH="‚",a.NBH="ƒ",a.IND="„",a.NEL="…",a.SSA="†",a.ESA="‡",a.HTS="ˆ",a.HTJ="‰",a.VTS="Š",a.PLD="‹",a.PLU="Œ",a.RI="",a.SS2="Ž",a.SS3="",a.DCS="",a.PU1="‘",a.PU2="’",a.STS="“",a.CCH="”",a.MW="•",a.SPA="–",a.EPA="—",a.SOS="˜",a.SGCI="™",a.SCI="š",a.CSI="›",a.ST="œ",a.OSC="",a.PM="ž",a.APC="Ÿ"})(c||(i.C1=c={})),(function(a){a.ST=`${n.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=n(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(a,p,S,y){const _={type:0,cancel:!1,key:void 0},o=(a.shiftKey?1:0)|(a.altKey?2:0)|(a.ctrlKey?4:0)|(a.metaKey?8:0);switch(a.keyCode){case 0:a.key==="UIKeyInputUpArrow"?_.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A":a.key==="UIKeyInputLeftArrow"?_.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D":a.key==="UIKeyInputRightArrow"?_.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C":a.key==="UIKeyInputDownArrow"&&(_.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(a.altKey){_.key=c.C0.ESC+c.C0.DEL;break}_.key=c.C0.DEL;break;case 9:if(a.shiftKey){_.key=c.C0.ESC+"[Z";break}_.key=c.C0.HT,_.cancel=!0;break;case 13:_.key=a.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,_.cancel=!0;break;case 27:_.key=c.C0.ESC,a.altKey&&(_.key=c.C0.ESC+c.C0.ESC),_.cancel=!0;break;case 37:if(a.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"D",_.key===c.C0.ESC+"[1;3D"&&(_.key=c.C0.ESC+(S?"b":"[1;5D"))):_.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(a.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"C",_.key===c.C0.ESC+"[1;3C"&&(_.key=c.C0.ESC+(S?"f":"[1;5C"))):_.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(a.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"A",S||_.key!==c.C0.ESC+"[1;3A"||(_.key=c.C0.ESC+"[1;5A")):_.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(a.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"B",S||_.key!==c.C0.ESC+"[1;3B"||(_.key=c.C0.ESC+"[1;5B")):_.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(_.key=c.C0.ESC+"[2~");break;case 46:_.key=o?c.C0.ESC+"[3;"+(o+1)+"~":c.C0.ESC+"[3~";break;case 36:_.key=o?c.C0.ESC+"[1;"+(o+1)+"H":p?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:_.key=o?c.C0.ESC+"[1;"+(o+1)+"F":p?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:a.shiftKey?_.type=2:a.ctrlKey?_.key=c.C0.ESC+"[5;"+(o+1)+"~":_.key=c.C0.ESC+"[5~";break;case 34:a.shiftKey?_.type=3:a.ctrlKey?_.key=c.C0.ESC+"[6;"+(o+1)+"~":_.key=c.C0.ESC+"[6~";break;case 112:_.key=o?c.C0.ESC+"[1;"+(o+1)+"P":c.C0.ESC+"OP";break;case 113:_.key=o?c.C0.ESC+"[1;"+(o+1)+"Q":c.C0.ESC+"OQ";break;case 114:_.key=o?c.C0.ESC+"[1;"+(o+1)+"R":c.C0.ESC+"OR";break;case 115:_.key=o?c.C0.ESC+"[1;"+(o+1)+"S":c.C0.ESC+"OS";break;case 116:_.key=o?c.C0.ESC+"[15;"+(o+1)+"~":c.C0.ESC+"[15~";break;case 117:_.key=o?c.C0.ESC+"[17;"+(o+1)+"~":c.C0.ESC+"[17~";break;case 118:_.key=o?c.C0.ESC+"[18;"+(o+1)+"~":c.C0.ESC+"[18~";break;case 119:_.key=o?c.C0.ESC+"[19;"+(o+1)+"~":c.C0.ESC+"[19~";break;case 120:_.key=o?c.C0.ESC+"[20;"+(o+1)+"~":c.C0.ESC+"[20~";break;case 121:_.key=o?c.C0.ESC+"[21;"+(o+1)+"~":c.C0.ESC+"[21~";break;case 122:_.key=o?c.C0.ESC+"[23;"+(o+1)+"~":c.C0.ESC+"[23~";break;case 123:_.key=o?c.C0.ESC+"[24;"+(o+1)+"~":c.C0.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if(S&&!y||!a.altKey||a.metaKey)!S||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.keyCode>=48&&a.key.length===1?_.key=a.key:a.key&&a.ctrlKey&&(a.key==="_"&&(_.key=c.C0.US),a.key==="@"&&(_.key=c.C0.NUL)):a.keyCode===65&&(_.type=1);else{const h=f[a.keyCode],u=h?.[a.shiftKey?1:0];if(u)_.key=c.C0.ESC+u;else if(a.keyCode>=65&&a.keyCode<=90){const d=a.ctrlKey?a.keyCode-64:a.keyCode+32;let b=String.fromCharCode(d);a.shiftKey&&(b=b.toUpperCase()),_.key=c.C0.ESC+b}else if(a.keyCode===32)_.key=c.C0.ESC+(a.ctrlKey?c.C0.NUL:" ");else if(a.key==="Dead"&&a.code.startsWith("Key")){let d=a.code.slice(3,4);a.shiftKey||(d=d.toLowerCase()),_.key=c.C0.ESC+d,_.cancel=!0}}else a.keyCode>=65&&a.keyCode<=90?_.key=String.fromCharCode(a.keyCode-64):a.keyCode===32?_.key=c.C0.NUL:a.keyCode>=51&&a.keyCode<=55?_.key=String.fromCharCode(a.keyCode-51+27):a.keyCode===56?_.key=c.C0.DEL:a.keyCode===219?_.key=c.C0.ESC:a.keyCode===220?_.key=c.C0.FS:a.keyCode===221&&(_.key=c.C0.GS)}return _}},482:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,c=0,f=n.length){let a="";for(let p=c;p<f;++p){let S=n[p];S>65535?(S-=65536,a+=String.fromCharCode(55296+(S>>10))+String.fromCharCode(S%1024+56320)):a+=String.fromCharCode(S)}return a},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,c){const f=n.length;if(!f)return 0;let a=0,p=0;if(this._interim){const S=n.charCodeAt(p++);56320<=S&&S<=57343?c[a++]=1024*(this._interim-55296)+S-56320+65536:(c[a++]=this._interim,c[a++]=S),this._interim=0}for(let S=p;S<f;++S){const y=n.charCodeAt(S);if(55296<=y&&y<=56319){if(++S>=f)return this._interim=y,a;const _=n.charCodeAt(S);56320<=_&&_<=57343?c[a++]=1024*(y-55296)+_-56320+65536:(c[a++]=y,c[a++]=_)}else y!==65279&&(c[a++]=y)}return a}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,c){const f=n.length;if(!f)return 0;let a,p,S,y,_=0,o=0,h=0;if(this.interim[0]){let b=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let w,j=0;for(;(w=63&this.interim[++j])&&j<4;)C<<=6,C|=w;const g=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=g-j;for(;h<k;){if(h>=f)return 0;if(w=n[h++],(192&w)!=128){h--,b=!0;break}this.interim[j++]=w,C<<=6,C|=63&w}b||(g===2?C<128?h--:c[_++]=C:g===3?C<2048||C>=55296&&C<=57343||C===65279||(c[_++]=C):C<65536||C>1114111||(c[_++]=C)),this.interim.fill(0)}const u=f-4;let d=h;for(;d<f;){for(;!(!(d<u)||128&(a=n[d])||128&(p=n[d+1])||128&(S=n[d+2])||128&(y=n[d+3]));)c[_++]=a,c[_++]=p,c[_++]=S,c[_++]=y,d+=4;if(a=n[d++],a<128)c[_++]=a;else if((224&a)==192){if(d>=f)return this.interim[0]=a,_;if(p=n[d++],(192&p)!=128){d--;continue}if(o=(31&a)<<6|63&p,o<128){d--;continue}c[_++]=o}else if((240&a)==224){if(d>=f)return this.interim[0]=a,_;if(p=n[d++],(192&p)!=128){d--;continue}if(d>=f)return this.interim[0]=a,this.interim[1]=p,_;if(S=n[d++],(192&S)!=128){d--;continue}if(o=(15&a)<<12|(63&p)<<6|63&S,o<2048||o>=55296&&o<=57343||o===65279)continue;c[_++]=o}else if((248&a)==240){if(d>=f)return this.interim[0]=a,_;if(p=n[d++],(192&p)!=128){d--;continue}if(d>=f)return this.interim[0]=a,this.interim[1]=p,_;if(S=n[d++],(192&S)!=128){d--;continue}if(d>=f)return this.interim[0]=a,this.interim[1]=p,this.interim[2]=S,_;if(y=n[d++],(192&y)!=128){d--;continue}if(o=(7&a)<<18|(63&p)<<12|(63&S)<<6|63&y,o<65536||o>1114111)continue;c[_++]=o}}return _}}},225:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],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 a=0;a<n.length;++a)f.fill(0,n[a][0],n[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?f[a]:(function(p,S){let y,_=0,o=S.length-1;if(p<S[0][0]||p>S[o][1])return!1;for(;o>=_;)if(y=_+o>>1,p>S[y][1])_=y+1;else{if(!(p<S[y][0]))return!0;o=y-1}return!1})(a,c)?0:a>=131072&&a<=196605||a>=196608&&a<=262141?2:1}}},5981:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=n(8460),f=n(844);class a extends f.Disposable{constructor(S){super(),this._action=S,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(S,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(S,y){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+=S.length,this._writeBuffer.push(S),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(y)}_innerWrite(S=0,y=!0){const _=S||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const o=this._writeBuffer[this._bufferOffset],h=this._action(o,y);if(h){const d=b=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(_,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(d)}const u=this._callbacks[this._bufferOffset];if(u&&u(),this._bufferOffset++,this._pendingData-=o.length,Date.now()-_>=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=a},5941:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c=/^[\da-f]+$/;function f(a,p){const S=a.toString(16),y=S.length<2?"0"+S:S;switch(p){case 4:return S[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(a){if(!a)return;let p=a.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const S=n.exec(p);if(S){const y=S[1]?15:S[4]?255:S[7]?4095:65535;return[Math.round(parseInt(S[1]||S[4]||S[7]||S[10],16)/y*255),Math.round(parseInt(S[2]||S[5]||S[8]||S[11],16)/y*255),Math.round(parseInt(S[3]||S[6]||S[9]||S[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),c.exec(p)&&[3,6,9,12].includes(p.length))){const S=p.length/3,y=[0,0,0];for(let _=0;_<3;++_){const o=parseInt(p.slice(S*_,S*_+S),16);y[_]=S===1?o<<4:S===2?o:S===3?o>>4:o>>8}return y}},i.toRgbString=function(a,p=16){const[S,y,_]=a;return`rgb:${f(S,p)}/${f(y,p)}/${f(_,p)}`}},5770:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=n(482),f=n(8742),a=n(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(y,_){this._handlers[y]===void 0&&(this._handlers[y]=[]);const o=this._handlers[y];return o.push(_),{dispose:()=>{const h=o.indexOf(_);h!==-1&&o.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(y,_){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(y,_,o){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,_,o);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,_,o))}unhook(y,_=!0){if(this._active.length){let o=!1,h=this._active.length-1,u=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,o=_,u=this._stack.fallThrough,this._stack.paused=!1),!u&&o===!1){for(;h>=0&&(o=this._active[h].unhook(y),o!==!0);h--)if(o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,o;h--}for(;h>=0;h--)if(o=this._active[h].unhook(!1),o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,o}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const S=new f.Params;S.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=S,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():S,this._data="",this._hitLimit=!1}put(y,_,o){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,_,o),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let _=!1;if(this._hitLimit)_=!1;else if(y&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((o=>(this._params=S,this._data="",this._hitLimit=!1,o)));return this._params=S,this._data="",this._hitLimit=!1,_}}},2015:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=n(844),f=n(8742),a=n(6242),p=n(6351);class S{constructor(h){this.table=new Uint8Array(h)}setDefault(h,u){this.table.fill(h<<4|u)}add(h,u,d,b){this.table[u<<8|h]=d<<4|b}addMany(h,u,d,b){for(let C=0;C<h.length;C++)this.table[u<<8|h[C]]=d<<4|b}}i.TransitionTable=S;const y=160;i.VT500_TRANSITION_TABLE=(function(){const o=new S(4095),h=Array.apply(null,Array(256)).map(((j,g)=>g)),u=(j,g)=>h.slice(j,g),d=u(32,127),b=u(0,24);b.push(25),b.push.apply(b,u(28,32));const C=u(0,14);let w;for(w in o.setDefault(1,0),o.addMany(d,0,2,0),C)o.addMany([24,26,153,154],w,3,0),o.addMany(u(128,144),w,3,0),o.addMany(u(144,152),w,3,0),o.add(156,w,0,0),o.add(27,w,11,1),o.add(157,w,4,8),o.addMany([152,158,159],w,0,7),o.add(155,w,11,3),o.add(144,w,11,9);return o.addMany(b,0,3,0),o.addMany(b,1,3,1),o.add(127,1,0,1),o.addMany(b,8,0,8),o.addMany(b,3,3,3),o.add(127,3,0,3),o.addMany(b,4,3,4),o.add(127,4,0,4),o.addMany(b,6,3,6),o.addMany(b,5,3,5),o.add(127,5,0,5),o.addMany(b,2,3,2),o.add(127,2,0,2),o.add(93,1,4,8),o.addMany(d,8,5,8),o.add(127,8,5,8),o.addMany([156,27,24,26,7],8,6,0),o.addMany(u(28,32),8,0,8),o.addMany([88,94,95],1,0,7),o.addMany(d,7,0,7),o.addMany(b,7,0,7),o.add(156,7,0,0),o.add(127,7,0,7),o.add(91,1,11,3),o.addMany(u(64,127),3,7,0),o.addMany(u(48,60),3,8,4),o.addMany([60,61,62,63],3,9,4),o.addMany(u(48,60),4,8,4),o.addMany(u(64,127),4,7,0),o.addMany([60,61,62,63],4,0,6),o.addMany(u(32,64),6,0,6),o.add(127,6,0,6),o.addMany(u(64,127),6,0,0),o.addMany(u(32,48),3,9,5),o.addMany(u(32,48),5,9,5),o.addMany(u(48,64),5,0,6),o.addMany(u(64,127),5,7,0),o.addMany(u(32,48),4,9,5),o.addMany(u(32,48),1,9,2),o.addMany(u(32,48),2,9,2),o.addMany(u(48,127),2,10,0),o.addMany(u(48,80),1,10,0),o.addMany(u(81,88),1,10,0),o.addMany([89,90,92],1,10,0),o.addMany(u(96,127),1,10,0),o.add(80,1,11,9),o.addMany(b,9,0,9),o.add(127,9,0,9),o.addMany(u(28,32),9,0,9),o.addMany(u(32,48),9,9,12),o.addMany(u(48,60),9,8,10),o.addMany([60,61,62,63],9,9,10),o.addMany(b,11,0,11),o.addMany(u(32,128),11,0,11),o.addMany(u(28,32),11,0,11),o.addMany(b,10,0,10),o.add(127,10,0,10),o.addMany(u(28,32),10,0,10),o.addMany(u(48,60),10,8,10),o.addMany([60,61,62,63],10,0,11),o.addMany(u(32,48),10,9,12),o.addMany(b,12,0,12),o.add(127,12,0,12),o.addMany(u(28,32),12,0,12),o.addMany(u(32,48),12,9,12),o.addMany(u(48,64),12,0,11),o.addMany(u(64,127),12,12,13),o.addMany(u(64,127),10,12,13),o.addMany(u(64,127),9,12,13),o.addMany(b,13,13,13),o.addMany(d,13,13,13),o.add(127,13,0,13),o.addMany([27,156,24,26],13,14,0),o.add(y,0,2,0),o.add(y,8,5,8),o.add(y,6,0,6),o.add(y,11,0,11),o.add(y,13,13,13),o})();class _ extends c.Disposable{constructor(h=i.VT500_TRANSITION_TABLE){super(),this._transitions=h,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=(u,d,b)=>{},this._executeHandlerFb=u=>{},this._csiHandlerFb=(u,d)=>{},this._escHandlerFb=u=>{},this._errorHandlerFb=u=>u,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 a.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,u=[64,126]){let d=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(d=h.prefix.charCodeAt(0),d&&60>d||d>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const w=h.intermediates.charCodeAt(C);if(32>w||w>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");d<<=8,d|=w}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(u[0]>b||b>u[1])throw new Error(`final must be in range ${u[0]} .. ${u[1]}`);return d<<=8,d|=b,d}identToString(h){const u=[];for(;h;)u.push(String.fromCharCode(255&h)),h>>=8;return u.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,u){const d=this._identifier(h,[48,126]);this._escHandlers[d]===void 0&&(this._escHandlers[d]=[]);const b=this._escHandlers[d];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,u){this._executeHandlers[h.charCodeAt(0)]=u}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,u){const d=this._identifier(h);this._csiHandlers[d]===void 0&&(this._csiHandlers[d]=[]);const b=this._csiHandlers[d];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,u){return this._dcsParser.registerHandler(this._identifier(h),u)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,u){return this._oscParser.registerHandler(h,u)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}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(h,u,d,b,C){this._parseStack.state=h,this._parseStack.handlers=u,this._parseStack.handlerPos=d,this._parseStack.transition=b,this._parseStack.chunkPos=C}parse(h,u,d){let b,C=0,w=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(d===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const g=this._parseStack.handlers;let k=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(d===!1&&k>-1){for(;k>=0&&(b=g[k](this._params),b!==!0);k--)if(b instanceof Promise)return this._parseStack.handlerPos=k,b}this._parseStack.handlers=[];break;case 4:if(d===!1&&k>-1){for(;k>=0&&(b=g[k](),b!==!0);k--)if(b instanceof Promise)return this._parseStack.handlerPos=k,b}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(C!==24&&C!==26,d),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],b=this._oscParser.end(C!==24&&C!==26,d),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let g=j;g<u;++g){switch(C=h[g],w=this._transitions.table[this.currentState<<8|(C<160?C:y)],w>>4){case 2:for(let N=g+1;;++N){if(N>=u||(C=h[N])<32||C>126&&C<y){this._printHandler(h,g,N),g=N-1;break}if(++N>=u||(C=h[N])<32||C>126&&C<y){this._printHandler(h,g,N),g=N-1;break}if(++N>=u||(C=h[N])<32||C>126&&C<y){this._printHandler(h,g,N),g=N-1;break}if(++N>=u||(C=h[N])<32||C>126&&C<y){this._printHandler(h,g,N),g=N-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:g,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const k=this._csiHandlers[this._collect<<8|C];let R=k?k.length-1:-1;for(;R>=0&&(b=k[R](this._params),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(3,k,R,w,g),b;R<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++g<u&&(C=h[g])>47&&C<60);g--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const D=this._escHandlers[this._collect<<8|C];let M=D?D.length-1:-1;for(;M>=0&&(b=D[M](),b!==!0);M--)if(b instanceof Promise)return this._preserveStack(4,D,M,w,g),b;M<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let N=g+1;;++N)if(N>=u||(C=h[N])===24||C===26||C===27||C>127&&C<y){this._dcsParser.put(h,g,N),g=N-1;break}break;case 14:if(b=this._dcsParser.unhook(C!==24&&C!==26),b)return this._preserveStack(6,[],0,w,g),b;C===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 N=g+1;;N++)if(N>=u||(C=h[N])<32||C>127&&C<y){this._oscParser.put(h,g,N),g=N-1;break}break;case 6:if(b=this._oscParser.end(C!==24&&C!==26),b)return this._preserveStack(5,[],0,w,g),b;C===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&w}}}i.EscapeSequenceParser=_},6242:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=n(5770),f=n(482),a=[];i.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,S){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(S),{dispose:()=>{const _=y.indexOf(S);_!==-1&&y.splice(_,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=a}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=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,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,S,y){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(p,S,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,S,y))}start(){this.reset(),this._state=1}put(p,S,y){if(this._state!==3){if(this._state===1)for(;S<y;){const _=p[S++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&y-S>0&&this._put(p,S,y)}}end(p,S=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,_=this._active.length-1,o=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,y=S,o=this._stack.fallThrough,this._stack.paused=!1),!o&&y===!1){for(;_>=0&&(y=this._active[_].end(p),y!==!0);_--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,y;_--}for(;_>=0;_--)if(y=this._active[_].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",p);this._active=a,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,S,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,S,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let S=!1;if(this._hitLimit)S=!1;else if(p&&(S=this._handler(this._data),S instanceof Promise))return S.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,S}}},8742:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class c{static fromArray(a){const p=new c;if(!a.length)return p;for(let S=Array.isArray(a[0])?1:0;S<a.length;++S){const y=a[S];if(Array.isArray(y))for(let _=0;_<y.length;++_)p.addSubParam(y[_]);else p.addParam(y)}return p}constructor(a=32,p=32){if(this.maxLength=a,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const a=new c(this.maxLength,this.maxSubParamsLength);return a.params.set(this.params),a.length=this.length,a._subParams.set(this._subParams),a._subParamsLength=this._subParamsLength,a._subParamsIdx.set(this._subParamsIdx),a._rejectDigits=this._rejectDigits,a._rejectSubDigits=this._rejectSubDigits,a._digitIsSub=this._digitIsSub,a}toArray(){const a=[];for(let p=0;p<this.length;++p){a.push(this.params[p]);const S=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-S>0&&a.push(Array.prototype.slice.call(this._subParams,S,y))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>n?n:a}}addSubParam(a){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>n?n:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){const p=this._subParamsIdx[a]>>8,S=255&this._subParamsIdx[a];return S-p>0?this._subParams.subarray(p,S):null}getSubParamsAll(){const a={};for(let p=0;p<this.length;++p){const S=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-S>0&&(a[p]=this._subParams.slice(S,y))}return a}addDigit(a){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const S=this._digitIsSub?this._subParams:this.params,y=S[p-1];S[p-1]=~y?Math.min(10*y+a,n):a}}i.Params=c},5741:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===n){c=f;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(c,1)}}},8771:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=n(3785),f=n(511);i.BufferApiView=class{constructor(a,p){this._buffer=a,this.type=p}init(a){return this._buffer=a,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(a){const p=this._buffer.lines.get(a);if(p)return new c.BufferLineApiView(p)}getNullCell(){return new f.CellData}}},3785:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=n(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,a){if(!(f<0||f>=this._line.length))return a?(this._line.loadCell(f,a),a):this._line.loadCell(f,new c.CellData)}translateToString(f,a,p){return this._line.translateToString(f,a,p)}}},8285:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=n(8771),f=n(8460),a=n(844);class p extends a.Disposable{constructor(y){super(),this._core=y,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:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,c){return this._core.registerCsiHandler(n,(f=>c(f.toArray())))}addCsiHandler(n,c){return this.registerCsiHandler(n,c)}registerDcsHandler(n,c){return this._core.registerDcsHandler(n,((f,a)=>c(f,a.toArray())))}addDcsHandler(n,c){return this.registerDcsHandler(n,c)}registerEscHandler(n,c){return this._core.registerEscHandler(n,c)}addEscHandler(n,c){return this.registerEscHandler(n,c)}registerOscHandler(n,c){return this._core.registerOscHandler(n,c)}addOscHandler(n,c){return this.registerOscHandler(n,c)}}},7090:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(x,i,n){var c=this&&this.__decorate||function(o,h,u,d){var b,C=arguments.length,w=C<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(o,h,u,d);else for(var j=o.length-1;j>=0;j--)(b=o[j])&&(w=(C<3?b(w):C>3?b(h,u,w):b(h,u))||w);return C>3&&w&&Object.defineProperty(h,u,w),w},f=this&&this.__param||function(o,h){return function(u,d){h(u,d,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const a=n(8460),p=n(844),S=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let _=i.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(o){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(o.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(o.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new S.BufferSet(o,this))}resize(o,h){this.cols=o,this.rows=h,this.buffers.resize(o,h),this._onResize.fire({cols:o,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(o,h=!1){const u=this.buffer;let d;d=this._cachedBlankLine,d&&d.length===this.cols&&d.getFg(0)===o.fg&&d.getBg(0)===o.bg||(d=u.getBlankLine(o,h),this._cachedBlankLine=d),d.isWrapped=h;const b=u.ybase+u.scrollTop,C=u.ybase+u.scrollBottom;if(u.scrollTop===0){const w=u.lines.isFull;C===u.lines.length-1?w?u.lines.recycle().copyFrom(d):u.lines.push(d.clone()):u.lines.splice(C+1,0,d.clone()),w?this.isUserScrolling&&(u.ydisp=Math.max(u.ydisp-1,0)):(u.ybase++,this.isUserScrolling||u.ydisp++)}else{const w=C-b+1;u.lines.shiftElements(b+1,w-1,-1),u.lines.set(C,d.clone())}this.isUserScrolling||(u.ydisp=u.ybase),this._onScroll.fire(u.ydisp)}scrollLines(o,h,u){const d=this.buffer;if(o<0){if(d.ydisp===0)return;this.isUserScrolling=!0}else o+d.ydisp>=d.ybase&&(this.isUserScrolling=!1);const b=d.ydisp;d.ydisp=Math.max(Math.min(d.ydisp+o,d.ybase),0),b!==d.ydisp&&(h||this._onScroll.fire(d.ydisp))}};i.BufferService=_=c([f(0,y.IOptionsService)],_)},7994:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,c){this._charsets[n]=c,this.glevel===n&&(this.charset=c)}}},1753:function(x,i,n){var c=this&&this.__decorate||function(d,b,C,w){var j,g=arguments.length,k=g<3?b:w===null?w=Object.getOwnPropertyDescriptor(b,C):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(d,b,C,w);else for(var R=d.length-1;R>=0;R--)(j=d[R])&&(k=(g<3?j(k):g>3?j(b,C,k):j(b,C))||k);return g>3&&k&&Object.defineProperty(b,C,k),k},f=this&&this.__param||function(d,b){return function(C,w){b(C,w,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const a=n(2585),p=n(8460),S=n(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:d=>d.button!==4&&d.action===1&&(d.ctrl=!1,d.alt=!1,d.shift=!1,!0)},VT200:{events:19,restrict:d=>d.action!==32},DRAG:{events:23,restrict:d=>d.action!==32||d.button!==3},ANY:{events:31,restrict:d=>!0}};function _(d,b){let C=(d.ctrl?16:0)|(d.shift?4:0)|(d.alt?8:0);return d.button===4?(C|=64,C|=d.action):(C|=3&d.button,4&d.button&&(C|=64),8&d.button&&(C|=128),d.action===32?C|=32:d.action!==0||b||(C|=3)),C}const o=String.fromCharCode,h={DEFAULT:d=>{const b=[_(d,!1)+32,d.col+32,d.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${o(b[0])}${o(b[1])}${o(b[2])}`},SGR:d=>{const b=d.action===0&&d.button!==4?"m":"M";return`\x1B[<${_(d,!0)};${d.col};${d.row}${b}`},SGR_PIXELS:d=>{const b=d.action===0&&d.button!==4?"m":"M";return`\x1B[<${_(d,!0)};${d.x};${d.y}${b}`}};let u=i.CoreMouseService=class extends S.Disposable{constructor(d,b){super(),this._bufferService=d,this._coreService=b,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 C of Object.keys(y))this.addProtocol(C,y[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(d,b){this._protocols[d]=b}addEncoding(d,b){this._encodings[d]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(d){if(!this._protocols[d])throw new Error(`unknown protocol "${d}"`);this._activeProtocol=d,this._onProtocolChange.fire(this._protocols[d].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(d){if(!this._encodings[d])throw new Error(`unknown encoding "${d}"`);this._activeEncoding=d}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(d){if(d.col<0||d.col>=this._bufferService.cols||d.row<0||d.row>=this._bufferService.rows||d.button===4&&d.action===32||d.button===3&&d.action!==32||d.button!==4&&(d.action===2||d.action===3)||(d.col++,d.row++,d.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,d,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(d))return!1;const b=this._encodings[this._activeEncoding](d);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=d,!0}explainEvents(d){return{down:!!(1&d),up:!!(2&d),drag:!!(4&d),move:!!(8&d),wheel:!!(16&d)}}_equalEvents(d,b,C){if(C){if(d.x!==b.x||d.y!==b.y)return!1}else if(d.col!==b.col||d.row!==b.row)return!1;return d.button===b.button&&d.action===b.action&&d.ctrl===b.ctrl&&d.alt===b.alt&&d.shift===b.shift}};i.CoreMouseService=u=c([f(0,a.IBufferService),f(1,a.ICoreService)],u)},6975:function(x,i,n){var c=this&&this.__decorate||function(u,d,b,C){var w,j=arguments.length,g=j<3?d:C===null?C=Object.getOwnPropertyDescriptor(d,b):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(u,d,b,C);else for(var k=u.length-1;k>=0;k--)(w=u[k])&&(g=(j<3?w(g):j>3?w(d,b,g):w(d,b))||g);return j>3&&g&&Object.defineProperty(d,b,g),g},f=this&&this.__param||function(u,d){return function(b,C){d(b,C,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const a=n(1439),p=n(8460),S=n(844),y=n(2585),_=Object.freeze({insertMode:!1}),o=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends S.Disposable{constructor(u,d,b){super(),this._bufferService=u,this._logService=d,this._optionsService=b,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,a.clone)(_),this.decPrivateModes=(0,a.clone)(o)}reset(){this.modes=(0,a.clone)(_),this.decPrivateModes=(0,a.clone)(o)}triggerDataEvent(u,d=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;d&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),d&&this._onUserInput.fire(),this._logService.debug(`sending data "${u}"`,(()=>u.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(u)}triggerBinaryEvent(u){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${u}"`,(()=>u.split("").map((d=>d.charCodeAt(0))))),this._onBinary.fire(u))}};i.CoreService=h=c([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],h)},9074:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=n(8055),f=n(8460),a=n(844),p=n(6106);let S=0,y=0;class _ extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((u=>u?.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,a.toDisposable)((()=>this.reset())))}registerDecoration(u){if(u.marker.isDisposed)return;const d=new o(u);if(d){const b=d.marker.onDispose((()=>d.dispose()));d.onDispose((()=>{d&&(this._decorations.delete(d)&&this._onDecorationRemoved.fire(d),b.dispose())})),this._decorations.insert(d),this._onDecorationRegistered.fire(d)}return d}reset(){for(const u of this._decorations.values())u.dispose();this._decorations.clear()}*getDecorationsAtCell(u,d,b){var C,w,j;let g=0,k=0;for(const R of this._decorations.getKeyIterator(d))g=(C=R.options.x)!==null&&C!==void 0?C:0,k=g+((w=R.options.width)!==null&&w!==void 0?w:1),u>=g&&u<k&&(!b||((j=R.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&(yield R)}forEachDecorationAtCell(u,d,b,C){this._decorations.forEachByKey(d,(w=>{var j,g,k;S=(j=w.options.x)!==null&&j!==void 0?j:0,y=S+((g=w.options.width)!==null&&g!==void 0?g:1),u>=S&&u<y&&(!b||((k=w.options.layer)!==null&&k!==void 0?k:"bottom")===b)&&C(w)}))}}i.DecorationService=_;class o extends a.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(u){super(),this.options=u,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=u.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=n(2585),f=n(8343);class a{constructor(...S){this._entries=new Map;for(const[y,_]of S)this.set(y,_)}set(S,y){const _=this._entries.get(S);return this._entries.set(S,y),_}forEach(S){for(const[y,_]of this._entries.entries())S(y,_)}has(S){return this._entries.has(S)}get(S){return this._entries.get(S)}}i.ServiceCollection=a,i.InstantiationService=class{constructor(){this._services=new a,this._services.set(c.IInstantiationService,this)}setService(p,S){this._services.set(p,S)}getService(p){return this._services.get(p)}createInstance(p,...S){const y=(0,f.getServiceDependencies)(p).sort(((h,u)=>h.index-u.index)),_=[];for(const h of y){const u=this._services.get(h.id);if(!u)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${h.id}.`);_.push(u)}const o=y.length>0?y[0].index:S.length;if(S.length!==o)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${o+1} conflicts with ${S.length} static arguments`);return new p(...S,..._)}}},7866:function(x,i,n){var c=this&&this.__decorate||function(o,h,u,d){var b,C=arguments.length,w=C<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(o,h,u,d);else for(var j=o.length-1;j>=0;j--)(b=o[j])&&(w=(C<3?b(w):C>3?b(h,u,w):b(h,u))||w);return C>3&&w&&Object.defineProperty(h,u,w),w},f=this&&this.__param||function(o,h){return function(u,d){h(u,d,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const a=n(844),p=n(2585),S={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 y,_=i.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(o){super(),this._optionsService=o,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=S[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(o){for(let h=0;h<o.length;h++)typeof o[h]=="function"&&(o[h]=o[h]())}_log(o,h,u){this._evalLazyOptionalParams(u),o.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...u)}trace(o,...h){var u,d;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((d=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.trace.bind(this._optionsService.options.logger))!==null&&d!==void 0?d:console.log,o,h)}debug(o,...h){var u,d;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((d=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.debug.bind(this._optionsService.options.logger))!==null&&d!==void 0?d:console.log,o,h)}info(o,...h){var u,d;this._logLevel<=p.LogLevelEnum.INFO&&this._log((d=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.info.bind(this._optionsService.options.logger))!==null&&d!==void 0?d:console.info,o,h)}warn(o,...h){var u,d;this._logLevel<=p.LogLevelEnum.WARN&&this._log((d=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.warn.bind(this._optionsService.options.logger))!==null&&d!==void 0?d:console.warn,o,h)}error(o,...h){var u,d;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((d=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.error.bind(this._optionsService.options.logger))!==null&&d!==void 0?d:console.error,o,h)}};i.LogService=_=c([f(0,p.IOptionsService)],_),i.setTraceLogger=function(o){y=o},i.traceCall=function(o,h,u){if(typeof u.value!="function")throw new Error("not supported");const d=u.value;u.value=function(...b){if(y.logLevel!==p.LogLevelEnum.TRACE)return d.apply(this,b);y.trace(`GlyphRenderer#${d.name}(${b.map((w=>JSON.stringify(w))).join(", ")})`);const C=d.apply(this,b);return y.trace(`GlyphRenderer#${d.name} return`,C),C}}},7302:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=n(8460),f=n(844),a=n(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:a.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 S extends f.Disposable{constructor(_){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const o=Object.assign({},i.DEFAULT_OPTIONS);for(const h in _)if(h in o)try{const u=_[h];o[h]=this._sanitizeAndValidateOption(h,u)}catch(u){console.error(u)}this.rawOptions=o,this.options=Object.assign({},o),this._setupOptions()}onSpecificOptionChange(_,o){return this.onOptionChange((h=>{h===_&&o(this.rawOptions[_])}))}onMultipleOptionChange(_,o){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&o()}))}_setupOptions(){const _=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},o=(h,u)=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);u=this._sanitizeAndValidateOption(h,u),this.rawOptions[h]!==u&&(this.rawOptions[h]=u,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const u={get:_.bind(this,h),set:o.bind(this,h)};Object.defineProperty(this.options,h,u)}}_sanitizeAndValidateOption(_,o){switch(_){case"cursorStyle":if(o||(o=i.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(o))throw new Error(`"${o}" is not a valid value for ${_}`);break;case"wordSeparator":o||(o=i.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1e3)break;o=p.includes(o)?o:i.DEFAULT_OPTIONS[_];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw new Error(`${_} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw new Error(`${_} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}i.OptionsService=S},2660:function(x,i,n){var c=this&&this.__decorate||function(S,y,_,o){var h,u=arguments.length,d=u<3?y:o===null?o=Object.getOwnPropertyDescriptor(y,_):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(S,y,_,o);else for(var b=S.length-1;b>=0;b--)(h=S[b])&&(d=(u<3?h(d):u>3?h(y,_,d):h(y,_))||d);return u>3&&d&&Object.defineProperty(y,_,d),d},f=this&&this.__param||function(S,y){return function(_,o){y(_,o,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const a=n(2585);let p=i.OscLinkService=class{constructor(S){this._bufferService=S,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(S){const y=this._bufferService.buffer;if(S.id===void 0){const b=y.addMarker(y.ybase+y.y),C={data:S,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(C,b))),this._dataByLinkId.set(C.id,C),C.id}const _=S,o=this._getEntryIdKey(_),h=this._entriesWithId.get(o);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const u=y.addMarker(y.ybase+y.y),d={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[u]};return u.onDispose((()=>this._removeMarkerFromLink(d,u))),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(S,y){const _=this._dataByLinkId.get(S);if(_&&_.lines.every((o=>o.line!==y))){const o=this._bufferService.buffer.addMarker(y);_.lines.push(o),o.onDispose((()=>this._removeMarkerFromLink(_,o)))}}getLinkData(S){var y;return(y=this._dataByLinkId.get(S))===null||y===void 0?void 0:y.data}_getEntryIdKey(S){return`${S.id};;${S.uri}`}_removeMarkerFromLink(S,y){const _=S.lines.indexOf(y);_!==-1&&(S.lines.splice(_,1),S.lines.length===0&&(S.data.id!==void 0&&this._entriesWithId.delete(S.key),this._dataByLinkId.delete(S.id)))}};i.OscLinkService=p=c([f(0,a.IBufferService)],p)},8343:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[c]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const a=function(p,S,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,o,h){o[n]===o?o[c].push({id:_,index:h}):(o[c]=[{id:_,index:h}],o[n]=o)})(a,p,y)};return a.toString=()=>f,i.serviceRegistry.set(f,a),a}},2585:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const c=n(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(a){a[a.TRACE=0]="TRACE",a[a.DEBUG=1]="DEBUG",a[a.INFO=2]="INFO",a[a.WARN=3]="WARN",a[a.ERROR=4]="ERROR",a[a.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:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=n(8460),f=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const a=new f.UnicodeV6;this.register(a),this._active=a.version,this._activeProvider=a}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw new Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(a){let p=0;const S=a.length;for(let y=0;y<S;++y){let _=a.charCodeAt(y);if(55296<=_&&_<=56319){if(++y>=S)return p+this.wcwidth(_);const o=a.charCodeAt(y);56320<=o&&o<=57343?_=1024*(_-55296)+o-56320+65536:p+=this.wcwidth(o)}p+=this.wcwidth(_)}return p}}}},l={};function m(x){var i=l[x];if(i!==void 0)return i.exports;var n=l[x]={exports:{}};return s[x].call(n.exports,n,n.exports,m),n.exports}var v={};return(()=>{var x=v;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;const i=m(9042),n=m(3236),c=m(844),f=m(5741),a=m(8285),p=m(7975),S=m(7090),y=["cols","rows"];class _ extends c.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const u=b=>this._core.options[b],d=(b,C)=>{this._checkReadonlyOptions(b),this._core.options[b]=C};for(const b in this._core.options){const C={get:u.bind(this,b),set:d.bind(this,b)};Object.defineProperty(this._publicOptions,b,C)}}_checkReadonlyOptions(h){if(y.includes(h))throw new Error(`Option "${h}" 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 S.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 a.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let u="none";switch(this._core.coreMouseService.activeProtocol){case"X10":u="x10";break;case"VT200":u="vt200";break;case"DRAG":u="drag";break;case"ANY":u="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:u,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const u in h)this._publicOptions[u]=h[u]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,u){this._verifyIntegers(h,u),this._core.resize(h,u)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var u,d,b;return this._checkProposedApi(),this._verifyPositiveIntegers((u=h.x)!==null&&u!==void 0?u:0,(d=h.width)!==null&&d!==void 0?d:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,u,d){this._verifyIntegers(h,u,d),this._core.select(h,u,d)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,u){this._verifyIntegers(h,u),this._core.selectLines(h,u)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,u){this._core.write(h,u)}writeln(h,u){this._core.write(h),this._core.write(`\r
19
+ `,u)}paste(h){this._core.paste(h)}refresh(h,u){this._verifyIntegers(h,u),this._core.refresh(h,u)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return i}_verifyIntegers(...h){for(const u of h)if(u===1/0||isNaN(u)||u%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const u of h)if(u&&(u===1/0||isNaN(u)||u%1!=0||u<0))throw new Error("This API only accepts positive integers")}}x.Terminal=_})(),v})()))})(Rr)),Rr.exports}var Uu=$u();var qu=2,Ku=1,Xu=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),l=parseInt(s.getPropertyValue("height")),m=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),x={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=x.top+x.bottom,n=x.right+x.left,c=l-i,f=m-n-t;return{cols:Math.max(qu,Math.floor(f/e.css.cell.width)),rows:Math.max(Ku,Math.floor(c/e.css.cell.height))}}};function Yu(e={}){const{cwd:t,cols:s,rows:l,onOutput:m,onExit:v}=e,[x,i]=E.useState(null),[n,c]=E.useState(()=>Pt.isConnected()),[f,a]=E.useState(!1),[p,S]=E.useState(!1),[y,_]=E.useState(!1),o=E.useRef({onOutput:m,onExit:v});o.current={onOutput:m,onExit:v};const h=E.useRef(null);h.current=x,E.useEffect(()=>{if(!x)return;const w=Pt.getSocket(),j=()=>{c(!0),a(!1),i(null),_(!0)},g=()=>{c(!1),a(!1)},k=N=>{N.terminalId===x&&o.current.onOutput?.(N.data)},R=N=>{N.terminalId===x&&(a(!1),o.current.onExit?.(N.exitCode),i(null))},D=N=>{N.terminalId===x&&a(!0)},M=N=>{N.terminalId===x&&a(!1)};return w.on("connect",j),w.on("disconnect",g),w.on(Je.TERMINAL_STDOUT,k),w.on(Je.TERMINAL_EXIT,R),w.on(Je.TERMINAL_SUBSCRIBED,D),w.on(Je.TERMINAL_UNSUBSCRIBED,M),c(w.connected),w.connected&&w.emit(Zt.SUBSCRIBE,{topic:"terminal",id:x},N=>{N.success&&a(!0)}),()=>{w.off("connect",j),w.off("disconnect",g),w.off(Je.TERMINAL_STDOUT,k),w.off(Je.TERMINAL_EXIT,R),w.off(Je.TERMINAL_SUBSCRIBED,D),w.off(Je.TERMINAL_UNSUBSCRIBED,M),w.emit(Zt.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const u=E.useCallback(async()=>{const w=Pt.getSocket();if(!w.connected)return null;S(!0);try{const j=await ue.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:l});return i(j.terminalId),_(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{S(!1)}},[t,s,l]),d=E.useCallback(async()=>{const w=h.current;if(w){try{await ue.delete(`/terminals/${w}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),a(!1)}},[]),b=E.useCallback(w=>{const j=h.current;if(!j)return;Pt.getSocket().emit(Zt.TERMINAL_INPUT,{terminalId:j,data:w})},[]),C=E.useCallback((w,j)=>{const g=h.current;if(!g)return;Pt.getSocket().emit(Zt.TERMINAL_RESIZE,{terminalId:g,cols:w,rows:j})},[]);return E.useEffect(()=>()=>{const w=h.current;w&&ue.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:x,isConnected:n,isAttached:f,isCreating:p,needsRecreate:y,create:u,destroy:d,sendInput:b,resize:C}}const Vu={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"},Gu=re.memo(function({cwd:t,onExit:s,onReady:l}){const m=E.useRef(null),v=E.useRef(null),x=E.useRef(null),i=E.useRef(!1),{terminalId:n,isAttached:c,needsRecreate:f,create:a,sendInput:p,resize:S}=Yu({cwd:t,onOutput:E.useCallback(y=>{v.current?.write(y)},[]),onExit:E.useCallback(y=>{v.current?.writeln(`\r
20
+ \x1B[90m[Process exited with code ${y}]\x1B[0m`),s?.(y)},[s])});return E.useEffect(()=>{if(!f)return;const y=v.current;y&&y.writeln(`\r
21
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),a()},[f,a]),E.useLayoutEffect(()=>{if(!m.current)return;const y=new Uu.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Vu,scrollback:5e3,convertEol:!0}),_=new Xu;y.loadAddon(_),y.open(m.current);const o=(h=0)=>{if(!(h>=5))try{const d=m.current;if(!d||d.clientWidth===0||d.clientHeight===0){setTimeout(()=>o(h+1),50);return}_.fit(),S(y.cols,y.rows)}catch{setTimeout(()=>o(h+1),50)}};return o(0),setTimeout(()=>o(1),100),v.current=y,x.current=_,()=>{y.dispose(),v.current=null,x.current=null}},[S]),E.useEffect(()=>{i.current||(i.current=!0,a())},[a]),E.useEffect(()=>{const y=v.current;if(!y||!c)return;const _=y.onData(o=>{p(o)});return()=>_.dispose()},[p,c]),E.useEffect(()=>{c&&l?.({sendInput:p})},[c,p,l]),E.useEffect(()=>{if(!m.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const _=x.current,o=v.current,h=m.current;_&&o&&h&&h.clientWidth>0&&h.clientHeight>0&&(_.fit(),S(o.cols,o.rows))}catch{}})});return y.observe(m.current),()=>y.disconnect()},[S]),r.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),r.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Qu=re.memo(function({commands:t,onSelect:s}){const{t:l}=ae(),[m,v]=E.useState(!1),x=E.useRef(null),i=E.useRef(null);return E.useEffect(()=>{if(!m)return;const n=c=>{x.current&&!x.current.contains(c.target)&&i.current&&!i.current.contains(c.target)&&v(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[m]),t.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),r.jsxs("div",{className:"relative",children:[r.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:[r.jsx(vc,{size:12}),r.jsx("span",{children:l("快捷命令")}),r.jsx(jt,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&r.jsx("div",{ref:x,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:r.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((n,c)=>r.jsxs("button",{onClick:()=>{s(n.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:[r.jsx(Kt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),r.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},c))})})]})]})});let Ar=0;function hn(){return Ar+=1,{id:`shell-${Ar}`,order:Ar}}const Zu=re.memo(function({cwd:t,quickCommands:s=[]}){const{t:l}=ae(),[m,v]=E.useState(()=>[hn()]),[x,i]=E.useState(()=>m[0].id),n=E.useRef(new Map),c=E.useCallback(()=>{const y=hn();v(_=>[..._,y]),i(y.id)},[]),f=E.useCallback((y,_)=>{_.stopPropagation(),n.current.delete(y),v(o=>{const h=o.filter(u=>u.id!==y);return y===x&&h.length>0&&i(h[h.length-1].id),h})},[x]),a=E.useCallback(y=>{n.current.delete(y),v(_=>{const o=_.filter(h=>h.id!==y);return y===x&&o.length>0&&i(o[o.length-1].id),o})},[x]),p=E.useCallback((y,_)=>{n.current.set(y,_.sendInput)},[]),S=E.useCallback(y=>{const _=n.current.get(x);_&&_(y+"\r")},[x]);return r.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[r.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[r.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:m.map(y=>r.jsxs("button",{onClick:()=>i(y.id),className:ne("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",y.id===x?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[r.jsx($s,{size:11,className:"shrink-0"}),r.jsx("span",{children:l("Shell {count}",{count:y.order})}),m.length>1&&r.jsx("span",{onClick:_=>f(y.id,_),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:r.jsx(Cs,{size:10})})]},y.id))}),r.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:l("New Terminal"),children:r.jsx(vs,{size:14})}),s.length>0&&r.jsx(Qu,{commands:s,onSelect:S})]}),r.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.length===0?r.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx($s,{size:28}),r.jsx("span",{className:"text-xs",children:l("No terminals open")}),r.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:l("New Terminal")})]})}):m.map(y=>r.jsx("div",{className:"absolute inset-0",style:{display:y.id===x?"block":"none"},children:r.jsx(Gu,{cwd:t,onExit:()=>a(y.id),onReady:_=>p(y.id,_)})},y.id))})]})});function fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,l=Array(t);s<t;s++)l[s]=e[s];return l}function Ju(e){if(Array.isArray(e))return e}function eh(e,t,s){return(t=ah(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function th(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,m,v,x,i=[],n=!0,c=!1;try{if(v=(s=s.call(e)).next,t!==0)for(;!(n=(l=v.call(s)).done)&&(i.push(l.value),i.length!==t);n=!0);}catch(f){c=!0,m=f}finally{try{if(!n&&s.return!=null&&(x=s.return(),Object(x)!==x))return}finally{if(c)throw m}}return i}}function sh(){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 mn(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,l)}return s}function pn(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?mn(Object(s),!0).forEach(function(l){eh(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):mn(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function rh(e,t){if(e==null)return{};var s,l,m=ih(e,t);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(l=0;l<v.length;l++)s=v[l],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(m[s]=e[s])}return m}function ih(e,t){if(e==null)return{};var s={};for(var l in e)if({}.hasOwnProperty.call(e,l)){if(t.indexOf(l)!==-1)continue;s[l]=e[l]}return s}function nh(e,t){return Ju(e)||th(e,t)||lh(e,t)||sh()}function oh(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var l=s.call(e,t);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ah(e){var t=oh(e,"string");return typeof t=="symbol"?t:t+""}function lh(e,t){if(e){if(typeof e=="string")return fn(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)?fn(e,t):void 0}}function ch(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function vn(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,l)}return s}function gn(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?vn(Object(s),!0).forEach(function(l){ch(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):vn(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function dh(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(l){return t.reduceRight(function(m,v){return v(m)},l)}}function ds(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),v=0;v<l;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return t.apply(s,[].concat(m,i))}}}function Gs(e){return{}.toString.call(e).includes("Object")}function uh(e){return!Object.keys(e).length}function ys(e){return typeof e=="function"}function hh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function fh(e,t){return Gs(t)||It("changeType"),Object.keys(t).some(function(s){return!hh(e,s)})&&It("changeField"),t}function mh(e){ys(e)||It("selectorType")}function ph(e){ys(e)||Gs(e)||It("handlerType"),Gs(e)&&Object.values(e).some(function(t){return!ys(t)})&&It("handlersType")}function vh(e){e||It("initialIsRequired"),Gs(e)||It("initialType"),uh(e)&&It("initialContent")}function gh(e,t){throw new Error(e[t]||e.default)}var _h={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"},It=ds(gh)(_h),Ls={changes:fh,selector:mh,handler:ph,initial:vh};function xh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ls.initial(e),Ls.handler(t);var s={current:e},l=ds(yh)(s,t),m=ds(Sh)(s),v=ds(Ls.changes)(e),x=ds(bh)(s);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return Ls.selector(c),c(s.current)}function n(c){dh(l,m,v,x)(c)}return[i,n]}function bh(e,t){return ys(t)?t(e.current):t}function Sh(e,t){return e.current=gn(gn({},e.current),t),t}function yh(e,t,s){return ys(t)?t(e.current):Object.keys(s).forEach(function(l){var m;return(m=t[l])===null||m===void 0?void 0:m.call(t,e.current[l])}),s}var Ch={create:xh},wh={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Eh(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),v=0;v<l;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return t.apply(s,[].concat(m,i))}}}function kh(e){return{}.toString.call(e).includes("Object")}function jh(e){return e||_n("configIsRequired"),kh(e)||_n("configType"),e.urls?(Nh(),{paths:{vs:e.urls.monacoBase}}):e}function Nh(){console.warn(To.deprecation)}function Rh(e,t){throw new Error(e[t]||e.default)}var To={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
+ `},_n=Eh(Rh)(To),Ah={config:jh},Th=function(){for(var t=arguments.length,s=new Array(t),l=0;l<t;l++)s[l]=arguments[l];return function(m){return s.reduceRight(function(v,x){return x(v)},m)}};function Do(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],Do(e[s],t[s]))}),pn(pn({},e),t)}var Dh={type:"cancelation",msg:"operation is manually canceled"};function Tr(e){var t=!1,s=new Promise(function(l,m){e.then(function(v){return t?m(Dh):l(v)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var Mh=["monaco"],Lh=Ch.create({config:wh,isInitialized:!1,resolve:null,reject:null,monaco:null}),Mo=nh(Lh,2),Rs=Mo[0],dr=Mo[1];function Ph(e){var t=Ah.config(e),s=t.monaco,l=rh(t,Mh);dr(function(m){return{config:Do(m.config,l),monaco:s}})}function Oh(){var e=Rs(function(t){var s=t.monaco,l=t.isInitialized,m=t.resolve;return{monaco:s,isInitialized:l,resolve:m}});if(!e.isInitialized){if(dr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Tr(Dr);if(window.monaco&&window.monaco.editor)return Lo(window.monaco),e.resolve(window.monaco),Tr(Dr);Th(Ih,Fh)(Hh)}return Tr(Dr)}function Ih(e){return document.body.appendChild(e)}function Bh(e){var t=document.createElement("script");return e&&(t.src=e),t}function Fh(e){var t=Rs(function(l){var m=l.config,v=l.reject;return{config:m,reject:v}}),s=Bh("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Hh(){var e=Rs(function(s){var l=s.config,m=s.resolve,v=s.reject;return{config:l,resolve:m,reject:v}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var l=s.m||s;Lo(l),e.resolve(l)},function(s){e.reject(s)})}function Lo(e){Rs().monaco||dr({monaco:e})}function zh(){return Rs(function(e){var t=e.monaco;return t})}var Dr=new Promise(function(e,t){return dr({resolve:e,reject:t})}),Po={config:Ph,init:Oh,__getMonacoInstance:zh},Wh={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Mr=Wh,$h={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Uh=$h;function qh({children:e}){return re.createElement("div",{style:Uh.container},e)}var Kh=qh,Xh=Kh;function Yh({width:e,height:t,isEditorReady:s,loading:l,_ref:m,className:v,wrapperProps:x}){return re.createElement("section",{style:{...Mr.wrapper,width:e,height:t},...x},!s&&re.createElement(Xh,null,l),re.createElement("div",{ref:m,style:{...Mr.fullWidth,...!s&&Mr.hide},className:v}))}var Vh=Yh,Oo=E.memo(Vh);function Gh(e){E.useEffect(e,[])}var Io=Gh;function Qh(e,t,s=!0){let l=E.useRef(!0);E.useEffect(l.current||!s?()=>{l.current=!1}:e,t)}var vt=Qh;function ms(){}function Jt(e,t,s,l){return Zh(e,l)||Jh(e,t,s,l)}function Zh(e,t){return e.editor.getModel(Bo(e,t))}function Jh(e,t,s,l){return e.editor.createModel(t,s,l?Bo(e,l):void 0)}function Bo(e,t){return e.Uri.parse(t)}function ef({original:e,modified:t,language:s,originalLanguage:l,modifiedLanguage:m,originalModelPath:v,modifiedModelPath:x,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:c="light",loading:f="Loading...",options:a={},height:p="100%",width:S="100%",className:y,wrapperProps:_={},beforeMount:o=ms,onMount:h=ms}){let[u,d]=E.useState(!1),[b,C]=E.useState(!0),w=E.useRef(null),j=E.useRef(null),g=E.useRef(null),k=E.useRef(h),R=E.useRef(o),D=E.useRef(!1);Io(()=>{let B=Po.init();return B.then(z=>(j.current=z)&&C(!1)).catch(z=>z?.type!=="cancelation"&&console.error("Monaco initialization: error:",z)),()=>w.current?P():B.cancel()}),vt(()=>{if(w.current&&j.current){let B=w.current.getOriginalEditor(),z=Jt(j.current,e||"",l||s||"text",v||"");z!==B.getModel()&&B.setModel(z)}},[v],u),vt(()=>{if(w.current&&j.current){let B=w.current.getModifiedEditor(),z=Jt(j.current,t||"",m||s||"text",x||"");z!==B.getModel()&&B.setModel(z)}},[x],u),vt(()=>{let B=w.current.getModifiedEditor();B.getOption(j.current.editor.EditorOption.readOnly)?B.setValue(t||""):t!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[t],u),vt(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],u),vt(()=>{let{original:B,modified:z}=w.current.getModel();j.current.editor.setModelLanguage(B,l||s||"text"),j.current.editor.setModelLanguage(z,m||s||"text")},[s,l,m],u),vt(()=>{j.current?.editor.setTheme(c)},[c],u),vt(()=>{w.current?.updateOptions(a)},[a],u);let M=E.useCallback(()=>{if(!j.current)return;R.current(j.current);let B=Jt(j.current,e||"",l||s||"text",v||""),z=Jt(j.current,t||"",m||s||"text",x||"");w.current?.setModel({original:B,modified:z})},[s,t,m,e,l,v,x]),N=E.useCallback(()=>{!D.current&&g.current&&(w.current=j.current.editor.createDiffEditor(g.current,{automaticLayout:!0,...a}),M(),j.current?.editor.setTheme(c),d(!0),D.current=!0)},[a,c,M]);E.useEffect(()=>{u&&k.current(w.current,j.current)},[u]),E.useEffect(()=>{!b&&!u&&N()},[b,u,N]);function P(){let B=w.current?.getModel();i||B?.original?.dispose(),n||B?.modified?.dispose(),w.current?.dispose()}return re.createElement(Oo,{width:S,height:p,isEditorReady:u,loading:f,_ref:g,className:y,wrapperProps:_})}var tf=ef;E.memo(tf);function sf(e){let t=E.useRef();return E.useEffect(()=>{t.current=e},[e]),t.current}var rf=sf,Ps=new Map;function nf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:l,language:m,path:v,theme:x="light",line:i,loading:n="Loading...",options:c={},overrideServices:f={},saveViewState:a=!0,keepCurrentModel:p=!1,width:S="100%",height:y="100%",className:_,wrapperProps:o={},beforeMount:h=ms,onMount:u=ms,onChange:d,onValidate:b=ms}){let[C,w]=E.useState(!1),[j,g]=E.useState(!0),k=E.useRef(null),R=E.useRef(null),D=E.useRef(null),M=E.useRef(u),N=E.useRef(h),P=E.useRef(),B=E.useRef(l),z=rf(v),W=E.useRef(!1),A=E.useRef(!1);Io(()=>{let I=Po.init();return I.then(F=>(k.current=F)&&g(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>R.current?O():I.cancel()}),vt(()=>{let I=Jt(k.current,e||l||"",t||m||"",v||s||"");I!==R.current?.getModel()&&(a&&Ps.set(z,R.current?.saveViewState()),R.current?.setModel(I),a&&R.current?.restoreViewState(Ps.get(v)))},[v],C),vt(()=>{R.current?.updateOptions(c)},[c],C),vt(()=>{!R.current||l===void 0||(R.current.getOption(k.current.editor.EditorOption.readOnly)?R.current.setValue(l):l!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[l],C),vt(()=>{let I=R.current?.getModel();I&&m&&k.current?.editor.setModelLanguage(I,m)},[m],C),vt(()=>{i!==void 0&&R.current?.revealLine(i)},[i],C),vt(()=>{k.current?.editor.setTheme(x)},[x],C);let L=E.useCallback(()=>{if(!(!D.current||!k.current)&&!W.current){N.current(k.current);let I=v||s,F=Jt(k.current,l||e||"",t||m||"",I||"");R.current=k.current?.editor.create(D.current,{model:F,automaticLayout:!0,...c},f),a&&R.current.restoreViewState(Ps.get(I)),k.current.editor.setTheme(x),i!==void 0&&R.current.revealLine(i),w(!0),W.current=!0}},[e,t,s,l,m,v,c,f,a,x,i]);E.useEffect(()=>{C&&M.current(R.current,k.current)},[C]),E.useEffect(()=>{!j&&!C&&L()},[j,C,L]),B.current=l,E.useEffect(()=>{C&&d&&(P.current?.dispose(),P.current=R.current?.onDidChangeModelContent(I=>{A.current||d(R.current.getValue(),I)}))},[C,d]),E.useEffect(()=>{if(C){let I=k.current.editor.onDidChangeMarkers(F=>{let U=R.current.getModel()?.uri;if(U&&F.find(X=>X.path===U.path)){let X=k.current.editor.getModelMarkers({resource:U});b?.(X)}});return()=>{I?.dispose()}}return()=>{}},[C,b]);function O(){P.current?.dispose(),p?a&&Ps.set(v,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return re.createElement(Oo,{width:S,height:y,isEditorReady:C,loading:n,_ref:D,className:_,wrapperProps:o})}var of=nf,af=E.memo(of),lf=af,St=function(e,t){return Number(e.toFixed(t))},cf=function(e,t){return typeof e=="number"?e:t},Ne=function(e,t,s){s&&typeof s=="function"&&s(e,t)},df=function(e){return-Math.cos(e*Math.PI)/2+.5},uf=function(e){return e},hf=function(e){return e*e},ff=function(e){return e*(2-e)},mf=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},pf=function(e){return e*e*e},vf=function(e){return--e*e*e+1},gf=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},_f=function(e){return e*e*e*e},xf=function(e){return 1- --e*e*e*e},bf=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Sf=function(e){return e*e*e*e*e},yf=function(e){return 1+--e*e*e*e*e},Cf=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Fo={easeOut:df,linear:uf,easeInQuad:hf,easeOutQuad:ff,easeInOutQuad:mf,easeInCubic:pf,easeOutCubic:vf,easeInOutCubic:gf,easeInQuart:_f,easeOutQuart:xf,easeInOutQuart:bf,easeInQuint:Sf,easeOutQuint:yf,easeInOutQuint:Cf},Ho=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Et=function(e){e.mounted&&(Ho(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function zo(e,t,s,l){if(e.mounted){var m=new Date().getTime(),v=1;Et(e),e.animation=function(){if(!e.mounted)return Ho(e.animation);var x=new Date().getTime()-m,i=x/s,n=Fo[t],c=n(i);x>=s?(l(v),e.animation=null):e.animation&&(l(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function wf(e){var t=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(l))}function zt(e,t,s,l){var m=wf(t);if(!(!e.mounted||!m)){var v=e.setTransformState,x=e.transformState,i=x.scale,n=x.positionX,c=x.positionY,f=t.scale-i,a=t.positionX-n,p=t.positionY-c;s===0?v(t.scale,t.positionX,t.positionY):zo(e,l,s,function(S){var y=i+f*S,_=n+a*S,o=c+p*S;v(y,_,o)})}}function Ef(e,t,s){var l=e.offsetWidth,m=e.offsetHeight,v=t.offsetWidth,x=t.offsetHeight,i=v*s,n=x*s,c=l-i,f=m-n;return{wrapperWidth:l,wrapperHeight:m,newContentWidth:i,newDiffWidth:c,newContentHeight:n,newDiffHeight:f}}var kf=function(e,t,s,l,m,v,x){var i=e>t?s*(x?1:.5):0,n=l>m?v*(x?1:.5):0,c=e-t-i,f=i,a=l-m-n,p=n;return{minPositionX:c,maxPositionX:f,minPositionY:a,maxPositionY:p}},bi=function(e,t){var s=e.wrapperComponent,l=e.contentComponent,m=e.setup.centerZoomedOut;if(!s||!l)throw new Error("Components are not mounted");var v=Ef(s,l,t),x=v.wrapperWidth,i=v.wrapperHeight,n=v.newContentWidth,c=v.newDiffWidth,f=v.newContentHeight,a=v.newDiffHeight,p=kf(x,n,c,i,f,a,!!m);return p},Xr=function(e,t,s,l){return l?e<t?St(t,2):e>s?St(s,2):St(e,2):St(e,2)},Xt=function(e,t){var s=bi(e,t);return e.bounds=s,s};function As(e,t,s,l,m,v,x){var i=s.minPositionX,n=s.minPositionY,c=s.maxPositionX,f=s.maxPositionY,a=0,p=0;x&&(a=m,p=v);var S=Xr(e,i-a,c+a,l),y=Xr(t,n-p,f+p,l);return{x:S,y}}function ur(e,t,s,l,m,v){var x=e.transformState,i=x.scale,n=x.positionX,c=x.positionY,f=l-i;if(typeof t!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:c};var a=n-t*f,p=c-s*f,S=As(a,p,m,v,0,0,null);return S}function Ts(e,t,s,l,m){var v=m?l:0,x=t-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=x?x:e}var xn=function(e,t){var s=e.setup.panning.excluded,l=e.isInitialized,m=e.wrapperComponent,v=t.target,x="shadowRoot"in v&&"composedPath"in t,i=x?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(v),n=l&&v&&i;if(!n)return!1;var c=hr(v,s);return!c},bn=function(e){var t=e.isInitialized,s=e.isPanning,l=e.setup,m=l.panning.disabled,v=t&&s&&!m;return!!v},jf=function(e,t){var s=e.transformState,l=s.positionX,m=s.positionY;e.isPanning=!0;var v=t.clientX,x=t.clientY;e.startCoords={x:v-l,y:x-m}},Nf=function(e,t){var s=t.touches,l=e.transformState,m=l.positionX,v=l.positionY;e.isPanning=!0;var x=s.length===1;if(x){var i=s[0].clientX,n=s[0].clientY;e.startCoords={x:i-m,y:n-v}}};function Rf(e){var t=e.transformState,s=t.positionX,l=t.positionY,m=t.scale,v=e.setup,x=v.disabled,i=v.limitToBounds,n=v.centerZoomedOut,c=e.wrapperComponent;if(!(x||!c||!e.bounds)){var f=e.bounds,a=f.maxPositionX,p=f.minPositionX,S=f.maxPositionY,y=f.minPositionY,_=s>a||s<p,o=l>S||l<y,h=s>a?c.offsetWidth:e.setup.minPositionX||0,u=l>S?c.offsetHeight:e.setup.minPositionY||0,d=ur(e,h,u,m,e.bounds,i||n),b=d.x,C=d.y;return{scale:m,positionX:_?b:s,positionY:o?C:l}}}function Wo(e,t,s,l,m){var v=e.setup.limitToBounds,x=e.wrapperComponent,i=e.bounds,n=e.transformState,c=n.scale,f=n.positionX,a=n.positionY;if(!(x===null||i===null||t===f&&s===a)){var p=As(t,s,i,v,l,m,x),S=p.x,y=p.y;e.setTransformState(c,S,y)}}var Af=function(e,t,s){var l=e.startCoords,m=e.transformState,v=e.setup.panning,x=v.lockAxisX,i=v.lockAxisY,n=m.positionX,c=m.positionY;if(!l)return{x:n,y:c};var f=t-l.x,a=s-l.y,p=x?n:f,S=i?c:a;return{x:p,y:S}},Ft=function(e,t){var s=e.setup,l=e.transformState,m=l.scale,v=s.minScale,x=s.disablePadding;return t>0&&m>=v&&!x?t:0},Tf=function(e){var t=e.mounted,s=e.setup,l=s.disabled,m=s.velocityAnimation,v=e.transformState.scale,x=m.disabled,i=!x||v>1||!l||t;return!!i},Df=function(e){var t=e.mounted,s=e.velocity,l=e.bounds,m=e.setup,v=m.disabled,x=m.velocityAnimation,i=e.transformState.scale,n=x.disabled,c=!n||i>1||!v||t;return!(!c||!s||!l)};function Mf(e,t){var s=e.setup.velocityAnimation,l=s.equalToMove,m=s.animationTime,v=s.sensitivity;return l?m*t*v:m}function Sn(e,t,s,l,m,v,x,i,n,c){if(m){if(t>x&&s>x){var f=x+(e-x)*c;return f>n?n:f<x?x:f}if(t<v&&s<v){var f=v+(e-v)*c;return f<i?i:f>v?v:f}}return l?t:Xr(e,v,x,m)}function Lf(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function Pf(e,t){var s=Tf(e);if(s){var l=e.lastMousePosition,m=e.velocityTime,v=e.setup,x=e.wrapperComponent,i=v.velocityAnimation.equalToMove,n=Date.now();if(l&&m&&x){var c=Lf(x,i),f=t.x-l.x,a=t.y-l.y,p=f/c,S=a/c,y=n-m,_=f*f+a*a,o=Math.sqrt(_)/y;e.velocity={velocityX:p,velocityY:S,total:o}}e.lastMousePosition=t,e.velocityTime=n}}function Of(e){var t=e.velocity,s=e.bounds,l=e.setup,m=e.wrapperComponent,v=Df(e);if(!(!v||!t||!s||!m)){var x=t.velocityX,i=t.velocityY,n=t.total,c=s.maxPositionX,f=s.minPositionX,a=s.maxPositionY,p=s.minPositionY,S=l.limitToBounds,y=l.alignmentAnimation,_=l.zoomAnimation,o=l.panning,h=o.lockAxisY,u=o.lockAxisX,d=_.animationType,b=y.sizeX,C=y.sizeY,w=y.velocityAlignmentTime,j=w,g=Mf(e,n),k=Math.max(g,j),R=Ft(e,b),D=Ft(e,C),M=R*m.offsetWidth/100,N=D*m.offsetHeight/100,P=c+M,B=f-M,z=a+N,W=p-N,A=e.transformState,L=new Date().getTime();zo(e,d,k,function(O){var I=e.transformState,F=I.scale,U=I.positionX,X=I.positionY,Y=new Date().getTime()-L,J=Y/j,T=Fo[y.animationType],H=1-T(Math.min(1,J)),q=1-O,$=U+x*q,ee=X+i*q,Q=Sn($,A.positionX,U,u,S,f,c,B,P,H),le=Sn(ee,A.positionY,X,h,S,p,a,W,z,H);(U!==$||X!==ee)&&e.setTransformState(F,Q,le)})}}function yn(e,t){var s=e.transformState.scale;Et(e),Xt(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?Nf(e,t):jf(e,t)}function Si(e,t){var s=e.transformState.scale,l=e.setup,m=l.minScale,v=l.alignmentAnimation,x=v.disabled,i=v.sizeX,n=v.sizeY,c=v.animationTime,f=v.animationType,a=x||s<m||!i&&!n;if(!a){var p=Rf(e);p&&zt(e,p,t??c,f)}}function Cn(e,t,s){var l=e.startCoords,m=e.setup,v=m.alignmentAnimation,x=v.sizeX,i=v.sizeY;if(l){var n=Af(e,t,s),c=n.x,f=n.y,a=Ft(e,x),p=Ft(e,i);Pf(e,{x:c,y:f}),Wo(e,c,f,a,p)}}function If(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,s=e.velocity,l=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=l?.getBoundingClientRect(),x=m?.getBoundingClientRect(),i=v?.width||0,n=v?.height||0,c=x?.width||0,f=x?.height||0,a=i<c||n<f,p=!t&&s&&s?.total>.1&&a;p?Of(e):Si(e)}}function yi(e,t,s,l){var m=e.setup,v=m.minScale,x=m.maxScale,i=m.limitToBounds,n=Ts(St(t,2),v,x,0,!1),c=Xt(e,n),f=ur(e,s,l,n,c,i),a=f.x,p=f.y;return{scale:n,positionX:a,positionY:p}}function $o(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,x=v.minScale,i=v.limitToBounds,n=v.zoomAnimation,c=n.disabled,f=n.animationTime,a=n.animationType,p=c||l>=x;if((l>=1||i)&&Si(e),!(p||!m||!e.mounted)){var S=t||m.offsetWidth/2,y=s||m.offsetHeight/2,_=yi(e,x,S,y);_&&zt(e,_,f,a)}}var Bt=function(){return Bt=Object.assign||function(t){for(var s,l=1,m=arguments.length;l<m;l++){s=arguments[l];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(t[v]=s[v])}return t},Bt.apply(this,arguments)};function wn(e,t,s){for(var l=0,m=t.length,v;l<m;l++)(v||!(l in t))&&(v||(v=Array.prototype.slice.call(t,0,l)),v[l]=t[l]);return e.concat(v||Array.prototype.slice.call(t))}var Os={scale:1,positionX:0,positionY:0},as={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}},Yr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Uo=function(e){var t,s,l,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:Os.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:Os.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:Os.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:Os.positionY}},En=function(e){var t=Bt({},as);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",m=typeof as[s]<"u";if(m&&l){var v=Object.prototype.toString.call(as[s]),x=v==="[object Object]",i=v==="[object Array]";x?t[s]=Bt(Bt({},as[s]),e[s]):i?t[s]=wn(wn([],as[s],!0),e[s]):t[s]=e[s]}}),t},qo=function(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,x=v.maxScale,i=v.minScale,n=v.zoomAnimation,c=v.smooth,f=n.size;if(!m)throw new Error("Wrapper is not mounted");var a=c?l*Math.exp(t*s):l+t*s,p=Ts(St(a,3),i,x,f,!1);return p};function Ko(e,t,s,l,m){var v=e.wrapperComponent,x=e.transformState,i=x.scale,n=x.positionX,c=x.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,a=v.offsetHeight,p=(f/2-n)/i,S=(a/2-c)/i,y=qo(e,t,s),_=yi(e,y,p,S);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");zt(e,_,l,m)}function Xo(e,t,s,l){var m=e.setup,v=e.wrapperComponent,x=m.limitToBounds,i=Uo(e.props),n=e.transformState,c=n.scale,f=n.positionX,a=n.positionY;if(v){var p=bi(e,i.scale),S=As(i.positionX,i.positionY,p,x,0,0,v),y={scale:i.scale,positionX:S.x,positionY:S.y};c===i.scale&&f===i.positionX&&a===i.positionY||(l?.(),zt(e,y,t,s))}}function Bf(e,t,s,l){var m=e.getBoundingClientRect(),v=t.getBoundingClientRect(),x=s.getBoundingClientRect(),i=v.x*l.scale,n=v.y*l.scale;return{x:(m.x-x.x+i)/l.scale,y:(m.y-x.y+n)/l.scale}}function Ff(e,t,s){var l=e.wrapperComponent,m=e.contentComponent,v=e.transformState,x=e.setup,i=x.limitToBounds,n=x.minScale,c=x.maxScale;if(!l||!m)return v;var f=l.getBoundingClientRect(),a=t.getBoundingClientRect(),p=Bf(t,l,m,v),S=p.x,y=p.y,_=a.width/v.scale,o=a.height/v.scale,h=l.offsetWidth/_,u=l.offsetHeight/o,d=Ts(s||Math.min(h,u),n,c,0,!1),b=(f.width-_*d)/2,C=(f.height-o*d)/2,w=(f.left-S)*d+b,j=(f.top-y)*d+C,g=bi(e,d),k=As(w,j,g,i,0,0,l),R=k.x,D=k.y;return{positionX:R,positionY:D,scale:d}}var Hf=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),Ko(e,1,t,s,l)}},zf=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),Ko(e,-1,t,s,l)}},Wf=function(e){return function(t,s,l,m,v){m===void 0&&(m=300),v===void 0&&(v="easeOut");var x=e.transformState,i=x.positionX,n=x.positionY,c=x.scale,f=e.wrapperComponent,a=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!a)){var S={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(s)?n:s,scale:Number.isNaN(l)?c:l};zt(e,S,m,v)}}},$f=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),Xo(e,t,s)}},Uf=function(e){return function(t,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var m=e.transformState,v=e.wrapperComponent,x=e.contentComponent;if(v&&x){var i=Yo(t||m.scale,v,x);zt(e,i,s,l)}}},qf=function(e){return function(t,s,l,m){l===void 0&&(l=600),m===void 0&&(m="easeOut"),Et(e);var v=e.wrapperComponent,x=typeof t=="string"?document.getElementById(t):t;if(v&&x&&v.contains(x)){var i=Ff(e,x,s);zt(e,i,l,m)}}},Qs=function(e){return{instance:e,zoomIn:Hf(e),zoomOut:zf(e),setTransform:Wf(e),resetTransform:$f(e),centerView:Uf(e),zoomToElement:qf(e)}},Vr=function(e){return{instance:e,state:e.transformState}},ke=function(e){var t={};return Object.assign(t,Vr(e)),Object.assign(t,Qs(e)),t},Lr=!1;function Pr(){try{var e={get passive(){return Lr=!0,!1}};return e}catch{return Lr=!1,Lr}}var Is=".".concat(Yr.wrapperClass),hr=function(e,t){return t.some(function(s){return e.matches("".concat(Is," ").concat(s,", ").concat(Is," .").concat(s,", ").concat(Is," ").concat(s," *, ").concat(Is," .").concat(s," *"))})},Gr=function(e){e&&clearTimeout(e)},Kf=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},Yo=function(e,t,s){var l=s.offsetWidth*e,m=s.offsetHeight*e,v=(t.offsetWidth-l)/2,x=(t.offsetHeight-m)/2;return{scale:e,positionX:v,positionY:x}};function Xf(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var Yf=function(e,t){var s=e.setup.wheel,l=s.disabled,m=s.wheelDisabled,v=s.touchPadDisabled,x=s.excluded,i=e.isInitialized,n=e.isPanning,c=t.target,f=i&&!n&&!l&&c;if(!f||m&&!t.ctrlKey||v&&t.ctrlKey)return!1;var a=hr(c,x);return!a},Vf=function(e){return e?e.deltaY<0?1:-1:0};function Gf(e,t){var s=Vf(e),l=cf(t,s);return l}function Vo(e,t,s){var l=t.getBoundingClientRect(),m=0,v=0;if("clientX"in e)m=(e.clientX-l.left)/s,v=(e.clientY-l.top)/s;else{var x=e.touches[0];m=(x.clientX-l.left)/s,v=(x.clientY-l.top)/s}return(Number.isNaN(m)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:m,y:v}}var Qf=function(e,t,s,l,m){var v=e.transformState.scale,x=e.wrapperComponent,i=e.setup,n=i.maxScale,c=i.minScale,f=i.zoomAnimation,a=i.disablePadding,p=f.size,S=f.disabled;if(!x)throw new Error("Wrapper is not mounted");var y=v+t*s,_=l?!1:!S,o=Ts(St(y,3),c,n,p,_&&!a);return o},Zf=function(e,t){var s=e.previousWheelEvent,l=e.transformState.scale,m=e.setup,v=m.maxScale,x=m.minScale;return s?l<v||l>x||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},Jf=function(e,t){var s=e.setup.pinch,l=s.disabled,m=s.excluded,v=e.isInitialized,x=t.target,i=v&&!l&&x;if(!i)return!1;var n=hr(x,m);return!n},em=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,m=s&&!t&&l;return!!m},tm=function(e,t,s){var l=s.getBoundingClientRect(),m=e.touches,v=St(m[0].clientX-l.left,5),x=St(m[0].clientY-l.top,5),i=St(m[1].clientX-l.left,5),n=St(m[1].clientY-l.top,5);return{x:(v+i)/2/t,y:(x+n)/2/t}},Go=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))},sm=function(e,t){var s=e.pinchStartScale,l=e.pinchStartDistance,m=e.setup,v=m.maxScale,x=m.minScale,i=m.zoomAnimation,n=m.disablePadding,c=i.size,f=i.disabled;if(!s||l===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var a=t/l,p=a*s;return Ts(St(p,2),x,v,c,!f&&!n)},rm=160,im=100,nm=function(e,t){var s=e.props,l=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(Et(e),Ne(ke(e),t,l),Ne(ke(e),t,m))},om=function(e,t){var s=e.props,l=s.onWheel,m=s.onZoom,v=e.contentComponent,x=e.setup,i=e.transformState,n=i.scale,c=x.limitToBounds,f=x.centerZoomedOut,a=x.zoomAnimation,p=x.wheel,S=x.disablePadding,y=x.smooth,_=a.size,o=a.disabled,h=p.step,u=p.smoothStep;if(!v)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var d=Gf(t,null),b=y?u*Math.abs(t.deltaY):h,C=Qf(e,d,b,!t.ctrlKey);if(n!==C){var w=Xt(e,C),j=Vo(t,v,n),g=o||_===0||f||S,k=c&&g,R=ur(e,j.x,j.y,C,w,k),D=R.x,M=R.y;e.previousWheelEvent=t,e.setTransformState(C,D,M),Ne(ke(e),t,l),Ne(ke(e),t,m)}},am=function(e,t){var s=e.props,l=s.onWheelStop,m=s.onZoomStop;Gr(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&($o(e,t.x,t.y),e.wheelAnimationTimer=null)},im);var v=Zf(e,t);v&&(Gr(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ne(ke(e),t,l),Ne(ke(e),t,m))},rm))},Qo=function(e){for(var t=0,s=0,l=0;l<2;l+=1)t+=e.touches[l].clientX,s+=e.touches[l].clientY;var m=t/2,v=s/2;return{x:m,y:v}},lm=function(e,t){var s=Go(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=Qo(t);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,Et(e)},cm=function(e,t){var s=e.contentComponent,l=e.pinchStartDistance,m=e.wrapperComponent,v=e.transformState.scale,x=e.setup,i=x.limitToBounds,n=x.centerZoomedOut,c=x.zoomAnimation,f=x.alignmentAnimation,a=c.disabled,p=c.size;if(!(l===null||!s)){var S=tm(t,v,s);if(!(!Number.isFinite(S.x)||!Number.isFinite(S.y))){var y=Go(t),_=sm(e,y),o=Qo(t),h=o.x-(e.pinchLastCenterX||0),u=o.y-(e.pinchLastCenterY||0);if(!(_===v&&h===0&&u===0)){e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y;var d=Xt(e,_),b=a||p===0||n,C=i&&b,w=ur(e,S.x,S.y,_,d,C),j=w.x,g=w.y;e.pinchMidpoint=S,e.lastDistance=y;var k=f.sizeX,R=f.sizeY,D=Ft(e,k),M=Ft(e,R),N=j+h,P=g+u,B=As(N,P,d,i,D,M,m),z=B.x,W=B.y;e.setTransformState(_,z,W)}}}},dm=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,$o(e,t?.x,t?.y)},Zo=function(e,t){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;Gr(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ne(ke(e),t,s)},l)},um=function(e,t){var s=e.props,l=s.onZoomStart,m=s.onZoom,v=e.setup.doubleClick,x=v.animationTime,i=v.animationType;Ne(ke(e),t,l),Xo(e,x,i,function(){return Ne(ke(e),t,m)}),Zo(e,t)};function hm(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function fm(e,t){var s=e.setup,l=e.doubleClickStopEventTimer,m=e.transformState,v=e.contentComponent,x=m.scale,i=e.props,n=i.onZoomStart,c=i.onZoom,f=s.doubleClick,a=f.disabled,p=f.mode,S=f.step,y=f.animationTime,_=f.animationType;if(!a&&!l){if(p==="reset")return um(e,t);if(!v)return console.error("No ContentComponent found");var o=hm(p,e.transformState.scale),h=qo(e,o,S);if(x!==h){Ne(ke(e),t,n);var u=Vo(t,v,x),d=yi(e,h,u.x,u.y);if(!d)return console.error("Error during zoom event. New transformation state was not calculated.");Ne(ke(e),t,c),zt(e,d,y,_),Zo(e,t)}}}var mm=function(e,t){var s=e.isInitialized,l=e.setup,m=e.wrapperComponent,v=l.doubleClick,x=v.disabled,i=v.excluded,n=t.target,c=m?.contains(n),f=s&&n&&c&&!x;if(!f)return!1;var a=hr(n,i);return!a},pm=(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(l){s.props=l,Xt(s,s.transformState.scale),s.setup=En(l)},this.initializeWindowEvents=function(){var l,m,v=Pr(),x=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,i=x?.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),x?.addEventListener("mouseleave",s.clearPanning,v),i?.addEventListener("keyup",s.setKeyUnPressed,v),i?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var l,m,v=Pr(),x=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,i=x?.defaultView;i?.removeEventListener("mousedown",s.onPanningStart,v),i?.removeEventListener("mousemove",s.onPanning,v),i?.removeEventListener("mouseup",s.onPanningStop,v),x?.removeEventListener("mouseleave",s.clearPanning,v),i?.removeEventListener("keyup",s.setKeyUnPressed,v),i?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),Et(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(l){var m=Pr();l.addEventListener("wheel",s.onWheelZoom,m),l.addEventListener("dblclick",s.onDoubleClick,m),l.addEventListener("touchstart",s.onTouchPanningStart,m),l.addEventListener("touchmove",s.onTouchPanning,m),l.addEventListener("touchend",s.onTouchPanningStop,m)},this.handleInitialize=function(l,m){var v=!1,x=s.setup.centerOnInit,i=function(n,c){for(var f=0,a=n;f<a.length;f++){var p=a[f];if(p.target===c)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(n){n(ke(s))}),s.observer=new ResizeObserver(function(n){if(i(n,l)||i(n,m))if(x&&!v){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(v=!0,s.setCenter())}else Et(s),Xt(s,s.transformState.scale),Si(s,0)}),s.observer.observe(l),s.observer.observe(m)},this.onWheelZoom=function(l){var m=s.setup.disabled;if(!m){var v=Yf(s,l);if(v){var x=s.isPressingKeys(s.setup.wheel.activationKeys);x&&(nm(s,l),om(s,l),am(s,l))}}},this.onWheelPanning=function(l){var m=s.setup,v=m.disabled,x=m.wheel,i=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!x.wheelDisabled||i.disabled||!i.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var n=s.transformState,c=n.positionX,f=n.positionY,a=c-l.deltaX,p=f-l.deltaY,S=i.lockAxisX?c:a,y=i.lockAxisY?f:p,_=s.setup.alignmentAnimation,o=_.sizeX,h=_.sizeY,u=Ft(s,o),d=Ft(s,h);S===c&&y===f||Wo(s,S,y,u,d)}},this.onPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var x=xn(s,l);if(x){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(l.button===0&&!s.setup.panning.allowLeftClickPan||l.button===1&&!s.setup.panning.allowMiddleClickPan||l.button===2&&!s.setup.panning.allowRightClickPan||(l.preventDefault(),l.stopPropagation(),Et(s),yn(s,l),Ne(ke(s),l,v)))}}},this.onPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(!m){var x=bn(s);if(x){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(l.preventDefault(),l.stopPropagation(),Cn(s,l.clientX,l.clientY),Ne(ke(s),l,v))}}},this.onPanningStop=function(l){var m=s.props.onPanningStop;s.isPanning&&(If(s),Ne(ke(s),l,m))},this.onPinchStart=function(l){var m=s.setup.disabled,v=s.props,x=v.onPinchingStart,i=v.onZoomStart;if(!m){var n=Jf(s,l);n&&(lm(s,l),Et(s),Ne(ke(s),l,x),Ne(ke(s),l,i))}},this.onPinch=function(l){var m=s.setup.disabled,v=s.props,x=v.onPinching,i=v.onZoom;if(!m){var n=em(s);n&&(l.preventDefault(),l.stopPropagation(),cm(s,l),Ne(ke(s),l,x),Ne(ke(s),l,i))}},this.onPinchStop=function(l){var m=s.props,v=m.onPinchingStop,x=m.onZoomStop;s.pinchStartScale&&(dm(s),Ne(ke(s),l,v),Ne(ke(s),l,x))},this.onTouchPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var x=xn(s,l);if(x){var i=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!i){s.lastTouch=+new Date,Et(s);var n=l.touches,c=n.length===1,f=n.length===2;c&&(Et(s),yn(s,l),Ne(ke(s),l,v)),f&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(m)return;var x=bn(s);if(!x)return;l.preventDefault(),l.stopPropagation();var i=l.touches[0];Cn(s,i.clientX,i.clientY),Ne(ke(s),l,v)}else l.touches.length>1&&s.onPinch(l)},this.onTouchPanningStop=function(l){s.onPanningStop(l),s.onPinchStop(l)},this.onDoubleClick=function(l){var m=s.setup.disabled;if(!m){var v=mm(s,l);v&&fm(s,l)}},this.clearPanning=function(l){s.isPanning&&s.onPanningStop(l)},this.setKeyPressed=function(l){s.pressedKeys[l.key]=!0},this.setKeyUnPressed=function(l){s.pressedKeys[l.key]=!1},this.isPressingKeys=function(l){return l.length?!!l.find(function(m){return s.pressedKeys[m]}):!0},this.setTransformState=function(l,m,v){var x=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(m)&&!Number.isNaN(v)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=m,s.transformState.positionY=v,s.applyTransformation();var i=ke(s);s.onChangeCallbacks.forEach(function(n){return n(i)}),Ne(i,{scale:l,positionX:m,positionY:v},x)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=Yo(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,m,v){return s.props.customTransform?s.props.customTransform(l,m,v):Kf(l,m,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,m=l.scale,v=l.positionX,x=l.positionY,i=s.handleTransformStyles(v,x,m);s.contentComponent.style.transform=i}},this.getContext=function(){return ke(s)},this.onChange=function(l){return s.onChangeCallbacks.has(l)||s.onChangeCallbacks.add(l),function(){s.onChangeCallbacks.delete(l)}},this.onInit=function(l){return s.onInitCallbacks.has(l)||s.onInitCallbacks.add(l),function(){s.onInitCallbacks.delete(l)}},this.init=function(l,m){s.cleanupWindowEvents(),s.wrapperComponent=l,s.contentComponent=m,Xt(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,m),s.initializeWindowEvents(),s.isInitialized=!0;var v=ke(s);Ne(v,void 0,s.props.onInit)},this.props=t,this.setup=En(this.props),this.transformState=Uo(this.props)}return e})(),fr=re.createContext(null),vm=function(e,t){return typeof e=="function"?e(t):e},gm=re.forwardRef(function(e,t){var s=E.useRef(new pm(e)).current,l=vm(e.children,Qs(s));return E.useImperativeHandle(t,function(){return Qs(s)},[s]),E.useEffect(function(){s.update(e)},[s,e]),re.createElement(fr.Provider,{value:s},l)});re.forwardRef(function(e,t){var s=E.useRef(null),l=E.useContext(fr);return E.useEffect(function(){return l.onChange(function(m){if(s.current){var v=0,x=0;s.current.style.transform=l.handleTransformStyles(v,x,1/m.instance.transformState.scale)}})},[l]),re.createElement("div",Bt({},e,{ref:Xf([s,t])}))});function _m(e,t){t===void 0&&(t={});var s=t.insertAt;if(!(typeof document>"u")){var l=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",s==="top"&&l.firstChild?l.insertBefore(m,l.firstChild):l.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var xm=`.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
+ `,kn={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};_m(xm);var bm=function(e){var t=e.children,s=e.wrapperClass,l=s===void 0?"":s,m=e.contentClass,v=m===void 0?"":m,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,c=n===void 0?{}:n,f=e.contentProps,a=f===void 0?{}:f,p=E.useContext(fr),S=p.init,y=p.cleanupWindowEvents,_=E.useRef(null),o=E.useRef(null);return E.useEffect(function(){var h=_.current,u=o.current;return h!==null&&u!==null&&S&&S?.(h,u),function(){y?.()}},[]),re.createElement("div",Bt({},c,{ref:_,className:"".concat(Yr.wrapperClass," ").concat(kn.wrapper," ").concat(l),style:x}),re.createElement("div",Bt({},a,{ref:o,className:"".concat(Yr.contentClass," ").concat(kn.content," ").concat(v),style:i}),t))},Jo=function(){var e=E.useContext(fr);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Sm=function(){var e=Jo();return Qs(e)};function ym(e){var t=Jo(),s=E.useState(e(Vr(t))),l=s[0],m=s[1];return E.useEffect(function(){var v=!0,x=t.onChange(function(i){v&&m(e(Vr(i.instance)))});return function(){x(),v=!1}},[e,t]),l}function Cm(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 wm(e,t){return yt({queryKey:oe.files.tree(e||"",t),queryFn:()=>ue.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Em(e,t){return yt({queryKey:oe.files.content(e||"",t||""),queryFn:()=>ue.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function km(e){const t=We();return E.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function jm(){const e=We();return nt({mutationFn:t=>ue.post("/files/write",t),onSuccess:(t,s)=>{const l=oe.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||Cm(s.path)})}})}function Nm(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Rm(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Am=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Tm(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Am.has(t)?li:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?gs:t==="json"?Il:t==="md"||t==="mdx"||t==="txt"?io:pl}const jn=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:v})=>r.jsxs("button",{type:"button",onClick:s,className:ne("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:[r.jsx("span",{className:"shrink-0",children:m}),r.jsx("span",{className:"shrink-0 text-neutral-500",children:l}),r.jsx("span",{className:"truncate text-neutral-700",children:v})]}),ea=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:x})=>{const{t:i}=ae(),{data:n,isLoading:c,isError:f}=wm(e,t),a=E.useMemo(()=>n?.items??[],[n?.items]);return c?r.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:i("Loading...")}):f?r.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:i("Failed to load")}):r.jsx("div",{className:"space-y-0.5",children:a.map(p=>{if(p.type==="directory"){const h=Nm(t,p.name),u=l.has(h);return r.jsxs("div",{children:[r.jsx(jn,{depth:s,onClick:()=>m(h),rightIcon:u?r.jsx(jt,{size:14,className:"text-neutral-400"}):r.jsx(Ht,{size:14,className:"text-neutral-400"}),leftIcon:u?r.jsx(no,{size:14,className:"text-amber-500"}):r.jsx(ml,{size:14,className:"text-amber-500"}),label:p.name}),u&&r.jsx(ea,{workingDir:e,path:h,depth:s+1,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:x})]},h)}const S=Rm(t,p.name),y=Tm(p),_=x===S,o=y===li;return r.jsx(jn,{depth:s,active:_,onClick:()=>v(S),rightIcon:r.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?r.jsx(y,{size:14,className:o?"text-emerald-600":"text-sky-600"}):null,label:p.name},S)})})},Dm=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const{t:v}=ae(),[x,i]=E.useState(()=>new Set),n=km(e),c=E.useCallback(f=>{i(a=>{const p=new Set(a);return p.has(f)?p.delete(f):p.add(f),p})},[]);return r.jsxs("div",{className:ne("h-full flex flex-col",t),children:[r.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:v("Files")}),r.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||v("No working directory")})]}),r.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&r.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:v("Refresh file tree"),children:r.jsx($r,{size:13})}),m&&r.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:r.jsx(ic,{size:13})})]})]}),r.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?r.jsx(ea,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:c,onFileSelect:s,selectedFilePath:l}):r.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:v("No workspace selected.")})})]})},Mm=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Lm(e){const t=e.split(".").pop()?.toLowerCase();return t?Mm.has(t):!1}function Pm(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${l.toString()}`}const Om=({filePath:e})=>{const{t}=ae(),{zoomIn:s,zoomOut:l,centerView:m}=Sm(),v=ym(i=>i.state.scale),x=Math.round(v*100);return r.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:[r.jsx("button",{type:"button",onClick:()=>l(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom out"),children:r.jsx(bc,{size:14})}),r.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:[x,"%"]}),r.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:r.jsx(_c,{size:14})}),r.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:r.jsx(tc,{size:13})}),r.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Im=({workingDir:e,filePath:t})=>{const{t:s}=ae(),[l,m]=E.useState(!1),v=Pm(e,t);return l?r.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("Failed to load image.")}):r.jsx(gm,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx(Om,{filePath:t}),r.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:r.jsx(bm,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx("img",{src:v,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function Bm(e){const t=e.split("/");return t[t.length-1]||e}function Fm(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 Hm=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>{const{t:v}=ae();return r.jsxs("button",{type:"button",onClick:l,className:ne("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:[r.jsx("span",{className:ne("w-2 h-2 rounded-full",s?"bg-amber-500":"bg-transparent")}),r.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),r.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:r.jsx(Cs,{size:12})})]})},zm=({workingDir:e,className:t,readOnly:s=!1})=>{const{t:l}=ae(),[m,v]=E.useState([]),[x,i]=E.useState(null),n=jm(),[c,f]=E.useState(280),[a,p]=E.useState(!1),[S,y]=E.useState(!1),_=E.useRef(280),o=E.useCallback(()=>{p(N=>(N?f(_.current):_.current=c,!N))},[c]),h=E.useCallback(N=>{N.preventDefault(),y(!0);const P=N.clientX,B=c,z=A=>{const L=A.clientX-P,O=Math.min(480,Math.max(160,B+L));f(O)},W=()=>{y(!1),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",z),document.addEventListener("mouseup",W)},[c]);E.useEffect(()=>{v([]),i(null)},[e]);const u=E.useMemo(()=>m.find(N=>N.path===x)||null,[m,x]),{data:d,isFetching:b,isError:C,error:w}=Em(e,u?.isImage?null:x);E.useEffect(()=>{!x||!d||v(N=>N.map(P=>P.path!==x||P.isDirty||P.loaded?P:{...P,language:d.language||P.language,content:d.content,savedContent:d.content,isDirty:!1,loaded:!0}))},[x,d]);const j=E.useCallback(N=>{v(P=>{if(P.find(W=>W.path===N))return P;const z=Lm(N);return[...P,{path:N,name:Bm(N),language:Fm(N),content:"",savedContent:"",isDirty:!1,loaded:z,isImage:z}]}),i(N)},[]),g=E.useCallback(N=>{v(P=>{const B=P.filter(z=>z.path!==N);return i(z=>z!==N?z:B.length?B[B.length-1].path:null),B})},[]),k=E.useCallback(N=>{v(P=>P.map(B=>{if(B.path!==x)return B;const z=N!==B.savedContent;return{...B,content:N,isDirty:z}}))},[x]),R=E.useCallback(async()=>{s||!e||!u||(await n.mutateAsync({workingDir:e,path:u.path,content:u.content}),v(N=>N.map(P=>P.path===u.path?{...P,savedContent:P.content,isDirty:!1,loaded:!0}:P)))},[u,s,n,e]),D=E.useRef(()=>{});E.useEffect(()=>{D.current=()=>{R().catch(()=>{})}},[R]),E.useEffect(()=>{const N=P=>{s||(P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="s"&&(P.preventDefault(),D.current())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[s]);const M=E.useCallback((N,P)=>{N.addCommand(P.KeyMod.CtrlCmd|P.KeyCode.KeyS,()=>{D.current()})},[]);return r.jsxs("div",{className:ne("flex h-full overflow-hidden bg-white",t),style:S?{userSelect:"none",cursor:"col-resize"}:void 0,children:[r.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:a?36:c,transition:S?"none":"width 0.15s ease"},children:a?r.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:r.jsx("button",{type:"button",onClick:o,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:l("Expand file tree"),children:r.jsx(oc,{size:16})})}):r.jsx(r.Fragment,{children:r.jsx(Dm,{workingDir:e,onFileSelect:j,selectedFilePath:u?.path||null,onCollapse:o},e||"no-working-dir")})}),!a&&r.jsx("div",{onMouseDown:h,className:ne("w-1 shrink-0 cursor-col-resize transition-colors",S?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),r.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[m.length===0?r.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:l("No open files")}):m.map(N=>r.jsx(Hm,{active:N.path===x,name:N.name,isDirty:N.isDirty,onClick:()=>i(N.path),onClose:P=>{P.stopPropagation(),g(N.path)}},N.path)),r.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[s&&r.jsx("span",{className:"text-[11px] text-neutral-400",children:l("Read-only")}),n.isPending&&r.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),l("Saving")]}),u?.isDirty&&!n.isPending&&r.jsx("span",{className:"text-[11px] text-amber-600",children:l("Unsaved")})]})]}),r.jsx("div",{className:"flex-1 min-h-0 relative",children:e?u?u.isImage?r.jsx(Im,{workingDir:e,filePath:u.path}):r.jsxs(r.Fragment,{children:[r.jsx(lf,{path:u.path,value:u.content,language:u.language,theme:"vs-light",height:"100%",onChange:s?void 0:N=>k(N??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:s}}),b&&!u.loaded&&r.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),l("Loading file...")]})}),C&&r.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:[l("Failed to load file"),w instanceof Error?`: ${w.message}`:""]})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("Select a file from the tree to open.")}):r.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("No workspace selected.")})})]})]})};function ta(e){return yt({queryKey:oe.git.changes(e||""),queryFn:()=>ue.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function sa(e,t,s){return yt({queryKey:oe.git.diff(e||"",t||"",s),queryFn:()=>ue.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function ra(e,t){return yt({queryKey:oe.git.commitFiles(e||"",t||""),queryFn:()=>ue.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function ia(e,t,s){return yt({queryKey:oe.git.commitDiff(e||"",t||"",s||""),queryFn:()=>ue.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Nn={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"},Wm={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function $m(e){const t=e.split("/");return t[t.length-1]||e}function Um(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const qm=({entry:e,selected:t,onClick:s})=>{const{t:l}=ae(),m=Nn[e.status]||Nn.M,v=Wm[e.status]||e.status,x=Um(e.path);return r.jsxs("button",{type:"button",onClick:s,className:ne("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:[r.jsx("span",{className:ne("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:l(v),children:e.status}),r.jsx("span",{className:"text-xs text-neutral-900 truncate",children:$m(e.path)}),x&&r.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:x})]})},Rn=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>{const{t:v}=ae();return t.length===0?null:r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[r.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),r.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),r.jsx("div",{className:"space-y-0.5",children:t.map(x=>{const i=`${s}:${x.path}`;return r.jsx(qm,{entry:x,selected:l===i,onClick:()=>m(x.path,s)},i)})})]})},Km=({line:e,lineNum:t})=>{let s="",l="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",l="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",l="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",l="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(l="text-neutral-400"),r.jsxs("div",{className:ne("flex",s),children:[r.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),r.jsx("span",{className:ne("pl-2 whitespace-pre",l),children:e})]})},Xm=({workingDir:e,filePath:t,type:s})=>{const{t:l}=ae(),{data:m,isLoading:v,isError:x}=sa(e,t,s);if(v)return r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(x)return r.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:l("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:l("No diff content available.")});const n=i.split(`
63
+ `);return r.jsx("div",{className:"flex-1 overflow-auto font-mono text-xs leading-5",children:n.map((c,f)=>r.jsx(Km,{line:c,lineNum:f+1},f))})},Ym=({workingDir:e})=>{const{t}=ae(),{data:s,isLoading:l,isError:m}=ta(e),[v,x]=E.useState(null),[i,n]=E.useState(260),[c,f]=E.useState(!1),a=E.useCallback(h=>{h.preventDefault(),f(!0);const u=h.clientX,d=i,b=w=>{const j=w.clientX-u,g=Math.min(480,Math.max(160,d+j));n(g)},C=()=>{f(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",C)},[i]),p=v?`${v.type}:${v.path}`:null,S=(h,u)=>{x({path:h,type:u})};if(!e)return r.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(l)return r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return r.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 y=s?.uncommitted||[],_=s?.committed||[],o=y.length+_.length;return r.jsxs("div",{className:"flex h-full bg-white",style:c?{userSelect:"none",cursor:"col-resize"}:void 0,children:[r.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:i},children:[r.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_s,{size:14,className:"text-neutral-500"}),r.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("Changes")}),o>0&&r.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:o})]})}),r.jsx("div",{className:"flex-1 overflow-auto p-1.5",children:o===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[r.jsx(_s,{size:28,className:"mb-2"}),r.jsx("span",{className:"text-xs",children:t("No pending changes")})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx(Rn,{title:"Uncommitted",entries:y,type:"uncommitted",selectedKey:p,onSelect:S}),r.jsx(Rn,{title:"Committed",entries:_,type:"committed",selectedKey:p,onSelect:S})]})})]}),r.jsx("div",{onMouseDown:a,className:ne("w-1 shrink-0 cursor-col-resize transition-colors",c?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),r.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[r.jsx(gs,{size:14,className:"text-neutral-500"}),r.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:v.path}),r.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",t(v.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),r.jsx(Xm,{workingDir:e,filePath:v.path,type:v.type})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gs,{size:28}),r.jsx("span",{className:"text-xs",children:t("Select a file to view diff")})]})})})]})},Or=50,An={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 Vm(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ot("{count}s ago",{count:s}):s<3600?Ot("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ot("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ot("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Gm(e){const t=e.split("/");return t[t.length-1]||e}function Qm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Zm=`
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
+ `,Jm=({line:e,lineNum:t})=>{let s="",l="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",l="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",l="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",l="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(l="text-neutral-400"),r.jsxs("div",{className:ne("flex",s),children:[r.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),r.jsx("span",{className:ne("pl-2 whitespace-pre",l),children:e})]})},ep=({workingDir:e,hash:t,filePath:s})=>{const{t:l}=ae(),{data:m,isLoading:v,isError:x}=ia(e,t,s);if(v)return r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(x)return r.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:l("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:l("No diff content available.")});const n=i.split(`
69
+ `);return r.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:n.map((c,f)=>r.jsx(Jm,{line:c,lineNum:f+1},f))})},tp=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{t:m}=ae(),{data:v,isLoading:x}=ra(e,t);if(x)return r.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[r.jsx(Pe,{size:12,className:"animate-spin"}),r.jsx("span",{children:m("Loading...")})]});const i=v?.files||[];return i.length===0?r.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):r.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const c=An[n.status]||An.M,f=Qm(n.path);return r.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),l(n.path)},className:ne("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===n.path?"bg-blue-50":"hover:bg-neutral-50"),children:[r.jsx("span",{className:ne("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:n.status}),r.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:Gm(n.path)}),f&&r.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},n.path)})})},sp=({workingDir:e})=>{const{t}=ae(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:x,isFetchingNextPage:i}=to({queryKey:oe.git.log(e||""),queryFn:({pageParam:C=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(Or),skip:String(C)}}),initialPageParam:0,getNextPageParam:(C,w)=>C.commits.length<Or?void 0:w.length*Or,enabled:!!e}),n=s?.pages.flatMap(C=>C.commits)||[],[c,f]=E.useState(null),[a,p]=E.useState(null),[S,y]=E.useState(280),[_,o]=E.useState(!1),h=E.useCallback(C=>{C.preventDefault(),o(!0);const w=C.clientX,j=S,g=R=>{const D=Math.min(480,Math.max(180,j+(R.clientX-w)));y(D)},k=()=>{o(!1),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",k)},[S]),u=C=>{c===C?(f(null),p(null)):(f(C),p(null))},d=E.useRef(null);if(!e)return r.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(l)return r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return r.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(n.length===0)return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[r.jsx(ss,{size:28,className:"mb-2"}),r.jsx("span",{className:"text-xs",children:t("No commit history")})]});const b=n.find(C=>C.hash===c);return r.jsxs("div",{className:"flex h-full bg-white",style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[r.jsx("style",{children:Zm}),r.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:S},children:[r.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ss,{size:14,className:"text-neutral-500"}),r.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),r.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n.length})]})}),r.jsxs("div",{ref:d,className:"flex-1 overflow-auto history-scroll p-1.5",children:[n.map(C=>{const w=c===C.hash;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",onClick:()=>u(C.hash),className:ne("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:[r.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:r.jsx("div",{className:ne("w-2 h-2 rounded-full shrink-0 transition-colors",w?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:C.shortHash}),r.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:C.message}),r.jsx(Ht,{size:12,className:ne("shrink-0 text-neutral-400 transition-transform",w&&"rotate-90")})]}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:C.author}),r.jsx("span",{className:"text-[10px] text-neutral-400",children:Vm(C.timestamp)})]})]})]}),w&&r.jsxs(r.Fragment,{children:[C.body&&r.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:C.body}),r.jsx(tp,{workingDir:e,hash:C.hash,selectedPath:a,onSelectFile:p})]})]},C.hash)}),x&&r.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?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),r.jsx("div",{onMouseDown:h,className:ne("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),r.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:a&&c?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[r.jsx(gs,{size:14,className:"text-neutral-500"}),r.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:a}),r.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",b?.shortHash,")"]})]}),r.jsx(ep,{workingDir:e,hash:c,filePath:a})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gs,{size:28}),r.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},rp=[{key:"changes",label:"Changes",icon:r.jsx(_s,{size:14})},{key:"history",label:"History",icon:r.jsx(ss,{size:14})},{key:"editor",label:"Editor",icon:r.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:r.jsx($s,{size:14})},{key:"preview",label:"Preview",icon:r.jsx(tr,{size:14})}],ip=[{key:"history",label:"History",icon:r.jsx(ss,{size:14})},{key:"editor",label:"Editor",icon:r.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:r.jsx($s,{size:14})},{key:"preview",label:"Preview",icon:r.jsx(tr,{size:14})}],np=({active:e,onClick:t,icon:s,label:l})=>r.jsxs("button",{onClick:t,className:ne("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,r.jsx("span",{children:l})]}),Tn=({icon:e,title:t})=>{const{t:s}=ae();return r.jsx("div",{className:"flex-1 flex items-center justify-center bg-white",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-neutral-400",children:[e,r.jsx("span",{className:"text-sm font-medium text-neutral-500",children:s(t)}),r.jsx("span",{className:"text-xs",children:s("Coming soon...")})]})})},na=re.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:v,readOnly:x,repoDeleted:i,teamRun:n,teamStatus:c}){const{t:f}=ae(),a=E.useMemo(()=>{const d=v?ip:rp,b=x?d.filter(C=>C.key!=="terminal"):d;return n?[{key:"team-status",label:"Team Status",icon:r.jsx(ps,{size:14})},...b]:b},[v,x,n]),[p,S]=E.useState(v?"history":"changes"),{data:y}=vl(m??""),_=E.useMemo(()=>{if(!y?.quickCommands)return[];try{return JSON.parse(y.quickCommands)}catch{return[]}},[y?.quickCommands]),[o,h]=E.useState([]),u=E.useRef(void 0);return E.useEffect(()=>{l&&l!==u.current&&(u.current=l,h(d=>d.includes(l)?d:[...d,l]))},[l]),E.useEffect(()=>{x&&p==="terminal"&&S(v?"history":"changes")},[p,v,x]),E.useEffect(()=>{n||p!=="team-status"||S(v?"history":"changes")},[p,v,n]),r.jsxs("div",{className:ne("flex flex-col h-full bg-white",t),children:[x&&r.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:f(i?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),r.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:a.map(d=>r.jsx(np,{active:p===d.key,onClick:()=>S(d.key),icon:d.icon,label:f(d.label)},d.key))}),r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[p==="team-status"&&n&&(c??r.jsx(Tn,{icon:r.jsx(ps,{size:32}),title:"Team Status"})),p==="editor"&&r.jsx(zm,{workingDir:l,readOnly:x}),o.map(d=>r.jsx("div",{className:"h-full absolute inset-0",style:{display:p==="terminal"&&l===d?"block":"none"},children:r.jsx(Zu,{cwd:d,quickCommands:_})},d)),p==="preview"&&r.jsx(Tn,{icon:r.jsx(tr,{size:32}),title:"Preview"}),p==="changes"&&r.jsx(Ym,{workingDir:l}),p==="history"&&r.jsx(sp,{workingDir:l})]})]})});function oa(e){return yt({queryKey:oe.workspaces.list(e),queryFn:()=>ue.get(`/tasks/${e}/workspaces`),enabled:!!e})}function aa(e){const t=We();return nt({mutationFn:s=>ue.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.workspaces.list(e)}),t.invalidateQueries({queryKey:oe.tasks.all})}})}function op(){const e=We();return nt({mutationFn:({id:t,commitMessage:s})=>ue.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function ap(){const e=We();return nt({mutationFn:t=>ue.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Ci(){return nt({mutationFn:({workspaceId:e,editorType:t})=>ue.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function la(e){return yt({queryKey:oe.workspaces.gitStatus(e),queryFn:()=>ue.get(`/workspaces/${e}/git-status`),enabled:!!e})}function lp(){const e=We();return nt({mutationFn:t=>ue.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}function cp(){const e=We();return nt({mutationFn:t=>ue.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}const Dn=1500,dp=3e3;function up(e){const[t,s]=E.useState(null),l=E.useRef(0),m=E.useRef(null),v=E.useRef(null);return E.useEffect(()=>{if(!e)return;const x=()=>{v.current&&(clearTimeout(v.current),v.current=null)},i=Pt.connect(),n=f=>{s(f),v.current=setTimeout(()=>s(null),dp)},c=f=>{if(f.taskId!==e)return;const a={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){x(),m.current=null,l.current===0&&(l.current=Date.now()),s(a);return}const p=l.current>0?Date.now()-l.current:0,S=Dn-p;l.current===0?(l.current=Date.now(),s({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=a,v.current=setTimeout(()=>n(a),Dn)):S>0?(m.current=a,x(),v.current=setTimeout(()=>n(a),S)):n(a)};return i.on(Je.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(Je.WORKSPACE_SETUP_PROGRESS,c),x(),l.current=0,m.current=null}},[e]),t}function wi(){const e=We();return nt({mutationFn:t=>ue.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function ca(){const e=We();return nt({mutationFn:t=>ue.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)})}})}function Ei(){const e=We();return nt({mutationFn:({id:t,message:s,providerId:l})=>ue.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function hp(e,t){const s={};return yt({queryKey:oe.tasks.list(e,t),queryFn:()=>ue.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function fp(e){const t=We();return nt({mutationFn:s=>ue.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.tasks.list(e)}),t.invalidateQueries({queryKey:oe.tasks.stats(e)})}})}function mp(){const e=We();return nt({mutationFn:({id:t,status:s})=>ue.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function pp(){const e=We();return nt({mutationFn:t=>ue.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tasks.all})}})}function vp(){const e=We();return nt({mutationFn:t=>ue.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function da(e,t){return E.useMemo(()=>{for(let s=e.length-1;s>=0;s--){const l=e[s];if(l.tokenUsage&&typeof l.tokenUsage.totalTokens=="number"&&l.tokenUsage.totalTokens>0)return{totalTokens:l.tokenUsage.totalTokens,modelContextWindow:l.tokenUsage.modelContextWindow}}return t??null},[e,t])}const gp="/api";async function _p(e){const t=new FormData;t.append("file",e);const s=await fetch(`${gp}/attachments/upload`,{method:"POST",body:t});if(!s.ok){const l=await s.json().catch(()=>({}));throw new Error(l.error||`Upload failed (${s.status})`)}return s.json()}let xp=0;function ki(){const[e,t]=E.useState([]),s=E.useRef(e);s.current=e;const l=E.useCallback(async c=>{const f=c.map(a=>({tempId:`tmp-${++xp}`,file:a,progress:0,status:"uploading"}));t(a=>[...a,...f]),await Promise.allSettled(f.map(async a=>{try{const p=await _p(a.file);t(S=>S.map(y=>y.tempId===a.tempId?{...y,status:"done",progress:100,attachment:p}:y))}catch(p){t(S=>S.map(y=>y.tempId===a.tempId?{...y,status:"error",error:p instanceof Error?p.message:"Upload failed"}:y))}}))},[]),m=E.useCallback(c=>{t(f=>f.filter(a=>a.tempId!==c))},[]),v=E.useCallback(()=>{t([])},[]),x=E.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const a=f.attachment;return`${a.mimeType.startsWith("image/")?"!":""}[${a.originalName}](${a.storagePath})`}).join(`
70
+ `)},[]),i=e.length>0,n=e.some(c=>c.status==="uploading");return{files:e,addFiles:l,removeFile:m,clear:v,buildMarkdownLinks:x,hasFiles:i,isUploading:n}}const bp="/api";function Sp(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function ji({files:e,onRemove:t}){return e.length===0?null:r.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(s=>r.jsx(yp,{item:s,onRemove:t},s.tempId))})}function yp({item:e,onRemove:t}){const s=e.file.type.startsWith("image/"),l=e.status==="error",m=e.status==="uploading";return r.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${l?"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?r.jsx("img",{src:`${bp}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):r.jsx("span",{className:"flex-shrink-0",children:m?r.jsx(Pe,{size:16,className:"animate-spin text-neutral-400"}):s?r.jsx(li,{size:16,className:"text-neutral-400"}):r.jsx(io,{size:16,className:"text-neutral-400"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate font-medium",children:e.file.name}),l?r.jsx("div",{className:"truncate text-red-500",children:e.error}):r.jsx("div",{className:"text-neutral-400",children:Sp(e.file.size)})]}),r.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:r.jsx(Cs,{size:10})})]})}function ua({isOpen:e,onClose:t,taskId:s,taskTitle:l,taskDescription:m}){const{t:v}=ae(),[x,i]=E.useState(""),[n,c]=E.useState(""),[f,a]=E.useState("idle"),[p,S]=E.useState(null),y=We(),_=aa(s),o=wi(),{data:h,isLoading:u}=ws();E.useEffect(()=>{if(!e||!h)return;const w=h.find(j=>j.availability.type!=="NOT_FOUND");w&&i(w.provider.id)},[e,h]),E.useEffect(()=>{if(e){const w=[l];m&&w.push(m),c(w.join(`
71
+
72
+ `)),a("idle"),S(null)}},[e,l,m]);const d=f!=="idle",b=async()=>{if(!(!x||!n.trim())){S(null);try{a("creating-workspace");const w=await _.mutateAsync({});a("creating-session");const j=await ue.post(`/workspaces/${w.id}/sessions`,{providerId:x,prompt:n.trim()});a("starting-session"),await o.mutateAsync(j.id),await y.invalidateQueries({queryKey:oe.workspaces.list(s)}),a("idle"),t()}catch(w){a("idle"),S(w instanceof Error?w.message:v("启动失败,请重试"))}}},C={idle:v("启动"),"creating-workspace":v("创建工作空间..."),"creating-session":v("创建会话..."),"starting-session":v("启动 Agent...")};return r.jsx(sr,{isOpen:e,onClose:d?()=>{}:t,title:v("启动 Agent"),action:r.jsxs(r.Fragment,{children:[r.jsx(ze,{variant:"outline",onClick:t,disabled:d,children:v("取消")}),r.jsx(ze,{onClick:b,disabled:d||!x||!n.trim(),children:C[f]})]}),children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("选择 Provider")}),r.jsxs("div",{className:"flex gap-2 flex-wrap",children:[u&&r.jsx("span",{className:"text-sm text-neutral-400",children:v("加载中...")}),h?.map(({provider:w,availability:j})=>{const g=j.type!=="NOT_FOUND";return r.jsxs(ze,{variant:x===w.id?"default":"outline",size:"sm",disabled:!g||d,onClick:()=>i(w.id),children:[w.name,!g&&v(" (不可用)")]},w.id)})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("任务描述")}),r.jsx("textarea",{value:n,onChange:w=>c(w.target.value),rows:5,disabled:d,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&&r.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:p})]})})}function Cp(e,t){return e instanceof Error?e.message:t}function wp(e){return Object.values(e).filter(Boolean).length}function Mn({title:e,error:t,isFetching:s,onRetry:l,disabled:m}){const{t:v}=ae();return r.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"font-medium",children:e}),r.jsx("div",{className:"mt-1 text-xs text-red-600",children:Cp(t,v("请稍后重试。"))})]}),r.jsx(ze,{type:"button",size:"sm",variant:"outline",onClick:l,disabled:m||s,children:s?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{size:14,className:"animate-spin"}),v("加载中...")]}):v("重试")})]})})}function ha({mode:e,setMode:t,selectedTemplateId:s,setSelectedTemplateId:l,selectedMemberPresetIds:m,setSelectedMemberPresetIds:v,disabled:x=!1}){const{t:i}=ae(),{data:n}=ws(),{data:c,error:f,isError:a,isFetching:p,isLoading:S,refetch:y}=nl(),{data:_,error:o,isError:h,isFetching:u,isLoading:d,refetch:b}=ol(),C=E.useMemo(()=>new Map((n??[]).map(({provider:N,availability:P})=>[N.id,N.name+(P.type==="NOT_FOUND"?i(" (不可用)"):"")])),[n,i]),w=E.useMemo(()=>new Map((c??[]).map(N=>[N.id,N])),[c]),j=E.useMemo(()=>new Map((_??[]).map(N=>[N.id,N])),[_]),g=s?j.get(s)??null:null,k=E.useMemo(()=>m.map(N=>w.get(N)).filter(N=>!!N),[w,m]);E.useEffect(()=>{c!==void 0&&v(N=>{const P=N.filter(B=>w.has(B));return P.length===N.length&&P.every((B,z)=>B===N[z])?N:P})},[c,w,v]),E.useEffect(()=>{_!==void 0&&l(N=>!N||j.has(N)?N:null)},[l,j,_]);const R=N=>{x||l(P=>P===N?null:N)},D=N=>{x||v(P=>P.includes(N)?P.filter(B=>B!==N):[...P,N])},M=(N,P)=>{x||v(B=>{const z=N+P;if(z<0||z>=B.length)return B;const W=[...B],[A]=W.splice(N,1);return W.splice(z,0,A),W})};return r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i("TeamRun 模式")}),r.jsx("div",{className:"text-xs text-neutral-500",children:i("默认使用确认模式,便于先检查团队编排。")})]}),r.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[r.jsx("button",{type:"button",onClick:()=>!x&&t("CONFIRM"),disabled:x,className:ne("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("确认模式")}),r.jsx("button",{type:"button",onClick:()=>!x&&t("AUTO"),disabled:x,className:ne("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("自动模式")})]})]}),r.jsx("div",{className:"pr-1",children:r.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[r.jsxs("div",{className:"space-y-5",children:[r.jsxs("section",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("团队模板")}),r.jsx("p",{className:"text-xs text-neutral-400",children:i("模板成员会先加入,随后按顺序追加所选成员。")})]}),h?r.jsx(Mn,{title:i("团队模板加载失败"),error:o,isFetching:u,onRetry:()=>{b()},disabled:x}):d?r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),i("加载中...")]}):(_??[]).length===0?r.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[r.jsx("div",{children:i("当前没有团队模板")}),r.jsx(ze,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:r.jsx(Hs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):r.jsx("div",{className:"space-y-2",children:(_??[]).map(N=>{const P=N.id===s,B=N.members?.length??0,z=N.members?.slice(0,3).map(W=>W.memberPreset?.name??W.memberPresetId).join(" · ");return r.jsx("button",{type:"button",onClick:()=>R(N.id),disabled:x,className:ne("w-full rounded-lg border px-3 py-2 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60",P?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:N.name}),r.jsx("div",{className:"mt-1 truncate text-xs text-neutral-500",children:i("{count} 个成员",{count:B})}),z&&r.jsx("div",{className:"mt-2 truncate text-[11px] text-neutral-400",children:z})]}),P&&r.jsx(Yt,{size:14,className:"mt-0.5 shrink-0 text-neutral-900"})]})},N.id)})})]}),r.jsxs("section",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("成员预设")}),r.jsx("p",{className:"text-xs text-neutral-400",children:i("选择顺序即保存顺序。")})]}),a?r.jsx(Mn,{title:i("成员预设加载失败"),error:f,isFetching:p,onRetry:()=>{y()},disabled:x}):S?r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),i("加载中...")]}):(c??[]).length===0?r.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[r.jsx("div",{children:i("当前没有成员预设")}),r.jsx(ze,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:r.jsx(Hs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):r.jsx("div",{className:"space-y-2",children:(c??[]).map(N=>{const P=m.includes(N.id),B=C.get(N.providerId)??N.providerId,z=wp(N.capabilities);return r.jsxs("label",{className:ne("flex cursor-pointer items-start gap-3 rounded-lg border px-3 py-2 transition-colors",x&&"cursor-not-allowed opacity-60",P?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[r.jsx("input",{type:"checkbox",checked:P,onChange:()=>D(N.id),disabled:x,className:"mt-1 h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-400 disabled:cursor-not-allowed"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:N.name}),r.jsx("div",{className:"truncate text-xs text-neutral-500",children:B})]}),r.jsxs("div",{className:"shrink-0 text-[11px] text-neutral-400",children:[z,"/10"]})]},N.id)})})]})]}),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("section",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("已选成员")}),r.jsx("p",{className:"text-xs text-neutral-400",children:i("上移下移后即为保存顺序。")})]}),k.length===0?r.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:i("尚未选择成员预设")}):r.jsx("div",{className:"space-y-2",children:k.map((N,P)=>{const B=C.get(N.providerId)??N.providerId;return r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:N.name}),r.jsx("div",{className:"truncate text-xs text-neutral-500",children:B})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(ze,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(P,-1),disabled:x||P===0,title:i("上移"),children:r.jsx(bl,{size:14})}),r.jsx(ze,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(P,1),disabled:x||P===k.length-1,title:i("下移"),children:r.jsx(jt,{size:14})})]})]},N.id)})})]}),r.jsxs("section",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-4",children:[r.jsx("div",{className:"text-xs font-medium text-neutral-700",children:i("模板成员会先加入,随后按顺序追加所选成员。")}),r.jsx("div",{className:"mt-2 text-xs text-neutral-500",children:g?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-medium text-neutral-700",children:g.name}),r.jsx("span",{className:"mx-1",children:"·"}),r.jsx("span",{children:i("{count} 个成员",{count:g.members?.length??0})})]}):r.jsx("span",{children:i("请选择至少一个团队模板或成员预设。")})})]})]})]})})]})}function Ep({isOpen:e,onClose:t,taskId:s}){const{t:l}=ae(),[m,v]=E.useState("CONFIRM"),[x,i]=E.useState(null),[n,c]=E.useState([]),[f,a]=E.useState(null),p=Yn();E.useEffect(()=>{e&&(v("CONFIRM"),i(null),c([]),a(null))},[e]);const S=p.isPending,y=!!x||n.length>0,_=async()=>{if(!S){if(!x&&n.length===0){a(l("请选择至少一个团队模板或成员预设。"));return}a(null);try{await p.mutateAsync({taskId:s,mode:m,...x?{teamTemplateId:x}:{},...n.length>0?{memberPresetIds:n}:{}}),t()}catch(h){if(h instanceof al&&h.status===409){a(l("该任务已经存在 TeamRun。请刷新后再试。"));return}a(h instanceof Error?h.message:l("创建 TeamRun 失败"))}}},o=S||!y;return r.jsxs(sr,{isOpen:e,onClose:S?()=>{}:t,title:l("创建 TeamRun"),className:"max-w-5xl",action:r.jsxs(r.Fragment,{children:[r.jsx(ze,{type:"button",variant:"outline",onClick:t,disabled:S,children:l("取消")}),r.jsx(ze,{type:"button",onClick:_,disabled:o,children:l(S?"处理中...":"创建 TeamRun")})]}),children:[r.jsx(ha,{mode:m,setMode:v,selectedTemplateId:x,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:c,disabled:S}),f&&r.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f})]})}function fa({providers:e,currentProviderId:t,agentType:s,onSelect:l}){const{t:m}=ae(),[v,x]=E.useState(!1),i=E.useRef(null),n=e.filter(f=>String(f.provider.agentType)===s),c=e.find(f=>f.provider.id===t);return E.useEffect(()=>{function f(a){i.current&&!i.current.contains(a.target)&&x(!1)}if(v)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[v]),n.length<=1?r.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[r.jsx(Bi,{size:14,className:"shrink-0"}),r.jsx("span",{children:c?.provider.name?Wi(c.provider.name,12):s})]}):r.jsxs("div",{className:"relative",ref:i,children:[r.jsxs("button",{onClick:()=>x(!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:[r.jsx(Bi,{size:14,className:"shrink-0"}),r.jsx("span",{children:c?.provider.name?Wi(c.provider.name,12):s}),r.jsx(jt,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&r.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:[r.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),n.map(f=>r.jsxs("button",{onClick:()=>{l(f.provider.id),x(!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:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&r.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===t&&r.jsx(Yt,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function kp({commands:e,selectedIndex:t,query:s,hasCatalog:l,title:m="Slash Commands",queryPrefix:v="/",emptyCatalogMessage:x="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:c=!1,onSelect:f}){const a=c?"px-1.5 pb-1.5":"px-2 pb-2",p=c?"px-2 py-1.5":"px-2.5 py-2",S=c?"max-h-36":"max-h-48";return r.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[r.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),r.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?r.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:l?i??`No matches for ${v}${s}`:x}):r.jsx("div",{className:`${a} ${S} overflow-y-auto`,children:e.map((y,_)=>r.jsxs("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>f(y),className:`w-full rounded-lg border text-left transition-colors ${_===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${p}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?r.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:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),r.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Mt=12,Bs=8;function Zs({open:e,anchorRef:t,commands:s,selectedIndex:l,query:m,hasCatalog:v,title:x,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:a=!1,onSelect:p}){const S=E.useRef(null),[y,_]=E.useState(null);return E.useLayoutEffect(()=>{if(!e){_(null);return}const o=t.current;if(!o)return;let h=0;const u=()=>{const C=t.current;if(!C)return;const w=C.getBoundingClientRect(),j=window.innerWidth,g=window.innerHeight,k=a?260:320,R=a?j-Mt*2:560,D=Math.min(Math.max(w.width,k),Math.max(k,R)),M=Math.min(Math.max(Mt,w.left),Math.max(Mt,j-Mt-D)),N=g-w.bottom-Bs-Mt,P=w.top-Bs-Mt,B=S.current?.offsetHeight??(a?220:280),z=a?240:320,W=N<180&&P>N,L=Math.max(120,Math.min(z,W?P:N)),O=W?Math.max(Mt,w.top-Bs-Math.min(B,L)):Math.min(g-Mt-Math.min(B,L),w.bottom+Bs);_({top:O,left:M,width:D,maxHeight:L})},d=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(u)};d();const b=new ResizeObserver(d);return b.observe(o),S.current&&b.observe(S.current),window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.visualViewport?.addEventListener("resize",d),window.visualViewport?.addEventListener("scroll",d),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.visualViewport?.removeEventListener("resize",d),window.visualViewport?.removeEventListener("scroll",d)}},[t,s.length,a,e,m,l]),!e||!y||typeof document>"u"?null:qt.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:r.jsx("div",{ref:S,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:r.jsx(kp,{commands:s,selectedIndex:l,query:m,hasCatalog:v,title:x,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:a,onSelect:p})})}),document.body)}function jp({workspaceId:e,gitStatus:t,onResolve:s}){const{t:l}=ae(),m=cp();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const v=t.operation==="rebase"?"Rebase":"Merge";return r.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:[r.jsx(eo,{size:18,className:"text-amber-600 shrink-0"}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("p",{className:"text-sm font-medium text-amber-900",children:l("{opLabel} 冲突 — {count} 个文件",{opLabel:v,count:t.conflictedFiles.length})})}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx(ze,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:l("中止操作")}),r.jsx(ze,{size:"sm",onClick:s,children:l("解决冲突")})]})]})}function Np(e,t,s,l){const m=s.map(v=>`- ${v}`).join(`
73
+ `);return l===fl.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 Rp({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:v,targetBranch:x,sessions:i}){const{t:n}=ae(),[c,f]=E.useState(""),a=Ei(),p=Ci(),S=()=>{if(!c)return;const o=Np(v,x,m,l);a.mutate({id:c,message:o},{onSuccess:()=>t(!1)})},y=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},_=l==="REBASE"?"Rebase":"Merge";return r.jsx(sr,{isOpen:e,onClose:()=>t(!1),title:n("解决 {opLabel} 冲突",{opLabel:_}),action:r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ze,{variant:"outline",onClick:y,children:n("在 IDE 中打开")}),r.jsx(ze,{onClick:S,disabled:!c||a.isPending,children:a.isPending?n("发送中..."):n("AI 辅助解决")})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:n("冲突文件({count})",{count:m.length})}),r.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(o=>r.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:o},o))})]}),i.length>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:n("选择 Session(AI 辅助解决)")}),r.jsxs("select",{value:c,onChange:o=>f(o.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:[r.jsx("option",{value:"",children:n("选择一个 Session...")}),i.map(o=>r.jsxs("option",{value:o.id,children:[o.agentType," — ",o.status]},o.id))]})]}),i.length===0&&r.jsx("p",{className:"text-sm text-neutral-500",children:n("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Ut({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 r.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 Ap({gitStatus:e,branchName:t,targetBranch:s}){const{t:l}=ae();return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),r.jsx(so,{size:14,className:"text-neutral-400"}),r.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:s})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&r.jsxs(Ut,{variant:"danger",children:[r.jsx(Hl,{size:12}),l("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&r.jsxs(Ut,{variant:"warning",children:[r.jsx(eo,{size:12}),l("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&r.jsxs(Ut,{variant:"warning",children:[r.jsx(Pe,{size:12,className:"animate-spin"}),l("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&r.jsxs(Ut,{variant:"warning",children:[r.jsx(Pe,{size:12,className:"animate-spin"}),l("合并进行中")]}),e.ahead>0&&r.jsxs(Ut,{variant:"success",children:[r.jsx(qi,{size:12}),l("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&r.jsx(Ut,{variant:"warning",children:l("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&r.jsxs(Ut,{variant:"neutral",children:[r.jsx(qi,{size:12}),l("已是最新")]})]}),e.hasUncommittedChanges&&r.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:l("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function Tp({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:v,onRefreshCommitMessage:x,onConflict:i}){const{t:n}=ae(),{data:c,isLoading:f}=la(s),a=lp(),p=op(),[S,y]=E.useState(null),[_,o]=E.useState("select"),[h,u]=E.useState(""),[d,b]=E.useState(!1),C=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,j=c?.hasUncommittedChanges??!1;E.useEffect(()=>{e&&(o("select"),y(null),b(!1),x?.())},[e,x]),E.useEffect(()=>{!e||d||u(v??"")},[e,v,d]);const g=N=>{b(!0),u(P=>typeof N=="function"?N(P):N)},k=()=>{y(null),a.mutate(s,{onSuccess:()=>t(!1),onError:N=>{const P=N;P.status===409?(t(!1),i()):y(P.message??n("变基失败"))}})},R=()=>{y(null),o("confirm")},D=()=>{y(null);const N=h.trim()||void 0;p.mutate({id:s,commitMessage:N},{onSuccess:()=>t(!1),onError:P=>{const B=P;B.status===409?(t(!1),i()):y(B.message??n("合并失败"))}})},M=n(_==="confirm"?"确认合并":"Git 操作");return r.jsx(sr,{isOpen:e,onClose:()=>t(!1),title:M,children:f||!c?r.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[r.jsx(Pe,{size:18,className:"animate-spin"}),r.jsx("span",{className:"text-sm",children:n("加载分支状态...")})]}):_==="confirm"?r.jsx(Mp,{editableMessage:h,setEditableMessage:g,error:S,isPending:p.isPending,onConfirm:D,onBack:()=>o("select"),branchName:l,targetBranch:m}):r.jsx(Dp,{gitStatus:c,branchName:l,targetBranch:m,error:S,isDirty:j,hasConflicts:C,isOperationInProgress:w,rebasePending:a.isPending,mergePending:p.isPending,onRebase:k,onMerge:R})})}function Dp({gitStatus:e,branchName:t,targetBranch:s,error:l,isDirty:m,hasConflicts:v,isOperationInProgress:x,rebasePending:i,mergePending:n,onRebase:c,onMerge:f}){const{t:a}=ae();return r.jsxs("div",{className:"space-y-5",children:[r.jsx(Ap,{gitStatus:e,branchName:t,targetBranch:s}),l&&r.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("button",{onClick:c,disabled:i||v||x||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:[r.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:r.jsx(Kl,{size:16,className:"text-blue-600"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900",children:a(i?"变基中...":"变基 (Rebase)")}),r.jsx("div",{className:"text-xs text-neutral-500",children:a("将当前分支变基到最新的 {targetBranch}",{targetBranch:s})})]})]}),r.jsxs("button",{onClick:f,disabled:n||v||x||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:[r.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:r.jsx(oo,{size:16,className:"text-emerald-600"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900",children:a(n?"合并中...":"合并 (Merge)")}),r.jsx("div",{className:"text-xs text-neutral-500",children:a("Squash merge 到 {targetBranch}",{targetBranch:s})})]})]})]})]})}function Mp({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:v,branchName:x,targetBranch:i}){const{t:n}=ae();return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:x}),r.jsx(so,{size:14,className:"text-neutral-400"}),r.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:i})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:n("提交消息")}),r.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:n("输入提交消息..."),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()&&r.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:n("留空将使用默认消息")})]}),s&&r.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:s}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:v,disabled:l,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:n("返回")}),r.jsx("button",{onClick:m,disabled:l,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:l?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{size:14,className:"animate-spin"}),n("合并中...")]}):r.jsxs(r.Fragment,{children:[r.jsx(oo,{size:14}),n("确认合并")]})})]})]})}function Lp({agentType:e,workingDir:t}){return yt({queryKey:oe.system.slashCommandCatalog(e,t),queryFn:async()=>(await ue.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function Pp(e,t){const s=new Set,l=[];for(const m of[...e,...t]){const v=m.command.trim().toLowerCase();!v||s.has(v)||(s.add(v),l.push(m.kind?m:{...m,kind:"builtin"}))}return l}function mr(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function Op(e){return mr(e.command)}function Ip(e,t){if(!t)return 1e3;const s=Op(e),l=e.aliases?.map(mr)??[],m=[s,...l];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} ${l.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function Ln(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const s=t.index+t[1].length;return{query:mr(t[2]),replaceStart:s}}function ma(e,t){const s=mr(t);return s?e.map((l,m)=>({command:l,index:m,score:Ip(l,s)})).filter(l=>l.score>0).sort((l,m)=>m.score-l.score||l.index-m.index||l.command.command.localeCompare(m.command.command)).map(l=>l.command):e.slice()}const Bp=[{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"}],Fp=[{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"}],Hp=[{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"}],zp=[{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"}],Wp={[Rt.CODEX]:Bp,[Rt.CLAUDE_CODE]:Fp,[Rt.GEMINI_CLI]:Hp,[Rt.CURSOR_AGENT]:zp};function pa(e){return e.trim().toLowerCase().replace(/^\//,"")}function $p(e){return e?(Wp[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function Up(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?pa(t[1]):null}function qp(e,t){return ma(e,pa(t))}function Kp(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 va({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:x}){const[i,n]=E.useState(0),{data:c=[]}=Lp({agentType:e,workingDir:t}),f=E.useMemo(()=>Pp($p(e),c),[e,c]),a=E.useMemo(()=>Up(s),[s]),p=E.useMemo(()=>a===null?[]:qp(f,a),[f,a]),S=E.useCallback(()=>{const o=m.current;o&&(o.style.height="auto",o.style.height=`${Math.max(v,Math.min(o.scrollHeight,x))}px`)},[x,v,m]);E.useEffect(()=>{n(0)},[e,a]),E.useEffect(()=>{i<p.length||n(0)},[p.length,i]);const y=E.useCallback(o=>{const u=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${o.command} `;l(u),requestAnimationFrame(()=>{const d=m.current;d&&(S(),d.focus(),d.setSelectionRange(u.length,u.length))})},[s,S,l,m]),_=E.useCallback(o=>a===null||p.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(h=>(h+1)%p.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(h=>(h-1+p.length)%p.length),!0):Kp(o)?(o.preventDefault(),y(p[i]??p[0]),!0):!1,[y,p,a,i]);return{allCommands:f,query:a,filteredCommands:p,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:_}}function Xp({agentType:e,workingDir:t}){return yt({queryKey:oe.system.skillCatalog(e,t),queryFn:async()=>(await ue.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===Rt.CODEX,staleTime:3e4})}function Yp(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 ga({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:x}){const[i,n]=E.useState(0),{data:c=[]}=Xp({agentType:e,workingDir:t}),a=E.useMemo(()=>e===Rt.CODEX?Ln(s):null,[e,s])?.query??null,p=E.useMemo(()=>a===null?[]:ma(c,a),[a,c]),S=E.useCallback(()=>{const o=m.current;o&&(o.style.height="auto",o.style.height=`${Math.max(v,Math.min(o.scrollHeight,x))}px`)},[x,v,m]);E.useEffect(()=>{n(0)},[e,a]),E.useEffect(()=>{i<p.length||n(0)},[p.length,i]);const y=E.useCallback(o=>{const h=Ln(s);if(!h)return;const u=`${s.slice(0,h.replaceStart)}${o.command} `;l(u),requestAnimationFrame(()=>{const d=m.current;d&&(S(),d.focus(),d.setSelectionRange(u.length,u.length))})},[s,S,l,m]),_=E.useCallback(o=>a===null||p.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(h=>(h+1)%p.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(h=>(h-1+p.length)%p.length),!0):Yp(o)?(o.preventDefault(),y(p[i]??p[0]),!0):!1,[y,p,a,i]);return{allSkills:c,query:a,filteredSkills:p,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:_}}const Vp="/api",Gp=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Vp}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Qp=({src:e,alt:t,...s})=>r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:r.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"})}),Zp={img:Qp},Jp=675,Pn=320,On=1200;function e0(){const{t:e}=ae();return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[r.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:r.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:[r.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),r.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),r.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 In=[{status:de.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:r.jsx(ei,{className:"w-3 h-3"})},{status:de.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:r.jsx(ti,{className:"w-3 h-3"})},{status:de.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:r.jsx(si,{className:"w-3 h-3"})},{status:de.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:r.jsx(ri,{className:"w-3 h-3"})},{status:de.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:r.jsx(ii,{className:"w-3 h-3"})}];function t0({status:e,onChangeStatus:t}){const{t:s}=ae(),[l,m]=E.useState(!1),v=E.useRef(null);E.useEffect(()=>{if(!l)return;const i=n=>{v.current&&!v.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[l]);const x=In.find(i=>i.status===e);return r.jsxs("div",{className:"relative",ref:v,children:[r.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 ${x.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[x.icon,r.jsx("span",{children:s(e)}),t&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${l?"rotate-180":""}`,children:r.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),l&&r.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:In.filter(i=>i.status!==e).map(i=>r.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:[r.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),r.jsx("span",{className:"text-neutral-700",children:s(i.status)})]},i.status))})]})}function s0({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const{t:m}=ae(),[v,x]=E.useState(""),[i,n]=E.useState(!1),[c,f]=E.useState(!1),[a,p]=E.useState(!1),[S,y]=E.useState(!1),[_,o]=E.useState(!1),[h,u]=E.useState(!1),[d,b]=E.useState(!1),[C,w]=E.useState(!1),[j,g]=E.useState(null),[k,R]=E.useState(!1),D=E.useRef(null),M=E.useRef(null),N=E.useRef(null),P=E.useRef(null),{scrollRef:B,contentRef:z,isAtBottom:W,scrollToBottom:A}=xi({resize:"smooth",initial:"instant"}),[L,O]=E.useState(Jp),[I,F]=E.useState(!0),[U,X]=E.useState(!1),Y=E.useRef(0),J=E.useRef(0),T=E.useRef(null),{data:H,isLoading:q}=oa(e?.id??""),$=up(e?.id),{data:ee}=ll(e?.id??""),{data:Q}=cl(ee?.id??""),le=dl(ee?.id??""),he=ee??null,Se=!!he,Be=ee===null;E.useEffect(()=>{R(!1),g(null)},[e?.id]),E.useEffect(()=>{if(!k||!H)return;H.some(se=>se.status==="ACTIVE"&&se.sessions&&se.sessions.length>0)&&R(!1)},[H,k]);const Z=E.useMemo(()=>{if(k||!H)return null;const G=Xe=>{const br=Xe.createdAt,os=Xe.endedAt??Xe.startedAt??br;if(!os)return 0;const Gt=Date.parse(os);return Number.isNaN(Gt)?0:Gt},se=(Xe,br)=>{const os=Xe.filter(Gt=>br.includes(Gt.status));return os.length===0?null:os.sort((Gt,za)=>G(za)-G(Gt))[0]??null},Ce=H.filter(Xe=>Xe.status==="ACTIVE"&&Array.isArray(Xe.sessions)).flatMap(Xe=>Xe.sessions??[]),xt=se(Ce,[Re.RUNNING])??se(Ce,[Re.PENDING])??se(Ce,[Re.COMPLETED,Re.FAILED,Re.CANCELLED]);if(xt)return xt;const it=H.filter(Xe=>(Xe.status==="MERGED"||Xe.status==="ABANDONED"||Xe.status==="HIBERNATED")&&Array.isArray(Xe.sessions)).flatMap(Xe=>Xe.sessions??[]);return se(it,[Re.COMPLETED,Re.FAILED,Re.CANCELLED])},[H,k]),Ye=Z?.id??"",fe=Se?j??"":Ye,st=E.useMemo(()=>{if(!j||!H)return null;for(const G of H){const se=G.sessions?.find(Ce=>Ce.id===j);if(se)return se}return null},[j,H])??Z??null,$e=st?.status===Re.RUNNING||st?.status===Re.PENDING,ge=!!e?.projectArchivedAt,Ae=!!e?.projectRepoDeletedAt,we=m(Ae?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:tt}=ws(),[Te,je]=E.useState(null);E.useEffect(()=>{je(Z?.providerId??null)},[Z?.providerId]);const Ze=E.useMemo(()=>!Z||!H?!1:!H.some(se=>se.status==="ACTIVE"&&se.sessions?.some(Ce=>Ce.id===Z.id)),[Z,H]),Ue=E.useMemo(()=>{if(!(!H||k)){for(const G of H)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return H[0]?.worktreePath}},[H,k]),_e=va({agentType:Z?.agentType,workingDir:Ue,input:v,setInput:x,textareaRef:N,minHeight:60,maxHeight:300}),K=ga({agentType:Z?.agentType,workingDir:Ue,input:v,setInput:x,textareaRef:N,minHeight:60,maxHeight:300}),te=E.useMemo(()=>H?H.find(se=>se.status==="ACTIVE")?.id:void 0,[H]),{data:xe}=la(te??""),pe=E.useMemo(()=>H?H.find(se=>se.status==="ACTIVE")?.sessions??[]:[],[H]),Ve=E.useMemo(()=>H?H.find(se=>se.status==="ACTIVE")?.branchName??"":"",[H]),rt=E.useMemo(()=>H?H.find(se=>se.status==="ACTIVE")?.commitMessage:void 0,[H]),ie=We(),gt=E.useCallback(()=>e?.id?ie.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,ie]);E.useEffect(()=>{if(!C)return;const G=se=>{M.current&&!M.current.contains(se.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[C]);const ct=Ei(),_t=Ci(),ye=vp(),qe=aa(e?.id??""),Ke=wi(),ot=ap(),Oe=E.useMemo(()=>!H||H.some(se=>se.status==="ACTIVE")?null:H.find(se=>se.status==="HIBERNATED")??null,[H]),Ge=E.useRef(null);E.useEffect(()=>{Oe&&Ge.current!==Oe.id&&(ot.isPending||(Ge.current=Oe.id,ot.mutate(Oe.id,{onSettled:()=>{Ge.current=null}})))},[Oe,ot]);const dt=E.useCallback(async()=>{if(!e?.id)return;const G=Z?.providerId??tt?.find(Ce=>Ce.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const se=[e.title,e.description].filter(Boolean).join(`
76
+
77
+ `);y(!1),o(!0);try{await ye.mutateAsync(e.id),R(!0);const Ce=await qe.mutateAsync({}),xt=await ue.post(`/workspaces/${Ce.id}/sessions`,{providerId:G,prompt:se});await Ke.mutateAsync(xt.id),await ie.invalidateQueries({queryKey:oe.workspaces.list(e.id)})}catch(Ce){console.error("[retry] failed:",Ce),R(!1)}finally{o(!1)}},[e?.id,e?.title,e?.description,Z?.providerId,tt,ye,qe,Ke,ie]),Ct=E.useCallback(()=>{te&&_t.mutate({workspaceId:te})},[te,_t]),De=E.useCallback(()=>{!e?.id||!t||(t(e.id),p(!1))},[e?.id,t]),ft=E.useCallback(G=>{g(G),requestAnimationFrame(()=>{A()})},[A]),ut=E.useCallback(()=>{g(null)},[]),mt=E.useCallback(G=>le.mutateAsync(G),[le]),at=E.useCallback(()=>{ie.invalidateQueries({queryKey:ul.all})},[ie]),{isConnected:wt,isLoadingSnapshot:pt,logs:ht,entries:Wt,attach:$t}=Gn({sessionId:fe,sessionStatus:st?.status,onExit:E.useCallback(()=>{ie.invalidateQueries({queryKey:["workspaces"]})},[ie])});E.useEffect(()=>{if(!e?.id)return;const G=Pt.connect();G.emit(Zt.SUBSCRIBE,{topic:"task",id:e.id});const se=it=>{it.taskId===e.id&&(ie.invalidateQueries({queryKey:["tasks"]}),at())},Ce=it=>{it.taskId===e.id&&(ie.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),at())},xt=it=>{it.taskId===e.id&&(ie.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),at())};return G.on(Je.TASK_UPDATED,se),G.on(Je.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ce),G.on(Je.WORKSPACE_HIBERNATED,xt),()=>{G.off(Je.TASK_UPDATED,se),G.off(Je.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ce),G.off(Je.WORKSPACE_HIBERNATED,xt),G.emit(Zt.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,ie,at]),E.useEffect(()=>{if(!fe)return;const G=Pt.connect(),se=Ce=>{Ce.sessionId===fe&&(ie.invalidateQueries({queryKey:["workspaces"]}),at())};return G.on(Je.SESSION_COMPLETED,se),()=>{G.off(Je.SESSION_COMPLETED,se)}},[fe,ie,at]);const{todos:ns}=Qn(Wt),{files:Ri,addFiles:V,removeFile:ce,clear:be,buildMarkdownLinks:He,hasFiles:Me,isUploading:Le}=ki(),Tt=E.useMemo(()=>{if(!Z?.tokenUsage)return;const G=Z.tokenUsage;if(typeof G.totalTokens=="number")return G},[Z?.tokenUsage]),Dt=da(ht,Tt);E.useEffect(()=>{fe&&wt&&$t()},[fe,wt,$t]);const Ai=E.useRef(e?.id);E.useEffect(()=>{if(Ai.current!==e?.id&&B.current){const G=B.current;requestAnimationFrame(()=>{G.scrollTop=G.scrollHeight})}Ai.current=e?.id},[e?.id,B]);const pr=ca(),vr=E.useRef(!1),Ti=E.useCallback(async()=>{if(!v.trim()&&!Me||!fe||vr.current||Le)return;vr.current=!0;const G=He(),se=[v.trim(),G].filter(Boolean).join(`
78
+
79
+ `);x(""),be(),N.current&&(N.current.style.height="60px"),ct.mutate({id:fe,message:se,providerId:Te??void 0},{onSuccess:()=>{$t()},onSettled:()=>{vr.current=!1}})},[v,fe,ct,$t,Me,Le,He,be,Te]),Da=E.useCallback(async()=>{fe&&(await pr.mutateAsync(fe),ie.invalidateQueries({queryKey:["workspaces"]}))},[fe,pr,ie]),Ma=E.useCallback(G=>{const se=G.target.files;se&&se.length>0&&V(Array.from(se)),G.target.value=""},[V]),La=E.useCallback(G=>{const se=G.clipboardData.items,Ce=[];for(const xt of se)if(xt.kind==="file"){const it=xt.getAsFile();it&&Ce.push(it)}Ce.length>0&&(G.preventDefault(),V(Ce))},[V]),[Di,gr]=E.useState(!1),Pa=E.useCallback(G=>{G.preventDefault(),gr(!0)},[]),Oa=E.useCallback(G=>{G.preventDefault(),gr(!1)},[]),Ia=E.useCallback(G=>{G.preventDefault(),gr(!1);const se=G.dataTransfer.files;se.length>0&&V(Array.from(se))},[V]),_r=E.useCallback(G=>{const se=G.clientX-Y.current,Ce=Math.max(Pn,Math.min(J.current+se,On));T.current&&(T.current.style.width=`${Ce}px`)},[]),xr=E.useCallback(()=>{if(X(!1),T.current){const G=T.current.getBoundingClientRect().width;O(Math.max(Pn,Math.min(Math.round(G),On)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);E.useEffect(()=>{if(U)return document.addEventListener("mousemove",_r),document.addEventListener("mouseup",xr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_r),document.removeEventListener("mouseup",xr),document.body.style.cursor="",document.body.style.userSelect=""}},[U,_r,xr]);const Ba=E.useCallback(G=>{G.preventDefault(),Y.current=G.clientX,J.current=L,X(!0)},[L]),Fa=E.useCallback(()=>{F(G=>!G)},[]),Ha=E.useCallback(G=>{x(G.target.value);const se=G.target;se.style.height="auto";const Ce=se.scrollHeight;se.style.height=`${Math.max(60,Math.min(Ce,300))}px`},[]),Mi=E.useMemo(()=>{const G=[];if(H&&H.length>0){const se=H.some(it=>it.status==="ACTIVE"),Ce=H.some(it=>it.sessions?.some(Xe=>Xe.status===Re.RUNNING||Xe.status===Re.PENDING)),xt=H.some(it=>it.status==="ACTIVE");Ce&&G.push(m("正在运行的 Agent 将被停止")),xt&&G.push(m("分支上未合并的变更将丢失")),se&&G.push(m("关联的工作目录(worktree)将被清理"))}return G},[H,m]);return e?r.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[r.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:[r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&r.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),r.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),r.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),r.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(t0,{status:e.status,onChangeStatus:!ge&&l?G=>l(e.id,G):void 0}),te&&!ge&&r.jsx("button",{onClick:()=>b(!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:r.jsx(Yl,{size:18})}),r.jsx("button",{onClick:Ct,disabled:!te||ge,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:r.jsx(rr,{size:18})}),r.jsx("button",{onClick:Fa,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:I?r.jsx(lc,{size:18}):r.jsx(di,{size:18})}),Be&&!ge&&r.jsxs("button",{onClick:()=>f(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:m("创建 TeamRun"),children:[r.jsx(vs,{size:14}),r.jsx("span",{children:m("创建 TeamRun")})]}),t&&!ge&&r.jsxs("div",{className:"relative",ref:M,children:[r.jsx("button",{onClick:()=>w(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:r.jsx(ro,{size:18})}),C&&r.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[r.jsxs("button",{onClick:()=>{y(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[r.jsx(gl,{size:15}),r.jsx("span",{children:m("重新开始")})]}),r.jsxs("button",{onClick:()=>{p(!0),w(!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:[r.jsx(Jn,{size:15}),r.jsx("span",{children:m("删除任务")})]})]})]})]})]}),te&&xe&&r.jsx(jp,{workspaceId:te,gitStatus:xe,onResolve:()=>u(!0)}),r.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[r.jsx("div",{ref:T,className:`flex flex-col bg-white relative ${I?"flex-shrink-0":"flex-1"}`,style:{width:I?L:"100%"},children:Se&&he?j?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),r.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:j})]}),r.jsx(ze,{type:"button",size:"sm",variant:"outline",onClick:ut,children:m("Back to room")})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{ref:B,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:r.jsx("div",{ref:z,className:"w-full",children:pt?r.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[r.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):ht.length===0?r.jsx("div",{className:"text-neutral-400 text-center py-8",children:m($e?"Waiting for agent output...":"No logs recorded for this session.")}):r.jsx(Hr,{logs:ht})})}),!W&&r.jsxs("button",{onClick:()=>A(),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:[r.jsx(Ws,{size:14}),r.jsx("span",{children:m("回到底部")})]})]})]}):r.jsx(Nu,{teamRun:he,messages:Q??he.messages??[],readOnly:ge,readOnlyMessage:we,onSendMessage:mt,onViewInvocationSession:ft}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{ref:B,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:r.jsxs("div",{ref:z,className:"w-full",children:[r.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?r.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:r.jsx(ni,{urlTransform:Gp,components:Zp,children:e.description})}):r.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),$&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[$.status==="running"&&r.jsxs(r.Fragment,{children:[r.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:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:$.currentIndex,total:$.totalCommands,command:$.currentCommand})})]}),$.status==="completed"&&r.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),$.status==="failed"&&r.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:$.error})})]}),q?r.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[r.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{className:"text-sm",children:m("Loading...")})]}):Ye?pt?r.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[r.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):ht.length===0?r.jsx("div",{className:"text-neutral-400 text-center py-8",children:m($e?"Waiting for agent output...":"No logs recorded for this session.")}):r.jsx(Hr,{logs:ht}):r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:r.jsx(Kt,{size:24,className:"text-neutral-400 ml-0.5"})}),r.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(ge?"项目为只读历史":"尚未启动 Agent")}),r.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:ge?we:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ge&&r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[r.jsxs(ze,{onClick:()=>n(!0),children:[r.jsx(Kt,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),Be&&r.jsxs(ze,{variant:"outline",onClick:()=>f(!0),children:[r.jsx(vs,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!W&&r.jsxs("button",{onClick:()=>A(),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:[r.jsx(Ws,{size:14}),r.jsx("span",{children:m("回到底部")})]})]}),ns.length>0&&r.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:r.jsx(Zn,{todos:ns})}),ge?r.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:r.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:we})}):Ze?r.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:r.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[r.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),r.jsxs(ze,{size:"sm",onClick:()=>n(!0),children:[r.jsx(Kt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):r.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Pa,onDragLeave:Oa,onDrop:Ia,children:[r.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 ${Di?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[r.jsx(ji,{files:Ri,onRemove:ce}),r.jsx("textarea",{ref:N,value:v,onChange:Ha,onPaste:La,onKeyDown:G=>{K.handleKeyDown(G)||_e.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),Ti())},rows:1,placeholder:m(Di?"Drop files here...":Ye&&!$e?"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"}}),r.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Ma}),r.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("button",{onClick:()=>P.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:r.jsx(oi,{size:18})})}),r.jsxs("div",{className:"flex items-center gap-2",children:[Z&&tt&&r.jsx(fa,{providers:tt,currentProviderId:Te,agentType:Z.agentType,onSelect:je}),r.jsx(Ro,{usage:Dt}),$e&&!v.trim()&&!Me?r.jsx("button",{onClick:Da,disabled:pr.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:r.jsx(zs,{size:14})}):r.jsx("button",{onClick:Ti,disabled:!v.trim()&&!Me||Le,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||Me)&&!Le?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:r.jsx(ai,{size:18})})]})]})]}),r.jsx(Zs,{open:_e.query!==null,anchorRef:D,commands:_e.filteredCommands,selectedIndex:_e.selectedIndex,query:_e.query??"",hasCatalog:_e.allCommands.length>0,onSelect:_e.applyCommand}),r.jsx(Zs,{open:K.query!==null,anchorRef:D,commands:K.filteredSkills,selectedIndex:K.selectedIndex,query:K.query??"",hasCatalog:K.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:K.applySkill})]})]})}),I&&r.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:Ba}),I&&r.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:r.jsx(na,{sessionId:Ye||void 0,workingDir:Ue,projectId:e.projectId,readOnly:ge,repoDeleted:Ae,teamRun:he,teamStatus:he?r.jsx(Wu,{teamRun:he,onViewInvocationSession:ft}):void 0})})]}),!ge&&r.jsx(ua,{isOpen:i,onClose:()=>n(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),Be&&!ge&&r.jsx(Ep,{isOpen:c,onClose:()=>f(!1),taskId:e.id}),te&&!ge&&r.jsx(Tp,{open:d,onOpenChange:b,workspaceId:te,branchName:Ve,targetBranch:e.mainBranch,commitMessage:rt,onRefreshCommitMessage:gt,onConflict:()=>u(!0)}),te&&xe&&xe.conflictOp&&r.jsx(Rp,{open:h,onOpenChange:u,workspaceId:te,conflictOp:xe.conflictOp,conflictedFiles:xe.conflictedFiles,sourceBranch:Ve,targetBranch:e.mainBranch,sessions:pe}),r.jsx(zr,{isOpen:S,onClose:()=>y(!1),onConfirm:dt,title:m("重新开始任务"),description:r.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:_}),r.jsx(zr,{isOpen:a,onClose:()=>p(!1),onConfirm:De,title:m("删除任务"),description:r.jsxs(r.Fragment,{children:[r.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),Mi.length>0&&r.jsx("ul",{className:"mt-2 space-y-1",children:Mi.map((G,se)=>r.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[r.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),r.jsx("span",{children:G})]},se))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):r.jsx(e0,{})}function Ni(e){switch(e){case Nt.TODO:return de.Pending;case Nt.IN_PROGRESS:return de.Running;case Nt.IN_REVIEW:return de.Review;case Nt.DONE:return de.Done;case Nt.CANCELLED:return de.Cancelled}}function r0(e){switch(e){case de.Pending:return Nt.TODO;case de.Running:return Nt.IN_PROGRESS;case de.Review:return Nt.IN_REVIEW;case de.Done:return Nt.DONE;case de.Cancelled:return Nt.CANCELLED}}function i0(e){switch(e){case Rt.CLAUDE_CODE:return"Claude Code";case Rt.GEMINI_CLI:return"Gemini CLI";case Rt.CURSOR_AGENT:return"Cursor Agent";case Rt.CODEX:return"Codex"}}const Js=["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 _a(e,t){let s=0;for(let l=0;l<e.length;l++)s=(s<<5)-s+e.charCodeAt(l)|0;return Math.abs(s)%t}function xa(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function n0(e){return{id:e.id,name:e.name,color:e.color||Js[_a(e.name,Js.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function o0(e){const t=xa(e);if(!t)return{agent:"—",branch:"—"};const s=t.branchName,l=t.sessions;if(l&&l.length>0){const m=l[l.length-1];return{agent:i0(m.agentType),branch:s}}return{agent:"—",branch:s}}function a0(e){const{agent:t,branch:s}=o0(e.workspaces),l=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Ni(e.status),agent:t,branch:s,description:e.description??"",projectArchivedAt:l?.archivedAt??null,projectRepoDeletedAt:l?.repoDeletedAt??null}}function l0(e,t,s){const l=xa(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Js[_a(t.name,Js.length)],title:e.title,status:Ni(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const Bn={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 c0(e){const t=e.split("/");return t[t.length-1]||e}function d0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function u0({workingDir:e,filePath:t,type:s}){const{t:l}=ae(),{data:m,isLoading:v,isError:x}=sa(e,t,s);if(v)return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),r.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(x)return r.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return r.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const n=i.split(`
80
+ `);return r.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((c,f)=>{let a="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(a="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(a="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(a="bg-blue-950/30",p="text-blue-400"),r.jsx("div",{className:ne("px-3 whitespace-pre",a,p),children:c},f)})})}function h0({entry:e,type:t,workingDir:s}){const[l,m]=E.useState(!1),v=Bn[e.status]||Bn.M,x=d0(e.path);return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>m(i=>!i),className:ne("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[r.jsx("span",{className:ne("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:c0(e.path)}),x&&r.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),r.jsx("span",{className:"text-neutral-400 shrink-0",children:l?r.jsx(jt,{size:14}):r.jsx(Ht,{size:14})})]}),l&&r.jsx(u0,{workingDir:s,filePath:e.path,type:t})]})}function Fn({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=ae(),[x,i]=E.useState(m);return t.length===0?null:r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[r.jsx("span",{className:"text-neutral-400",children:x?r.jsx(jt,{size:14}):r.jsx(Ht,{size:14})}),r.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),r.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),x&&r.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(n=>r.jsx(h0,{entry:n,type:s,workingDir:l},`${s}:${n.path}`))})]})}function f0({workingDir:e}){const{t}=ae(),{data:s,isLoading:l,isError:m}=ta(e);if(!e)return r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(l)return r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return r.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||[],x=s?.committed||[];return v.length+x.length===0?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[r.jsx(_s,{size:28,className:"mb-3"}),r.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):r.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[r.jsx(Fn,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),r.jsx(Fn,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const Ir=50,Hn={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 m0(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ot("{count}s ago",{count:s}):s<3600?Ot("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ot("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ot("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function p0(e){const t=e.split("/");return t[t.length-1]||e}function v0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function g0({workingDir:e,hash:t,filePath:s}){const{t:l}=ae(),{data:m,isLoading:v,isError:x}=ia(e,t,s);if(v)return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),r.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(x)return r.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return r.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const n=i.split(`
81
+ `);return r.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((c,f)=>{let a="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(a="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(a="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(a="bg-blue-950/30",p="text-blue-400"),r.jsx("div",{className:ne("px-3 whitespace-pre",a,p),children:c},f)})})}function _0({entry:e,workingDir:t,hash:s}){const[l,m]=E.useState(!1),v=Hn[e.status]||Hn.M,x=v0(e.path);return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>m(i=>!i),className:ne("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[r.jsx("span",{className:ne("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:p0(e.path)}),x&&r.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),r.jsx("span",{className:"text-neutral-400 shrink-0",children:l?r.jsx(jt,{size:14}):r.jsx(Ht,{size:14})})]}),l&&r.jsx(g0,{workingDir:t,hash:s,filePath:e.path})]})}function x0({commit:e,workingDir:t}){const{t:s}=ae(),[l,m]=E.useState(!1),{data:v,isLoading:x}=ra(t,l?e.hash:null),i=v?.files||[];return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>m(n=>!n),className:ne("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[r.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:r.jsx("div",{className:ne("w-2.5 h-2.5 rounded-full shrink-0",l?"bg-blue-500":"bg-neutral-300")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),r.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),r.jsx("span",{className:"text-[11px] text-neutral-400",children:m0(e.timestamp)})]})]}),r.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?r.jsx(jt,{size:14}):r.jsx(Ht,{size:14})})]}),l&&r.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&r.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),x?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[r.jsx(Pe,{size:14,className:"animate-spin"}),r.jsx("span",{className:"text-xs",children:s("Loading files...")})]}):i.length===0?r.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:s("No files changed")}):r.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>r.jsx(_0,{entry:n,workingDir:t,hash:e.hash},n.path))})]})]})}function b0({workingDir:e}){const{t}=ae(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:x,isFetchingNextPage:i}=to({queryKey:oe.git.log(e||""),queryFn:({pageParam:c=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(Ir),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<Ir?void 0:f.length*Ir,enabled:!!e}),n=s?.pages.flatMap(c=>c.commits)||[];return e?l?r.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[r.jsx(Pe,{size:16,className:"animate-spin mr-2"}),r.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?r.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):n.length===0?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[r.jsx(ss,{size:28,className:"mb-3"}),r.jsx("span",{className:"text-sm",children:t("No commit history")})]}):r.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[r.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(c=>r.jsx(x0,{commit:c,workingDir:e},c.hash))}),x&&r.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?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const S0="/api",y0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${S0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,C0=({src:e,alt:t,...s})=>r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:r.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"})}),w0={img:C0};function E0({status:e}){const t={[de.Running]:"bg-blue-500",[de.Review]:"bg-amber-500",[de.Pending]:"bg-neutral-400",[de.Done]:"bg-emerald-500",[de.Cancelled]:"bg-neutral-400"};return r.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const k0=[{key:"chat",label:"Chat",icon:ci},{key:"changes",label:"Changes",icon:_s},{key:"history",label:"History",icon:ss},{key:"workspace",label:"Workspace",icon:no}];function j0({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=ae(),[v,x]=E.useState("chat"),[i,n]=E.useState(""),[c,f]=E.useState(!1),[a,p]=E.useState(!1),[S,y]=E.useState(!1),_=E.useRef(null),o=E.useRef(null),h=E.useRef(null),u=E.useRef(null),{scrollRef:d,contentRef:b,isAtBottom:C,scrollToBottom:w}=xi({resize:"smooth",initial:"instant"}),j=We();E.useEffect(()=>{if(!S)return;const K=te=>{o.current&&!o.current.contains(te.target)&&y(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[S]);const{data:g,isLoading:k}=oa(e.id),R=E.useMemo(()=>{if(!g)return null;const K=g.filter(ie=>ie.status==="ACTIVE"&&Array.isArray(ie.sessions)).flatMap(ie=>ie.sessions??[]),te=ie=>{const gt=ie.createdAt,ct=ie.endedAt??ie.startedAt??gt;if(!ct)return 0;const _t=Date.parse(ct);return Number.isNaN(_t)?0:_t},xe=ie=>{const gt=K.filter(ct=>ie.includes(ct.status));return gt.length===0?null:gt.sort((ct,_t)=>te(_t)-te(ct))[0]??null},pe=xe([Re.RUNNING])??xe([Re.PENDING])??xe([Re.COMPLETED,Re.FAILED,Re.CANCELLED]);if(pe)return pe;const rt=g.filter(ie=>(ie.status==="ABANDONED"||ie.status==="MERGED"||ie.status==="HIBERNATED")&&Array.isArray(ie.sessions)).flatMap(ie=>ie.sessions??[]).filter(ie=>[Re.COMPLETED,Re.FAILED,Re.CANCELLED].includes(ie.status));return rt.length===0?null:rt.sort((ie,gt)=>te(gt)-te(ie))[0]??null},[g]),D=R?.id??"",M=R?.status===Re.RUNNING||R?.status===Re.PENDING,N=!!e.projectArchivedAt,P=!!e.projectRepoDeletedAt,B=m(P?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),z=E.useMemo(()=>!R||!g?!1:!g.some(te=>te.status==="ACTIVE"&&te.sessions?.some(xe=>xe.id===R.id)),[R,g]),{data:W}=ws(),[A,L]=E.useState(null);E.useEffect(()=>{L(R?.providerId??null)},[R?.providerId]);const O=E.useMemo(()=>{if(g){for(const K of g)if(K.status==="ACTIVE"&&K.worktreePath)return K.worktreePath;return g[0]?.worktreePath}},[g]),I=va({agentType:R?.agentType,workingDir:O,input:i,setInput:n,textareaRef:h,minHeight:40,maxHeight:140}),F=ga({agentType:R?.agentType,workingDir:O,input:i,setInput:n,textareaRef:h,minHeight:40,maxHeight:140}),U=E.useMemo(()=>{if(g)return g.find(K=>K.status==="ACTIVE")?.id},[g]),X=E.useMemo(()=>{const K=[];if(g&&g.length>0){const te=g.some(pe=>pe.status==="ACTIVE");g.some(pe=>pe.sessions?.some(Ve=>Ve.status===Re.RUNNING||Ve.status===Re.PENDING))&&K.push(m("正在运行的 Agent 将被停止")),te&&(K.push(m("分支上未合并的变更将丢失")),K.push(m("关联的工作目录(worktree)将被清理")))}return K},[g,m]),Y=Ei(),J=Ci(),T=ca(),{isConnected:H,isLoadingSnapshot:q,logs:$,entries:ee,attach:Q}=Gn({sessionId:D,sessionStatus:R?.status,onExit:E.useCallback(()=>{j.invalidateQueries({queryKey:["workspaces"]})},[j])}),{todos:le}=Qn(ee),{files:he,addFiles:Se,removeFile:Be,clear:Z,buildMarkdownLinks:Ye,hasFiles:fe,isUploading:Fe}=ki(),st=E.useMemo(()=>{if(!R?.tokenUsage)return;const K=R.tokenUsage;if(typeof K.totalTokens=="number")return K},[R?.tokenUsage]),$e=da($,st);E.useEffect(()=>{D&&H&&Q()},[D,H,Q]);const ge=E.useRef(null);E.useEffect(()=>{if(ge.current!==e.id&&d.current){const K=d.current;requestAnimationFrame(()=>{K.scrollTop=K.scrollHeight})}ge.current=e.id},[e.id,d]);const Ae=E.useRef(!1),we=E.useCallback(async()=>{if(!i.trim()&&!fe||!D||Ae.current||Fe)return;Ae.current=!0;const K=Ye(),te=[i.trim(),K].filter(Boolean).join(`
82
+
83
+ `);n(""),Z(),h.current&&(h.current.style.height="40px"),Y.mutate({id:D,message:te,providerId:A??void 0},{onSuccess:()=>Q(),onSettled:()=>{Ae.current=!1}})},[i,D,Y,Q,fe,Fe,Ye,Z,A]),tt=E.useCallback(async()=>{D&&(await T.mutateAsync(D),j.invalidateQueries({queryKey:["workspaces"]}))},[D,T,j]),Te=E.useCallback(K=>{const te=K.target.files;te&&te.length>0&&Se(Array.from(te)),K.target.value=""},[Se]),je=E.useCallback(K=>{const te=K.clipboardData.items,xe=[];for(const pe of te)if(pe.kind==="file"){const Ve=pe.getAsFile();Ve&&xe.push(Ve)}xe.length>0&&(K.preventDefault(),Se(xe))},[Se]),Ze=E.useCallback(K=>{n(K.target.value);const te=K.target;te.style.height="auto",te.style.height=`${Math.max(40,Math.min(te.scrollHeight,140))}px`},[]),Ue=E.useCallback(()=>{U&&J.mutate({workspaceId:U})},[U,J]),_e=E.useRef(null);return E.useEffect(()=>{const K=window.visualViewport;if(!K)return;let te=!1;const xe=()=>{_e.current&&(_e.current.style.height=`${K.height}px`,_e.current.style.top=`${K.offsetTop}px`)},pe=()=>xe(),Ve=()=>{te||xe()},rt=()=>{te=!0},ie=()=>{te=!1,requestAnimationFrame(xe)};return K.addEventListener("resize",pe),K.addEventListener("scroll",Ve),document.addEventListener("touchstart",rt,{passive:!0}),document.addEventListener("touchend",ie,{passive:!0}),document.addEventListener("touchcancel",ie,{passive:!0}),()=>{K.removeEventListener("resize",pe),K.removeEventListener("scroll",Ve),document.removeEventListener("touchstart",rt),document.removeEventListener("touchend",ie),document.removeEventListener("touchcancel",ie)}},[]),E.useEffect(()=>{const K=_e.current;if(!K)return;const te=xe=>{let pe=xe.target;for(;pe&&pe!==K;){if(pe.tagName==="TEXTAREA"){if(pe.scrollHeight>pe.clientHeight)return;pe=pe.parentElement;continue}const rt=window.getComputedStyle(pe).overflowY;if((rt==="auto"||rt==="scroll")&&pe.scrollHeight>pe.clientHeight)return;pe=pe.parentElement}xe.preventDefault()};return K.addEventListener("touchmove",te,{passive:!1}),()=>K.removeEventListener("touchmove",te)},[]),r.jsxs("div",{ref:_e,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[r.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[r.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[r.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:r.jsx(hl,{size:18})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),r.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[r.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&r.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),r.jsx("span",{className:"text-neutral-300",children:"/"}),r.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),r.jsx(E0,{status:e.status}),r.jsx("button",{onClick:Ue,disabled:!U||N,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:r.jsx(rr,{size:16})}),s&&!N&&r.jsxs("div",{className:"relative",ref:o,children:[r.jsx("button",{onClick:()=>y(K=>!K),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:r.jsx(ro,{size:16})}),S&&r.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:r.jsxs("button",{onClick:()=>{p(!0),y(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[r.jsx(Jn,{size:15}),r.jsx("span",{children:m("删除任务")})]})})]})]}),r.jsx("div",{className:"flex border-t border-neutral-100",children:k0.map(({key:K,label:te,icon:xe})=>r.jsxs("button",{onClick:()=>x(K),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===K?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[r.jsx(xe,{size:13}),r.jsx("span",{children:te})]},K))})]}),v==="chat"&&r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{ref:d,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:r.jsxs("div",{ref:b,children:[r.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?r.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:r.jsx(ni,{urlTransform:y0,components:w0,children:e.description})}):r.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),k?r.jsx(zn,{label:"Loading..."}):D?q?r.jsx(zn,{label:"Loading logs..."}):$.length===0?r.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:M?"Waiting for agent output...":"No logs recorded."}):r.jsx(Hr,{logs:$}):r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:r.jsx(Kt,{size:20,className:"text-neutral-400 ml-0.5"})}),r.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),r.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:N?B:m("选择一个 Agent 来执行此任务")}),!N&&r.jsxs(ze,{onClick:()=>f(!0),children:[r.jsx(Kt,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!C&&r.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:[r.jsx(Ws,{size:12}),r.jsx("span",{children:m("回到底部")})]})]}),le.length>0&&r.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:r.jsx(Zn,{todos:le,compact:!0})}),N?r.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:B})}):z?r.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[r.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),r.jsxs(ze,{size:"sm",onClick:()=>f(!0),children:[r.jsx(Kt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):D&&r.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[r.jsxs("div",{ref:_,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[r.jsx(ji,{files:he,onRemove:Be}),r.jsx("textarea",{ref:h,value:i,onChange:Ze,onPaste:je,onKeyDown:K=>{F.handleKeyDown(K)||I.handleKeyDown(K)||K.key==="Enter"&&!K.shiftKey&&!K.repeat&&!K.nativeEvent.isComposing&&K.nativeEvent.keyCode!==229&&(K.preventDefault(),we())},rows:1,placeholder:M?"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}}),r.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:Te}),r.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[r.jsx("div",{className:"flex items-center gap-0.5",children:r.jsx("button",{onClick:()=>u.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:r.jsx(oi,{size:15})})}),r.jsxs("div",{className:"flex items-center gap-1",children:[R&&W&&r.jsx(fa,{providers:W,currentProviderId:A,agentType:R.agentType,onSelect:L}),r.jsx(Ro,{usage:$e}),M&&!i.trim()&&!fe?r.jsx("button",{onClick:tt,disabled:T.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:r.jsx(zs,{size:12})}):r.jsx("button",{onClick:we,disabled:!i.trim()&&!fe||Fe,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||fe)&&!Fe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:r.jsx(ai,{size:15})})]})]})]}),r.jsx(Zs,{open:I.query!==null,anchorRef:_,commands:I.filteredCommands,selectedIndex:I.selectedIndex,query:I.query??"",hasCatalog:I.allCommands.length>0,compact:!0,onSelect:I.applyCommand}),r.jsx(Zs,{open:F.query!==null,anchorRef:_,commands:F.filteredSkills,selectedIndex:F.selectedIndex,query:F.query??"",hasCatalog:F.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:F.applySkill})]})]}),v==="changes"&&r.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:r.jsx(f0,{workingDir:O})}),v==="history"&&r.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:r.jsx(b0,{workingDir:O})}),v==="workspace"&&r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(na,{sessionId:D||void 0,workingDir:O,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:N,repoDeleted:P})}),!N&&r.jsx(ua,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),r.jsx(zr,{isOpen:a,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:r.jsxs(r.Fragment,{children:[r.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),X.length>0&&r.jsx("ul",{className:"mt-2 space-y-1",children:X.map((K,te)=>r.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[r.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),r.jsx("span",{children:K})]},te))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function zn({label:e}){return r.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[r.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{className:"text-sm",children:e})]})}var N0=Object.defineProperty,er=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,Sa=Object.prototype.propertyIsEnumerable,Wn=(e,t,s)=>t in e?N0(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Qr=(e,t)=>{for(var s in t||(t={}))ba.call(t,s)&&Wn(e,s,t[s]);if(er)for(var s of er(t))Sa.call(t,s)&&Wn(e,s,t[s]);return e},Zr=(e,t)=>{var s={};for(var l in e)ba.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&er)for(var l of er(e))t.indexOf(l)<0&&Sa.call(e,l)&&(s[l]=e[l]);return s};var Vt;(e=>{const t=class me{constructor(n,c,f,a){if(this.version=n,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],n<me.MIN_VERSION||n>me.MAX_VERSION)throw new RangeError("Version value out of range");if(a<-1||a>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let p=[];for(let y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(f);if(this.drawCodewords(S),a==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const o=this.getPenaltyScore();o<y&&(a=_,y=o),this.applyMask(_)}}m(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,c){const f=e.QrSegment.makeSegments(n);return me.encodeSegments(f,c)}static encodeBinary(n,c){const f=e.QrSegment.makeBytes(n);return me.encodeSegments([f],c)}static encodeSegments(n,c,f=1,a=40,p=-1,S=!0){if(!(me.MIN_VERSION<=f&&f<=a&&a<=me.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,_;for(y=f;;y++){const d=me.getNumDataCodewords(y,c)*8,b=x.getTotalBits(n,y);if(b<=d){_=b;break}if(y>=a)throw new RangeError("Data too long")}for(const d of[me.Ecc.MEDIUM,me.Ecc.QUARTILE,me.Ecc.HIGH])S&&_<=me.getNumDataCodewords(y,d)*8&&(c=d);let o=[];for(const d of n){s(d.mode.modeBits,4,o),s(d.numChars,d.mode.numCharCountBits(y),o);for(const b of d.getData())o.push(b)}m(o.length==_);const h=me.getNumDataCodewords(y,c)*8;m(o.length<=h),s(0,Math.min(4,h-o.length),o),s(0,(8-o.length%8)%8,o),m(o.length%8==0);for(let d=236;o.length<h;d^=253)s(d,8,o);let u=[];for(;u.length*8<o.length;)u.push(0);return o.forEach((d,b)=>u[b>>>3]|=d<<7-(b&7)),new me(y,c,u,p)}getModule(n,c){return 0<=n&&n<this.size&&0<=c&&c<this.size&&this.modules[c][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let 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 n=this.getAlignmentPatternPositions(),c=n.length;for(let f=0;f<c;f++)for(let a=0;a<c;a++)f==0&&a==0||f==0&&a==c-1||f==c-1&&a==0||this.drawAlignmentPattern(n[f],n[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const c=this.errorCorrectionLevel.formatBits<<3|n;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const a=(c<<10|f)^21522;m(a>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(a,p));this.setFunctionModule(8,7,l(a,6)),this.setFunctionModule(8,8,l(a,7)),this.setFunctionModule(7,8,l(a,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(a,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(a,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(a,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let f=0;f<12;f++)n=n<<1^(n>>>11)*7973;const c=this.version<<12|n;m(c>>>18==0);for(let f=0;f<18;f++){const a=l(c,f),p=this.size-11+f%3,S=Math.floor(f/3);this.setFunctionModule(p,S,a),this.setFunctionModule(S,p,a)}}drawFinderPattern(n,c){for(let f=-4;f<=4;f++)for(let a=-4;a<=4;a++){const p=Math.max(Math.abs(a),Math.abs(f)),S=n+a,y=c+f;0<=S&&S<this.size&&0<=y&&y<this.size&&this.setFunctionModule(S,y,p!=2&&p!=4)}}drawAlignmentPattern(n,c){for(let f=-2;f<=2;f++)for(let a=-2;a<=2;a++)this.setFunctionModule(n+a,c+f,Math.max(Math.abs(a),Math.abs(f))!=1)}setFunctionModule(n,c,f){this.modules[c][n]=f,this.isFunction[c][n]=!0}addEccAndInterleave(n){const c=this.version,f=this.errorCorrectionLevel;if(n.length!=me.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const a=me.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=me.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],S=Math.floor(me.getNumRawDataModules(c)/8),y=a-S%a,_=Math.floor(S/a);let o=[];const h=me.reedSolomonComputeDivisor(p);for(let d=0,b=0;d<a;d++){let C=n.slice(b,b+_-p+(d<y?0:1));b+=C.length;const w=me.reedSolomonComputeRemainder(C,h);d<y&&C.push(0),o.push(C.concat(w))}let u=[];for(let d=0;d<o[0].length;d++)o.forEach((b,C)=>{(d!=_-p||C>=y)&&u.push(b[d])});return m(u.length==S),u}drawCodewords(n){if(n.length!=Math.floor(me.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 a=0;a<this.size;a++)for(let p=0;p<2;p++){const S=f-p,_=(f+1&2)==0?this.size-1-a:a;!this.isFunction[_][S]&&c<n.length*8&&(this.modules[_][S]=l(n[c>>>3],7-(c&7)),c++)}}m(c==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let a;switch(n){case 0:a=(f+c)%2==0;break;case 1:a=c%2==0;break;case 2:a=f%3==0;break;case 3:a=(f+c)%3==0;break;case 4:a=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:a=f*c%2+f*c%3==0;break;case 6:a=(f*c%2+f*c%3)%2==0;break;case 7:a=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&a&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let n=0;for(let p=0;p<this.size;p++){let S=!1,y=0,_=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[p][o]==S?(y++,y==5?n+=me.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),S||(n+=this.finderPenaltyCountPatterns(_)*me.PENALTY_N3),S=this.modules[p][o],y=1);n+=this.finderPenaltyTerminateAndCount(S,y,_)*me.PENALTY_N3}for(let p=0;p<this.size;p++){let S=!1,y=0,_=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][p]==S?(y++,y==5?n+=me.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),S||(n+=this.finderPenaltyCountPatterns(_)*me.PENALTY_N3),S=this.modules[o][p],y=1);n+=this.finderPenaltyTerminateAndCount(S,y,_)*me.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let S=0;S<this.size-1;S++){const y=this.modules[p][S];y==this.modules[p][S+1]&&y==this.modules[p+1][S]&&y==this.modules[p+1][S+1]&&(n+=me.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((S,y)=>S+(y?1:0),c);const f=this.size*this.size,a=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=a&&a<=9),n+=a*me.PENALTY_N4,m(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let f=[6];for(let a=this.size-7;f.length<n;a-=c)f.splice(1,0,a);return f}}static getNumRawDataModules(n){if(n<me.MIN_VERSION||n>me.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*n+128)*n+64;if(n>=2){const f=Math.floor(n/7)+2;c-=(25*f-10)*f-55,n>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(n,c){return Math.floor(me.getNumRawDataModules(n)/8)-me.ECC_CODEWORDS_PER_BLOCK[c.ordinal][n]*me.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let c=[];for(let a=0;a<n-1;a++)c.push(0);c.push(1);let f=1;for(let a=0;a<n;a++){for(let p=0;p<c.length;p++)c[p]=me.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=me.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(n,c){let f=c.map(a=>0);for(const a of n){const p=a^f.shift();f.push(0),c.forEach((S,y)=>f[y]^=me.reedSolomonMultiply(S,p))}return f}static reedSolomonMultiply(n,c){if(n>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let a=7;a>=0;a--)f=f<<1^(f>>>7)*285,f^=(c>>>a&1)*n;return m(f>>>8==0),f}finderPenaltyCountPatterns(n){const c=n[1];m(c<=this.size*3);const f=c>0&&n[2]==c&&n[3]==c*3&&n[4]==c&&n[5]==c;return(f&&n[0]>=c*4&&n[6]>=c?1:0)+(f&&n[6]>=c*4&&n[0]>=c?1:0)}finderPenaltyTerminateAndCount(n,c,f){return n&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(n,c){c[0]==0&&(n+=this.size),c.pop(),c.unshift(n)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(i,n,c){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let f=n-1;f>=0;f--)c.push(i>>>f&1)}function l(i,n){return(i>>>n&1)!=0}function m(i){if(!i)throw new Error("Assertion error")}const v=class Ie{constructor(n,c,f){if(this.mode=n,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(n){let c=[];for(const f of n)s(f,8,c);return new Ie(Ie.Mode.BYTE,n.length,c)}static makeNumeric(n){if(!Ie.isNumeric(n))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<n.length;){const a=Math.min(n.length-f,3);s(parseInt(n.substring(f,f+a),10),a*3+1,c),f+=a}return new Ie(Ie.Mode.NUMERIC,n.length,c)}static makeAlphanumeric(n){if(!Ie.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=n.length;f+=2){let a=Ie.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f))*45;a+=Ie.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f+1)),s(a,11,c)}return f<n.length&&s(Ie.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f)),6,c),new Ie(Ie.Mode.ALPHANUMERIC,n.length,c)}static makeSegments(n){return n==""?[]:Ie.isNumeric(n)?[Ie.makeNumeric(n)]:Ie.isAlphanumeric(n)?[Ie.makeAlphanumeric(n)]:[Ie.makeBytes(Ie.toUtf8ByteArray(n))]}static makeEci(n){let c=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)s(n,8,c);else if(n<16384)s(2,2,c),s(n,14,c);else if(n<1e6)s(6,3,c),s(n,21,c);else throw new RangeError("ECI assignment value out of range");return new Ie(Ie.Mode.ECI,0,c)}static isNumeric(n){return Ie.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return Ie.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,c){let f=0;for(const a of n){const p=a.mode.numCharCountBits(c);if(a.numChars>=1<<p)return 1/0;f+=4+p+a.bitData.length}return f}static toUtf8ByteArray(n){n=encodeURI(n);let c=[];for(let f=0;f<n.length;f++)n.charAt(f)!="%"?c.push(n.charCodeAt(f)):(c.push(parseInt(n.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 x=v;e.QrSegment=v})(Vt||(Vt={}));(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={}))})(Vt||(Vt={}));(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={}))})(Vt||(Vt={}));var es=Vt;var R0={L:es.QrCode.Ecc.LOW,M:es.QrCode.Ecc.MEDIUM,Q:es.QrCode.Ecc.QUARTILE,H:es.QrCode.Ecc.HIGH},ya=128,Ca="L",wa="#FFFFFF",Ea="#000000",ka=!1,ja=1,A0=4,T0=0,D0=.1;function Na(e,t=0){const s=[];return e.forEach(function(l,m){let v=null;l.forEach(function(x,i){if(!x&&v!==null){s.push(`M${v+t} ${m+t}h${i-v}v1H${v+t}z`),v=null;return}if(i===l.length-1){if(!x)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}x&&v===null&&(v=i)})}),s.join("")}function Ra(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function M0(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*D0),x=m/t,i=(l.width||v)*x,n=(l.height||v)*x,c=l.x==null?e.length/2-i/2:l.x*x,f=l.y==null?e.length/2-n/2:l.y*x,a=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let y=Math.floor(c),_=Math.floor(f),o=Math.ceil(i+c-y),h=Math.ceil(n+f-_);p={x:y,y:_,w:o,h}}const S=l.crossOrigin;return{x:c,y:f,h:n,w:i,excavation:p,opacity:a,crossOrigin:S}}function L0(e,t){return t!=null?Math.max(Math.floor(t),0):e?A0:T0}function Aa({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:x,boostLevel:i}){let n=re.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,o)=>(_.push(...es.QrSegment.makeSegments(o)),_),[]);return es.QrCode.encodeSegments(y,R0[t],s,void 0,void 0,i)},[e,t,s,i]);const{cells:c,margin:f,numCells:a,calculatedImageSettings:p}=re.useMemo(()=>{let S=n.getModules();const y=L0(l,m),_=S.length+y*2,o=M0(S,x,y,v);return{cells:S,margin:y,numCells:_,calculatedImageSettings:o}},[n,x,v,l,m]);return{qrcode:n,margin:f,cells:c,numCells:a,calculatedImageSettings:p}}var P0=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),O0=re.forwardRef(function(t,s){const l=t,{value:m,size:v=ya,level:x=Ca,bgColor:i=wa,fgColor:n=Ea,includeMargin:c=ka,minVersion:f=ja,boostLevel:a,marginSize:p,imageSettings:S}=l,_=Zr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:o}=_,h=Zr(_,["style"]),u=S?.src,d=re.useRef(null),b=re.useRef(null),C=re.useCallback(P=>{d.current=P,typeof s=="function"?s(P):s&&(s.current=P)},[s]),[w,j]=re.useState(!1),{margin:g,cells:k,numCells:R,calculatedImageSettings:D}=Aa({value:m,level:x,minVersion:f,boostLevel:a,includeMargin:c,marginSize:p,imageSettings:S,size:v});re.useEffect(()=>{if(d.current!=null){const P=d.current,B=P.getContext("2d");if(!B)return;let z=k;const W=b.current,A=D!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&D.excavation!=null&&(z=Ra(k,D.excavation));const L=window.devicePixelRatio||1;P.height=P.width=v*L;const O=v/R*L;B.scale(O,O),B.fillStyle=i,B.fillRect(0,0,R,R),B.fillStyle=n,P0?B.fill(new Path2D(Na(z,g))):k.forEach(function(I,F){I.forEach(function(U,X){U&&B.fillRect(X+g,F+g,1,1)})}),D&&(B.globalAlpha=D.opacity),A&&B.drawImage(W,D.x+g,D.y+g,D.w,D.h)}}),re.useEffect(()=>{j(!1)},[u]);const M=Qr({height:v,width:v},o);let N=null;return u!=null&&(N=re.createElement("img",{src:u,key:u,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:D?.crossOrigin})),re.createElement(re.Fragment,null,re.createElement("canvas",Qr({style:M,height:v,width:v,ref:C,role:"img"},h)),N)});O0.displayName="QRCodeCanvas";var Ta=re.forwardRef(function(t,s){const l=t,{value:m,size:v=ya,level:x=Ca,bgColor:i=wa,fgColor:n=Ea,includeMargin:c=ka,minVersion:f=ja,boostLevel:a,title:p,marginSize:S,imageSettings:y}=l,_=Zr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:o,cells:h,numCells:u,calculatedImageSettings:d}=Aa({value:m,level:x,minVersion:f,boostLevel:a,includeMargin:c,marginSize:S,imageSettings:y,size:v});let b=h,C=null;y!=null&&d!=null&&(d.excavation!=null&&(b=Ra(h,d.excavation)),C=re.createElement("image",{href:y.src,height:d.h,width:d.w,x:d.x+o,y:d.y+o,preserveAspectRatio:"none",opacity:d.opacity,crossOrigin:d.crossOrigin}));const w=Na(b,o);return re.createElement("svg",Qr({height:v,width:v,viewBox:`0 0 ${u} ${u}`,ref:s,role:"img"},_),!!p&&re.createElement("title",null,p),re.createElement("path",{fill:i,d:`M0,0 h${u}v${u}H0z`,shapeRendering:"crispEdges"}),re.createElement("path",{fill:n,d:w,shapeRendering:"crispEdges"}),C)});Ta.displayName="QRCodeSVG";function I0(){return yt({queryKey:oe.tunnel.status,queryFn:()=>ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function B0(){const e=We();return nt({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ue.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function F0(){const e=We();return nt({mutationFn:()=>ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function $n(){const{t:e}=ae(),{data:t}=I0(),s=B0(),l=F0(),[m,v]=E.useState(!1),[x,i]=E.useState(null),n=E.useRef(null),[c,f]=E.useState({top:0,right:0}),[a,p]=E.useState(!1),S=t?.running??!1,y=s.isPending,_=t?.shareableUrl,o=t?.token;E.useEffect(()=>{if(m&&n.current){const C=n.current.getBoundingClientRect();f({top:C.bottom+8,right:window.innerWidth-C.right})}},[m]);const h=E.useCallback(()=>{S?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[S,s]),u=E.useCallback(()=>{_&&(navigator.clipboard.writeText(_),i("url"),setTimeout(()=>i(null),2e3))},[_]),d=E.useCallback(()=>{o&&(navigator.clipboard.writeText(o),i("token"),setTimeout(()=>i(null),2e3))},[o]),b=E.useCallback(()=>{l.mutate(),v(!1),p(!1)},[l]);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{ref:n,onClick:h,disabled:y,className:`p-1.5 rounded-md transition-colors ${S?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(S?"Tunnel active":"Share via tunnel"),children:y?r.jsx(Pe,{size:16,className:"animate-spin"}):r.jsx(tr,{size:16})}),S&&!y&&r.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&S&&qt.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),r.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:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[r.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),e("Tunnel Active")]}),r.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:r.jsx(Cs,{size:14})})]}),o&&r.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:[r.jsx(fc,{size:12}),r.jsx("span",{children:e("Token protected")})]}),_&&r.jsx("div",{className:"flex justify-center py-3",children:r.jsx(Ta,{value:_,size:160})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{readOnly:!0,value:_??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:C=>C.target.select()}),r.jsx("button",{onClick:u,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:x==="url"?r.jsx(Yt,{size:14,className:"text-emerald-500"}):r.jsx(Ki,{size:14})})]}),o&&r.jsxs("div",{className:"mt-2",children:[r.jsx("button",{onClick:()=>p(!a),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(a?"Hide token":"Show token")}),a&&r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.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:o}),r.jsx("button",{onClick:d,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:x==="token"?r.jsx(Yt,{size:14,className:"text-emerald-500"}):r.jsx(Ki,{size:14})})]})]}),r.jsx("button",{onClick:b,disabled:l.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:l.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}const Un={idle:"Create & Start","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},ls=E.lazy(()=>Vn(()=>import("./modal-B5IRN7QI.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),Br=E.lazy(()=>Vn(()=>import("./folder-picker-CtQkbWfa.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),qn=r.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:[r.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),r.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Kn=r.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),H0=260,z0=600,Xn=400;function iv(){const{t:e}=ae(),[t,s]=E.useState(null),[l,m]=E.useState(null),[v,x]=E.useState(Xn),[i,n]=E.useState(!1),[c,f]=E.useState(!1),[a,p]=E.useState(""),[S,y]=E.useState(""),[_,o]=E.useState(""),[h,u]=E.useState(""),[d,b]=E.useState(""),[C,w]=E.useState(""),[j,g]=E.useState("SOLO"),[k,R]=E.useState("CONFIRM"),[D,M]=E.useState(null),[N,P]=E.useState([]),[B,z]=E.useState(null),[W,A]=E.useState(null),[L,O]=E.useState("idle"),{files:I,addFiles:F,removeFile:U,clear:X,buildMarkdownLinks:Y,isUploading:J}=ki(),T=E.useRef(null),H=E.useRef(!1),q=E.useRef(0),$=E.useRef(Xn),ee=E.useRef(null),Q=We(),{data:le,isLoading:he}=ws(),{data:Se,isLoading:Be}=_l(),Z=E.useMemo(()=>Se?.data??[],[Se?.data]),Ye=E.useMemo(()=>Z.map(n0),[Z]),fe=l&&Z.some(V=>V.id===l)?l:null,{data:Fe,isLoading:st}=hp(fe??""),$e=wl({queries:fe?[]:Z.map(V=>({queryKey:oe.tasks.list(V.id),queryFn:()=>ue.get(`/projects/${V.id}/tasks`,{params:{limit:"500"}})}))}),ge=!fe&&$e.some(V=>V.isLoading),Ae=E.useMemo(()=>{if(fe)return Fe?.data??[];const V=[];for(const ce of $e)ce.data?.data&&V.push(...ce.data.data);return V},[fe,Fe,$e]),we=t&&Ae.some(V=>V.id===t)?t:null,tt=E.useMemo(()=>{const V=new Map;for(const ce of Ae){const be=ce.createdAt?new Date(ce.createdAt).getTime():0,He=V.get(ce.projectId)??0;be>He&&V.set(ce.projectId,be)}return[...Z].sort((ce,be)=>{const He=V.get(ce.id)??(ce.createdAt?new Date(ce.createdAt).getTime():0);return(V.get(be.id)??(be.createdAt?new Date(be.createdAt).getTime():0))-He})},[Z,Ae]),Te=E.useMemo(()=>tt.filter(V=>!V.archivedAt),[tt]),je=E.useMemo(()=>{if(!le)return[];const V=localStorage.getItem("providerUsageCount"),ce=V?JSON.parse(V):{};return[...le].sort((be,He)=>{const Me=be.availability.type!=="NOT_FOUND",Le=He.availability.type!=="NOT_FOUND";if(Me!==Le)return Me?-1:1;const Tt=ce[be.provider.id]??0;return(ce[He.provider.id]??0)-Tt})},[le]),Ze=E.useMemo(()=>Ae.map(a0),[Ae]),Ue=E.useMemo(()=>new Set,[]),_e=E.useMemo(()=>{if(!we)return null;const V=Ae.find(be=>be.id===we);if(!V)return null;const ce=Z.find(be=>be.id===V.projectId);if(!ce){const be=V.workspaces?.find(He=>He.status==="ACTIVE")?.branchName??V.workspaces?.[0]?.branchName??"—";return{id:V.id,projectId:V.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:V.title,status:Ni(V.status),branch:be,mainBranch:"main",description:V.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return l0(V,ce)},[we,Ae,Z]),K=xl(),te=fp(d),xe=Yn(),pe=pp(),Ve=mp(),rt=E.useCallback(V=>{pe.mutate(V,{onSuccess:()=>{we===V&&s(null),Q.invalidateQueries({queryKey:oe.tasks.all})}})},[pe,we,Q]),ie=E.useCallback((V,ce)=>{Ve.mutate({id:V,status:r0(ce)},{onError:()=>{Fi.error(e("状态变更失败,该操作不被允许"))}})},[Ve,e]),gt=E.useCallback(V=>{V.preventDefault(),H.current=!0,q.current=V.clientX,$.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);E.useEffect(()=>{const V=be=>{if(!H.current)return;const He=be.clientX-q.current,Me=Math.max(H0,Math.min(z0,$.current+He));x(Me)},ce=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",ce),()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",ce)}},[]);const ct=E.useCallback(()=>{n(!0)},[]),_t=E.useCallback(()=>{if(Te.length===0){Fi.error(e("没有可用项目,请先创建或恢复项目"));return}const V=localStorage.getItem("lastSelectedProjectId"),ce=localStorage.getItem("lastSelectedProviderId"),be=V&&Te.find(Le=>Le.id===V)?V:(fe&&Te.find(Le=>Le.id===fe)?.id)??Te[0]?.id??"";b(be);const He=je?.find(Le=>Le.availability.type!=="NOT_FOUND"),Me=ce&&je?.find(Le=>Le.provider.id===ce&&Le.availability.type!=="NOT_FOUND")?ce:He?.provider.id??"";w(Me),g("SOLO"),R("CONFIRM"),M(null),P([]),z(null),A(null),O("idle"),f(!0)},[Te,fe,je,e]),ye=E.useCallback(()=>{n(!1),p(""),y("")},[]),qe=E.useCallback(()=>{L==="idle"&&(f(!1),o(""),u(""),b(""),w(""),g("SOLO"),R("CONFIRM"),M(null),P([]),z(null),A(null),O("idle"),X())},[L,X]),Ke=E.useCallback(async()=>{if(!(!a.trim()||!S.trim()))try{await K.mutateAsync({name:a.trim(),repoPath:S.trim()}),ye()}catch{}},[a,S,K,ye]),ot=wi(),Oe=E.useCallback(async()=>{const V=!!_.trim()&&!!d,ce=j==="TEAM"&&B!==null;if(j==="TEAM"&&!D&&N.length===0){A(e("请选择至少一个团队模板或成员预设。"));return}if(j==="TEAM"){if(!ce&&!V)return}else if(!V)return;try{A(null);const be=Y(),He=[h.trim(),be].filter(Boolean).join(`
84
+
85
+ `);let Me=B;if(!Me){O("creating-task");const Le=await te.mutateAsync({title:_.trim(),description:He||void 0});if(Me=Le.id,z(Le.id),localStorage.setItem("lastSelectedProjectId",d),j==="SOLO"&&C){localStorage.setItem("lastSelectedProviderId",C);const Tt=localStorage.getItem("providerUsageCount"),Dt=Tt?JSON.parse(Tt):{};Dt[C]=(Dt[C]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Dt))}}if(j==="TEAM"){const Le=N;O("creating-teamrun"),await xe.mutateAsync({taskId:Me,mode:k,...D?{teamTemplateId:D}:{},...Le.length>0?{memberPresetIds:Le}:{}}),z(null)}else if(C){const Le=[_.trim(),He].filter(Boolean).join(`
86
+
87
+ `);O("creating-workspace");const Tt=await ue.post(`/tasks/${Me}/workspaces`,{});O("creating-session");const Dt=await ue.post(`/workspaces/${Tt.id}/sessions`,{providerId:C,prompt:Le});O("starting-session"),await ot.mutateAsync(Dt.id),await Q.invalidateQueries({queryKey:oe.workspaces.list(Me)})}s(Me),O("idle"),f(!1),o(""),u(""),b(""),w(""),g("SOLO"),R("CONFIRM"),M(null),P([]),z(null),A(null),X()}catch(be){j==="TEAM"&&A(be instanceof Error?be.message:e("创建 TeamRun 失败")),O("idle")}},[_,h,d,C,j,k,D,N,B,te,xe,ot,Q,Y,X,e]),Ge=E.useCallback(V=>{const ce=V.target.files;ce&&ce.length>0&&F(Array.from(ce)),V.target.value=""},[F]),dt=E.useCallback(V=>{const ce=V.clipboardData.items,be=[];for(const He of ce)if(He.kind==="file"){const Me=He.getAsFile();Me&&be.push(Me)}be.length>0&&(V.preventDefault(),F(be))},[F]),[Ct,De]=E.useState(!1),ft=E.useCallback(V=>{V.preventDefault(),De(!0)},[]),ut=E.useCallback(V=>{V.preventDefault(),De(!1)},[]),mt=E.useCallback(V=>{V.preventDefault(),De(!1);const ce=V.dataTransfer.files;ce.length>0&&F(Array.from(ce))},[F]),at=Be||st||ge,wt=!!_.trim()&&!!d,pt=j!=="TEAM"||!!D||N.length>0,ht=L==="idle"&&pt&&(j==="TEAM"&&B!==null||wt),Wt=e(j==="TEAM"&&L==="idle"?"Create TeamRun":Un[L]),$t=r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:qe,disabled:L!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),r.jsx("button",{onClick:Oe,disabled:!ht,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${ht?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Wt})]}),ns=r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-700",children:e("Execution")}),r.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[r.jsx("button",{type:"button",onClick:()=>{L==="idle"&&(g("SOLO"),A(null))},disabled:L!=="idle",className:ne("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",j==="SOLO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("Solo Agent")}),r.jsx("button",{type:"button",onClick:()=>{L==="idle"&&(g("TEAM"),A(null))},disabled:L!=="idle",className:ne("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",j==="TEAM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("TeamRun")})]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),r.jsx($i,{value:d,onChange:b,options:Te.map(V=>({value:V.id,label:V.name})),placeholder:e("Select project..."),disabled:L!=="idle"})]}),j==="SOLO"?r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),r.jsx($i,{value:C,onChange:w,options:je.map(({provider:V,availability:ce})=>({value:V.id,label:V.name+(ce.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:ce.type==="NOT_FOUND"})),placeholder:e(he?"Loading...":"Select provider..."),disabled:L!=="idle"})]}):r.jsx("div",{className:"flex-1 min-w-0"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),r.jsx("input",{type:"text",value:_,onChange:V=>o(V.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:L!=="idle",onKeyDown:V=>{V.key==="Enter"&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&Oe()}})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),r.jsxs("div",{className:`relative border rounded-lg transition-colors ${Ct?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:ft,onDragLeave:ut,onDrop:mt,children:[r.jsx("textarea",{rows:3,value:h,onChange:V=>u(V.target.value),onPaste:dt,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:L!=="idle",onKeyDown:V=>{(V.metaKey||V.ctrlKey)&&V.key==="Enter"&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&Oe()}}),Ct&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:r.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>T.current?.click(),disabled:L!=="idle"||J,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:[r.jsx(oi,{size:14}),e("Attach files")]}),r.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),r.jsx("input",{ref:T,type:"file",multiple:!0,onChange:Ge,className:"hidden"}),r.jsx(ji,{files:I,onRemove:U})]}),j==="TEAM"&&r.jsxs("div",{className:"space-y-3 border-t border-neutral-100 pt-4",children:[r.jsx(ha,{mode:k,setMode:R,selectedTemplateId:D,setSelectedTemplateId:M,selectedMemberPresetIds:N,setSelectedMemberPresetIds:P,disabled:L!=="idle"}),W&&r.jsx("p",{className:"text-xs text-red-500",children:W})]}),te.isError&&r.jsx("p",{className:"text-xs text-red-500",children:te.error instanceof Error?te.error.message:e("Failed to create task")})]});return No()?we&&_e?r.jsxs(r.Fragment,{children:[r.jsx(j0,{task:_e,onBack:()=>s(null),onDeleteTask:_e.projectArchivedAt?void 0:rt,isDeleting:pe.isPending}),r.jsx(E.Suspense,{fallback:null,children:r.jsx(ls,{isOpen:i,onClose:ye,title:e("Create New Project"),action:r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:ye,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),r.jsx("button",{onClick:Ke,disabled:!a.trim()||!S.trim()||K.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${a.trim()&&S.trim()&&!K.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:K.isPending?e("Creating..."):e("Create")})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),r.jsx("input",{type:"text",value:a,onChange:V=>p(V.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})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),r.jsx(Br,{value:S,onChange:y})]})]})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[r.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[qn,Kn]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx($n,{}),r.jsx(Hs,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:r.jsx(zi,{size:16})})]})]}),at&&Ze.length===0?r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):r.jsx(on,{tasks:Ze,projects:Ye,selectedTaskId:null,onSelectTask:s,filterProjectId:fe,setFilterProjectId:m,width:"100%",onCreateProject:ct,onCreateTask:_t,activeTaskIds:Ue,onTaskStatusChange:ie})]}),r.jsxs(E.Suspense,{fallback:null,children:[r.jsx(ls,{isOpen:i,onClose:ye,title:e("Create New Project"),action:r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:ye,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),r.jsx("button",{onClick:Ke,disabled:!a.trim()||!S.trim()||K.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${a.trim()&&S.trim()&&!K.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:K.isPending?e("Creating..."):e("Create")})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),r.jsx("input",{type:"text",value:a,onChange:V=>p(V.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})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),r.jsx(Br,{value:S,onChange:y})]})]})}),r.jsx(ls,{isOpen:c,onClose:qe,title:e("Create New Task"),className:j==="TEAM"?"max-w-5xl":void 0,action:$t,children:ns})]})]}):r.jsxs("div",{ref:ee,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[qn,Kn]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx($n,{}),r.jsx(Hs,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:r.jsx(zi,{size:16})})]})]}),r.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[at&&Ze.length===0?r.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...")}):r.jsx(on,{tasks:Ze,projects:Ye,selectedTaskId:we,onSelectTask:s,filterProjectId:fe,setFilterProjectId:m,width:v,onCreateProject:ct,onCreateTask:_t,activeTaskIds:Ue,onTaskStatusChange:ie,onDeleteTask:rt}),r.jsx("div",{onMouseDown:gt,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")}),r.jsx(s0,{task:_e,onDeleteTask:_e?.projectArchivedAt?void 0:rt,isDeleting:pe.isPending,onTaskStatusChange:_e?.projectArchivedAt?void 0:ie})]}),r.jsxs(E.Suspense,{fallback:null,children:[r.jsx(ls,{isOpen:i,onClose:ye,title:e("Create New Project"),action:r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:ye,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:e("Cancel")}),r.jsx("button",{onClick:Ke,disabled:!a.trim()||!S.trim()||K.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${a.trim()&&S.trim()&&!K.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:K.isPending?e("Creating..."):e("Create Project")})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),r.jsx("input",{type:"text",value:a,onChange:V=>p(V.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})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),r.jsx(Br,{value:S,onChange:y})]}),K.isError&&r.jsx("p",{className:"text-xs text-red-500",children:K.error instanceof Error?K.error.message:e("Failed to create project")})]})}),r.jsx(ls,{isOpen:c,onClose:qe,title:e("Create New Task"),className:j==="TEAM"?"max-w-5xl":void 0,action:$t,children:ns})]})]})}export{iv as ProjectKanbanPage};