agent-tower 0.3.9 → 0.3.10

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 (89) hide show
  1. package/dist/executors/base.executor.d.ts +1 -1
  2. package/dist/executors/base.executor.d.ts.map +1 -1
  3. package/dist/executors/base.executor.js +1 -1
  4. package/dist/executors/base.executor.js.map +1 -1
  5. package/dist/pipeline/agent-pipeline.d.ts +1 -1
  6. package/dist/pipeline/agent-pipeline.d.ts.map +1 -1
  7. package/dist/routes/app-settings.d.ts +3 -0
  8. package/dist/routes/app-settings.d.ts.map +1 -0
  9. package/dist/routes/app-settings.js +39 -0
  10. package/dist/routes/app-settings.js.map +1 -0
  11. package/dist/routes/index.d.ts.map +1 -1
  12. package/dist/routes/index.js +3 -0
  13. package/dist/routes/index.js.map +1 -1
  14. package/dist/routes/notifications.d.ts.map +1 -1
  15. package/dist/routes/notifications.js +6 -1
  16. package/dist/routes/notifications.js.map +1 -1
  17. package/dist/routes/system.d.ts.map +1 -1
  18. package/dist/routes/system.js +9 -0
  19. package/dist/routes/system.js.map +1 -1
  20. package/dist/services/notifications/defaults.d.ts +3 -0
  21. package/dist/services/notifications/defaults.d.ts.map +1 -0
  22. package/dist/services/notifications/defaults.js +23 -0
  23. package/dist/services/notifications/defaults.js.map +1 -0
  24. package/dist/services/notifications/notification.service.d.ts.map +1 -1
  25. package/dist/services/notifications/notification.service.js +5 -9
  26. package/dist/services/notifications/notification.service.js.map +1 -1
  27. package/dist/services/slash-command-catalog.service.d.ts +4 -0
  28. package/dist/services/slash-command-catalog.service.d.ts.map +1 -0
  29. package/dist/services/slash-command-catalog.service.js +265 -0
  30. package/dist/services/slash-command-catalog.service.js.map +1 -0
  31. package/dist/services/terminal-manager.js +1 -1
  32. package/dist/services/terminal-manager.js.map +1 -1
  33. package/dist/web/assets/AgentDemoPage-BpV7uQ3g.js +1 -0
  34. package/dist/web/assets/DemoPage-BGjHCKHx.js +4 -0
  35. package/dist/web/assets/GeneralSettingsPage-D8GaBU89.js +1 -0
  36. package/dist/web/assets/NotificationSettingsPage-R1vzDEfU.js +1 -0
  37. package/dist/web/assets/ProfileSettingsPage-DrNxHv3c.js +3 -0
  38. package/dist/web/assets/ProjectKanbanPage-B3aK9esV.js +85 -0
  39. package/dist/web/assets/ProjectSettingsPage-Cmopz-Gr.js +2 -0
  40. package/dist/web/assets/ProviderSettingsPage-Pf3xga4g.js +54 -0
  41. package/dist/web/assets/button-mT6fR5Wv.js +1 -0
  42. package/dist/web/assets/{chevron-down-DrP9EgY9.js → chevron-down-KO5Wcpg9.js} +1 -1
  43. package/dist/web/assets/circle-alert-CZMIHvRs.js +1 -0
  44. package/dist/web/assets/circle-check-CdWs_twI.js +1 -0
  45. package/dist/web/assets/code-block-OCS4YCEC-CVVuqs_P.js +2 -0
  46. package/dist/web/assets/confirm-dialog-COaPglPO.js +1 -0
  47. package/dist/web/assets/folder-picker-CPaFyHlQ.js +1 -0
  48. package/dist/web/assets/index-CTITGUzC.js +13 -0
  49. package/dist/web/assets/index-HqeZJR3B.css +1 -0
  50. package/dist/web/assets/loader-circle-B49bBnM9.js +1 -0
  51. package/dist/web/assets/{mermaid-NOHMQCX5-BvevrkjG.js → mermaid-NOHMQCX5-drOfvylS.js} +42 -42
  52. package/dist/web/assets/modal-D6YfM74t.js +1 -0
  53. package/dist/web/assets/pencil-CvEjUv9A.js +1 -0
  54. package/dist/web/assets/select-B3kLwiMg.js +1 -0
  55. package/dist/web/assets/use-profiles-nR91n9X5.js +1 -0
  56. package/dist/web/assets/use-projects-CP8WXqHv.js +1 -0
  57. package/dist/web/assets/utils-CkSf8FUe.js +1 -0
  58. package/dist/web/assets/x-BP0L8Jra.js +1 -0
  59. package/dist/web/index.html +2 -2
  60. package/node_modules/@agent-tower/shared/dist/types.d.ts +19 -0
  61. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  62. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  63. package/package.json +2 -2
  64. package/prisma/migrations/20260331000000_add_app_settings/migration.sql +5 -0
  65. package/prisma/schema.prisma +6 -0
  66. package/scripts/postinstall.js +16 -14
  67. package/dist/web/assets/AgentDemoPage-CzND8Y0f.js +0 -1
  68. package/dist/web/assets/DemoPage-CmUJ0dvS.js +0 -4
  69. package/dist/web/assets/NotificationSettingsPage-B1SDsL68.js +0 -1
  70. package/dist/web/assets/ProfileSettingsPage-Z42bsJop.js +0 -3
  71. package/dist/web/assets/ProjectKanbanPage-BsRLM_To.js +0 -85
  72. package/dist/web/assets/ProjectSettingsPage-DizbsdCH.js +0 -2
  73. package/dist/web/assets/ProviderSettingsPage-BnLCrZgD.js +0 -54
  74. package/dist/web/assets/api-client-CgvcCTaj.js +0 -1
  75. package/dist/web/assets/circle-alert-wdB5gDUz.js +0 -1
  76. package/dist/web/assets/circle-check-DilG10OC.js +0 -1
  77. package/dist/web/assets/code-block-OCS4YCEC-BQpzSGnw.js +0 -2
  78. package/dist/web/assets/confirm-dialog-zLKSUa6j.js +0 -1
  79. package/dist/web/assets/folder-picker-CmgJx3lM.js +0 -1
  80. package/dist/web/assets/index-B-QFtMnj.js +0 -13
  81. package/dist/web/assets/index-DX47RnmN.css +0 -1
  82. package/dist/web/assets/loader-circle-B8Hk0gt3.js +0 -1
  83. package/dist/web/assets/modal-CCInxYr_.js +0 -1
  84. package/dist/web/assets/pencil-u5vhUMho.js +0 -1
  85. package/dist/web/assets/query-keys-BGgDKleg.js +0 -1
  86. package/dist/web/assets/select-CinUO48b.js +0 -1
  87. package/dist/web/assets/use-profiles-DJwSheDq.js +0 -1
  88. package/dist/web/assets/use-projects-OFs5uSW6.js +0 -1
  89. package/dist/web/assets/x-Bz9Stptu.js +0 -1
@@ -1,85 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-CCInxYr_.js","assets/index-B-QFtMnj.js","assets/index-DX47RnmN.css","assets/api-client-CgvcCTaj.js","assets/x-Bz9Stptu.js","assets/folder-picker-CmgJx3lM.js","assets/mermaid-NOHMQCX5-BvevrkjG.js","assets/log-adapter-50wgehrc.js","assets/chevron-down-DrP9EgY9.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/loader-circle-B8Hk0gt3.js","assets/circle-alert-wdB5gDUz.js","assets/use-projects-OFs5uSW6.js","assets/query-keys-BGgDKleg.js"])))=>i.map(i=>d[i]);
2
- import{z as Br,A as Do,B as To,a as jo,q as rr,d as Lo,D as Ao,u as Ie,r as R,n as No,c as ge,R as ee,E as Tt,j as a,s as dt,S as Oe,C as ot,i as Qt,g as Zt,G as Ir,H as Mo,y as Po,L as Fr,_ as Wi}from"./index-B-QFtMnj.js";import{Q as pr,b as Oo,c as Bo,e as Io,d as Fo,f as Ho,s as Hr,g as zr,w as zo,h as Wo,i as $o,a as Ge,q as he,u as lt}from"./query-keys-BGgDKleg.js";import{C as kt,h as mr,b as vr,d as gr,c as _r,i as br,G as Ds,u as $i,a as Ui,Q as Ki,e as qi,T as Xi,P as ms,f as Yi,S as Wr}from"./mermaid-NOHMQCX5-BvevrkjG.js";import{C as pt,a as Ut}from"./chevron-down-DrP9EgY9.js";import{P as ir,X as Ts}from"./x-Bz9Stptu.js";import{u as js,T as Vi,g as Uo,S as Me,C as Gi,h as nt,A as as}from"./confirm-dialog-zLKSUa6j.js";import"./log-adapter-50wgehrc.js";import{a as ve,c as Se,B as at,t as $r}from"./api-client-CgvcCTaj.js";import{F as Ko,a as qo,c as Xo,u as Yo,d as Vo}from"./use-projects-OFs5uSW6.js";import{L as Be}from"./loader-circle-B8Hk0gt3.js";import{M as xr,T as Qi}from"./modal-CCInxYr_.js";import{S as ls}from"./select-CinUO48b.js";var Go=class extends pr{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:Br()})}getOptimisticResult(e){return e.behavior=Br(),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:b,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",d=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:To(t,s.data),hasPreviousPage:Do(t,s.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:b&&!d&&!p}}};function Ur(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function Qo(e,t,s){const l=e.slice(0);return l[t]=s,l}var Zo=class extends jo{#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,rr.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const m=l.map(d=>d.observer),b=m.map(d=>d.getCurrentResult()),C=s.length!==m.length,r=m.some((d,o)=>d!==s[o]),i=C||r,c=i?!0:b.some((d,o)=>{const p=this.#e[o];return!p||!Lo(d,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=b,this.hasListeners()&&(i&&(Ur(s,m).forEach(d=>{d.destroy()}),Ur(m,s).forEach(d=>{d.subscribe(o=>{this.#f(d,o)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(b=>b.observer.getOptimisticResult(b.defaultedQueryOptions)),m=s.map(b=>b.defaultedQueryOptions.queryHash);return[l,b=>this.#u(b??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,b=>{t.forEach(C=>{C.observer.trackProp(b)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((b,C)=>b!==l[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Ao(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const b=t.get(m);b?b.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),C=t.get(m.queryHash)?.shift()??new pr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=Qo(this.#e,s,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&rr.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Jo({queries:e,...t},s){const l=Ie(),m=Oo(),b=Bo(),C=R.useMemo(()=>e.map(_=>{const n=l.defaultQueryOptions(_);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(_=>{Io(_);const n=l.getQueryCache().get(_.queryHash);Fo(_,b,n)}),Ho(b);const[r]=R.useState(()=>new Zo(l,C,t)),[i,c,d]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(_=>o?r.subscribe(rr.batchCalls(_)):No,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),R.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const g=i.some((_,n)=>Hr(C[n],_))?i.flatMap((_,n)=>{const f=C[n];if(f){const h=new pr(l,f);if(Hr(f,_))return zr(f,h,b);zo(_,m)&&zr(f,h,b)}return[]}):[];if(g.length>0)throw Promise.all(g);const S=i.find((_,n)=>{const f=C[n];return f&&Wo({result:_,errorResetBoundary:b,throwOnError:f.throwOnError,query:l.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return c(d())}function Zi(e,t){return $o(e,Go)}const ea=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ji=ge("arrow-down",ea);const ta=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],en=ge("arrow-right",ta);const sa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],tn=ge("arrow-up",sa);const ra=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Kr=ge("circle-check-big",ra);const ia=[["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"}]],Ls=ge("code-xml",ia);const na=[["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"}]],qr=ge("copy",na);const oa=[["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"}]],sn=ge("ellipsis-vertical",oa);const aa=[["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"}]],la=ge("file-braces-corner",aa);const ca=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Kt=ge("file-code-corner",ca);const ha=[["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"}]],ua=ge("file-exclamation-point",ha);const da=[["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"}]],rn=ge("file-text",da);const fa=[["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"}]],nn=ge("folder-open",fa);const pa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ma=ge("gauge",pa);const va=[["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"}]],ga=ge("git-branch",va);const _a=[["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"}]],ba=ge("git-fork",_a);const xa=[["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"}]],qt=ge("git-graph",xa);const Sa=[["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"}]],on=ge("git-merge",Sa);const ya=[["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"}]],Mt=ge("history",ya);const Ca=[["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"}]],Sr=ge("image",Ca);const wa=[["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"}]],Xr=ge("layers",wa);const Ea=[["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"}]],ka=ge("maximize",Ea);const Ra=[["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"}]],Da=ge("message-square",Ra);const Ta=[["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"}]],ja=ge("panel-left-close",Ta);const La=[["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"}]],Aa=ge("panel-left-open",La);const Na=[["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"}]],Ma=ge("panel-right-close",Na);const Pa=[["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"}]],Oa=ge("panel-right-open",Pa);const Ba=[["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"}]],At=ge("play",Ba);const Ia=[["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"}]],Fa=ge("refresh-cw",Ia);const Ha=[["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"}]],za=ge("shield",Ha);const Wa=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],vs=ge("terminal",Wa);const $a=[["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"}]],Ua=ge("zap",$a);const Ka=[["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"}]],qa=ge("zoom-in",Ka);const Xa=[["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"}]],Ya=ge("zoom-out",Xa),As=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function yr(e){return"nodeType"in e}function Ve(e){var t,s;return e?Pt(e)?e:yr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Cr(e){const{Document:t}=Ve(e);return e instanceof t}function Jt(e){return Pt(e)?!1:e instanceof Ve(e).HTMLElement}function an(e){return e instanceof Ve(e).SVGElement}function Ot(e){return e?Pt(e)?e.document:yr(e)?Cr(e)?e:Jt(e)||an(e)?e.ownerDocument:document:document:document}const ft=As?R.useLayoutEffect:R.useEffect;function Ns(e){const t=R.useRef(e);return ft(()=>{t.current=e}),R.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 Va(){const e=R.useRef(null),t=R.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=R.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Xt(e,t){t===void 0&&(t=[e]);const s=R.useRef(e);return ft(()=>{s.current!==e&&(s.current=e)},t),s}function es(e,t){const s=R.useRef();return R.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function gs(e){const t=Ns(e),s=R.useRef(null),l=R.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function _s(e){const t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}let Ws={};function Ms(e,t){return R.useMemo(()=>{if(t)return t;const s=Ws[e]==null?0:Ws[e]+1;return Ws[e]=s,e+"-"+s},[e,t])}function ln(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((b,C)=>{const r=Object.entries(C);for(const[i,c]of r){const d=b[i];d!=null&&(b[i]=d+e*c)}return b},{...t})}}const Nt=ln(1),bs=ln(-1);function Ga(e){return"clientX"in e&&"clientY"in e}function wr(e){if(!e)return!1;const{KeyboardEvent:t}=Ve(e.target);return t&&e instanceof t}function Qa(e){if(!e)return!1;const{TouchEvent:t}=Ve(e.target);return t&&e instanceof t}function xs(e){if(Qa(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 Ga(e)?{x:e.clientX,y:e.clientY}:null}const Yt=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[Yt.Translate.toString(e),Yt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),Yr="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Za(e){return e.matches(Yr)?e:e.querySelector(Yr)}const Ja={display:"none"};function el(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Ja},s)}function tl(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 ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function sl(){const[e,t]=R.useState("");return{announce:R.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const cn=R.createContext(null);function rl(e){const t=R.useContext(cn);R.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function il(){const[e]=R.useState(()=>new Set),t=R.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[R.useCallback(l=>{let{type:m,event:b}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,b)})},[e]),t]}const nl={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
- `},ol={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 al(e){let{announcements:t=ol,container:s,hiddenTextDescribedById:l,screenReaderInstructions:m=nl}=e;const{announce:b,announcement:C}=sl(),r=Ms("DndLiveRegion"),[i,c]=R.useState(!1);if(R.useEffect(()=>{c(!0)},[]),rl(R.useMemo(()=>({onDragStart(o){let{active:p}=o;b(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:g}=o;t.onDragMove&&b(t.onDragMove({active:p,over:g}))},onDragOver(o){let{active:p,over:g}=o;b(t.onDragOver({active:p,over:g}))},onDragEnd(o){let{active:p,over:g}=o;b(t.onDragEnd({active:p,over:g}))},onDragCancel(o){let{active:p,over:g}=o;b(t.onDragCancel({active:p,over:g}))}}),[b,t])),!i)return null;const d=ee.createElement(ee.Fragment,null,ee.createElement(el,{id:l,value:m.draggable}),ee.createElement(tl,{id:r,announcement:C}));return s?Tt.createPortal(d,s):d}var ze;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ze||(ze={}));function Ss(){}function ll(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function cl(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return R.useMemo(()=>[...t].filter(l=>l!=null),[...t])}const rt=Object.freeze({x:0,y:0});function hl(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 ul(e,t){let{data:{value:s}}=e,{data:{value:l}}=t;return l-s}function dl(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function fl(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),b=Math.min(t.top+t.height,e.top+e.height),C=m-l,r=b-s;if(l<m&&s<b){const i=t.width*t.height,c=e.width*e.height,d=C*r,o=d/(i+c-d);return Number(o.toFixed(4))}return 0}const pl=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:l}=e;const m=[];for(const b of l){const{id:C}=b,r=s.get(C);if(r){const i=fl(r,t);i>0&&m.push({id:C,data:{droppableContainer:b,value:i}})}}return m.sort(ul)};function ml(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function hn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:rt}function vl(e){return function(s){for(var l=arguments.length,m=new Array(l>1?l-1:0),b=1;b<l;b++)m[b-1]=arguments[b];return m.reduce((C,r)=>({...C,top:C.top+e*r.y,bottom:C.bottom+e*r.y,left:C.left+e*r.x,right:C.right+e*r.x}),{...s})}}const gl=vl(1);function un(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 _l(e,t,s){const l=un(t);if(!l)return e;const{scaleX:m,scaleY:b,x:C,y:r}=l,i=e.left-C-(1-m)*parseFloat(s),c=e.top-r-(1-b)*parseFloat(s.slice(s.indexOf(" ")+1)),d=m?e.width/m:e.width,o=b?e.height/b:e.height;return{width:d,height:o,top:c,right:i+d,bottom:c+o,left:i}}const bl={ignoreTransform:!1};function ts(e,t){t===void 0&&(t=bl);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:d}=Ve(e).getComputedStyle(e);c&&(s=_l(s,c,d))}const{top:l,left:m,width:b,height:C,bottom:r,right:i}=s;return{top:l,left:m,width:b,height:C,bottom:r,right:i}}function Vr(e){return ts(e,{ignoreTransform:!0})}function xl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function Sl(e,t){return t===void 0&&(t=Ve(e).getComputedStyle(e)),t.position==="fixed"}function yl(e,t){t===void 0&&(t=Ve(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const b=t[m];return typeof b=="string"?s.test(b):!1})}function Er(e,t){const s=[];function l(m){if(t!=null&&s.length>=t||!m)return s;if(Cr(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!Jt(m)||an(m)||s.includes(m))return s;const b=Ve(e).getComputedStyle(m);return m!==e&&yl(m,b)&&s.push(m),Sl(m,b)?s:l(m.parentNode)}return e?l(e):s}function dn(e){const[t]=Er(e,1);return t??null}function $s(e){return!As||!e?null:Pt(e)?e:yr(e)?Cr(e)||e===Ot(e).scrollingElement?window:Jt(e)?e:null:null}function fn(e){return Pt(e)?e.scrollX:e.scrollLeft}function pn(e){return Pt(e)?e.scrollY:e.scrollTop}function nr(e){return{x:fn(e),y:pn(e)}}var $e;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})($e||($e={}));function mn(e){return!As||!e?!1:e===document.scrollingElement}function vn(e){const t={x:0,y:0},s=mn(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,b=e.scrollLeft<=t.x,C=e.scrollTop>=l.y,r=e.scrollLeft>=l.x;return{isTop:m,isLeft:b,isBottom:C,isRight:r,maxScroll:l,minScroll:t}}const Cl={x:.2,y:.2};function wl(e,t,s,l,m){let{top:b,left:C,right:r,bottom:i}=s;l===void 0&&(l=10),m===void 0&&(m=Cl);const{isTop:c,isBottom:d,isLeft:o,isRight:p}=vn(e),g={x:0,y:0},S={x:0,y:0},_={height:t.height*m.y,width:t.width*m.x};return!c&&b<=t.top+_.height?(g.y=$e.Backward,S.y=l*Math.abs((t.top+_.height-b)/_.height)):!d&&i>=t.bottom-_.height&&(g.y=$e.Forward,S.y=l*Math.abs((t.bottom-_.height-i)/_.height)),!p&&r>=t.right-_.width?(g.x=$e.Forward,S.x=l*Math.abs((t.right-_.width-r)/_.width)):!o&&C<=t.left+_.width&&(g.x=$e.Backward,S.x=l*Math.abs((t.left+_.width-C)/_.width)),{direction:g,speed:S}}function El(e){if(e===document.scrollingElement){const{innerWidth:b,innerHeight:C}=window;return{top:0,left:0,right:b,bottom:C,width:b,height:C}}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 gn(e){return e.reduce((t,s)=>Nt(t,nr(s)),rt)}function kl(e){return e.reduce((t,s)=>t+fn(s),0)}function Rl(e){return e.reduce((t,s)=>t+pn(s),0)}function _n(e,t){if(t===void 0&&(t=ts),!e)return;const{top:s,left:l,bottom:m,right:b}=t(e);dn(e)&&(m<=0||b<=0||s>=window.innerHeight||l>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Dl=[["x",["left","right"],kl],["y",["top","bottom"],Rl]];class kr{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=Er(s),m=gn(l);this.rect={...t},this.width=t.width,this.height=t.height;for(const[b,C,r]of Dl)for(const i of C)Object.defineProperty(this,i,{get:()=>{const c=r(l),d=m[b]-c;return this.rect[i]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ht{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 Tl(e){const{EventTarget:t}=Ve(e);return e instanceof t?e:Ot(e)}function Us(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 Je;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Je||(Je={}));function Gr(e){e.preventDefault()}function jl(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 bn={start:[Ee.Space,Ee.Enter],cancel:[Ee.Esc],end:[Ee.Space,Ee.Enter,Ee.Tab]},Ll=(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 xn{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 Ht(Ot(s)),this.windowListeners=new Ht(Ve(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Je.Resize,this.handleCancel),this.windowListeners.add(Je.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Je.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,l=t.node.current;l&&_n(l),s(rt)}handleKeyDown(t){if(wr(t)){const{active:s,context:l,options:m}=this.props,{keyboardCodes:b=bn,coordinateGetter:C=Ll,scrollBehavior:r="smooth"}=m,{code:i}=t;if(b.end.includes(i)){this.handleEnd(t);return}if(b.cancel.includes(i)){this.handleCancel(t);return}const{collisionRect:c}=l.current,d=c?{x:c.left,y:c.top}:rt;this.referenceCoordinates||(this.referenceCoordinates=d);const o=C(t,{active:s,context:l.current,currentCoordinates:d});if(o){const p=bs(o,d),g={x:0,y:0},{scrollableAncestors:S}=l.current;for(const _ of S){const n=t.code,{isTop:f,isRight:h,isLeft:u,isBottom:v,maxScroll:x,minScroll:w}=vn(_),k=El(_),y={x:Math.min(n===Ee.Right?k.right-k.width/2:k.right,Math.max(n===Ee.Right?k.left:k.left+k.width/2,o.x)),y:Math.min(n===Ee.Down?k.bottom-k.height/2:k.bottom,Math.max(n===Ee.Down?k.top:k.top+k.height/2,o.y))},E=n===Ee.Right&&!h||n===Ee.Left&&!u,j=n===Ee.Down&&!v||n===Ee.Up&&!f;if(E&&y.x!==o.x){const A=_.scrollLeft+p.x,L=n===Ee.Right&&A<=x.x||n===Ee.Left&&A>=w.x;if(L&&!p.y){_.scrollTo({left:A,behavior:r});return}L?g.x=_.scrollLeft-A:g.x=n===Ee.Right?_.scrollLeft-x.x:_.scrollLeft-w.x,g.x&&_.scrollBy({left:-g.x,behavior:r});break}else if(j&&y.y!==o.y){const A=_.scrollTop+p.y,L=n===Ee.Down&&A<=x.y||n===Ee.Up&&A>=w.y;if(L&&!p.x){_.scrollTo({top:A,behavior:r});return}L?g.y=_.scrollTop-A:g.y=n===Ee.Down?_.scrollTop-x.y:_.scrollTop-w.y,g.y&&_.scrollBy({top:-g.y,behavior:r});break}}this.handleMove(t,Nt(bs(o,this.referenceCoordinates),g))}}}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()}}xn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:l=bn,onActivation:m}=t,{active:b}=s;const{code:C}=e.nativeEvent;if(l.start.includes(C)){const r=b.activatorNode.current;return r&&e.target!==r?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Qr(e){return!!(e&&"distance"in e)}function Zr(e){return!!(e&&"delay"in e)}class Rr{constructor(t,s,l){var m;l===void 0&&(l=Tl(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:b}=t,{target:C}=b;this.props=t,this.events=s,this.document=Ot(C),this.documentListeners=new Ht(this.document),this.listeners=new Ht(l),this.windowListeners=new Ht(Ve(C)),this.initialCoordinates=(m=xs(b))!=null?m:rt,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(Je.Resize,this.handleCancel),this.windowListeners.add(Je.DragStart,Gr),this.windowListeners.add(Je.VisibilityChange,this.handleCancel),this.windowListeners.add(Je.ContextMenu,Gr),this.documentListeners.add(Je.Keydown,this.handleKeydown),s){if(l!=null&&l({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Zr(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Qr(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(Je.Click,jl,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Je.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:l,initialCoordinates:m,props:b}=this,{onMove:C,options:{activationConstraint:r}}=b;if(!m)return;const i=(s=xs(t))!=null?s:rt,c=bs(m,i);if(!l&&r){if(Qr(r)){if(r.tolerance!=null&&Us(c,r.tolerance))return this.handleCancel();if(Us(c,r.distance))return this.handleStart()}if(Zr(r)&&Us(c,r.tolerance))return this.handleCancel();this.handlePending(r,c);return}t.cancelable&&t.preventDefault(),C(i)}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 Al={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Dr extends Rr{constructor(t){const{event:s}=t,l=Ot(s.target);super(t,Al,l)}}Dr.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 Nl={move:{name:"mousemove"},end:{name:"mouseup"}};var or;(function(e){e[e.RightClick=2]="RightClick"})(or||(or={}));class Ml extends Rr{constructor(t){super(t,Nl,Ot(t.event.target))}}Ml.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return s.button===or.RightClick?!1:(l?.({event:s}),!0)}}];const Ks={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Pl extends Rr{constructor(t){super(t,Ks)}static setup(){return window.addEventListener(Ks.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ks.move.name,t)};function t(){}}}Pl.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 zt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(zt||(zt={}));var ys;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ys||(ys={}));function Ol(e){let{acceleration:t,activator:s=zt.Pointer,canScroll:l,draggingRect:m,enabled:b,interval:C=5,order:r=ys.TreeOrder,pointerCoordinates:i,scrollableAncestors:c,scrollableAncestorRects:d,delta:o,threshold:p}=e;const g=Il({delta:o,disabled:!b}),[S,_]=Va(),n=R.useRef({x:0,y:0}),f=R.useRef({x:0,y:0}),h=R.useMemo(()=>{switch(s){case zt.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case zt.DraggableRect:return m}},[s,m,i]),u=R.useRef(null),v=R.useCallback(()=>{const w=u.current;if(!w)return;const k=n.current.x*f.current.x,y=n.current.y*f.current.y;w.scrollBy(k,y)},[]),x=R.useMemo(()=>r===ys.TreeOrder?[...c].reverse():c,[r,c]);R.useEffect(()=>{if(!b||!c.length||!h){_();return}for(const w of x){if(l?.(w)===!1)continue;const k=c.indexOf(w),y=d[k];if(!y)continue;const{direction:E,speed:j}=wl(w,y,h,t,p);for(const A of["x","y"])g[A][E[A]]||(j[A]=0,E[A]=0);if(j.x>0||j.y>0){_(),u.current=w,S(v,C),n.current=j,f.current=E;return}}n.current={x:0,y:0},f.current={x:0,y:0},_()},[t,v,l,_,b,C,JSON.stringify(h),JSON.stringify(g),S,c,x,d,JSON.stringify(p)])}const Bl={x:{[$e.Backward]:!1,[$e.Forward]:!1},y:{[$e.Backward]:!1,[$e.Forward]:!1}};function Il(e){let{delta:t,disabled:s}=e;const l=_s(t);return es(m=>{if(s||!l||!m)return Bl;const b={x:Math.sign(t.x-l.x),y:Math.sign(t.y-l.y)};return{x:{[$e.Backward]:m.x[$e.Backward]||b.x===-1,[$e.Forward]:m.x[$e.Forward]||b.x===1},y:{[$e.Backward]:m.y[$e.Backward]||b.y===-1,[$e.Forward]:m.y[$e.Forward]||b.y===1}}},[s,t,l])}function Fl(e,t){const s=t!=null?e.get(t):void 0,l=s?s.node.current:null;return es(m=>{var b;return t==null?null:(b=l??m)!=null?b:null},[l,t])}function Hl(e,t){return R.useMemo(()=>e.reduce((s,l)=>{const{sensor:m}=l,b=m.activators.map(C=>({eventName:C.eventName,handler:t(C.handler,l)}));return[...s,...b]},[]),[e,t])}var Vt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Vt||(Vt={}));var ar;(function(e){e.Optimized="optimized"})(ar||(ar={}));const Jr=new Map;function zl(e,t){let{dragging:s,dependencies:l,config:m}=t;const[b,C]=R.useState(null),{frequency:r,measure:i,strategy:c}=m,d=R.useRef(e),o=n(),p=Xt(o),g=R.useCallback(function(f){f===void 0&&(f=[]),!p.current&&C(h=>h===null?f:h.concat(f.filter(u=>!h.includes(u))))},[p]),S=R.useRef(null),_=es(f=>{if(o&&!s)return Jr;if(!f||f===Jr||d.current!==e||b!=null){const h=new Map;for(let u of e){if(!u)continue;if(b&&b.length>0&&!b.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const v=u.node.current,x=v?new kr(i(v),v):null;u.rect.current=x,x&&h.set(u.id,x)}return h}return f},[e,b,s,o,i]);return R.useEffect(()=>{d.current=e},[e]),R.useEffect(()=>{o||g()},[s,o]),R.useEffect(()=>{b&&b.length>0&&C(null)},[JSON.stringify(b)]),R.useEffect(()=>{o||typeof r!="number"||S.current!==null||(S.current=setTimeout(()=>{g(),S.current=null},r))},[r,o,g,...l]),{droppableRects:_,measureDroppableContainers:g,measuringScheduled:b!=null};function n(){switch(c){case Vt.Always:return!1;case Vt.BeforeDragging:return s;default:return!s}}}function Tr(e,t){return es(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function Wl(e,t){return Tr(e,t)}function $l(e){let{callback:t,disabled:s}=e;const l=Ns(t),m=R.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:b}=window;return new b(l)},[l,s]);return R.useEffect(()=>()=>m?.disconnect(),[m]),m}function Ps(e){let{callback:t,disabled:s}=e;const l=Ns(t),m=R.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:b}=window;return new b(l)},[s]);return R.useEffect(()=>()=>m?.disconnect(),[m]),m}function Ul(e){return new kr(ts(e),e)}function ei(e,t,s){t===void 0&&(t=Ul);const[l,m]=R.useState(null);function b(){m(i=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=i??s)!=null?c:null}const d=t(e);return JSON.stringify(i)===JSON.stringify(d)?i:d})}const C=$l({callback(i){if(e)for(const c of i){const{type:d,target:o}=c;if(d==="childList"&&o instanceof HTMLElement&&o.contains(e)){b();break}}}}),r=Ps({callback:b});return ft(()=>{b(),e?(r?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(r?.disconnect(),C?.disconnect())},[e]),l}function Kl(e){const t=Tr(e);return hn(e,t)}const ti=[];function ql(e){const t=R.useRef(e),s=es(l=>e?l&&l!==ti&&e&&t.current&&e.parentNode===t.current.parentNode?l:Er(e):ti,[e]);return R.useEffect(()=>{t.current=e},[e]),s}function Xl(e){const[t,s]=R.useState(null),l=R.useRef(e),m=R.useCallback(b=>{const C=$s(b.target);C&&s(r=>r?(r.set(C,nr(C)),new Map(r)):null)},[]);return R.useEffect(()=>{const b=l.current;if(e!==b){C(b);const r=e.map(i=>{const c=$s(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,nr(c)]):null}).filter(i=>i!=null);s(r.length?new Map(r):null),l.current=e}return()=>{C(e),C(b)};function C(r){r.forEach(i=>{const c=$s(i);c?.removeEventListener("scroll",m)})}},[m,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((b,C)=>Nt(b,C),rt):gn(e):rt,[e,t])}function si(e,t){t===void 0&&(t=[]);const s=R.useRef(null);return R.useEffect(()=>{s.current=null},t),R.useEffect(()=>{const l=e!==rt;l&&!s.current&&(s.current=e),!l&&s.current&&(s.current=null)},[e]),s.current?bs(e,s.current):rt}function Yl(e){R.useEffect(()=>{if(!As)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 Vl(e,t){return R.useMemo(()=>e.reduce((s,l)=>{let{eventName:m,handler:b}=l;return s[m]=C=>{b(C,t)},s},{}),[e,t])}function Sn(e){return R.useMemo(()=>e?xl(e):null,[e])}const ri=[];function Gl(e,t){t===void 0&&(t=ts);const[s]=e,l=Sn(s?Ve(s):null),[m,b]=R.useState(ri);function C(){b(()=>e.length?e.map(i=>mn(i)?l:new kr(t(i),i)):ri)}const r=Ps({callback:C});return ft(()=>{r?.disconnect(),C(),e.forEach(i=>r?.observe(i))},[e]),m}function yn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Jt(t)?t:e}function Ql(e){let{measure:t}=e;const[s,l]=R.useState(null),m=R.useCallback(c=>{for(const{target:d}of c)if(Jt(d)){l(o=>{const p=t(d);return o?{...o,width:p.width,height:p.height}:p});break}},[t]),b=Ps({callback:m}),C=R.useCallback(c=>{const d=yn(c);b?.disconnect(),d&&b?.observe(d),l(d?t(d):null)},[t,b]),[r,i]=gs(C);return R.useMemo(()=>({nodeRef:r,rect:s,setRef:i}),[s,r,i])}const Zl=[{sensor:Dr,options:{}},{sensor:xn,options:{}}],Jl={current:{}},ps={draggable:{measure:Vr},droppable:{measure:Vr,strategy:Vt.WhileDragging,frequency:ar.Optimized},dragOverlay:{measure:ts}};class Wt 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 ec={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Wt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ss},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ps,measureDroppableContainers:Ss,windowRect:null,measuringScheduled:!1},Cn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ss,draggableNodes:new Map,over:null,measureDroppableContainers:Ss},ss=R.createContext(Cn),wn=R.createContext(ec);function tc(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Wt}}}function sc(e,t){switch(t.type){case ze.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ze.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ze.DragEnd:case ze.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ze.RegisterDroppable:{const{element:s}=t,{id:l}=s,m=new Wt(e.droppable.containers);return m.set(l,s),{...e,droppable:{...e.droppable,containers:m}}}case ze.SetDroppableDisabled:{const{id:s,key:l,disabled:m}=t,b=e.droppable.containers.get(s);if(!b||l!==b.key)return e;const C=new Wt(e.droppable.containers);return C.set(s,{...b,disabled:m}),{...e,droppable:{...e.droppable,containers:C}}}case ze.UnregisterDroppable:{const{id:s,key:l}=t,m=e.droppable.containers.get(s);if(!m||l!==m.key)return e;const b=new Wt(e.droppable.containers);return b.delete(s),{...e,droppable:{...e.droppable,containers:b}}}default:return e}}function rc(e){let{disabled:t}=e;const{active:s,activatorEvent:l,draggableNodes:m}=R.useContext(ss),b=_s(l),C=_s(s?.id);return R.useEffect(()=>{if(!t&&!l&&b&&C!=null){if(!wr(b)||document.activeElement===b.target)return;const r=m.get(C);if(!r)return;const{activatorNode:i,node:c}=r;if(!i.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[i.current,c.current]){if(!d)continue;const o=Za(d);if(o){o.focus();break}}})}},[l,t,m,C,b]),null}function En(e,t){let{transform:s,...l}=t;return e!=null&&e.length?e.reduce((m,b)=>b({transform:m,...l}),s):s}function ic(e){return R.useMemo(()=>({draggable:{...ps.draggable,...e?.draggable},droppable:{...ps.droppable,...e?.droppable},dragOverlay:{...ps.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function nc(e){let{activeNode:t,measure:s,initialRect:l,config:m=!0}=e;const b=R.useRef(!1),{x:C,y:r}=typeof m=="boolean"?{x:m,y:m}:m;ft(()=>{if(!C&&!r||!t){b.current=!1;return}if(b.current||!l)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const d=s(c),o=hn(d,l);if(C||(o.x=0),r||(o.y=0),b.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const p=dn(c);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,r,l,s])}const Os=R.createContext({...rt,scaleX:1,scaleY:1});var gt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(gt||(gt={}));const oc=R.memo(function(t){var s,l,m,b;let{id:C,accessibility:r,autoScroll:i=!0,children:c,sensors:d=Zl,collisionDetection:o=pl,measuring:p,modifiers:g,...S}=t;const _=R.useReducer(sc,void 0,tc),[n,f]=_,[h,u]=il(),[v,x]=R.useState(gt.Uninitialized),w=v===gt.Initialized,{draggable:{active:k,nodes:y,translate:E},droppable:{containers:j}}=n,A=k!=null?y.get(k):null,L=R.useRef({initial:null,translated:null}),N=R.useMemo(()=>{var ie;return k!=null?{id:k,data:(ie=A?.data)!=null?ie:Jl,rect:L}:null},[k,A]),B=R.useRef(null),[I,H]=R.useState(null),[W,D]=R.useState(null),M=Xt(S,Object.values(S)),P=Ms("DndDescribedBy",C),O=R.useMemo(()=>j.getEnabled(),[j]),U=ic(p),{droppableRects:X,measureDroppableContainers:Y,measuringScheduled:Q}=zl(O,{dragging:w,dependencies:[E.x,E.y],config:U.droppable}),oe=Fl(y,k),T=R.useMemo(()=>W?xs(W):null,[W]),F=re(),$=Wl(oe,U.draggable.measure);nc({activeNode:k!=null?y.get(k):null,config:F.layoutShiftCompensation,initialRect:$,measure:U.draggable.measure});const z=ei(oe,U.draggable.measure,$),Z=ei(oe?oe.parentElement:null),q=R.useRef({activatorEvent:null,active:null,activeNode:oe,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=j.getNodeFor((s=q.current.over)==null?void 0:s.id),fe=Ql({measure:U.dragOverlay.measure}),ye=(l=fe.nodeRef.current)!=null?l:oe,Le=w?(m=fe.rect)!=null?m:z:null,J=!!(fe.nodeRef.current&&fe.rect),Fe=Kl(J?null:z),Ke=Sn(ye?Ve(ye):null),Ne=ql(w?ne??oe:null),qe=Gl(Ne),Re=En(g,{transform:{x:E.x-Fe.x,y:E.y-Fe.y,scaleX:1,scaleY:1},activatorEvent:W,active:N,activeNodeRect:z,containerNodeRect:Z,draggingNodeRect:Le,over:q.current.over,overlayNodeRect:fe.rect,scrollableAncestors:Ne,scrollableAncestorRects:qe,windowRect:Ke}),G=T?Nt(T,E):null,ae=Xl(Ne),ce=si(ae),se=si(ae,[z]),me=Nt(Re,ce),pe=Le?gl(Le,Re):null,Ce=N&&pe?o({active:N,collisionRect:pe,droppableRects:X,droppableContainers:O,pointerCoordinates:G}):null,Te=dl(Ce,"id"),[He,be]=R.useState(null),tt=J?Re:Nt(Re,se),ct=ml(tt,(b=He?.rect)!=null?b:null,z),it=R.useRef(null),mt=R.useCallback((ie,de)=>{let{sensor:_e,options:je}=de;if(B.current==null)return;const We=y.get(B.current);if(!We)return;const Xe=ie.nativeEvent,Ze=new _e({active:B.current,activeNode:We,event:Xe,options:je,context:q,onAbort(Pe){if(!y.get(Pe))return;const{onDragAbort:te}=M.current,xe={id:Pe};te?.(xe),h({type:"onDragAbort",event:xe})},onPending(Pe,V,te,xe){if(!y.get(Pe))return;const{onDragPending:Ye}=M.current,we={id:Pe,constraint:V,initialCoordinates:te,offset:xe};Ye?.(we),h({type:"onDragPending",event:we})},onStart(Pe){const V=B.current;if(V==null)return;const te=y.get(V);if(!te)return;const{onDragStart:xe}=M.current,Ue={activatorEvent:Xe,active:{id:V,data:te.data,rect:L}};Tt.unstable_batchedUpdates(()=>{xe?.(Ue),x(gt.Initializing),f({type:ze.DragStart,initialCoordinates:Pe,active:V}),h({type:"onDragStart",event:Ue}),H(it.current),D(Xe)})},onMove(Pe){f({type:ze.DragMove,coordinates:Pe})},onEnd:vt(ze.DragEnd),onCancel:vt(ze.DragCancel)});it.current=Ze;function vt(Pe){return async function(){const{active:te,collisions:xe,over:Ue,scrollAdjustedTranslate:Ye}=q.current;let we=null;if(te&&Ye){const{cancelDrop:ht}=M.current;we={activatorEvent:Xe,active:te,collisions:xe,delta:Ye,over:Ue},Pe===ze.DragEnd&&typeof ht=="function"&&await Promise.resolve(ht(we))&&(Pe=ze.DragCancel)}B.current=null,Tt.unstable_batchedUpdates(()=>{f({type:Pe}),x(gt.Uninitialized),be(null),H(null),D(null),it.current=null;const ht=Pe===ze.DragEnd?"onDragEnd":"onDragCancel";if(we){const ut=M.current[ht];ut?.(we),h({type:ht,event:we})}})}}},[y]),Rt=R.useCallback((ie,de)=>(_e,je)=>{const We=_e.nativeEvent,Xe=y.get(je);if(B.current!==null||!Xe||We.dndKit||We.defaultPrevented)return;const Ze={active:Xe};ie(_e,de.options,Ze)===!0&&(We.dndKit={capturedBy:de.sensor},B.current=je,mt(_e,de))},[y,mt]),yt=Hl(d,Rt);Yl(d),ft(()=>{z&&v===gt.Initializing&&x(gt.Initialized)},[z,v]),R.useEffect(()=>{const{onDragMove:ie}=M.current,{active:de,activatorEvent:_e,collisions:je,over:We}=q.current;if(!de||!_e)return;const Xe={active:de,activatorEvent:_e,collisions:je,delta:{x:me.x,y:me.y},over:We};Tt.unstable_batchedUpdates(()=>{ie?.(Xe),h({type:"onDragMove",event:Xe})})},[me.x,me.y]),R.useEffect(()=>{const{active:ie,activatorEvent:de,collisions:_e,droppableContainers:je,scrollAdjustedTranslate:We}=q.current;if(!ie||B.current==null||!de||!We)return;const{onDragOver:Xe}=M.current,Ze=je.get(Te),vt=Ze&&Ze.rect.current?{id:Ze.id,rect:Ze.rect.current,data:Ze.data,disabled:Ze.disabled}:null,Pe={active:ie,activatorEvent:de,collisions:_e,delta:{x:We.x,y:We.y},over:vt};Tt.unstable_batchedUpdates(()=>{be(vt),Xe?.(Pe),h({type:"onDragOver",event:Pe})})},[Te]),ft(()=>{q.current={activatorEvent:W,active:N,activeNode:oe,collisionRect:pe,collisions:Ce,droppableRects:X,draggableNodes:y,draggingNode:ye,draggingNodeRect:Le,droppableContainers:j,over:He,scrollableAncestors:Ne,scrollAdjustedTranslate:me},L.current={initial:Le,translated:pe}},[N,oe,Ce,pe,y,ye,Le,X,j,He,Ne,me]),Ol({...F,delta:E,draggingRect:pe,pointerCoordinates:G,scrollableAncestors:Ne,scrollableAncestorRects:qe});const os=R.useMemo(()=>({active:N,activeNode:oe,activeNodeRect:z,activatorEvent:W,collisions:Ce,containerNodeRect:Z,dragOverlay:fe,draggableNodes:y,droppableContainers:j,droppableRects:X,over:He,measureDroppableContainers:Y,scrollableAncestors:Ne,scrollableAncestorRects:qe,measuringConfiguration:U,measuringScheduled:Q,windowRect:Ke}),[N,oe,z,W,Ce,Z,fe,y,j,X,He,Y,Ne,qe,U,Q,Ke]),K=R.useMemo(()=>({activatorEvent:W,activators:yt,active:N,activeNodeRect:z,ariaDescribedById:{draggable:P},dispatch:f,draggableNodes:y,over:He,measureDroppableContainers:Y}),[W,yt,N,z,f,P,y,He,Y]);return ee.createElement(cn.Provider,{value:u},ee.createElement(ss.Provider,{value:K},ee.createElement(wn.Provider,{value:os},ee.createElement(Os.Provider,{value:ct},c)),ee.createElement(rc,{disabled:r?.restoreFocus===!1})),ee.createElement(al,{...r,hiddenTextDescribedById:P}));function re(){const ie=I?.autoScrollEnabled===!1,de=typeof i=="object"?i.enabled===!1:i===!1,_e=w&&!ie&&!de;return typeof i=="object"?{...i,enabled:_e}:{enabled:_e}}}),ac=R.createContext(null),ii="button",lc="Draggable";function cc(e){let{id:t,data:s,disabled:l=!1,attributes:m}=e;const b=Ms(lc),{activators:C,activatorEvent:r,active:i,activeNodeRect:c,ariaDescribedById:d,draggableNodes:o,over:p}=R.useContext(ss),{role:g=ii,roleDescription:S="draggable",tabIndex:_=0}=m??{},n=i?.id===t,f=R.useContext(n?Os:ac),[h,u]=gs(),[v,x]=gs(),w=Vl(C,t),k=Xt(s);ft(()=>(o.set(t,{id:t,key:b,node:h,activatorNode:v,data:k}),()=>{const E=o.get(t);E&&E.key===b&&o.delete(t)}),[o,t]);const y=R.useMemo(()=>({role:g,tabIndex:_,"aria-disabled":l,"aria-pressed":n&&g===ii?!0:void 0,"aria-roledescription":S,"aria-describedby":d.draggable}),[l,g,_,n,S,d.draggable]);return{active:i,activatorEvent:r,activeNodeRect:c,attributes:y,isDragging:n,listeners:l?void 0:w,node:h,over:p,setNodeRef:u,setActivatorNodeRef:x,transform:f}}function hc(){return R.useContext(wn)}const uc="Droppable",dc={timeout:25};function fc(e){let{data:t,disabled:s=!1,id:l,resizeObserverConfig:m}=e;const b=Ms(uc),{active:C,dispatch:r,over:i,measureDroppableContainers:c}=R.useContext(ss),d=R.useRef({disabled:s}),o=R.useRef(!1),p=R.useRef(null),g=R.useRef(null),{disabled:S,updateMeasurementsFor:_,timeout:n}={...dc,...m},f=Xt(_??l),h=R.useCallback(()=>{if(!o.current){o.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(f.current)?f.current:[f.current]),g.current=null},n)},[n]),u=Ps({callback:h,disabled:S||!C}),v=R.useCallback((y,E)=>{u&&(E&&(u.unobserve(E),o.current=!1),y&&u.observe(y))},[u]),[x,w]=gs(v),k=Xt(t);return R.useEffect(()=>{!u||!x.current||(u.disconnect(),o.current=!1,u.observe(x.current))},[x,u]),R.useEffect(()=>(r({type:ze.RegisterDroppable,element:{id:l,key:b,disabled:s,node:x,rect:p,data:k}}),()=>r({type:ze.UnregisterDroppable,key:b,id:l})),[l]),R.useEffect(()=>{s!==d.current.disabled&&(r({type:ze.SetDroppableDisabled,id:l,key:b,disabled:s}),d.current.disabled=s)},[l,b,s,r]),{active:C,rect:p,isOver:i?.id===l,node:x,over:i,setNodeRef:w}}function pc(e){let{animation:t,children:s}=e;const[l,m]=R.useState(null),[b,C]=R.useState(null),r=_s(s);return!s&&!l&&r&&m(r),ft(()=>{if(!b)return;const i=l?.key,c=l?.props.id;if(i==null||c==null){m(null);return}Promise.resolve(t(c,b)).then(()=>{m(null)})},[t,l,b]),ee.createElement(ee.Fragment,null,s,l?R.cloneElement(l,{ref:C}):null)}const mc={x:0,y:0,scaleX:1,scaleY:1};function vc(e){let{children:t}=e;return ee.createElement(ss.Provider,{value:Cn},ee.createElement(Os.Provider,{value:mc},t))}const gc={position:"fixed",touchAction:"none"},_c=e=>wr(e)?"transform 250ms ease":void 0,bc=R.forwardRef((e,t)=>{let{as:s,activatorEvent:l,adjustScale:m,children:b,className:C,rect:r,style:i,transform:c,transition:d=_c}=e;if(!r)return null;const o=m?c:{...c,scaleX:1,scaleY:1},p={...gc,width:r.width,height:r.height,top:r.top,left:r.left,transform:Yt.Transform.toString(o),transformOrigin:m&&l?hl(l,r):void 0,transition:typeof d=="function"?d(l):d,...i};return ee.createElement(s,{className:C,style:p,ref:t},b)}),xc=e=>t=>{let{active:s,dragOverlay:l}=t;const m={},{styles:b,className:C}=e;if(b!=null&&b.active)for(const[r,i]of Object.entries(b.active))i!==void 0&&(m[r]=s.node.style.getPropertyValue(r),s.node.style.setProperty(r,i));if(b!=null&&b.dragOverlay)for(const[r,i]of Object.entries(b.dragOverlay))i!==void 0&&l.node.style.setProperty(r,i);return C!=null&&C.active&&s.node.classList.add(C.active),C!=null&&C.dragOverlay&&l.node.classList.add(C.dragOverlay),function(){for(const[i,c]of Object.entries(m))s.node.style.setProperty(i,c);C!=null&&C.active&&s.node.classList.remove(C.active)}},Sc=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:Yt.Transform.toString(t)},{transform:Yt.Transform.toString(s)}]},yc={duration:250,easing:"ease",keyframes:Sc,sideEffects:xc({styles:{active:{opacity:"0"}}})};function Cc(e){let{config:t,draggableNodes:s,droppableContainers:l,measuringConfiguration:m}=e;return Ns((b,C)=>{if(t===null)return;const r=s.get(b);if(!r)return;const i=r.node.current;if(!i)return;const c=yn(C);if(!c)return;const{transform:d}=Ve(C).getComputedStyle(C),o=un(d);if(!o)return;const p=typeof t=="function"?t:wc(t);return _n(i,m.draggable.measure),p({active:{id:b,data:r.data,node:i,rect:m.draggable.measure(i)},draggableNodes:s,dragOverlay:{node:C,rect:m.dragOverlay.measure(c)},droppableContainers:l,measuringConfiguration:m,transform:o})})}function wc(e){const{duration:t,easing:s,sideEffects:l,keyframes:m}={...yc,...e};return b=>{let{active:C,dragOverlay:r,transform:i,...c}=b;if(!t)return;const d={x:r.rect.left-C.rect.left,y:r.rect.top-C.rect.top},o={scaleX:i.scaleX!==1?C.rect.width*i.scaleX/r.rect.width:1,scaleY:i.scaleY!==1?C.rect.height*i.scaleY/r.rect.height:1},p={x:i.x-d.x,y:i.y-d.y,...o},g=m({...c,active:C,dragOverlay:r,transform:{initial:i,final:p}}),[S]=g,_=g[g.length-1];if(JSON.stringify(S)===JSON.stringify(_))return;const n=l?.({active:C,dragOverlay:r,...c}),f=r.node.animate(g,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{f.onfinish=()=>{n?.(),h()}})}}let ni=0;function Ec(e){return R.useMemo(()=>{if(e!=null)return ni++,ni},[e])}const kc=ee.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:l,style:m,transition:b,modifiers:C,wrapperElement:r="div",className:i,zIndex:c=999}=e;const{activatorEvent:d,active:o,activeNodeRect:p,containerNodeRect:g,draggableNodes:S,droppableContainers:_,dragOverlay:n,over:f,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:v,windowRect:x}=hc(),w=R.useContext(Os),k=Ec(o?.id),y=En(C,{activatorEvent:d,active:o,activeNodeRect:p,containerNodeRect:g,draggingNodeRect:n.rect,over:f,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:v,transform:w,windowRect:x}),E=Tr(p),j=Cc({config:l,draggableNodes:S,droppableContainers:_,measuringConfiguration:h}),A=E?n.setRef:void 0;return ee.createElement(vc,null,ee.createElement(pc,{animation:j},o&&k?ee.createElement(bc,{key:k,id:o.id,ref:A,as:r,activatorEvent:d,adjustScale:t,className:i,transition:b,rect:E,style:{zIndex:c,...m},transform:y},s):null))}),le={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Rc=[{status:le.Review,label:"Review",icon:mr,color:"text-amber-600"},{status:le.Running,label:"Running",icon:vr,color:"text-blue-600"},{status:le.Pending,label:"Pending",icon:gr,color:"text-neutral-600"},{status:le.Done,label:"Done",icon:_r,color:"text-emerald-600"},{status:le.Cancelled,label:"Cancelled",icon:br,color:"text-neutral-500"}];function Dc({task:e,status:t,isSelected:s,isAgentActive:l,project:m,onSelectTask:b,onTaskStatusChange:C,onDeleteTask:r}){const{attributes:i,listeners:c,setNodeRef:d,isDragging:o}=cc({id:e.id,data:{task:e,fromStatus:t}}),[p,g]=R.useState(null),S=R.useRef(null),_=R.useCallback(n=>{!C&&!r||(n.preventDefault(),g({x:n.clientX,y:n.clientY}))},[C,r]);return R.useEffect(()=>{if(!p)return;const n=f=>{S.current&&!S.current.contains(f.target)&&g(null)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:d,onClick:()=>b(e.id),onContextMenu:_,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
7
- ${o?"opacity-30":""}
8
- ${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...c,...i,children:[a.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===le.Running?"text-blue-600":"text-neutral-500"}`,children:[t===le.Review&&a.jsx(mr,{className:s?"text-amber-600":"text-neutral-500"}),t===le.Running&&a.jsx(vr,{className:"animate-pulse"}),t===le.Pending&&a.jsx(gr,{}),t===le.Done&&a.jsx(_r,{className:"text-neutral-400"}),t===le.Cancelled&&a.jsx(br,{className:"text-neutral-400"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"mb-0.5",children:[a.jsx("span",{className:`font-medium mr-1 ${m?.color||"text-neutral-500"}`,children:m?.name}),a.jsx("span",{className:"text-neutral-400",children:"/"}),a.jsx("span",{className:`ml-1 ${s?"text-neutral-900":"text-neutral-700"}`,children:e.title}),l&&a.jsxs("span",{className:"relative inline-flex h-2 w-2 ml-1.5 align-middle",children:[a.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),a.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),a.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})]})]}),p&&a.jsxs("div",{ref:S,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:p.x,top:p.y},children:[C&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:"移动到"}),Rc.filter(n=>n.status!==t).map(n=>{const f=n.icon;return a.jsxs("button",{onClick:()=>{C(e.id,n.status),g(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[a.jsx(f,{className:`w-3.5 h-3.5 ${n.color}`}),a.jsx("span",{className:"text-neutral-700",children:n.label})]},n.status)})]}),r&&a.jsxs(a.Fragment,{children:[C&&a.jsx("div",{className:"my-1 border-t border-neutral-100"}),a.jsxs("button",{onClick:()=>{r(e.id),g(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:[a.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:[a.jsx("path",{d:"M3 6h18"}),a.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),a.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),a.jsx("span",{children:"删除任务"})]})]})]})]})}const Tc=R.memo(function({title:t,tasks:s,status:l,defaultOpen:m,selectedTaskId:b,onSelectTask:C,projects:r,activeTaskIds:i,isDragging:c,dragFromStatus:d,onTaskStatusChange:o,onDeleteTask:p}){const[g,S]=R.useState(m),_=s.length===0,n=c&&d===l,f=c&&d!==l,{setNodeRef:h,isOver:u}=fc({id:`group-${l}`,data:{status:l}}),v=l===le.Review,x=c?n&&(g||!0):g;return a.jsxs("div",{className:"mb-2",children:[a.jsxs("button",{onClick:()=>!c&&S(w=>!w),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:[a.jsx("span",{className:"mr-2 text-neutral-400",children:x?a.jsx(pt,{size:14}):a.jsx(kt,{size:14})}),a.jsx("span",{className:"flex-1 text-left",children:t}),v&&!_?a.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}):a.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",s.length,")"]})]}),f&&a.jsx("div",{ref:h,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
- ${u?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:a.jsx("span",{className:"text-xs font-medium",children:u?`放入 ${t}`:"拖到此处"})}),x&&!f&&a.jsx("div",{ref:n?void 0:h,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
10
- ${u&&!n?"bg-blue-50 ring-1 ring-blue-200":""}
11
- ${_&&c?"border border-dashed border-neutral-300":""}`,children:_?a.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:"No tasks"}):s.map(w=>{const k=r.find(j=>j.id===w.projectId),y=b===w.id,E=i?.has(w.id)??!1;return a.jsx(Dc,{task:w,status:l,isSelected:y,isAgentActive:E,project:k,onSelectTask:C,onTaskStatusChange:o,onDeleteTask:p},w.id)})})]})}),jc=a.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:a.jsx("span",{children:"0 tasks"})});function Lc(e){const t={[le.Review]:[],[le.Running]:[],[le.Pending]:[],[le.Done]:[],[le.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const Ac=[{status:le.Review,title:"Review",defaultOpen:!0},{status:le.Running,title:"Running",defaultOpen:!0},{status:le.Pending,title:"Pending",defaultOpen:!1},{status:le.Done,title:"Done",defaultOpen:!1},{status:le.Cancelled,title:"Cancelled",defaultOpen:!1}];function oi({tasks:e=[],projects:t=[],selectedTaskId:s,onSelectTask:l,filterProjectId:m,setFilterProjectId:b,width:C=320,onCreateProject:r,onCreateTask:i,activeTaskIds:c,onTaskStatusChange:d,onDeleteTask:o}){const[p,g]=R.useState(!1),[S,_]=R.useState(null),[n,f]=R.useState(null),h=cl(ll(Dr,{activationConstraint:{distance:8}})),u=R.useCallback(E=>{const j=E.active.data.current?.task,A=E.active.data.current?.fromStatus;j&&_(j),A&&f(A)},[]),v=R.useCallback(E=>{_(null),f(null);const{active:j,over:A}=E;if(!A)return;const L=j.data.current?.task,N=j.data.current?.fromStatus,B=A.data.current?.status;!L||!N||!B||N!==B&&d?.(L.id,B)},[d]),x=m?e.filter(E=>E.projectId===m):e,w=m?t.find(E=>E.id===m)??null:null,k=Lc(x),y=C==="100%";return a.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${y?"":"border-r border-neutral-200"}`,style:{width:C},children:[a.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[a.jsxs("div",{className:"relative flex-1 mr-2",children:[a.jsxs("button",{onClick:()=>g(E=>!E),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&w?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),a.jsx("span",{className:"truncate",children:w.name})]}):a.jsxs(a.Fragment,{children:[a.jsx(Xr,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),a.jsx("span",{children:"All Projects"})]}),a.jsx(pt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${p?"rotate-180":""}`})]}),p?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>g(!1)}),a.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:[a.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:"Select View"}),a.jsxs("button",{onClick:()=>{b(null),g(!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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:a.jsx(Xr,{size:12})}),a.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:"All Projects"})]}),m===null?a.jsx(Ut,{size:14,className:"text-neutral-900"}):null]}),a.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),t.map(E=>{const j=m===E.id,A=E.color.replace("text-","bg-");return a.jsxs("button",{onClick:()=>{b(E.id),g(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${A}`}),a.jsx("span",{className:j?"text-neutral-900 font-medium":"text-neutral-600",children:E.name})]}),j?a.jsx(Ut,{size:14,className:"text-neutral-900"}):null]},E.id)}),a.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),a.jsxs("button",{onClick:()=>{g(!1),r?.()},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:[a.jsx(ir,{size:14}),a.jsx("span",{children:"Create New Project..."})]})]})]}):null]}),a.jsx("button",{onClick:i,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0",title:"New Task",children:a.jsx(ir,{size:18})})]}),a.jsxs(oc,{sensors:h,onDragStart:u,onDragEnd:v,children:[a.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:Ac.map(({status:E,title:j,defaultOpen:A})=>a.jsx(Tc,{title:j,tasks:k[E],status:E,defaultOpen:A,selectedTaskId:s,onSelectTask:l,projects:t,activeTaskIds:c,isDragging:S!==null,dragFromStatus:n,onTaskStatusChange:d,onDeleteTask:o},E))}),a.jsx(kc,{dropAnimation:null,children:S?a.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:a.jsx("span",{className:"text-neutral-700 font-medium",children:S.title})}):null})]}),x.length>0?a.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[a.jsxs("span",{children:[x.length," tasks"]}),m?a.jsx("button",{onClick:()=>b(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:"Clear filter"}):null]}):jc]})}const Nc={damping:.7,stiffness:.05,mass:1.25},Mc=70,Pc=1e3/60,Oc=350;let Bs=!1;globalThis.document?.addEventListener("mousedown",()=>{Bs=!0});globalThis.document?.addEventListener("mouseup",()=>{Bs=!1});globalThis.document?.addEventListener("click",()=>{Bs=!1});const kn=(e={})=>{const[t,s]=R.useState(!1),[l,m]=R.useState(e.initial!==!1),[b,C]=R.useState(!1),r=R.useRef(null);r.current=e;const i=R.useCallback(()=>{if(!Bs)return!1;const h=window.getSelection();if(!h||!h.rangeCount)return!1;const u=h.getRangeAt(0);return u.commonAncestorContainer.contains(n.current)||n.current?.contains(u.commonAncestorContainer)},[]),c=R.useCallback(h=>{o.isAtBottom=h,m(h)},[]),d=R.useCallback(h=>{o.escapedFromLock=h,s(h)},[]),o=R.useMemo(()=>{let h;return{escapedFromLock:t,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return n.current?.scrollTop??0},set scrollTop(u){n.current&&(n.current.scrollTop=u,o.ignoreScrollToTop=n.current.scrollTop)},get targetScrollTop(){return!n.current||!f.current?0:n.current.scrollHeight-1-n.current.clientHeight},get calculatedTargetScrollTop(){if(!n.current||!f.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(h?.targetScrollTop===u)return h.calculatedScrollTop;const v=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:n.current,contentElement:f.current}),u),0);return h={targetScrollTop:u,calculatedScrollTop:v},requestAnimationFrame(()=>{h=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Mc}}},[]),p=R.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||c(!0);const u=Date.now()+(Number(h.wait)||0),v=Xs(r.current,h.animation),{ignoreEscapes:x=!1}=h;let w,k=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const y=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:j}=o,A=performance.now(),L=(A-(o.lastTick??A))/Pc;if(o.animation||(o.animation={behavior:v,promise:E,ignoreEscapes:x}),o.animation.behavior===v&&(o.lastTick=A),i()||u>Date.now())return y();if(j<Math.min(k,o.calculatedTargetScrollTop)){if(o.animation?.behavior===v){if(v==="instant")return o.scrollTop=o.calculatedTargetScrollTop,y();o.velocity=(v.damping*o.velocity+v.stiffness*o.scrollDifference)/v.mass,o.accumulated+=o.velocity*L,o.scrollTop+=o.accumulated,o.scrollTop!==j&&(o.accumulated=0)}return y()}return w>Date.now()?(k=o.calculatedTargetScrollTop,y()):(o.animation=void 0,o.scrollTop<o.calculatedTargetScrollTop?p({animation:Xs(r.current,r.current.resize),ignoreEscapes:x,duration:Math.max(0,w-Date.now())||void 0}):o.isAtBottom)});return E.then(j=>(requestAnimationFrame(()=>{o.animation||(o.lastTick=void 0,o.velocity=0)}),j))};return h.wait!==!0&&(o.animation=void 0),o.animation?.behavior===v?o.animation.promise:y()},[c,i,o]),g=R.useCallback(()=>{d(!0),c(!1)},[d,c]),S=R.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:v}=o;let{lastScrollTop:x=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,v&&v>u&&(x=v),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===v)return;if(i()){d(!0),c(!1);return}const w=u>x,k=u<x;if(o.animation?.ignoreEscapes){o.scrollTop=x;return}k&&(d(!0),c(!1)),w&&d(!1),!o.escapedFromLock&&o.isNearBottom&&c(!0)},1)},[d,c,i,o]),_=R.useCallback(({target:h,deltaY:u})=>{let v=h;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===n.current&&u<0&&n.current.scrollHeight>n.current.clientHeight&&!o.animation?.ignoreEscapes&&(d(!0),c(!1))},[d,c,o]),n=ai(h=>{n.current?.removeEventListener("scroll",S),n.current?.removeEventListener("wheel",_),h?.addEventListener("scroll",S,{passive:!0}),h?.addEventListener("wheel",_,{passive:!0})},[]),f=ai(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([v])=>{const{height:x}=v.contentRect,w=x-(u??x);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const k=Xs(r.current,u?r.current.resize:r.current.initial);p({animation:k,wait:!0,preserveScrollPosition:!0,duration:k==="instant"?void 0:Oc})}else o.isNearBottom&&(d(!1),c(!0));u=x,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:f,scrollRef:n,scrollToBottom:p,stopScroll:g,isAtBottom:l||b,isNearBottom:b,escapedFromLock:t,state:o}};function ai(e,t){const s=R.useCallback(l=>(s.current=l,e(l)),t);return s}const qs=new Map;function Xs(...e){const t={...Nc};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 qs.has(l)||qs.set(l,Object.freeze(t)),s?"instant":qs.get(l)}function Bc({content:e,children:t,className:s=""}){return a.jsxs("div",{className:`group/tooltip relative ${s}`,children:[t,a.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,a.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-neutral-900"})]})]})}function cs(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ic(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Rn({usage:e}){if(!e)return null;const t=e.modelContextWindow,s=t?e.totalTokens/t:0,l=t?Math.min(Math.round(s*100),100):null,m=t?Ic(s):"text-neutral-400",b=t?a.jsxs("span",{children:["上下文: ",cs(e.totalTokens)," / ",cs(t)," tokens"]}):a.jsxs("span",{children:["已使用: ",cs(e.totalTokens)," tokens"]});return a.jsx(Bc,{content:b,children:a.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:[a.jsx(ma,{size:14,className:m}),a.jsxs("span",{className:`tabular-nums ${m}`,children:[cs(e.totalTokens),l!==null&&a.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",l,"%"]})]})]})})}var Ys={exports:{}},li;function Fc(){return li||(li=1,(function(e,t){(function(s,l){e.exports=l()})(self,(()=>(()=>{var s={4567:function(C,r,i){var c=this&&this.__decorate||function(u,v,x,w){var k,y=arguments.length,E=y<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,v,x,w);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(E=(y<3?k(E):y>3?k(v,x,E):k(v,x))||E);return y>3&&E&&Object.defineProperty(v,x,E),E},d=this&&this.__param||function(u,v){return function(x,w){v(x,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const o=i(9042),p=i(6114),g=i(9924),S=i(844),_=i(5596),n=i(4725),f=i(3656);let h=r.AccessibilityManager=class extends S.Disposable{constructor(u,v){super(),this._terminal=u,this._renderService=v,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 x=0;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);if(this._topBoundaryFocusListener=x=>this._handleBoundaryFocus(x,0),this._bottomBoundaryFocusListener=x=>this._handleBoundaryFocus(x,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 g.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((x=>this._handleResize(x.rows)))),this.register(this._terminal.onRender((x=>this._refreshRows(x.start,x.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((x=>this._handleChar(x)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
12
- `)))),this.register(this._terminal.onA11yTab((x=>this._handleTab(x)))),this.register(this._terminal.onKey((x=>this._handleKey(x.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,f.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let v=0;v<u;v++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
13
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=o.tooMuchOutput)),p.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,p.isMac&&this._liveRegion.remove()}_handleKey(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,v){this._liveRegionDebouncer.refresh(u,v,this._terminal.rows)}_renderRows(u,v){const x=this._terminal.buffer,w=x.lines.length.toString();for(let k=u;k<=v;k++){const y=x.translateBufferLineToString(x.ydisp+k,!0),E=(x.ydisp+k+1).toString(),j=this._rowElements[k];j&&(y.length===0?j.innerText=" ":j.textContent=y,j.setAttribute("aria-posinset",E),j.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,v){const x=u.target,w=this._rowElements[v===0?1:this._rowElements.length-2];if(x.getAttribute("aria-posinset")===(v===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==w)return;let k,y;if(v===0?(k=x,y=this._rowElements.pop(),this._rowContainer.removeChild(y)):(k=this._rowElements.shift(),y=x,this._rowContainer.removeChild(k)),k.removeEventListener("focus",this._topBoundaryFocusListener),y.removeEventListener("focus",this._bottomBoundaryFocusListener),v===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(v===0?-1:1),this._rowElements[v===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let v=this._rowContainer.children.length;v<this._terminal.rows;v++)this._rowElements[v]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[v]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=h=c([d(1,n.IRenderService)],h)},3614:(C,r)=>{function i(p){return p.replace(/\r?\n/g,"\r")}function c(p,g){return g?"\x1B[200~"+p+"\x1B[201~":p}function d(p,g,S,_){p=c(p=i(p),S.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(p,!0),g.value=""}function o(p,g,S){const _=S.getBoundingClientRect(),n=p.clientX-_.left-10,f=p.clientY-_.top-10;g.style.width="20px",g.style.height="20px",g.style.left=`${n}px`,g.style.top=`${f}px`,g.style.zIndex="1000",g.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=i,r.bracketTextForPaste=c,r.copyHandler=function(p,g){p.clipboardData&&p.clipboardData.setData("text/plain",g.selectionText),p.preventDefault()},r.handlePasteEvent=function(p,g,S,_){p.stopPropagation(),p.clipboardData&&d(p.clipboardData.getData("text/plain"),g,S,_)},r.paste=d,r.moveTextAreaUnderMouseCursor=o,r.rightClickHandler=function(p,g,S,_,n){o(p,g,S),n&&_.rightClickSelect(p),g.value=_.selectionText,g.select()}},7239:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const c=i(1505);r.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(d,o,p){this._css.set(d,o,p)}getCss(d,o){return this._css.get(d,o)}setColor(d,o,p){this._color.set(d,o,p)}getColor(d,o){return this._color.get(d,o)}clear(){this._color.clear(),this._css.clear()}}},3656:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(i,c,d,o){i.addEventListener(c,d,o);let p=!1;return{dispose:()=>{p||(p=!0,i.removeEventListener(c,d,o))}}}},6465:function(C,r,i){var c=this&&this.__decorate||function(n,f,h,u){var v,x=arguments.length,w=x<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(x<3?v(w):x>3?v(f,h,w):v(f,h))||w);return x>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const o=i(3656),p=i(8460),g=i(844),S=i(2585);let _=r.Linkifier2=class extends g.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,g.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,g.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const f=this._linkProviders.indexOf(n);f!==-1&&this._linkProviders.splice(f,1)}}}attachToDom(n,f,h){this._element=n,this._mouseService=f,this._renderService=h,this.register((0,o.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,o.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const f=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const h=n.composedPath();for(let u=0;u<h.length;u++){const v=h[u];if(v.classList.contains("xterm"))break;if(v.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,f){var h,u;this._activeProviderReplies&&f||((h=this._activeProviderReplies)===null||h===void 0||h.forEach((x=>{x?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let v=!1;for(const[x,w]of this._linkProviders.entries())f?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(x)&&(v=this._checkLinkProviderResult(x,n,v)):w.provideLinks(n.y,(k=>{var y,E;if(this._isMouseOut)return;const j=k?.map((A=>({link:A})));(y=this._activeProviderReplies)===null||y===void 0||y.set(x,j),v=this._checkLinkProviderResult(x,n,v),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,f){const h=new Set;for(let u=0;u<f.size;u++){const v=f.get(u);if(v)for(let x=0;x<v.length;x++){const w=v[x],k=w.link.range.start.y<n?0:w.link.range.start.x,y=w.link.range.end.y>n?this._bufferService.cols:w.link.range.end.x;for(let E=k;E<=y;E++){if(h.has(E)){v.splice(x--,1);break}h.add(E)}}}}_checkLinkProviderResult(n,f,h){var u;if(!this._activeProviderReplies)return h;const v=this._activeProviderReplies.get(n);let x=!1;for(let w=0;w<n;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(x=!0);if(!x&&v){const w=v.find((k=>this._linkAtPosition(k.link,f)));w&&(h=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviders.length&&!h)for(let w=0;w<this._activeProviderReplies.size;w++){const k=(u=this._activeProviderReplies.get(w))===null||u===void 0?void 0:u.find((y=>this._linkAtPosition(y.link,f)));if(k){h=!0,this._handleNewLink(k);break}}return h}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const f=this._positionFromMouseEvent(n,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,f){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!f||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,g.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(n.link,f)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:h=>{var u,v;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==h&&(this._currentLink.state.decorations.pointerCursor=h,this._currentLink.state.isHovered&&((v=this._element)===null||v===void 0||v.classList.toggle("xterm-cursor-pointer",h)))}},underline:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.underline},set:h=>{var u,v,x;!((u=this._currentLink)===null||u===void 0)&&u.state&&((x=(v=this._currentLink)===null||v===void 0?void 0:v.state)===null||x===void 0?void 0:x.decorations.underline)!==h&&(this._currentLink.state.decorations.underline=h,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,h))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((h=>{if(!this._currentLink)return;const u=h.start===0?0:h.start+1+this._bufferService.buffer.ydisp,v=this._bufferService.buffer.ydisp+1+h.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=v&&(this._clearCurrentLink(u,v),this._lastMouseEvent&&this._element)){const x=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);x&&this._askForLink(x,!1)}}))))}_linkHover(n,f,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(h,f.text)}_fireUnderlineEvent(n,f){const h=n.range,u=this._bufferService.buffer.ydisp,v=this._createLinkUnderlineEvent(h.start.x-1,h.start.y-u-1,h.end.x,h.end.y-u-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(v)}_linkLeave(n,f,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(h,f.text)}_linkAtPosition(n,f){const h=n.range.start.y*this._bufferService.cols+n.range.start.x,u=n.range.end.y*this._bufferService.cols+n.range.end.x,v=f.y*this._bufferService.cols+f.x;return h<=v&&v<=u}_positionFromMouseEvent(n,f,h){const u=h.getCoords(n,f,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,f,h,u,v){return{x1:n,y1:f,x2:h,y2:u,cols:this._bufferService.cols,fg:v}}};r.Linkifier2=_=c([d(0,S.IBufferService)],_)},9042:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(C,r,i){var c=this&&this.__decorate||function(_,n,f,h){var u,v=arguments.length,x=v<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,f):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(_,n,f,h);else for(var w=_.length-1;w>=0;w--)(u=_[w])&&(x=(v<3?u(x):v>3?u(n,f,x):u(n,f))||x);return v>3&&x&&Object.defineProperty(n,f,x),x},d=this&&this.__param||function(_,n){return function(f,h){n(f,h,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const o=i(511),p=i(2585);let g=r.OscLinkProvider=class{constructor(_,n,f){this._bufferService=_,this._optionsService=n,this._oscLinkService=f}provideLinks(_,n){var f;const h=this._bufferService.buffer.lines.get(_-1);if(!h)return void n(void 0);const u=[],v=this._optionsService.rawOptions.linkHandler,x=new o.CellData,w=h.getTrimmedLength();let k=-1,y=-1,E=!1;for(let j=0;j<w;j++)if(y!==-1||h.hasContent(j)){if(h.loadCell(j,x),x.hasExtendedAttrs()&&x.extended.urlId){if(y===-1){y=j,k=x.extended.urlId;continue}E=x.extended.urlId!==k}else y!==-1&&(E=!0);if(E||y!==-1&&j===w-1){const A=(f=this._oscLinkService.getLinkData(k))===null||f===void 0?void 0:f.uri;if(A){const L={start:{x:y+1,y:_},end:{x:j+(E||j!==w-1?0:1),y:_}};let N=!1;if(!v?.allowNonHttpProtocols)try{const B=new URL(A);["http:","https:"].includes(B.protocol)||(N=!0)}catch{N=!0}N||u.push({text:A,range:L,activate:(B,I)=>v?v.activate(B,I,L):S(0,I),hover:(B,I)=>{var H;return(H=v?.hover)===null||H===void 0?void 0:H.call(v,B,I,L)},leave:(B,I)=>{var H;return(H=v?.leave)===null||H===void 0?void 0:H.call(v,B,I,L)}})}E=!1,x.hasExtendedAttrs()&&x.extended.urlId?(y=j,k=x.extended.urlId):(y=-1,k=-1)}}n(u)}};function S(_,n){if(confirm(`Do you want to navigate to ${n}?
14
-
15
- WARNING: This link could potentially be dangerous`)){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=g=c([d(0,p.IBufferService),d(1,p.IOptionsService),d(2,p.IOscLinkService)],g)},6193:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(i,c){this._parentWindow=i,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,c,d){this._rowCount=d,i=i!==void 0?i:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,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 i=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const c=i(844);class d 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)}}r.ScreenDprMonitor=d},3236:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const c=i(3614),d=i(3656),o=i(6465),p=i(9042),g=i(3730),S=i(1680),_=i(3107),n=i(5744),f=i(2950),h=i(1296),u=i(428),v=i(4269),x=i(5114),w=i(8934),k=i(3230),y=i(9312),E=i(4725),j=i(6731),A=i(8055),L=i(8969),N=i(8460),B=i(844),I=i(6114),H=i(8437),W=i(2584),D=i(7399),M=i(5941),P=i(9074),O=i(2585),U=i(5435),X=i(4567),Y=typeof window<"u"?window.document:null;class Q extends L.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=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new 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(o.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(g.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,$)=>this.refresh(F,$)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,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((F=>this._afterResize(F.cols,F.rows)))),this.register((0,B.toDisposable)((()=>{var F,$;this._customKeyEventHandler=void 0,($=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||$===void 0||$.removeChild(this.element)})))}_handleColorEvent(T){if(this._themeService)for(const F of T){let $,z="";switch(F.index){case 256:$="foreground",z="10";break;case 257:$="background",z="11";break;case 258:$="cursor",z="12";break;default:$="ansi",z="4;"+F.index}switch(F.type){case 0:const Z=A.color.toColorRGB($==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[$]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${z};${(0,M.toRgbString)(Z)}${W.C1_ESCAPED.ST}`);break;case 1:if($==="ansi")this._themeService.modifyColors((q=>q.ansi[F.index]=A.rgba.toColor(...F.color)));else{const q=$;this._themeService.modifyColors((ne=>ne[q]=A.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(T){T?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.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,F=this.buffer.lines.get(T);if(!F)return;const $=Math.min(this.buffer.x,this.cols-1),z=this._renderService.dimensions.css.cell.height,Z=F.getWidth($),q=this._renderService.dimensions.css.cell.width*Z,ne=this.buffer.y*this._renderService.dimensions.css.cell.height,fe=$*this._renderService.dimensions.css.cell.width;this.textarea.style.left=fe+"px",this.textarea.style.top=ne+"px",this.textarea.style.width=q+"px",this.textarea.style.height=z+"px",this.textarea.style.lineHeight=z+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,c.copyHandler)(F,this._selectionService)})));const T=F=>(0,c.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",T)),this.register((0,d.addDisposableDomListener)(this.element,"paste",T)),I.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,c.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,c.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,c.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(T=>this._keyUp(T)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(T=>this._keyDown(T)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(T=>this._keyPress(T)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(T=>this._compositionHelper.compositionupdate(T)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(T=>this._inputEvent(T)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(T){var F;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 $=Y.createDocumentFragment();this._viewportElement=Y.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),$.appendChild(this._viewportElement),this._viewportScrollArea=Y.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=Y.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=Y.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),$.appendChild(this.screenElement),this.textarea=Y.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(x.CoreBrowserService,this.textarea,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(z=>this._handleTextAreaFocus(z)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(j.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(v.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(k.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((z=>this._onRender.fire(z)))),this.onResize((z=>this._renderService.resize(z.cols,z.rows))),this._compositionView=Y.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(f.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild($);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(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((z=>this.scrollLines(z.amount,z.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(y.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((z=>this.scrollLines(z.amount,z.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((z=>this._renderService.handleSelectionChanged(z.start,z.end,z.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((z=>{this.textarea.value=z,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((z=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.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,d.addDisposableDomListener)(this.element,"mousedown",(z=>this._selectionService.handleMouseDown(z)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(z=>this._handleScreenReaderModeOptionChange(z)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(z=>{!this._overviewRulerRenderer&&z&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(h.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const T=this,F=this.element;function $(q){const ne=T._mouseService.getMouseReportCoords(q,T.screenElement);if(!ne)return!1;let fe,ye;switch(q.overrideType||q.type){case"mousemove":ye=32,q.buttons===void 0?(fe=3,q.button!==void 0&&(fe=q.button<3?q.button:3)):fe=1&q.buttons?0:4&q.buttons?1:2&q.buttons?2:3;break;case"mouseup":ye=0,fe=q.button<3?q.button:3;break;case"mousedown":ye=1,fe=q.button<3?q.button:3;break;case"wheel":if(T.viewport.getLinesScrolled(q)===0)return!1;ye=q.deltaY<0?0:1,fe=4;break;default:return!1}return!(ye===void 0||fe===void 0||fe>4)&&T.coreMouseService.triggerMouseEvent({col:ne.col,row:ne.row,x:ne.x,y:ne.y,button:fe,action:ye,ctrl:q.ctrlKey,alt:q.altKey,shift:q.shiftKey})}const z={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Z={mouseup:q=>($(q),q.buttons||(this._document.removeEventListener("mouseup",z.mouseup),z.mousedrag&&this._document.removeEventListener("mousemove",z.mousedrag)),this.cancel(q)),wheel:q=>($(q),this.cancel(q,!0)),mousedrag:q=>{q.buttons&&$(q)},mousemove:q=>{q.buttons||$(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?z.mousemove||(F.addEventListener("mousemove",Z.mousemove),z.mousemove=Z.mousemove):(F.removeEventListener("mousemove",z.mousemove),z.mousemove=null),16&q?z.wheel||(F.addEventListener("wheel",Z.wheel,{passive:!1}),z.wheel=Z.wheel):(F.removeEventListener("wheel",z.wheel),z.wheel=null),2&q?z.mouseup||(F.addEventListener("mouseup",Z.mouseup),z.mouseup=Z.mouseup):(this._document.removeEventListener("mouseup",z.mouseup),F.removeEventListener("mouseup",z.mouseup),z.mouseup=null),4&q?z.mousedrag||(z.mousedrag=Z.mousedrag):(this._document.removeEventListener("mousemove",z.mousedrag),z.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(F,"mousedown",(q=>{if(q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(q))return $(q),z.mouseup&&this._document.addEventListener("mouseup",z.mouseup),z.mousedrag&&this._document.addEventListener("mousemove",z.mousedrag),this.cancel(q)}))),this.register((0,d.addDisposableDomListener)(F,"wheel",(q=>{if(!z.wheel){if(!this.buffer.hasScrollback){const ne=this.viewport.getLinesScrolled(q);if(ne===0)return;const fe=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(q.deltaY<0?"A":"B");let ye="";for(let Le=0;Le<Math.abs(ne);Le++)ye+=fe;return this.coreService.triggerDataEvent(ye,!0),this.cancel(q,!0)}return this.viewport.handleWheel(q)?this.cancel(q):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(F,"touchstart",(q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(q),this.cancel(q)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(F,"touchmove",(q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(q)?void 0:this.cancel(q)}),{passive:!1}))}refresh(T,F){var $;($=this._renderService)===null||$===void 0||$.refreshRows(T,F)}updateCursorStyle(T){var F;!((F=this._selectionService)===null||F===void 0)&&F.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,F,$=0){var z;$===1?(super.scrollLines(T,F,$),this.refresh(0,this.rows-1)):(z=this.viewport)===null||z===void 0||z.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 F=this._characterJoinerService.register(T);return this.refresh(0,this.rows-1),F}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,F,$){this._selectionService.setSelection(T,F,$)}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,F){var $;($=this._selectionService)===null||$===void 0||$.selectLines(T,F)}_keyDown(T){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&T.altKey;if(!F&&!this._compositionHelper.keydown(T))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||T.key!=="Dead"&&T.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const $=(0,D.evaluateKeyboardEvent)(T,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(T),$.type===3||$.type===2){const z=this.rows-1;return this.scrollLines($.type===2?-z:z),this.cancel(T,!0)}return $.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,T)||($.cancel&&this.cancel(T,!0),!$.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):($.key!==W.C0.ETX&&$.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:$.key,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent($.key,!0),!this.optionsService.rawOptions.screenReaderMode||T.altKey||T.ctrlKey?this.cancel(T,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(T,F){const $=T.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||T.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||T.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?$:$&&(!F.keyCode||F.keyCode>47)}_keyUp(T){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(T)||this.focus(),this.updateCursorStyle(T),this._keyPressHandled=!1)}_keyPress(T){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;if(this.cancel(T),T.charCode)F=T.charCode;else if(T.which===null||T.which===void 0)F=T.keyCode;else{if(T.which===0||T.charCode===0)return!1;F=T.which}return!(!F||(T.altKey||T.ctrlKey||T.metaKey)&&!this._isThirdLevelShift(this.browser,T)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(F,!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 F=T.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(T),!0}return!1}resize(T,F){T!==this.cols||F!==this.rows?super.resize(T,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(T,F){var $,z;($=this._charSizeService)===null||$===void 0||$.measure(),(z=this.viewport)===null||z===void 0||z.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 F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(T=this.viewport)===null||T===void 0||T.reset(),this.refresh(0,this.rows-1)}}reset(){var T,F;this.options.rows=this.rows,this.options.cols=this.cols;const $=this._customKeyEventHandler;this._setup(),super.reset(),(T=this._selectionService)===null||T===void 0||T.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=$,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 U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),$=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${$};${F}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const z=this._renderService.dimensions.css.cell.width.toFixed(0),Z=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${Z};${z}t`)}}cancel(T,F){if(this.options.cancelEvents||F)return T.preventDefault(),T.stopPropagation(),!1}}r.Terminal=Q},9924:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(i,c=1e3){this._renderCallback=i,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,c,d){this._rowCount=d,i=i!==void 0?i:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const o=Date.now();if(o-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=o,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=o-this._lastRefreshMs,g=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),g)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c)}}},1680:function(C,r,i){var c=this&&this.__decorate||function(f,h,u,v){var x,w=arguments.length,k=w<3?h:v===null?v=Object.getOwnPropertyDescriptor(h,u):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(f,h,u,v);else for(var y=f.length-1;y>=0;y--)(x=f[y])&&(k=(w<3?x(k):w>3?x(h,u,k):x(h,u))||k);return w>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(f,h){return function(u,v){h(u,v,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const o=i(3656),p=i(4725),g=i(8460),S=i(844),_=i(2585);let n=r.Viewport=class extends S.Disposable{constructor(f,h,u,v,x,w,k,y){super(),this._viewportElement=f,this._scrollArea=h,this._bufferService=u,this._optionsService=v,this._charSizeService=x,this._renderService=w,this._coreBrowserService=k,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 g.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,o.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(y.colors),this.register(y.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(f){this._viewportElement.style.backgroundColor=f.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(f){if(f)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const h=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==h&&(this._lastRecordedBufferHeight=h,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const f=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==f&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=f),this._refreshAnimationFrame=null}syncScrollArea(f=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(f);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(f)}_handleScroll(f){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const h=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const f=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(f*(this._smoothScrollState.target-this._smoothScrollState.origin)),f<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(f,h){const u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(h<0&&this._viewportElement.scrollTop!==0||h>0&&u<this._lastRecordedBufferHeight)||(f.cancelable&&f.preventDefault(),!1)}handleWheel(f){const h=this._getPixelsScrolled(f);return h!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+h:this._smoothScrollState.target+=h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=h,this._bubbleScroll(f,h))}scrollLines(f){if(f!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const h=f*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:f,suppressScrollEvent:!1})}_getPixelsScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let h=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_LINE?h*=this._currentRowHeight:f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._currentRowHeight*this._bufferService.rows),h}getBufferElements(f,h){var u;let v,x="";const w=[],k=h??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let E=f;E<k;E++){const j=y.get(E);if(!j)continue;const A=(u=y.get(E+1))===null||u===void 0?void 0:u.isWrapped;if(x+=j.translateToString(!A),!A||E===y.length-1){const L=document.createElement("div");L.textContent=x,w.push(L),x.length>0&&(v=L),x=""}}return{bufferElements:w,cursorElement:v}}getLinesScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let h=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(h/=this._currentRowHeight+0,this._wheelPartialScroll+=h,h=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._bufferService.rows),h}_applyScrollModifier(f,h){const u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&h.altKey||u==="ctrl"&&h.ctrlKey||u==="shift"&&h.shiftKey?f*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:f*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(f){this._lastTouchY=f.touches[0].pageY}handleTouchMove(f){const h=this._lastTouchY-f.touches[0].pageY;return this._lastTouchY=f.touches[0].pageY,h!==0&&(this._viewportElement.scrollTop+=h,this._bubbleScroll(f,h))}};r.Viewport=n=c([d(2,_.IBufferService),d(3,_.IOptionsService),d(4,p.ICharSizeService),d(5,p.IRenderService),d(6,p.ICoreBrowserService),d(7,p.IThemeService)],n)},3107:function(C,r,i){var c=this&&this.__decorate||function(n,f,h,u){var v,x=arguments.length,w=x<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(x<3?v(w):x>3?v(f,h,w):v(f,h))||w);return x>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const o=i(3656),p=i(4725),g=i(844),S=i(2585);let _=r.BufferDecorationRenderer=class extends g.Disposable{constructor(n,f,h,u){super(),this._screenElement=n,this._bufferService=f,this._decorationService=h,this._renderService=u,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,o.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((v=>this._removeDecoration(v)))),this.register((0,g.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var f,h;const u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((f=n?.options)===null||f===void 0?void 0:f.layer)==="top"),u.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(n.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const v=(h=n.options.x)!==null&&h!==void 0?h:0;return v&&v>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(n,u),u}_refreshStyle(n){const f=n.marker.line-this._bufferService.buffers.active.ydisp;if(f<0||f>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let h=this._decorationElements.get(n);h||(h=this._createElement(n),n.element=h,this._decorationElements.set(n,h),this._container.appendChild(h),n.onDispose((()=>{this._decorationElements.delete(n),h.remove()}))),h.style.top=f*this._renderService.dimensions.css.cell.height+"px",h.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(h)}}_refreshXPosition(n,f=n.element){var h;if(!f)return;const u=(h=n.options.x)!==null&&h!==void 0?h:0;(n.options.anchor||"left")==="right"?f.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":f.style.left=u?u*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var f;(f=this._decorationElements.get(n))===null||f===void 0||f.remove(),this._decorationElements.delete(n),n.dispose()}};r.BufferDecorationRenderer=_=c([d(1,S.IBufferService),d(2,S.IDecorationService),d(3,p.IRenderService)],_)},5871:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const c of this._zones)if(c.color===i.options.overviewRulerOptions.color&&c.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,i.marker.line))return;if(this._lineAdjacentToZone(c,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(c,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,c){return c>=i.startBufferLine&&c<=i.endBufferLine}_lineAdjacentToZone(i,c,d){return c>=i.startBufferLine-this._linePadding[d||"full"]&&c<=i.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(i,c){i.startBufferLine=Math.min(i.startBufferLine,c),i.endBufferLine=Math.max(i.endBufferLine,c)}}},5744:function(C,r,i){var c=this&&this.__decorate||function(v,x,w,k){var y,E=arguments.length,j=E<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(v,x,w,k);else for(var A=v.length-1;A>=0;A--)(y=v[A])&&(j=(E<3?y(j):E>3?y(x,w,j):y(x,w))||j);return E>3&&j&&Object.defineProperty(x,w,j),j},d=this&&this.__param||function(v,x){return function(w,k){x(w,k,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const o=i(5871),p=i(3656),g=i(4725),S=i(844),_=i(2585),n={full:0,left:0,center:0,right:0},f={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0};let u=r.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(v,x,w,k,y,E,j){var A;super(),this._viewportElement=v,this._screenElement=x,this._bufferService=w,this._decorationService=k,this._renderService=y,this._optionsService=E,this._coreBrowseService=j,this._colorZoneStore=new o.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(A=this._viewportElement.parentElement)===null||A===void 0||A.insertBefore(this._canvas,this._viewportElement);const L=this._canvas.getContext("2d");if(!L)throw new Error("Ctx cannot be null");this._ctx=L,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,S.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 v=Math.floor(this._canvas.width/3),x=Math.ceil(this._canvas.width/3);f.full=this._canvas.width,f.left=v,f.center=x,f.right=v,this._refreshDrawHeightConstants(),h.full=0,h.left=0,h.center=f.left,h.right=f.left+f.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const v=this._canvas.height/this._bufferService.buffer.lines.length,x=Math.round(Math.max(Math.min(v,12),6)*this._coreBrowseService.dpr);n.left=x,n.center=x,n.right=x}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const x of this._decorationService.decorations)this._colorZoneStore.addDecoration(x);this._ctx.lineWidth=1;const v=this._colorZoneStore.zones;for(const x of v)x.position!=="full"&&this._renderColorZone(x);for(const x of v)x.position==="full"&&this._renderColorZone(x);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(v){this._ctx.fillStyle=v.color,this._ctx.fillRect(h[v.position||"full"],Math.round((this._canvas.height-1)*(v.startBufferLine/this._bufferService.buffers.active.lines.length)-n[v.position||"full"]/2),f[v.position||"full"],Math.round((this._canvas.height-1)*((v.endBufferLine-v.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[v.position||"full"]))}_queueRefresh(v,x){this._shouldUpdateDimensions=v||this._shouldUpdateDimensions,this._shouldUpdateAnchor=x||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=u=c([d(2,_.IBufferService),d(3,_.IDecorationService),d(4,g.IRenderService),d(5,_.IOptionsService),d(6,g.ICoreBrowserService)],u)},2950:function(C,r,i){var c=this&&this.__decorate||function(_,n,f,h){var u,v=arguments.length,x=v<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,f):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(_,n,f,h);else for(var w=_.length-1;w>=0;w--)(u=_[w])&&(x=(v<3?u(x):v>3?u(n,f,x):u(n,f))||x);return v>3&&x&&Object.defineProperty(n,f,x),x},d=this&&this.__param||function(_,n){return function(f,h){n(f,h,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const o=i(4725),p=i(2585),g=i(2584);let S=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,n,f,h,u,v){this._textarea=_,this._compositionView=n,this._bufferService=f,this._optionsService=h,this._coreService=u,this._renderService=v,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 n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let f;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,f=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),f.length>0&&this._coreService.triggerDataEvent(f,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,f=n.replace(_,"");this._dataAlreadySent=f,n.length>_.length?this._coreService.triggerDataEvent(f,!0):n.length<_.length?this._coreService.triggerDataEvent(`${g.C0.DEL}`,!0):n.length===_.length&&n!==_&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(_){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),f=this._renderService.dimensions.css.cell.height,h=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,u=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"px",this._compositionView.style.top=h+"px",this._compositionView.style.height=f+"px",this._compositionView.style.lineHeight=f+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const v=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=h+"px",this._textarea.style.width=Math.max(v.width,1)+"px",this._textarea.style.height=Math.max(v.height,1)+"px",this._textarea.style.lineHeight=v.height+"px"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=S=c([d(2,p.IBufferService),d(3,p.IOptionsService),d(4,p.ICoreService),d(5,o.IRenderService)],S)},9806:(C,r)=>{function i(c,d,o){const p=o.getBoundingClientRect(),g=c.getComputedStyle(o),S=parseInt(g.getPropertyValue("padding-left")),_=parseInt(g.getPropertyValue("padding-top"));return[d.clientX-p.left-S,d.clientY-p.top-_]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=i,r.getCoords=function(c,d,o,p,g,S,_,n,f){if(!S)return;const h=i(c,d,o);return h?(h[0]=Math.ceil((h[0]+(f?_/2:0))/_),h[1]=Math.ceil(h[1]/n),h[0]=Math.min(Math.max(h[0],1),p+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),g),h):void 0}},9504:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const c=i(2584);function d(n,f,h,u){const v=n-o(n,h),x=f-o(f,h),w=Math.abs(v-x)-(function(k,y,E){let j=0;const A=k-o(k,E),L=y-o(y,E);for(let N=0;N<Math.abs(A-L);N++){const B=p(k,y)==="A"?-1:1,I=E.buffer.lines.get(A+B*N);I?.isWrapped&&j++}return j})(n,f,h);return _(w,S(p(n,f),u))}function o(n,f){let h=0,u=f.buffer.lines.get(n),v=u?.isWrapped;for(;v&&n>=0&&n<f.rows;)h++,u=f.buffer.lines.get(--n),v=u?.isWrapped;return h}function p(n,f){return n>f?"A":"B"}function g(n,f,h,u,v,x){let w=n,k=f,y="";for(;w!==h||k!==u;)w+=v?1:-1,v&&w>x.cols-1?(y+=x.buffer.translateBufferLineToString(k,!1,n,w),w=0,n=0,k++):!v&&w<0&&(y+=x.buffer.translateBufferLineToString(k,!1,0,n+1),w=x.cols-1,n=w,k--);return y+x.buffer.translateBufferLineToString(k,!1,n,w)}function S(n,f){const h=f?"O":"[";return c.C0.ESC+h+n}function _(n,f){n=Math.floor(n);let h="";for(let u=0;u<n;u++)h+=f;return h}r.moveToCellSequence=function(n,f,h,u){const v=h.buffer.x,x=h.buffer.y;if(!h.buffer.hasScrollback)return(function(y,E,j,A,L,N){return d(E,A,L,N).length===0?"":_(g(y,E,y,E-o(E,L),!1,L).length,S("D",N))})(v,x,0,f,h,u)+d(x,f,h,u)+(function(y,E,j,A,L,N){let B;B=d(E,A,L,N).length>0?A-o(A,L):E;const I=A,H=(function(W,D,M,P,O,U){let X;return X=d(M,P,O,U).length>0?P-o(P,O):D,W<M&&X<=P||W>=M&&X<P?"C":"D"})(y,E,j,A,L,N);return _(g(y,B,j,I,H==="C",L).length,S(H,N))})(v,x,n,f,h,u);let w;if(x===f)return w=v>n?"D":"C",_(Math.abs(v-n),S(w,u));w=x>f?"D":"C";const k=Math.abs(x-f);return _((function(y,E){return E.cols-y})(x>f?n:v,h)+(k-1)*h.cols+1+((x>f?v:n)-1),S(w,u))}},1296:function(C,r,i){var c=this&&this.__decorate||function(L,N,B,I){var H,W=arguments.length,D=W<3?N:I===null?I=Object.getOwnPropertyDescriptor(N,B):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(L,N,B,I);else for(var M=L.length-1;M>=0;M--)(H=L[M])&&(D=(W<3?H(D):W>3?H(N,B,D):H(N,B))||D);return W>3&&D&&Object.defineProperty(N,B,D),D},d=this&&this.__param||function(L,N){return function(B,I){N(B,I,L)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const o=i(3787),p=i(2550),g=i(2223),S=i(6171),_=i(4725),n=i(8055),f=i(8460),h=i(844),u=i(2585),v="xterm-dom-renderer-owner-",x="xterm-rows",w="xterm-fg-",k="xterm-bg-",y="xterm-focus",E="xterm-selection";let j=1,A=r.DomRenderer=class extends h.Disposable{constructor(L,N,B,I,H,W,D,M,P,O){super(),this._element=L,this._screenElement=N,this._viewportElement=B,this._linkifier2=I,this._charSizeService=W,this._optionsService=D,this._bufferService=M,this._coreBrowserService=P,this._themeService=O,this._terminalClass=j++,this._rowElements=[],this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(x),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(o.DomRendererRowFactory,document),this._element.classList.add(v+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,h.toDisposable)((()=>{this._element.classList.remove(v+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 L=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*L,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*L),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/L),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/L),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const N=`${this._terminalSelector} .${x} 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(L){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let N=`${this._terminalSelector} .${x} { color: ${L.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;N+=`${this._terminalSelector} .${x} .xterm-dim { color: ${n.color.multiplyOpacity(L.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: ${L.cursor.css}; color: ${L.cursorAccent.css}; } 50% { background-color: inherit; color: ${L.cursor.css}; }}`,N+=`${this._terminalSelector} .${x}.${y} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${x}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${x} .xterm-cursor.xterm-cursor-block { background-color: ${L.cursor.css}; color: ${L.cursorAccent.css};}${this._terminalSelector} .${x} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${L.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${x} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${L.cursor.css} inset;}${this._terminalSelector} .${x} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${L.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,N+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${L.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${L.selectionInactiveBackgroundOpaque.css};}`;for(const[B,I]of L.ansi.entries())N+=`${this._terminalSelector} .${w}${B} { color: ${I.css}; }${this._terminalSelector} .${w}${B}.xterm-dim { color: ${n.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${k}${B} { background-color: ${I.css}; }`;N+=`${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(L.background).css}; }${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(L.background),.5).css}; }${this._terminalSelector} .${k}${g.INVERTED_DEFAULT_COLOR} { background-color: ${L.foreground.css}; }`,this._themeStyleElement.textContent=N}_setDefaultSpacing(){const L=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${L}px`,this._rowFactory.defaultSpacing=L}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(L,N){for(let B=this._rowElements.length;B<=N;B++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>N;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(L,N){this._refreshRowElements(L,N),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(L,N,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(L,N,B),this.renderRows(0,this._bufferService.rows-1),!L||!N)return;const I=L[1]-this._bufferService.buffer.ydisp,H=N[1]-this._bufferService.buffer.ydisp,W=Math.max(I,0),D=Math.min(H,this._bufferService.rows-1);if(W>=this._bufferService.rows||D<0)return;const M=document.createDocumentFragment();if(B){const P=L[0]>N[0];M.appendChild(this._createSelectionElement(W,P?N[0]:L[0],P?L[0]:N[0],D-W+1))}else{const P=I===W?L[0]:0,O=W===H?N[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(W,P,O));const U=D-W-1;if(M.appendChild(this._createSelectionElement(W+1,0,this._bufferService.cols,U)),W!==D){const X=H===D?N[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(D,0,X))}}this._selectionContainer.appendChild(M)}_createSelectionElement(L,N,B,I=1){const H=document.createElement("div");return H.style.height=I*this.dimensions.css.cell.height+"px",H.style.top=L*this.dimensions.css.cell.height+"px",H.style.left=N*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(B-N)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const L of this._rowElements)L.replaceChildren()}renderRows(L,N){const B=this._bufferService.buffer,I=B.ybase+B.y,H=Math.min(B.x,this._bufferService.cols-1),W=this._optionsService.rawOptions.cursorBlink,D=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=L;P<=N;P++){const O=P+B.ydisp,U=this._rowElements[P],X=B.lines.get(O);if(!U||!X)break;U.replaceChildren(...this._rowFactory.createRow(X,O,O===I,D,M,H,W,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${v}${this._terminalClass}`}_handleLinkHover(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!0)}_handleLinkLeave(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!1)}_setCellUnderline(L,N,B,I,H,W){B<0&&(L=0),I<0&&(N=0);const D=this._bufferService.rows-1;B=Math.max(Math.min(B,D),0),I=Math.max(Math.min(I,D),0),H=Math.min(H,this._bufferService.cols);const M=this._bufferService.buffer,P=M.ybase+M.y,O=Math.min(M.x,H-1),U=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,Y=this._optionsService.rawOptions.cursorInactiveStyle;for(let Q=B;Q<=I;++Q){const oe=Q+M.ydisp,T=this._rowElements[Q],F=M.lines.get(oe);if(!T||!F)break;T.replaceChildren(...this._rowFactory.createRow(F,oe,oe===P,X,Y,O,U,this.dimensions.css.cell.width,this._widthCache,W?Q===B?L:0:-1,W?(Q===I?N:H)-1:-1))}}};r.DomRenderer=A=c([d(4,u.IInstantiationService),d(5,_.ICharSizeService),d(6,u.IOptionsService),d(7,u.IBufferService),d(8,_.ICoreBrowserService),d(9,_.IThemeService)],A)},3787:function(C,r,i){var c=this&&this.__decorate||function(w,k,y,E){var j,A=arguments.length,L=A<3?k:E===null?E=Object.getOwnPropertyDescriptor(k,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(w,k,y,E);else for(var N=w.length-1;N>=0;N--)(j=w[N])&&(L=(A<3?j(L):A>3?j(k,y,L):j(k,y))||L);return A>3&&L&&Object.defineProperty(k,y,L),L},d=this&&this.__param||function(w,k){return function(y,E){k(y,E,w)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const o=i(2223),p=i(643),g=i(511),S=i(2585),_=i(8055),n=i(4725),f=i(4269),h=i(6171),u=i(3734);let v=r.DomRendererRowFactory=class{constructor(w,k,y,E,j,A,L){this._document=w,this._characterJoinerService=k,this._optionsService=y,this._coreBrowserService=E,this._coreService=j,this._decorationService=A,this._themeService=L,this._workCell=new g.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(w,k,y){this._selectionStart=w,this._selectionEnd=k,this._columnSelectMode=y}createRow(w,k,y,E,j,A,L,N,B,I,H){const W=[],D=this._characterJoinerService.getJoinedCharacters(k),M=this._themeService.colors;let P,O=w.getNoBgTrimmedLength();y&&O<A+1&&(O=A+1);let U=0,X="",Y=0,Q=0,oe=0,T=!1,F=0,$=!1,z=0;const Z=[],q=I!==-1&&H!==-1;for(let ne=0;ne<O;ne++){w.loadCell(ne,this._workCell);let fe=this._workCell.getWidth();if(fe===0)continue;let ye=!1,Le=ne,J=this._workCell;if(D.length>0&&ne===D[0][0]){ye=!0;const be=D.shift();J=new f.JoinedCellData(this._workCell,w.translateToString(!0,be[0],be[1]),be[1]-be[0]),Le=be[1]-1,fe=J.getWidth()}const Fe=this._isCellInSelection(ne,k),Ke=y&&ne===A,Ne=q&&ne>=I&&ne<=H;let qe=!1;this._decorationService.forEachDecorationAtCell(ne,k,void 0,(be=>{qe=!0}));let Re=J.getChars()||p.WHITESPACE_CELL_CHAR;if(Re===" "&&(J.isUnderline()||J.isOverline())&&(Re=" "),z=fe*N-B.get(Re,J.isBold(),J.isItalic()),P){if(U&&(Fe&&$||!Fe&&!$&&J.bg===Y)&&(Fe&&$&&M.selectionForeground||J.fg===Q)&&J.extended.ext===oe&&Ne===T&&z===F&&!Ke&&!ye&&!qe){X+=Re,U++;continue}U&&(P.textContent=X),P=this._document.createElement("span"),U=0,X=""}else P=this._document.createElement("span");if(Y=J.bg,Q=J.fg,oe=J.extended.ext,T=Ne,F=z,$=Fe,ye&&A>=ne&&A<=Le&&(A=ne),!this._coreService.isCursorHidden&&Ke){if(Z.push("xterm-cursor"),this._coreBrowserService.isFocused)L&&Z.push("xterm-cursor-blink"),Z.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(j)switch(j){case"outline":Z.push("xterm-cursor-outline");break;case"block":Z.push("xterm-cursor-block");break;case"bar":Z.push("xterm-cursor-bar");break;case"underline":Z.push("xterm-cursor-underline")}}if(J.isBold()&&Z.push("xterm-bold"),J.isItalic()&&Z.push("xterm-italic"),J.isDim()&&Z.push("xterm-dim"),X=J.isInvisible()?p.WHITESPACE_CELL_CHAR:J.getChars()||p.WHITESPACE_CELL_CHAR,J.isUnderline()&&(Z.push(`xterm-underline-${J.extended.underlineStyle}`),X===" "&&(X=" "),!J.isUnderlineColorDefault()))if(J.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(J.getUnderlineColor()).join(",")})`;else{let be=J.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&J.isBold()&&be<8&&(be+=8),P.style.textDecorationColor=M.ansi[be].css}J.isOverline()&&(Z.push("xterm-overline"),X===" "&&(X=" ")),J.isStrikethrough()&&Z.push("xterm-strikethrough"),Ne&&(P.style.textDecoration="underline");let G=J.getFgColor(),ae=J.getFgColorMode(),ce=J.getBgColor(),se=J.getBgColorMode();const me=!!J.isInverse();if(me){const be=G;G=ce,ce=be;const tt=ae;ae=se,se=tt}let pe,Ce,Te,He=!1;switch(this._decorationService.forEachDecorationAtCell(ne,k,void 0,(be=>{be.options.layer!=="top"&&He||(be.backgroundColorRGB&&(se=50331648,ce=be.backgroundColorRGB.rgba>>8&16777215,pe=be.backgroundColorRGB),be.foregroundColorRGB&&(ae=50331648,G=be.foregroundColorRGB.rgba>>8&16777215,Ce=be.foregroundColorRGB),He=be.options.layer==="top")})),!He&&Fe&&(pe=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,ce=pe.rgba>>8&16777215,se=50331648,He=!0,M.selectionForeground&&(ae=50331648,G=M.selectionForeground.rgba>>8&16777215,Ce=M.selectionForeground)),He&&Z.push("xterm-decoration-top"),se){case 16777216:case 33554432:Te=M.ansi[ce],Z.push(`xterm-bg-${ce}`);break;case 50331648:Te=_.rgba.toColor(ce>>16,ce>>8&255,255&ce),this._addStyle(P,`background-color:#${x((ce>>>0).toString(16),"0",6)}`);break;default:me?(Te=M.foreground,Z.push(`xterm-bg-${o.INVERTED_DEFAULT_COLOR}`)):Te=M.background}switch(pe||J.isDim()&&(pe=_.color.multiplyOpacity(Te,.5)),ae){case 16777216:case 33554432:J.isBold()&&G<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(G+=8),this._applyMinimumContrast(P,Te,M.ansi[G],J,pe,void 0)||Z.push(`xterm-fg-${G}`);break;case 50331648:const be=_.rgba.toColor(G>>16&255,G>>8&255,255&G);this._applyMinimumContrast(P,Te,be,J,pe,Ce)||this._addStyle(P,`color:#${x(G.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Te,M.foreground,J,pe,void 0)||me&&Z.push(`xterm-fg-${o.INVERTED_DEFAULT_COLOR}`)}Z.length&&(P.className=Z.join(" "),Z.length=0),Ke||ye||qe?P.textContent=X:U++,z!==this.defaultSpacing&&(P.style.letterSpacing=`${z}px`),W.push(P),ne=Le}return P&&U&&(P.textContent=X),W}_applyMinimumContrast(w,k,y,E,j,A){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,h.excludeFromContrastRatioDemands)(E.getCode()))return!1;const L=this._getContrastCache(E);let N;if(j||A||(N=L.getColor(k.rgba,y.rgba)),N===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);N=_.color.ensureContrastRatio(j||k,A||y,B),L.setColor((j||k).rgba,(A||y).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,k){w.setAttribute("style",`${w.getAttribute("style")||""}${k};`)}_isCellInSelection(w,k){const y=this._selectionStart,E=this._selectionEnd;return!(!y||!E)&&(this._columnSelectMode?y[0]<=E[0]?w>=y[0]&&k>=y[1]&&w<E[0]&&k<=E[1]:w<y[0]&&k>=y[1]&&w>=E[0]&&k<=E[1]:k>y[1]&&k<E[1]||y[1]===E[1]&&k===y[1]&&w>=y[0]&&w<E[0]||y[1]<E[1]&&k===E[1]&&w<E[0]||y[1]<E[1]&&k===y[1]&&w>=y[0])}};function x(w,k,y){for(;w.length<y;)w=k+w;return w}r.DomRendererRowFactory=v=c([d(1,n.ICharacterJoinerService),d(2,S.IOptionsService),d(3,n.ICoreBrowserService),d(4,S.ICoreService),d(5,S.IDecorationService),d(6,n.IThemeService)],v)},2550:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const c=i.createElement("span"),d=i.createElement("span");d.style.fontWeight="bold";const o=i.createElement("span");o.style.fontStyle="italic";const p=i.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[c,d,o,p],this._container.appendChild(c),this._container.appendChild(d),this._container.appendChild(o),this._container.appendChild(p),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,c,d,o){i===this._font&&c===this._fontSize&&d===this._weight&&o===this._weightBold||(this._font=i,this._fontSize=c,this._weight=d,this._weightBold=o,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${o}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${o}`,this.clear())}get(i,c,d){let o=0;if(!c&&!d&&i.length===1&&(o=i.charCodeAt(0))<256)return this._flat[o]!==-9999?this._flat[o]:this._flat[o]=this._measure(i,0);let p=i;c&&(p+="B"),d&&(p+="I");let g=this._holey.get(p);if(g===void 0){let S=0;c&&(S|=1),d&&(S|=2),g=this._measure(i,S),this._holey.set(p,g)}return g}_measure(i,c){const d=this._measureElements[c];return d.textContent=i.repeat(32),d.offsetWidth/32}}},2223:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const c=i(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(C,r)=>{function i(c){return 57508<=c&&c<=57558}Object.defineProperty(r,"__esModule",{value:!0}),r.createRenderDimensions=r.excludeFromContrastRatioDemands=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},r.isPowerlineGlyph=i,r.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},r.excludeFromContrastRatioDemands=function(c){return i(c)||(function(d){return 9472<=d&&d<=9631})(c)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,c=this.selectionEnd;return!(!i||!c)&&(i[1]>c[1]||i[1]===c[1]&&i[0]>c[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(C,r,i){var c=this&&this.__decorate||function(n,f,h,u){var v,x=arguments.length,w=x<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(x<3?v(w):x>3?v(f,h,w):v(f,h))||w);return x>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const o=i(2585),p=i(8460),g=i(844);let S=r.CharSizeService=class extends g.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,f,h){super(),this._optionsService=h,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new _(n,f,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};r.CharSizeService=S=c([d(2,o.IOptionsService)],S);class _{constructor(f,h,u){this._document=f,this._parentElement=h,this._optionsService=u,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const f={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return f.width!==0&&f.height!==0&&(this._result.width=f.width/32,this._result.height=Math.ceil(f.height)),this._result}}},4269:function(C,r,i){var c=this&&this.__decorate||function(f,h,u,v){var x,w=arguments.length,k=w<3?h:v===null?v=Object.getOwnPropertyDescriptor(h,u):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(f,h,u,v);else for(var y=f.length-1;y>=0;y--)(x=f[y])&&(k=(w<3?x(k):w>3?x(h,u,k):x(h,u))||k);return w>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(f,h){return function(u,v){h(u,v,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const o=i(3734),p=i(643),g=i(511),S=i(2585);class _ extends o.AttributeData{constructor(h,u,v){super(),this.content=0,this.combinedData="",this.fg=h.fg,this.bg=h.bg,this.combinedData=u,this._width=v}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(h){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.JoinedCellData=_;let n=r.CharacterJoinerService=class Dn{constructor(h){this._bufferService=h,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new g.CellData}register(h){const u={id:this._nextCharacterJoinerId++,handler:h};return this._characterJoiners.push(u),u.id}deregister(h){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===h)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(h){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(h);if(!u||u.length===0)return[];const v=[],x=u.translateToString(!0);let w=0,k=0,y=0,E=u.getFg(0),j=u.getBg(0);for(let A=0;A<u.getTrimmedLength();A++)if(u.loadCell(A,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==j){if(A-w>1){const L=this._getJoinedRanges(x,y,k,u,w);for(let N=0;N<L.length;N++)v.push(L[N])}w=A,y=k,E=this._workCell.fg,j=this._workCell.bg}k+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-w>1){const A=this._getJoinedRanges(x,y,k,u,w);for(let L=0;L<A.length;L++)v.push(A[L])}return v}_getJoinedRanges(h,u,v,x,w){const k=h.substring(u,v);let y=[];try{y=this._characterJoiners[0].handler(k)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const j=this._characterJoiners[E].handler(k);for(let A=0;A<j.length;A++)Dn._mergeRanges(y,j[A])}catch(j){console.error(j)}return this._stringRangesToCellRanges(y,x,w),y}_stringRangesToCellRanges(h,u,v){let x=0,w=!1,k=0,y=h[x];if(y){for(let E=v;E<this._bufferService.cols;E++){const j=u.getWidth(E),A=u.getString(E).length||p.WHITESPACE_CELL_CHAR.length;if(j!==0){if(!w&&y[0]<=k&&(y[0]=E,w=!0),y[1]<=k){if(y[1]=E,y=h[++x],!y)break;y[0]<=k?(y[0]=E,w=!0):w=!1}k+=A}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(h,u){let v=!1;for(let x=0;x<h.length;x++){const w=h[x];if(v){if(u[1]<=w[0])return h[x-1][1]=u[1],h;if(u[1]<=w[1])return h[x-1][1]=Math.max(u[1],w[1]),h.splice(x,1),h;h.splice(x,1),x--}else{if(u[1]<=w[0])return h.splice(x,0,u),h;if(u[1]<=w[1])return w[0]=Math.min(u[0],w[0]),h;u[0]<w[1]&&(w[0]=Math.min(u[0],w[0]),v=!0)}}return v?h[h.length-1][1]=u[1]:h.push(u),h}};r.CharacterJoinerService=n=c([d(0,S.IBufferService)],n)},5114:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(i,c){this._textarea=i,this.window=c,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(C,r,i){var c=this&&this.__decorate||function(S,_,n,f){var h,u=arguments.length,v=u<3?_:f===null?f=Object.getOwnPropertyDescriptor(_,n):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(S,_,n,f);else for(var x=S.length-1;x>=0;x--)(h=S[x])&&(v=(u<3?h(v):u>3?h(_,n,v):h(_,n))||v);return u>3&&v&&Object.defineProperty(_,n,v),v},d=this&&this.__param||function(S,_){return function(n,f){_(n,f,S)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const o=i(4725),p=i(9806);let g=r.MouseService=class{constructor(S,_){this._renderService=S,this._charSizeService=_}getCoords(S,_,n,f,h){return(0,p.getCoords)(window,S,_,n,f,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,h)}getMouseReportCoords(S,_){const n=(0,p.getCoordsRelativeToElement)(window,S,_);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};r.MouseService=g=c([d(0,o.IRenderService),d(1,o.ICharSizeService)],g)},3230:function(C,r,i){var c=this&&this.__decorate||function(v,x,w,k){var y,E=arguments.length,j=E<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(v,x,w,k);else for(var A=v.length-1;A>=0;A--)(y=v[A])&&(j=(E<3?y(j):E>3?y(x,w,j):y(x,w))||j);return E>3&&j&&Object.defineProperty(x,w,j),j},d=this&&this.__param||function(v,x){return function(w,k){x(w,k,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const o=i(3656),p=i(6193),g=i(5596),S=i(4725),_=i(8460),n=i(844),f=i(7226),h=i(2585);let u=r.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,x,w,k,y,E,j,A){if(super(),this._rowCount=v,this._charSizeService=k,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new f.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new _.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(j.window,((L,N)=>this._renderRows(L,N))),this.register(this._renderDebouncer),this._screenDprMonitor=new g.ScreenDprMonitor(j.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var L;return(L=this._renderer.value)===null||L===void 0?void 0:L.clear()}))),this.register(w.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(y.onDecorationRegistered((()=>this._fullRefresh()))),this.register(y.onDecorationRemoved((()=>this._fullRefresh()))),this.register(w.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(w.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,o.addDisposableDomListener)(j.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(A.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in j.window){const L=new j.window.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});L.observe(x),this.register({dispose:()=>L.disconnect()})}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.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(v,x,w=!1){this._isPaused?this._needsFullRefresh=!0:(w||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,x,this._rowCount))}_renderRows(v,x){this._renderer.value&&(v=Math.min(v,this._rowCount-1),x=Math.min(x,this._rowCount-1),this._renderer.value.renderRows(v,x),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:v,end:x}),this._onRender.fire({start:v,end:x}),this._isNextRenderRedrawOnly=!0)}resize(v,x){this._rowCount=x,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(v){this._renderer.value=v,this._renderer.value.onRequestRedraw((x=>this.refreshRows(x.start,x.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var v,x;this._renderer.value&&((x=(v=this._renderer.value).clearTextureAtlas)===null||x===void 0||x.call(v),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(v,x){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(v,x))):this._renderer.value.handleResize(v,x),this._fullRefresh())}handleCharSizeChanged(){var v;(v=this._renderer.value)===null||v===void 0||v.handleCharSizeChanged()}handleBlur(){var v;(v=this._renderer.value)===null||v===void 0||v.handleBlur()}handleFocus(){var v;(v=this._renderer.value)===null||v===void 0||v.handleFocus()}handleSelectionChanged(v,x,w){var k;this._selectionState.start=v,this._selectionState.end=x,this._selectionState.columnSelectMode=w,(k=this._renderer.value)===null||k===void 0||k.handleSelectionChanged(v,x,w)}handleCursorMove(){var v;(v=this._renderer.value)===null||v===void 0||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)===null||v===void 0||v.clear()}};r.RenderService=u=c([d(2,h.IOptionsService),d(3,S.ICharSizeService),d(4,h.IDecorationService),d(5,h.IBufferService),d(6,S.ICoreBrowserService),d(7,S.IThemeService)],u)},9312:function(C,r,i){var c=this&&this.__decorate||function(y,E,j,A){var L,N=arguments.length,B=N<3?E:A===null?A=Object.getOwnPropertyDescriptor(E,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(y,E,j,A);else for(var I=y.length-1;I>=0;I--)(L=y[I])&&(B=(N<3?L(B):N>3?L(E,j,B):L(E,j))||B);return N>3&&B&&Object.defineProperty(E,j,B),B},d=this&&this.__param||function(y,E){return function(j,A){E(j,A,y)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const o=i(9806),p=i(9504),g=i(456),S=i(4725),_=i(8460),n=i(844),f=i(6114),h=i(4841),u=i(511),v=i(2585),x=" ",w=new RegExp(x,"g");let k=r.SelectionService=class extends n.Disposable{constructor(y,E,j,A,L,N,B,I,H){super(),this._element=y,this._screenElement=E,this._linkifier=j,this._bufferService=A,this._coreService=L,this._mouseService=N,this._optionsService=B,this._renderService=I,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.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 g.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,n.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!y||!E||y[0]===E[0]&&y[1]===E[1])}get selectionText(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!y||!E)return"";const j=this._bufferService.buffer,A=[];if(this._activeSelectionMode===3){if(y[0]===E[0])return"";const L=y[0]<E[0]?y[0]:E[0],N=y[0]<E[0]?E[0]:y[0];for(let B=y[1];B<=E[1];B++){const I=j.translateBufferLineToString(B,!0,L,N);A.push(I)}}else{const L=y[1]===E[1]?E[0]:void 0;A.push(j.translateBufferLineToString(y[1],!0,y[0],L));for(let N=y[1]+1;N<=E[1]-1;N++){const B=j.lines.get(N),I=j.translateBufferLineToString(N,!0);B?.isWrapped?A[A.length-1]+=I:A.push(I)}if(y[1]!==E[1]){const N=j.lines.get(E[1]),B=j.translateBufferLineToString(E[1],!0,0,E[0]);N&&N.isWrapped?A[A.length-1]+=B:A.push(B)}}return A.map((L=>L.replace(w," "))).join(f.isWindows?`\r
16
- `:`
17
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(y){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),f.isLinux&&y&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(y){const E=this._getMouseBufferCoords(y),j=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!!(j&&A&&E)&&this._areCoordsInSelection(E,j,A)}isCellInSelection(y,E){const j=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!(!j||!A)&&this._areCoordsInSelection([y,E],j,A)}_areCoordsInSelection(y,E,j){return y[1]>E[1]&&y[1]<j[1]||E[1]===j[1]&&y[1]===E[1]&&y[0]>=E[0]&&y[0]<j[0]||E[1]<j[1]&&y[1]===j[1]&&y[0]<j[0]||E[1]<j[1]&&y[1]===E[1]&&y[0]>=E[0]}_selectWordAtCursor(y,E){var j,A;const L=(A=(j=this._linkifier.currentLink)===null||j===void 0?void 0:j.link)===null||A===void 0?void 0:A.range;if(L)return this._model.selectionStart=[L.start.x-1,L.start.y-1],this._model.selectionStartLength=(0,h.getRangeLength)(L,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const N=this._getMouseBufferCoords(y);return!!N&&(this._selectWordAt(N,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,E){this._model.clearSelection(),y=Math.max(y,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const E=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(y){let E=(0,o.getCoordsRelativeToElement)(this._coreBrowserService.window,y,this._screenElement)[1];const j=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=j?0:(E>j&&(E-=j),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(y){return f.isMac?y.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:y.shiftKey}handleMouseDown(y){if(this._mouseDownTimeStamp=y.timeStamp,(y.button!==2||!this.hasSelection)&&y.button===0){if(!this._enabled){if(!this.shouldForceSelection(y))return;y.stopPropagation()}y.preventDefault(),this._dragScrollAmount=0,this._enabled&&y.shiftKey?this._handleIncrementalClick(y):y.detail===1?this._handleSingleClick(y):y.detail===2?this._handleDoubleClick(y):y.detail===3&&this._handleTripleClick(y),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(y){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(y))}_handleSingleClick(y){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(y)?3:0,this._model.selectionStart=this._getMouseBufferCoords(y),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const E=this._getMouseBufferCoords(y);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(y){return y.altKey&&!(f.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(y),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(y),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const j=this._bufferService.buffer;if(this._model.selectionEnd[1]<j.lines.length){const A=j.lines.get(this._model.selectionEnd[1]);A&&A.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}E&&E[0]===this._model.selectionEnd[0]&&E[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const y=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(y.ydisp+this._bufferService.rows,y.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=y.ydisp),this.refresh()}}_handleMouseUp(y){const E=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const j=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(j&&j[0]!==void 0&&j[1]!==void 0){const A=(0,p.moveToCellSequence)(j[0]-1,j[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(A,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,j=!(!y||!E||y[0]===E[0]&&y[1]===E[1]);j?y&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,E,j)):this._oldHasSelection&&this._fireOnSelectionChange(y,E,j)}_fireOnSelectionChange(y,E,j){this._oldSelectionStart=y,this._oldSelectionEnd=E,this._oldHasSelection=j,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(y,E){let j=E;for(let A=0;E>=A;A++){const L=y.loadCell(A,this._workCell).getChars().length;this._workCell.getWidth()===0?j--:L>1&&E!==A&&(j+=L-1)}return j}setSelection(y,E,j){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,E],this._model.selectionStartLength=j,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,E,j=!0,A=!0){if(y[0]>=this._bufferService.cols)return;const L=this._bufferService.buffer,N=L.lines.get(y[1]);if(!N)return;const B=L.translateBufferLineToString(y[1],!1);let I=this._convertViewportColToCharacterIndex(N,y[0]),H=I;const W=y[0]-I;let D=0,M=0,P=0,O=0;if(B.charAt(I)===" "){for(;I>0&&B.charAt(I-1)===" ";)I--;for(;H<B.length&&B.charAt(H+1)===" ";)H++}else{let Y=y[0],Q=y[0];N.getWidth(Y)===0&&(D++,Y--),N.getWidth(Q)===2&&(M++,Q++);const oe=N.getString(Q).length;for(oe>1&&(O+=oe-1,H+=oe-1);Y>0&&I>0&&!this._isCharWordSeparator(N.loadCell(Y-1,this._workCell));){N.loadCell(Y-1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===0?(D++,Y--):T>1&&(P+=T-1,I-=T-1),I--,Y--}for(;Q<N.length&&H+1<B.length&&!this._isCharWordSeparator(N.loadCell(Q+1,this._workCell));){N.loadCell(Q+1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,Q++):T>1&&(O+=T-1,H+=T-1),H++,Q++}}H++;let U=I+W-D+P,X=Math.min(this._bufferService.cols,H-I+D+M-P-O);if(E||B.slice(I,H).trim()!==""){if(j&&U===0&&N.getCodePoint(0)!==32){const Y=L.lines.get(y[1]-1);if(Y&&N.isWrapped&&Y.getCodePoint(this._bufferService.cols-1)!==32){const Q=this._getWordAt([this._bufferService.cols-1,y[1]-1],!1,!0,!1);if(Q){const oe=this._bufferService.cols-Q.start;U-=oe,X+=oe}}}if(A&&U+X===this._bufferService.cols&&N.getCodePoint(this._bufferService.cols-1)!==32){const Y=L.lines.get(y[1]+1);if(Y?.isWrapped&&Y.getCodePoint(0)!==32){const Q=this._getWordAt([0,y[1]+1],!1,!1,!0);Q&&(X+=Q.length)}}return{start:U,length:X}}}_selectWordAt(y,E){const j=this._getWordAt(y,E);if(j){for(;j.start<0;)j.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[j.start,y[1]],this._model.selectionStartLength=j.length}}_selectToWordAt(y){const E=this._getWordAt(y,!0);if(E){let j=y[1];for(;E.start<0;)E.start+=this._bufferService.cols,j--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,j++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,j]}}_isCharWordSeparator(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}_selectLineAt(y){const E=this._bufferService.buffer.getWrappedRangeForLine(y),j={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,h.getRangeLength)(j,this._bufferService.cols)}};r.SelectionService=k=c([d(3,v.IBufferService),d(4,v.ICoreService),d(5,S.IMouseService),d(6,v.IOptionsService),d(7,S.IRenderService),d(8,S.ICoreBrowserService)],k)},4725:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const c=i(8343);r.ICharSizeService=(0,c.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),r.IMouseService=(0,c.createDecorator)("MouseService"),r.IRenderService=(0,c.createDecorator)("RenderService"),r.ISelectionService=(0,c.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(C,r,i){var c=this&&this.__decorate||function(k,y,E,j){var A,L=arguments.length,N=L<3?y:j===null?j=Object.getOwnPropertyDescriptor(y,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(k,y,E,j);else for(var B=k.length-1;B>=0;B--)(A=k[B])&&(N=(L<3?A(N):L>3?A(y,E,N):A(y,E))||N);return L>3&&N&&Object.defineProperty(y,E,N),N},d=this&&this.__param||function(k,y){return function(E,j){y(E,j,k)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const o=i(7239),p=i(8055),g=i(8460),S=i(844),_=i(2585),n=p.css.toColor("#ffffff"),f=p.css.toColor("#000000"),h=p.css.toColor("#ffffff"),u=p.css.toColor("#000000"),v={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const k=[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")],y=[0,95,135,175,215,255];for(let E=0;E<216;E++){const j=y[E/36%6|0],A=y[E/6%6|0],L=y[E%6];k.push({css:p.channels.toCss(j,A,L),rgba:p.channels.toRgba(j,A,L)})}for(let E=0;E<24;E++){const j=8+10*E;k.push({css:p.channels.toCss(j,j,j),rgba:p.channels.toRgba(j,j,j)})}return k})());let x=r.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(k){super(),this._optionsService=k,this._contrastCache=new o.ColorContrastCache,this._halfContrastCache=new o.ColorContrastCache,this._onChangeColors=this.register(new g.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:f,cursor:h,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:v,selectionBackgroundOpaque:p.color.blend(f,v),selectionInactiveBackgroundTransparent:v,selectionInactiveBackgroundOpaque:p.color.blend(f,v),ansi:r.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(k={}){const y=this._colors;if(y.foreground=w(k.foreground,n),y.background=w(k.background,f),y.cursor=w(k.cursor,h),y.cursorAccent=w(k.cursorAccent,u),y.selectionBackgroundTransparent=w(k.selectionBackground,v),y.selectionBackgroundOpaque=p.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=w(k.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=p.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=k.selectionForeground?w(k.selectionForeground,p.NULL_COLOR):void 0,y.selectionForeground===p.NULL_COLOR&&(y.selectionForeground=void 0),p.color.isOpaque(y.selectionBackgroundTransparent)&&(y.selectionBackgroundTransparent=p.color.opacity(y.selectionBackgroundTransparent,.3)),p.color.isOpaque(y.selectionInactiveBackgroundTransparent)&&(y.selectionInactiveBackgroundTransparent=p.color.opacity(y.selectionInactiveBackgroundTransparent,.3)),y.ansi=r.DEFAULT_ANSI_COLORS.slice(),y.ansi[0]=w(k.black,r.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=w(k.red,r.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=w(k.green,r.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=w(k.yellow,r.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=w(k.blue,r.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=w(k.magenta,r.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=w(k.cyan,r.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=w(k.white,r.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=w(k.brightBlack,r.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=w(k.brightRed,r.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=w(k.brightGreen,r.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=w(k.brightYellow,r.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=w(k.brightBlue,r.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=w(k.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=w(k.brightCyan,r.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=w(k.brightWhite,r.DEFAULT_ANSI_COLORS[15]),k.extendedAnsi){const E=Math.min(y.ansi.length-16,k.extendedAnsi.length);for(let j=0;j<E;j++)y.ansi[j+16]=w(k.extendedAnsi[j],r.DEFAULT_ANSI_COLORS[j+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(k){this._restoreColor(k),this._onChangeColors.fire(this.colors)}_restoreColor(k){if(k!==void 0)switch(k){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[k]=this._restoreColors.ansi[k]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(k){k(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(k,y){if(k!==void 0)try{return p.css.toColor(k)}catch{}return y}r.ThemeService=x=c([d(0,_.IOptionsService)],x)},6349:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const c=i(8460),d=i(844);class o extends d.Disposable{constructor(g){super(),this._maxLength=g,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(g){if(this._maxLength===g)return;const S=new Array(g);for(let _=0;_<Math.min(g,this.length);_++)S[_]=this._array[this._getCyclicIndex(_)];this._array=S,this._maxLength=g,this._startIndex=0}get length(){return this._length}set length(g){if(g>this._length)for(let S=this._length;S<g;S++)this._array[S]=void 0;this._length=g}get(g){return this._array[this._getCyclicIndex(g)]}set(g,S){this._array[this._getCyclicIndex(g)]=S}push(g){this._array[this._getCyclicIndex(this._length)]=g,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(g,S,..._){if(S){for(let n=g;n<this._length-S;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+S)];this._length-=S,this.onDeleteEmitter.fire({index:g,amount:S})}for(let n=this._length-1;n>=g;n--)this._array[this._getCyclicIndex(n+_.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<_.length;n++)this._array[this._getCyclicIndex(g+n)]=_[n];if(_.length&&this.onInsertEmitter.fire({index:g,amount:_.length}),this._length+_.length>this._maxLength){const n=this._length+_.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=_.length}trimStart(g){g>this._length&&(g=this._length),this._startIndex+=g,this._length-=g,this.onTrimEmitter.fire(g)}shiftElements(g,S,_){if(!(S<=0)){if(g<0||g>=this._length)throw new Error("start argument out of range");if(g+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let f=S-1;f>=0;f--)this.set(g+f+_,this.get(g+f));const n=g+S+_-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<S;n++)this.set(g+n+_,this.get(g+n))}}_getCyclicIndex(g){return(this._startIndex+g)%this._maxLength}}r.CircularList=o},1439:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function i(c,d=5){if(typeof c!="object")return c;const o=Array.isArray(c)?[]:{};for(const p in c)o[p]=d<=1?c[p]:c[p]&&i(c[p],d-1);return o}},8055:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;const c=i(6114);let d=0,o=0,p=0,g=0;var S,_,n,f,h;function u(x){const w=x.toString(16);return w.length<2?"0"+w:w}function v(x,w){return x<w?(w+.05)/(x+.05):(x+.05)/(w+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(x){x.toCss=function(w,k,y,E){return E!==void 0?`#${u(w)}${u(k)}${u(y)}${u(E)}`:`#${u(w)}${u(k)}${u(y)}`},x.toRgba=function(w,k,y,E=255){return(w<<24|k<<16|y<<8|E)>>>0}})(S||(r.channels=S={})),(function(x){function w(k,y){return g=Math.round(255*y),[d,o,p]=h.toChannels(k.rgba),{css:S.toCss(d,o,p,g),rgba:S.toRgba(d,o,p,g)}}x.blend=function(k,y){if(g=(255&y.rgba)/255,g===1)return{css:y.css,rgba:y.rgba};const E=y.rgba>>24&255,j=y.rgba>>16&255,A=y.rgba>>8&255,L=k.rgba>>24&255,N=k.rgba>>16&255,B=k.rgba>>8&255;return d=L+Math.round((E-L)*g),o=N+Math.round((j-N)*g),p=B+Math.round((A-B)*g),{css:S.toCss(d,o,p),rgba:S.toRgba(d,o,p)}},x.isOpaque=function(k){return(255&k.rgba)==255},x.ensureContrastRatio=function(k,y,E){const j=h.ensureContrastRatio(k.rgba,y.rgba,E);if(j)return h.toColor(j>>24&255,j>>16&255,j>>8&255)},x.opaque=function(k){const y=(255|k.rgba)>>>0;return[d,o,p]=h.toChannels(y),{css:S.toCss(d,o,p),rgba:y}},x.opacity=w,x.multiplyOpacity=function(k,y){return g=255&k.rgba,w(k,g*y/255)},x.toColorRGB=function(k){return[k.rgba>>24&255,k.rgba>>16&255,k.rgba>>8&255]}})(_||(r.color=_={})),(function(x){let w,k;if(!c.isNode){const y=document.createElement("canvas");y.width=1,y.height=1;const E=y.getContext("2d",{willReadFrequently:!0});E&&(w=E,w.globalCompositeOperation="copy",k=w.createLinearGradient(0,0,1,1))}x.toColor=function(y){if(y.match(/#[\da-f]{3,8}/i))switch(y.length){case 4:return d=parseInt(y.slice(1,2).repeat(2),16),o=parseInt(y.slice(2,3).repeat(2),16),p=parseInt(y.slice(3,4).repeat(2),16),h.toColor(d,o,p);case 5:return d=parseInt(y.slice(1,2).repeat(2),16),o=parseInt(y.slice(2,3).repeat(2),16),p=parseInt(y.slice(3,4).repeat(2),16),g=parseInt(y.slice(4,5).repeat(2),16),h.toColor(d,o,p,g);case 7:return{css:y,rgba:(parseInt(y.slice(1),16)<<8|255)>>>0};case 9:return{css:y,rgba:parseInt(y.slice(1),16)>>>0}}const E=y.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return d=parseInt(E[1]),o=parseInt(E[2]),p=parseInt(E[3]),g=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),h.toColor(d,o,p,g);if(!w||!k)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=k,w.fillStyle=y,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[d,o,p,g]=w.getImageData(0,0,1,1).data,g!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(d,o,p,g),css:y}}})(n||(r.css=n={})),(function(x){function w(k,y,E){const j=k/255,A=y/255,L=E/255;return .2126*(j<=.03928?j/12.92:Math.pow((j+.055)/1.055,2.4))+.7152*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}x.relativeLuminance=function(k){return w(k>>16&255,k>>8&255,255&k)},x.relativeLuminance2=w})(f||(r.rgb=f={})),(function(x){function w(y,E,j){const A=y>>24&255,L=y>>16&255,N=y>>8&255;let B=E>>24&255,I=E>>16&255,H=E>>8&255,W=v(f.relativeLuminance2(B,I,H),f.relativeLuminance2(A,L,N));for(;W<j&&(B>0||I>0||H>0);)B-=Math.max(0,Math.ceil(.1*B)),I-=Math.max(0,Math.ceil(.1*I)),H-=Math.max(0,Math.ceil(.1*H)),W=v(f.relativeLuminance2(B,I,H),f.relativeLuminance2(A,L,N));return(B<<24|I<<16|H<<8|255)>>>0}function k(y,E,j){const A=y>>24&255,L=y>>16&255,N=y>>8&255;let B=E>>24&255,I=E>>16&255,H=E>>8&255,W=v(f.relativeLuminance2(B,I,H),f.relativeLuminance2(A,L,N));for(;W<j&&(B<255||I<255||H<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),I=Math.min(255,I+Math.ceil(.1*(255-I))),H=Math.min(255,H+Math.ceil(.1*(255-H))),W=v(f.relativeLuminance2(B,I,H),f.relativeLuminance2(A,L,N));return(B<<24|I<<16|H<<8|255)>>>0}x.ensureContrastRatio=function(y,E,j){const A=f.relativeLuminance(y>>8),L=f.relativeLuminance(E>>8);if(v(A,L)<j){if(L<A){const I=w(y,E,j),H=v(A,f.relativeLuminance(I>>8));if(H<j){const W=k(y,E,j);return H>v(A,f.relativeLuminance(W>>8))?I:W}return I}const N=k(y,E,j),B=v(A,f.relativeLuminance(N>>8));if(B<j){const I=w(y,E,j);return B>v(A,f.relativeLuminance(I>>8))?N:I}return N}},x.reduceLuminance=w,x.increaseLuminance=k,x.toChannels=function(y){return[y>>24&255,y>>16&255,y>>8&255,255&y]},x.toColor=function(y,E,j,A){return{css:S.toCss(y,E,j,A),rgba:S.toRgba(y,E,j,A)}}})(h||(r.rgba=h={})),r.toPaddedHex=u,r.contrastRatio=v},8969:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const c=i(844),d=i(2585),o=i(4348),p=i(7866),g=i(744),S=i(7302),_=i(6975),n=i(8460),f=i(1753),h=i(1480),u=i(7994),v=i(9282),x=i(5435),w=i(5981),k=i(2660);let y=!1;class E extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((A=>{var L;(L=this._onScrollApi)===null||L===void 0||L.fire(A.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(A){for(const L in A)this.optionsService.options[L]=A[L]}constructor(A){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new o.InstantiationService,this.optionsService=this.register(new S.OptionsService(A)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(g.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(f.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(h.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(k.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new x.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((L=>{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((L=>{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(((L,N)=>this._inputHandler.parse(L,N)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(A,L){this._writeBuffer.write(A,L)}writeSync(A,L){this._logService.logLevel<=d.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(A,L)}resize(A,L){isNaN(A)||isNaN(L)||(A=Math.max(A,g.MINIMUM_COLS),L=Math.max(L,g.MINIMUM_ROWS),this._bufferService.resize(A,L))}scroll(A,L=!1){this._bufferService.scroll(A,L)}scrollLines(A,L,N){this._bufferService.scrollLines(A,L,N)}scrollPages(A){this.scrollLines(A*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(A){const L=A-this._bufferService.buffer.ydisp;L!==0&&this.scrollLines(L)}registerEscHandler(A,L){return this._inputHandler.registerEscHandler(A,L)}registerDcsHandler(A,L){return this._inputHandler.registerDcsHandler(A,L)}registerCsiHandler(A,L){return this._inputHandler.registerCsiHandler(A,L)}registerOscHandler(A,L){return this._inputHandler.registerOscHandler(A,L)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let A=!1;const L=this.optionsService.rawOptions.windowsPty;L&&L.buildNumber!==void 0&&L.buildNumber!==void 0?A=L.backend==="conpty"&&L.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(A=!0),A?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const A=[];A.push(this.onLineFeed(v.updateWindowsModeWrappedState.bind(null,this._bufferService))),A.push(this.registerCsiHandler({final:"H"},(()=>((0,v.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const L of A)L.dispose()}))}}}r.CoreTerminal=E},8460:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===i)return void this._listeners.splice(c,1)}}})),this._event}fire(i,c){const d=[];for(let o=0;o<this._listeners.length;o++)d.push(this._listeners[o]);for(let o=0;o<d.length;o++)d[o].call(void 0,i,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(i,c){return i((d=>c.fire(d)))}},5435:function(C,r,i){var c=this&&this.__decorate||function(W,D,M,P){var O,U=arguments.length,X=U<3?D:P===null?P=Object.getOwnPropertyDescriptor(D,M):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(W,D,M,P);else for(var Y=W.length-1;Y>=0;Y--)(O=W[Y])&&(X=(U<3?O(X):U>3?O(D,M,X):O(D,M))||X);return U>3&&X&&Object.defineProperty(D,M,X),X},d=this&&this.__param||function(W,D){return function(M,P){D(M,P,W)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const o=i(2584),p=i(7116),g=i(2015),S=i(844),_=i(482),n=i(8437),f=i(8460),h=i(643),u=i(511),v=i(3734),x=i(2585),w=i(6242),k=i(6351),y=i(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},j=131072;function A(W,D){if(W>24)return D.setWinLines||!1;switch(W){case 1:return!!D.restoreWin;case 2:return!!D.minimizeWin;case 3:return!!D.setWinPosition;case 4:return!!D.setWinSizePixels;case 5:return!!D.raiseWin;case 6:return!!D.lowerWin;case 7:return!!D.refreshWin;case 8:return!!D.setWinSizeChars;case 9:return!!D.maximizeWin;case 10:return!!D.fullscreenWin;case 11:return!!D.getWinState;case 13:return!!D.getWinPosition;case 14:return!!D.getWinSizePixels;case 15:return!!D.getScreenSizePixels;case 16:return!!D.getCellSizePixels;case 18:return!!D.getWinSizeChars;case 19:return!!D.getScreenSizeChars;case 20:return!!D.getIconTitle;case 21:return!!D.getWinTitle;case 22:return!!D.pushTitle;case 23:return!!D.popTitle;case 24:return!!D.setWinLines}return!1}var L;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(L||(r.WindowsOptionsReportType=L={}));let N=0;class B extends S.Disposable{getAttrData(){return this._curAttrData}constructor(D,M,P,O,U,X,Y,Q,oe=new g.EscapeSequenceParser){super(),this._bufferService=D,this._charsetService=M,this._coreService=P,this._logService=O,this._optionsService=U,this._oscLinkService=X,this._coreMouseService=Y,this._unicodeService=Q,this._parser=oe,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new f.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new f.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new f.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new f.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new f.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new f.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new f.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new f.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new f.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new f.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new f.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new f.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((T=>this._activeBuffer=T.activeBuffer))),this._parser.setCsiHandlerFallback(((T,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(T),params:F.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,F,$)=>{this._logService.debug("Unknown OSC code: ",{identifier:T,action:F,data:$})})),this._parser.setDcsHandlerFallback(((T,F,$)=>{F==="HOOK"&&($=$.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(T),action:F,payload:$})})),this._parser.setPrintHandler(((T,F,$)=>this.print(T,F,$))),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(o.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(o.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(o.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(o.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(o.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(o.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(o.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(o.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(o.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new w.OscHandler((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 k.DcsHandler(((T,F)=>this.requestStatusString(T,F))))}_preserveStack(D,M,P,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=D,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=P,this._parseStack.position=O}_logSlowResolvingAsync(D){this._logService.logLevel<=x.LogLevelEnum.WARN&&Promise.race([D,new Promise(((M,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(D,M){let P,O=this._activeBuffer.x,U=this._activeBuffer.y,X=0;const Y=this._parseStack.paused;if(Y){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(P),P;O=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,D.length>j&&(X=this._parseStack.position+j)}if(this._logService.logLevel<=x.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof D=="string"?` "${D}"`:` "${Array.prototype.map.call(D,(Q=>String.fromCharCode(Q))).join("")}"`),typeof D=="string"?D.split("").map((Q=>Q.charCodeAt(0))):D),this._parseBuffer.length<D.length&&this._parseBuffer.length<j&&(this._parseBuffer=new Uint32Array(Math.min(D.length,j))),Y||this._dirtyRowTracker.clearRange(),D.length>j)for(let Q=X;Q<D.length;Q+=j){const oe=Q+j<D.length?Q+j:D.length,T=typeof D=="string"?this._stringDecoder.decode(D.substring(Q,oe),this._parseBuffer):this._utf8Decoder.decode(D.subarray(Q,oe),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,T))return this._preserveStack(O,U,T,Q),this._logSlowResolvingAsync(P),P}else if(!Y){const Q=typeof D=="string"?this._stringDecoder.decode(D,this._parseBuffer):this._utf8Decoder.decode(D,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,Q))return this._preserveStack(O,U,Q,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===O&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(D,M,P){let O,U;const X=this._charsetService.charset,Y=this._optionsService.rawOptions.screenReaderMode,Q=this._bufferService.cols,oe=this._coreService.decPrivateModes.wraparound,T=this._coreService.modes.insertMode,F=this._curAttrData;let $=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-M>0&&$.getWidth(this._activeBuffer.x-1)===2&&$.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let z=M;z<P;++z){if(O=D[z],U=this._unicodeService.wcwidth(O),O<127&&X){const Z=X[String.fromCharCode(O)];Z&&(O=Z.charCodeAt(0))}if(Y&&this._onA11yChar.fire((0,_.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=Q){if(oe){for(;this._activeBuffer.x<Q;)$.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),$=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Q-1,U===2)continue}if(T&&($.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(F),F),$.getWidth(Q-1)===2&&$.setCellFromCodePoint(Q-1,h.NULL_CELL_CODE,h.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),$.setCellFromCodePoint(this._activeBuffer.x++,O,U,F.fg,F.bg,F.extended),U>0)for(;--U;)$.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else $.getWidth(this._activeBuffer.x-1)?$.addCodepointToCell(this._activeBuffer.x-1,O):$.addCodepointToCell(this._activeBuffer.x-2,O)}P-M>0&&($.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<Q&&P-M>0&&$.getWidth(this._activeBuffer.x)===0&&!$.hasContent(this._activeBuffer.x)&&$.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(D,M){return D.final!=="t"||D.prefix||D.intermediates?this._parser.registerCsiHandler(D,M):this._parser.registerCsiHandler(D,(P=>!A(P.params[0],this._optionsService.rawOptions.windowOptions)||M(P)))}registerDcsHandler(D,M){return this._parser.registerDcsHandler(D,new k.DcsHandler(M))}registerEscHandler(D,M){return this._parser.registerEscHandler(D,M)}registerOscHandler(D,M){return this._parser.registerOscHandler(D,new w.OscHandler(M))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var D;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||D===void 0)&&D.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const D=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-D),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(D=this._bufferService.cols-1){this._activeBuffer.x=Math.min(D,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(D,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=D,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=D,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(D,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+D,this._activeBuffer.y+M)}cursorUp(D){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,D.params[0]||1)):this._moveCursor(0,-(D.params[0]||1)),!0}cursorDown(D){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,D.params[0]||1)):this._moveCursor(0,D.params[0]||1),!0}cursorForward(D){return this._moveCursor(D.params[0]||1,0),!0}cursorBackward(D){return this._moveCursor(-(D.params[0]||1),0),!0}cursorNextLine(D){return this.cursorDown(D),this._activeBuffer.x=0,!0}cursorPrecedingLine(D){return this.cursorUp(D),this._activeBuffer.x=0,!0}cursorCharAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(D){return this._setCursor(D.length>=2?(D.params[1]||1)-1:0,(D.params[0]||1)-1),!0}charPosAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(D){return this._moveCursor(D.params[0]||1,0),!0}linePosAbsolute(D){return this._setCursor(this._activeBuffer.x,(D.params[0]||1)-1),!0}vPositionRelative(D){return this._moveCursor(0,D.params[0]||1),!0}hVPosition(D){return this.cursorPosition(D),!0}tabClear(D){const M=D.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=D.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=D.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(D){const M=D.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(D,M,P,O=!1,U=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);X.replaceCells(M,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),O&&(X.isWrapped=!1)}_resetBufferLine(D,M=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+D),P.isWrapped=!1)}eraseInDisplay(D,M=!1){let P;switch(this._restrictCursor(this._bufferService.cols),D.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);P<this._bufferService.rows;P++)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(D,M=!1){switch(this._restrictCursor(this._bufferService.cols),D.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(D){this._restrictCursor();let M=D.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(D){this._restrictCursor();let M=D.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;M--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(D){let M=D.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(D){let M=D.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(D.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(D){if(!this._parser.precedingCodepoint)return!0;const M=D.params[0]||1,P=new Uint32Array(M);for(let O=0;O<M;++O)P[O]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(D){return D.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(D){return D.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(D.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0}_is(D){return(this._optionsService.rawOptions.termName+"").indexOf(D)===0}setMode(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),D.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(D,M){const P=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:U}=this._coreMouseService,X=this._coreService,{buffers:Y,cols:Q}=this._bufferService,{active:oe,alt:T}=Y,F=this._optionsService.rawOptions,$=ne=>ne?1:2,z=D.params[0];return Z=z,q=M?z===2?4:z===4?$(X.modes.insertMode):z===12?3:z===20?$(F.convertEol):0:z===1?$(P.applicationCursorKeys):z===3?F.windowOptions.setWinLines?Q===80?2:Q===132?1:0:0:z===6?$(P.origin):z===7?$(P.wraparound):z===8?3:z===9?$(O==="X10"):z===12?$(F.cursorBlink):z===25?$(!X.isCursorHidden):z===45?$(P.reverseWraparound):z===66?$(P.applicationKeypad):z===67?4:z===1e3?$(O==="VT200"):z===1002?$(O==="DRAG"):z===1003?$(O==="ANY"):z===1004?$(P.sendFocus):z===1005?4:z===1006?$(U==="SGR"):z===1015?4:z===1016?$(U==="SGR_PIXELS"):z===1048?1:z===47||z===1047||z===1049?$(oe===T):z===2004?$(P.bracketedPasteMode):0,X.triggerDataEvent(`${o.C0.ESC}[${M?"":"?"}${Z};${q}$y`),!0;var Z,q}_updateAttrColor(D,M,P,O,U){return M===2?(D|=50331648,D&=-16777216,D|=v.AttributeData.fromColorRGB([P,O,U])):M===5&&(D&=-50331904,D|=33554432|255&P),D}_extractColor(D,M,P){const O=[0,0,-1,0,0,0];let U=0,X=0;do{if(O[X+U]=D.params[M+X],D.hasSubParams(M+X)){const Y=D.getSubParams(M+X);let Q=0;do O[1]===5&&(U=1),O[X+Q+1+U]=Y[Q];while(++Q<Y.length&&Q+X+1+U<O.length);break}if(O[1]===5&&X+U>=2||O[1]===2&&X+U>=5)break;O[1]&&(U=1)}while(++X+M<D.length&&X+U<O.length);for(let Y=2;Y<O.length;++Y)O[Y]===-1&&(O[Y]=0);switch(O[0]){case 38:P.fg=this._updateAttrColor(P.fg,O[1],O[3],O[4],O[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,O[1],O[3],O[4],O[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,O[1],O[3],O[4],O[5])}return X}_processUnderline(D,M){M.extended=M.extended.clone(),(!~D||D>5)&&(D=1),M.extended.underlineStyle=D,M.fg|=268435456,D===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(D){D.fg=n.DEFAULT_ATTR_DATA.fg,D.bg=n.DEFAULT_ATTR_DATA.bg,D.extended=D.extended.clone(),D.extended.underlineStyle=0,D.extended.underlineColor&=-67108864,D.updateExtended()}charAttributes(D){if(D.length===1&&D.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=D.length;let P;const O=this._curAttrData;for(let U=0;U<M;U++)P=D.params[U],P>=30&&P<=37?(O.fg&=-50331904,O.fg|=16777216|P-30):P>=40&&P<=47?(O.bg&=-50331904,O.bg|=16777216|P-40):P>=90&&P<=97?(O.fg&=-50331904,O.fg|=16777224|P-90):P>=100&&P<=107?(O.bg&=-50331904,O.bg|=16777224|P-100):P===0?this._processSGR0(O):P===1?O.fg|=134217728:P===3?O.bg|=67108864:P===4?(O.fg|=268435456,this._processUnderline(D.hasSubParams(U)?D.getSubParams(U)[0]:1,O)):P===5?O.fg|=536870912:P===7?O.fg|=67108864:P===8?O.fg|=1073741824:P===9?O.fg|=2147483648:P===2?O.bg|=134217728:P===21?this._processUnderline(2,O):P===22?(O.fg&=-134217729,O.bg&=-134217729):P===23?O.bg&=-67108865:P===24?(O.fg&=-268435457,this._processUnderline(0,O)):P===25?O.fg&=-536870913:P===27?O.fg&=-67108865:P===28?O.fg&=-1073741825:P===29?O.fg&=2147483647:P===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):P===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?U+=this._extractColor(D,U,O):P===53?O.bg|=1073741824:P===55?O.bg&=-1073741825:P===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):P===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(D){switch(D.params[0]){case 5:this._coreService.triggerDataEvent(`${o.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[${M};${P}R`)}return!0}deviceStatusPrivate(D){if(D.params[0]===6){const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[?${M};${P}R`)}return!0}softReset(D){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(D){const M=D.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const P=M%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(D){const M=D.params[0]||1;let P;return(D.length<2||(P=D.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(D){if(!A(D.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=D.length>1?D.params[1]:0;switch(D.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(L.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(L.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${o.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(D){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(D){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(D){return this._windowTitle=D,this._onTitleChange.fire(D),!0}setIconName(D){return this._iconName=D,!0}setOrReportIndexedColor(D){const M=[],P=D.split(";");for(;P.length>1;){const O=P.shift(),U=P.shift();if(/^\d+$/.exec(O)){const X=parseInt(O);if(H(X))if(U==="?")M.push({type:0,index:X});else{const Y=(0,y.parseColor)(U);Y&&M.push({type:1,index:X,color:Y})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(D){const M=D.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(D,M){this._getCurrentLinkId()&&this._finishHyperlink();const P=D.split(":");let O;const U=P.findIndex((X=>X.startsWith("id=")));return U!==-1&&(O=P[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(D,M){const P=D.split(";");for(let O=0;O<P.length&&!(M>=this._specialColors.length);++O,++M)if(P[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,y.parseColor)(P[O]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(D){return this._setOrReportSpecialColor(D,0)}setOrReportBgColor(D){return this._setOrReportSpecialColor(D,1)}setOrReportCursorColor(D){return this._setOrReportSpecialColor(D,2)}restoreIndexedColor(D){if(!D)return this._onColor.fire([{type:2}]),!0;const M=[],P=D.split(";");for(let O=0;O<P.length;++O)if(/^\d+$/.exec(P[O])){const U=parseInt(P[O]);H(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(D){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(D){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(D){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),!0}selectCharset(D){return D.length!==2?(this.selectDefaultCharset(),!0):(D[0]==="/"||this._charsetService.setgCharset(E[D[0]],p.CHARSETS[D[1]]||p.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const D=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,D,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(D){return this._charsetService.setgLevel(D),!0}screenAlignmentPattern(){const D=new u.CellData;D.content=4194373,D.fg=this._curAttrData.fg,D.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const P=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(P);O&&(O.fill(D),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(D,M){const P=this._bufferService.buffer,O=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${o.C0.ESC}${U}${o.C0.ESC}\\`),!0))(D==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:D==='"p'?'P1$r61;1"p':D==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:D==="m"?"P1$r0m":D===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(D,M){this._dirtyRowTracker.markRangeDirty(D,M)}}r.InputHandler=B;let I=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,D){W>D&&(N=W,W=D,D=N),W<this.start&&(this.start=W),D>this.end&&(this.end=D)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(W){return 0<=W&&W<256}I=c([d(0,x.IBufferService)],I)},844:(C,r)=>{function i(c){for(const d of c)d.dispose();c.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.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 d=this._disposables.indexOf(c);d!==-1&&this._disposables.splice(d,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var d;this._isDisposed||c===this._value||((d=this._value)===null||d===void 0||d.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}},r.toDisposable=function(c){return{dispose:c}},r.disposeArray=i,r.getDisposeArrayDisposable=function(c){return{dispose:()=>i(c)}}},1505:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(d,o,p){this._data[d]||(this._data[d]={}),this._data[d][o]=p}get(d,o){return this._data[d]?this._data[d][o]:void 0}clear(){this._data={}}}r.TwoKeyMap=i,r.FourKeyMap=class{constructor(){this._data=new i}set(c,d,o,p,g){this._data.get(c,d)||this._data.set(c,d,new i),this._data.get(c,d).set(o,p,g)}get(c,d,o,p){var g;return(g=this._data.get(c,d))===null||g===void 0?void 0:g.get(o,p)}clear(){this._data.clear()}}},6114:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof navigator>"u";const i=r.isNode?"node":navigator.userAgent,c=r.isNode?"node":navigator.platform;r.isFirefox=i.includes("Firefox"),r.isLegacyEdge=i.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(i),r.getSafariVersion=function(){if(!r.isSafari)return 0;const d=i.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),r.isIpad=c==="iPad",r.isIphone=c==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),r.isLinux=c.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(i)},6106:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let i=0;r.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(i=this._search(this._getKey(c)),this._array.splice(i,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const d=this._getKey(c);if(d===void 0||(i=this._search(d),i===-1)||this._getKey(this._array[i])!==d)return!1;do if(this._array[i]===c)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===d);return!1}*getKeyIterator(c){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===c)}forEachByKey(c,d){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do d(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===c)}values(){return[...this._array].values()}_search(c){let d=0,o=this._array.length-1;for(;o>=d;){let p=d+o>>1;const g=this._getKey(this._array[p]);if(g>c)o=p-1;else{if(!(g<c)){for(;p>0&&this._getKey(this._array[p-1])===c;)p--;return p}d=p+1}}return d}}},7226:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const c=i(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(g){this._tasks.push(g),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(g){this._idleCallback=void 0;let S=0,_=0,n=g.timeRemaining(),f=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),_=Math.max(S,_),f=g.timeRemaining(),1.5*_>f)return n-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-S))}ms`),void this._start();n=f}this.clear()}}class o extends d{_requestCallback(g){return setTimeout((()=>g(this._createDeadline(16))))}_cancelCallback(g){clearTimeout(g)}_createDeadline(g){const S=Date.now()+g;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}r.PriorityTaskQueue=o,r.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:o,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const c=i(643);r.updateWindowsModeWrappedState=function(d){const o=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),p=o?.get(d.cols-1),g=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);g&&p&&(g.isWrapped=p[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&p[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(o){return[o>>>16&255,o>>>8&255,255&o]}static fromColorRGB(o){return(255&o[0])<<16|(255&o[1])<<8|255&o[2]}clone(){const o=new i;return o.fg=this.fg,o.bg=this.bg,o.extended=this.extended.clone(),o}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}r.AttributeData=i;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(o){this._ext=o}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(o){this._ext&=-469762049,this._ext|=o<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(o){this._ext&=-67108864,this._ext|=67108863&o}get urlId(){return this._urlId}set urlId(o){this._urlId=o}constructor(o=0,p=0){this._ext=0,this._urlId=0,this._ext=o,this._urlId=p}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=c},9092:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const c=i(6349),d=i(7226),o=i(3734),p=i(8437),g=i(4634),S=i(511),_=i(643),n=i(4863),f=i(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(h,u,v){this._hasScrollback=h,this._optionsService=u,this._bufferService=v,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=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new o.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new o.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,u){return new p.BufferLine(this._bufferService.cols,this.getNullCell(h),u)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;const u=h+this._optionsService.rawOptions.scrollback;return u>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:u}fillViewportRows(h){if(this.lines.length===0){h===void 0&&(h=p.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(h))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(h,u){const v=this.getNullCell(p.DEFAULT_ATTR_DATA);let x=0;const w=this._getCorrectBufferLength(u);if(w>this.lines.maxLength&&(this.lines.maxLength=w),this.lines.length>0){if(this._cols<h)for(let y=0;y<this.lines.length;y++)x+=+this.lines.get(y).resize(h,v);let k=0;if(this._rows<u)for(let y=this._rows;y<u;y++)this.lines.length<u+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(h,v)):this.ybase>0&&this.lines.length<=this.ybase+this.y+k+1?(this.ybase--,k++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(h,v)));else for(let y=this._rows;y>u;y--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(w<this.lines.maxLength){const y=this.lines.length-w;y>0&&(this.lines.trimStart(y),this.ybase=Math.max(this.ybase-y,0),this.ydisp=Math.max(this.ydisp-y,0),this.savedY=Math.max(this.savedY-y,0)),this.lines.maxLength=w}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,u-1),k&&(this.y+=k),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(h,u),this._cols>h))for(let k=0;k<this.lines.length;k++)x+=+this.lines.get(k).resize(h,v);this._cols=h,this._rows=u,this._memoryCleanupQueue.clear(),x>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let h=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,h=!1);let u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>100)return!0;return h}get _isReflowEnabled(){const h=this._optionsService.rawOptions.windowsPty;return h&&h.buildNumber?this._hasScrollback&&h.backend==="conpty"&&h.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(h,u){this._cols!==h&&(h>this._cols?this._reflowLarger(h,u):this._reflowSmaller(h,u))}_reflowLarger(h,u){const v=(0,g.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(v.length>0){const x=(0,g.reflowLargerCreateNewLayout)(this.lines,v);(0,g.reflowLargerApplyNewLayout)(this.lines,x.layout),this._reflowLargerAdjustViewport(h,u,x.countRemoved)}}_reflowLargerAdjustViewport(h,u,v){const x=this.getNullCell(p.DEFAULT_ATTR_DATA);let w=v;for(;w-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new p.BufferLine(h,x))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-v,0)}_reflowSmaller(h,u){const v=this.getNullCell(p.DEFAULT_ATTR_DATA),x=[];let w=0;for(let k=this.lines.length-1;k>=0;k--){let y=this.lines.get(k);if(!y||!y.isWrapped&&y.getTrimmedLength()<=h)continue;const E=[y];for(;y.isWrapped&&k>0;)y=this.lines.get(--k),E.unshift(y);const j=this.ybase+this.y;if(j>=k&&j<k+E.length)continue;const A=E[E.length-1].getTrimmedLength(),L=(0,g.reflowSmallerGetNewLineLengths)(E,this._cols,h),N=L.length-E.length;let B;B=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 I=[];for(let O=0;O<N;O++){const U=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);I.push(U)}I.length>0&&(x.push({start:k+E.length+w,newLines:I}),w+=I.length),E.push(...I);let H=L.length-1,W=L[H];W===0&&(H--,W=L[H]);let D=E.length-N-1,M=A;for(;D>=0;){const O=Math.min(M,W);if(E[H]===void 0)break;if(E[H].copyCellsFrom(E[D],M-O,W-O,O,!0),W-=O,W===0&&(H--,W=L[H]),M-=O,M===0){D--;const U=Math.max(D,0);M=(0,g.getWrappedLineTrimmedLength)(E,U,this._cols)}}for(let O=0;O<E.length;O++)L[O]<h&&E[O].setCell(L[O],v);let P=N-B;for(;P-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+w)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+N,this.ybase+u-1)}if(x.length>0){const k=[],y=[];for(let H=0;H<this.lines.length;H++)y.push(this.lines.get(H));const E=this.lines.length;let j=E-1,A=0,L=x[A];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+w);let N=0;for(let H=Math.min(this.lines.maxLength-1,E+w-1);H>=0;H--)if(L&&L.start>j+N){for(let W=L.newLines.length-1;W>=0;W--)this.lines.set(H--,L.newLines[W]);H++,k.push({index:j+1,amount:L.newLines.length}),N+=L.newLines.length,L=x[++A]}else this.lines.set(H,y[j--]);let B=0;for(let H=k.length-1;H>=0;H--)k[H].index+=B,this.lines.onInsertEmitter.fire(k[H]),B+=k[H].amount;const I=Math.max(0,E+w-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(h,u,v=0,x){const w=this.lines.get(h);return w?w.translateToString(u,v,x):""}getWrappedRangeForLine(h){let u=h,v=h;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;v+1<this.lines.length&&this.lines.get(v+1).isWrapped;)v++;return{first:u,last:v}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].line===h&&(this.markers[u].dispose(),this.markers.splice(u--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose(),this.markers.splice(h--,1);this._isClearing=!1}addMarker(h){const u=new n.Marker(h);return this.markers.push(u),u.register(this.lines.onTrim((v=>{u.line-=v,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((v=>{u.line>=v.index&&(u.line+=v.amount)}))),u.register(this.lines.onDelete((v=>{u.line>=v.index&&u.line<v.index+v.amount&&u.dispose(),u.line>v.index&&(u.line-=v.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},8437:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const c=i(3734),d=i(511),o=i(643),p=i(482);r.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let g=0;class S{constructor(n,f,h=!1){this.isWrapped=h,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const u=f||d.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]);for(let v=0;v<n;++v)this.setCell(v,u);this.length=n}get(n){const f=this._data[3*n+0],h=2097151&f;return[this._data[3*n+1],2097152&f?this._combined[n]:h?(0,p.stringFromCodePoint)(h):"",f>>22,2097152&f?this._combined[n].charCodeAt(this._combined[n].length-1):h]}set(n,f){this._data[3*n+1]=f[o.CHAR_DATA_ATTR_INDEX],f[o.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=f[1],this._data[3*n+0]=2097152|n|f[o.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=f[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[o.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const f=this._data[3*n+0];return 2097152&f?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&f}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const f=this._data[3*n+0];return 2097152&f?this._combined[n]:2097151&f?(0,p.stringFromCodePoint)(2097151&f):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,f){return g=3*n,f.content=this._data[g+0],f.fg=this._data[g+1],f.bg=this._data[g+2],2097152&f.content&&(f.combinedData=this._combined[n]),268435456&f.bg&&(f.extended=this._extendedAttrs[n]),f}setCell(n,f){2097152&f.content&&(this._combined[n]=f.combinedData),268435456&f.bg&&(this._extendedAttrs[n]=f.extended),this._data[3*n+0]=f.content,this._data[3*n+1]=f.fg,this._data[3*n+2]=f.bg}setCellFromCodePoint(n,f,h,u,v,x){268435456&v&&(this._extendedAttrs[n]=x),this._data[3*n+0]=f|h<<22,this._data[3*n+1]=u,this._data[3*n+2]=v}addCodepointToCell(n,f){let h=this._data[3*n+0];2097152&h?this._combined[n]+=(0,p.stringFromCodePoint)(f):(2097151&h?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&h)+(0,p.stringFromCodePoint)(f),h&=-2097152,h|=2097152):h=f|4194304,this._data[3*n+0]=h)}insertCells(n,f,h,u){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length-n){const v=new d.CellData;for(let x=this.length-n-f-1;x>=0;--x)this.setCell(n+f+x,this.loadCell(n+x,v));for(let x=0;x<f;++x)this.setCell(n+x,h)}else for(let v=n;v<this.length;++v)this.setCell(v,h);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(n,f,h,u){if(n%=this.length,f<this.length-n){const v=new d.CellData;for(let x=0;x<this.length-n-f;++x)this.setCell(n+x,this.loadCell(n+f+x,v));for(let x=this.length-f;x<this.length;++x)this.setCell(x,h)}else for(let v=n;v<this.length;++v)this.setCell(v,h);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(n,f,h,u,v=!1){if(v)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&!this.isProtected(f)&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<f&&n<this.length;)this.isProtected(n)||this.setCell(n,h),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<f&&n<this.length;)this.setCell(n++,h)}resize(n,f){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const h=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*h)this._data=new Uint32Array(this._data.buffer,0,h);else{const u=new Uint32Array(h);u.set(this._data),this._data=u}for(let u=this.length;u<n;++u)this.setCell(u,f)}else{this._data=this._data.subarray(0,h);const u=Object.keys(this._combined);for(let x=0;x<u.length;x++){const w=parseInt(u[x],10);w>=n&&delete this._combined[w]}const v=Object.keys(this._extendedAttrs);for(let x=0;x<v.length;x++){const w=parseInt(v[x],10);w>=n&&delete this._extendedAttrs[w]}}return this.length=n,4*h*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,f=!1){if(f)for(let h=0;h<this.length;++h)this.isProtected(h)||this.setCell(h,n);else{this._combined={},this._extendedAttrs={};for(let h=0;h<this.length;++h)this.setCell(h,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const f in n._combined)this._combined[f]=n._combined[f];this._extendedAttrs={};for(const f in n._extendedAttrs)this._extendedAttrs[f]=n._extendedAttrs[f];this.isWrapped=n.isWrapped}clone(){const n=new S(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const f in this._combined)n._combined[f]=this._combined[f];for(const f in this._extendedAttrs)n._extendedAttrs[f]=this._extendedAttrs[f];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,f,h,u,v){const x=n._data;if(v)for(let k=u-1;k>=0;k--){for(let y=0;y<3;y++)this._data[3*(h+k)+y]=x[3*(f+k)+y];268435456&x[3*(f+k)+2]&&(this._extendedAttrs[h+k]=n._extendedAttrs[f+k])}else for(let k=0;k<u;k++){for(let y=0;y<3;y++)this._data[3*(h+k)+y]=x[3*(f+k)+y];268435456&x[3*(f+k)+2]&&(this._extendedAttrs[h+k]=n._extendedAttrs[f+k])}const w=Object.keys(n._combined);for(let k=0;k<w.length;k++){const y=parseInt(w[k],10);y>=f&&(this._combined[y-f+h]=n._combined[y])}}translateToString(n=!1,f=0,h=this.length){n&&(h=Math.min(h,this.getTrimmedLength()));let u="";for(;f<h;){const v=this._data[3*f+0],x=2097151&v;u+=2097152&v?this._combined[f]:x?(0,p.stringFromCodePoint)(x):o.WHITESPACE_CELL_CHAR,f+=v>>22||1}return u}}r.BufferLine=S},4841:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(i,c){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return c*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(C,r)=>{function i(c,d,o){if(d===c.length-1)return c[d].getTrimmedLength();const p=!c[d].hasContent(o-1)&&c[d].getWidth(o-1)===1,g=c[d+1].getWidth(0)===2;return p&&g?o-1:o}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(c,d,o,p,g){const S=[];for(let _=0;_<c.length-1;_++){let n=_,f=c.get(++n);if(!f.isWrapped)continue;const h=[c.get(_)];for(;n<c.length&&f.isWrapped;)h.push(f),f=c.get(++n);if(p>=_&&p<n){_+=h.length-1;continue}let u=0,v=i(h,u,d),x=1,w=0;for(;x<h.length;){const y=i(h,x,d),E=y-w,j=o-v,A=Math.min(E,j);h[u].copyCellsFrom(h[x],w,v,A,!1),v+=A,v===o&&(u++,v=0),w+=A,w===y&&(x++,w=0),v===0&&u!==0&&h[u-1].getWidth(o-1)===2&&(h[u].copyCellsFrom(h[u-1],o-1,v++,1,!1),h[u-1].setCell(o-1,g))}h[u].replaceCells(v,o,g);let k=0;for(let y=h.length-1;y>0&&(y>u||h[y].getTrimmedLength()===0);y--)k++;k>0&&(S.push(_+h.length-k),S.push(k)),_+=h.length-1}return S},r.reflowLargerCreateNewLayout=function(c,d){const o=[];let p=0,g=d[p],S=0;for(let _=0;_<c.length;_++)if(g===_){const n=d[++p];c.onDeleteEmitter.fire({index:_-S,amount:n}),_+=n-1,S+=n,g=d[++p]}else o.push(_);return{layout:o,countRemoved:S}},r.reflowLargerApplyNewLayout=function(c,d){const o=[];for(let p=0;p<d.length;p++)o.push(c.get(d[p]));for(let p=0;p<o.length;p++)c.set(p,o[p]);c.length=d.length},r.reflowSmallerGetNewLineLengths=function(c,d,o){const p=[],g=c.map(((f,h)=>i(c,h,d))).reduce(((f,h)=>f+h));let S=0,_=0,n=0;for(;n<g;){if(g-n<o){p.push(g-n);break}S+=o;const f=i(c,_,d);S>f&&(S-=f,_++);const h=c[_].getWidth(S-1)===2;h&&S--;const u=h?o-1:o;p.push(u),n+=u}return p},r.getWrappedLineTrimmedLength=i},5295:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const c=i(8460),d=i(844),o=i(9092);class p extends d.Disposable{constructor(S,_){super(),this._optionsService=S,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 o.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(S,_){this._normal.resize(S,_),this._alt.resize(S,_),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}r.BufferSet=p},511:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const c=i(482),d=i(643),o=i(3734);class p extends o.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new o.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const _=new p;return _.setFromCharData(S),_}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(S[d.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(S[d.CHAR_DATA_CHAR_INDEX].length===2){const n=S[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const f=S[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=f&&f<=57343?this.content=1024*(n-55296)+f-56320+65536|S[d.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=S[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[d.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=S[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=p},643:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const c=i(8460),d=i(844);class o{get id(){return this._id}constructor(g){this.line=g,this.isDisposed=!1,this._disposables=[],this._id=o._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(g){return this._disposables.push(g),g}}r.Marker=o,o._nextId=1},7116:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.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:"≥","{":"π","|":"≠","}":"£","~":"·"},r.CHARSETS.A={"#":"£"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},r.CHARSETS.C=r.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},r.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},r.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},r.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},r.CHARSETS.E=r.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},r.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},r.CHARSETS.H=r.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(C,r)=>{var i,c,d;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(o){o.NUL="\0",o.SOH="",o.STX="",o.ETX="",o.EOT="",o.ENQ="",o.ACK="",o.BEL="\x07",o.BS="\b",o.HT=" ",o.LF=`
18
- `,o.VT="\v",o.FF="\f",o.CR="\r",o.SO="",o.SI="",o.DLE="",o.DC1="",o.DC2="",o.DC3="",o.DC4="",o.NAK="",o.SYN="",o.ETB="",o.CAN="",o.EM="",o.SUB="",o.ESC="\x1B",o.FS="",o.GS="",o.RS="",o.US="",o.SP=" ",o.DEL=""})(i||(r.C0=i={})),(function(o){o.PAD="€",o.HOP="",o.BPH="‚",o.NBH="ƒ",o.IND="„",o.NEL="…",o.SSA="†",o.ESA="‡",o.HTS="ˆ",o.HTJ="‰",o.VTS="Š",o.PLD="‹",o.PLU="Œ",o.RI="",o.SS2="Ž",o.SS3="",o.DCS="",o.PU1="‘",o.PU2="’",o.STS="“",o.CCH="”",o.MW="•",o.SPA="–",o.EPA="—",o.SOS="˜",o.SGCI="™",o.SCI="š",o.CSI="›",o.ST="œ",o.OSC="",o.PM="ž",o.APC="Ÿ"})(c||(r.C1=c={})),(function(o){o.ST=`${i.ESC}\\`})(d||(r.C1_ESCAPED=d={}))},7399:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const c=i(2584),d={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:["'",'"']};r.evaluateKeyboardEvent=function(o,p,g,S){const _={type:0,cancel:!1,key:void 0},n=(o.shiftKey?1:0)|(o.altKey?2:0)|(o.ctrlKey?4:0)|(o.metaKey?8:0);switch(o.keyCode){case 0:o.key==="UIKeyInputUpArrow"?_.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A":o.key==="UIKeyInputLeftArrow"?_.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D":o.key==="UIKeyInputRightArrow"?_.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C":o.key==="UIKeyInputDownArrow"&&(_.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(o.altKey){_.key=c.C0.ESC+c.C0.DEL;break}_.key=c.C0.DEL;break;case 9:if(o.shiftKey){_.key=c.C0.ESC+"[Z";break}_.key=c.C0.HT,_.cancel=!0;break;case 13:_.key=o.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,_.cancel=!0;break;case 27:_.key=c.C0.ESC,o.altKey&&(_.key=c.C0.ESC+c.C0.ESC),_.cancel=!0;break;case 37:if(o.metaKey)break;n?(_.key=c.C0.ESC+"[1;"+(n+1)+"D",_.key===c.C0.ESC+"[1;3D"&&(_.key=c.C0.ESC+(g?"b":"[1;5D"))):_.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(o.metaKey)break;n?(_.key=c.C0.ESC+"[1;"+(n+1)+"C",_.key===c.C0.ESC+"[1;3C"&&(_.key=c.C0.ESC+(g?"f":"[1;5C"))):_.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(o.metaKey)break;n?(_.key=c.C0.ESC+"[1;"+(n+1)+"A",g||_.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(o.metaKey)break;n?(_.key=c.C0.ESC+"[1;"+(n+1)+"B",g||_.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:o.shiftKey||o.ctrlKey||(_.key=c.C0.ESC+"[2~");break;case 46:_.key=n?c.C0.ESC+"[3;"+(n+1)+"~":c.C0.ESC+"[3~";break;case 36:_.key=n?c.C0.ESC+"[1;"+(n+1)+"H":p?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:_.key=n?c.C0.ESC+"[1;"+(n+1)+"F":p?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:o.shiftKey?_.type=2:o.ctrlKey?_.key=c.C0.ESC+"[5;"+(n+1)+"~":_.key=c.C0.ESC+"[5~";break;case 34:o.shiftKey?_.type=3:o.ctrlKey?_.key=c.C0.ESC+"[6;"+(n+1)+"~":_.key=c.C0.ESC+"[6~";break;case 112:_.key=n?c.C0.ESC+"[1;"+(n+1)+"P":c.C0.ESC+"OP";break;case 113:_.key=n?c.C0.ESC+"[1;"+(n+1)+"Q":c.C0.ESC+"OQ";break;case 114:_.key=n?c.C0.ESC+"[1;"+(n+1)+"R":c.C0.ESC+"OR";break;case 115:_.key=n?c.C0.ESC+"[1;"+(n+1)+"S":c.C0.ESC+"OS";break;case 116:_.key=n?c.C0.ESC+"[15;"+(n+1)+"~":c.C0.ESC+"[15~";break;case 117:_.key=n?c.C0.ESC+"[17;"+(n+1)+"~":c.C0.ESC+"[17~";break;case 118:_.key=n?c.C0.ESC+"[18;"+(n+1)+"~":c.C0.ESC+"[18~";break;case 119:_.key=n?c.C0.ESC+"[19;"+(n+1)+"~":c.C0.ESC+"[19~";break;case 120:_.key=n?c.C0.ESC+"[20;"+(n+1)+"~":c.C0.ESC+"[20~";break;case 121:_.key=n?c.C0.ESC+"[21;"+(n+1)+"~":c.C0.ESC+"[21~";break;case 122:_.key=n?c.C0.ESC+"[23;"+(n+1)+"~":c.C0.ESC+"[23~";break;case 123:_.key=n?c.C0.ESC+"[24;"+(n+1)+"~":c.C0.ESC+"[24~";break;default:if(!o.ctrlKey||o.shiftKey||o.altKey||o.metaKey)if(g&&!S||!o.altKey||o.metaKey)!g||o.altKey||o.ctrlKey||o.shiftKey||!o.metaKey?o.key&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&o.keyCode>=48&&o.key.length===1?_.key=o.key:o.key&&o.ctrlKey&&(o.key==="_"&&(_.key=c.C0.US),o.key==="@"&&(_.key=c.C0.NUL)):o.keyCode===65&&(_.type=1);else{const f=d[o.keyCode],h=f?.[o.shiftKey?1:0];if(h)_.key=c.C0.ESC+h;else if(o.keyCode>=65&&o.keyCode<=90){const u=o.ctrlKey?o.keyCode-64:o.keyCode+32;let v=String.fromCharCode(u);o.shiftKey&&(v=v.toUpperCase()),_.key=c.C0.ESC+v}else if(o.keyCode===32)_.key=c.C0.ESC+(o.ctrlKey?c.C0.NUL:" ");else if(o.key==="Dead"&&o.code.startsWith("Key")){let u=o.code.slice(3,4);o.shiftKey||(u=u.toLowerCase()),_.key=c.C0.ESC+u,_.cancel=!0}}else o.keyCode>=65&&o.keyCode<=90?_.key=String.fromCharCode(o.keyCode-64):o.keyCode===32?_.key=c.C0.NUL:o.keyCode>=51&&o.keyCode<=55?_.key=String.fromCharCode(o.keyCode-51+27):o.keyCode===56?_.key=c.C0.DEL:o.keyCode===219?_.key=c.C0.ESC:o.keyCode===220?_.key=c.C0.FS:o.keyCode===221&&(_.key=c.C0.GS)}return _}},482:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},r.utf32ToString=function(i,c=0,d=i.length){let o="";for(let p=c;p<d;++p){let g=i[p];g>65535?(g-=65536,o+=String.fromCharCode(55296+(g>>10))+String.fromCharCode(g%1024+56320)):o+=String.fromCharCode(g)}return o},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,c){const d=i.length;if(!d)return 0;let o=0,p=0;if(this._interim){const g=i.charCodeAt(p++);56320<=g&&g<=57343?c[o++]=1024*(this._interim-55296)+g-56320+65536:(c[o++]=this._interim,c[o++]=g),this._interim=0}for(let g=p;g<d;++g){const S=i.charCodeAt(g);if(55296<=S&&S<=56319){if(++g>=d)return this._interim=S,o;const _=i.charCodeAt(g);56320<=_&&_<=57343?c[o++]=1024*(S-55296)+_-56320+65536:(c[o++]=S,c[o++]=_)}else S!==65279&&(c[o++]=S)}return o}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,c){const d=i.length;if(!d)return 0;let o,p,g,S,_=0,n=0,f=0;if(this.interim[0]){let v=!1,x=this.interim[0];x&=(224&x)==192?31:(240&x)==224?15:7;let w,k=0;for(;(w=63&this.interim[++k])&&k<4;)x<<=6,x|=w;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=y-k;for(;f<E;){if(f>=d)return 0;if(w=i[f++],(192&w)!=128){f--,v=!0;break}this.interim[k++]=w,x<<=6,x|=63&w}v||(y===2?x<128?f--:c[_++]=x:y===3?x<2048||x>=55296&&x<=57343||x===65279||(c[_++]=x):x<65536||x>1114111||(c[_++]=x)),this.interim.fill(0)}const h=d-4;let u=f;for(;u<d;){for(;!(!(u<h)||128&(o=i[u])||128&(p=i[u+1])||128&(g=i[u+2])||128&(S=i[u+3]));)c[_++]=o,c[_++]=p,c[_++]=g,c[_++]=S,u+=4;if(o=i[u++],o<128)c[_++]=o;else if((224&o)==192){if(u>=d)return this.interim[0]=o,_;if(p=i[u++],(192&p)!=128){u--;continue}if(n=(31&o)<<6|63&p,n<128){u--;continue}c[_++]=n}else if((240&o)==224){if(u>=d)return this.interim[0]=o,_;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,_;if(g=i[u++],(192&g)!=128){u--;continue}if(n=(15&o)<<12|(63&p)<<6|63&g,n<2048||n>=55296&&n<=57343||n===65279)continue;c[_++]=n}else if((248&o)==240){if(u>=d)return this.interim[0]=o,_;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,_;if(g=i[u++],(192&g)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,this.interim[2]=g,_;if(S=i[u++],(192&S)!=128){u--;continue}if(n=(7&o)<<18|(63&p)<<12|(63&g)<<6|63&S,n<65536||n>1114111)continue;c[_++]=n}}return _}}},225:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],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 d;r.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let o=0;o<i.length;++o)d.fill(0,i[o][0],i[o][1]+1)}}wcwidth(o){return o<32?0:o<127?1:o<65536?d[o]:(function(p,g){let S,_=0,n=g.length-1;if(p<g[0][0]||p>g[n][1])return!1;for(;n>=_;)if(S=_+n>>1,p>g[S][1])_=S+1;else{if(!(p<g[S][0]))return!0;n=S-1}return!1})(o,c)?0:o>=131072&&o<=196605||o>=196608&&o<=262141?2:1}}},5981:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const c=i(8460),d=i(844);class o extends d.Disposable{constructor(g){super(),this._action=g,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(g,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(g,S){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(S),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(S)}_innerWrite(g=0,S=!0){const _=g||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],f=this._action(n,S);if(f){const u=v=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,v))):this._innerWrite(_,v);return void f.catch((v=>(queueMicrotask((()=>{throw v})),Promise.resolve(!1)))).then(u)}const h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=n.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()}}r.WriteBuffer=o},5941:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c=/^[\da-f]+$/;function d(o,p){const g=o.toString(16),S=g.length<2?"0"+g:g;switch(p){case 4:return g[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}r.parseColor=function(o){if(!o)return;let p=o.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const g=i.exec(p);if(g){const S=g[1]?15:g[4]?255:g[7]?4095:65535;return[Math.round(parseInt(g[1]||g[4]||g[7]||g[10],16)/S*255),Math.round(parseInt(g[2]||g[5]||g[8]||g[11],16)/S*255),Math.round(parseInt(g[3]||g[6]||g[9]||g[12],16)/S*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),c.exec(p)&&[3,6,9,12].includes(p.length))){const g=p.length/3,S=[0,0,0];for(let _=0;_<3;++_){const n=parseInt(p.slice(g*_,g*_+g),16);S[_]=g===1?n<<4:g===2?n:g===3?n>>4:n>>8}return S}},r.toRgbString=function(o,p=16){const[g,S,_]=o;return`rgb:${d(g,p)}/${d(S,p)}/${d(_,p)}`}},5770:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const c=i(482),d=i(8742),o=i(5770),p=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(S,_){this._handlers[S]===void 0&&(this._handlers[S]=[]);const n=this._handlers[S];return n.push(_),{dispose:()=>{const f=n.indexOf(_);f!==-1&&n.splice(f,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(S,_){if(this.reset(),this._ident=S,this._active=this._handlers[S]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(S,_,n){if(this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].put(S,_,n);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(S,_,n))}unhook(S,_=!0){if(this._active.length){let n=!1,f=this._active.length-1,h=!1;if(this._stack.paused&&(f=this._stack.loopPosition-1,n=_,h=this._stack.fallThrough,this._stack.paused=!1),!h&&n===!1){for(;f>=0&&(n=this._active[f].unhook(S),n!==!0);f--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!1,n;f--}for(;f>=0;f--)if(n=this._active[f].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",S);this._active=p,this._ident=0}};const g=new d.Params;g.addParam(0),r.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=g,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():g,this._data="",this._hitLimit=!1}put(S,_,n){this._hitLimit||(this._data+=(0,c.utf32ToString)(S,_,n),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let _=!1;if(this._hitLimit)_=!1;else if(S&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((n=>(this._params=g,this._data="",this._hitLimit=!1,n)));return this._params=g,this._data="",this._hitLimit=!1,_}}},2015:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const c=i(844),d=i(8742),o=i(6242),p=i(6351);class g{constructor(f){this.table=new Uint8Array(f)}setDefault(f,h){this.table.fill(f<<4|h)}add(f,h,u,v){this.table[h<<8|f]=u<<4|v}addMany(f,h,u,v){for(let x=0;x<f.length;x++)this.table[h<<8|f[x]]=u<<4|v}}r.TransitionTable=g;const S=160;r.VT500_TRANSITION_TABLE=(function(){const n=new g(4095),f=Array.apply(null,Array(256)).map(((k,y)=>y)),h=(k,y)=>f.slice(k,y),u=h(32,127),v=h(0,24);v.push(25),v.push.apply(v,h(28,32));const x=h(0,14);let w;for(w in n.setDefault(1,0),n.addMany(u,0,2,0),x)n.addMany([24,26,153,154],w,3,0),n.addMany(h(128,144),w,3,0),n.addMany(h(144,152),w,3,0),n.add(156,w,0,0),n.add(27,w,11,1),n.add(157,w,4,8),n.addMany([152,158,159],w,0,7),n.add(155,w,11,3),n.add(144,w,11,9);return n.addMany(v,0,3,0),n.addMany(v,1,3,1),n.add(127,1,0,1),n.addMany(v,8,0,8),n.addMany(v,3,3,3),n.add(127,3,0,3),n.addMany(v,4,3,4),n.add(127,4,0,4),n.addMany(v,6,3,6),n.addMany(v,5,3,5),n.add(127,5,0,5),n.addMany(v,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(u,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(h(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(u,7,0,7),n.addMany(v,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(h(64,127),3,7,0),n.addMany(h(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(h(48,60),4,8,4),n.addMany(h(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(h(32,64),6,0,6),n.add(127,6,0,6),n.addMany(h(64,127),6,0,0),n.addMany(h(32,48),3,9,5),n.addMany(h(32,48),5,9,5),n.addMany(h(48,64),5,0,6),n.addMany(h(64,127),5,7,0),n.addMany(h(32,48),4,9,5),n.addMany(h(32,48),1,9,2),n.addMany(h(32,48),2,9,2),n.addMany(h(48,127),2,10,0),n.addMany(h(48,80),1,10,0),n.addMany(h(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(h(96,127),1,10,0),n.add(80,1,11,9),n.addMany(v,9,0,9),n.add(127,9,0,9),n.addMany(h(28,32),9,0,9),n.addMany(h(32,48),9,9,12),n.addMany(h(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(v,11,0,11),n.addMany(h(32,128),11,0,11),n.addMany(h(28,32),11,0,11),n.addMany(v,10,0,10),n.add(127,10,0,10),n.addMany(h(28,32),10,0,10),n.addMany(h(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(h(32,48),10,9,12),n.addMany(v,12,0,12),n.add(127,12,0,12),n.addMany(h(28,32),12,0,12),n.addMany(h(32,48),12,9,12),n.addMany(h(48,64),12,0,11),n.addMany(h(64,127),12,12,13),n.addMany(h(64,127),10,12,13),n.addMany(h(64,127),9,12,13),n.addMany(v,13,13,13),n.addMany(u,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(S,0,2,0),n.add(S,8,5,8),n.add(S,6,0,6),n.add(S,11,0,11),n.add(S,13,13,13),n})();class _ extends c.Disposable{constructor(f=r.VT500_TRANSITION_TABLE){super(),this._transitions=f,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(h,u,v)=>{},this._executeHandlerFb=h=>{},this._csiHandlerFb=(h,u)=>{},this._escHandlerFb=h=>{},this._errorHandlerFb=h=>h,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new o.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(f,h=[64,126]){let u=0;if(f.prefix){if(f.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=f.prefix.charCodeAt(0),u&&60>u||u>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(f.intermediates){if(f.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let x=0;x<f.intermediates.length;++x){const w=f.intermediates.charCodeAt(x);if(32>w||w>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=w}}if(f.final.length!==1)throw new Error("final must be a single byte");const v=f.final.charCodeAt(0);if(h[0]>v||v>h[1])throw new Error(`final must be in range ${h[0]} .. ${h[1]}`);return u<<=8,u|=v,u}identToString(f){const h=[];for(;f;)h.push(String.fromCharCode(255&f)),f>>=8;return h.reverse().join("")}setPrintHandler(f){this._printHandler=f}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(f,h){const u=this._identifier(f,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const v=this._escHandlers[u];return v.push(h),{dispose:()=>{const x=v.indexOf(h);x!==-1&&v.splice(x,1)}}}clearEscHandler(f){this._escHandlers[this._identifier(f,[48,126])]&&delete this._escHandlers[this._identifier(f,[48,126])]}setEscHandlerFallback(f){this._escHandlerFb=f}setExecuteHandler(f,h){this._executeHandlers[f.charCodeAt(0)]=h}clearExecuteHandler(f){this._executeHandlers[f.charCodeAt(0)]&&delete this._executeHandlers[f.charCodeAt(0)]}setExecuteHandlerFallback(f){this._executeHandlerFb=f}registerCsiHandler(f,h){const u=this._identifier(f);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const v=this._csiHandlers[u];return v.push(h),{dispose:()=>{const x=v.indexOf(h);x!==-1&&v.splice(x,1)}}}clearCsiHandler(f){this._csiHandlers[this._identifier(f)]&&delete this._csiHandlers[this._identifier(f)]}setCsiHandlerFallback(f){this._csiHandlerFb=f}registerDcsHandler(f,h){return this._dcsParser.registerHandler(this._identifier(f),h)}clearDcsHandler(f){this._dcsParser.clearHandler(this._identifier(f))}setDcsHandlerFallback(f){this._dcsParser.setHandlerFallback(f)}registerOscHandler(f,h){return this._oscParser.registerHandler(f,h)}clearOscHandler(f){this._oscParser.clearHandler(f)}setOscHandlerFallback(f){this._oscParser.setHandlerFallback(f)}setErrorHandler(f){this._errorHandler=f}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(f,h,u,v,x){this._parseStack.state=f,this._parseStack.handlers=h,this._parseStack.handlerPos=u,this._parseStack.transition=v,this._parseStack.chunkPos=x}parse(f,h,u){let v,x=0,w=0,k=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,k=this._parseStack.chunkPos+1;else{if(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const y=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&E>-1){for(;E>=0&&(v=y[E](this._params),v!==!0);E--)if(v instanceof Promise)return this._parseStack.handlerPos=E,v}this._parseStack.handlers=[];break;case 4:if(u===!1&&E>-1){for(;E>=0&&(v=y[E](),v!==!0);E--)if(v instanceof Promise)return this._parseStack.handlerPos=E,v}this._parseStack.handlers=[];break;case 6:if(x=f[this._parseStack.chunkPos],v=this._dcsParser.unhook(x!==24&&x!==26,u),v)return v;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(x=f[this._parseStack.chunkPos],v=this._oscParser.end(x!==24&&x!==26,u),v)return v;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,k=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let y=k;y<h;++y){switch(x=f[y],w=this._transitions.table[this.currentState<<8|(x<160?x:S)],w>>4){case 2:for(let N=y+1;;++N){if(N>=h||(x=f[N])<32||x>126&&x<S){this._printHandler(f,y,N),y=N-1;break}if(++N>=h||(x=f[N])<32||x>126&&x<S){this._printHandler(f,y,N),y=N-1;break}if(++N>=h||(x=f[N])<32||x>126&&x<S){this._printHandler(f,y,N),y=N-1;break}if(++N>=h||(x=f[N])<32||x>126&&x<S){this._printHandler(f,y,N),y=N-1;break}}break;case 3:this._executeHandlers[x]?this._executeHandlers[x]():this._executeHandlerFb(x),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:y,code:x,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|x];let j=E?E.length-1:-1;for(;j>=0&&(v=E[j](this._params),v!==!0);j--)if(v instanceof Promise)return this._preserveStack(3,E,j,w,y),v;j<0&&this._csiHandlerFb(this._collect<<8|x,this._params),this.precedingCodepoint=0;break;case 8:do switch(x){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(x-48)}while(++y<h&&(x=f[y])>47&&x<60);y--;break;case 9:this._collect<<=8,this._collect|=x;break;case 10:const A=this._escHandlers[this._collect<<8|x];let L=A?A.length-1:-1;for(;L>=0&&(v=A[L](),v!==!0);L--)if(v instanceof Promise)return this._preserveStack(4,A,L,w,y),v;L<0&&this._escHandlerFb(this._collect<<8|x),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|x,this._params);break;case 13:for(let N=y+1;;++N)if(N>=h||(x=f[N])===24||x===26||x===27||x>127&&x<S){this._dcsParser.put(f,y,N),y=N-1;break}break;case 14:if(v=this._dcsParser.unhook(x!==24&&x!==26),v)return this._preserveStack(6,[],0,w,y),v;x===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=y+1;;N++)if(N>=h||(x=f[N])<32||x>127&&x<S){this._oscParser.put(f,y,N),y=N-1;break}break;case 6:if(v=this._oscParser.end(x!==24&&x!==26),v)return this._preserveStack(5,[],0,w,y),v;x===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&w}}}r.EscapeSequenceParser=_},6242:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const c=i(5770),d=i(482),o=[];r.OscParser=class{constructor(){this._state=0,this._active=o,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,g){this._handlers[p]===void 0&&(this._handlers[p]=[]);const S=this._handlers[p];return S.push(g),{dispose:()=>{const _=S.indexOf(g);_!==-1&&S.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=o}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||o,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,g,S){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(p,g,S);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(p,g,S))}start(){this.reset(),this._state=1}put(p,g,S){if(this._state!==3){if(this._state===1)for(;g<S;){const _=p[g++];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&&S-g>0&&this._put(p,g,S)}}end(p,g=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,_=this._active.length-1,n=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,S=g,n=this._stack.fallThrough,this._stack.paused=!1),!n&&S===!1){for(;_>=0&&(S=this._active[_].end(p),S!==!0);_--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,S;_--}for(;_>=0;_--)if(S=this._active[_].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",p);this._active=o,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,g,S){this._hitLimit||(this._data+=(0,d.utf32ToString)(p,g,S),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let g=!1;if(this._hitLimit)g=!1;else if(p&&(g=this._handler(this._data),g instanceof Promise))return g.then((S=>(this._data="",this._hitLimit=!1,S)));return this._data="",this._hitLimit=!1,g}}},8742:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const i=2147483647;class c{static fromArray(o){const p=new c;if(!o.length)return p;for(let g=Array.isArray(o[0])?1:0;g<o.length;++g){const S=o[g];if(Array.isArray(S))for(let _=0;_<S.length;++_)p.addSubParam(S[_]);else p.addParam(S)}return p}constructor(o=32,p=32){if(this.maxLength=o,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(o),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(o),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const o=new c(this.maxLength,this.maxSubParamsLength);return o.params.set(this.params),o.length=this.length,o._subParams.set(this._subParams),o._subParamsLength=this._subParamsLength,o._subParamsIdx.set(this._subParamsIdx),o._rejectDigits=this._rejectDigits,o._rejectSubDigits=this._rejectSubDigits,o._digitIsSub=this._digitIsSub,o}toArray(){const o=[];for(let p=0;p<this.length;++p){o.push(this.params[p]);const g=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-g>0&&o.push(Array.prototype.slice.call(this._subParams,g,S))}return o}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(o){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=o>i?i:o}}addSubParam(o){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=o>i?i:o,this._subParamsIdx[this.length-1]++}}hasSubParams(o){return(255&this._subParamsIdx[o])-(this._subParamsIdx[o]>>8)>0}getSubParams(o){const p=this._subParamsIdx[o]>>8,g=255&this._subParamsIdx[o];return g-p>0?this._subParams.subarray(p,g):null}getSubParamsAll(){const o={};for(let p=0;p<this.length;++p){const g=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-g>0&&(o[p]=this._subParams.slice(g,S))}return o}addDigit(o){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const g=this._digitIsSub?this._subParams:this.params,S=g[p-1];g[p-1]=~S?Math.min(10*S+o,i):o}}r.Params=c},5741:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,c){const d={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(d),c.dispose=()=>this._wrappedAddonDispose(d),c.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let c=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===i){c=d;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(c,1)}}},8771:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const c=i(3785),d=i(511);r.BufferApiView=class{constructor(o,p){this._buffer=o,this.type=p}init(o){return this._buffer=o,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(o){const p=this._buffer.lines.get(o);if(p)return new c.BufferLineApiView(p)}getNullCell(){return new d.CellData}}},3785:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const c=i(511);r.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,o){if(!(d<0||d>=this._line.length))return o?(this._line.loadCell(d,o),o):this._line.loadCell(d,new c.CellData)}translateToString(d,o,p){return this._line.translateToString(d,o,p)}}},8285:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const c=i(8771),d=i(8460),o=i(844);class p extends o.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new d.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)}}r.BufferNamespaceApi=p},7975:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,c){return this._core.registerCsiHandler(i,(d=>c(d.toArray())))}addCsiHandler(i,c){return this.registerCsiHandler(i,c)}registerDcsHandler(i,c){return this._core.registerDcsHandler(i,((d,o)=>c(d,o.toArray())))}addDcsHandler(i,c){return this.registerDcsHandler(i,c)}registerEscHandler(i,c){return this._core.registerEscHandler(i,c)}addEscHandler(i,c){return this.registerEscHandler(i,c)}registerOscHandler(i,c){return this._core.registerOscHandler(i,c)}addOscHandler(i,c){return this.registerOscHandler(i,c)}}},7090:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(C,r,i){var c=this&&this.__decorate||function(n,f,h,u){var v,x=arguments.length,w=x<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(x<3?v(w):x>3?v(f,h,w):v(f,h))||w);return x>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const o=i(8460),p=i(844),g=i(5295),S=i(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let _=r.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new o.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new g.BufferSet(n,this))}resize(n,f){this.cols=n,this.rows=f,this.buffers.resize(n,f),this._onResize.fire({cols:n,rows:f})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,f=!1){const h=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===n.fg&&u.getBg(0)===n.bg||(u=h.getBlankLine(n,f),this._cachedBlankLine=u),u.isWrapped=f;const v=h.ybase+h.scrollTop,x=h.ybase+h.scrollBottom;if(h.scrollTop===0){const w=h.lines.isFull;x===h.lines.length-1?w?h.lines.recycle().copyFrom(u):h.lines.push(u.clone()):h.lines.splice(x+1,0,u.clone()),w?this.isUserScrolling&&(h.ydisp=Math.max(h.ydisp-1,0)):(h.ybase++,this.isUserScrolling||h.ydisp++)}else{const w=x-v+1;h.lines.shiftElements(v+1,w-1,-1),h.lines.set(x,u.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(n,f,h){const u=this.buffer;if(n<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else n+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const v=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+n,u.ybase),0),v!==u.ydisp&&(f||this._onScroll.fire(u.ydisp))}};r.BufferService=_=c([d(0,S.IOptionsService)],_)},7994:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,c){this._charsets[i]=c,this.glevel===i&&(this.charset=c)}}},1753:function(C,r,i){var c=this&&this.__decorate||function(u,v,x,w){var k,y=arguments.length,E=y<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,v,x,w);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(E=(y<3?k(E):y>3?k(v,x,E):k(v,x))||E);return y>3&&E&&Object.defineProperty(v,x,E),E},d=this&&this.__param||function(u,v){return function(x,w){v(x,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const o=i(2585),p=i(8460),g=i(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function _(u,v){let x=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(x|=64,x|=u.action):(x|=3&u.button,4&u.button&&(x|=64),8&u.button&&(x|=128),u.action===32?x|=32:u.action!==0||v||(x|=3)),x}const n=String.fromCharCode,f={DEFAULT:u=>{const v=[_(u,!1)+32,u.col+32,u.row+32];return v[0]>255||v[1]>255||v[2]>255?"":`\x1B[M${n(v[0])}${n(v[1])}${n(v[2])}`},SGR:u=>{const v=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.col};${u.row}${v}`},SGR_PIXELS:u=>{const v=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.x};${u.y}${v}`}};let h=r.CoreMouseService=class extends g.Disposable{constructor(u,v){super(),this._bufferService=u,this._coreService=v,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 x of Object.keys(S))this.addProtocol(x,S[x]);for(const x of Object.keys(f))this.addEncoding(x,f[x]);this.reset()}addProtocol(u,v){this._protocols[u]=v}addEncoding(u,v){this._encodings[u]=v}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const v=this._encodings[this._activeEncoding](u);return v&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(v):this._coreService.triggerDataEvent(v,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,v,x){if(x){if(u.x!==v.x||u.y!==v.y)return!1}else if(u.col!==v.col||u.row!==v.row)return!1;return u.button===v.button&&u.action===v.action&&u.ctrl===v.ctrl&&u.alt===v.alt&&u.shift===v.shift}};r.CoreMouseService=h=c([d(0,o.IBufferService),d(1,o.ICoreService)],h)},6975:function(C,r,i){var c=this&&this.__decorate||function(h,u,v,x){var w,k=arguments.length,y=k<3?u:x===null?x=Object.getOwnPropertyDescriptor(u,v):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(h,u,v,x);else for(var E=h.length-1;E>=0;E--)(w=h[E])&&(y=(k<3?w(y):k>3?w(u,v,y):w(u,v))||y);return k>3&&y&&Object.defineProperty(u,v,y),y},d=this&&this.__param||function(h,u){return function(v,x){u(v,x,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const o=i(1439),p=i(8460),g=i(844),S=i(2585),_=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let f=r.CoreService=class extends g.Disposable{constructor(h,u,v){super(),this._bufferService=h,this._logService=u,this._optionsService=v,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,o.clone)(_),this.decPrivateModes=(0,o.clone)(n)}reset(){this.modes=(0,o.clone)(_),this.decPrivateModes=(0,o.clone)(n)}triggerDataEvent(h,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const v=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&v.ybase!==v.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`,(()=>h.split("").map((x=>x.charCodeAt(0))))),this._onData.fire(h)}triggerBinaryEvent(h){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${h}"`,(()=>h.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(h))}};r.CoreService=f=c([d(0,S.IBufferService),d(1,S.ILogService),d(2,S.IOptionsService)],f)},9074:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const c=i(8055),d=i(8460),o=i(844),p=i(6106);let g=0,S=0;class _ extends o.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((h=>h?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,o.toDisposable)((()=>this.reset())))}registerDecoration(h){if(h.marker.isDisposed)return;const u=new n(h);if(u){const v=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),v.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const h of this._decorations.values())h.dispose();this._decorations.clear()}*getDecorationsAtCell(h,u,v){var x,w,k;let y=0,E=0;for(const j of this._decorations.getKeyIterator(u))y=(x=j.options.x)!==null&&x!==void 0?x:0,E=y+((w=j.options.width)!==null&&w!==void 0?w:1),h>=y&&h<E&&(!v||((k=j.options.layer)!==null&&k!==void 0?k:"bottom")===v)&&(yield j)}forEachDecorationAtCell(h,u,v,x){this._decorations.forEachByKey(u,(w=>{var k,y,E;g=(k=w.options.x)!==null&&k!==void 0?k:0,S=g+((y=w.options.width)!==null&&y!==void 0?y:1),h>=g&&h<S&&(!v||((E=w.options.layer)!==null&&E!==void 0?E:"bottom")===v)&&x(w)}))}}r.DecorationService=_;class n extends o.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(h){super(),this.options=h,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=h.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const c=i(2585),d=i(8343);class o{constructor(...g){this._entries=new Map;for(const[S,_]of g)this.set(S,_)}set(g,S){const _=this._entries.get(g);return this._entries.set(g,S),_}forEach(g){for(const[S,_]of this._entries.entries())g(S,_)}has(g){return this._entries.has(g)}get(g){return this._entries.get(g)}}r.ServiceCollection=o,r.InstantiationService=class{constructor(){this._services=new o,this._services.set(c.IInstantiationService,this)}setService(p,g){this._services.set(p,g)}getService(p){return this._services.get(p)}createInstance(p,...g){const S=(0,d.getServiceDependencies)(p).sort(((f,h)=>f.index-h.index)),_=[];for(const f of S){const h=this._services.get(f.id);if(!h)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${f.id}.`);_.push(h)}const n=S.length>0?S[0].index:g.length;if(g.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${g.length} static arguments`);return new p(...g,..._)}}},7866:function(C,r,i){var c=this&&this.__decorate||function(n,f,h,u){var v,x=arguments.length,w=x<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(x<3?v(w):x>3?v(f,h,w):v(f,h))||w);return x>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const o=i(844),p=i(2585),g={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let S,_=r.LogService=class extends o.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=g[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let f=0;f<n.length;f++)typeof n[f]=="function"&&(n[f]=n[f]())}_log(n,f,h){this._evalLazyOptionalParams(h),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+f,...h)}trace(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,f)}debug(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,f)}info(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.INFO&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,n,f)}warn(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.WARN&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,n,f)}error(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,n,f)}};r.LogService=_=c([d(0,p.IOptionsService)],_),r.setTraceLogger=function(n){S=n},r.traceCall=function(n,f,h){if(typeof h.value!="function")throw new Error("not supported");const u=h.value;h.value=function(...v){if(S.logLevel!==p.LogLevelEnum.TRACE)return u.apply(this,v);S.trace(`GlyphRenderer#${u.name}(${v.map((w=>JSON.stringify(w))).join(", ")})`);const x=u.apply(this,v);return S.trace(`GlyphRenderer#${u.name} return`,x),x}}},7302:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const c=i(8460),d=i(844),o=i(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:o.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class g extends d.Disposable{constructor(_){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},r.DEFAULT_OPTIONS);for(const f in _)if(f in n)try{const h=_[f];n[f]=this._sanitizeAndValidateOption(f,h)}catch(h){console.error(h)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(_,n){return this.onOptionChange((f=>{f===_&&n(this.rawOptions[_])}))}onMultipleOptionChange(_,n){return this.onOptionChange((f=>{_.indexOf(f)!==-1&&n()}))}_setupOptions(){const _=f=>{if(!(f in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);return this.rawOptions[f]},n=(f,h)=>{if(!(f in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);h=this._sanitizeAndValidateOption(f,h),this.rawOptions[f]!==h&&(this.rawOptions[f]=h,this._onOptionChange.fire(f))};for(const f in this.rawOptions){const h={get:_.bind(this,f),set:n.bind(this,f)};Object.defineProperty(this.options,f,h)}}_sanitizeAndValidateOption(_,n){switch(_){case"cursorStyle":if(n||(n=r.DEFAULT_OPTIONS[_]),!(function(f){return f==="block"||f==="underline"||f==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${_}`);break;case"wordSeparator":n||(n=r.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:r.DEFAULT_OPTIONS[_];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${_} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${_} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}r.OptionsService=g},2660:function(C,r,i){var c=this&&this.__decorate||function(g,S,_,n){var f,h=arguments.length,u=h<3?S:n===null?n=Object.getOwnPropertyDescriptor(S,_):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(g,S,_,n);else for(var v=g.length-1;v>=0;v--)(f=g[v])&&(u=(h<3?f(u):h>3?f(S,_,u):f(S,_))||u);return h>3&&u&&Object.defineProperty(S,_,u),u},d=this&&this.__param||function(g,S){return function(_,n){S(_,n,g)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const o=i(2585);let p=r.OscLinkService=class{constructor(g){this._bufferService=g,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(g){const S=this._bufferService.buffer;if(g.id===void 0){const v=S.addMarker(S.ybase+S.y),x={data:g,id:this._nextId++,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(x,v))),this._dataByLinkId.set(x.id,x),x.id}const _=g,n=this._getEntryIdKey(_),f=this._entriesWithId.get(n);if(f)return this.addLineToLink(f.id,S.ybase+S.y),f.id;const h=S.addMarker(S.ybase+S.y),u={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[h]};return h.onDispose((()=>this._removeMarkerFromLink(u,h))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(g,S){const _=this._dataByLinkId.get(g);if(_&&_.lines.every((n=>n.line!==S))){const n=this._bufferService.buffer.addMarker(S);_.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(_,n)))}}getLinkData(g){var S;return(S=this._dataByLinkId.get(g))===null||S===void 0?void 0:S.data}_getEntryIdKey(g){return`${g.id};;${g.uri}`}_removeMarkerFromLink(g,S){const _=g.lines.indexOf(S);_!==-1&&(g.lines.splice(_,1),g.lines.length===0&&(g.data.id!==void 0&&this._entriesWithId.delete(g.key),this._dataByLinkId.delete(g.id)))}};r.OscLinkService=p=c([d(0,o.IBufferService)],p)},8343:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const i="di$target",c="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(d){return d[c]||[]},r.createDecorator=function(d){if(r.serviceRegistry.has(d))return r.serviceRegistry.get(d);const o=function(p,g,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,n,f){n[i]===n?n[c].push({id:_,index:f}):(n[c]=[{id:_,index:f}],n[i]=n)})(o,p,S)};return o.toString=()=>d,r.serviceRegistry.set(d,o),o}},2585:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;const c=i(8343);var d;r.IBufferService=(0,c.createDecorator)("BufferService"),r.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),r.ICoreService=(0,c.createDecorator)("CoreService"),r.ICharsetService=(0,c.createDecorator)("CharsetService"),r.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(o){o[o.TRACE=0]="TRACE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.ERROR=4]="ERROR",o[o.OFF=5]="OFF"})(d||(r.LogLevelEnum=d={})),r.ILogService=(0,c.createDecorator)("LogService"),r.IOptionsService=(0,c.createDecorator)("OptionsService"),r.IOscLinkService=(0,c.createDecorator)("OscLinkService"),r.IUnicodeService=(0,c.createDecorator)("UnicodeService"),r.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const c=i(8460),d=i(225);r.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const o=new d.UnicodeV6;this.register(o),this._active=o.version,this._activeProvider=o}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(o){if(!this._providers[o])throw new Error(`unknown Unicode version "${o}"`);this._active=o,this._activeProvider=this._providers[o],this._onChange.fire(o)}register(o){this._providers[o.version]=o}wcwidth(o){return this._activeProvider.wcwidth(o)}getStringCellWidth(o){let p=0;const g=o.length;for(let S=0;S<g;++S){let _=o.charCodeAt(S);if(55296<=_&&_<=56319){if(++S>=g)return p+this.wcwidth(_);const n=o.charCodeAt(S);56320<=n&&n<=57343?_=1024*(_-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(_)}return p}}}},l={};function m(C){var r=l[C];if(r!==void 0)return r.exports;var i=l[C]={exports:{}};return s[C].call(i.exports,i,i.exports,m),i.exports}var b={};return(()=>{var C=b;Object.defineProperty(C,"__esModule",{value:!0}),C.Terminal=void 0;const r=m(9042),i=m(3236),c=m(844),d=m(5741),o=m(8285),p=m(7975),g=m(7090),S=["cols","rows"];class _ extends c.Disposable{constructor(f){super(),this._core=this.register(new i.Terminal(f)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const h=v=>this._core.options[v],u=(v,x)=>{this._checkReadonlyOptions(v),this._core.options[v]=x};for(const v in this._core.options){const x={get:h.bind(this,v),set:u.bind(this,v)};Object.defineProperty(this._publicOptions,v,x)}}_checkReadonlyOptions(f){if(S.includes(f))throw new Error(`Option "${f}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new g.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new o.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const f=this._core.coreService.decPrivateModes;let h="none";switch(this._core.coreMouseService.activeProtocol){case"X10":h="x10";break;case"VT200":h="vt200";break;case"DRAG":h="drag";break;case"ANY":h="any"}return{applicationCursorKeysMode:f.applicationCursorKeys,applicationKeypadMode:f.applicationKeypad,bracketedPasteMode:f.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:h,originMode:f.origin,reverseWraparoundMode:f.reverseWraparound,sendFocusMode:f.sendFocus,wraparoundMode:f.wraparound}}get options(){return this._publicOptions}set options(f){for(const h in f)this._publicOptions[h]=f[h]}blur(){this._core.blur()}focus(){this._core.focus()}resize(f,h){this._verifyIntegers(f,h),this._core.resize(f,h)}open(f){this._core.open(f)}attachCustomKeyEventHandler(f){this._core.attachCustomKeyEventHandler(f)}registerLinkProvider(f){return this._core.registerLinkProvider(f)}registerCharacterJoiner(f){return this._checkProposedApi(),this._core.registerCharacterJoiner(f)}deregisterCharacterJoiner(f){this._checkProposedApi(),this._core.deregisterCharacterJoiner(f)}registerMarker(f=0){return this._verifyIntegers(f),this._core.registerMarker(f)}registerDecoration(f){var h,u,v;return this._checkProposedApi(),this._verifyPositiveIntegers((h=f.x)!==null&&h!==void 0?h:0,(u=f.width)!==null&&u!==void 0?u:0,(v=f.height)!==null&&v!==void 0?v:0),this._core.registerDecoration(f)}hasSelection(){return this._core.hasSelection()}select(f,h,u){this._verifyIntegers(f,h,u),this._core.select(f,h,u)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(f,h){this._verifyIntegers(f,h),this._core.selectLines(f,h)}dispose(){super.dispose()}scrollLines(f){this._verifyIntegers(f),this._core.scrollLines(f)}scrollPages(f){this._verifyIntegers(f),this._core.scrollPages(f)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(f){this._verifyIntegers(f),this._core.scrollToLine(f)}clear(){this._core.clear()}write(f,h){this._core.write(f,h)}writeln(f,h){this._core.write(f),this._core.write(`\r
19
- `,h)}paste(f){this._core.paste(f)}refresh(f,h){this._verifyIntegers(f,h),this._core.refresh(f,h)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(f){this._addonManager.loadAddon(this,f)}static get strings(){return r}_verifyIntegers(...f){for(const h of f)if(h===1/0||isNaN(h)||h%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...f){for(const h of f)if(h&&(h===1/0||isNaN(h)||h%1!=0||h<0))throw new Error("This API only accepts positive integers")}}C.Terminal=_})(),b})()))})(Ys)),Ys.exports}var Hc=Fc();var zc=2,Wc=1,$c=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"))),b=window.getComputedStyle(this._terminal.element),C={top:parseInt(b.getPropertyValue("padding-top")),bottom:parseInt(b.getPropertyValue("padding-bottom")),right:parseInt(b.getPropertyValue("padding-right")),left:parseInt(b.getPropertyValue("padding-left"))},r=C.top+C.bottom,i=C.right+C.left,c=l-r,d=m-i-t;return{cols:Math.max(zc,Math.floor(d/e.css.cell.width)),rows:Math.max(Wc,Math.floor(c/e.css.cell.height))}}};function Uc(e={}){const{cwd:t,cols:s,rows:l,onOutput:m,onExit:b}=e,[C,r]=R.useState(null),[i,c]=R.useState(()=>dt.isConnected()),[d,o]=R.useState(!1),[p,g]=R.useState(!1),[S,_]=R.useState(!1),n=R.useRef({onOutput:m,onExit:b});n.current={onOutput:m,onExit:b};const f=R.useRef(null);f.current=C,R.useEffect(()=>{if(!C)return;const w=dt.getSocket(),k=()=>{c(!0),o(!1),r(null),_(!0)},y=()=>{c(!1),o(!1)},E=N=>{N.terminalId===C&&n.current.onOutput?.(N.data)},j=N=>{N.terminalId===C&&(o(!1),n.current.onExit?.(N.exitCode),r(null))},A=N=>{N.terminalId===C&&o(!0)},L=N=>{N.terminalId===C&&o(!1)};return w.on("connect",k),w.on("disconnect",y),w.on(Oe.TERMINAL_STDOUT,E),w.on(Oe.TERMINAL_EXIT,j),w.on(Oe.TERMINAL_SUBSCRIBED,A),w.on(Oe.TERMINAL_UNSUBSCRIBED,L),c(w.connected),w.connected&&w.emit(ot.SUBSCRIBE,{topic:"terminal",id:C},N=>{N.success&&o(!0)}),()=>{w.off("connect",k),w.off("disconnect",y),w.off(Oe.TERMINAL_STDOUT,E),w.off(Oe.TERMINAL_EXIT,j),w.off(Oe.TERMINAL_SUBSCRIBED,A),w.off(Oe.TERMINAL_UNSUBSCRIBED,L),w.emit(ot.UNSUBSCRIBE,{topic:"terminal",id:C})}},[C]);const h=R.useCallback(async()=>{const w=dt.getSocket();if(!w.connected)return null;g(!0);try{const k=await ve.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:l});return r(k.terminalId),_(!1),k.terminalId}catch(k){return console.error("[useStandaloneTerminal] Failed to create terminal:",k),null}finally{g(!1)}},[t,s,l]),u=R.useCallback(async()=>{const w=f.current;if(w){try{await ve.delete(`/terminals/${w}`)}catch(k){console.error("[useStandaloneTerminal] Failed to destroy terminal:",k)}r(null),o(!1)}},[]),v=R.useCallback(w=>{const k=f.current;if(!k)return;dt.getSocket().emit(ot.TERMINAL_INPUT,{terminalId:k,data:w})},[]),x=R.useCallback((w,k)=>{const y=f.current;if(!y)return;dt.getSocket().emit(ot.TERMINAL_RESIZE,{terminalId:y,cols:w,rows:k})},[]);return R.useEffect(()=>()=>{const w=f.current;w&&ve.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:C,isConnected:i,isAttached:d,isCreating:p,needsRecreate:S,create:h,destroy:u,sendInput:v,resize:x}}const Kc={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"},qc=ee.memo(function({cwd:t,onExit:s,onReady:l}){const m=R.useRef(null),b=R.useRef(null),C=R.useRef(null),r=R.useRef(!1),{terminalId:i,isAttached:c,needsRecreate:d,create:o,sendInput:p,resize:g}=Uc({cwd:t,onOutput:R.useCallback(S=>{b.current?.write(S)},[]),onExit:R.useCallback(S=>{b.current?.writeln(`\r
20
- \x1B[90m[Process exited with code ${S}]\x1B[0m`),s?.(S)},[s])});return R.useEffect(()=>{if(!d)return;const S=b.current;S&&S.writeln(`\r
21
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),o()},[d,o]),R.useLayoutEffect(()=>{if(!m.current)return;const S=new Hc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Kc,scrollback:5e3,convertEol:!0}),_=new $c;S.loadAddon(_),S.open(m.current);const n=(f=0)=>{if(!(f>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>n(f+1),50);return}_.fit(),g(S.cols,S.rows)}catch{setTimeout(()=>n(f+1),50)}};return n(0),setTimeout(()=>n(1),100),b.current=S,C.current=_,()=>{S.dispose(),b.current=null,C.current=null}},[g]),R.useEffect(()=>{r.current||(r.current=!0,o())},[o]),R.useEffect(()=>{const S=b.current;if(!S||!c)return;const _=S.onData(n=>{p(n)});return()=>_.dispose()},[p,c]),R.useEffect(()=>{c&&l?.({sendInput:p})},[c,p,l]),R.useEffect(()=>{if(!m.current)return;const S=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const _=C.current,n=b.current,f=m.current;_&&n&&f&&f.clientWidth>0&&f.clientHeight>0&&(_.fit(),g(n.cols,n.rows))}catch{}})});return S.observe(m.current),()=>S.disconnect()},[g]),a.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!i&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),a.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Xc=ee.memo(function({commands:t,onSelect:s}){const[l,m]=R.useState(!1),b=R.useRef(null),C=R.useRef(null);return R.useEffect(()=>{if(!l)return;const r=i=>{b.current&&!b.current.contains(i.target)&&C.current&&!C.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[l]),t.length===0?null:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),a.jsxs("div",{className:"relative",children:[a.jsxs("button",{ref:C,onClick:()=>m(!l),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${l?"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:[a.jsx(Ua,{size:12}),a.jsx("span",{children:"快捷命令"}),a.jsx(pt,{size:10,className:`transition-transform ${l?"rotate-180":""}`})]}),l&&a.jsx("div",{ref:b,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:a.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((r,i)=>a.jsxs("button",{onClick:()=>{s(r.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[a.jsx(At,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:r.name}),a.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:r.command})]})]},i))})})]})]})});let Yc=0;function ci(){return`shell-${++Yc}`}const Vc=ee.memo(function({cwd:t,quickCommands:s=[]}){const[l,m]=R.useState(()=>[{id:ci(),label:"Shell 1"}]),[b,C]=R.useState(()=>l[0].id),r=R.useRef(new Map),i=R.useCallback(()=>{const g=ci(),S={id:g,label:`Shell ${l.length+1}`};m(_=>[..._,S]),C(g)},[l.length]),c=R.useCallback((g,S)=>{S.stopPropagation(),r.current.delete(g),m(_=>{const n=_.filter(f=>f.id!==g);return g===b&&n.length>0&&C(n[n.length-1].id),n})},[b]),d=R.useCallback(g=>{r.current.delete(g),m(S=>{const _=S.filter(n=>n.id!==g);return g===b&&_.length>0&&C(_[_.length-1].id),_})},[b]),o=R.useCallback((g,S)=>{r.current.set(g,S.sendInput)},[]),p=R.useCallback(g=>{const S=r.current.get(b);S&&S(g+"\r")},[b]);return a.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[a.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[a.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:l.map(g=>a.jsxs("button",{onClick:()=>C(g.id),className:Se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",g.id===b?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[a.jsx(vs,{size:11,className:"shrink-0"}),a.jsx("span",{children:g.label}),l.length>1&&a.jsx("span",{onClick:S=>c(g.id,S),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a.jsx(Ts,{size:10})})]},g.id))}),a.jsx("button",{onClick:i,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:"New Terminal",children:a.jsx(ir,{size:14})}),s.length>0&&a.jsx(Xc,{commands:s,onSelect:p})]}),a.jsx("div",{className:"flex-1 overflow-hidden relative",children:l.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(vs,{size:28}),a.jsx("span",{className:"text-xs",children:"No terminals open"}),a.jsx("button",{onClick:i,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:"New Terminal"})]})}):l.map(g=>a.jsx("div",{className:"absolute inset-0",style:{display:g.id===b?"block":"none"},children:a.jsx(qc,{cwd:t,onExit:()=>d(g.id),onReady:S=>o(g.id,S)})},g.id))})]})});function hi(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 Gc(e){if(Array.isArray(e))return e}function Qc(e,t,s){return(t=ih(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Zc(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,m,b,C,r=[],i=!0,c=!1;try{if(b=(s=s.call(e)).next,t!==0)for(;!(i=(l=b.call(s)).done)&&(r.push(l.value),r.length!==t);i=!0);}catch(d){c=!0,m=d}finally{try{if(!i&&s.return!=null&&(C=s.return(),Object(C)!==C))return}finally{if(c)throw m}}return r}}function Jc(){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 ui(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 di(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ui(Object(s),!0).forEach(function(l){Qc(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ui(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function eh(e,t){if(e==null)return{};var s,l,m=th(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(l=0;l<b.length;l++)s=b[l],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(m[s]=e[s])}return m}function th(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 sh(e,t){return Gc(e)||Zc(e,t)||nh(e,t)||Jc()}function rh(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 ih(e){var t=rh(e,"string");return typeof t=="symbol"?t:t+""}function nh(e,t){if(e){if(typeof e=="string")return hi(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)?hi(e,t):void 0}}function oh(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function fi(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 pi(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?fi(Object(s),!0).forEach(function(l){oh(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):fi(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function ah(){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,b){return b(m)},l)}}function Ft(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),b=0;b<l;b++)m[b]=arguments[b];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function Cs(e){return{}.toString.call(e).includes("Object")}function lh(e){return!Object.keys(e).length}function Gt(e){return typeof e=="function"}function ch(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hh(e,t){return Cs(t)||_t("changeType"),Object.keys(t).some(function(s){return!ch(e,s)})&&_t("changeField"),t}function uh(e){Gt(e)||_t("selectorType")}function dh(e){Gt(e)||Cs(e)||_t("handlerType"),Cs(e)&&Object.values(e).some(function(t){return!Gt(t)})&&_t("handlersType")}function fh(e){e||_t("initialIsRequired"),Cs(e)||_t("initialType"),lh(e)&&_t("initialContent")}function ph(e,t){throw new Error(e[t]||e.default)}var mh={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"},_t=Ft(ph)(mh),hs={changes:hh,selector:uh,handler:dh,initial:fh};function vh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hs.initial(e),hs.handler(t);var s={current:e},l=Ft(bh)(s,t),m=Ft(_h)(s),b=Ft(hs.changes)(e),C=Ft(gh)(s);function r(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return hs.selector(c),c(s.current)}function i(c){ah(l,m,b,C)(c)}return[r,i]}function gh(e,t){return Gt(t)?t(e.current):t}function _h(e,t){return e.current=pi(pi({},e.current),t),t}function bh(e,t,s){return Gt(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 xh={create:vh},Sh={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function yh(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),b=0;b<l;b++)m[b]=arguments[b];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function Ch(e){return{}.toString.call(e).includes("Object")}function wh(e){return e||mi("configIsRequired"),Ch(e)||mi("configType"),e.urls?(Eh(),{paths:{vs:e.urls.monacoBase}}):e}function Eh(){console.warn(Tn.deprecation)}function kh(e,t){throw new Error(e[t]||e.default)}var Tn={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
- `},mi=yh(kh)(Tn),Rh={config:wh},Dh=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(b,C){return C(b)},m)}};function jn(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],jn(e[s],t[s]))}),di(di({},e),t)}var Th={type:"cancelation",msg:"operation is manually canceled"};function Vs(e){var t=!1,s=new Promise(function(l,m){e.then(function(b){return t?m(Th):l(b)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var jh=["monaco"],Lh=xh.create({config:Sh,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ln=sh(Lh,2),rs=Ln[0],Is=Ln[1];function Ah(e){var t=Rh.config(e),s=t.monaco,l=eh(t,jh);Is(function(m){return{config:jn(m.config,l),monaco:s}})}function Nh(){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(Is({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Vs(Gs);if(window.monaco&&window.monaco.editor)return An(window.monaco),e.resolve(window.monaco),Vs(Gs);Dh(Mh,Oh)(Bh)}return Vs(Gs)}function Mh(e){return document.body.appendChild(e)}function Ph(e){var t=document.createElement("script");return e&&(t.src=e),t}function Oh(e){var t=rs(function(l){var m=l.config,b=l.reject;return{config:m,reject:b}}),s=Ph("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Bh(){var e=rs(function(s){var l=s.config,m=s.resolve,b=s.reject;return{config:l,resolve:m,reject:b}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var l=s.m||s;An(l),e.resolve(l)},function(s){e.reject(s)})}function An(e){rs().monaco||Is({monaco:e})}function Ih(){return rs(function(e){var t=e.monaco;return t})}var Gs=new Promise(function(e,t){return Is({resolve:e,reject:t})}),Nn={config:Ah,init:Nh,__getMonacoInstance:Ih},Fh={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Qs=Fh,Hh={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},zh=Hh;function Wh({children:e}){return ee.createElement("div",{style:zh.container},e)}var $h=Wh,Uh=$h;function Kh({width:e,height:t,isEditorReady:s,loading:l,_ref:m,className:b,wrapperProps:C}){return ee.createElement("section",{style:{...Qs.wrapper,width:e,height:t},...C},!s&&ee.createElement(Uh,null,l),ee.createElement("div",{ref:m,style:{...Qs.fullWidth,...!s&&Qs.hide},className:b}))}var qh=Kh,Mn=R.memo(qh);function Xh(e){R.useEffect(e,[])}var Pn=Xh;function Yh(e,t,s=!0){let l=R.useRef(!0);R.useEffect(l.current||!s?()=>{l.current=!1}:e,t)}var Qe=Yh;function $t(){}function jt(e,t,s,l){return Vh(e,l)||Gh(e,t,s,l)}function Vh(e,t){return e.editor.getModel(On(e,t))}function Gh(e,t,s,l){return e.editor.createModel(t,s,l?On(e,l):void 0)}function On(e,t){return e.Uri.parse(t)}function Qh({original:e,modified:t,language:s,originalLanguage:l,modifiedLanguage:m,originalModelPath:b,modifiedModelPath:C,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:i=!1,theme:c="light",loading:d="Loading...",options:o={},height:p="100%",width:g="100%",className:S,wrapperProps:_={},beforeMount:n=$t,onMount:f=$t}){let[h,u]=R.useState(!1),[v,x]=R.useState(!0),w=R.useRef(null),k=R.useRef(null),y=R.useRef(null),E=R.useRef(f),j=R.useRef(n),A=R.useRef(!1);Pn(()=>{let I=Nn.init();return I.then(H=>(k.current=H)&&x(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>w.current?B():I.cancel()}),Qe(()=>{if(w.current&&k.current){let I=w.current.getOriginalEditor(),H=jt(k.current,e||"",l||s||"text",b||"");H!==I.getModel()&&I.setModel(H)}},[b],h),Qe(()=>{if(w.current&&k.current){let I=w.current.getModifiedEditor(),H=jt(k.current,t||"",m||s||"text",C||"");H!==I.getModel()&&I.setModel(H)}},[C],h),Qe(()=>{let I=w.current.getModifiedEditor();I.getOption(k.current.editor.EditorOption.readOnly)?I.setValue(t||""):t!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[t],h),Qe(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],h),Qe(()=>{let{original:I,modified:H}=w.current.getModel();k.current.editor.setModelLanguage(I,l||s||"text"),k.current.editor.setModelLanguage(H,m||s||"text")},[s,l,m],h),Qe(()=>{k.current?.editor.setTheme(c)},[c],h),Qe(()=>{w.current?.updateOptions(o)},[o],h);let L=R.useCallback(()=>{if(!k.current)return;j.current(k.current);let I=jt(k.current,e||"",l||s||"text",b||""),H=jt(k.current,t||"",m||s||"text",C||"");w.current?.setModel({original:I,modified:H})},[s,t,m,e,l,b,C]),N=R.useCallback(()=>{!A.current&&y.current&&(w.current=k.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...o}),L(),k.current?.editor.setTheme(c),u(!0),A.current=!0)},[o,c,L]);R.useEffect(()=>{h&&E.current(w.current,k.current)},[h]),R.useEffect(()=>{!v&&!h&&N()},[v,h,N]);function B(){let I=w.current?.getModel();r||I?.original?.dispose(),i||I?.modified?.dispose(),w.current?.dispose()}return ee.createElement(Mn,{width:g,height:p,isEditorReady:h,loading:d,_ref:y,className:S,wrapperProps:_})}var Zh=Qh;R.memo(Zh);function Jh(e){let t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}var eu=Jh,us=new Map;function tu({defaultValue:e,defaultLanguage:t,defaultPath:s,value:l,language:m,path:b,theme:C="light",line:r,loading:i="Loading...",options:c={},overrideServices:d={},saveViewState:o=!0,keepCurrentModel:p=!1,width:g="100%",height:S="100%",className:_,wrapperProps:n={},beforeMount:f=$t,onMount:h=$t,onChange:u,onValidate:v=$t}){let[x,w]=R.useState(!1),[k,y]=R.useState(!0),E=R.useRef(null),j=R.useRef(null),A=R.useRef(null),L=R.useRef(h),N=R.useRef(f),B=R.useRef(),I=R.useRef(l),H=eu(b),W=R.useRef(!1),D=R.useRef(!1);Pn(()=>{let O=Nn.init();return O.then(U=>(E.current=U)&&y(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>j.current?P():O.cancel()}),Qe(()=>{let O=jt(E.current,e||l||"",t||m||"",b||s||"");O!==j.current?.getModel()&&(o&&us.set(H,j.current?.saveViewState()),j.current?.setModel(O),o&&j.current?.restoreViewState(us.get(b)))},[b],x),Qe(()=>{j.current?.updateOptions(c)},[c],x),Qe(()=>{!j.current||l===void 0||(j.current.getOption(E.current.editor.EditorOption.readOnly)?j.current.setValue(l):l!==j.current.getValue()&&(D.current=!0,j.current.executeEdits("",[{range:j.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),j.current.pushUndoStop(),D.current=!1))},[l],x),Qe(()=>{let O=j.current?.getModel();O&&m&&E.current?.editor.setModelLanguage(O,m)},[m],x),Qe(()=>{r!==void 0&&j.current?.revealLine(r)},[r],x),Qe(()=>{E.current?.editor.setTheme(C)},[C],x);let M=R.useCallback(()=>{if(!(!A.current||!E.current)&&!W.current){N.current(E.current);let O=b||s,U=jt(E.current,l||e||"",t||m||"",O||"");j.current=E.current?.editor.create(A.current,{model:U,automaticLayout:!0,...c},d),o&&j.current.restoreViewState(us.get(O)),E.current.editor.setTheme(C),r!==void 0&&j.current.revealLine(r),w(!0),W.current=!0}},[e,t,s,l,m,b,c,d,o,C,r]);R.useEffect(()=>{x&&L.current(j.current,E.current)},[x]),R.useEffect(()=>{!k&&!x&&M()},[k,x,M]),I.current=l,R.useEffect(()=>{x&&u&&(B.current?.dispose(),B.current=j.current?.onDidChangeModelContent(O=>{D.current||u(j.current.getValue(),O)}))},[x,u]),R.useEffect(()=>{if(x){let O=E.current.editor.onDidChangeMarkers(U=>{let X=j.current.getModel()?.uri;if(X&&U.find(Y=>Y.path===X.path)){let Y=E.current.editor.getModelMarkers({resource:X});v?.(Y)}});return()=>{O?.dispose()}}return()=>{}},[x,v]);function P(){B.current?.dispose(),p?o&&us.set(b,j.current.saveViewState()):j.current.getModel()?.dispose(),j.current.dispose()}return ee.createElement(Mn,{width:g,height:S,isEditorReady:x,loading:i,_ref:A,className:_,wrapperProps:n})}var su=tu,ru=R.memo(su),iu=ru,et=function(e,t){return Number(e.toFixed(t))},nu=function(e,t){return typeof e=="number"?e:t},De=function(e,t,s){s&&typeof s=="function"&&s(e,t)},ou=function(e){return-Math.cos(e*Math.PI)/2+.5},au=function(e){return e},lu=function(e){return e*e},cu=function(e){return e*(2-e)},hu=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},uu=function(e){return e*e*e},du=function(e){return--e*e*e+1},fu=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},pu=function(e){return e*e*e*e},mu=function(e){return 1- --e*e*e*e},vu=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},gu=function(e){return e*e*e*e*e},_u=function(e){return 1+--e*e*e*e*e},bu=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Bn={easeOut:ou,linear:au,easeInQuad:lu,easeOutQuad:cu,easeInOutQuad:hu,easeInCubic:uu,easeOutCubic:du,easeInOutCubic:fu,easeInQuart:pu,easeOutQuart:mu,easeInOutQuart:vu,easeInQuint:gu,easeOutQuint:_u,easeInOutQuint:bu},In=function(e){typeof e=="number"&&cancelAnimationFrame(e)},st=function(e){e.mounted&&(In(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Fn(e,t,s,l){if(e.mounted){var m=new Date().getTime(),b=1;st(e),e.animation=function(){if(!e.mounted)return In(e.animation);var C=new Date().getTime()-m,r=C/s,i=Bn[t],c=i(r);C>=s?(l(b),e.animation=null):e.animation&&(l(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function xu(e){var t=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(l))}function St(e,t,s,l){var m=xu(t);if(!(!e.mounted||!m)){var b=e.setTransformState,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,d=t.scale-r,o=t.positionX-i,p=t.positionY-c;s===0?b(t.scale,t.positionX,t.positionY):Fn(e,l,s,function(g){var S=r+d*g,_=i+o*g,n=c+p*g;b(S,_,n)})}}function Su(e,t,s){var l=e.offsetWidth,m=e.offsetHeight,b=t.offsetWidth,C=t.offsetHeight,r=b*s,i=C*s,c=l-r,d=m-i;return{wrapperWidth:l,wrapperHeight:m,newContentWidth:r,newDiffWidth:c,newContentHeight:i,newDiffHeight:d}}var yu=function(e,t,s,l,m,b,C){var r=e>t?s*(C?1:.5):0,i=l>m?b*(C?1:.5):0,c=e-t-r,d=r,o=l-m-i,p=i;return{minPositionX:c,maxPositionX:d,minPositionY:o,maxPositionY:p}},jr=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 b=Su(s,l,t),C=b.wrapperWidth,r=b.wrapperHeight,i=b.newContentWidth,c=b.newDiffWidth,d=b.newContentHeight,o=b.newDiffHeight,p=yu(C,i,c,r,d,o,!!m);return p},lr=function(e,t,s,l){return l?e<t?et(t,2):e>s?et(s,2):et(e,2):et(e,2)},wt=function(e,t){var s=jr(e,t);return e.bounds=s,s};function is(e,t,s,l,m,b,C){var r=s.minPositionX,i=s.minPositionY,c=s.maxPositionX,d=s.maxPositionY,o=0,p=0;C&&(o=m,p=b);var g=lr(e,r-o,c+o,l),S=lr(t,i-p,d+p,l);return{x:g,y:S}}function Fs(e,t,s,l,m,b){var C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,d=l-r;if(typeof t!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:c};var o=i-t*d,p=c-s*d,g=is(o,p,m,b,0,0,null);return g}function ns(e,t,s,l,m){var b=m?l:0,C=t-b;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=C?C:e}var vi=function(e,t){var s=e.setup.panning.excluded,l=e.isInitialized,m=e.wrapperComponent,b=t.target,C="shadowRoot"in b&&"composedPath"in t,r=C?t.composedPath().some(function(d){return d instanceof Element?m?.contains(d):!1}):m?.contains(b),i=l&&b&&r;if(!i)return!1;var c=Hs(b,s);return!c},gi=function(e){var t=e.isInitialized,s=e.isPanning,l=e.setup,m=l.panning.disabled,b=t&&s&&!m;return!!b},Cu=function(e,t){var s=e.transformState,l=s.positionX,m=s.positionY;e.isPanning=!0;var b=t.clientX,C=t.clientY;e.startCoords={x:b-l,y:C-m}},wu=function(e,t){var s=t.touches,l=e.transformState,m=l.positionX,b=l.positionY;e.isPanning=!0;var C=s.length===1;if(C){var r=s[0].clientX,i=s[0].clientY;e.startCoords={x:r-m,y:i-b}}};function Eu(e){var t=e.transformState,s=t.positionX,l=t.positionY,m=t.scale,b=e.setup,C=b.disabled,r=b.limitToBounds,i=b.centerZoomedOut,c=e.wrapperComponent;if(!(C||!c||!e.bounds)){var d=e.bounds,o=d.maxPositionX,p=d.minPositionX,g=d.maxPositionY,S=d.minPositionY,_=s>o||s<p,n=l>g||l<S,f=s>o?c.offsetWidth:e.setup.minPositionX||0,h=l>g?c.offsetHeight:e.setup.minPositionY||0,u=Fs(e,f,h,m,e.bounds,r||i),v=u.x,x=u.y;return{scale:m,positionX:_?v:s,positionY:n?x:l}}}function Hn(e,t,s,l,m){var b=e.setup.limitToBounds,C=e.wrapperComponent,r=e.bounds,i=e.transformState,c=i.scale,d=i.positionX,o=i.positionY;if(!(C===null||r===null||t===d&&s===o)){var p=is(t,s,r,b,l,m,C),g=p.x,S=p.y;e.setTransformState(c,g,S)}}var ku=function(e,t,s){var l=e.startCoords,m=e.transformState,b=e.setup.panning,C=b.lockAxisX,r=b.lockAxisY,i=m.positionX,c=m.positionY;if(!l)return{x:i,y:c};var d=t-l.x,o=s-l.y,p=C?i:d,g=r?c:o;return{x:p,y:g}},xt=function(e,t){var s=e.setup,l=e.transformState,m=l.scale,b=s.minScale,C=s.disablePadding;return t>0&&m>=b&&!C?t:0},Ru=function(e){var t=e.mounted,s=e.setup,l=s.disabled,m=s.velocityAnimation,b=e.transformState.scale,C=m.disabled,r=!C||b>1||!l||t;return!!r},Du=function(e){var t=e.mounted,s=e.velocity,l=e.bounds,m=e.setup,b=m.disabled,C=m.velocityAnimation,r=e.transformState.scale,i=C.disabled,c=!i||r>1||!b||t;return!(!c||!s||!l)};function Tu(e,t){var s=e.setup.velocityAnimation,l=s.equalToMove,m=s.animationTime,b=s.sensitivity;return l?m*t*b:m}function _i(e,t,s,l,m,b,C,r,i,c){if(m){if(t>C&&s>C){var d=C+(e-C)*c;return d>i?i:d<C?C:d}if(t<b&&s<b){var d=b+(e-b)*c;return d<r?r:d>b?b:d}}return l?t:lr(e,b,C,m)}function ju(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function Lu(e,t){var s=Ru(e);if(s){var l=e.lastMousePosition,m=e.velocityTime,b=e.setup,C=e.wrapperComponent,r=b.velocityAnimation.equalToMove,i=Date.now();if(l&&m&&C){var c=ju(C,r),d=t.x-l.x,o=t.y-l.y,p=d/c,g=o/c,S=i-m,_=d*d+o*o,n=Math.sqrt(_)/S;e.velocity={velocityX:p,velocityY:g,total:n}}e.lastMousePosition=t,e.velocityTime=i}}function Au(e){var t=e.velocity,s=e.bounds,l=e.setup,m=e.wrapperComponent,b=Du(e);if(!(!b||!t||!s||!m)){var C=t.velocityX,r=t.velocityY,i=t.total,c=s.maxPositionX,d=s.minPositionX,o=s.maxPositionY,p=s.minPositionY,g=l.limitToBounds,S=l.alignmentAnimation,_=l.zoomAnimation,n=l.panning,f=n.lockAxisY,h=n.lockAxisX,u=_.animationType,v=S.sizeX,x=S.sizeY,w=S.velocityAlignmentTime,k=w,y=Tu(e,i),E=Math.max(y,k),j=xt(e,v),A=xt(e,x),L=j*m.offsetWidth/100,N=A*m.offsetHeight/100,B=c+L,I=d-L,H=o+N,W=p-N,D=e.transformState,M=new Date().getTime();Fn(e,u,E,function(P){var O=e.transformState,U=O.scale,X=O.positionX,Y=O.positionY,Q=new Date().getTime()-M,oe=Q/k,T=Bn[S.animationType],F=1-T(Math.min(1,oe)),$=1-P,z=X+C*$,Z=Y+r*$,q=_i(z,D.positionX,X,h,g,d,c,I,B,F),ne=_i(Z,D.positionY,Y,f,g,p,o,W,H,F);(X!==z||Y!==Z)&&e.setTransformState(U,q,ne)})}}function bi(e,t){var s=e.transformState.scale;st(e),wt(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?wu(e,t):Cu(e,t)}function Lr(e,t){var s=e.transformState.scale,l=e.setup,m=l.minScale,b=l.alignmentAnimation,C=b.disabled,r=b.sizeX,i=b.sizeY,c=b.animationTime,d=b.animationType,o=C||s<m||!r&&!i;if(!o){var p=Eu(e);p&&St(e,p,t??c,d)}}function xi(e,t,s){var l=e.startCoords,m=e.setup,b=m.alignmentAnimation,C=b.sizeX,r=b.sizeY;if(l){var i=ku(e,t,s),c=i.x,d=i.y,o=xt(e,C),p=xt(e,r);Lu(e,{x:c,y:d}),Hn(e,c,d,o,p)}}function Nu(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 b=l?.getBoundingClientRect(),C=m?.getBoundingClientRect(),r=b?.width||0,i=b?.height||0,c=C?.width||0,d=C?.height||0,o=r<c||i<d,p=!t&&s&&s?.total>.1&&o;p?Au(e):Lr(e)}}function Ar(e,t,s,l){var m=e.setup,b=m.minScale,C=m.maxScale,r=m.limitToBounds,i=ns(et(t,2),b,C,0,!1),c=wt(e,i),d=Fs(e,s,l,i,c,r),o=d.x,p=d.y;return{scale:i,positionX:o,positionY:p}}function zn(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,b=e.setup,C=b.minScale,r=b.limitToBounds,i=b.zoomAnimation,c=i.disabled,d=i.animationTime,o=i.animationType,p=c||l>=C;if((l>=1||r)&&Lr(e),!(p||!m||!e.mounted)){var g=t||m.offsetWidth/2,S=s||m.offsetHeight/2,_=Ar(e,C,g,S);_&&St(e,_,d,o)}}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 b in s)Object.prototype.hasOwnProperty.call(s,b)&&(t[b]=s[b])}return t},bt.apply(this,arguments)};function Si(e,t,s){for(var l=0,m=t.length,b;l<m;l++)(b||!(l in t))&&(b||(b=Array.prototype.slice.call(t,0,l)),b[l]=t[l]);return e.concat(b||Array.prototype.slice.call(t))}var ds={scale:1,positionX:0,positionY:0},Bt={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}},cr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Wn=function(e){var t,s,l,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:ds.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:ds.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:ds.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:ds.positionY}},yi=function(e){var t=bt({},Bt);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",m=typeof Bt[s]<"u";if(m&&l){var b=Object.prototype.toString.call(Bt[s]),C=b==="[object Object]",r=b==="[object Array]";C?t[s]=bt(bt({},Bt[s]),e[s]):r?t[s]=Si(Si([],Bt[s],!0),e[s]):t[s]=e[s]}}),t},$n=function(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,b=e.setup,C=b.maxScale,r=b.minScale,i=b.zoomAnimation,c=b.smooth,d=i.size;if(!m)throw new Error("Wrapper is not mounted");var o=c?l*Math.exp(t*s):l+t*s,p=ns(et(o,3),r,C,d,!1);return p};function Un(e,t,s,l,m){var b=e.wrapperComponent,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY;if(!b)return console.error("No WrapperComponent found");var d=b.offsetWidth,o=b.offsetHeight,p=(d/2-i)/r,g=(o/2-c)/r,S=$n(e,t,s),_=Ar(e,S,p,g);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");St(e,_,l,m)}function Kn(e,t,s,l){var m=e.setup,b=e.wrapperComponent,C=m.limitToBounds,r=Wn(e.props),i=e.transformState,c=i.scale,d=i.positionX,o=i.positionY;if(b){var p=jr(e,r.scale),g=is(r.positionX,r.positionY,p,C,0,0,b),S={scale:r.scale,positionX:g.x,positionY:g.y};c===r.scale&&d===r.positionX&&o===r.positionY||(l?.(),St(e,S,t,s))}}function Mu(e,t,s,l){var m=e.getBoundingClientRect(),b=t.getBoundingClientRect(),C=s.getBoundingClientRect(),r=b.x*l.scale,i=b.y*l.scale;return{x:(m.x-C.x+r)/l.scale,y:(m.y-C.y+i)/l.scale}}function Pu(e,t,s){var l=e.wrapperComponent,m=e.contentComponent,b=e.transformState,C=e.setup,r=C.limitToBounds,i=C.minScale,c=C.maxScale;if(!l||!m)return b;var d=l.getBoundingClientRect(),o=t.getBoundingClientRect(),p=Mu(t,l,m,b),g=p.x,S=p.y,_=o.width/b.scale,n=o.height/b.scale,f=l.offsetWidth/_,h=l.offsetHeight/n,u=ns(s||Math.min(f,h),i,c,0,!1),v=(d.width-_*u)/2,x=(d.height-n*u)/2,w=(d.left-g)*u+v,k=(d.top-S)*u+x,y=jr(e,u),E=is(w,k,y,r,0,0,l),j=E.x,A=E.y;return{positionX:j,positionY:A,scale:u}}var Ou=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),Un(e,1,t,s,l)}},Bu=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),Un(e,-1,t,s,l)}},Iu=function(e){return function(t,s,l,m,b){m===void 0&&(m=300),b===void 0&&(b="easeOut");var C=e.transformState,r=C.positionX,i=C.positionY,c=C.scale,d=e.wrapperComponent,o=e.contentComponent,p=e.setup.disabled;if(!(p||!d||!o)){var g={positionX:Number.isNaN(t)?r:t,positionY:Number.isNaN(s)?i:s,scale:Number.isNaN(l)?c:l};St(e,g,m,b)}}},Fu=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),Kn(e,t,s)}},Hu=function(e){return function(t,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var m=e.transformState,b=e.wrapperComponent,C=e.contentComponent;if(b&&C){var r=qn(t||m.scale,b,C);St(e,r,s,l)}}},zu=function(e){return function(t,s,l,m){l===void 0&&(l=600),m===void 0&&(m="easeOut"),st(e);var b=e.wrapperComponent,C=typeof t=="string"?document.getElementById(t):t;if(b&&C&&b.contains(C)){var r=Pu(e,C,s);St(e,r,l,m)}}},ws=function(e){return{instance:e,zoomIn:Ou(e),zoomOut:Bu(e),setTransform:Iu(e),resetTransform:Fu(e),centerView:Hu(e),zoomToElement:zu(e)}},hr=function(e){return{instance:e,state:e.transformState}},ke=function(e){var t={};return Object.assign(t,hr(e)),Object.assign(t,ws(e)),t},Zs=!1;function Js(){try{var e={get passive(){return Zs=!0,!1}};return e}catch{return Zs=!1,Zs}}var fs=".".concat(cr.wrapperClass),Hs=function(e,t){return t.some(function(s){return e.matches("".concat(fs," ").concat(s,", ").concat(fs," .").concat(s,", ").concat(fs," ").concat(s," *, ").concat(fs," .").concat(s," *"))})},ur=function(e){e&&clearTimeout(e)},Wu=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},qn=function(e,t,s){var l=s.offsetWidth*e,m=s.offsetHeight*e,b=(t.offsetWidth-l)/2,C=(t.offsetHeight-m)/2;return{scale:e,positionX:b,positionY:C}};function $u(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var Uu=function(e,t){var s=e.setup.wheel,l=s.disabled,m=s.wheelDisabled,b=s.touchPadDisabled,C=s.excluded,r=e.isInitialized,i=e.isPanning,c=t.target,d=r&&!i&&!l&&c;if(!d||m&&!t.ctrlKey||b&&t.ctrlKey)return!1;var o=Hs(c,C);return!o},Ku=function(e){return e?e.deltaY<0?1:-1:0};function qu(e,t){var s=Ku(e),l=nu(t,s);return l}function Xn(e,t,s){var l=t.getBoundingClientRect(),m=0,b=0;if("clientX"in e)m=(e.clientX-l.left)/s,b=(e.clientY-l.top)/s;else{var C=e.touches[0];m=(C.clientX-l.left)/s,b=(C.clientY-l.top)/s}return(Number.isNaN(m)||Number.isNaN(b))&&console.error("No mouse or touch offset found"),{x:m,y:b}}var Xu=function(e,t,s,l,m){var b=e.transformState.scale,C=e.wrapperComponent,r=e.setup,i=r.maxScale,c=r.minScale,d=r.zoomAnimation,o=r.disablePadding,p=d.size,g=d.disabled;if(!C)throw new Error("Wrapper is not mounted");var S=b+t*s,_=l?!1:!g,n=ns(et(S,3),c,i,p,_&&!o);return n},Yu=function(e,t){var s=e.previousWheelEvent,l=e.transformState.scale,m=e.setup,b=m.maxScale,C=m.minScale;return s?l<b||l>C||Math.sign(s.deltaY)!==Math.sign(t.deltaY)||s.deltaY>0&&s.deltaY<t.deltaY||s.deltaY<0&&s.deltaY>t.deltaY||Math.sign(s.deltaY)!==Math.sign(t.deltaY):!1},Vu=function(e,t){var s=e.setup.pinch,l=s.disabled,m=s.excluded,b=e.isInitialized,C=t.target,r=b&&!l&&C;if(!r)return!1;var i=Hs(C,m);return!i},Gu=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,m=s&&!t&&l;return!!m},Qu=function(e,t,s){var l=s.getBoundingClientRect(),m=e.touches,b=et(m[0].clientX-l.left,5),C=et(m[0].clientY-l.top,5),r=et(m[1].clientX-l.left,5),i=et(m[1].clientY-l.top,5);return{x:(b+r)/2/t,y:(C+i)/2/t}},Yn=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))},Zu=function(e,t){var s=e.pinchStartScale,l=e.pinchStartDistance,m=e.setup,b=m.maxScale,C=m.minScale,r=m.zoomAnimation,i=m.disablePadding,c=r.size,d=r.disabled;if(!s||l===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var o=t/l,p=o*s;return ns(et(p,2),C,b,c,!d&&!i)},Ju=160,ed=100,td=function(e,t){var s=e.props,l=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(st(e),De(ke(e),t,l),De(ke(e),t,m))},sd=function(e,t){var s=e.props,l=s.onWheel,m=s.onZoom,b=e.contentComponent,C=e.setup,r=e.transformState,i=r.scale,c=C.limitToBounds,d=C.centerZoomedOut,o=C.zoomAnimation,p=C.wheel,g=C.disablePadding,S=C.smooth,_=o.size,n=o.disabled,f=p.step,h=p.smoothStep;if(!b)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=qu(t,null),v=S?h*Math.abs(t.deltaY):f,x=Xu(e,u,v,!t.ctrlKey);if(i!==x){var w=wt(e,x),k=Xn(t,b,i),y=n||_===0||d||g,E=c&&y,j=Fs(e,k.x,k.y,x,w,E),A=j.x,L=j.y;e.previousWheelEvent=t,e.setTransformState(x,A,L),De(ke(e),t,l),De(ke(e),t,m)}},rd=function(e,t){var s=e.props,l=s.onWheelStop,m=s.onZoomStop;ur(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(zn(e,t.x,t.y),e.wheelAnimationTimer=null)},ed);var b=Yu(e,t);b&&(ur(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,De(ke(e),t,l),De(ke(e),t,m))},Ju))},Vn=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,b=s/2;return{x:m,y:b}},id=function(e,t){var s=Yn(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=Vn(t);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,st(e)},nd=function(e,t){var s=e.contentComponent,l=e.pinchStartDistance,m=e.wrapperComponent,b=e.transformState.scale,C=e.setup,r=C.limitToBounds,i=C.centerZoomedOut,c=C.zoomAnimation,d=C.alignmentAnimation,o=c.disabled,p=c.size;if(!(l===null||!s)){var g=Qu(t,b,s);if(!(!Number.isFinite(g.x)||!Number.isFinite(g.y))){var S=Yn(t),_=Zu(e,S),n=Vn(t),f=n.x-(e.pinchLastCenterX||0),h=n.y-(e.pinchLastCenterY||0);if(!(_===b&&f===0&&h===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var u=wt(e,_),v=o||p===0||i,x=r&&v,w=Fs(e,g.x,g.y,_,u,x),k=w.x,y=w.y;e.pinchMidpoint=g,e.lastDistance=S;var E=d.sizeX,j=d.sizeY,A=xt(e,E),L=xt(e,j),N=k+f,B=y+h,I=is(N,B,u,r,A,L,m),H=I.x,W=I.y;e.setTransformState(_,H,W)}}}},od=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,zn(e,t?.x,t?.y)},Gn=function(e,t){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;ur(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,De(ke(e),t,s)},l)},ad=function(e,t){var s=e.props,l=s.onZoomStart,m=s.onZoom,b=e.setup.doubleClick,C=b.animationTime,r=b.animationType;De(ke(e),t,l),Kn(e,C,r,function(){return De(ke(e),t,m)}),Gn(e,t)};function ld(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function cd(e,t){var s=e.setup,l=e.doubleClickStopEventTimer,m=e.transformState,b=e.contentComponent,C=m.scale,r=e.props,i=r.onZoomStart,c=r.onZoom,d=s.doubleClick,o=d.disabled,p=d.mode,g=d.step,S=d.animationTime,_=d.animationType;if(!o&&!l){if(p==="reset")return ad(e,t);if(!b)return console.error("No ContentComponent found");var n=ld(p,e.transformState.scale),f=$n(e,n,g);if(C!==f){De(ke(e),t,i);var h=Xn(t,b,C),u=Ar(e,f,h.x,h.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");De(ke(e),t,c),St(e,u,S,_),Gn(e,t)}}}var hd=function(e,t){var s=e.isInitialized,l=e.setup,m=e.wrapperComponent,b=l.doubleClick,C=b.disabled,r=b.excluded,i=t.target,c=m?.contains(i),d=s&&i&&c&&!C;if(!d)return!1;var o=Hs(i,r);return!o},ud=(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,wt(s,s.transformState.scale),s.setup=yi(l)},this.initializeWindowEvents=function(){var l,m,b=Js(),C=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=C?.defaultView;(m=s.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",s.onWheelPanning,b),r?.addEventListener("mousedown",s.onPanningStart,b),r?.addEventListener("mousemove",s.onPanning,b),r?.addEventListener("mouseup",s.onPanningStop,b),C?.addEventListener("mouseleave",s.clearPanning,b),r?.addEventListener("keyup",s.setKeyUnPressed,b),r?.addEventListener("keydown",s.setKeyPressed,b)},this.cleanupWindowEvents=function(){var l,m,b=Js(),C=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=C?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,b),r?.removeEventListener("mousemove",s.onPanning,b),r?.removeEventListener("mouseup",s.onPanningStop,b),C?.removeEventListener("mouseleave",s.clearPanning,b),r?.removeEventListener("keyup",s.setKeyUnPressed,b),r?.removeEventListener("keydown",s.setKeyPressed,b),document.removeEventListener("mouseleave",s.clearPanning,b),st(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(l){var m=Js();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 b=!1,C=s.setup.centerOnInit,r=function(i,c){for(var d=0,o=i;d<o.length;d++){var p=o[d];if(p.target===c)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(i){i(ke(s))}),s.observer=new ResizeObserver(function(i){if(r(i,l)||r(i,m))if(C&&!b){var c=m.offsetWidth,d=m.offsetHeight;(c>0||d>0)&&(b=!0,s.setCenter())}else st(s),wt(s,s.transformState.scale),Lr(s,0)}),s.observer.observe(l),s.observer.observe(m)},this.onWheelZoom=function(l){var m=s.setup.disabled;if(!m){var b=Uu(s,l);if(b){var C=s.isPressingKeys(s.setup.wheel.activationKeys);C&&(td(s,l),sd(s,l),rd(s,l))}}},this.onWheelPanning=function(l){var m=s.setup,b=m.disabled,C=m.wheel,r=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||b||!C.wheelDisabled||r.disabled||!r.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var i=s.transformState,c=i.positionX,d=i.positionY,o=c-l.deltaX,p=d-l.deltaY,g=r.lockAxisX?c:o,S=r.lockAxisY?d:p,_=s.setup.alignmentAnimation,n=_.sizeX,f=_.sizeY,h=xt(s,n),u=xt(s,f);g===c&&S===d||Hn(s,g,S,h,u)}},this.onPanningStart=function(l){var m=s.setup.disabled,b=s.props.onPanningStart;if(!m){var C=vi(s,l);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(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(),st(s),bi(s,l),De(ke(s),l,b)))}}},this.onPanning=function(l){var m=s.setup.disabled,b=s.props.onPanning;if(!m){var C=gi(s);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(l.preventDefault(),l.stopPropagation(),xi(s,l.clientX,l.clientY),De(ke(s),l,b))}}},this.onPanningStop=function(l){var m=s.props.onPanningStop;s.isPanning&&(Nu(s),De(ke(s),l,m))},this.onPinchStart=function(l){var m=s.setup.disabled,b=s.props,C=b.onPinchingStart,r=b.onZoomStart;if(!m){var i=Vu(s,l);i&&(id(s,l),st(s),De(ke(s),l,C),De(ke(s),l,r))}},this.onPinch=function(l){var m=s.setup.disabled,b=s.props,C=b.onPinching,r=b.onZoom;if(!m){var i=Gu(s);i&&(l.preventDefault(),l.stopPropagation(),nd(s,l),De(ke(s),l,C),De(ke(s),l,r))}},this.onPinchStop=function(l){var m=s.props,b=m.onPinchingStop,C=m.onZoomStop;s.pinchStartScale&&(od(s),De(ke(s),l,b),De(ke(s),l,C))},this.onTouchPanningStart=function(l){var m=s.setup.disabled,b=s.props.onPanningStart;if(!m){var C=vi(s,l);if(C){var r=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!r){s.lastTouch=+new Date,st(s);var i=l.touches,c=i.length===1,d=i.length===2;c&&(st(s),bi(s,l),De(ke(s),l,b)),d&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var m=s.setup.disabled,b=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(m)return;var C=gi(s);if(!C)return;l.preventDefault(),l.stopPropagation();var r=l.touches[0];xi(s,r.clientX,r.clientY),De(ke(s),l,b)}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 b=hd(s,l);b&&cd(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,b){var C=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(m)&&!Number.isNaN(b)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=m,s.transformState.positionY=b,s.applyTransformation();var r=ke(s);s.onChangeCallbacks.forEach(function(i){return i(r)}),De(r,{scale:l,positionX:m,positionY:b},C)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=qn(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,m,b){return s.props.customTransform?s.props.customTransform(l,m,b):Wu(l,m,b)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,m=l.scale,b=l.positionX,C=l.positionY,r=s.handleTransformStyles(b,C,m);s.contentComponent.style.transform=r}},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,wt(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,m),s.initializeWindowEvents(),s.isInitialized=!0;var b=ke(s);De(b,void 0,s.props.onInit)},this.props=t,this.setup=yi(this.props),this.transformState=Wn(this.props)}return e})(),zs=ee.createContext(null),dd=function(e,t){return typeof e=="function"?e(t):e},fd=ee.forwardRef(function(e,t){var s=R.useRef(new ud(e)).current,l=dd(e.children,ws(s));return R.useImperativeHandle(t,function(){return ws(s)},[s]),R.useEffect(function(){s.update(e)},[s,e]),ee.createElement(zs.Provider,{value:s},l)});ee.forwardRef(function(e,t){var s=R.useRef(null),l=R.useContext(zs);return R.useEffect(function(){return l.onChange(function(m){if(s.current){var b=0,C=0;s.current.style.transform=l.handleTransformStyles(b,C,1/m.instance.transformState.scale)}})},[l]),ee.createElement("div",bt({},e,{ref:$u([s,t])}))});function pd(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 md=`.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
- `,Ci={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};pd(md);var vd=function(e){var t=e.children,s=e.wrapperClass,l=s===void 0?"":s,m=e.contentClass,b=m===void 0?"":m,C=e.wrapperStyle,r=e.contentStyle,i=e.wrapperProps,c=i===void 0?{}:i,d=e.contentProps,o=d===void 0?{}:d,p=R.useContext(zs),g=p.init,S=p.cleanupWindowEvents,_=R.useRef(null),n=R.useRef(null);return R.useEffect(function(){var f=_.current,h=n.current;return f!==null&&h!==null&&g&&g?.(f,h),function(){S?.()}},[]),ee.createElement("div",bt({},c,{ref:_,className:"".concat(cr.wrapperClass," ").concat(Ci.wrapper," ").concat(l),style:C}),ee.createElement("div",bt({},o,{ref:n,className:"".concat(cr.contentClass," ").concat(Ci.content," ").concat(b),style:r}),t))},Qn=function(){var e=R.useContext(zs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},gd=function(){var e=Qn();return ws(e)};function _d(e){var t=Qn(),s=R.useState(e(hr(t))),l=s[0],m=s[1];return R.useEffect(function(){var b=!0,C=t.onChange(function(r){b&&m(e(hr(r.instance)))});return function(){C(),b=!1}},[e,t]),l}function bd(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 xd(e,t){return lt({queryKey:he.files.tree(e||"",t),queryFn:()=>ve.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Sd(e,t){return lt({queryKey:he.files.content(e||"",t||""),queryFn:()=>ve.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function yd(e){const t=Ie();return R.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Cd(){const e=Ie();return Ge({mutationFn:t=>ve.post("/files/write",t),onSuccess:(t,s)=>{const l=he.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||bd(s.path)})}})}function wd(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Ed(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const kd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Rd(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&kd.has(t)?Sr:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?Kt:t==="json"?la:t==="md"||t==="mdx"||t==="txt"?rn:qo}const wi=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:b})=>a.jsxs("button",{type:"button",onClick:s,className:Se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",t&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[a.jsx("span",{className:"shrink-0",children:m}),a.jsx("span",{className:"shrink-0 text-neutral-500",children:l}),a.jsx("span",{className:"truncate text-neutral-700",children:b})]}),Zn=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:b,selectedFilePath:C})=>{const{data:r,isLoading:i,isError:c}=xd(e,t),d=R.useMemo(()=>r?.items??[],[r?.items]);return i?a.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:"Loading..."}):c?a.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:"Failed to load"}):a.jsx("div",{className:"space-y-0.5",children:d.map(o=>{if(o.type==="directory"){const n=wd(t,o.name),f=l.has(n);return a.jsxs("div",{children:[a.jsx(wi,{depth:s,onClick:()=>m(n),rightIcon:f?a.jsx(pt,{size:14,className:"text-neutral-400"}):a.jsx(kt,{size:14,className:"text-neutral-400"}),leftIcon:f?a.jsx(nn,{size:14,className:"text-amber-500"}):a.jsx(Ko,{size:14,className:"text-amber-500"}),label:o.name}),f&&a.jsx(Zn,{workingDir:e,path:n,depth:s+1,expanded:l,toggleDir:m,onFileSelect:b,selectedFilePath:C})]},n)}const p=Ed(t,o.name),g=Rd(o),S=C===p,_=g===Sr;return a.jsx(wi,{depth:s,active:S,onClick:()=>b(p),rightIcon:a.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:g?a.jsx(g,{size:14,className:_?"text-emerald-600":"text-sky-600"}):null,label:o.name},p)})})},Dd=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const[b,C]=R.useState(()=>new Set),r=yd(e),i=R.useCallback(c=>{C(d=>{const o=new Set(d);return o.has(c)?o.delete(c):o.add(c),o})},[]);return a.jsxs("div",{className:Se("h-full flex flex-col",t),children:[a.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:"Files"}),a.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||"No workingDir"})]}),a.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&a.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:"Refresh file tree",children:a.jsx(Fa,{size:13})}),m&&a.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:"Collapse file tree",children:a.jsx(ja,{size:13})})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?a.jsx(Zn,{workingDir:e,path:"/",depth:0,expanded:b,toggleDir:i,onFileSelect:s,selectedFilePath:l}):a.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:"No workspace selected."})})]})},Td=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function jd(e){const t=e.split(".").pop()?.toLowerCase();return t?Td.has(t):!1}function Ld(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});if(Qt()){const m=Zt();m&&l.set("token",m)}return`${s}/files/image?${l.toString()}`}const Ad=({filePath:e})=>{const{zoomIn:t,zoomOut:s,centerView:l}=gd(),m=_d(C=>C.state.scale),b=Math.round(m*100);return a.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:[a.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:"Zoom out",children:a.jsx(Ya,{size:14})}),a.jsxs("button",{type:"button",onClick:()=>l(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:"Reset zoom",children:[b,"%"]}),a.jsx("button",{type:"button",onClick:()=>t(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:"Zoom in",children:a.jsx(qa,{size:14})}),a.jsx("button",{type:"button",onClick:()=>l(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:"Fit to view",children:a.jsx(ka,{size:13})}),a.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Nd=({workingDir:e,filePath:t})=>{const[s,l]=R.useState(!1),m=Ld(e,t);return s?a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"Failed to load image."}):a.jsx(fd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx(Ad,{filePath:t}),a.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:a.jsx(vd,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsx("img",{src:m,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>l(!0)})})})]})})};function Md(e){const t=e.split("/");return t[t.length-1]||e}function Pd(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 Od=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>a.jsxs("button",{type:"button",onClick:l,className:Se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[a.jsx("span",{className:Se("w-2 h-2 rounded-full",s?"bg-amber-500":"bg-transparent")}),a.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),a.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":"Close tab",title:"Close",children:a.jsx(Ts,{size:12})})]}),Bd=({workingDir:e,className:t})=>{const[s,l]=R.useState([]),[m,b]=R.useState(null),C=Cd(),[r,i]=R.useState(280),[c,d]=R.useState(!1),[o,p]=R.useState(!1),g=R.useRef(280),S=R.useCallback(()=>{d(A=>(A?i(g.current):g.current=r,!A))},[r]),_=R.useCallback(A=>{A.preventDefault(),p(!0);const L=A.clientX,N=r,B=H=>{const W=H.clientX-L,D=Math.min(480,Math.max(160,N+W));i(D)},I=()=>{p(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",I)},[r]);R.useEffect(()=>{l([]),b(null)},[e]);const n=R.useMemo(()=>s.find(A=>A.path===m)||null,[s,m]),{data:f,isFetching:h,isError:u,error:v}=Sd(e,n?.isImage?null:m);R.useEffect(()=>{!m||!f||l(A=>A.map(L=>L.path!==m||L.isDirty||L.loaded?L:{...L,language:f.language||L.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[m,f]);const x=R.useCallback(A=>{l(L=>{if(L.find(I=>I.path===A))return L;const B=jd(A);return[...L,{path:A,name:Md(A),language:Pd(A),content:"",savedContent:"",isDirty:!1,loaded:B,isImage:B}]}),b(A)},[]),w=R.useCallback(A=>{l(L=>{const N=L.filter(B=>B.path!==A);return b(B=>B!==A?B:N.length?N[N.length-1].path:null),N})},[]),k=R.useCallback(A=>{l(L=>L.map(N=>{if(N.path!==m)return N;const B=A!==N.savedContent;return{...N,content:A,isDirty:B}}))},[m]),y=R.useCallback(async()=>{!e||!n||(await C.mutateAsync({workingDir:e,path:n.path,content:n.content}),l(A=>A.map(L=>L.path===n.path?{...L,savedContent:L.content,isDirty:!1,loaded:!0}:L)))},[e,n,C]),E=R.useRef(()=>{});R.useEffect(()=>{E.current=()=>{y().catch(()=>{})}},[y]),R.useEffect(()=>{const A=L=>{(L.metaKey||L.ctrlKey)&&L.key.toLowerCase()==="s"&&(L.preventDefault(),E.current())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[]);const j=R.useCallback((A,L)=>{A.addCommand(L.KeyMod.CtrlCmd|L.KeyCode.KeyS,()=>{E.current()})},[]);return a.jsxs("div",{className:Se("flex h-full overflow-hidden bg-white",t),style:o?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:c?36:r,transition:o?"none":"width 0.15s ease"},children:c?a.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:a.jsx("button",{type:"button",onClick:S,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:"Expand file tree",children:a.jsx(Aa,{size:16})})}):a.jsx(a.Fragment,{children:a.jsx(Dd,{workingDir:e,onFileSelect:x,selectedFilePath:n?.path||null,onCollapse:S},e||"no-working-dir")})}),!c&&a.jsx("div",{onMouseDown:_,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",o?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[a.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:[s.length===0?a.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:"No open files"}):s.map(A=>a.jsx(Od,{active:A.path===m,name:A.name,isDirty:A.isDirty,onClick:()=>b(A.path),onClose:L=>{L.stopPropagation(),w(A.path)}},A.path)),a.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[C.isPending&&a.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[a.jsx(Be,{size:14,className:"animate-spin"}),"Saving"]}),n?.isDirty&&!C.isPending&&a.jsx("span",{className:"text-[11px] text-amber-600",children:"Unsaved"})]})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:e?n?n.isImage?a.jsx(Nd,{workingDir:e,filePath:n.path}):a.jsxs(a.Fragment,{children:[a.jsx(iu,{path:n.path,value:n.content,language:n.language,theme:"vs-light",height:"100%",onChange:A=>k(A??""),onMount:j,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0}}),h&&!n.loaded&&a.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[a.jsx(Be,{size:14,className:"animate-spin"}),"Loading file..."]})}),u&&a.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:["Failed to load file",v instanceof Error?`: ${v.message}`:"","."]})]}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"Select a file from the tree to open."}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"No workspace selected."})})]})]})};function Jn(e){return lt({queryKey:he.git.changes(e||""),queryFn:()=>ve.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function eo(e,t,s){return lt({queryKey:he.git.diff(e||"",t||"",s),queryFn:()=>ve.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function to(e,t){return lt({queryKey:he.git.commitFiles(e||"",t||""),queryFn:()=>ve.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function so(e,t,s){return lt({queryKey:he.git.commitDiff(e||"",t||"",s||""),queryFn:()=>ve.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ei={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"},Id={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function Fd(e){const t=e.split("/");return t[t.length-1]||e}function Hd(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const zd=({entry:e,selected:t,onClick:s})=>{const l=Ei[e.status]||Ei.M,m=Id[e.status]||e.status,b=Hd(e.path);return a.jsxs("button",{type:"button",onClick:s,className:Se("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",t?"bg-blue-50":"hover:bg-neutral-50"),children:[a.jsx("span",{className:Se("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",l),title:m,children:e.status}),a.jsx("span",{className:"text-xs text-neutral-900 truncate",children:Fd(e.path)}),b&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:b})]})},ki=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>t.length===0?null:a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:e}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),a.jsx("div",{className:"space-y-0.5",children:t.map(b=>{const C=`${s}:${b.path}`;return a.jsx(zd,{entry:b,selected:l===C,onClick:()=>m(b.path,s)},C)})})]}),Wd=({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"),a.jsxs("div",{className:Se("flex",s),children:[a.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),a.jsx("span",{className:Se("pl-2 whitespace-pre",l),children:e})]})},$d=({workingDir:e,filePath:t,type:s})=>{const{data:l,isLoading:m,isError:b}=eo(e,t,s);if(m)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:"Failed to load diff."});const C=l?.diff||"";if(!C.trim())return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:"No diff content available."});const r=C.split(`
63
- `);return a.jsx("div",{className:"flex-1 overflow-auto font-mono text-xs leading-5",children:r.map((i,c)=>a.jsx(Wd,{line:i,lineNum:c+1},c))})},Ud=({workingDir:e})=>{const{data:t,isLoading:s,isError:l}=Jn(e),[m,b]=R.useState(null),[C,r]=R.useState(260),[i,c]=R.useState(!1),d=R.useCallback(n=>{n.preventDefault(),c(!0);const f=n.clientX,h=C,u=x=>{const w=x.clientX-f,k=Math.min(480,Math.max(160,h+w));r(k)},v=()=>{c(!1),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",v)},[C]),o=m?`${m.type}:${m.path}`:null,p=(n,f)=>{b({path:n,type:f})};if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:"No workspace selected."});if(s)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading changes..."})]});if(l)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:"Failed to load changes."});const g=t?.uncommitted||[],S=t?.committed||[],_=g.length+S.length;return a.jsxs("div",{className:"flex h-full bg-white",style:i?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:C},children:[a.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:"Changes"}),_>0&&a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:_})]})}),a.jsx("div",{className:"flex-1 overflow-auto p-1.5",children:_===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[a.jsx(qt,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:"No pending changes"})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(ki,{title:"Uncommitted",entries:g,type:"uncommitted",selectedKey:o,onSelect:p}),a.jsx(ki,{title:"Committed",entries:S,type:"committed",selectedKey:o,onSelect:p})]})})]}),a.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",i?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[a.jsx(Kt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:m.path}),a.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",m.type,")"]})]}),a.jsx($d,{workingDir:e,filePath:m.path,type:m.type})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(Kt,{size:28}),a.jsx("span",{className:"text-xs",children:"Select a file to view diff"})]})})})]})},er=50,Ri={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 Kd(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:s<86400?`${Math.floor(s/3600)}h ago`:s<604800?`${Math.floor(s/86400)}d ago`:new Date(e*1e3).toLocaleDateString()}function qd(e){const t=e.split("/");return t[t.length-1]||e}function Xd(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Yd=`
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
- `,Vd=({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"),a.jsxs("div",{className:Se("flex",s),children:[a.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),a.jsx("span",{className:Se("pl-2 whitespace-pre",l),children:e})]})},Gd=({workingDir:e,hash:t,filePath:s})=>{const{data:l,isLoading:m,isError:b}=so(e,t,s);if(m)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:"Failed to load diff."});const C=l?.diff||"";if(!C.trim())return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:"No diff content available."});const r=C.split(`
69
- `);return a.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:r.map((i,c)=>a.jsx(Vd,{line:i,lineNum:c+1},c))})},Qd=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{data:m,isLoading:b}=to(e,t);if(b)return a.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[a.jsx(Be,{size:12,className:"animate-spin"}),a.jsx("span",{children:"Loading..."})]});const C=m?.files||[];return C.length===0?a.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:"No files changed"}):a.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:C.map(r=>{const i=Ri[r.status]||Ri.M,c=Xd(r.path);return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),l(r.path)},className:Se("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===r.path?"bg-blue-50":"hover:bg-neutral-50"),children:[a.jsx("span",{className:Se("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",i),children:r.status}),a.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:qd(r.path)}),c&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:c})]},r.path)})})},Zd=({workingDir:e})=>{const{data:t,isLoading:s,isError:l,fetchNextPage:m,hasNextPage:b,isFetchingNextPage:C}=Zi({queryKey:he.git.log(e||""),queryFn:({pageParam:v=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(er),skip:String(v)}}),initialPageParam:0,getNextPageParam:(v,x)=>v.commits.length<er?void 0:x.length*er,enabled:!!e}),r=t?.pages.flatMap(v=>v.commits)||[],[i,c]=R.useState(null),[d,o]=R.useState(null),[p,g]=R.useState(280),[S,_]=R.useState(!1),n=R.useCallback(v=>{v.preventDefault(),_(!0);const x=v.clientX,w=p,k=E=>{const j=Math.min(480,Math.max(180,w+(E.clientX-x)));g(j)},y=()=>{_(!1),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",y)},[p]),f=v=>{i===v?(c(null),o(null)):(c(v),o(null))},h=R.useRef(null);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:"No workspace selected."});if(s)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading history..."})]});if(l)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:"Failed to load history."});if(r.length===0)return a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[a.jsx(Mt,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:"No commit history"})]});const u=r.find(v=>v.hash===i);return a.jsxs("div",{className:"flex h-full bg-white",style:S?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsx("style",{children:Yd}),a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:p},children:[a.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Mt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:"History"}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:r.length})]})}),a.jsxs("div",{ref:h,className:"flex-1 overflow-auto history-scroll p-1.5",children:[r.map(v=>{const x=i===v.hash;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>f(v.hash),className:Se("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",x?"bg-blue-50":"hover:bg-neutral-50"),children:[a.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:a.jsx("div",{className:Se("w-2 h-2 rounded-full shrink-0 transition-colors",x?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:v.shortHash}),a.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:v.message}),a.jsx(kt,{size:12,className:Se("shrink-0 text-neutral-400 transition-transform",x&&"rotate-90")})]}),a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[a.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:v.author}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:Kd(v.timestamp)})]})]})]}),x&&a.jsxs(a.Fragment,{children:[v.body&&a.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:v.body}),a.jsx(Qd,{workingDir:e,hash:v.hash,selectedPath:d,onSelectFile:o})]})]},v.hash)}),b&&a.jsx("button",{type:"button",onClick:()=>m(),disabled:C,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:C?a.jsxs(a.Fragment,{children:[a.jsx(Be,{size:12,className:"animate-spin"})," Loading..."]}):"Load more"})]})]}),a.jsx("div",{onMouseDown:n,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",S?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:d&&i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[a.jsx(Kt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:d}),a.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",u?.shortHash,")"]})]}),a.jsx(Gd,{workingDir:e,hash:i,filePath:d})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(Kt,{size:28}),a.jsx("span",{className:"text-xs",children:i?"Select a file to view diff":"Select a commit to view changes"})]})})})]})},Jd=[{key:"changes",label:"Changes",icon:a.jsx(qt,{size:14})},{key:"history",label:"History",icon:a.jsx(Mt,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(Ls,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(vs,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Ds,{size:14})}],ef=[{key:"history",label:"History",icon:a.jsx(Mt,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(Ls,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(vs,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Ds,{size:14})}],tf=({active:e,onClick:t,icon:s,label:l})=>a.jsxs("button",{onClick:t,className:Se("flex items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[s,a.jsx("span",{children:l})]}),sf=({icon:e,title:t})=>a.jsx("div",{className:"flex-1 flex items-center justify-center bg-white",children:a.jsxs("div",{className:"flex flex-col items-center gap-2 text-neutral-400",children:[e,a.jsx("span",{className:"text-sm font-medium text-neutral-500",children:t}),a.jsx("span",{className:"text-xs",children:"Coming soon..."})]})}),ro=ee.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:b}){const C=b?ef:Jd,[r,i]=R.useState(b?"history":"changes"),{data:c}=Xo(m??""),d=R.useMemo(()=>{if(!c?.quickCommands)return[];try{return JSON.parse(c.quickCommands)}catch{return[]}},[c?.quickCommands]),[o,p]=R.useState([]),g=R.useRef(void 0);return R.useEffect(()=>{l&&l!==g.current&&(g.current=l,p(S=>S.includes(l)?S:[...S,l]))},[l]),a.jsxs("div",{className:Se("flex flex-col h-full bg-white",t),children:[a.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:C.map(S=>a.jsx(tf,{active:r===S.key,onClick:()=>i(S.key),icon:S.icon,label:S.label},S.key))}),a.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[r==="editor"&&a.jsx(Bd,{workingDir:l}),o.map(S=>a.jsx("div",{className:"h-full absolute inset-0",style:{display:r==="terminal"&&l===S?"block":"none"},children:a.jsx(Vc,{cwd:S,quickCommands:d})},S)),r==="preview"&&a.jsx(sf,{icon:a.jsx(Ds,{size:32}),title:"Preview"}),r==="changes"&&a.jsx(Ud,{workingDir:l}),r==="history"&&a.jsx(Zd,{workingDir:l})]})]})});function io(e){return lt({queryKey:he.workspaces.list(e),queryFn:()=>ve.get(`/tasks/${e}/workspaces`),enabled:!!e})}function rf(e){const t=Ie();return Ge({mutationFn:s=>ve.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:he.workspaces.list(e)}),t.invalidateQueries({queryKey:he.tasks.all})}})}function nf(){const e=Ie();return Ge({mutationFn:({id:t,commitMessage:s})=>ve.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:he.workspaces.all}),e.invalidateQueries({queryKey:he.tasks.all})}})}function Nr(){return Ge({mutationFn:({workspaceId:e,editorType:t})=>ve.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function no(e){return lt({queryKey:he.workspaces.gitStatus(e),queryFn:()=>ve.get(`/workspaces/${e}/git-status`),enabled:!!e})}function of(){const e=Ie();return Ge({mutationFn:t=>ve.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})}})}function af(){const e=Ie();return Ge({mutationFn:t=>ve.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.workspaces.gitStatus(s)})}})}const Di=1500,lf=3e3;function cf(e){const[t,s]=R.useState(null),l=R.useRef(0),m=R.useRef(null),b=R.useRef(null);return R.useEffect(()=>{if(!e)return;const C=()=>{b.current&&(clearTimeout(b.current),b.current=null)},r=dt.connect();r.emit(ot.SUBSCRIBE,{topic:"task",id:e},d=>{});const i=d=>{s(d),b.current=setTimeout(()=>s(null),lf)},c=d=>{if(d.taskId!==e)return;const o={status:d.status,currentCommand:d.currentCommand,currentIndex:d.currentIndex,totalCommands:d.totalCommands,error:d.error};if(d.status==="running"){C(),m.current=null,l.current===0&&(l.current=Date.now()),s(o);return}const p=l.current>0?Date.now()-l.current:0,g=Di-p;l.current===0?(l.current=Date.now(),s({status:"running",totalCommands:d.totalCommands,currentIndex:d.totalCommands}),m.current=o,b.current=setTimeout(()=>i(o),Di)):g>0?(m.current=o,C(),b.current=setTimeout(()=>i(o),g)):i(o)};return r.on(Oe.WORKSPACE_SETUP_PROGRESS,c),()=>{r.off(Oe.WORKSPACE_SETUP_PROGRESS,c),C(),l.current=0,m.current=null}},[e]),t}function oo(){const e=Ie();return Ge({mutationFn:t=>ve.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.sessions.detail(s)})}})}function ao(){const e=Ie();return Ge({mutationFn:t=>ve.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:he.sessions.detail(s)})}})}function Mr(){const e=Ie();return Ge({mutationFn:({id:t,message:s,providerId:l})=>ve.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:he.workspaces.all})}})}function lo(e,t){return R.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 hf="/api";async function uf(e){const t=new FormData;t.append("file",e);const s={};if(Qt()){const m=Zt();m&&(s.Authorization=`Bearer ${m}`)}const l=await fetch(`${hf}/attachments/upload`,{method:"POST",body:t,headers:s});if(!l.ok){const m=await l.json().catch(()=>({}));throw new Error(m.error||`Upload failed (${l.status})`)}return l.json()}let df=0;function Pr(){const[e,t]=R.useState([]),s=R.useRef(e);s.current=e;const l=R.useCallback(async c=>{const d=c.map(o=>({tempId:`tmp-${++df}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...d]),await Promise.allSettled(d.map(async o=>{try{const p=await uf(o.file);t(g=>g.map(S=>S.tempId===o.tempId?{...S,status:"done",progress:100,attachment:p}:S))}catch(p){t(g=>g.map(S=>S.tempId===o.tempId?{...S,status:"error",error:p instanceof Error?p.message:"Upload failed"}:S))}}))},[]),m=R.useCallback(c=>{t(d=>d.filter(o=>o.tempId!==c))},[]),b=R.useCallback(()=>{t([])},[]),C=R.useCallback(()=>{const c=s.current.filter(d=>d.status==="done"&&d.attachment);return c.length===0?"":c.map(d=>{const o=d.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
70
- `)},[]),r=e.length>0,i=e.some(c=>c.status==="uploading");return{files:e,addFiles:l,removeFile:m,clear:b,buildMarkdownLinks:C,hasFiles:r,isUploading:i}}const ff="/api";function pf(e){if(!Qt())return e;const t=Zt();if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}token=${encodeURIComponent(t)}`}function mf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Es({files:e,onRemove:t}){return e.length===0?null:a.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(s=>a.jsx(vf,{item:s,onRemove:t},s.tempId))})}function vf({item:e,onRemove:t}){const s=e.file.type.startsWith("image/"),l=e.status==="error",m=e.status==="uploading";return a.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?a.jsx("img",{src:pf(`${ff}${e.attachment.url}`),alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):a.jsx("span",{className:"flex-shrink-0",children:m?a.jsx(Be,{size:16,className:"animate-spin text-neutral-400"}):s?a.jsx(Sr,{size:16,className:"text-neutral-400"}):a.jsx(rn,{size:16,className:"text-neutral-400"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate font-medium",children:e.file.name}),l?a.jsx("div",{className:"truncate text-red-500",children:e.error}):a.jsx("div",{className:"text-neutral-400",children:mf(e.file.size)})]}),a.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:a.jsx(Ts,{size:10})})]})}function co({isOpen:e,onClose:t,taskId:s,taskTitle:l,taskDescription:m}){const[b,C]=R.useState(""),[r,i]=R.useState(""),[c,d]=R.useState("idle"),[o,p]=R.useState(null),g=Ie(),S=rf(s),_=oo(),{data:n,isLoading:f}=js();R.useEffect(()=>{if(!e||!n)return;const x=n.find(w=>w.availability.type!=="NOT_FOUND");x&&C(x.provider.id)},[e,n]),R.useEffect(()=>{if(e){const x=[l];m&&x.push(m),i(x.join(`
71
-
72
- `)),d("idle"),p(null)}},[e,l,m]);const h=c!=="idle",u=async()=>{if(!(!b||!r.trim())){p(null);try{d("creating-workspace");const x=await S.mutateAsync({});d("creating-session");const w=await ve.post(`/workspaces/${x.id}/sessions`,{providerId:b,prompt:r.trim()});d("starting-session"),await _.mutateAsync(w.id),await g.invalidateQueries({queryKey:he.workspaces.list(s)}),d("idle"),t()}catch(x){d("idle"),p(x instanceof Error?x.message:"启动失败,请重试")}}},v={idle:"启动","creating-workspace":"创建工作空间...","creating-session":"创建会话...","starting-session":"启动 Agent..."};return a.jsx(xr,{isOpen:e,onClose:h?()=>{}:t,title:"启动 Agent",action:a.jsxs(a.Fragment,{children:[a.jsx(at,{variant:"outline",onClick:t,disabled:h,children:"取消"}),a.jsx(at,{onClick:u,disabled:h||!b||!r.trim(),children:v[c]})]}),children:a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:"选择 Provider"}),a.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f&&a.jsx("span",{className:"text-sm text-neutral-400",children:"加载中..."}),n?.map(({provider:x,availability:w})=>{const k=w.type!=="NOT_FOUND";return a.jsxs(at,{variant:b===x.id?"default":"outline",size:"sm",disabled:!k||h,onClick:()=>C(x.id),children:[x.name,!k&&" (不可用)"]},x.id)})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:"任务描述"}),a.jsx("textarea",{value:r,onChange:x=>i(x.target.value),rows:5,disabled:h,placeholder:"描述你想让 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"})]}),o&&a.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:o})]})})}function ho({providers:e,currentProviderId:t,agentType:s,onSelect:l}){const[m,b]=R.useState(!1),C=R.useRef(null),r=e.filter(c=>String(c.provider.agentType)===s),i=e.find(c=>c.provider.id===t);return R.useEffect(()=>{function c(d){C.current&&!C.current.contains(d.target)&&b(!1)}if(m)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[m]),r.length<=1?a.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[a.jsx(Ir,{size:14,className:"shrink-0"}),a.jsx("span",{children:i?.provider.name?$r(i.provider.name,12):s})]}):a.jsxs("div",{className:"relative",ref:C,children:[a.jsxs("button",{onClick:()=>b(!m),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: ${i?.provider.name??s} (click to change)`,children:[a.jsx(Ir,{size:14,className:"shrink-0"}),a.jsx("span",{children:i?.provider.name?$r(i.provider.name,12):s}),a.jsx(pt,{size:12,className:`shrink-0 transition-transform ${m?"rotate-180":""}`})]}),m&&a.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:[a.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:"切换渠道"}),r.map(c=>a.jsxs("button",{onClick:()=>{l(c.provider.id),b(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${c.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate max-w-[120px]",children:c.provider.name}),c.provider.isDefault&&a.jsx("span",{className:"text-xs text-neutral-400",children:"(默认)"})]}),c.provider.id===t&&a.jsx(Ut,{size:14,className:"shrink-0"})]},c.provider.id))]})]})}function gf({workspaceId:e,gitStatus:t,onResolve:s}){const l=af();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const m=t.operation==="rebase"?"Rebase":"Merge";return a.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:[a.jsx(Vi,{size:18,className:"text-amber-600 shrink-0"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("p",{className:"text-sm font-medium text-amber-900",children:[m," 冲突 — ",t.conflictedFiles.length," 个文件"]})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx(at,{variant:"outline",size:"sm",onClick:()=>l.mutate(e),disabled:l.isPending,children:"中止操作"}),a.jsx(at,{size:"sm",onClick:s,children:"解决冲突"})]})]})}function _f(e,t,s,l){const m=s.map(b=>`- ${b}`).join(`
73
- `);return l===Uo.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 bf({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:b,targetBranch:C,sessions:r}){const[i,c]=R.useState(""),d=Mr(),o=Nr(),p=()=>{if(!i)return;const _=_f(b,C,m,l);d.mutate({id:i,message:_},{onSuccess:()=>t(!1)})},g=()=>{o.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},S=l==="REBASE"?"Rebase":"Merge";return a.jsx(xr,{isOpen:e,onClose:()=>t(!1),title:`解决 ${S} 冲突`,action:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(at,{variant:"outline",onClick:g,children:"在 IDE 中打开"}),a.jsx(at,{onClick:p,disabled:!i||d.isPending,children:d.isPending?"发送中...":"AI 辅助解决"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:["冲突文件(",m.length,")"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(_=>a.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:_},_))})]}),r.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:"选择 Session(AI 辅助解决)"}),a.jsxs("select",{value:i,onChange:_=>c(_.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:[a.jsx("option",{value:"",children:"选择一个 Session..."}),r.map(_=>a.jsxs("option",{value:_.id,children:[_.agentType," — ",_.status]},_.id))]})]}),r.length===0&&a.jsx("p",{className:"text-sm text-neutral-500",children:"没有可用的 Session,请在 IDE 中手动解决冲突。"})]})})}function Ct({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 a.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 xf({gitStatus:e,branchName:t,targetBranch:s}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),a.jsx(en,{size:14,className:"text-neutral-400"}),a.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:s})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&a.jsxs(Ct,{variant:"danger",children:[a.jsx(ua,{size:12}),e.uncommittedCount," 个未提交变更"]}),e.conflictedFiles.length>0&&a.jsxs(Ct,{variant:"warning",children:[a.jsx(Vi,{size:12}),e.conflictedFiles.length," 个冲突文件"]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&a.jsxs(Ct,{variant:"warning",children:[a.jsx(Be,{size:12,className:"animate-spin"}),"变基进行中"]}),e.operation==="merge"&&e.conflictedFiles.length===0&&a.jsxs(Ct,{variant:"warning",children:[a.jsx(Be,{size:12,className:"animate-spin"}),"合并进行中"]}),e.ahead>0&&a.jsxs(Ct,{variant:"success",children:[a.jsx(Kr,{size:12}),"领先 ",e.ahead," 个提交"]}),e.behind>0&&a.jsxs(Ct,{variant:"warning",children:["落后 ",e.behind," 个提交"]}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&a.jsxs(Ct,{variant:"neutral",children:[a.jsx(Kr,{size:12}),"已是最新"]})]}),e.hasUncommittedChanges&&a.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:"工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。"})]})}function Sf({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:b,onRefreshCommitMessage:C,onConflict:r}){const{data:i,isLoading:c}=no(s),d=of(),o=nf(),[p,g]=R.useState(null),[S,_]=R.useState("select"),[n,f]=R.useState(""),[h,u]=R.useState(!1),v=i?i.conflictedFiles.length>0:!1,x=i?i.operation!=="idle":!1,w=i?.hasUncommittedChanges??!1;R.useEffect(()=>{e&&(_("select"),g(null),u(!1),C?.())},[e,C]),R.useEffect(()=>{!e||h||f(b??"")},[e,b,h]);const k=L=>{u(!0),f(N=>typeof L=="function"?L(N):L)},y=()=>{g(null),d.mutate(s,{onSuccess:()=>t(!1),onError:L=>{const N=L;N.status===409?(t(!1),r()):g(N.message??"变基失败")}})},E=()=>{g(null),_("confirm")},j=()=>{g(null);const L=n.trim()||void 0;o.mutate({id:s,commitMessage:L},{onSuccess:()=>t(!1),onError:N=>{const B=N;B.status===409?(t(!1),r()):g(B.message??"合并失败")}})},A=S==="confirm"?"确认合并":"Git 操作";return a.jsx(xr,{isOpen:e,onClose:()=>t(!1),title:A,children:c||!i?a.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[a.jsx(Be,{size:18,className:"animate-spin"}),a.jsx("span",{className:"text-sm",children:"加载分支状态..."})]}):S==="confirm"?a.jsx(Cf,{editableMessage:n,setEditableMessage:k,error:p,isPending:o.isPending,onConfirm:j,onBack:()=>_("select"),branchName:l,targetBranch:m}):a.jsx(yf,{gitStatus:i,branchName:l,targetBranch:m,error:p,isDirty:w,hasConflicts:v,isOperationInProgress:x,rebasePending:d.isPending,mergePending:o.isPending,onRebase:y,onMerge:E})})}function yf({gitStatus:e,branchName:t,targetBranch:s,error:l,isDirty:m,hasConflicts:b,isOperationInProgress:C,rebasePending:r,mergePending:i,onRebase:c,onMerge:d}){return a.jsxs("div",{className:"space-y-5",children:[a.jsx(xf,{gitStatus:e,branchName:t,targetBranch:s}),l&&a.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{onClick:c,disabled:r||b||C||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:a.jsx(ga,{size:16,className:"text-blue-600"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-neutral-900",children:r?"变基中...":"变基 (Rebase)"}),a.jsxs("div",{className:"text-xs text-neutral-500",children:["将当前分支变基到最新的 ",s]})]})]}),a.jsxs("button",{onClick:d,disabled:i||b||C||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:a.jsx(on,{size:16,className:"text-emerald-600"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i?"合并中...":"合并 (Merge)"}),a.jsxs("div",{className:"text-xs text-neutral-500",children:["Squash merge 到 ",s]})]})]})]})]})}function Cf({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:b,branchName:C,targetBranch:r}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:C}),a.jsx(en,{size:14,className:"text-neutral-400"}),a.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:"提交消息"}),a.jsx("textarea",{value:e,onChange:i=>t(i.target.value),placeholder:"输入提交消息...",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()&&a.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:"留空将使用默认消息"})]}),s&&a.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:s}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{onClick:b,disabled:l,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:"返回"}),a.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?a.jsxs(a.Fragment,{children:[a.jsx(Be,{size:14,className:"animate-spin"}),"合并中..."]}):a.jsxs(a.Fragment,{children:[a.jsx(on,{size:14}),"确认合并"]})})]})]})}const wf="/api";function Ef(e){if(!Qt())return e;const t=Zt();if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}token=${encodeURIComponent(t)}`}const kf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?Ef(`${wf}/attachments/by-path?path=${encodeURIComponent(e)}`):e,Rf=({src:e,alt:t,...s})=>a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:a.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"})}),Df={img:Rf},Tf=675,Ti=320,ji=1200,jf=a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[a.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:a.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:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),a.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:"Select a task from the sidebar to view logs, monitor execution, or interact with an agent."})]}),Li=[{status:le.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:a.jsx(mr,{className:"w-3 h-3"})},{status:le.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:a.jsx(vr,{className:"w-3 h-3"})},{status:le.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:a.jsx(gr,{className:"w-3 h-3"})},{status:le.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:a.jsx(_r,{className:"w-3 h-3"})},{status:le.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:a.jsx(br,{className:"w-3 h-3"})}];function Lf({status:e,onChangeStatus:t}){const[s,l]=R.useState(!1),m=R.useRef(null);R.useEffect(()=>{if(!s)return;const C=r=>{m.current&&!m.current.contains(r.target)&&l(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s]);const b=Li.find(C=>C.status===e);return a.jsxs("div",{className:"relative",ref:m,children:[a.jsxs("button",{onClick:()=>t&&l(C=>!C),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${b.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[b.icon,a.jsx("span",{children:e}),t&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${s?"rotate-180":""}`,children:a.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),s&&a.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:Li.filter(C=>C.status!==e).map(C=>a.jsxs("button",{onClick:()=>{t?.(C.status),l(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${C.hoverClass}`,children:[a.jsx("span",{className:C.className.split(" ").find(r=>r.startsWith("text-")),children:C.icon}),a.jsx("span",{className:"text-neutral-700",children:C.status})]},C.status))})]})}function Af({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const[m,b]=R.useState(""),[C,r]=R.useState(!1),[i,c]=R.useState(!1),[d,o]=R.useState(!1),[p,g]=R.useState(!1),[S,_]=R.useState(!1),n=R.useRef(null),f=R.useRef(null),h=R.useRef(null),{scrollRef:u,contentRef:v,isAtBottom:x,scrollToBottom:w}=kn({resize:"smooth",initial:"instant"}),[k,y]=R.useState(Tf),[E,j]=R.useState(!0),[A,L]=R.useState(!1),N=R.useRef(0),B=R.useRef(0),I=R.useRef(null),{data:H,isLoading:W}=io(e?.id??""),D=cf(e?.id),M=R.useMemo(()=>{if(!H)return null;const V=we=>{const ht=we.createdAt,ut=we.endedAt??we.startedAt??ht;if(!ut)return 0;const Dt=Date.parse(ut);return Number.isNaN(Dt)?0:Dt},te=(we,ht)=>{const ut=we.filter(Dt=>ht.includes(Dt.status));return ut.length===0?null:ut.sort((Dt,Ro)=>V(Ro)-V(Dt))[0]??null},xe=H.filter(we=>we.status==="ACTIVE"&&Array.isArray(we.sessions)).flatMap(we=>we.sessions??[]),Ue=te(xe,[Me.RUNNING])??te(xe,[Me.PENDING])??te(xe,[Me.COMPLETED,Me.FAILED,Me.CANCELLED]);if(Ue)return Ue;const Ye=H.filter(we=>we.status==="MERGED"&&Array.isArray(we.sessions)).flatMap(we=>we.sessions??[]);return te(Ye,[Me.COMPLETED,Me.FAILED,Me.CANCELLED])},[H]),P=M?.id??"",O=M?.status===Me.RUNNING||M?.status===Me.PENDING,{data:U}=js(),[X,Y]=R.useState(null);R.useEffect(()=>{Y(M?.providerId??null)},[M?.providerId]);const Q=R.useMemo(()=>!M||!H?!1:!H.some(te=>te.status==="ACTIVE"&&te.sessions?.some(xe=>xe.id===M.id)),[M,H]),oe=R.useMemo(()=>{if(H){for(const V of H)if(V.status==="ACTIVE"&&V.worktreePath)return V.worktreePath;return H[0]?.worktreePath}},[H]),T=R.useMemo(()=>H?H.find(te=>te.status==="ACTIVE")?.id:void 0,[H]),{data:F}=no(T??""),$=R.useMemo(()=>H?H.find(te=>te.status==="ACTIVE")?.sessions??[]:[],[H]),z=R.useMemo(()=>H?H.find(te=>te.status==="ACTIVE")?.branchName??"":"",[H]),Z=R.useMemo(()=>H?H.find(te=>te.status==="ACTIVE")?.commitMessage:void 0,[H]),q=Ie(),ne=R.useCallback(()=>e?.id?q.invalidateQueries({queryKey:he.workspaces.list(e.id)}):Promise.resolve(),[e?.id,q]);R.useEffect(()=>{if(!S)return;const V=te=>{n.current&&!n.current.contains(te.target)&&_(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[S]);const fe=Mr(),ye=Nr(),Le=R.useCallback(()=>{T&&ye.mutate({workspaceId:T})},[T,ye]),J=R.useCallback(()=>{!e?.id||!t||(t(e.id),c(!1))},[e?.id,t]),{isConnected:Fe,isLoadingSnapshot:Ke,logs:Ne,entries:qe,attach:Re}=$i({sessionId:P,onExit:R.useCallback(()=>{q.invalidateQueries({queryKey:["workspaces"]})},[q])});R.useEffect(()=>{if(!e?.id)return;const V=dt.connect();V.emit(ot.SUBSCRIBE,{topic:"task",id:e.id});const te=Ue=>{Ue.taskId===e.id&&q.invalidateQueries({queryKey:["tasks"]})},xe=Ue=>{Ue.taskId===e.id&&q.invalidateQueries({queryKey:he.workspaces.list(e.id)})};return V.on(Oe.TASK_UPDATED,te),V.on(Oe.WORKSPACE_COMMIT_MESSAGE_UPDATED,xe),()=>{V.off(Oe.TASK_UPDATED,te),V.off(Oe.WORKSPACE_COMMIT_MESSAGE_UPDATED,xe),V.emit(ot.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,q]),R.useEffect(()=>{if(!P)return;const V=dt.connect(),te=xe=>{xe.sessionId===P&&q.invalidateQueries({queryKey:["workspaces"]})};return V.on(Oe.SESSION_COMPLETED,te),()=>{V.off(Oe.SESSION_COMPLETED,te)}},[P,q]);const{todos:G}=Ui(qe),{files:ae,addFiles:ce,removeFile:se,clear:me,buildMarkdownLinks:pe,hasFiles:Ce,isUploading:Te}=Pr(),He=R.useMemo(()=>{if(!M?.tokenUsage)return;const V=M.tokenUsage;if(typeof V.totalTokens=="number")return V},[M?.tokenUsage]),be=lo(Ne,He);R.useEffect(()=>{P&&Fe&&Re()},[P,Fe,Re]);const tt=R.useRef(e?.id);R.useEffect(()=>{tt.current!==e?.id&&w(),tt.current=e?.id},[e?.id,w]);const ct=ao(),it=R.useRef(!1),mt=R.useCallback(async()=>{if(!m.trim()&&!Ce||!P||it.current||Te)return;it.current=!0;const V=pe(),te=[m.trim(),V].filter(Boolean).join(`
76
-
77
- `);b(""),me(),f.current&&(f.current.style.height="60px"),fe.mutate({id:P,message:te,providerId:X??void 0},{onSuccess:()=>{Re()},onSettled:()=>{it.current=!1}})},[m,P,fe,Re,Ce,Te,pe,me,X]),Rt=R.useCallback(async()=>{P&&(await ct.mutateAsync(P),q.invalidateQueries({queryKey:["workspaces"]}))},[P,ct,q]),yt=R.useCallback(V=>{const te=V.target.files;te&&te.length>0&&ce(Array.from(te)),V.target.value=""},[ce]),os=R.useCallback(V=>{const te=V.clipboardData.items,xe=[];for(const Ue of te)if(Ue.kind==="file"){const Ye=Ue.getAsFile();Ye&&xe.push(Ye)}xe.length>0&&(V.preventDefault(),ce(xe))},[ce]),[K,re]=R.useState(!1),ie=R.useCallback(V=>{V.preventDefault(),re(!0)},[]),de=R.useCallback(V=>{V.preventDefault(),re(!1)},[]),_e=R.useCallback(V=>{V.preventDefault(),re(!1);const te=V.dataTransfer.files;te.length>0&&ce(Array.from(te))},[ce]),je=R.useCallback(V=>{const te=V.clientX-N.current,xe=Math.max(Ti,Math.min(B.current+te,ji));I.current&&(I.current.style.width=`${xe}px`),B.current=B.current},[]),We=R.useCallback(()=>{if(L(!1),I.current){const V=I.current.getBoundingClientRect().width;y(Math.max(Ti,Math.min(Math.round(V),ji)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);R.useEffect(()=>{if(A)return document.addEventListener("mousemove",je),document.addEventListener("mouseup",We),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",We),document.body.style.cursor="",document.body.style.userSelect=""}},[A,je,We]);const Xe=R.useCallback(V=>{V.preventDefault(),N.current=V.clientX,B.current=k,L(!0)},[k]),Ze=R.useCallback(()=>{j(V=>!V)},[]),vt=R.useCallback(V=>{b(V.target.value);const te=V.target;te.style.height="auto";const xe=te.scrollHeight;te.style.height=`${Math.max(60,Math.min(xe,300))}px`},[]),Pe=R.useMemo(()=>{const V=[];if(H&&H.length>0){const te=H.some(Ye=>Ye.status==="ACTIVE"),xe=H.some(Ye=>Ye.sessions?.some(we=>we.status===Me.RUNNING||we.status===Me.PENDING)),Ue=H.some(Ye=>Ye.status==="ACTIVE");xe&&V.push("正在运行的 Agent 将被停止"),Ue&&V.push("分支上未合并的变更将丢失"),te&&V.push("关联的工作目录(worktree)将被清理")}return V},[H]);return e?a.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[a.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:[a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),a.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),a.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),a.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Lf,{status:e.status,onChangeStatus:l?V=>l(e.id,V):void 0}),T&&a.jsx("button",{onClick:()=>g(!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:"Git 操作",children:a.jsx(ba,{size:18})}),a.jsx("button",{onClick:Le,disabled:!T,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:"Open in IDE",children:a.jsx(Ls,{size:18})}),a.jsx("button",{onClick:Ze,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:"Toggle Workspace",children:E?a.jsx(Ma,{size:18}):a.jsx(Oa,{size:18})}),t&&a.jsxs("div",{className:"relative",ref:n,children:[a.jsx("button",{onClick:()=>_(V=>!V),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:"More actions",children:a.jsx(sn,{size:18})}),S&&a.jsx("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:a.jsxs("button",{onClick:()=>{c(!0),_(!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:[a.jsx(Qi,{size:15}),a.jsx("span",{children:"删除任务"})]})})]})]})]}),T&&F&&a.jsx(gf,{workspaceId:T,gitStatus:F,onResolve:()=>o(!0)}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{ref:I,className:`flex flex-col bg-white relative ${E?"flex-shrink-0":"flex-1"}`,style:{width:E?k:"100%"},children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:u,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:a.jsxs("div",{ref:v,className:"w-full",children:[a.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx(Ki,{urlTransform:kf,components:Df,children:e.description})}):a.jsx("p",{className:"text-sm text-neutral-400 italic",children:"No description"})}),D&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[D.status==="running"&&a.jsxs(a.Fragment,{children:[a.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:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsxs("span",{children:["Setup (",D.currentIndex,"/",D.totalCommands,"): ",a.jsx("code",{children:D.currentCommand})]})]}),D.status==="completed"&&a.jsx("span",{className:"text-emerald-600",children:"Setup 完成"}),D.status==="failed"&&a.jsxs("span",{className:"text-red-500",children:["Setup 失败: ",D.error]})]}),W?a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:"Loading..."})]}):P?Ke?a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:"Loading logs..."})]}):Ne.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8",children:O?"Waiting for agent output...":"No logs recorded for this session."}):a.jsx(qi,{logs:Ne}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[a.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:a.jsx(At,{size:24,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:"尚未启动 Agent"}),a.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:"选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。"}),a.jsxs(at,{onClick:()=>r(!0),children:[a.jsx(At,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!x&&a.jsxs("button",{onClick:()=>w(),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":"Scroll to bottom",children:[a.jsx(Ji,{size:14}),a.jsx("span",{children:"回到底部"})]})]}),G.length>0&&a.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:a.jsx(Xi,{todos:G})}),Q?a.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:a.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[a.jsx("span",{className:"text-sm text-neutral-500",children:"代码已合并,以上为历史沟通记录"}),a.jsxs(at,{size:"sm",onClick:()=>r(!0),children:[a.jsx(At,{size:14,className:"mr-1.5"}),"启动新 Agent"]})]})}):a.jsx("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:ie,onDragLeave:de,onDrop:_e,children:a.jsxs("div",{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 ${K?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[a.jsx(Es,{files:ae,onRemove:se}),a.jsx("textarea",{ref:f,value:m,onChange:vt,onPaste:os,onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),mt())},rows:1,placeholder:K?"Drop files here...":P&&!O?"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"}}),a.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:yt}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{onClick:()=>h.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:"Upload file",children:a.jsx(ms,{size:18})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[M&&U&&a.jsx(ho,{providers:U,currentProviderId:X,agentType:M.agentType,onSelect:Y}),a.jsx(Rn,{usage:be}),O&&!m.trim()&&!Ce?a.jsx("button",{onClick:Rt,disabled:ct.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:a.jsx(Yi,{size:14})}):a.jsx("button",{onClick:mt,disabled:!m.trim()&&!Ce||Te,className:`p-2 rounded-lg transition-all duration-200 ${(m.trim()||Ce)&&!Te?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:a.jsx(tn,{size:18})})]})]})]})})]}),E&&a.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:Xe}),E&&a.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:a.jsx(ro,{sessionId:P||void 0,workingDir:oe,projectId:e.projectId})})]}),a.jsx(co,{isOpen:C,onClose:()=>r(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),T&&a.jsx(Sf,{open:p,onOpenChange:g,workspaceId:T,branchName:z,targetBranch:e.mainBranch,commitMessage:Z,onRefreshCommitMessage:ne,onConflict:()=>o(!0)}),T&&F&&F.conflictOp&&a.jsx(bf,{open:d,onOpenChange:o,workspaceId:T,conflictOp:F.conflictOp,conflictedFiles:F.conflictedFiles,sourceBranch:z,targetBranch:e.mainBranch,sessions:$}),a.jsx(Gi,{isOpen:i,onClose:()=>c(!1),onConfirm:J,title:"删除任务",description:a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),Pe.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:Pe.map((V,te)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:V})]},te))})]}),confirmText:"删除",variant:"danger",isLoading:s})]}):jf}function Or(e){switch(e){case nt.TODO:return le.Pending;case nt.IN_PROGRESS:return le.Running;case nt.IN_REVIEW:return le.Review;case nt.DONE:return le.Done;case nt.CANCELLED:return le.Cancelled}}function Nf(e){switch(e){case le.Pending:return nt.TODO;case le.Running:return nt.IN_PROGRESS;case le.Review:return nt.IN_REVIEW;case le.Done:return nt.DONE;case le.Cancelled:return nt.CANCELLED}}function Mf(e){switch(e){case as.CLAUDE_CODE:return"Claude Code";case as.GEMINI_CLI:return"Gemini CLI";case as.CURSOR_AGENT:return"Cursor Agent";case as.CODEX:return"Codex"}}const ks=["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 uo(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 fo(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function Pf(e){return{id:e.id,name:e.name,color:e.color||ks[uo(e.name,ks.length)]}}function Of(e){const t=fo(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:Mf(m.agentType),branch:s}}return{agent:"—",branch:s}}function Bf(e){const{agent:t,branch:s}=Of(e.workspaces);return{id:e.id,projectId:e.projectId,title:e.title,status:Or(e.status),agent:t,branch:s,description:e.description??""}}function If(e,t,s){const l=fo(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||ks[uo(t.name,ks.length)],title:e.title,status:Or(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??""}}function Ff(e,t){const s={};return lt({queryKey:he.tasks.list(e,t),queryFn:()=>ve.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function Hf(e){const t=Ie();return Ge({mutationFn:s=>ve.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:he.tasks.list(e)}),t.invalidateQueries({queryKey:he.tasks.stats(e)})}})}function zf(){const e=Ie();return Ge({mutationFn:({id:t,status:s})=>ve.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:he.tasks.all}),e.invalidateQueries({queryKey:he.tasks.detail(t.id)})}})}function Wf(){const e=Ie();return Ge({mutationFn:t=>ve.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:he.tasks.all})}})}function $f(e){const t=Ie(),s=R.useRef(new Set);R.useEffect(()=>{if(e.length===0)return;const l=dt.connect(),m=s.current,b=new Set(e);for(const i of b)m.has(i)||l.emit(ot.SUBSCRIBE,{topic:"project",id:i},c=>{c.success&&m.add(i)});for(const i of m)b.has(i)||l.emit(ot.UNSUBSCRIBE,{topic:"project",id:i},()=>{m.delete(i)});const C=i=>{t.invalidateQueries({queryKey:he.tasks.list(i.projectId)}),t.invalidateQueries({queryKey:he.tasks.detail(i.taskId)})},r=i=>{t.invalidateQueries({queryKey:he.tasks.list(i.projectId)}),t.removeQueries({queryKey:he.tasks.detail(i.taskId)})};return l.on(Oe.TASK_UPDATED,C),l.on(Oe.TASK_DELETED,r),()=>{l.off(Oe.TASK_UPDATED,C),l.off(Oe.TASK_DELETED,r);for(const i of m)l.emit(ot.UNSUBSCRIBE,{topic:"project",id:i});m.clear()}},[e,t])}const po=768;function Uf(e){const t=window.matchMedia(`(max-width: ${po-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Kf(){return window.innerWidth<po}function qf(){return!1}function Xf(){return R.useSyncExternalStore(Uf,Kf,qf)}const Ai={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 Yf(e){const t=e.split("/");return t[t.length-1]||e}function Vf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Gf({workingDir:e,filePath:t,type:s}){const{data:l,isLoading:m,isError:b}=eo(e,t,s);if(m)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Be,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:"Failed to load diff."});const C=l?.diff||"";if(!C.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No diff content."});const r=C.split(`
78
- `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,c)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",d,o),children:i},c)})})}function Qf({entry:e,type:t,workingDir:s}){const[l,m]=R.useState(!1),b=Ai[e.status]||Ai.M,C=Vf(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Yf(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(pt,{size:14}):a.jsx(kt,{size:14})})]}),l&&a.jsx(Gf,{workingDir:s,filePath:e.path,type:t})]})}function Ni({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const[b,C]=R.useState(m);return t.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>C(r=>!r),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[a.jsx("span",{className:"text-neutral-400",children:b?a.jsx(pt,{size:14}):a.jsx(kt,{size:14})}),a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:e}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),b&&a.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(r=>a.jsx(Qf,{entry:r,type:s,workingDir:l},`${s}:${r.path}`))})]})}function Zf({workingDir:e}){const{data:t,isLoading:s,isError:l}=Jn(e);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."});if(s)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading changes..."})]});if(l)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load changes."});const m=t?.uncommitted||[],b=t?.committed||[];return m.length+b.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(qt,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:"No pending changes"})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx(Ni,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(Ni,{title:"Committed",entries:b,type:"committed",workingDir:e,defaultOpen:!1})]})}const tr=50,Mi={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 Jf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:s<86400?`${Math.floor(s/3600)}h ago`:s<604800?`${Math.floor(s/86400)}d ago`:new Date(e*1e3).toLocaleDateString()}function ep(e){const t=e.split("/");return t[t.length-1]||e}function tp(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function sp({workingDir:e,hash:t,filePath:s}){const{data:l,isLoading:m,isError:b}=so(e,t,s);if(m)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Be,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:"Failed to load diff."});const C=l?.diff||"";if(!C.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No diff content."});const r=C.split(`
79
- `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,c)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",d,o),children:i},c)})})}function rp({entry:e,workingDir:t,hash:s}){const[l,m]=R.useState(!1),b=Mi[e.status]||Mi.M,C=tp(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:Se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:ep(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(pt,{size:14}):a.jsx(kt,{size:14})})]}),l&&a.jsx(sp,{workingDir:t,hash:s,filePath:e.path})]})}function ip({commit:e,workingDir:t}){const[s,l]=R.useState(!1),{data:m,isLoading:b}=to(t,s?e.hash:null),C=m?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>l(r=>!r),className:Se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",s&&"bg-neutral-50"),children:[a.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:a.jsx("div",{className:Se("w-2.5 h-2.5 rounded-full shrink-0",s?"bg-blue-500":"bg-neutral-300")})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),a.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[a.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),a.jsx("span",{className:"text-[11px] text-neutral-400",children:Jf(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:s?a.jsx(pt,{size:14}):a.jsx(kt,{size:14})})]}),s&&a.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&a.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),b?a.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[a.jsx(Be,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:"Loading files..."})]}):C.length===0?a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No files changed"}):a.jsx("div",{className:"divide-y divide-neutral-100",children:C.map(r=>a.jsx(rp,{entry:r,workingDir:t,hash:e.hash},r.path))})]})]})}function np({workingDir:e}){const{data:t,isLoading:s,isError:l,fetchNextPage:m,hasNextPage:b,isFetchingNextPage:C}=Zi({queryKey:he.git.log(e||""),queryFn:({pageParam:i=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(tr),skip:String(i)}}),initialPageParam:0,getNextPageParam:(i,c)=>i.commits.length<tr?void 0:c.length*tr,enabled:!!e}),r=t?.pages.flatMap(i=>i.commits)||[];return e?s?a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Be,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:"Loading history..."})]}):l?a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load history."}):r.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(Mt,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:"No commit history"})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>a.jsx(ip,{commit:i,workingDir:e},i.hash))}),b&&a.jsx("button",{type:"button",onClick:()=>m(),disabled:C,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:C?a.jsxs(a.Fragment,{children:[a.jsx(Be,{size:14,className:"animate-spin"})," Loading..."]}):"Load more"})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."})}const op="/api";function ap(e){if(!Qt())return e;const t=Zt();if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}token=${encodeURIComponent(t)}`}const lp=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?ap(`${op}/attachments/by-path?path=${encodeURIComponent(e)}`):e,cp=({src:e,alt:t,...s})=>a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:a.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"})}),hp={img:cp};function up({status:e}){const t={[le.Running]:"bg-blue-500",[le.Review]:"bg-amber-500",[le.Pending]:"bg-neutral-400",[le.Done]:"bg-emerald-500",[le.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const dp=[{key:"chat",label:"Chat",icon:Da},{key:"changes",label:"Changes",icon:qt},{key:"history",label:"History",icon:Mt},{key:"workspace",label:"Workspace",icon:nn}];function fp({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const[m,b]=R.useState("chat"),[C,r]=R.useState(""),[i,c]=R.useState(!1),[d,o]=R.useState(!1),[p,g]=R.useState(!1),S=R.useRef(null),_=R.useRef(null),n=R.useRef(null),{scrollRef:f,contentRef:h,isAtBottom:u,scrollToBottom:v}=kn({resize:"smooth",initial:"instant"}),x=Ie();R.useEffect(()=>{if(!p)return;const G=ae=>{S.current&&!S.current.contains(ae.target)&&g(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[p]);const{data:w,isLoading:k}=io(e.id),y=R.useMemo(()=>{if(!w)return null;const G=w.filter(se=>se.status==="ACTIVE"&&Array.isArray(se.sessions)).flatMap(se=>se.sessions??[]),ae=se=>{const me=se.createdAt,pe=se.endedAt??se.startedAt??me;if(!pe)return 0;const Ce=Date.parse(pe);return Number.isNaN(Ce)?0:Ce},ce=se=>{const me=G.filter(pe=>se.includes(pe.status));return me.length===0?null:me.sort((pe,Ce)=>ae(Ce)-ae(pe))[0]??null};return ce([Me.RUNNING])??ce([Me.PENDING])??ce([Me.COMPLETED,Me.FAILED,Me.CANCELLED])},[w]),E=y?.id??"",j=y?.status===Me.RUNNING||y?.status===Me.PENDING,{data:A}=js(),[L,N]=R.useState(null);R.useEffect(()=>{N(y?.providerId??null)},[y?.providerId]);const B=R.useMemo(()=>{if(w){for(const G of w)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return w[0]?.worktreePath}},[w]),I=R.useMemo(()=>{if(w)return w.find(G=>G.status==="ACTIVE")?.id},[w]),H=R.useMemo(()=>{const G=[];if(w&&w.length>0){const ae=w.some(se=>se.status==="ACTIVE");w.some(se=>se.sessions?.some(me=>me.status===Me.RUNNING||me.status===Me.PENDING))&&G.push("正在运行的 Agent 将被停止"),ae&&(G.push("分支上未合并的变更将丢失"),G.push("关联的工作目录(worktree)将被清理"))}return G},[w]),W=Mr(),D=Nr(),M=ao(),{isConnected:P,isLoadingSnapshot:O,logs:U,entries:X,attach:Y}=$i({sessionId:E,onExit:R.useCallback(()=>{x.invalidateQueries({queryKey:["workspaces"]})},[x])}),{todos:Q}=Ui(X),{files:oe,addFiles:T,removeFile:F,clear:$,buildMarkdownLinks:z,hasFiles:Z,isUploading:q}=Pr(),ne=R.useMemo(()=>{if(!y?.tokenUsage)return;const G=y.tokenUsage;if(typeof G.totalTokens=="number")return G},[y?.tokenUsage]),fe=lo(U,ne);R.useEffect(()=>{E&&P&&Y()},[E,P,Y]),R.useEffect(()=>{v()},[e.id,v]);const ye=R.useRef(!1),Le=R.useCallback(async()=>{if(!C.trim()&&!Z||!E||ye.current||q)return;ye.current=!0;const G=z(),ae=[C.trim(),G].filter(Boolean).join(`
80
-
81
- `);r(""),$(),_.current&&(_.current.style.height="40px"),W.mutate({id:E,message:ae,providerId:L??void 0},{onSuccess:()=>Y(),onSettled:()=>{ye.current=!1}})},[C,E,W,Y,Z,q,z,$,L]),J=R.useCallback(async()=>{E&&(await M.mutateAsync(E),x.invalidateQueries({queryKey:["workspaces"]}))},[E,M,x]),Fe=R.useCallback(G=>{const ae=G.target.files;ae&&ae.length>0&&T(Array.from(ae)),G.target.value=""},[T]),Ke=R.useCallback(G=>{const ae=G.clipboardData.items,ce=[];for(const se of ae)if(se.kind==="file"){const me=se.getAsFile();me&&ce.push(me)}ce.length>0&&(G.preventDefault(),T(ce))},[T]),Ne=R.useCallback(G=>{r(G.target.value);const ae=G.target;ae.style.height="auto",ae.style.height=`${Math.max(40,Math.min(ae.scrollHeight,140))}px`},[]),qe=R.useCallback(()=>{I&&D.mutate({workspaceId:I})},[I,D]),Re=R.useRef(null);return R.useEffect(()=>{const G=window.visualViewport;if(!G)return;let ae=!1;const ce=()=>{Re.current&&(Re.current.style.height=`${G.height}px`,Re.current.style.top=`${G.offsetTop}px`)},se=()=>ce(),me=()=>{ae||ce()},pe=()=>{ae=!0},Ce=()=>{ae=!1,requestAnimationFrame(ce)};return G.addEventListener("resize",se),G.addEventListener("scroll",me),document.addEventListener("touchstart",pe,{passive:!0}),document.addEventListener("touchend",Ce,{passive:!0}),document.addEventListener("touchcancel",Ce,{passive:!0}),()=>{G.removeEventListener("resize",se),G.removeEventListener("scroll",me),document.removeEventListener("touchstart",pe),document.removeEventListener("touchend",Ce),document.removeEventListener("touchcancel",Ce)}},[]),R.useEffect(()=>{const G=Re.current;if(!G)return;const ae=ce=>{let se=ce.target;for(;se&&se!==G;){if(se.tagName==="TEXTAREA"){if(se.scrollHeight>se.clientHeight)return;se=se.parentElement;continue}const pe=window.getComputedStyle(se).overflowY;if((pe==="auto"||pe==="scroll")&&se.scrollHeight>se.clientHeight)return;se=se.parentElement}ce.preventDefault()};return G.addEventListener("touchmove",ae,{passive:!1}),()=>G.removeEventListener("touchmove",ae)},[]),a.jsxs("div",{ref:Re,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[a.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[a.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[a.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:a.jsx(Mo,{size:18})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),a.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[a.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(up,{status:e.status}),a.jsx("button",{onClick:qe,disabled:!I,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(Ls,{size:16})}),s&&a.jsxs("div",{className:"relative",ref:S,children:[a.jsx("button",{onClick:()=>g(G=>!G),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(sn,{size:16})}),p&&a.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:a.jsxs("button",{onClick:()=>{o(!0),g(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(Qi,{size:15}),a.jsx("span",{children:"删除任务"})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:dp.map(({key:G,label:ae,icon:ce})=>a.jsxs("button",{onClick:()=>b(G),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${m===G?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(ce,{size:13}),a.jsx("span",{children:ae})]},G))})]}),m==="chat"&&a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:f,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:h,children:[a.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx(Ki,{urlTransform:lp,components:hp,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),k?a.jsx(Pi,{label:"Loading..."}):E?O?a.jsx(Pi,{label:"Loading logs..."}):U.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:j?"Waiting for agent output...":"No logs recorded."}):a.jsx(qi,{logs:U}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:a.jsx(At,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:"尚未启动 Agent"}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:"选择一个 Agent 来执行此任务"}),a.jsxs(at,{onClick:()=>c(!0),children:[a.jsx(At,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!u&&a.jsxs("button",{onClick:()=>v(),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:[a.jsx(Ji,{size:12}),a.jsx("span",{children:"回到底部"})]})]}),Q.length>0&&a.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:a.jsx(Xi,{todos:Q,compact:!0})}),E&&a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Es,{files:oe,onRemove:F}),a.jsx("textarea",{ref:_,value:C,onChange:Ne,onPaste:Ke,onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),Le())},rows:1,placeholder:j?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:n,type:"file",multiple:!0,className:"hidden",onChange:Fe}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[a.jsx("div",{className:"flex items-center gap-0.5",children:a.jsx("button",{onClick:()=>n.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ms,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[y&&A&&a.jsx(ho,{providers:A,currentProviderId:L,agentType:y.agentType,onSelect:N}),a.jsx(Rn,{usage:fe}),j&&!C.trim()&&!Z?a.jsx("button",{onClick:J,disabled:M.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(Yi,{size:12})}):a.jsx("button",{onClick:Le,disabled:!C.trim()&&!Z||q,className:`p-1.5 rounded-lg transition-colors ${(C.trim()||Z)&&!q?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(tn,{size:15})})]})]})]})})]}),m==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Zf,{workingDir:B})}),m==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(np,{workingDir:B})}),m==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(ro,{sessionId:E||void 0,workingDir:B,projectId:e.projectId,className:"h-full",hideChanges:!0})}),a.jsx(co,{isOpen:i,onClose:()=>c(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(Gi,{isOpen:d,onClose:()=>o(!1),onConfirm:()=>{s?.(e.id),o(!1)},title:"删除任务",description:a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),H.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:H.map((G,ae)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:G})]},ae))})]}),confirmText:"删除",variant:"danger",isLoading:l})]})}function Pi({label:e}){return a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:e})]})}var pp=Object.defineProperty,Rs=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,vo=Object.prototype.propertyIsEnumerable,Oi=(e,t,s)=>t in e?pp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,dr=(e,t)=>{for(var s in t||(t={}))mo.call(t,s)&&Oi(e,s,t[s]);if(Rs)for(var s of Rs(t))vo.call(t,s)&&Oi(e,s,t[s]);return e},fr=(e,t)=>{var s={};for(var l in e)mo.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&Rs)for(var l of Rs(e))t.indexOf(l)<0&&vo.call(e,l)&&(s[l]=e[l]);return s};var Et;(e=>{const t=class ue{constructor(i,c,d,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<ue.MIN_VERSION||i>ue.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const g=this.addEccAndInterleave(d);if(this.drawCodewords(g),o==-1){let S=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const n=this.getPenaltyScore();n<S&&(o=_,S=n),this.applyMask(_)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const d=e.QrSegment.makeSegments(i);return ue.encodeSegments(d,c)}static encodeBinary(i,c){const d=e.QrSegment.makeBytes(i);return ue.encodeSegments([d],c)}static encodeSegments(i,c,d=1,o=40,p=-1,g=!0){if(!(ue.MIN_VERSION<=d&&d<=o&&o<=ue.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,_;for(S=d;;S++){const u=ue.getNumDataCodewords(S,c)*8,v=C.getTotalBits(i,S);if(v<=u){_=v;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[ue.Ecc.MEDIUM,ue.Ecc.QUARTILE,ue.Ecc.HIGH])g&&_<=ue.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const v of u.getData())n.push(v)}m(n.length==_);const f=ue.getNumDataCodewords(S,c)*8;m(n.length<=f),s(0,Math.min(4,f-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<f;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,v)=>h[v>>>3]|=u<<7-(v&7)),new ue(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let d=0;d<c;d++)for(let o=0;o<c;o++)d==0&&o==0||d==0&&o==c-1||d==c-1&&o==0||this.drawAlignmentPattern(i[d],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let d=c;for(let p=0;p<10;p++)d=d<<1^(d>>>9)*1335;const o=(c<<10|d)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(o,p));this.setFunctionModule(8,7,l(o,6)),this.setFunctionModule(8,8,l(o,7)),this.setFunctionModule(7,8,l(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let d=0;d<18;d++){const o=l(c,d),p=this.size-11+d%3,g=Math.floor(d/3);this.setFunctionModule(p,g,o),this.setFunctionModule(g,p,o)}}drawFinderPattern(i,c){for(let d=-4;d<=4;d++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(d)),g=i+o,S=c+d;0<=g&&g<this.size&&0<=S&&S<this.size&&this.setFunctionModule(g,S,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let d=-2;d<=2;d++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+d,Math.max(Math.abs(o),Math.abs(d))!=1)}setFunctionModule(i,c,d){this.modules[c][i]=d,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,d=this.errorCorrectionLevel;if(i.length!=ue.getNumDataCodewords(c,d))throw new RangeError("Invalid argument");const o=ue.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c],p=ue.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c],g=Math.floor(ue.getNumRawDataModules(c)/8),S=o-g%o,_=Math.floor(g/o);let n=[];const f=ue.reedSolomonComputeDivisor(p);for(let u=0,v=0;u<o;u++){let x=i.slice(v,v+_-p+(u<S?0:1));v+=x.length;const w=ue.reedSolomonComputeRemainder(x,f);u<S&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((v,x)=>{(u!=_-p||x>=S)&&h.push(v[u])});return m(h.length==g),h}drawCodewords(i){if(i.length!=Math.floor(ue.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const g=d-p,_=(d+1&2)==0?this.size-1-o:o;!this.isFunction[_][g]&&c<i.length*8&&(this.modules[_][g]=l(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let d=0;d<this.size;d++){let o;switch(i){case 0:o=(d+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=d%3==0;break;case 3:o=(d+c)%3==0;break;case 4:o=(Math.floor(d/3)+Math.floor(c/2))%2==0;break;case 5:o=d*c%2+d*c%3==0;break;case 6:o=(d*c%2+d*c%3)%2==0;break;case 7:o=((d+c)%2+d*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][d]&&o&&(this.modules[c][d]=!this.modules[c][d])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let g=!1,S=0,_=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==g?(S++,S==5?i+=ue.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,_),g||(i+=this.finderPenaltyCountPatterns(_)*ue.PENALTY_N3),g=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(g,S,_)*ue.PENALTY_N3}for(let p=0;p<this.size;p++){let g=!1,S=0,_=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==g?(S++,S==5?i+=ue.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,_),g||(i+=this.finderPenaltyCountPatterns(_)*ue.PENALTY_N3),g=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(g,S,_)*ue.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let g=0;g<this.size-1;g++){const S=this.modules[p][g];S==this.modules[p][g+1]&&S==this.modules[p+1][g]&&S==this.modules[p+1][g+1]&&(i+=ue.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((g,S)=>g+(S?1:0),c);const d=this.size*this.size,o=Math.ceil(Math.abs(c*20-d*10)/d)-1;return m(0<=o&&o<=9),i+=o*ue.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let o=this.size-7;d.length<i;o-=c)d.splice(1,0,o);return d}}static getNumRawDataModules(i){if(i<ue.MIN_VERSION||i>ue.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;c-=(25*d-10)*d-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(ue.getNumRawDataModules(i)/8)-ue.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*ue.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<i-1;o++)c.push(0);c.push(1);let d=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=ue.reedSolomonMultiply(c[p],d),p+1<c.length&&(c[p]^=c[p+1]);d=ue.reedSolomonMultiply(d,2)}return c}static reedSolomonComputeRemainder(i,c){let d=c.map(o=>0);for(const o of i){const p=o^d.shift();d.push(0),c.forEach((g,S)=>d[S]^=ue.reedSolomonMultiply(g,p))}return d}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let d=0;for(let o=7;o>=0;o--)d=d<<1^(d>>>7)*285,d^=(c>>>o&1)*i;return m(d>>>8==0),d}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const d=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(d&&i[0]>=c*4&&i[6]>=c?1:0)+(d&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,d){return i&&(this.finderPenaltyAddHistory(c,d),c=0),c+=this.size,this.finderPenaltyAddHistory(c,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};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(r,i,c){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)c.push(r>>>d&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const b=class Ae{constructor(i,c,d){if(this.mode=i,this.numChars=c,this.bitData=d,c<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let c=[];for(const d of i)s(d,8,c);return new Ae(Ae.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ae.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let d=0;d<i.length;){const o=Math.min(i.length-d,3);s(parseInt(i.substring(d,d+o),10),o*3+1,c),d+=o}return new Ae(Ae.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ae.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],d;for(d=0;d+2<=i.length;d+=2){let o=Ae.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;o+=Ae.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),s(o,11,c)}return d<i.length&&s(Ae.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,c),new Ae(Ae.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ae.isNumeric(i)?[Ae.makeNumeric(i)]:Ae.isAlphanumeric(i)?[Ae.makeAlphanumeric(i)]:[Ae.makeBytes(Ae.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,c);else if(i<16384)s(2,2,c),s(i,14,c);else if(i<1e6)s(6,3,c),s(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Ae(Ae.Mode.ECI,0,c)}static isNumeric(i){return Ae.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ae.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let d=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;d+=4+p+o.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?c.push(i.charCodeAt(d)):(c.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return c}};b.NUMERIC_REGEX=/^[0-9]*$/,b.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,b.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=b;e.QrSegment=b})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.ordinal=m,this.formatBits=b}};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={}))})(Et||(Et={}));(e=>{(t=>{const s=class{constructor(m,b){this.modeBits=m,this.numBitsCharCount=b}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={}))})(Et||(Et={}));var Lt=Et;var mp={L:Lt.QrCode.Ecc.LOW,M:Lt.QrCode.Ecc.MEDIUM,Q:Lt.QrCode.Ecc.QUARTILE,H:Lt.QrCode.Ecc.HIGH},go=128,_o="L",bo="#FFFFFF",xo="#000000",So=!1,yo=1,vp=4,gp=0,_p=.1;function Co(e,t=0){const s=[];return e.forEach(function(l,m){let b=null;l.forEach(function(C,r){if(!C&&b!==null){s.push(`M${b+t} ${m+t}h${r-b}v1H${b+t}z`),b=null;return}if(r===l.length-1){if(!C)return;b===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${b+t},${m+t} h${r+1-b}v1H${b+t}z`);return}C&&b===null&&(b=r)})}),s.join("")}function wo(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,b)=>b<t.x||b>=t.x+t.w?m:!1))}function bp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,b=Math.floor(t*_p),C=m/t,r=(l.width||b)*C,i=(l.height||b)*C,c=l.x==null?e.length/2-r/2:l.x*C,d=l.y==null?e.length/2-i/2:l.y*C,o=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let S=Math.floor(c),_=Math.floor(d),n=Math.ceil(r+c-S),f=Math.ceil(i+d-_);p={x:S,y:_,w:n,h:f}}const g=l.crossOrigin;return{x:c,y:d,h:i,w:r,excavation:p,opacity:o,crossOrigin:g}}function xp(e,t){return t!=null?Math.max(Math.floor(t),0):e?vp:gp}function Eo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:b,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((_,n)=>(_.push(...Lt.QrSegment.makeSegments(n)),_),[]);return Lt.QrCode.encodeSegments(S,mp[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:d,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let g=i.getModules();const S=xp(l,m),_=g.length+S*2,n=bp(g,C,S,b);return{cells:g,margin:S,numCells:_,calculatedImageSettings:n}},[i,C,b,l,m]);return{qrcode:i,margin:d,cells:c,numCells:o,calculatedImageSettings:p}}var Sp=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),yp=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=go,level:C=_o,bgColor:r=bo,fgColor:i=xo,includeMargin:c=So,minVersion:d=yo,boostLevel:o,marginSize:p,imageSettings:g}=l,_=fr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=_,f=fr(_,["style"]),h=g?.src,u=ee.useRef(null),v=ee.useRef(null),x=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,k]=ee.useState(!1),{margin:y,cells:E,numCells:j,calculatedImageSettings:A}=Eo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:g,size:b});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=E;const W=v.current,D=A!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;D&&A.excavation!=null&&(H=wo(E,A.excavation));const M=window.devicePixelRatio||1;B.height=B.width=b*M;const P=b/j*M;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,Sp?I.fill(new Path2D(Co(H,y))):E.forEach(function(O,U){O.forEach(function(X,Y){X&&I.fillRect(Y+y,U+y,1,1)})}),A&&(I.globalAlpha=A.opacity),D&&I.drawImage(W,A.x+y,A.y+y,A.w,A.h)}}),ee.useEffect(()=>{k(!1)},[h]);const L=dr({height:b,width:b},n);let N=null;return h!=null&&(N=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{k(!0)},ref:v,crossOrigin:A?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",dr({style:L,height:b,width:b,ref:x,role:"img"},f)),N)});yp.displayName="QRCodeCanvas";var ko=ee.forwardRef(function(t,s){const l=t,{value:m,size:b=go,level:C=_o,bgColor:r=bo,fgColor:i=xo,includeMargin:c=So,minVersion:d=yo,boostLevel:o,title:p,marginSize:g,imageSettings:S}=l,_=fr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:f,numCells:h,calculatedImageSettings:u}=Eo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:c,marginSize:g,imageSettings:S,size:b});let v=f,x=null;S!=null&&u!=null&&(u.excavation!=null&&(v=wo(f,u.excavation)),x=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Co(v,n);return ee.createElement("svg",dr({height:b,width:b,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},_),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});ko.displayName="QRCodeSVG";function Cp(){return lt({queryKey:he.tunnel.status,queryFn:()=>ve.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function wp(){const e=Ie();return Ge({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ve.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:he.tunnel.status})}})}function Ep(){const e=Ie();return Ge({mutationFn:()=>ve.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:he.tunnel.status})}})}function Bi(){const{data:e}=Cp(),t=wp(),s=Ep(),[l,m]=R.useState(!1),[b,C]=R.useState(null),r=R.useRef(null),[i,c]=R.useState({top:0,right:0}),[d,o]=R.useState(!1),p=e?.running??!1,g=t.isPending,S=e?.shareableUrl,_=e?.token;R.useEffect(()=>{if(l&&r.current){const v=r.current.getBoundingClientRect();c({top:v.bottom+8,right:window.innerWidth-v.right})}},[l]);const n=R.useCallback(()=>{p?m(!0):t.mutate(void 0,{onSuccess:()=>m(!0)})},[p,t]),f=R.useCallback(()=>{S&&(navigator.clipboard.writeText(S),C("url"),setTimeout(()=>C(null),2e3))},[S]),h=R.useCallback(()=>{_&&(navigator.clipboard.writeText(_),C("token"),setTimeout(()=>C(null),2e3))},[_]),u=R.useCallback(()=>{s.mutate(),m(!1),o(!1)},[s]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:r,onClick:n,disabled:g,className:`p-1.5 rounded-md transition-colors ${p?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:p?"Tunnel active":"Share via tunnel",children:g?a.jsx(Be,{size:16,className:"animate-spin"}):a.jsx(Ds,{size:16})}),p&&!g&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),l&&p&&Tt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>m(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:i.top,right:i.right},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),"Tunnel Active"]}),a.jsx("button",{onClick:()=>m(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(Ts,{size:14})})]}),_&&a.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:[a.jsx(za,{size:12}),a.jsx("span",{children:"Token protected"})]}),S&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(ko,{value:S,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:S??e?.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:v=>v.target.select()}),a.jsx("button",{onClick:f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:"Copy shareable link",children:b==="url"?a.jsx(Ut,{size:14,className:"text-emerald-500"}):a.jsx(qr,{size:14})})]}),_&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>o(!d),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:d?"Hide token":"Show token"}),d&&a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.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:_}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:"Copy token",children:b==="token"?a.jsx(Ut,{size:14,className:"text-emerald-500"}):a.jsx(qr,{size:14})})]})]}),a.jsx("button",{onClick:u,disabled:s.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:s.isPending?"Stopping...":"Stop Tunnel"})]})]}),document.body)]})}const Ii={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},It=R.lazy(()=>Wi(()=>import("./modal-CCInxYr_.js").then(e=>e.m),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.Modal}))),sr=R.lazy(()=>Wi(()=>import("./folder-picker-CmgJx3lM.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12,13])).then(e=>({default:e.FolderPicker}))),Fi=a.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:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Hi=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),kp=260,Rp=600,zi=400;function Wp(){const[e,t]=R.useState(null),[s,l]=R.useState(null),[m,b]=R.useState(zi),[C,r]=R.useState(!1),[i,c]=R.useState(!1),[d,o]=R.useState(""),[p,g]=R.useState(""),[S,_]=R.useState(""),[n,f]=R.useState(""),[h,u]=R.useState(""),[v,x]=R.useState(""),[w,k]=R.useState("idle"),{files:y,addFiles:E,removeFile:j,clear:A,buildMarkdownLinks:L,isUploading:N}=Pr(),B=R.useRef(null),I=R.useRef(!1),H=R.useRef(0),W=R.useRef(zi),D=R.useRef(null),M=Ie(),{data:P,isLoading:O}=js(),{data:U,isLoading:X}=Yo(),Y=U?.data??[],Q=R.useMemo(()=>Y.map(Pf),[Y]),oe=R.useMemo(()=>Y.map(K=>K.id),[Y]);$f(oe);const{data:T,isLoading:F}=Ff(s??""),$=Jo({queries:s?[]:Y.map(K=>({queryKey:he.tasks.list(K.id),queryFn:()=>ve.get(`/projects/${K.id}/tasks`,{params:{limit:"100"}})}))}),z=!s&&$.some(K=>K.isLoading),Z=R.useMemo(()=>{if(s)return T?.data??[];const K=[];for(const re of $)re.data?.data&&K.push(...re.data.data);return K},[s,T,$]),q=R.useMemo(()=>{const K=new Map;for(const re of Z){const ie=re.createdAt?new Date(re.createdAt).getTime():0,de=K.get(re.projectId)??0;ie>de&&K.set(re.projectId,ie)}return[...Y].sort((re,ie)=>{const de=K.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(K.get(ie.id)??(ie.createdAt?new Date(ie.createdAt).getTime():0))-de})},[Y,Z]),ne=R.useMemo(()=>{if(!P)return[];const K=localStorage.getItem("providerUsageCount"),re=K?JSON.parse(K):{};return[...P].sort((ie,de)=>{const _e=ie.availability.type!=="NOT_FOUND",je=de.availability.type!=="NOT_FOUND";if(_e!==je)return _e?-1:1;const We=re[ie.provider.id]??0;return(re[de.provider.id]??0)-We})},[P]),fe=R.useMemo(()=>Z.map(Bf),[Z]),ye=R.useMemo(()=>new Set,[]),Le=R.useMemo(()=>{if(!e)return null;const K=Z.find(ie=>ie.id===e);if(!K)return null;const re=Y.find(ie=>ie.id===K.projectId);if(!re){const ie=K.workspaces?.find(de=>de.status==="ACTIVE")?.branchName??K.workspaces?.[0]?.branchName??"—";return{id:K.id,projectId:K.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:K.title,status:Or(K.status),branch:ie,mainBranch:"main",description:K.description??""}}return If(K,re)},[e,Z,Y]),J=Vo(),Fe=Hf(h),Ke=Wf(),Ne=zf(),qe=R.useCallback(K=>{Ke.mutate(K,{onSuccess:()=>{e===K&&t(null),M.invalidateQueries({queryKey:he.tasks.all})}})},[Ke,e,M]),Re=R.useCallback((K,re)=>{Ne.mutate({id:K,status:Nf(re)},{onError:()=>{Po.error("状态变更失败,该操作不被允许")}})},[Ne]),G=R.useCallback(K=>{K.preventDefault(),I.current=!0,H.current=K.clientX,W.current=m,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[m]);R.useEffect(()=>{const K=ie=>{if(!I.current)return;const de=ie.clientX-H.current,_e=Math.max(kp,Math.min(Rp,W.current+de));b(_e)},re=()=>{I.current&&(I.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",K),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",re)}},[]);const ae=R.useCallback(()=>{r(!0)},[]),ce=R.useCallback(()=>{const K=localStorage.getItem("lastSelectedProjectId"),re=localStorage.getItem("lastSelectedProviderId"),ie=K&&q.find(je=>je.id===K)?K:s??q[0]?.id??"";u(ie);const de=ne?.find(je=>je.availability.type!=="NOT_FOUND"),_e=re&&ne?.find(je=>je.provider.id===re&&je.availability.type!=="NOT_FOUND")?re:de?.provider.id??"";x(_e),k("idle"),c(!0)},[s,q,ne]),se=R.useCallback(()=>{r(!1),o(""),g("")},[]),me=R.useCallback(()=>{w==="idle"&&(c(!1),_(""),f(""),u(""),x(""),k("idle"),A())},[w,A]),pe=R.useCallback(async()=>{if(!(!d.trim()||!p.trim()))try{await J.mutateAsync({name:d.trim(),repoPath:p.trim()}),se()}catch{}},[d,p,J,se]),Ce=oo(),Te=R.useCallback(async()=>{if(!(!S.trim()||!h))try{const K=L(),re=[n.trim(),K].filter(Boolean).join(`
82
-
83
- `);k("creating-task");const ie=await Fe.mutateAsync({title:S.trim(),description:re||void 0});if(localStorage.setItem("lastSelectedProjectId",h),v){localStorage.setItem("lastSelectedProviderId",v);const de=localStorage.getItem("providerUsageCount"),_e=de?JSON.parse(de):{};_e[v]=(_e[v]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(_e))}if(v){const de=[S.trim(),re].filter(Boolean).join(`
84
-
85
- `);k("creating-workspace");const _e=await ve.post(`/tasks/${ie.id}/workspaces`,{});k("creating-session");const je=await ve.post(`/workspaces/${_e.id}/sessions`,{providerId:v,prompt:de});k("starting-session"),await Ce.mutateAsync(je.id),await M.invalidateQueries({queryKey:he.workspaces.list(ie.id)})}t(ie.id),k("idle"),c(!1),_(""),f(""),u(""),x(""),A()}catch{k("idle")}},[S,n,h,v,Fe,Ce,M,L,A]),He=R.useCallback(K=>{const re=K.target.files;re&&re.length>0&&E(Array.from(re)),K.target.value=""},[E]),be=R.useCallback(K=>{const re=K.clipboardData.items,ie=[];for(const de of re)if(de.kind==="file"){const _e=de.getAsFile();_e&&ie.push(_e)}ie.length>0&&(K.preventDefault(),E(ie))},[E]),[tt,ct]=R.useState(!1),it=R.useCallback(K=>{K.preventDefault(),ct(!0)},[]),mt=R.useCallback(K=>{K.preventDefault(),ct(!1)},[]),Rt=R.useCallback(K=>{K.preventDefault(),ct(!1);const re=K.dataTransfer.files;re.length>0&&E(Array.from(re))},[E]),yt=X||F||z;return Xf()?e&&Le?a.jsxs(a.Fragment,{children:[a.jsx(fp,{task:Le,onBack:()=>t(null),onDeleteTask:qe,isDeleting:Ke.isPending}),a.jsx(R.Suspense,{fallback:null,children:a.jsx(It,{isOpen:C,onClose:se,title:"Create New Project",action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:se,className:"px-4 py-2 text-sm text-neutral-600",children:"Cancel"}),a.jsx("button",{onClick:pe,disabled:!d.trim()||!p.trim()||J.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${d.trim()&&p.trim()&&!J.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:J.isPending?"Creating...":"Create"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),a.jsx("input",{type:"text",value:d,onChange:K=>o(K.target.value),placeholder:"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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),a.jsx(sr,{value:p,onChange:g})]})]})})})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[a.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[Fi,Hi]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Bi,{}),a.jsx(Fr,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:a.jsx(Wr,{size:16})})]})]}),yt&&fe.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:"Loading..."}):a.jsx(oi,{tasks:fe,projects:Q,selectedTaskId:null,onSelectTask:t,filterProjectId:s,setFilterProjectId:l,width:"100%",onCreateProject:ae,onCreateTask:ce,activeTaskIds:ye,onTaskStatusChange:Re})]}),a.jsxs(R.Suspense,{fallback:null,children:[a.jsx(It,{isOpen:C,onClose:se,title:"Create New Project",action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:se,className:"px-4 py-2 text-sm text-neutral-600",children:"Cancel"}),a.jsx("button",{onClick:pe,disabled:!d.trim()||!p.trim()||J.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${d.trim()&&p.trim()&&!J.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:J.isPending?"Creating...":"Create"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),a.jsx("input",{type:"text",value:d,onChange:K=>o(K.target.value),placeholder:"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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),a.jsx(sr,{value:p,onChange:g})]})]})}),a.jsx(It,{isOpen:i,onClose:me,title:"Create New Task",action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:me,disabled:w!=="idle",className:"px-4 py-2 text-sm text-neutral-600 disabled:opacity-50",children:"Cancel"}),a.jsx("button",{onClick:Te,disabled:!S.trim()||!h||w!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg ${S.trim()&&h&&w==="idle"?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ii[w]})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project"}),a.jsx(ls,{value:h,onChange:u,options:q.map(K=>({value:K.id,label:K.name})),placeholder:"Select project...",disabled:w!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Provider"}),a.jsx(ls,{value:v,onChange:x,options:ne.map(({provider:K,availability:re})=>({value:K.id,label:K.name+(re.type==="NOT_FOUND"?" (不可用)":""),disabled:re.type==="NOT_FOUND"})),placeholder:O?"Loading...":"Select provider...",disabled:w!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Task Title"}),a.jsx("input",{type:"text",value:S,onChange:K=>_(K.target.value),placeholder:"e.g., Implement login flow",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",disabled:w!=="idle",onKeyDown:K=>{K.key==="Enter"&&!K.nativeEvent.isComposing&&K.nativeEvent.keyCode!==229&&Te()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Description"}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${tt?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:it,onDragLeave:mt,onDrop:Rt,children:[a.jsx("textarea",{rows:3,value:n,onChange:K=>f(K.target.value),onPaste:be,placeholder:"Optional...",className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:w!=="idle",onKeyDown:K=>{(K.metaKey||K.ctrlKey)&&K.key==="Enter"&&!K.nativeEvent.isComposing&&K.nativeEvent.keyCode!==229&&Te()}}),tt&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:"Drop files here"})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>B.current?.click(),disabled:w!=="idle"||N,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 active:text-neutral-900 active:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(ms,{size:14}),"Attach files"]}),a.jsx("span",{className:"text-xs text-neutral-400",children:"or paste files"})]}),a.jsx("input",{ref:B,type:"file",multiple:!0,onChange:He,className:"hidden"}),a.jsx(Es,{files:y,onRemove:j})]})]})})]})]}):a.jsxs("div",{ref:D,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[a.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[Fi,Hi]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Bi,{}),a.jsx(Fr,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:a.jsx(Wr,{size:16})})]})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[yt&&fe.length===0?a.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:m},children:"Loading..."}):a.jsx(oi,{tasks:fe,projects:Q,selectedTaskId:e,onSelectTask:t,filterProjectId:s,setFilterProjectId:l,width:m,onCreateProject:ae,onCreateTask:ce,activeTaskIds:ye,onTaskStatusChange:Re,onDeleteTask:qe}),a.jsx("div",{onMouseDown:G,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:"Drag to resize"}),a.jsx(Af,{task:Le,onDeleteTask:qe,isDeleting:Ke.isPending,onTaskStatusChange:Re})]}),a.jsxs(R.Suspense,{fallback:null,children:[a.jsx(It,{isOpen:C,onClose:se,title:"Create New Project",action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:se,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:"Cancel"}),a.jsx("button",{onClick:pe,disabled:!d.trim()||!p.trim()||J.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${d.trim()&&p.trim()&&!J.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:J.isPending?"Creating...":"Create Project"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),a.jsx("input",{type:"text",value:d,onChange:K=>o(K.target.value),placeholder:"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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),a.jsx(sr,{value:p,onChange:g})]}),J.isError&&a.jsx("p",{className:"text-xs text-red-500",children:J.error instanceof Error?J.error.message:"Failed to create project"})]})}),a.jsx(It,{isOpen:i,onClose:me,title:"Create New Task",action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:me,disabled:w!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:"Cancel"}),a.jsx("button",{onClick:Te,disabled:!S.trim()||!h||w!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${S.trim()&&h&&w==="idle"?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ii[w]})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project"}),a.jsx(ls,{value:h,onChange:u,options:q.map(K=>({value:K.id,label:K.name})),placeholder:"Select project...",disabled:w!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Agent"}),a.jsx(ls,{value:v,onChange:x,options:ne.map(({provider:K,availability:re})=>({value:K.id,label:K.name+(re.type==="NOT_FOUND"?" (不可用)":""),disabled:re.type==="NOT_FOUND"})),placeholder:O?"Loading...":"Select provider...",disabled:w!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Task Title"}),a.jsx("input",{type:"text",value:S,onChange:K=>_(K.target.value),placeholder:"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:w!=="idle",onKeyDown:K=>{K.key==="Enter"&&!K.nativeEvent.isComposing&&K.nativeEvent.keyCode!==229&&Te()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Description"}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${tt?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:it,onDragLeave:mt,onDrop:Rt,children:[a.jsx("textarea",{rows:3,value:n,onChange:K=>f(K.target.value),onPaste:be,placeholder:"Optional description...",className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:w!=="idle",onKeyDown:K=>{(K.metaKey||K.ctrlKey)&&K.key==="Enter"&&!K.nativeEvent.isComposing&&K.nativeEvent.keyCode!==229&&Te()}}),tt&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:"Drop files here"})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>B.current?.click(),disabled:w!=="idle"||N,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:[a.jsx(ms,{size:14}),"Attach files"]}),a.jsx("span",{className:"text-xs text-neutral-400",children:"or paste/drag files"})]}),a.jsx("input",{ref:B,type:"file",multiple:!0,onChange:He,className:"hidden"}),a.jsx(Es,{files:y,onRemove:j})]}),Fe.isError&&a.jsx("p",{className:"text-xs text-red-500",children:Fe.error instanceof Error?Fe.error.message:"Failed to create task"})]})})]})]})}export{Wp as ProjectKanbanPage};