agent-tower 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/output/__tests__/msg-store-memory.test.d.ts +2 -0
  2. package/dist/output/__tests__/msg-store-memory.test.d.ts.map +1 -0
  3. package/dist/output/__tests__/msg-store-memory.test.js +154 -0
  4. package/dist/output/__tests__/msg-store-memory.test.js.map +1 -0
  5. package/dist/output/msg-store.d.ts +20 -0
  6. package/dist/output/msg-store.d.ts.map +1 -1
  7. package/dist/output/msg-store.js +97 -12
  8. package/dist/output/msg-store.js.map +1 -1
  9. package/dist/socket/index.d.ts +0 -3
  10. package/dist/socket/index.d.ts.map +1 -1
  11. package/dist/socket/index.js +0 -4
  12. package/dist/socket/index.js.map +1 -1
  13. package/dist/socket/socket-gateway.d.ts +0 -3
  14. package/dist/socket/socket-gateway.d.ts.map +1 -1
  15. package/dist/socket/socket-gateway.js +15 -51
  16. package/dist/socket/socket-gateway.js.map +1 -1
  17. package/dist/web/assets/{AgentDemoPage-BskuObus.js → AgentDemoPage-ClnGPAV9.js} +1 -1
  18. package/dist/web/assets/DemoPage-XwuS8vNB.js +4 -0
  19. package/dist/web/assets/{GeneralSettingsPage-DggKcdQM.js → GeneralSettingsPage-CliIgpwf.js} +1 -1
  20. package/dist/web/assets/{NotificationSettingsPage-fDjeTfPh.js → NotificationSettingsPage-y3vhVgPv.js} +1 -1
  21. package/dist/web/assets/{ProfileSettingsPage-CWVSxzJw.js → ProfileSettingsPage-CkU_kZKG.js} +1 -1
  22. package/dist/web/assets/{ProjectKanbanPage-DHNpmw-4.js → ProjectKanbanPage-BddzfZRV.js} +15 -15
  23. package/dist/web/assets/ProjectSettingsPage-B6xhbziO.js +2 -0
  24. package/dist/web/assets/{ProviderSettingsPage-A_AoWMBp.js → ProviderSettingsPage-CfvdeoEU.js} +1 -1
  25. package/dist/web/assets/{button-5iX1e_fm.js → button-BWFTEdOr.js} +1 -1
  26. package/dist/web/assets/{chevron-down-BXQh2Wxh.js → chevron-down-CuPdBAx-.js} +1 -1
  27. package/dist/web/assets/{chevron-right-Cpp4WiwB.js → chevron-right-Cs8vYTMn.js} +1 -1
  28. package/dist/web/assets/{circle-alert-B4o7LpBN.js → circle-alert-EUyZcWhp.js} +1 -1
  29. package/dist/web/assets/{circle-check-0QrYHY8C.js → circle-check-BXZTzqw0.js} +1 -1
  30. package/dist/web/assets/{code-block-OCS4YCEC-CyOCA4DG.js → code-block-OCS4YCEC-BxUpvXK_.js} +1 -1
  31. package/dist/web/assets/{confirm-dialog-DnYr0-iE.js → confirm-dialog-CDLHRthd.js} +1 -1
  32. package/dist/web/assets/folder-picker-CUbhsnhi.js +1 -0
  33. package/dist/web/assets/index-CHN8jahE.js +13 -0
  34. package/dist/web/assets/{loader-circle-DvZK36Ga.js → loader-circle-BHzDVpxt.js} +1 -1
  35. package/dist/web/assets/{mermaid-NOHMQCX5-xPQ5tFq8.js → mermaid-NOHMQCX5-BOSwJqP0.js} +60 -60
  36. package/dist/web/assets/{modal-CvoxLn2x.js → modal-D_AU4URz.js} +1 -1
  37. package/dist/web/assets/{pencil-CNuySmPC.js → pencil-BMxBxIhw.js} +1 -1
  38. package/dist/web/assets/{select-DOJOMQ5p.js → select-BUmRG0LY.js} +1 -1
  39. package/dist/web/assets/{use-profiles-CGAx71Yx.js → use-profiles-C1vlPE-2.js} +1 -1
  40. package/dist/web/assets/use-projects-Bcd5hIOY.js +1 -0
  41. package/dist/web/assets/{use-providers-RzfgfeZ2.js → use-providers-Cdxr4Jbz.js} +1 -1
  42. package/dist/web/index.html +1 -1
  43. package/package.json +1 -1
  44. package/dist/socket/rooms.d.ts +0 -30
  45. package/dist/socket/rooms.d.ts.map +0 -1
  46. package/dist/socket/rooms.js +0 -39
  47. package/dist/socket/rooms.js.map +0 -1
  48. package/dist/web/assets/DemoPage-DM2NLFlQ.js +0 -4
  49. package/dist/web/assets/ProjectSettingsPage-Cf4D6UFs.js +0 -2
  50. package/dist/web/assets/folder-picker-CTcrs_BC.js +0 -1
  51. package/dist/web/assets/index-BLRui4ck.js +0 -13
  52. package/dist/web/assets/rotate-ccw-BusOGXw0.js +0 -1
@@ -1,11 +1,11 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-CvoxLn2x.js","assets/index-BLRui4ck.js","assets/index-BGvfX18x.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CTcrs_BC.js","assets/chevron-right-Cpp4WiwB.js","assets/loader-circle-DvZK36Ga.js","assets/circle-alert-B4o7LpBN.js","assets/rotate-ccw-BusOGXw0.js"])))=>i.map(i=>d[i]);
2
- import{Q as Tr,o as ri,p as aa,v as la,w as ca,x as br,y as ha,z as ua,e as ze,A as da,B as fa,r as k,D as ma,E as pa,G as va,H as ga,I as ii,J as ni,K as _a,M as ba,N as xa,h as xe,R as J,O as Nt,u as he,j as a,s as kt,S as Ve,C as Pt,g as ue,f as Je,q as oe,d as ut,n as Rt,P as Sa,T as oi,U as ya,i as Ca,V as wa,t as ai,L as li,_ as un}from"./index-BLRui4ck.js";import{h as Lr,b as Mr,d as Nr,c as Pr,i as Or,G as Is,u as dn,a as fn,Q as mn,e as pn,T as vn,P as ws,f as gn,S as ci}from"./mermaid-NOHMQCX5-xPQ5tFq8.js";import{C as Ct,a as ss}from"./chevron-down-BXQh2Wxh.js";import{C as Ft}from"./chevron-right-Cpp4WiwB.js";import{P as xr,X as Fs,M as Br,T as _n}from"./modal-CvoxLn2x.js";import{C as Ea,A as bt,S as Te,T as _t}from"./log-adapter-CeKrvZcz.js";import{B as pt}from"./button-5iX1e_fm.js";import{c as Se,t as hi}from"./utils-CkSf8FUe.js";import{F as ka,a as Ra,R as Da}from"./rotate-ccw-BusOGXw0.js";import{L as Ue}from"./loader-circle-DvZK36Ga.js";import{u as Hs}from"./use-providers-RzfgfeZ2.js";import{T as bn,C as Sr}from"./confirm-dialog-DnYr0-iE.js";import{S as vs}from"./select-DOJOMQ5p.js";var Aa=class extends Tr{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:ri()})}getOptimisticResult(e){return e.behavior=ri(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",f=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:la(t,s.data),hasPreviousPage:aa(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ui(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ja(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ta=class extends ca{#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,br.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=l.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),C=s.length!==m.length,r=m.some((f,o)=>f!==s[o]),i=C||r,c=i?!0:v.some((f,o)=>{const p=this.#e[o];return!p||!ha(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ui(s,m).forEach(f=>{f.destroy()}),ui(m,s).forEach(f=>{f.subscribe(o=>{this.#f(f,o)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[l,v=>this.#u(v??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(C=>{C.observer.trackProp(v)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((v,C)=>v!==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=ua(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 v=t.get(m);v?v.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 Tr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ja(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&br.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function La({queries:e,...t},s){const l=ze(),m=da(),v=fa(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ma(g);const n=l.getQueryCache().get(g.queryHash);pa(g,v,n)}),va(v);const[r]=k.useState(()=>new Ta(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(br.batchCalls(g)):ga,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const S=i.some((g,n)=>ii(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new Tr(l,d);if(ii(d,g))return ni(d,h,v);_a(g,m)&&ni(d,h,v)}return[]}):[];if(S.length>0)throw Promise.all(S);const y=i.find((g,n)=>{const d=C[n];return d&&ba({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(y?.error)throw y.error;return c(f())}function xn(e,t){return xa(e,Aa)}const Ma=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Sn=xe("arrow-down",Ma);const Na=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],yn=xe("arrow-right",Na);const Pa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cn=xe("arrow-up",Pa);const Oa=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],di=xe("circle-check-big",Oa);const Ba=[["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"}]],zs=xe("code-xml",Ba);const Ia=[["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"}]],fi=xe("copy",Ia);const Fa=[["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"}]],wn=xe("ellipsis-vertical",Fa);const Ha=[["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"}]],za=xe("file-braces-corner",Ha);const Wa=[["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"}]],rs=xe("file-code-corner",Wa);const $a=[["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=xe("file-exclamation-point",$a);const qa=[["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"}]],En=xe("file-text",qa);const Ka=[["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"}]],kn=xe("folder-open",Ka);const Xa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ya=xe("gauge",Xa);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=xe("git-branch",Va);const Qa=[["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"}]],Za=xe("git-fork",Qa);const Ja=[["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"}]],is=xe("git-graph",Ja);const el=[["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"}]],Rn=xe("git-merge",el);const tl=[["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"}]],Ut=xe("history",tl);const sl=[["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"}]],Ir=xe("image",sl);const rl=[["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"}]],mi=xe("layers",rl);const il=[["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"}]],nl=xe("maximize",il);const ol=[["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"}]],al=xe("message-square",ol);const ll=[["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"}]],cl=xe("panel-left-close",ll);const hl=[["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"}]],ul=xe("panel-left-open",hl);const dl=[["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"}]],fl=xe("panel-right-close",dl);const ml=[["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"}]],pl=xe("panel-right-open",ml);const vl=[["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"}]],Ot=xe("play",vl);const gl=[["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"}]],_l=xe("refresh-cw",gl);const bl=[["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"}]],xl=xe("shield",bl);const Sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=xe("terminal",Sl);const yl=[["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"}]],Cl=xe("zap",yl);const wl=[["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"}]],El=xe("zoom-in",wl);const kl=[["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"}]],Rl=xe("zoom-out",kl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function tt(e){var t,s;return e?qt(e)?e:Fr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Hr(e){const{Document:t}=tt(e);return e instanceof t}function cs(e){return qt(e)?!1:e instanceof tt(e).HTMLElement}function Dn(e){return e instanceof tt(e).SVGElement}function Kt(e){return e?qt(e)?e.document:Fr(e)?Hr(e)?e:cs(e)||Dn(e)?e.ownerDocument:document:document:document}const yt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return yt(()=>{t.current=e}),k.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 Dl(){const e=k.useRef(null),t=k.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=k.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function ns(e,t){t===void 0&&(t=[e]);const s=k.useRef(e);return yt(()=>{s.current!==e&&(s.current=e)},t),s}function hs(e,t){const s=k.useRef();return k.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ks(e){const t=$s(e),s=k.useRef(null),l=k.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function Rs(e){const t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}let rr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=rr[e]==null?0:rr[e]+1;return rr[e]=s,e+"-"+s},[e,t])}function An(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((v,C)=>{const r=Object.entries(C);for(const[i,c]of r){const f=v[i];f!=null&&(v[i]=f+e*c)}return v},{...t})}}const $t=An(1),Ds=An(-1);function Al(e){return"clientX"in e&&"clientY"in e}function zr(e){if(!e)return!1;const{KeyboardEvent:t}=tt(e.target);return t&&e instanceof t}function jl(e){if(!e)return!1;const{TouchEvent:t}=tt(e.target);return t&&e instanceof t}function As(e){if(jl(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 Al(e)?{x:e.clientX,y:e.clientY}:null}const os=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[os.Translate.toString(e),os.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),pi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tl(e){return e.matches(pi)?e:e.querySelector(pi)}const Ll={display:"none"};function Ml(e){let{id:t,value:s}=e;return J.createElement("div",{id:t,style:Ll},s)}function Nl(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 J.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Pl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const jn=k.createContext(null);function Ol(e){const t=k.useContext(jn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bl(){const[e]=k.useState(()=>new Set),t=k.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[k.useCallback(l=>{let{type:m,event:v}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,v)})},[e]),t]}const Il={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-D_AU4URz.js","assets/index-CHN8jahE.js","assets/index-BGvfX18x.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CUbhsnhi.js","assets/chevron-right-Cs8vYTMn.js","assets/loader-circle-BHzDVpxt.js","assets/circle-alert-EUyZcWhp.js","assets/use-projects-Bcd5hIOY.js"])))=>i.map(i=>d[i]);
2
+ import{Q as Tr,k as ri,l as aa,m as la,n as ca,o as br,p as ha,v as ua,e as ze,w as da,x as fa,r as k,y as ma,z as pa,A as va,B as ga,D as ii,E as ni,G as _a,H as ba,I as xa,h as xe,R as J,J as Nt,u as he,j as a,s as kt,S as Ve,C as Ht,g as ue,f as Je,q as oe,d as ut,i as Rt,K as oi,M as Sa,t as ai,L as li,_ as un}from"./index-CHN8jahE.js";import{h as Lr,b as Mr,d as Nr,c as Pr,i as Or,G as Is,u as dn,a as fn,Q as mn,e as pn,T as vn,P as ws,f as gn,S as ci}from"./mermaid-NOHMQCX5-BOSwJqP0.js";import{C as Ct,a as ss}from"./chevron-down-CuPdBAx-.js";import{C as It}from"./chevron-right-Cs8vYTMn.js";import{P as xr,X as Fs,M as Br,T as _n}from"./modal-D_AU4URz.js";import{C as ya,A as bt,S as Te,T as _t}from"./log-adapter-CeKrvZcz.js";import{B as pt}from"./button-BWFTEdOr.js";import{c as Se,t as hi}from"./utils-CkSf8FUe.js";import{F as Ca,a as wa,e as Ea,R as ka,u as Ra,f as Da}from"./use-projects-Bcd5hIOY.js";import{L as Ue}from"./loader-circle-BHzDVpxt.js";import{u as Hs}from"./use-providers-Cdxr4Jbz.js";import{T as bn,C as Sr}from"./confirm-dialog-CDLHRthd.js";import{S as vs}from"./select-BUmRG0LY.js";var Aa=class extends Tr{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:ri()})}getOptimisticResult(e){return e.behavior=ri(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",f=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:la(t,s.data),hasPreviousPage:aa(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ui(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ja(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ta=class extends ca{#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,br.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=l.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),C=s.length!==m.length,r=m.some((f,o)=>f!==s[o]),i=C||r,c=i?!0:v.some((f,o)=>{const p=this.#e[o];return!p||!ha(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ui(s,m).forEach(f=>{f.destroy()}),ui(m,s).forEach(f=>{f.subscribe(o=>{this.#f(f,o)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[l,v=>this.#u(v??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(C=>{C.observer.trackProp(v)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((v,C)=>v!==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=ua(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 v=t.get(m);v?v.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 Tr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ja(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&br.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function La({queries:e,...t},s){const l=ze(),m=da(),v=fa(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ma(g);const n=l.getQueryCache().get(g.queryHash);pa(g,v,n)}),va(v);const[r]=k.useState(()=>new Ta(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(br.batchCalls(g)):ga,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const S=i.some((g,n)=>ii(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new Tr(l,d);if(ii(d,g))return ni(d,h,v);_a(g,m)&&ni(d,h,v)}return[]}):[];if(S.length>0)throw Promise.all(S);const y=i.find((g,n)=>{const d=C[n];return d&&ba({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(y?.error)throw y.error;return c(f())}function xn(e,t){return xa(e,Aa)}const Ma=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Sn=xe("arrow-down",Ma);const Na=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],yn=xe("arrow-right",Na);const Pa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cn=xe("arrow-up",Pa);const Oa=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],di=xe("circle-check-big",Oa);const Ba=[["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"}]],zs=xe("code-xml",Ba);const Ia=[["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"}]],fi=xe("copy",Ia);const Fa=[["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"}]],wn=xe("ellipsis-vertical",Fa);const Ha=[["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"}]],za=xe("file-braces-corner",Ha);const Wa=[["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"}]],rs=xe("file-code-corner",Wa);const $a=[["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=xe("file-exclamation-point",$a);const qa=[["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"}]],En=xe("file-text",qa);const Ka=[["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"}]],kn=xe("folder-open",Ka);const Xa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ya=xe("gauge",Xa);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=xe("git-branch",Va);const Qa=[["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"}]],Za=xe("git-fork",Qa);const Ja=[["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"}]],is=xe("git-graph",Ja);const el=[["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"}]],Rn=xe("git-merge",el);const tl=[["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"}]],Ut=xe("history",tl);const sl=[["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"}]],Ir=xe("image",sl);const rl=[["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"}]],mi=xe("layers",rl);const il=[["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"}]],nl=xe("maximize",il);const ol=[["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"}]],al=xe("message-square",ol);const ll=[["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"}]],cl=xe("panel-left-close",ll);const hl=[["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"}]],ul=xe("panel-left-open",hl);const dl=[["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"}]],fl=xe("panel-right-close",dl);const ml=[["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"}]],pl=xe("panel-right-open",ml);const vl=[["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"}]],Pt=xe("play",vl);const gl=[["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"}]],_l=xe("refresh-cw",gl);const bl=[["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"}]],xl=xe("shield",bl);const Sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=xe("terminal",Sl);const yl=[["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"}]],Cl=xe("zap",yl);const wl=[["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"}]],El=xe("zoom-in",wl);const kl=[["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"}]],Rl=xe("zoom-out",kl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function tt(e){var t,s;return e?qt(e)?e:Fr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Hr(e){const{Document:t}=tt(e);return e instanceof t}function cs(e){return qt(e)?!1:e instanceof tt(e).HTMLElement}function Dn(e){return e instanceof tt(e).SVGElement}function Kt(e){return e?qt(e)?e.document:Fr(e)?Hr(e)?e:cs(e)||Dn(e)?e.ownerDocument:document:document:document}const yt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return yt(()=>{t.current=e}),k.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 Dl(){const e=k.useRef(null),t=k.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=k.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function ns(e,t){t===void 0&&(t=[e]);const s=k.useRef(e);return yt(()=>{s.current!==e&&(s.current=e)},t),s}function hs(e,t){const s=k.useRef();return k.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ks(e){const t=$s(e),s=k.useRef(null),l=k.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function Rs(e){const t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}let rr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=rr[e]==null?0:rr[e]+1;return rr[e]=s,e+"-"+s},[e,t])}function An(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((v,C)=>{const r=Object.entries(C);for(const[i,c]of r){const f=v[i];f!=null&&(v[i]=f+e*c)}return v},{...t})}}const $t=An(1),Ds=An(-1);function Al(e){return"clientX"in e&&"clientY"in e}function zr(e){if(!e)return!1;const{KeyboardEvent:t}=tt(e.target);return t&&e instanceof t}function jl(e){if(!e)return!1;const{TouchEvent:t}=tt(e.target);return t&&e instanceof t}function As(e){if(jl(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 Al(e)?{x:e.clientX,y:e.clientY}:null}const os=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[os.Translate.toString(e),os.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),pi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tl(e){return e.matches(pi)?e:e.querySelector(pi)}const Ll={display:"none"};function Ml(e){let{id:t,value:s}=e;return J.createElement("div",{id:t,style:Ll},s)}function Nl(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 J.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Pl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const jn=k.createContext(null);function Ol(e){const t=k.useContext(jn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bl(){const[e]=k.useState(()=>new Set),t=k.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[k.useCallback(l=>{let{type:m,event:v}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,v)})},[e]),t]}const Il={draggable:`
3
3
  To pick up a draggable item, press the space bar.
4
4
  While dragging, use the arrow keys to move the item.
5
5
  Press space again to drop the item in its new position, or press escape to cancel.
6
6
  `},Fl={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 Hl(e){let{announcements:t=Fl,container:s,hiddenTextDescribedById:l,screenReaderInstructions:m=Il}=e;const{announce:v,announcement:C}=Pl(),r=Us("DndLiveRegion"),[i,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),Ol(k.useMemo(()=>({onDragStart(o){let{active:p}=o;v(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:S}=o;t.onDragMove&&v(t.onDragMove({active:p,over:S}))},onDragOver(o){let{active:p,over:S}=o;v(t.onDragOver({active:p,over:S}))},onDragEnd(o){let{active:p,over:S}=o;v(t.onDragEnd({active:p,over:S}))},onDragCancel(o){let{active:p,over:S}=o;v(t.onDragCancel({active:p,over:S}))}}),[v,t])),!i)return null;const f=J.createElement(J.Fragment,null,J.createElement(Ml,{id:l,value:m.draggable}),J.createElement(Nl,{id:r,announcement:C}));return s?Nt.createPortal(f,s):f}var qe;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(qe||(qe={}));function js(){}function zl(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Wl(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return k.useMemo(()=>[...t].filter(l=>l!=null),[...t])}const vt=Object.freeze({x:0,y:0});function $l(e,t){const s=As(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 ql(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function Kl(e,t){const s=Math.max(t.top,e.top),l=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),v=Math.min(t.top+t.height,e.top+e.height),C=m-l,r=v-s;if(l<m&&s<v){const i=t.width*t.height,c=e.width*e.height,f=C*r,o=f/(i+c-f);return Number(o.toFixed(4))}return 0}const Xl=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:l}=e;const m=[];for(const v of l){const{id:C}=v,r=s.get(C);if(r){const i=Kl(r,t);i>0&&m.push({id:C,data:{droppableContainer:v,value:i}})}}return m.sort(Ul)};function Yl(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function Tn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:vt}function Vl(e){return function(s){for(var l=arguments.length,m=new Array(l>1?l-1:0),v=1;v<l;v++)m[v-1]=arguments[v];return m.reduce((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 Ln(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 Ql(e,t,s){const l=Ln(t);if(!l)return e;const{scaleX:m,scaleY:v,x:C,y:r}=l,i=e.left-C-(1-m)*parseFloat(s),c=e.top-r-(1-v)*parseFloat(s.slice(s.indexOf(" ")+1)),f=m?e.width/m:e.width,o=v?e.height/v:e.height;return{width:f,height:o,top:c,right:i+f,bottom:c+o,left:i}}const Zl={ignoreTransform:!1};function us(e,t){t===void 0&&(t=Zl);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=tt(e).getComputedStyle(e);c&&(s=Ql(s,c,f))}const{top:l,left:m,width:v,height:C,bottom:r,right:i}=s;return{top:l,left:m,width:v,height:C,bottom:r,right:i}}function vi(e){return us(e,{ignoreTransform:!0})}function Jl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function ec(e,t){return t===void 0&&(t=tt(e).getComputedStyle(e)),t.position==="fixed"}function tc(e,t){t===void 0&&(t=tt(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const v=t[m];return typeof v=="string"?s.test(v):!1})}function Wr(e,t){const s=[];function l(m){if(t!=null&&s.length>=t||!m)return s;if(Hr(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!cs(m)||Dn(m)||s.includes(m))return s;const v=tt(e).getComputedStyle(m);return m!==e&&tc(m,v)&&s.push(m),ec(m,v)?s:l(m.parentNode)}return e?l(e):s}function Mn(e){const[t]=Wr(e,1);return t??null}function ir(e){return!Ws||!e?null:qt(e)?e:Fr(e)?Hr(e)||e===Kt(e).scrollingElement?window:cs(e)?e:null:null}function Nn(e){return qt(e)?e.scrollX:e.scrollLeft}function Pn(e){return qt(e)?e.scrollY:e.scrollTop}function yr(e){return{x:Nn(e),y:Pn(e)}}var Ge;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ge||(Ge={}));function On(e){return!Ws||!e?!1:e===document.scrollingElement}function Bn(e){const t={x:0,y:0},s=On(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},l={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},m=e.scrollTop<=t.y,v=e.scrollLeft<=t.x,C=e.scrollTop>=l.y,r=e.scrollLeft>=l.x;return{isTop:m,isLeft:v,isBottom:C,isRight:r,maxScroll:l,minScroll:t}}const sc={x:.2,y:.2};function rc(e,t,s,l,m){let{top:v,left:C,right:r,bottom:i}=s;l===void 0&&(l=10),m===void 0&&(m=sc);const{isTop:c,isBottom:f,isLeft:o,isRight:p}=Bn(e),S={x:0,y:0},y={x:0,y:0},g={height:t.height*m.y,width:t.width*m.x};return!c&&v<=t.top+g.height?(S.y=Ge.Backward,y.y=l*Math.abs((t.top+g.height-v)/g.height)):!f&&i>=t.bottom-g.height&&(S.y=Ge.Forward,y.y=l*Math.abs((t.bottom-g.height-i)/g.height)),!p&&r>=t.right-g.width?(S.x=Ge.Forward,y.x=l*Math.abs((t.right-g.width-r)/g.width)):!o&&C<=t.left+g.width&&(S.x=Ge.Backward,y.x=l*Math.abs((t.left+g.width-C)/g.width)),{direction:S,speed:y}}function ic(e){if(e===document.scrollingElement){const{innerWidth:v,innerHeight:C}=window;return{top:0,left:0,right:v,bottom:C,width:v,height:C}}const{top:t,left:s,right:l,bottom:m}=e.getBoundingClientRect();return{top:t,left:s,right:l,bottom:m,width:e.clientWidth,height:e.clientHeight}}function In(e){return e.reduce((t,s)=>$t(t,yr(s)),vt)}function nc(e){return e.reduce((t,s)=>t+Nn(s),0)}function oc(e){return e.reduce((t,s)=>t+Pn(s),0)}function Fn(e,t){if(t===void 0&&(t=us),!e)return;const{top:s,left:l,bottom:m,right:v}=t(e);Mn(e)&&(m<=0||v<=0||s>=window.innerHeight||l>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ac=[["x",["left","right"],nc],["y",["top","bottom"],oc]];class $r{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=Wr(s),m=In(l);this.rect={...t},this.width=t.width,this.height=t.height;for(const[v,C,r]of ac)for(const i of C)Object.defineProperty(this,i,{get:()=>{const c=r(l),f=m[v]-c;return this.rect[i]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zt{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 lc(e){const{EventTarget:t}=tt(e);return e instanceof t?e:Kt(e)}function nr(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 ct;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ct||(ct={}));function gi(e){e.preventDefault()}function cc(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 Hn={start:[Ee.Space,Ee.Enter],cancel:[Ee.Esc],end:[Ee.Space,Ee.Enter,Ee.Tab]},hc=(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 zn{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 Zt(Kt(s)),this.windowListeners=new Zt(tt(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ct.Resize,this.handleCancel),this.windowListeners.add(ct.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ct.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,l=t.node.current;l&&Fn(l),s(vt)}handleKeyDown(t){if(zr(t)){const{active:s,context:l,options:m}=this.props,{keyboardCodes:v=Hn,coordinateGetter:C=hc,scrollBehavior:r="smooth"}=m,{code:i}=t;if(v.end.includes(i)){this.handleEnd(t);return}if(v.cancel.includes(i)){this.handleCancel(t);return}const{collisionRect:c}=l.current,f=c?{x:c.left,y:c.top}:vt;this.referenceCoordinates||(this.referenceCoordinates=f);const o=C(t,{active:s,context:l.current,currentCoordinates:f});if(o){const p=Ds(o,f),S={x:0,y:0},{scrollableAncestors:y}=l.current;for(const g of y){const n=t.code,{isTop:d,isRight:h,isLeft:u,isBottom:_,maxScroll:x,minScroll:w}=Bn(g),E=ic(g),b={x:Math.min(n===Ee.Right?E.right-E.width/2:E.right,Math.max(n===Ee.Right?E.left:E.left+E.width/2,o.x)),y:Math.min(n===Ee.Down?E.bottom-E.height/2:E.bottom,Math.max(n===Ee.Down?E.top:E.top+E.height/2,o.y))},R=n===Ee.Right&&!h||n===Ee.Left&&!u,j=n===Ee.Down&&!_||n===Ee.Up&&!d;if(R&&b.x!==o.x){const L=g.scrollLeft+p.x,M=n===Ee.Right&&L<=x.x||n===Ee.Left&&L>=w.x;if(M&&!p.y){g.scrollTo({left:L,behavior:r});return}M?S.x=g.scrollLeft-L:S.x=n===Ee.Right?g.scrollLeft-x.x:g.scrollLeft-w.x,S.x&&g.scrollBy({left:-S.x,behavior:r});break}else if(j&&b.y!==o.y){const L=g.scrollTop+p.y,M=n===Ee.Down&&L<=x.y||n===Ee.Up&&L>=w.y;if(M&&!p.x){g.scrollTo({top:L,behavior:r});return}M?S.y=g.scrollTop-L:S.y=n===Ee.Down?g.scrollTop-x.y:g.scrollTop-w.y,S.y&&g.scrollBy({top:-S.y,behavior:r});break}}this.handleMove(t,$t(Ds(o,this.referenceCoordinates),S))}}}handleMove(t,s){const{onMove:l}=this.props;t.preventDefault(),l(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}zn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:l=Hn,onActivation:m}=t,{active:v}=s;const{code:C}=e.nativeEvent;if(l.start.includes(C)){const r=v.activatorNode.current;return r&&e.target!==r?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function _i(e){return!!(e&&"distance"in e)}function bi(e){return!!(e&&"delay"in e)}class Ur{constructor(t,s,l){var m;l===void 0&&(l=lc(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=s;const{event:v}=t,{target:C}=v;this.props=t,this.events=s,this.document=Kt(C),this.documentListeners=new Zt(this.document),this.listeners=new Zt(l),this.windowListeners=new Zt(tt(C)),this.initialCoordinates=(m=As(v))!=null?m:vt,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(ct.Resize,this.handleCancel),this.windowListeners.add(ct.DragStart,gi),this.windowListeners.add(ct.VisibilityChange,this.handleCancel),this.windowListeners.add(ct.ContextMenu,gi),this.documentListeners.add(ct.Keydown,this.handleKeydown),s){if(l!=null&&l({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(bi(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(_i(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(ct.Click,cc,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ct.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:l,initialCoordinates:m,props:v}=this,{onMove:C,options:{activationConstraint:r}}=v;if(!m)return;const i=(s=As(t))!=null?s:vt,c=Ds(m,i);if(!l&&r){if(_i(r)){if(r.tolerance!=null&&nr(c,r.tolerance))return this.handleCancel();if(nr(c,r.distance))return this.handleStart()}if(bi(r)&&nr(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 uc={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class qr extends Ur{constructor(t){const{event:s}=t,l=Kt(s.target);super(t,uc,l)}}qr.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 dc={move:{name:"mousemove"},end:{name:"mouseup"}};var Cr;(function(e){e[e.RightClick=2]="RightClick"})(Cr||(Cr={}));class fc extends Ur{constructor(t){super(t,dc,Kt(t.event.target))}}fc.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return s.button===Cr.RightClick?!1:(l?.({event:s}),!0)}}];const or={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mc extends Ur{constructor(t){super(t,or)}static setup(){return window.addEventListener(or.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(or.move.name,t)};function t(){}}}mc.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 Jt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Jt||(Jt={}));var Ts;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ts||(Ts={}));function pc(e){let{acceleration:t,activator:s=Jt.Pointer,canScroll:l,draggingRect:m,enabled:v,interval:C=5,order:r=Ts.TreeOrder,pointerCoordinates:i,scrollableAncestors:c,scrollableAncestorRects:f,delta:o,threshold:p}=e;const S=gc({delta:o,disabled:!v}),[y,g]=Dl(),n=k.useRef({x:0,y:0}),d=k.useRef({x:0,y:0}),h=k.useMemo(()=>{switch(s){case Jt.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Jt.DraggableRect:return m}},[s,m,i]),u=k.useRef(null),_=k.useCallback(()=>{const w=u.current;if(!w)return;const E=n.current.x*d.current.x,b=n.current.y*d.current.y;w.scrollBy(E,b)},[]),x=k.useMemo(()=>r===Ts.TreeOrder?[...c].reverse():c,[r,c]);k.useEffect(()=>{if(!v||!c.length||!h){g();return}for(const w of x){if(l?.(w)===!1)continue;const E=c.indexOf(w),b=f[E];if(!b)continue;const{direction:R,speed:j}=rc(w,b,h,t,p);for(const L of["x","y"])S[L][R[L]]||(j[L]=0,R[L]=0);if(j.x>0||j.y>0){g(),u.current=w,y(_,C),n.current=j,d.current=R;return}}n.current={x:0,y:0},d.current={x:0,y:0},g()},[t,_,l,g,v,C,JSON.stringify(h),JSON.stringify(S),y,c,x,f,JSON.stringify(p)])}const vc={x:{[Ge.Backward]:!1,[Ge.Forward]:!1},y:{[Ge.Backward]:!1,[Ge.Forward]:!1}};function gc(e){let{delta:t,disabled:s}=e;const l=Rs(t);return hs(m=>{if(s||!l||!m)return vc;const v={x:Math.sign(t.x-l.x),y:Math.sign(t.y-l.y)};return{x:{[Ge.Backward]:m.x[Ge.Backward]||v.x===-1,[Ge.Forward]:m.x[Ge.Forward]||v.x===1},y:{[Ge.Backward]:m.y[Ge.Backward]||v.y===-1,[Ge.Forward]:m.y[Ge.Forward]||v.y===1}}},[s,t,l])}function _c(e,t){const s=t!=null?e.get(t):void 0,l=s?s.node.current:null;return hs(m=>{var v;return t==null?null:(v=l??m)!=null?v:null},[l,t])}function bc(e,t){return k.useMemo(()=>e.reduce((s,l)=>{const{sensor:m}=l,v=m.activators.map(C=>({eventName:C.eventName,handler:t(C.handler,l)}));return[...s,...v]},[]),[e,t])}var as;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(as||(as={}));var wr;(function(e){e.Optimized="optimized"})(wr||(wr={}));const xi=new Map;function xc(e,t){let{dragging:s,dependencies:l,config:m}=t;const[v,C]=k.useState(null),{frequency:r,measure:i,strategy:c}=m,f=k.useRef(e),o=n(),p=ns(o),S=k.useCallback(function(d){d===void 0&&(d=[]),!p.current&&C(h=>h===null?d:h.concat(d.filter(u=>!h.includes(u))))},[p]),y=k.useRef(null),g=hs(d=>{if(o&&!s)return xi;if(!d||d===xi||f.current!==e||v!=null){const h=new Map;for(let u of e){if(!u)continue;if(v&&v.length>0&&!v.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const _=u.node.current,x=_?new $r(i(_),_):null;u.rect.current=x,x&&h.set(u.id,x)}return h}return d},[e,v,s,o,i]);return k.useEffect(()=>{f.current=e},[e]),k.useEffect(()=>{o||S()},[s,o]),k.useEffect(()=>{v&&v.length>0&&C(null)},[JSON.stringify(v)]),k.useEffect(()=>{o||typeof r!="number"||y.current!==null||(y.current=setTimeout(()=>{S(),y.current=null},r))},[r,o,S,...l]),{droppableRects:g,measureDroppableContainers:S,measuringScheduled:v!=null};function n(){switch(c){case as.Always:return!1;case as.BeforeDragging:return s;default:return!s}}}function Kr(e,t){return hs(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function Sc(e,t){return Kr(e,t)}function yc(e){let{callback:t,disabled:s}=e;const l=$s(t),m=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:v}=window;return new v(l)},[l,s]);return k.useEffect(()=>()=>m?.disconnect(),[m]),m}function qs(e){let{callback:t,disabled:s}=e;const l=$s(t),m=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:v}=window;return new v(l)},[s]);return k.useEffect(()=>()=>m?.disconnect(),[m]),m}function Cc(e){return new $r(us(e),e)}function Si(e,t,s){t===void 0&&(t=Cc);const[l,m]=k.useState(null);function v(){m(i=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=i??s)!=null?c:null}const f=t(e);return JSON.stringify(i)===JSON.stringify(f)?i:f})}const C=yc({callback(i){if(e)for(const c of i){const{type:f,target:o}=c;if(f==="childList"&&o instanceof HTMLElement&&o.contains(e)){v();break}}}}),r=qs({callback:v});return yt(()=>{v(),e?(r?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(r?.disconnect(),C?.disconnect())},[e]),l}function wc(e){const t=Kr(e);return Tn(e,t)}const yi=[];function Ec(e){const t=k.useRef(e),s=hs(l=>e?l&&l!==yi&&e&&t.current&&e.parentNode===t.current.parentNode?l:Wr(e):yi,[e]);return k.useEffect(()=>{t.current=e},[e]),s}function kc(e){const[t,s]=k.useState(null),l=k.useRef(e),m=k.useCallback(v=>{const C=ir(v.target);C&&s(r=>r?(r.set(C,yr(C)),new Map(r)):null)},[]);return k.useEffect(()=>{const v=l.current;if(e!==v){C(v);const r=e.map(i=>{const c=ir(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,yr(c)]):null}).filter(i=>i!=null);s(r.length?new Map(r):null),l.current=e}return()=>{C(e),C(v)};function C(r){r.forEach(i=>{const c=ir(i);c?.removeEventListener("scroll",m)})}},[m,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((v,C)=>$t(v,C),vt):In(e):vt,[e,t])}function Ci(e,t){t===void 0&&(t=[]);const s=k.useRef(null);return k.useEffect(()=>{s.current=null},t),k.useEffect(()=>{const l=e!==vt;l&&!s.current&&(s.current=e),!l&&s.current&&(s.current=null)},[e]),s.current?Ds(e,s.current):vt}function Rc(e){k.useEffect(()=>{if(!Ws)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 Dc(e,t){return k.useMemo(()=>e.reduce((s,l)=>{let{eventName:m,handler:v}=l;return s[m]=C=>{v(C,t)},s},{}),[e,t])}function Wn(e){return k.useMemo(()=>e?Jl(e):null,[e])}const wi=[];function Ac(e,t){t===void 0&&(t=us);const[s]=e,l=Wn(s?tt(s):null),[m,v]=k.useState(wi);function C(){v(()=>e.length?e.map(i=>On(i)?l:new $r(t(i),i)):wi)}const r=qs({callback:C});return yt(()=>{r?.disconnect(),C(),e.forEach(i=>r?.observe(i))},[e]),m}function $n(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return cs(t)?t:e}function jc(e){let{measure:t}=e;const[s,l]=k.useState(null),m=k.useCallback(c=>{for(const{target:f}of c)if(cs(f)){l(o=>{const p=t(f);return o?{...o,width:p.width,height:p.height}:p});break}},[t]),v=qs({callback:m}),C=k.useCallback(c=>{const f=$n(c);v?.disconnect(),f&&v?.observe(f),l(f?t(f):null)},[t,v]),[r,i]=ks(C);return k.useMemo(()=>({nodeRef:r,rect:s,setRef:i}),[s,r,i])}const Tc=[{sensor:qr,options:{}},{sensor:zn,options:{}}],Lc={current:{}},Cs={draggable:{measure:vi},droppable:{measure:vi,strategy:as.WhileDragging,frequency:wr.Optimized},dragOverlay:{measure:us}};class es 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 Mc={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new es,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:js},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Cs,measureDroppableContainers:js,windowRect:null,measuringScheduled:!1},Un={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:js,draggableNodes:new Map,over:null,measureDroppableContainers:js},ds=k.createContext(Un),qn=k.createContext(Mc);function Nc(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new es}}}function Pc(e,t){switch(t.type){case qe.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case qe.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case qe.DragEnd:case qe.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case qe.RegisterDroppable:{const{element:s}=t,{id:l}=s,m=new es(e.droppable.containers);return m.set(l,s),{...e,droppable:{...e.droppable,containers:m}}}case qe.SetDroppableDisabled:{const{id:s,key:l,disabled:m}=t,v=e.droppable.containers.get(s);if(!v||l!==v.key)return e;const C=new es(e.droppable.containers);return C.set(s,{...v,disabled:m}),{...e,droppable:{...e.droppable,containers:C}}}case qe.UnregisterDroppable:{const{id:s,key:l}=t,m=e.droppable.containers.get(s);if(!m||l!==m.key)return e;const v=new es(e.droppable.containers);return v.delete(s),{...e,droppable:{...e.droppable,containers:v}}}default:return e}}function Oc(e){let{disabled:t}=e;const{active:s,activatorEvent:l,draggableNodes:m}=k.useContext(ds),v=Rs(l),C=Rs(s?.id);return k.useEffect(()=>{if(!t&&!l&&v&&C!=null){if(!zr(v)||document.activeElement===v.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 f of[i.current,c.current]){if(!f)continue;const o=Tl(f);if(o){o.focus();break}}})}},[l,t,m,C,v]),null}function Kn(e,t){let{transform:s,...l}=t;return e!=null&&e.length?e.reduce((m,v)=>v({transform:m,...l}),s):s}function Bc(e){return k.useMemo(()=>({draggable:{...Cs.draggable,...e?.draggable},droppable:{...Cs.droppable,...e?.droppable},dragOverlay:{...Cs.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ic(e){let{activeNode:t,measure:s,initialRect:l,config:m=!0}=e;const v=k.useRef(!1),{x:C,y:r}=typeof m=="boolean"?{x:m,y:m}:m;yt(()=>{if(!C&&!r||!t){v.current=!1;return}if(v.current||!l)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=s(c),o=Tn(f,l);if(C||(o.x=0),r||(o.y=0),v.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const p=Mn(c);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,r,l,s])}const Ks=k.createContext({...vt,scaleX:1,scaleY:1});var Et;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Et||(Et={}));const Fc=k.memo(function(t){var s,l,m,v;let{id:C,accessibility:r,autoScroll:i=!0,children:c,sensors:f=Tc,collisionDetection:o=Xl,measuring:p,modifiers:S,...y}=t;const g=k.useReducer(Pc,void 0,Nc),[n,d]=g,[h,u]=Bl(),[_,x]=k.useState(Et.Uninitialized),w=_===Et.Initialized,{draggable:{active:E,nodes:b,translate:R},droppable:{containers:j}}=n,L=E!=null?b.get(E):null,M=k.useRef({initial:null,translated:null}),T=k.useMemo(()=>{var Ie;return E!=null?{id:E,data:(Ie=L?.data)!=null?Ie:Lc,rect:M}:null},[E,L]),B=k.useRef(null),[I,H]=k.useState(null),[W,A]=k.useState(null),N=ns(y,Object.values(y)),P=Us("DndDescribedBy",C),O=k.useMemo(()=>j.getEnabled(),[j]),$=Bc(p),{droppableRects:X,measureDroppableContainers:K,measuringScheduled:Q}=xc(O,{dragging:w,dependencies:[R.x,R.y],config:$.droppable}),se=_c(b,E),D=k.useMemo(()=>W?As(W):null,[W]),F=dt(),U=Sc(se,$.draggable.measure);Ic({activeNode:E!=null?b.get(E):null,config:F.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const z=Si(se,$.draggable.measure,U),ee=Si(se?se.parentElement:null),V=k.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=j.getNodeFor((s=V.current.over)==null?void 0:s.id),ve=jc({measure:$.dragOverlay.measure}),fe=(l=ve.nodeRef.current)!=null?l:se,Le=w?(m=ve.rect)!=null?m:z:null,re=!!(ve.nodeRef.current&&ve.rect),Be=wc(re?null:z),ye=Wn(fe?tt(fe):null),ae=Ec(w?ne??se:null),Me=Ac(ae),Ke=Kn(S,{transform:{x:R.x-Be.x,y:R.y-Be.y,scaleX:1,scaleY:1},activatorEvent:W,active:T,activeNodeRect:z,containerNodeRect:ee,draggingNodeRect:Le,over:V.current.over,overlayNodeRect:ve.rect,scrollableAncestors:ae,scrollableAncestorRects:Me,windowRect:ye}),Ae=D?$t(D,R):null,Xe=kc(ae),ge=Ci(Xe),rt=Ci(Xe,[z]),Ye=$t(Ke,ge),Ne=Le?Gl(Le,Ke):null,Pe=T&&Ne?o({active:T,collisionRect:Ne,droppableRects:X,droppableContainers:O,pointerCoordinates:Ae}):null,He=ql(Pe,"id"),[we,Y]=k.useState(null),ie=re?Ke:$t(Ke,rt),Ce=Yl(ie,(v=we?.rect)!=null?v:null,z),_e=k.useRef(null),We=k.useCallback((Ie,q)=>{let{sensor:Z,options:le}=q;if(B.current==null)return;const pe=b.get(B.current);if(!pe)return;const be=Ie.nativeEvent,ke=new Z({active:B.current,activeNode:pe,event:be,options:le,context:V,onAbort(Oe){if(!b.get(Oe))return;const{onDragAbort:ot}=N.current,at={id:Oe};ot?.(at),h({type:"onDragAbort",event:at})},onPending(Oe,gt,ot,at){if(!b.get(Oe))return;const{onDragPending:St}=N.current,ft={id:Oe,constraint:gt,initialCoordinates:ot,offset:at};St?.(ft),h({type:"onDragPending",event:ft})},onStart(Oe){const gt=B.current;if(gt==null)return;const ot=b.get(gt);if(!ot)return;const{onDragStart:at}=N.current,xt={activatorEvent:be,active:{id:gt,data:ot.data,rect:M}};Nt.unstable_batchedUpdates(()=>{at?.(xt),x(Et.Initializing),d({type:qe.DragStart,initialCoordinates:Oe,active:gt}),h({type:"onDragStart",event:xt}),H(_e.current),A(be)})},onMove(Oe){d({type:qe.DragMove,coordinates:Oe})},onEnd:st(qe.DragEnd),onCancel:st(qe.DragCancel)});_e.current=ke;function st(Oe){return async function(){const{active:ot,collisions:at,over:xt,scrollAdjustedTranslate:St}=V.current;let ft=null;if(ot&&St){const{cancelDrop:Lt}=N.current;ft={activatorEvent:be,active:ot,collisions:at,delta:St,over:xt},Oe===qe.DragEnd&&typeof Lt=="function"&&await Promise.resolve(Lt(ft))&&(Oe=qe.DragCancel)}B.current=null,Nt.unstable_batchedUpdates(()=>{d({type:Oe}),x(Et.Uninitialized),Y(null),H(null),A(null),_e.current=null;const Lt=Oe===qe.DragEnd?"onDragEnd":"onDragCancel";if(ft){const Xt=N.current[Lt];Xt?.(ft),h({type:Lt,event:ft})}})}}},[b]),Qe=k.useCallback((Ie,q)=>(Z,le)=>{const pe=Z.nativeEvent,be=b.get(le);if(B.current!==null||!be||pe.dndKit||pe.defaultPrevented)return;const ke={active:be};Ie(Z,q.options,ke)===!0&&(pe.dndKit={capturedBy:q.sensor},B.current=le,We(Z,q))},[b,We]),me=bc(f,Qe);Rc(f),yt(()=>{z&&_===Et.Initializing&&x(Et.Initialized)},[z,_]),k.useEffect(()=>{const{onDragMove:Ie}=N.current,{active:q,activatorEvent:Z,collisions:le,over:pe}=V.current;if(!q||!Z)return;const be={active:q,activatorEvent:Z,collisions:le,delta:{x:Ye.x,y:Ye.y},over:pe};Nt.unstable_batchedUpdates(()=>{Ie?.(be),h({type:"onDragMove",event:be})})},[Ye.x,Ye.y]),k.useEffect(()=>{const{active:Ie,activatorEvent:q,collisions:Z,droppableContainers:le,scrollAdjustedTranslate:pe}=V.current;if(!Ie||B.current==null||!q||!pe)return;const{onDragOver:be}=N.current,ke=le.get(He),st=ke&&ke.rect.current?{id:ke.id,rect:ke.rect.current,data:ke.data,disabled:ke.disabled}:null,Oe={active:Ie,activatorEvent:q,collisions:Z,delta:{x:pe.x,y:pe.y},over:st};Nt.unstable_batchedUpdates(()=>{Y(st),be?.(Oe),h({type:"onDragOver",event:Oe})})},[He]),yt(()=>{V.current={activatorEvent:W,active:T,activeNode:se,collisionRect:Ne,collisions:Pe,droppableRects:X,draggableNodes:b,draggingNode:fe,draggingNodeRect:Le,droppableContainers:j,over:we,scrollableAncestors:ae,scrollAdjustedTranslate:Ye},M.current={initial:Le,translated:Ne}},[T,se,Pe,Ne,b,fe,Le,X,j,we,ae,Ye]),pc({...F,delta:R,draggingRect:Ne,pointerCoordinates:Ae,scrollableAncestors:ae,scrollableAncestorRects:Me});const it=k.useMemo(()=>({active:T,activeNode:se,activeNodeRect:z,activatorEvent:W,collisions:Pe,containerNodeRect:ee,dragOverlay:ve,draggableNodes:b,droppableContainers:j,droppableRects:X,over:we,measureDroppableContainers:K,scrollableAncestors:ae,scrollableAncestorRects:Me,measuringConfiguration:$,measuringScheduled:Q,windowRect:ye}),[T,se,z,W,Pe,ee,ve,b,j,X,we,K,ae,Me,$,Q,ye]),et=k.useMemo(()=>({activatorEvent:W,activators:me,active:T,activeNodeRect:z,ariaDescribedById:{draggable:P},dispatch:d,draggableNodes:b,over:we,measureDroppableContainers:K}),[W,me,T,z,d,P,b,we,K]);return J.createElement(jn.Provider,{value:u},J.createElement(ds.Provider,{value:et},J.createElement(qn.Provider,{value:it},J.createElement(Ks.Provider,{value:Ce},c)),J.createElement(Oc,{disabled:r?.restoreFocus===!1})),J.createElement(Hl,{...r,hiddenTextDescribedById:P}));function dt(){const Ie=I?.autoScrollEnabled===!1,q=typeof i=="object"?i.enabled===!1:i===!1,Z=w&&!Ie&&!q;return typeof i=="object"?{...i,enabled:Z}:{enabled:Z}}}),Hc=k.createContext(null),Ei="button",zc="Draggable";function Wc(e){let{id:t,data:s,disabled:l=!1,attributes:m}=e;const v=Us(zc),{activators:C,activatorEvent:r,active:i,activeNodeRect:c,ariaDescribedById:f,draggableNodes:o,over:p}=k.useContext(ds),{role:S=Ei,roleDescription:y="draggable",tabIndex:g=0}=m??{},n=i?.id===t,d=k.useContext(n?Ks:Hc),[h,u]=ks(),[_,x]=ks(),w=Dc(C,t),E=ns(s);yt(()=>(o.set(t,{id:t,key:v,node:h,activatorNode:_,data:E}),()=>{const R=o.get(t);R&&R.key===v&&o.delete(t)}),[o,t]);const b=k.useMemo(()=>({role:S,tabIndex:g,"aria-disabled":l,"aria-pressed":n&&S===Ei?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[l,S,g,n,y,f.draggable]);return{active:i,activatorEvent:r,activeNodeRect:c,attributes:b,isDragging:n,listeners:l?void 0:w,node:h,over:p,setNodeRef:u,setActivatorNodeRef:x,transform:d}}function $c(){return k.useContext(qn)}const Uc="Droppable",qc={timeout:25};function Kc(e){let{data:t,disabled:s=!1,id:l,resizeObserverConfig:m}=e;const v=Us(Uc),{active:C,dispatch:r,over:i,measureDroppableContainers:c}=k.useContext(ds),f=k.useRef({disabled:s}),o=k.useRef(!1),p=k.useRef(null),S=k.useRef(null),{disabled:y,updateMeasurementsFor:g,timeout:n}={...qc,...m},d=ns(g??l),h=k.useCallback(()=>{if(!o.current){o.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{c(Array.isArray(d.current)?d.current:[d.current]),S.current=null},n)},[n]),u=qs({callback:h,disabled:y||!C}),_=k.useCallback((b,R)=>{u&&(R&&(u.unobserve(R),o.current=!1),b&&u.observe(b))},[u]),[x,w]=ks(_),E=ns(t);return k.useEffect(()=>{!u||!x.current||(u.disconnect(),o.current=!1,u.observe(x.current))},[x,u]),k.useEffect(()=>(r({type:qe.RegisterDroppable,element:{id:l,key:v,disabled:s,node:x,rect:p,data:E}}),()=>r({type:qe.UnregisterDroppable,key:v,id:l})),[l]),k.useEffect(()=>{s!==f.current.disabled&&(r({type:qe.SetDroppableDisabled,id:l,key:v,disabled:s}),f.current.disabled=s)},[l,v,s,r]),{active:C,rect:p,isOver:i?.id===l,node:x,over:i,setNodeRef:w}}function Xc(e){let{animation:t,children:s}=e;const[l,m]=k.useState(null),[v,C]=k.useState(null),r=Rs(s);return!s&&!l&&r&&m(r),yt(()=>{if(!v)return;const i=l?.key,c=l?.props.id;if(i==null||c==null){m(null);return}Promise.resolve(t(c,v)).then(()=>{m(null)})},[t,l,v]),J.createElement(J.Fragment,null,s,l?k.cloneElement(l,{ref:C}):null)}const Yc={x:0,y:0,scaleX:1,scaleY:1};function Vc(e){let{children:t}=e;return J.createElement(ds.Provider,{value:Un},J.createElement(Ks.Provider,{value:Yc},t))}const Gc={position:"fixed",touchAction:"none"},Qc=e=>zr(e)?"transform 250ms ease":void 0,Zc=k.forwardRef((e,t)=>{let{as:s,activatorEvent:l,adjustScale:m,children:v,className:C,rect:r,style:i,transform:c,transition:f=Qc}=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:os.Transform.toString(o),transformOrigin:m&&l?$l(l,r):void 0,transition:typeof f=="function"?f(l):f,...i};return J.createElement(s,{className:C,style:p,ref:t},v)}),Jc=e=>t=>{let{active:s,dragOverlay:l}=t;const m={},{styles:v,className:C}=e;if(v!=null&&v.active)for(const[r,i]of Object.entries(v.active))i!==void 0&&(m[r]=s.node.style.getPropertyValue(r),s.node.style.setProperty(r,i));if(v!=null&&v.dragOverlay)for(const[r,i]of Object.entries(v.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)}},eh=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:os.Transform.toString(t)},{transform:os.Transform.toString(s)}]},th={duration:250,easing:"ease",keyframes:eh,sideEffects:Jc({styles:{active:{opacity:"0"}}})};function sh(e){let{config:t,draggableNodes:s,droppableContainers:l,measuringConfiguration:m}=e;return $s((v,C)=>{if(t===null)return;const r=s.get(v);if(!r)return;const i=r.node.current;if(!i)return;const c=$n(C);if(!c)return;const{transform:f}=tt(C).getComputedStyle(C),o=Ln(f);if(!o)return;const p=typeof t=="function"?t:rh(t);return Fn(i,m.draggable.measure),p({active:{id:v,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 rh(e){const{duration:t,easing:s,sideEffects:l,keyframes:m}={...th,...e};return v=>{let{active:C,dragOverlay:r,transform:i,...c}=v;if(!t)return;const f={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-f.x,y:i.y-f.y,...o},S=m({...c,active:C,dragOverlay:r,transform:{initial:i,final:p}}),[y]=S,g=S[S.length-1];if(JSON.stringify(y)===JSON.stringify(g))return;const n=l?.({active:C,dragOverlay:r,...c}),d=r.node.animate(S,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{d.onfinish=()=>{n?.(),h()}})}}let ki=0;function ih(e){return k.useMemo(()=>{if(e!=null)return ki++,ki},[e])}const nh=J.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:l,style:m,transition:v,modifiers:C,wrapperElement:r="div",className:i,zIndex:c=999}=e;const{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:S,draggableNodes:y,droppableContainers:g,dragOverlay:n,over:d,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:_,windowRect:x}=$c(),w=k.useContext(Ks),E=ih(o?.id),b=Kn(C,{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:S,draggingNodeRect:n.rect,over:d,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:_,transform:w,windowRect:x}),R=Kr(p),j=sh({config:l,draggableNodes:y,droppableContainers:g,measuringConfiguration:h}),L=R?n.setRef:void 0;return J.createElement(Vc,null,J.createElement(Xc,{animation:j},o&&E?J.createElement(Zc,{key:E,id:o.id,ref:L,as:r,activatorEvent:f,adjustScale:t,className:i,transition:v,rect:R,style:{zIndex:c,...m},transform:b},s):null))}),Xn=768;function oh(e){const t=window.matchMedia(`(max-width: ${Xn-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function ah(){return window.innerWidth<Xn}function lh(){return!1}function Yn(){return k.useSyncExternalStore(oh,ah,lh)}const ce={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},ch=[{status:ce.Review,label:"Review",icon:Lr,color:"text-amber-600"},{status:ce.Running,label:"Running",icon:Mr,color:"text-blue-600"},{status:ce.Pending,label:"Pending",icon:Nr,color:"text-neutral-600"},{status:ce.Done,label:"Done",icon:Pr,color:"text-emerald-600"},{status:ce.Cancelled,label:"Cancelled",icon:Or,color:"text-neutral-500"}];function hh({task:e,status:t,isSelected:s,isAgentActive:l,project:m,onSelectTask:v,onTaskStatusChange:C,onDeleteTask:r,disableDrag:i}){const{t:c}=he(),f=!!e.projectArchivedAt,o=f||!!i,{attributes:p,listeners:S,setNodeRef:y,isDragging:g}=Wc({id:e.id,data:{task:e,fromStatus:t},disabled:o}),[n,d]=k.useState(null),h=k.useRef(null),u=k.useRef(null),_=k.useCallback(E=>{f||!C&&!r||(E.preventDefault(),d({x:E.clientX,y:E.clientY}))},[f,C,r]),x=k.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),w=k.useCallback(E=>{if(!i||f||!C&&!r)return;const b=E.touches[0];if(!b)return;const{clientX:R,clientY:j}=b;u.current=setTimeout(()=>{u.current=null,d({x:R,y:j})},500)},[i,f,C,r]);return k.useEffect(()=>{if(!n)return;const E=b=>{h.current&&!h.current.contains(b.target)&&d(null)};return document.addEventListener("mousedown",E),document.addEventListener("touchstart",E),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("touchstart",E)}},[n]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:y,onClick:()=>v(e.id),onContextMenu:_,onTouchStart:w,onTouchEnd:x,onTouchMove:x,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
7
7
  ${g?"opacity-30":""}
8
- ${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...o?{}:S,...o?{}:p,children:[a.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ce.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ce.Review&&a.jsx(Lr,{className:s?"text-amber-600":"text-neutral-500"}),t===ce.Running&&a.jsx(Mr,{className:"animate-pulse"}),t===ce.Pending&&a.jsx(Nr,{}),t===ce.Done&&a.jsx(Pr,{className:"text-neutral-400"}),t===ce.Cancelled&&a.jsx(Or,{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}),e.projectArchivedAt&&a.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),l&&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})]})]}),n&&a.jsxs("div",{ref:h,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:n.x,top:n.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:c("Move to")}),ch.filter(E=>E.status!==t).map(E=>{const b=E.icon;return a.jsxs("button",{onClick:()=>{C(e.id,E.status),d(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[a.jsx(b,{className:`w-3.5 h-3.5 ${E.color}`}),a.jsx("span",{className:"text-neutral-700",children:c(E.label)})]},E.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),d(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:c("Delete Task")})]})]})]})]})}const uh=k.memo(function({title:t,tasks:s,status:l,defaultOpen:m,selectedTaskId:v,onSelectTask:C,projects:r,activeTaskIds:i,isDragging:c,dragFromStatus:f,onTaskStatusChange:o,onDeleteTask:p,disableDrag:S}){const{t:y}=he(),[g,n]=k.useState(m),d=s.length===0,h=c&&f===l,u=c&&f!==l,{setNodeRef:_,isOver:x}=Kc({id:`group-${l}`,data:{status:l}}),w=l===ce.Review,E=y(t),b=c?h&&(g||!0):g;return a.jsxs("div",{className:"mb-2",children:[a.jsxs("button",{onClick:()=>!c&&n(R=>!R),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:b?a.jsx(Ct,{size:14}):a.jsx(Ft,{size:14})}),a.jsx("span",{className:"flex-1 text-left",children:E}),w&&!d?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,")"]})]}),u&&a.jsx("div",{ref:_,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
8
+ ${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...o?{}:S,...o?{}:p,children:[a.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ce.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ce.Review&&a.jsx(Lr,{className:s?"text-amber-600":"text-neutral-500"}),t===ce.Running&&a.jsx(Mr,{className:"animate-pulse"}),t===ce.Pending&&a.jsx(Nr,{}),t===ce.Done&&a.jsx(Pr,{className:"text-neutral-400"}),t===ce.Cancelled&&a.jsx(Or,{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}),e.projectArchivedAt&&a.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),l&&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})]})]}),n&&a.jsxs("div",{ref:h,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:n.x,top:n.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:c("Move to")}),ch.filter(E=>E.status!==t).map(E=>{const b=E.icon;return a.jsxs("button",{onClick:()=>{C(e.id,E.status),d(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[a.jsx(b,{className:`w-3.5 h-3.5 ${E.color}`}),a.jsx("span",{className:"text-neutral-700",children:c(E.label)})]},E.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),d(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:c("Delete Task")})]})]})]})]})}const uh=k.memo(function({title:t,tasks:s,status:l,defaultOpen:m,selectedTaskId:v,onSelectTask:C,projects:r,activeTaskIds:i,isDragging:c,dragFromStatus:f,onTaskStatusChange:o,onDeleteTask:p,disableDrag:S}){const{t:y}=he(),[g,n]=k.useState(m),d=s.length===0,h=c&&f===l,u=c&&f!==l,{setNodeRef:_,isOver:x}=Kc({id:`group-${l}`,data:{status:l}}),w=l===ce.Review,E=y(t),b=c?h&&(g||!0):g;return a.jsxs("div",{className:"mb-2",children:[a.jsxs("button",{onClick:()=>!c&&n(R=>!R),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:b?a.jsx(Ct,{size:14}):a.jsx(It,{size:14})}),a.jsx("span",{className:"flex-1 text-left",children:E}),w&&!d?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,")"]})]}),u&&a.jsx("div",{ref:_,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
9
  ${x?"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:x?y("Drop into {title}",{title:E}):y("Drop here")})}),b&&!u&&a.jsx("div",{ref:h?void 0:_,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
10
10
  ${x&&!h?"bg-blue-50 ring-1 ring-blue-200":""}
11
11
  ${d&&c?"border border-dashed border-neutral-300":""}`,children:d?a.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:y("No tasks")}):s.map(R=>{const j=r.find(T=>T.id===R.projectId),L=v===R.id,M=i?.has(R.id)??!1;return a.jsx(hh,{task:R,status:l,isSelected:L,isAgentActive:M,project:j,onSelectTask:C,onTaskStatusChange:R.projectArchivedAt?void 0:o,onDeleteTask:R.projectArchivedAt?void 0:p,disableDrag:S},R.id)})})]})});function dh(e){const t={[ce.Review]:[],[ce.Running]:[],[ce.Pending]:[],[ce.Done]:[],[ce.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const fh=[{status:ce.Review,title:"Review",defaultOpen:!0},{status:ce.Running,title:"Running",defaultOpen:!0},{status:ce.Pending,title:"Pending",defaultOpen:!1},{status:ce.Done,title:"Done",defaultOpen:!1},{status:ce.Cancelled,title:"Cancelled",defaultOpen:!1}];function Ri({tasks:e=[],projects:t=[],selectedTaskId:s,onSelectTask:l,filterProjectId:m,setFilterProjectId:v,width:C=320,onCreateProject:r,onCreateTask:i,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:o}){const{t:p}=he(),S=Yn(),[y,g]=k.useState(!1),[n,d]=k.useState(null),[h,u]=k.useState(null),_=Wl(zl(qr,{activationConstraint:{distance:8}})),x=k.useCallback(B=>{const I=B.active.data.current?.task,H=B.active.data.current?.fromStatus;I&&d(I),H&&u(H)},[]),w=k.useCallback(B=>{d(null),u(null);const{active:I,over:H}=B;if(!H)return;const W=I.data.current?.task,A=I.data.current?.fromStatus,N=H.data.current?.status;!W||!A||!N||W.projectArchivedAt||A!==N&&f?.(W.id,N)},[f]),E=m?e.filter(B=>B.projectId===m):e,b=m?t.find(B=>B.id===m)??null:null,R=t.filter(B=>!B.archivedAt),L=!!!b?.archivedAt,M=dh(E),T=C==="100%";return a.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${T?"":"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(B=>!B),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&&b?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${b.color.replace("text-","bg-")}`}),a.jsx("span",{className:"truncate",children:b.name})]}):a.jsxs(a.Fragment,{children:[a.jsx(mi,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),a.jsx("span",{children:p("All Projects")})]}),a.jsx(Ct,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${y?"rotate-180":""}`})]}),y?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:p("Select View")}),a.jsxs("button",{onClick:()=>{v(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(mi,{size:12})}),a.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:p("All Projects")})]}),m===null?a.jsx(ss,{size:14,className:"text-neutral-900"}):null]}),a.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),R.map(B=>{const I=m===B.id,H=B.color.replace("text-","bg-");return a.jsxs("button",{onClick:()=>{v(B.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 ${H}`}),a.jsx("span",{className:I?"text-neutral-900 font-medium":"text-neutral-600",children:B.name})]}),I?a.jsx(ss,{size:14,className:"text-neutral-900"}):null]},B.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(xr,{size:14}),a.jsx("span",{children:p("Create New Project...")})]})]})]}):null]}),a.jsx("button",{onClick:i,disabled:!L,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:p(L?"New Task":"Deleted projects are read-only"),children:a.jsx(xr,{size:18})})]}),a.jsxs(Fc,{sensors:_,onDragStart:x,onDragEnd:w,children:[a.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:fh.map(({status:B,title:I,defaultOpen:H})=>a.jsx(uh,{title:I,tasks:M[B],status:B,defaultOpen:H,selectedTaskId:s,onSelectTask:l,projects:t,activeTaskIds:c,isDragging:n!==null,dragFromStatus:h,onTaskStatusChange:f,onDeleteTask:o,disableDrag:S},B))}),a.jsx(nh,{dropAnimation:null,children:n?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:n.title})}):null})]}),E.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.jsx("span",{children:p("{count} tasks",{count:E.length})}),m?a.jsx("button",{onClick:()=>v(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:p("Clear filter")}):null]}):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:p("{count} tasks",{count:0})})})]})}const mh={damping:.7,stiffness:.05,mass:1.25},ph=70,vh=1e3/60,gh=350;let Xs=!1;globalThis.document?.addEventListener("mousedown",()=>{Xs=!0});globalThis.document?.addEventListener("mouseup",()=>{Xs=!1});globalThis.document?.addEventListener("click",()=>{Xs=!1});const Vn=(e={})=>{const[t,s]=k.useState(!1),[l,m]=k.useState(e.initial!==!1),[v,C]=k.useState(!1),r=k.useRef(null);r.current=e;const i=k.useCallback(()=>{if(!Xs)return!1;const h=window.getSelection();if(!h||!h.rangeCount)return!1;const u=h.getRangeAt(0);return u.commonAncestorContainer.contains(n.current)||n.current?.contains(u.commonAncestorContainer)},[]),c=k.useCallback(h=>{o.isAtBottom=h,m(h)},[]),f=k.useCallback(h=>{o.escapedFromLock=h,s(h)},[]),o=k.useMemo(()=>{let h;return{escapedFromLock:t,isAtBottom: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||!d.current?0:n.current.scrollHeight-1-n.current.clientHeight},get calculatedTargetScrollTop(){if(!n.current||!d.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(h?.targetScrollTop===u)return h.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:n.current,contentElement:d.current}),u),0);return h={targetScrollTop:u,calculatedScrollTop:_},requestAnimationFrame(()=>{h=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ph}}},[]),p=k.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||c(!0);const u=Date.now()+(Number(h.wait)||0),_=lr(r.current,h.animation),{ignoreEscapes:x=!1}=h;let w,E=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const b=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:j}=o,L=performance.now(),M=(L-(o.lastTick??L))/vh;if(o.animation||(o.animation={behavior:_,promise:R,ignoreEscapes:x}),o.animation.behavior===_&&(o.lastTick=L),i()||u>Date.now())return b();if(j<Math.min(E,o.calculatedTargetScrollTop)){if(o.animation?.behavior===_){if(_==="instant")return o.scrollTop=o.calculatedTargetScrollTop,b();o.velocity=(_.damping*o.velocity+_.stiffness*o.scrollDifference)/_.mass,o.accumulated+=o.velocity*M,o.scrollTop+=o.accumulated,o.scrollTop!==j&&(o.accumulated=0)}return b()}return w>Date.now()?(E=o.calculatedTargetScrollTop,b()):(o.animation=void 0,o.scrollTop<o.calculatedTargetScrollTop?p({animation:lr(r.current,r.current.resize),ignoreEscapes:x,duration:Math.max(0,w-Date.now())||void 0}):o.isAtBottom)});return R.then(j=>(requestAnimationFrame(()=>{o.animation||(o.lastTick=void 0,o.velocity=0)}),j))};return h.wait!==!0&&(o.animation=void 0),o.animation?.behavior===_?o.animation.promise:b()},[c,i,o]),S=k.useCallback(()=>{f(!0),c(!1)},[f,c]),y=k.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:_}=o;let{lastScrollTop:x=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,_&&_>u&&(x=_),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===_)return;if(i()){f(!0),c(!1);return}const w=u>x,E=u<x;if(o.animation?.ignoreEscapes){o.scrollTop=x;return}E&&(f(!0),c(!1)),w&&f(!1),!o.escapedFromLock&&o.isNearBottom&&c(!0)},1)},[f,c,i,o]),g=k.useCallback(({target:h,deltaY:u})=>{let _=h;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===n.current&&u<0&&n.current.scrollHeight>n.current.clientHeight&&!o.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,o]),n=Di(h=>{n.current?.removeEventListener("scroll",y),n.current?.removeEventListener("wheel",g),h?.addEventListener("scroll",y,{passive:!0}),h?.addEventListener("wheel",g,{passive:!0})},[]),d=Di(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([_])=>{const{height:x}=_.contentRect,w=x-(u??x);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const E=lr(r.current,u?r.current.resize:r.current.initial);p({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:gh})}else o.isNearBottom&&(f(!1),c(!0));u=x,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:d,scrollRef:n,scrollToBottom:p,stopScroll:S,isAtBottom:l||v,isNearBottom:v,escapedFromLock:t,state:o}};function Di(e,t){const s=k.useCallback(l=>(s.current=l,e(l)),t);return s}const ar=new Map;function lr(...e){const t={...mh};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 ar.has(l)||ar.set(l,Object.freeze(t)),s?"instant":ar.get(l)}function _h({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 gs(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function bh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Gn({usage:e}){const{t}=he();if(!e)return null;const s=e.modelContextWindow,l=s?e.totalTokens/s:0,m=s?Math.min(Math.round(l*100),100):null,v=s?bh(l):"text-neutral-400",C=s?a.jsx("span",{children:t("上下文: {used} / {max} tokens",{used:gs(e.totalTokens),max:gs(s)})}):a.jsx("span",{children:t("已使用: {used} tokens",{used:gs(e.totalTokens)})});return a.jsx(_h,{content:C,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(Ya,{size:14,className:v}),a.jsxs("span",{className:`tabular-nums ${v}`,children:[gs(e.totalTokens),m!==null&&a.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",m,"%"]})]})]})})}var cr={exports:{}},Ai;function xh(){return Ai||(Ai=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,_,x,w){var E,b=arguments.length,R=b<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,x,w);else for(var j=u.length-1;j>=0;j--)(E=u[j])&&(R=(b<3?E(R):b>3?E(_,x,R):E(_,x))||R);return b>3&&R&&Object.defineProperty(_,x,R),R},f=this&&this.__param||function(u,_){return function(x,w){_(x,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const o=i(9042),p=i(6114),S=i(9924),y=i(844),g=i(5596),n=i(4725),d=i(3656);let h=r.AccessibilityManager=class extends y.Disposable{constructor(u,_){super(),this._terminal=u,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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 S.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((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(`
@@ -16,9 +16,9 @@ WARNING: This link could potentially be dangerous`)){const d=window.open();if(d)
16
16
  `:`
17
17
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(b){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),d.isLinux&&b&&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(b){const R=this._getMouseBufferCoords(b),j=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(j&&L&&R)&&this._areCoordsInSelection(R,j,L)}isCellInSelection(b,R){const j=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!j||!L)&&this._areCoordsInSelection([b,R],j,L)}_areCoordsInSelection(b,R,j){return b[1]>R[1]&&b[1]<j[1]||R[1]===j[1]&&b[1]===R[1]&&b[0]>=R[0]&&b[0]<j[0]||R[1]<j[1]&&b[1]===j[1]&&b[0]<j[0]||R[1]<j[1]&&b[1]===R[1]&&b[0]>=R[0]}_selectWordAtCursor(b,R){var j,L;const M=(L=(j=this._linkifier.currentLink)===null||j===void 0?void 0:j.link)===null||L===void 0?void 0:L.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,h.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(b);return!!T&&(this._selectWordAt(T,R),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(b,R){this._model.clearSelection(),b=Math.max(b,0),R=Math.min(R,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,b],this._model.selectionEnd=[this._bufferService.cols,R],this.refresh(),this._onSelectionChange.fire()}_handleTrim(b){this._model.handleTrim(b)&&this.refresh()}_getMouseBufferCoords(b){const R=this._mouseService.getCoords(b,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(R)return R[0]--,R[1]--,R[1]+=this._bufferService.buffer.ydisp,R}_getMouseEventScrollAmount(b){let R=(0,o.getCoordsRelativeToElement)(this._coreBrowserService.window,b,this._screenElement)[1];const j=this._renderService.dimensions.css.canvas.height;return R>=0&&R<=j?0:(R>j&&(R-=j),R=Math.min(Math.max(R,-50),50),R/=50,R/Math.abs(R)+Math.round(14*R))}shouldForceSelection(b){return d.isMac?b.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:b.shiftKey}handleMouseDown(b){if(this._mouseDownTimeStamp=b.timeStamp,(b.button!==2||!this.hasSelection)&&b.button===0){if(!this._enabled){if(!this.shouldForceSelection(b))return;b.stopPropagation()}b.preventDefault(),this._dragScrollAmount=0,this._enabled&&b.shiftKey?this._handleIncrementalClick(b):b.detail===1?this._handleSingleClick(b):b.detail===2?this._handleDoubleClick(b):b.detail===3&&this._handleTripleClick(b),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(b){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(b))}_handleSingleClick(b){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(b)?3:0,this._model.selectionStart=this._getMouseBufferCoords(b),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const R=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);R&&R.length!==this._model.selectionStart[0]&&R.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(b){this._selectWordAtCursor(b,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(b){const R=this._getMouseBufferCoords(b);R&&(this._activeSelectionMode=2,this._selectLineAt(R[1]))}shouldColumnSelect(b){return b.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(b){if(b.stopImmediatePropagation(),!this._model.selectionStart)return;const R=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(b),!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(b),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 L=j.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}R&&R[0]===this._model.selectionEnd[0]&&R[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const b=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(b.ydisp+this._bufferService.rows,b.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=b.ydisp),this.refresh()}}_handleMouseUp(b){const R=b.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&R<500&&b.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const j=this._mouseService.getCoords(b,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(j&&j[0]!==void 0&&j[1]!==void 0){const L=(0,p.moveToCellSequence)(j[0]-1,j[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const b=this._model.finalSelectionStart,R=this._model.finalSelectionEnd,j=!(!b||!R||b[0]===R[0]&&b[1]===R[1]);j?b&&R&&(this._oldSelectionStart&&this._oldSelectionEnd&&b[0]===this._oldSelectionStart[0]&&b[1]===this._oldSelectionStart[1]&&R[0]===this._oldSelectionEnd[0]&&R[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(b,R,j)):this._oldHasSelection&&this._fireOnSelectionChange(b,R,j)}_fireOnSelectionChange(b,R,j){this._oldSelectionStart=b,this._oldSelectionEnd=R,this._oldHasSelection=j,this._onSelectionChange.fire()}_handleBufferActivate(b){this.clearSelection(),this._trimListener.dispose(),this._trimListener=b.activeBuffer.lines.onTrim((R=>this._handleTrim(R)))}_convertViewportColToCharacterIndex(b,R){let j=R;for(let L=0;R>=L;L++){const M=b.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?j--:M>1&&R!==L&&(j+=M-1)}return j}setSelection(b,R,j){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[b,R],this._model.selectionStartLength=j,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(b){this._isClickInSelection(b)||(this._selectWordAtCursor(b,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(b,R,j=!0,L=!0){if(b[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,T=M.lines.get(b[1]);if(!T)return;const B=M.translateBufferLineToString(b[1],!1);let I=this._convertViewportColToCharacterIndex(T,b[0]),H=I;const W=b[0]-I;let A=0,N=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 K=b[0],Q=b[0];T.getWidth(K)===0&&(A++,K--),T.getWidth(Q)===2&&(N++,Q++);const se=T.getString(Q).length;for(se>1&&(O+=se-1,H+=se-1);K>0&&I>0&&!this._isCharWordSeparator(T.loadCell(K-1,this._workCell));){T.loadCell(K-1,this._workCell);const D=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,K--):D>1&&(P+=D-1,I-=D-1),I--,K--}for(;Q<T.length&&H+1<B.length&&!this._isCharWordSeparator(T.loadCell(Q+1,this._workCell));){T.loadCell(Q+1,this._workCell);const D=this._workCell.getChars().length;this._workCell.getWidth()===2?(N++,Q++):D>1&&(O+=D-1,H+=D-1),H++,Q++}}H++;let $=I+W-A+P,X=Math.min(this._bufferService.cols,H-I+A+N-P-O);if(R||B.slice(I,H).trim()!==""){if(j&&$===0&&T.getCodePoint(0)!==32){const K=M.lines.get(b[1]-1);if(K&&T.isWrapped&&K.getCodePoint(this._bufferService.cols-1)!==32){const Q=this._getWordAt([this._bufferService.cols-1,b[1]-1],!1,!0,!1);if(Q){const se=this._bufferService.cols-Q.start;$-=se,X+=se}}}if(L&&$+X===this._bufferService.cols&&T.getCodePoint(this._bufferService.cols-1)!==32){const K=M.lines.get(b[1]+1);if(K?.isWrapped&&K.getCodePoint(0)!==32){const Q=this._getWordAt([0,b[1]+1],!1,!1,!0);Q&&(X+=Q.length)}}return{start:$,length:X}}}_selectWordAt(b,R){const j=this._getWordAt(b,R);if(j){for(;j.start<0;)j.start+=this._bufferService.cols,b[1]--;this._model.selectionStart=[j.start,b[1]],this._model.selectionStartLength=j.length}}_selectToWordAt(b){const R=this._getWordAt(b,!0);if(R){let j=b[1];for(;R.start<0;)R.start+=this._bufferService.cols,j--;if(!this._model.areSelectionValuesReversed())for(;R.start+R.length>this._bufferService.cols;)R.length-=this._bufferService.cols,j++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?R.start:R.start+R.length,j]}}_isCharWordSeparator(b){return b.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(b.getChars())>=0}_selectLineAt(b){const R=this._bufferService.buffer.getWrappedRangeForLine(b),j={start:{x:0,y:R.first},end:{x:this._bufferService.cols-1,y:R.last}};this._model.selectionStart=[0,R.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,h.getRangeLength)(j,this._bufferService.cols)}};r.SelectionService=E=c([f(3,_.IBufferService),f(4,_.ICoreService),f(5,y.IMouseService),f(6,_.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},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(E,b,R,j){var L,M=arguments.length,T=M<3?b:j===null?j=Object.getOwnPropertyDescriptor(b,R):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(E,b,R,j);else for(var B=E.length-1;B>=0;B--)(L=E[B])&&(T=(M<3?L(T):M>3?L(b,R,T):L(b,R))||T);return M>3&&T&&Object.defineProperty(b,R,T),T},f=this&&this.__param||function(E,b){return function(R,j){b(R,j,E)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const o=i(7239),p=i(8055),S=i(8460),y=i(844),g=i(2585),n=p.css.toColor("#ffffff"),d=p.css.toColor("#000000"),h=p.css.toColor("#ffffff"),u=p.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],b=[0,95,135,175,215,255];for(let R=0;R<216;R++){const j=b[R/36%6|0],L=b[R/6%6|0],M=b[R%6];E.push({css:p.channels.toCss(j,L,M),rgba:p.channels.toRgba(j,L,M)})}for(let R=0;R<24;R++){const j=8+10*R;E.push({css:p.channels.toCss(j,j,j),rgba:p.channels.toRgba(j,j,j)})}return E})());let x=r.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new o.ColorContrastCache,this._halfContrastCache=new o.ColorContrastCache,this._onChangeColors=this.register(new S.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:d,cursor:h,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:p.color.blend(d,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:p.color.blend(d,_),ansi: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(E={}){const b=this._colors;if(b.foreground=w(E.foreground,n),b.background=w(E.background,d),b.cursor=w(E.cursor,h),b.cursorAccent=w(E.cursorAccent,u),b.selectionBackgroundTransparent=w(E.selectionBackground,_),b.selectionBackgroundOpaque=p.color.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=w(E.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=p.color.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=E.selectionForeground?w(E.selectionForeground,p.NULL_COLOR):void 0,b.selectionForeground===p.NULL_COLOR&&(b.selectionForeground=void 0),p.color.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=p.color.opacity(b.selectionBackgroundTransparent,.3)),p.color.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=p.color.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.ansi=r.DEFAULT_ANSI_COLORS.slice(),b.ansi[0]=w(E.black,r.DEFAULT_ANSI_COLORS[0]),b.ansi[1]=w(E.red,r.DEFAULT_ANSI_COLORS[1]),b.ansi[2]=w(E.green,r.DEFAULT_ANSI_COLORS[2]),b.ansi[3]=w(E.yellow,r.DEFAULT_ANSI_COLORS[3]),b.ansi[4]=w(E.blue,r.DEFAULT_ANSI_COLORS[4]),b.ansi[5]=w(E.magenta,r.DEFAULT_ANSI_COLORS[5]),b.ansi[6]=w(E.cyan,r.DEFAULT_ANSI_COLORS[6]),b.ansi[7]=w(E.white,r.DEFAULT_ANSI_COLORS[7]),b.ansi[8]=w(E.brightBlack,r.DEFAULT_ANSI_COLORS[8]),b.ansi[9]=w(E.brightRed,r.DEFAULT_ANSI_COLORS[9]),b.ansi[10]=w(E.brightGreen,r.DEFAULT_ANSI_COLORS[10]),b.ansi[11]=w(E.brightYellow,r.DEFAULT_ANSI_COLORS[11]),b.ansi[12]=w(E.brightBlue,r.DEFAULT_ANSI_COLORS[12]),b.ansi[13]=w(E.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),b.ansi[14]=w(E.brightCyan,r.DEFAULT_ANSI_COLORS[14]),b.ansi[15]=w(E.brightWhite,r.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const R=Math.min(b.ansi.length-16,E.extendedAnsi.length);for(let j=0;j<R;j++)b.ansi[j+16]=w(E.extendedAnsi[j],r.DEFAULT_ANSI_COLORS[j+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let b=0;b<this._restoreColors.ansi.length;++b)this._colors.ansi[b]=this._restoreColors.ansi[b]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function w(E,b){if(E!==void 0)try{return p.css.toColor(E)}catch{}return b}r.ThemeService=x=c([f(0,g.IOptionsService)],x)},6349:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const c=i(8460),f=i(844);class o extends f.Disposable{constructor(S){super(),this._maxLength=S,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(S){if(this._maxLength===S)return;const y=new Array(S);for(let g=0;g<Math.min(S,this.length);g++)y[g]=this._array[this._getCyclicIndex(g)];this._array=y,this._maxLength=S,this._startIndex=0}get length(){return this._length}set length(S){if(S>this._length)for(let y=this._length;y<S;y++)this._array[y]=void 0;this._length=S}get(S){return this._array[this._getCyclicIndex(S)]}set(S,y){this._array[this._getCyclicIndex(S)]=y}push(S){this._array[this._getCyclicIndex(this._length)]=S,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(S,y,...g){if(y){for(let n=S;n<this._length-y;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+y)];this._length-=y,this.onDeleteEmitter.fire({index:S,amount:y})}for(let n=this._length-1;n>=S;n--)this._array[this._getCyclicIndex(n+g.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<g.length;n++)this._array[this._getCyclicIndex(S+n)]=g[n];if(g.length&&this.onInsertEmitter.fire({index:S,amount:g.length}),this._length+g.length>this._maxLength){const n=this._length+g.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=g.length}trimStart(S){S>this._length&&(S=this._length),this._startIndex+=S,this._length-=S,this.onTrimEmitter.fire(S)}shiftElements(S,y,g){if(!(y<=0)){if(S<0||S>=this._length)throw new Error("start argument out of range");if(S+g<0)throw new Error("Cannot shift elements in list beyond index 0");if(g>0){for(let d=y-1;d>=0;d--)this.set(S+d+g,this.get(S+d));const n=S+y+g-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<y;n++)this.set(S+n+g,this.get(S+n))}}_getCyclicIndex(S){return(this._startIndex+S)%this._maxLength}}r.CircularList=o},1439:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function i(c,f=5){if(typeof c!="object")return c;const o=Array.isArray(c)?[]:{};for(const p in c)o[p]=f<=1?c[p]:c[p]&&i(c[p],f-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 f=0,o=0,p=0,S=0;var y,g,n,d,h;function u(x){const w=x.toString(16);return w.length<2?"0"+w:w}function _(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,E,b,R){return R!==void 0?`#${u(w)}${u(E)}${u(b)}${u(R)}`:`#${u(w)}${u(E)}${u(b)}`},x.toRgba=function(w,E,b,R=255){return(w<<24|E<<16|b<<8|R)>>>0}})(y||(r.channels=y={})),(function(x){function w(E,b){return S=Math.round(255*b),[f,o,p]=h.toChannels(E.rgba),{css:y.toCss(f,o,p,S),rgba:y.toRgba(f,o,p,S)}}x.blend=function(E,b){if(S=(255&b.rgba)/255,S===1)return{css:b.css,rgba:b.rgba};const R=b.rgba>>24&255,j=b.rgba>>16&255,L=b.rgba>>8&255,M=E.rgba>>24&255,T=E.rgba>>16&255,B=E.rgba>>8&255;return f=M+Math.round((R-M)*S),o=T+Math.round((j-T)*S),p=B+Math.round((L-B)*S),{css:y.toCss(f,o,p),rgba:y.toRgba(f,o,p)}},x.isOpaque=function(E){return(255&E.rgba)==255},x.ensureContrastRatio=function(E,b,R){const j=h.ensureContrastRatio(E.rgba,b.rgba,R);if(j)return h.toColor(j>>24&255,j>>16&255,j>>8&255)},x.opaque=function(E){const b=(255|E.rgba)>>>0;return[f,o,p]=h.toChannels(b),{css:y.toCss(f,o,p),rgba:b}},x.opacity=w,x.multiplyOpacity=function(E,b){return S=255&E.rgba,w(E,S*b/255)},x.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(g||(r.color=g={})),(function(x){let w,E;if(!c.isNode){const b=document.createElement("canvas");b.width=1,b.height=1;const R=b.getContext("2d",{willReadFrequently:!0});R&&(w=R,w.globalCompositeOperation="copy",E=w.createLinearGradient(0,0,1,1))}x.toColor=function(b){if(b.match(/#[\da-f]{3,8}/i))switch(b.length){case 4:return f=parseInt(b.slice(1,2).repeat(2),16),o=parseInt(b.slice(2,3).repeat(2),16),p=parseInt(b.slice(3,4).repeat(2),16),h.toColor(f,o,p);case 5:return f=parseInt(b.slice(1,2).repeat(2),16),o=parseInt(b.slice(2,3).repeat(2),16),p=parseInt(b.slice(3,4).repeat(2),16),S=parseInt(b.slice(4,5).repeat(2),16),h.toColor(f,o,p,S);case 7:return{css:b,rgba:(parseInt(b.slice(1),16)<<8|255)>>>0};case 9:return{css:b,rgba:parseInt(b.slice(1),16)>>>0}}const R=b.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(R)return f=parseInt(R[1]),o=parseInt(R[2]),p=parseInt(R[3]),S=Math.round(255*(R[5]===void 0?1:parseFloat(R[5]))),h.toColor(f,o,p,S);if(!w||!E)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=E,w.fillStyle=b,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[f,o,p,S]=w.getImageData(0,0,1,1).data,S!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,o,p,S),css:b}}})(n||(r.css=n={})),(function(x){function w(E,b,R){const j=E/255,L=b/255,M=R/255;return .2126*(j<=.03928?j/12.92:Math.pow((j+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}x.relativeLuminance=function(E){return w(E>>16&255,E>>8&255,255&E)},x.relativeLuminance2=w})(d||(r.rgb=d={})),(function(x){function w(b,R,j){const L=b>>24&255,M=b>>16&255,T=b>>8&255;let B=R>>24&255,I=R>>16&255,H=R>>8&255,W=_(d.relativeLuminance2(B,I,H),d.relativeLuminance2(L,M,T));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=_(d.relativeLuminance2(B,I,H),d.relativeLuminance2(L,M,T));return(B<<24|I<<16|H<<8|255)>>>0}function E(b,R,j){const L=b>>24&255,M=b>>16&255,T=b>>8&255;let B=R>>24&255,I=R>>16&255,H=R>>8&255,W=_(d.relativeLuminance2(B,I,H),d.relativeLuminance2(L,M,T));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=_(d.relativeLuminance2(B,I,H),d.relativeLuminance2(L,M,T));return(B<<24|I<<16|H<<8|255)>>>0}x.ensureContrastRatio=function(b,R,j){const L=d.relativeLuminance(b>>8),M=d.relativeLuminance(R>>8);if(_(L,M)<j){if(M<L){const I=w(b,R,j),H=_(L,d.relativeLuminance(I>>8));if(H<j){const W=E(b,R,j);return H>_(L,d.relativeLuminance(W>>8))?I:W}return I}const T=E(b,R,j),B=_(L,d.relativeLuminance(T>>8));if(B<j){const I=w(b,R,j);return B>_(L,d.relativeLuminance(I>>8))?T:I}return T}},x.reduceLuminance=w,x.increaseLuminance=E,x.toChannels=function(b){return[b>>24&255,b>>16&255,b>>8&255,255&b]},x.toColor=function(b,R,j,L){return{css:y.toCss(b,R,j,L),rgba:y.toRgba(b,R,j,L)}}})(h||(r.rgba=h={})),r.toPaddedHex=u,r.contrastRatio=_},8969:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const c=i(844),f=i(2585),o=i(4348),p=i(7866),S=i(744),y=i(7302),g=i(6975),n=i(8460),d=i(1753),h=i(1480),u=i(7994),_=i(9282),x=i(5435),w=i(5981),E=i(2660);let b=!1;class R extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((L=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(L.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(L){for(const M in L)this.optionsService.options[M]=L[M]}constructor(L){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 y.OptionsService(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(S.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(g.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(h.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new 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((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new w.WriteBuffer(((M,T)=>this._inputHandler.parse(M,T)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,M){this._writeBuffer.write(L,M)}writeSync(L,M){this._logService.logLevel<=f.LogLevelEnum.WARN&&!b&&(this._logService.warn("writeSync is unreliable and will be removed soon."),b=!0),this._writeBuffer.writeSync(L,M)}resize(L,M){isNaN(L)||isNaN(M)||(L=Math.max(L,S.MINIMUM_COLS),M=Math.max(M,S.MINIMUM_ROWS),this._bufferService.resize(L,M))}scroll(L,M=!1){this._bufferService.scroll(L,M)}scrollLines(L,M,T){this._bufferService.scrollLines(L,M,T)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const M=L-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(L,M){return this._inputHandler.registerEscHandler(L,M)}registerDcsHandler(L,M){return this._inputHandler.registerDcsHandler(L,M)}registerCsiHandler(L,M){return this._inputHandler.registerCsiHandler(L,M)}registerOscHandler(L,M){return this._inputHandler.registerOscHandler(L,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?L=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const M of L)M.dispose()}))}}}r.CoreTerminal=R},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 f=[];for(let o=0;o<this._listeners.length;o++)f.push(this._listeners[o]);for(let o=0;o<f.length;o++)f[o].call(void 0,i,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(i,c){return i((f=>c.fire(f)))}},5435:function(C,r,i){var c=this&&this.__decorate||function(W,A,N,P){var O,$=arguments.length,X=$<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,N):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(W,A,N,P);else for(var K=W.length-1;K>=0;K--)(O=W[K])&&(X=($<3?O(X):$>3?O(A,N,X):O(A,N))||X);return $>3&&X&&Object.defineProperty(A,N,X),X},f=this&&this.__param||function(W,A){return function(N,P){A(N,P,W)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const o=i(2584),p=i(7116),S=i(2015),y=i(844),g=i(482),n=i(8437),d=i(8460),h=i(643),u=i(511),_=i(3734),x=i(2585),w=i(6242),E=i(6351),b=i(5941),R={"(":0,")":1,"*":2,"+":3,"-":1,".":2},j=131072;function L(W,A){if(W>24)return A.setWinLines||!1;switch(W){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(r.WindowsOptionsReportType=M={}));let T=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,N,P,O,$,X,K,Q,se=new S.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=N,this._coreService=P,this._logService=O,this._optionsService=$,this._oscLinkService=X,this._coreMouseService=K,this._unicodeService=Q,this._parser=se,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new g.StringToUtf32,this._utf8Decoder=new g.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._parser.setCsiHandlerFallback(((D,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(D),params:F.toArray()})})),this._parser.setEscHandlerFallback((D=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(D)})})),this._parser.setExecuteHandlerFallback((D=>{this._logService.debug("Unknown EXECUTE code: ",{code:D})})),this._parser.setOscHandlerFallback(((D,F,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:D,action:F,data:U})})),this._parser.setDcsHandlerFallback(((D,F,U)=>{F==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(D),action:F,payload:U})})),this._parser.setPrintHandler(((D,F,U)=>this.print(D,F,U))),this._parser.registerCsiHandler({final:"@"},(D=>this.insertChars(D))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(D=>this.scrollLeft(D))),this._parser.registerCsiHandler({final:"A"},(D=>this.cursorUp(D))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(D=>this.scrollRight(D))),this._parser.registerCsiHandler({final:"B"},(D=>this.cursorDown(D))),this._parser.registerCsiHandler({final:"C"},(D=>this.cursorForward(D))),this._parser.registerCsiHandler({final:"D"},(D=>this.cursorBackward(D))),this._parser.registerCsiHandler({final:"E"},(D=>this.cursorNextLine(D))),this._parser.registerCsiHandler({final:"F"},(D=>this.cursorPrecedingLine(D))),this._parser.registerCsiHandler({final:"G"},(D=>this.cursorCharAbsolute(D))),this._parser.registerCsiHandler({final:"H"},(D=>this.cursorPosition(D))),this._parser.registerCsiHandler({final:"I"},(D=>this.cursorForwardTab(D))),this._parser.registerCsiHandler({final:"J"},(D=>this.eraseInDisplay(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(D=>this.eraseInDisplay(D,!0))),this._parser.registerCsiHandler({final:"K"},(D=>this.eraseInLine(D,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(D=>this.eraseInLine(D,!0))),this._parser.registerCsiHandler({final:"L"},(D=>this.insertLines(D))),this._parser.registerCsiHandler({final:"M"},(D=>this.deleteLines(D))),this._parser.registerCsiHandler({final:"P"},(D=>this.deleteChars(D))),this._parser.registerCsiHandler({final:"S"},(D=>this.scrollUp(D))),this._parser.registerCsiHandler({final:"T"},(D=>this.scrollDown(D))),this._parser.registerCsiHandler({final:"X"},(D=>this.eraseChars(D))),this._parser.registerCsiHandler({final:"Z"},(D=>this.cursorBackwardTab(D))),this._parser.registerCsiHandler({final:"`"},(D=>this.charPosAbsolute(D))),this._parser.registerCsiHandler({final:"a"},(D=>this.hPositionRelative(D))),this._parser.registerCsiHandler({final:"b"},(D=>this.repeatPrecedingCharacter(D))),this._parser.registerCsiHandler({final:"c"},(D=>this.sendDeviceAttributesPrimary(D))),this._parser.registerCsiHandler({prefix:">",final:"c"},(D=>this.sendDeviceAttributesSecondary(D))),this._parser.registerCsiHandler({final:"d"},(D=>this.linePosAbsolute(D))),this._parser.registerCsiHandler({final:"e"},(D=>this.vPositionRelative(D))),this._parser.registerCsiHandler({final:"f"},(D=>this.hVPosition(D))),this._parser.registerCsiHandler({final:"g"},(D=>this.tabClear(D))),this._parser.registerCsiHandler({final:"h"},(D=>this.setMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(D=>this.setModePrivate(D))),this._parser.registerCsiHandler({final:"l"},(D=>this.resetMode(D))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(D=>this.resetModePrivate(D))),this._parser.registerCsiHandler({final:"m"},(D=>this.charAttributes(D))),this._parser.registerCsiHandler({final:"n"},(D=>this.deviceStatus(D))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(D=>this.deviceStatusPrivate(D))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(D=>this.softReset(D))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(D=>this.setCursorStyle(D))),this._parser.registerCsiHandler({final:"r"},(D=>this.setScrollRegion(D))),this._parser.registerCsiHandler({final:"s"},(D=>this.saveCursor(D))),this._parser.registerCsiHandler({final:"t"},(D=>this.windowOptions(D))),this._parser.registerCsiHandler({final:"u"},(D=>this.restoreCursor(D))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(D=>this.insertColumns(D))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(D=>this.deleteColumns(D))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(D=>this.selectProtected(D))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(D=>this.requestMode(D,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(D=>this.requestMode(D,!1))),this._parser.setExecuteHandler(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((D=>(this.setTitle(D),this.setIconName(D),!0)))),this._parser.registerOscHandler(1,new w.OscHandler((D=>this.setIconName(D)))),this._parser.registerOscHandler(2,new w.OscHandler((D=>this.setTitle(D)))),this._parser.registerOscHandler(4,new w.OscHandler((D=>this.setOrReportIndexedColor(D)))),this._parser.registerOscHandler(8,new w.OscHandler((D=>this.setHyperlink(D)))),this._parser.registerOscHandler(10,new w.OscHandler((D=>this.setOrReportFgColor(D)))),this._parser.registerOscHandler(11,new w.OscHandler((D=>this.setOrReportBgColor(D)))),this._parser.registerOscHandler(12,new w.OscHandler((D=>this.setOrReportCursorColor(D)))),this._parser.registerOscHandler(104,new w.OscHandler((D=>this.restoreIndexedColor(D)))),this._parser.registerOscHandler(110,new w.OscHandler((D=>this.restoreFgColor(D)))),this._parser.registerOscHandler(111,new w.OscHandler((D=>this.restoreBgColor(D)))),this._parser.registerOscHandler(112,new w.OscHandler((D=>this.restoreCursorColor(D)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const D in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:D},(()=>this.selectCharset("("+D))),this._parser.registerEscHandler({intermediates:")",final:D},(()=>this.selectCharset(")"+D))),this._parser.registerEscHandler({intermediates:"*",final:D},(()=>this.selectCharset("*"+D))),this._parser.registerEscHandler({intermediates:"+",final:D},(()=>this.selectCharset("+"+D))),this._parser.registerEscHandler({intermediates:"-",final:D},(()=>this.selectCharset("-"+D))),this._parser.registerEscHandler({intermediates:".",final:D},(()=>this.selectCharset("."+D))),this._parser.registerEscHandler({intermediates:"/",final:D},(()=>this.selectCharset("/"+D)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((D=>(this._logService.error("Parsing error: ",D),D))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((D,F)=>this.requestStatusString(D,F))))}_preserveStack(A,N,P,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=N,this._parseStack.decodedLength=P,this._parseStack.position=O}_logSlowResolvingAsync(A){this._logService.logLevel<=x.LogLevelEnum.WARN&&Promise.race([A,new Promise(((N,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((N=>{if(N!=="#SLOW_TIMEOUT")throw N;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,N){let P,O=this._activeBuffer.x,$=this._activeBuffer.y,X=0;const K=this._parseStack.paused;if(K){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,N))return this._logSlowResolvingAsync(P),P;O=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>j&&(X=this._parseStack.position+j)}if(this._logService.logLevel<=x.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(Q=>String.fromCharCode(Q))).join("")}"`),typeof A=="string"?A.split("").map((Q=>Q.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<j&&(this._parseBuffer=new Uint32Array(Math.min(A.length,j))),K||this._dirtyRowTracker.clearRange(),A.length>j)for(let Q=X;Q<A.length;Q+=j){const se=Q+j<A.length?Q+j:A.length,D=typeof A=="string"?this._stringDecoder.decode(A.substring(Q,se),this._parseBuffer):this._utf8Decoder.decode(A.subarray(Q,se),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,D))return this._preserveStack(O,$,D,Q),this._logSlowResolvingAsync(P),P}else if(!K){const Q=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,Q))return this._preserveStack(O,$,Q,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===O&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,N,P){let O,$;const X=this._charsetService.charset,K=this._optionsService.rawOptions.screenReaderMode,Q=this._bufferService.cols,se=this._coreService.decPrivateModes.wraparound,D=this._coreService.modes.insertMode,F=this._curAttrData;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-N>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let z=N;z<P;++z){if(O=A[z],$=this._unicodeService.wcwidth(O),O<127&&X){const ee=X[String.fromCharCode(O)];ee&&(O=ee.charCodeAt(0))}if(K&&this._onA11yChar.fire((0,g.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=Q){if(se){for(;this._activeBuffer.x<Q;)U.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Q-1,$===2)continue}if(D&&(U.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(F),F),U.getWidth(Q-1)===2&&U.setCellFromCodePoint(Q-1,h.NULL_CELL_CODE,h.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),U.setCellFromCodePoint(this._activeBuffer.x++,O,$,F.fg,F.bg,F.extended),$>0)for(;--$;)U.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else U.getWidth(this._activeBuffer.x-1)?U.addCodepointToCell(this._activeBuffer.x-1,O):U.addCodepointToCell(this._activeBuffer.x-2,O)}P-N>0&&(U.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<Q&&P-N>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,N){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,N):this._parser.registerCsiHandler(A,(P=>!L(P.params[0],this._optionsService.rawOptions.windowOptions)||N(P)))}registerDcsHandler(A,N){return this._parser.registerDcsHandler(A,new E.DcsHandler(N))}registerEscHandler(A,N){return this._parser.registerEscHandler(A,N)}registerOscHandler(A,N){return this._parser.registerOscHandler(A,new w.OscHandler(N))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);N.hasWidth(this._activeBuffer.x)&&!N.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,N){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+N):(this._activeBuffer.x=A,this._activeBuffer.y=N),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,N){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+N)}cursorUp(A){const N=this._activeBuffer.y-this._activeBuffer.scrollTop;return N>=0?this._moveCursor(0,-Math.min(N,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const N=this._activeBuffer.scrollBottom-this._activeBuffer.y;return N>=0?this._moveCursor(0,Math.min(N,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const N=A.params[0];return N===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:N===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=A.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=A.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const N=A.params[0];return N===1&&(this._curAttrData.bg|=536870912),N!==2&&N!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,N,P,O=!1,$=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);X.replaceCells(N,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),O&&(X.isWrapped=!1)}_resetBufferLine(A,N=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),N),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),P.isWrapped=!1)}eraseInDisplay(A,N=!1){let P;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,N);P<this._bufferService.rows;P++)this._resetBufferLine(P,N);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,N),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,N);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,N);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(A,N=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,N);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,N);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,N)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let N=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;N--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let N=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;N--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let N=A.params[0]||1;for(;N--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let N=A.params[0]||1;for(;N--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=A.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const N=A.params[0]||1,P=new Uint32Array(N);for(let O=0;O<N;++O)P[O]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(A){return A.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(A){return A.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(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let N=0;N<A.length;N++)switch(A.params[N]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let N=0;N<A.length;N++)switch(A.params[N]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let N=0;N<A.length;N++)switch(A.params[N]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let N=0;N<A.length;N++)switch(A.params[N]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[N]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,N){const P=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:$}=this._coreMouseService,X=this._coreService,{buffers:K,cols:Q}=this._bufferService,{active:se,alt:D}=K,F=this._optionsService.rawOptions,U=ne=>ne?1:2,z=A.params[0];return ee=z,V=N?z===2?4:z===4?U(X.modes.insertMode):z===12?3:z===20?U(F.convertEol):0:z===1?U(P.applicationCursorKeys):z===3?F.windowOptions.setWinLines?Q===80?2:Q===132?1:0:0:z===6?U(P.origin):z===7?U(P.wraparound):z===8?3:z===9?U(O==="X10"):z===12?U(F.cursorBlink):z===25?U(!X.isCursorHidden):z===45?U(P.reverseWraparound):z===66?U(P.applicationKeypad):z===67?4:z===1e3?U(O==="VT200"):z===1002?U(O==="DRAG"):z===1003?U(O==="ANY"):z===1004?U(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?U(se===D):z===2004?U(P.bracketedPasteMode):0,X.triggerDataEvent(`${o.C0.ESC}[${N?"":"?"}${ee};${V}$y`),!0;var ee,V}_updateAttrColor(A,N,P,O,$){return N===2?(A|=50331648,A&=-16777216,A|=_.AttributeData.fromColorRGB([P,O,$])):N===5&&(A&=-50331904,A|=33554432|255&P),A}_extractColor(A,N,P){const O=[0,0,-1,0,0,0];let $=0,X=0;do{if(O[X+$]=A.params[N+X],A.hasSubParams(N+X)){const K=A.getSubParams(N+X);let Q=0;do O[1]===5&&($=1),O[X+Q+1+$]=K[Q];while(++Q<K.length&&Q+X+1+$<O.length);break}if(O[1]===5&&X+$>=2||O[1]===2&&X+$>=5)break;O[1]&&($=1)}while(++X+N<A.length&&X+$<O.length);for(let K=2;K<O.length;++K)O[K]===-1&&(O[K]=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(A,N){N.extended=N.extended.clone(),(!~A||A>5)&&(A=1),N.extended.underlineStyle=A,N.fg|=268435456,A===0&&(N.fg&=-268435457),N.updateExtended()}_processSGR0(A){A.fg=n.DEFAULT_ATTR_DATA.fg,A.bg=n.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const N=A.length;let P;const O=this._curAttrData;for(let $=0;$<N;$++)P=A.params[$],P>=30&&P<=37?(O.fg&=-50331904,O.fg|=16777216|P-30):P>=40&&P<=47?(O.bg&=-50331904,O.bg|=16777216|P-40):P>=90&&P<=97?(O.fg&=-50331904,O.fg|=16777224|P-90):P>=100&&P<=107?(O.bg&=-50331904,O.bg|=16777224|P-100):P===0?this._processSGR0(O):P===1?O.fg|=134217728:P===3?O.bg|=67108864:P===4?(O.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,O)):P===5?O.fg|=536870912:P===7?O.fg|=67108864:P===8?O.fg|=1073741824:P===9?O.fg|=2147483648:P===2?O.bg|=134217728:P===21?this._processUnderline(2,O):P===22?(O.fg&=-134217729,O.bg&=-134217729):P===23?O.bg&=-67108865:P===24?(O.fg&=-268435457,this._processUnderline(0,O)):P===25?O.fg&=-536870913:P===27?O.fg&=-67108865:P===28?O.fg&=-1073741825:P===29?O.fg&=2147483647:P===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):P===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(A,$,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(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${o.C0.ESC}[0n`);break;case 6:const N=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[${N};${P}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const N=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[?${N};${P}R`)}return!0}softReset(A){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(A){const N=A.params[0]||1;switch(N){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const P=N%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(A){const N=A.params[0]||1;let P;return(A.length<2||(P=A.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>N&&(this._activeBuffer.scrollTop=N-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const N=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:N!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${o.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:N!==0&&N!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),N!==0&&N!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:N!==0&&N!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),N!==0&&N!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const N=[],P=A.split(";");for(;P.length>1;){const O=P.shift(),$=P.shift();if(/^\d+$/.exec(O)){const X=parseInt(O);if(H(X))if($==="?")N.push({type:0,index:X});else{const K=(0,b.parseColor)($);K&&N.push({type:1,index:X,color:K})}}}return N.length&&this._onColor.fire(N),!0}setHyperlink(A){const N=A.split(";");return!(N.length<2)&&(N[1]?this._createHyperlink(N[0],N[1]):!N[0]&&this._finishHyperlink())}_createHyperlink(A,N){this._getCurrentLinkId()&&this._finishHyperlink();const P=A.split(":");let O;const $=P.findIndex((X=>X.startsWith("id=")));return $!==-1&&(O=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:N}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,N){const P=A.split(";");for(let O=0;O<P.length&&!(N>=this._specialColors.length);++O,++N)if(P[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[N]}]);else{const $=(0,b.parseColor)(P[O]);$&&this._onColor.fire([{type:1,index:this._specialColors[N],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const N=[],P=A.split(";");for(let O=0;O<P.length;++O)if(/^\d+$/.exec(P[O])){const $=parseInt(P[O]);H($)&&N.push({type:2,index:$})}return N.length&&this._onColor.fire(N),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(R[A[0]],p.CHARSETS[A[1]]||p.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=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(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new u.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let N=0;N<this._bufferService.rows;++N){const P=this._activeBuffer.ybase+this._activeBuffer.y+N,O=this._activeBuffer.lines.get(P);O&&(O.fill(A),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,N){const P=this._bufferService.buffer,O=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${o.C0.ESC}${$}${o.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,N){this._dirtyRowTracker.markRangeDirty(A,N)}}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,A){W>A&&(T=W,W=A,A=T),W<this.start&&(this.start=W),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(W){return 0<=W&&W<256}I=c([f(0,x.IBufferService)],I)},844:(C,r)=>{function i(c){for(const f of c)f.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 f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},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(f,o,p){this._data[f]||(this._data[f]={}),this._data[f][o]=p}get(f,o){return this._data[f]?this._data[f][o]:void 0}clear(){this._data={}}}r.TwoKeyMap=i,r.FourKeyMap=class{constructor(){this._data=new i}set(c,f,o,p,S){this._data.get(c,f)||this._data.set(c,f,new i),this._data.get(c,f).set(o,p,S)}get(c,f,o,p){var S;return(S=this._data.get(c,f))===null||S===void 0?void 0:S.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 f=i.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[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 f=this._getKey(c);if(f===void 0||(i=this._search(f),i===-1)||this._getKey(this._array[i])!==f)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])===f);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,f){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do f(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===c)}values(){return[...this._array].values()}_search(c){let f=0,o=this._array.length-1;for(;o>=f;){let p=f+o>>1;const S=this._getKey(this._array[p]);if(S>c)o=p-1;else{if(!(S<c)){for(;p>0&&this._getKey(this._array[p-1])===c;)p--;return p}f=p+1}}return f}}},7226:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const c=i(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(S){this._tasks.push(S),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(S){this._idleCallback=void 0;let y=0,g=0,n=S.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),g=Math.max(y,g),d=S.timeRemaining(),1.5*g>d)return n-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-y))}ms`),void this._start();n=d}this.clear()}}class o extends f{_requestCallback(S){return setTimeout((()=>S(this._createDeadline(16))))}_cancelCallback(S){clearTimeout(S)}_createDeadline(S){const y=Date.now()+S;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}r.PriorityTaskQueue=o,r.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_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(f){const o=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=o?.get(f.cols-1),S=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);S&&p&&(S.isWrapped=p[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&p[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(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),f=i(7226),o=i(3734),p=i(8437),S=i(4634),y=i(511),g=i(643),n=i(4863),d=i(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(h,u,_){this._hasScrollback=h,this._optionsService=u,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,g.WHITESPACE_CELL_CHAR,g.WHITESPACE_CELL_WIDTH,g.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new o.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new o.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,u){return new p.BufferLine(this._bufferService.cols,this.getNullCell(h),u)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;const u=h+this._optionsService.rawOptions.scrollback;return u>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 _=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 b=0;b<this.lines.length;b++)x+=+this.lines.get(b).resize(h,_);let E=0;if(this._rows<u)for(let b=this._rows;b<u;b++)this.lines.length<u+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(h,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(h,_)));else for(let b=this._rows;b>u;b--)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 b=this.lines.length-w;b>0&&(this.lines.trimStart(b),this.ybase=Math.max(this.ybase-b,0),this.ydisp=Math.max(this.ydisp-b,0),this.savedY=Math.max(this.savedY-b,0)),this.lines.maxLength=w}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,u-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(h,u),this._cols>h))for(let E=0;E<this.lines.length;E++)x+=+this.lines.get(E).resize(h,_);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 _=(0,S.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(_.length>0){const x=(0,S.reflowLargerCreateNewLayout)(this.lines,_);(0,S.reflowLargerApplyNewLayout)(this.lines,x.layout),this._reflowLargerAdjustViewport(h,u,x.countRemoved)}}_reflowLargerAdjustViewport(h,u,_){const x=this.getNullCell(p.DEFAULT_ATTR_DATA);let w=_;for(;w-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new p.BufferLine(h,x))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(h,u){const _=this.getNullCell(p.DEFAULT_ATTR_DATA),x=[];let w=0;for(let E=this.lines.length-1;E>=0;E--){let b=this.lines.get(E);if(!b||!b.isWrapped&&b.getTrimmedLength()<=h)continue;const R=[b];for(;b.isWrapped&&E>0;)b=this.lines.get(--E),R.unshift(b);const j=this.ybase+this.y;if(j>=E&&j<E+R.length)continue;const L=R[R.length-1].getTrimmedLength(),M=(0,S.reflowSmallerGetNewLineLengths)(R,this._cols,h),T=M.length-R.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+T):Math.max(0,this.lines.length-this.lines.maxLength+T);const I=[];for(let O=0;O<T;O++){const $=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);I.push($)}I.length>0&&(x.push({start:E+R.length+w,newLines:I}),w+=I.length),R.push(...I);let H=M.length-1,W=M[H];W===0&&(H--,W=M[H]);let A=R.length-T-1,N=L;for(;A>=0;){const O=Math.min(N,W);if(R[H]===void 0)break;if(R[H].copyCellsFrom(R[A],N-O,W-O,O,!0),W-=O,W===0&&(H--,W=M[H]),N-=O,N===0){A--;const $=Math.max(A,0);N=(0,S.getWrappedLineTrimmedLength)(R,$,this._cols)}}for(let O=0;O<R.length;O++)M[O]<h&&R[O].setCell(M[O],_);let P=T-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+T,this.ybase+u-1)}if(x.length>0){const E=[],b=[];for(let H=0;H<this.lines.length;H++)b.push(this.lines.get(H));const R=this.lines.length;let j=R-1,L=0,M=x[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+w);let T=0;for(let H=Math.min(this.lines.maxLength-1,R+w-1);H>=0;H--)if(M&&M.start>j+T){for(let W=M.newLines.length-1;W>=0;W--)this.lines.set(H--,M.newLines[W]);H++,E.push({index:j+1,amount:M.newLines.length}),T+=M.newLines.length,M=x[++L]}else this.lines.set(H,b[j--]);let B=0;for(let H=E.length-1;H>=0;H--)E[H].index+=B,this.lines.onInsertEmitter.fire(E[H]),B+=E[H].amount;const I=Math.max(0,R+w-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(h,u,_=0,x){const w=this.lines.get(h);return w?w.translateToString(u,_,x):""}getWrappedRangeForLine(h){let u=h,_=h;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:u,last:_}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].line===h&&(this.markers[u].dispose(),this.markers.splice(u--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose(),this.markers.splice(h--,1);this._isClearing=!1}addMarker(h){const u=new n.Marker(h);return this.markers.push(u),u.register(this.lines.onTrim((_=>{u.line-=_,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((_=>{u.line>=_.index&&(u.line+=_.amount)}))),u.register(this.lines.onDelete((_=>{u.line>=_.index&&u.line<_.index+_.amount&&u.dispose(),u.line>_.index&&(u.line-=_.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},8437:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const c=i(3734),f=i(511),o=i(643),p=i(482);r.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let S=0;class y{constructor(n,d,h=!1){this.isWrapped=h,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const u=d||f.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]);for(let _=0;_<n;++_)this.setCell(_,u);this.length=n}get(n){const d=this._data[3*n+0],h=2097151&d;return[this._data[3*n+1],2097152&d?this._combined[n]:h?(0,p.stringFromCodePoint)(h):"",d>>22,2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):h]}set(n,d){this._data[3*n+1]=d[o.CHAR_DATA_ATTR_INDEX],d[o.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=d[1],this._data[3*n+0]=2097152|n|d[o.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=d[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[o.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&d}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n]:2097151&d?(0,p.stringFromCodePoint)(2097151&d):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,d){return S=3*n,d.content=this._data[S+0],d.fg=this._data[S+1],d.bg=this._data[S+2],2097152&d.content&&(d.combinedData=this._combined[n]),268435456&d.bg&&(d.extended=this._extendedAttrs[n]),d}setCell(n,d){2097152&d.content&&(this._combined[n]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[n]=d.extended),this._data[3*n+0]=d.content,this._data[3*n+1]=d.fg,this._data[3*n+2]=d.bg}setCellFromCodePoint(n,d,h,u,_,x){268435456&_&&(this._extendedAttrs[n]=x),this._data[3*n+0]=d|h<<22,this._data[3*n+1]=u,this._data[3*n+2]=_}addCodepointToCell(n,d){let h=this._data[3*n+0];2097152&h?this._combined[n]+=(0,p.stringFromCodePoint)(d):(2097151&h?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&h)+(0,p.stringFromCodePoint)(d),h&=-2097152,h|=2097152):h=d|4194304,this._data[3*n+0]=h)}insertCells(n,d,h,u){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length-n){const _=new f.CellData;for(let x=this.length-n-d-1;x>=0;--x)this.setCell(n+d+x,this.loadCell(n+x,_));for(let x=0;x<d;++x)this.setCell(n+x,h)}else for(let _=n;_<this.length;++_)this.setCell(_,h);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(n,d,h,u){if(n%=this.length,d<this.length-n){const _=new f.CellData;for(let x=0;x<this.length-n-d;++x)this.setCell(n+x,this.loadCell(n+d+x,_));for(let x=this.length-d;x<this.length;++x)this.setCell(x,h)}else for(let _=n;_<this.length;++_)this.setCell(_,h);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(n,d,h,u,_=!1){if(_)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<d&&n<this.length;)this.isProtected(n)||this.setCell(n,h),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);n<d&&n<this.length;)this.setCell(n++,h)}resize(n,d){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const h=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*h)this._data=new Uint32Array(this._data.buffer,0,h);else{const u=new Uint32Array(h);u.set(this._data),this._data=u}for(let u=this.length;u<n;++u)this.setCell(u,d)}else{this._data=this._data.subarray(0,h);const u=Object.keys(this._combined);for(let x=0;x<u.length;x++){const w=parseInt(u[x],10);w>=n&&delete this._combined[w]}const _=Object.keys(this._extendedAttrs);for(let x=0;x<_.length;x++){const w=parseInt(_[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,d=!1){if(d)for(let h=0;h<this.length;++h)this.isProtected(h)||this.setCell(h,n);else{this._combined={},this._extendedAttrs={};for(let h=0;h<this.length;++h)this.setCell(h,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const d in n._combined)this._combined[d]=n._combined[d];this._extendedAttrs={};for(const d in n._extendedAttrs)this._extendedAttrs[d]=n._extendedAttrs[d];this.isWrapped=n.isWrapped}clone(){const n=new y(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const d in this._combined)n._combined[d]=this._combined[d];for(const d in this._extendedAttrs)n._extendedAttrs[d]=this._extendedAttrs[d];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,d,h,u,_){const x=n._data;if(_)for(let E=u-1;E>=0;E--){for(let b=0;b<3;b++)this._data[3*(h+E)+b]=x[3*(d+E)+b];268435456&x[3*(d+E)+2]&&(this._extendedAttrs[h+E]=n._extendedAttrs[d+E])}else for(let E=0;E<u;E++){for(let b=0;b<3;b++)this._data[3*(h+E)+b]=x[3*(d+E)+b];268435456&x[3*(d+E)+2]&&(this._extendedAttrs[h+E]=n._extendedAttrs[d+E])}const w=Object.keys(n._combined);for(let E=0;E<w.length;E++){const b=parseInt(w[E],10);b>=d&&(this._combined[b-d+h]=n._combined[b])}}translateToString(n=!1,d=0,h=this.length){n&&(h=Math.min(h,this.getTrimmedLength()));let u="";for(;d<h;){const _=this._data[3*d+0],x=2097151&_;u+=2097152&_?this._combined[d]:x?(0,p.stringFromCodePoint)(x):o.WHITESPACE_CELL_CHAR,d+=_>>22||1}return u}}r.BufferLine=y},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,f,o){if(f===c.length-1)return c[f].getTrimmedLength();const p=!c[f].hasContent(o-1)&&c[f].getWidth(o-1)===1,S=c[f+1].getWidth(0)===2;return p&&S?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,f,o,p,S){const y=[];for(let g=0;g<c.length-1;g++){let n=g,d=c.get(++n);if(!d.isWrapped)continue;const h=[c.get(g)];for(;n<c.length&&d.isWrapped;)h.push(d),d=c.get(++n);if(p>=g&&p<n){g+=h.length-1;continue}let u=0,_=i(h,u,f),x=1,w=0;for(;x<h.length;){const b=i(h,x,f),R=b-w,j=o-_,L=Math.min(R,j);h[u].copyCellsFrom(h[x],w,_,L,!1),_+=L,_===o&&(u++,_=0),w+=L,w===b&&(x++,w=0),_===0&&u!==0&&h[u-1].getWidth(o-1)===2&&(h[u].copyCellsFrom(h[u-1],o-1,_++,1,!1),h[u-1].setCell(o-1,S))}h[u].replaceCells(_,o,S);let E=0;for(let b=h.length-1;b>0&&(b>u||h[b].getTrimmedLength()===0);b--)E++;E>0&&(y.push(g+h.length-E),y.push(E)),g+=h.length-1}return y},r.reflowLargerCreateNewLayout=function(c,f){const o=[];let p=0,S=f[p],y=0;for(let g=0;g<c.length;g++)if(S===g){const n=f[++p];c.onDeleteEmitter.fire({index:g-y,amount:n}),g+=n-1,y+=n,S=f[++p]}else o.push(g);return{layout:o,countRemoved:y}},r.reflowLargerApplyNewLayout=function(c,f){const o=[];for(let p=0;p<f.length;p++)o.push(c.get(f[p]));for(let p=0;p<o.length;p++)c.set(p,o[p]);c.length=f.length},r.reflowSmallerGetNewLineLengths=function(c,f,o){const p=[],S=c.map(((d,h)=>i(c,h,f))).reduce(((d,h)=>d+h));let y=0,g=0,n=0;for(;n<S;){if(S-n<o){p.push(S-n);break}y+=o;const d=i(c,g,f);y>d&&(y-=d,g++);const h=c[g].getWidth(y-1)===2;h&&y--;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),f=i(844),o=i(9092);class p extends f.Disposable{constructor(y,g){super(),this._optionsService=y,this._bufferService=g,this._onBufferActivate=this.register(new c.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new o.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,g){this._normal.resize(y,g),this._alt.resize(y,g),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}r.BufferSet=p},511:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const c=i(482),f=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(y){const g=new p;return g.setFromCharData(y),g}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let g=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)g=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const n=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const d=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(n-55296)+d-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:g=!0}else g=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;g&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}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),f=i(844);class o{get id(){return this._id}constructor(S){this.line=S,this.isDisposed=!1,this._disposables=[],this._id=o._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(S){return this._disposables.push(S),S}}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,f;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
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}\\`})(f||(r.C1_ESCAPED=f={}))},7399:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const c=i(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};r.evaluateKeyboardEvent=function(o,p,S,y){const g={type:0,cancel:!1,key:void 0},n=(o.shiftKey?1:0)|(o.altKey?2:0)|(o.ctrlKey?4:0)|(o.metaKey?8:0);switch(o.keyCode){case 0:o.key==="UIKeyInputUpArrow"?g.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A":o.key==="UIKeyInputLeftArrow"?g.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D":o.key==="UIKeyInputRightArrow"?g.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C":o.key==="UIKeyInputDownArrow"&&(g.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(o.altKey){g.key=c.C0.ESC+c.C0.DEL;break}g.key=c.C0.DEL;break;case 9:if(o.shiftKey){g.key=c.C0.ESC+"[Z";break}g.key=c.C0.HT,g.cancel=!0;break;case 13:g.key=o.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,g.cancel=!0;break;case 27:g.key=c.C0.ESC,o.altKey&&(g.key=c.C0.ESC+c.C0.ESC),g.cancel=!0;break;case 37:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"D",g.key===c.C0.ESC+"[1;3D"&&(g.key=c.C0.ESC+(S?"b":"[1;5D"))):g.key=p?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"C",g.key===c.C0.ESC+"[1;3C"&&(g.key=c.C0.ESC+(S?"f":"[1;5C"))):g.key=p?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"A",S||g.key!==c.C0.ESC+"[1;3A"||(g.key=c.C0.ESC+"[1;5A")):g.key=p?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(o.metaKey)break;n?(g.key=c.C0.ESC+"[1;"+(n+1)+"B",S||g.key!==c.C0.ESC+"[1;3B"||(g.key=c.C0.ESC+"[1;5B")):g.key=p?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:o.shiftKey||o.ctrlKey||(g.key=c.C0.ESC+"[2~");break;case 46:g.key=n?c.C0.ESC+"[3;"+(n+1)+"~":c.C0.ESC+"[3~";break;case 36:g.key=n?c.C0.ESC+"[1;"+(n+1)+"H":p?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:g.key=n?c.C0.ESC+"[1;"+(n+1)+"F":p?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:o.shiftKey?g.type=2:o.ctrlKey?g.key=c.C0.ESC+"[5;"+(n+1)+"~":g.key=c.C0.ESC+"[5~";break;case 34:o.shiftKey?g.type=3:o.ctrlKey?g.key=c.C0.ESC+"[6;"+(n+1)+"~":g.key=c.C0.ESC+"[6~";break;case 112:g.key=n?c.C0.ESC+"[1;"+(n+1)+"P":c.C0.ESC+"OP";break;case 113:g.key=n?c.C0.ESC+"[1;"+(n+1)+"Q":c.C0.ESC+"OQ";break;case 114:g.key=n?c.C0.ESC+"[1;"+(n+1)+"R":c.C0.ESC+"OR";break;case 115:g.key=n?c.C0.ESC+"[1;"+(n+1)+"S":c.C0.ESC+"OS";break;case 116:g.key=n?c.C0.ESC+"[15;"+(n+1)+"~":c.C0.ESC+"[15~";break;case 117:g.key=n?c.C0.ESC+"[17;"+(n+1)+"~":c.C0.ESC+"[17~";break;case 118:g.key=n?c.C0.ESC+"[18;"+(n+1)+"~":c.C0.ESC+"[18~";break;case 119:g.key=n?c.C0.ESC+"[19;"+(n+1)+"~":c.C0.ESC+"[19~";break;case 120:g.key=n?c.C0.ESC+"[20;"+(n+1)+"~":c.C0.ESC+"[20~";break;case 121:g.key=n?c.C0.ESC+"[21;"+(n+1)+"~":c.C0.ESC+"[21~";break;case 122:g.key=n?c.C0.ESC+"[23;"+(n+1)+"~":c.C0.ESC+"[23~";break;case 123:g.key=n?c.C0.ESC+"[24;"+(n+1)+"~":c.C0.ESC+"[24~";break;default:if(!o.ctrlKey||o.shiftKey||o.altKey||o.metaKey)if(S&&!y||!o.altKey||o.metaKey)!S||o.altKey||o.ctrlKey||o.shiftKey||!o.metaKey?o.key&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&o.keyCode>=48&&o.key.length===1?g.key=o.key:o.key&&o.ctrlKey&&(o.key==="_"&&(g.key=c.C0.US),o.key==="@"&&(g.key=c.C0.NUL)):o.keyCode===65&&(g.type=1);else{const d=f[o.keyCode],h=d?.[o.shiftKey?1:0];if(h)g.key=c.C0.ESC+h;else if(o.keyCode>=65&&o.keyCode<=90){const u=o.ctrlKey?o.keyCode-64:o.keyCode+32;let _=String.fromCharCode(u);o.shiftKey&&(_=_.toUpperCase()),g.key=c.C0.ESC+_}else if(o.keyCode===32)g.key=c.C0.ESC+(o.ctrlKey?c.C0.NUL:" ");else if(o.key==="Dead"&&o.code.startsWith("Key")){let u=o.code.slice(3,4);o.shiftKey||(u=u.toLowerCase()),g.key=c.C0.ESC+u,g.cancel=!0}}else o.keyCode>=65&&o.keyCode<=90?g.key=String.fromCharCode(o.keyCode-64):o.keyCode===32?g.key=c.C0.NUL:o.keyCode>=51&&o.keyCode<=55?g.key=String.fromCharCode(o.keyCode-51+27):o.keyCode===56?g.key=c.C0.DEL:o.keyCode===219?g.key=c.C0.ESC:o.keyCode===220?g.key=c.C0.FS:o.keyCode===221&&(g.key=c.C0.GS)}return g}},482:(C,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,f=i.length){let o="";for(let p=c;p<f;++p){let S=i[p];S>65535?(S-=65536,o+=String.fromCharCode(55296+(S>>10))+String.fromCharCode(S%1024+56320)):o+=String.fromCharCode(S)}return o},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,c){const f=i.length;if(!f)return 0;let o=0,p=0;if(this._interim){const S=i.charCodeAt(p++);56320<=S&&S<=57343?c[o++]=1024*(this._interim-55296)+S-56320+65536:(c[o++]=this._interim,c[o++]=S),this._interim=0}for(let S=p;S<f;++S){const y=i.charCodeAt(S);if(55296<=y&&y<=56319){if(++S>=f)return this._interim=y,o;const g=i.charCodeAt(S);56320<=g&&g<=57343?c[o++]=1024*(y-55296)+g-56320+65536:(c[o++]=y,c[o++]=g)}else y!==65279&&(c[o++]=y)}return o}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,c){const f=i.length;if(!f)return 0;let o,p,S,y,g=0,n=0,d=0;if(this.interim[0]){let _=!1,x=this.interim[0];x&=(224&x)==192?31:(240&x)==224?15:7;let w,E=0;for(;(w=63&this.interim[++E])&&E<4;)x<<=6,x|=w;const b=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,R=b-E;for(;d<R;){if(d>=f)return 0;if(w=i[d++],(192&w)!=128){d--,_=!0;break}this.interim[E++]=w,x<<=6,x|=63&w}_||(b===2?x<128?d--:c[g++]=x:b===3?x<2048||x>=55296&&x<=57343||x===65279||(c[g++]=x):x<65536||x>1114111||(c[g++]=x)),this.interim.fill(0)}const h=f-4;let u=d;for(;u<f;){for(;!(!(u<h)||128&(o=i[u])||128&(p=i[u+1])||128&(S=i[u+2])||128&(y=i[u+3]));)c[g++]=o,c[g++]=p,c[g++]=S,c[g++]=y,u+=4;if(o=i[u++],o<128)c[g++]=o;else if((224&o)==192){if(u>=f)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(n=(31&o)<<6|63&p,n<128){u--;continue}c[g++]=n}else if((240&o)==224){if(u>=f)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,g;if(S=i[u++],(192&S)!=128){u--;continue}if(n=(15&o)<<12|(63&p)<<6|63&S,n<2048||n>=55296&&n<=57343||n===65279)continue;c[g++]=n}else if((248&o)==240){if(u>=f)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,g;if(S=i[u++],(192&S)!=128){u--;continue}if(u>=f)return this.interim[0]=o,this.interim[1]=p,this.interim[2]=S,g;if(y=i[u++],(192&y)!=128){u--;continue}if(n=(7&o)<<18|(63&p)<<12|(63&S)<<6|63&y,n<65536||n>1114111)continue;c[g++]=n}}return g}}},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 f;r.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let o=0;o<i.length;++o)f.fill(0,i[o][0],i[o][1]+1)}}wcwidth(o){return o<32?0:o<127?1:o<65536?f[o]:(function(p,S){let y,g=0,n=S.length-1;if(p<S[0][0]||p>S[n][1])return!1;for(;n>=g;)if(y=g+n>>1,p>S[y][1])g=y+1;else{if(!(p<S[y][0]))return!0;n=y-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),f=i(844);class o extends f.Disposable{constructor(S){super(),this._action=S,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(S,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let g;for(this._isSyncWriting=!0;g=this._writeBuffer.shift();){this._action(g);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(S,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(y)}_innerWrite(S=0,y=!0){const g=S||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],d=this._action(n,y);if(d){const u=_=>Date.now()-g>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(g,_);return void d.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(u)}const h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-g>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}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 f(o,p){const S=o.toString(16),y=S.length<2?"0"+S:S;switch(p){case 4:return S[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}r.parseColor=function(o){if(!o)return;let p=o.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const S=i.exec(p);if(S){const y=S[1]?15:S[4]?255:S[7]?4095:65535;return[Math.round(parseInt(S[1]||S[4]||S[7]||S[10],16)/y*255),Math.round(parseInt(S[2]||S[5]||S[8]||S[11],16)/y*255),Math.round(parseInt(S[3]||S[6]||S[9]||S[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),c.exec(p)&&[3,6,9,12].includes(p.length))){const S=p.length/3,y=[0,0,0];for(let g=0;g<3;++g){const n=parseInt(p.slice(S*g,S*g+S),16);y[g]=S===1?n<<4:S===2?n:S===3?n>>4:n>>8}return y}},r.toRgbString=function(o,p=16){const[S,y,g]=o;return`rgb:${f(S,p)}/${f(y,p)}/${f(g,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),f=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(y,g){this._handlers[y]===void 0&&(this._handlers[y]=[]);const n=this._handlers[y];return n.push(g),{dispose:()=>{const d=n.indexOf(g);d!==-1&&n.splice(d,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(y,g){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(g);else this._handlerFb(this._ident,"HOOK",g)}put(y,g,n){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(y,g,n);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,g,n))}unhook(y,g=!0){if(this._active.length){let n=!1,d=this._active.length-1,h=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,n=g,h=this._stack.fallThrough,this._stack.paused=!1),!h&&n===!1){for(;d>=0&&(n=this._active[d].unhook(y),n!==!0);d--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,n;d--}for(;d>=0;d--)if(n=this._active[d].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const S=new f.Params;S.addParam(0),r.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=S,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():S,this._data="",this._hitLimit=!1}put(y,g,n){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,g,n),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let g=!1;if(this._hitLimit)g=!1;else if(y&&(g=this._handler(this._data,this._params),g instanceof Promise))return g.then((n=>(this._params=S,this._data="",this._hitLimit=!1,n)));return this._params=S,this._data="",this._hitLimit=!1,g}}},2015:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const c=i(844),f=i(8742),o=i(6242),p=i(6351);class S{constructor(d){this.table=new Uint8Array(d)}setDefault(d,h){this.table.fill(d<<4|h)}add(d,h,u,_){this.table[h<<8|d]=u<<4|_}addMany(d,h,u,_){for(let x=0;x<d.length;x++)this.table[h<<8|d[x]]=u<<4|_}}r.TransitionTable=S;const y=160;r.VT500_TRANSITION_TABLE=(function(){const n=new S(4095),d=Array.apply(null,Array(256)).map(((E,b)=>b)),h=(E,b)=>d.slice(E,b),u=h(32,127),_=h(0,24);_.push(25),_.push.apply(_,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(_,0,3,0),n.addMany(_,1,3,1),n.add(127,1,0,1),n.addMany(_,8,0,8),n.addMany(_,3,3,3),n.add(127,3,0,3),n.addMany(_,4,3,4),n.add(127,4,0,4),n.addMany(_,6,3,6),n.addMany(_,5,3,5),n.add(127,5,0,5),n.addMany(_,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(u,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(h(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(u,7,0,7),n.addMany(_,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(h(64,127),3,7,0),n.addMany(h(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(h(48,60),4,8,4),n.addMany(h(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(h(32,64),6,0,6),n.add(127,6,0,6),n.addMany(h(64,127),6,0,0),n.addMany(h(32,48),3,9,5),n.addMany(h(32,48),5,9,5),n.addMany(h(48,64),5,0,6),n.addMany(h(64,127),5,7,0),n.addMany(h(32,48),4,9,5),n.addMany(h(32,48),1,9,2),n.addMany(h(32,48),2,9,2),n.addMany(h(48,127),2,10,0),n.addMany(h(48,80),1,10,0),n.addMany(h(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(h(96,127),1,10,0),n.add(80,1,11,9),n.addMany(_,9,0,9),n.add(127,9,0,9),n.addMany(h(28,32),9,0,9),n.addMany(h(32,48),9,9,12),n.addMany(h(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(_,11,0,11),n.addMany(h(32,128),11,0,11),n.addMany(h(28,32),11,0,11),n.addMany(_,10,0,10),n.add(127,10,0,10),n.addMany(h(28,32),10,0,10),n.addMany(h(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(h(32,48),10,9,12),n.addMany(_,12,0,12),n.add(127,12,0,12),n.addMany(h(28,32),12,0,12),n.addMany(h(32,48),12,9,12),n.addMany(h(48,64),12,0,11),n.addMany(h(64,127),12,12,13),n.addMany(h(64,127),10,12,13),n.addMany(h(64,127),9,12,13),n.addMany(_,13,13,13),n.addMany(u,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(y,0,2,0),n.add(y,8,5,8),n.add(y,6,0,6),n.add(y,11,0,11),n.add(y,13,13,13),n})();class g extends c.Disposable{constructor(d=r.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(h,u,_)=>{},this._executeHandlerFb=h=>{},this._csiHandlerFb=(h,u)=>{},this._escHandlerFb=h=>{},this._errorHandlerFb=h=>h,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new o.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(d,h=[64,126]){let u=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=d.prefix.charCodeAt(0),u&&60>u||u>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let x=0;x<d.intermediates.length;++x){const w=d.intermediates.charCodeAt(x);if(32>w||w>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=w}}if(d.final.length!==1)throw new Error("final must be a single byte");const _=d.final.charCodeAt(0);if(h[0]>_||_>h[1])throw new Error(`final must be in range ${h[0]} .. ${h[1]}`);return u<<=8,u|=_,u}identToString(d){const h=[];for(;d;)h.push(String.fromCharCode(255&d)),d>>=8;return h.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,h){const u=this._identifier(d,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const _=this._escHandlers[u];return _.push(h),{dispose:()=>{const x=_.indexOf(h);x!==-1&&_.splice(x,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,h){this._executeHandlers[d.charCodeAt(0)]=h}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,h){const u=this._identifier(d);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const _=this._csiHandlers[u];return _.push(h),{dispose:()=>{const x=_.indexOf(h);x!==-1&&_.splice(x,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,h){return this._dcsParser.registerHandler(this._identifier(d),h)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,h){return this._oscParser.registerHandler(d,h)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(d,h,u,_,x){this._parseStack.state=d,this._parseStack.handlers=h,this._parseStack.handlerPos=u,this._parseStack.transition=_,this._parseStack.chunkPos=x}parse(d,h,u){let _,x=0,w=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const b=this._parseStack.handlers;let R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&R>-1){for(;R>=0&&(_=b[R](this._params),_!==!0);R--)if(_ instanceof Promise)return this._parseStack.handlerPos=R,_}this._parseStack.handlers=[];break;case 4:if(u===!1&&R>-1){for(;R>=0&&(_=b[R](),_!==!0);R--)if(_ instanceof Promise)return this._parseStack.handlerPos=R,_}this._parseStack.handlers=[];break;case 6:if(x=d[this._parseStack.chunkPos],_=this._dcsParser.unhook(x!==24&&x!==26,u),_)return _;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(x=d[this._parseStack.chunkPos],_=this._oscParser.end(x!==24&&x!==26,u),_)return _;x===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let b=E;b<h;++b){switch(x=d[b],w=this._transitions.table[this.currentState<<8|(x<160?x:y)],w>>4){case 2:for(let T=b+1;;++T){if(T>=h||(x=d[T])<32||x>126&&x<y){this._printHandler(d,b,T),b=T-1;break}if(++T>=h||(x=d[T])<32||x>126&&x<y){this._printHandler(d,b,T),b=T-1;break}if(++T>=h||(x=d[T])<32||x>126&&x<y){this._printHandler(d,b,T),b=T-1;break}if(++T>=h||(x=d[T])<32||x>126&&x<y){this._printHandler(d,b,T),b=T-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:b,code:x,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const R=this._csiHandlers[this._collect<<8|x];let j=R?R.length-1:-1;for(;j>=0&&(_=R[j](this._params),_!==!0);j--)if(_ instanceof Promise)return this._preserveStack(3,R,j,w,b),_;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(++b<h&&(x=d[b])>47&&x<60);b--;break;case 9:this._collect<<=8,this._collect|=x;break;case 10:const L=this._escHandlers[this._collect<<8|x];let M=L?L.length-1:-1;for(;M>=0&&(_=L[M](),_!==!0);M--)if(_ instanceof Promise)return this._preserveStack(4,L,M,w,b),_;M<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 T=b+1;;++T)if(T>=h||(x=d[T])===24||x===26||x===27||x>127&&x<y){this._dcsParser.put(d,b,T),b=T-1;break}break;case 14:if(_=this._dcsParser.unhook(x!==24&&x!==26),_)return this._preserveStack(6,[],0,w,b),_;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 T=b+1;;T++)if(T>=h||(x=d[T])<32||x>127&&x<y){this._oscParser.put(d,b,T),b=T-1;break}break;case 6:if(_=this._oscParser.end(x!==24&&x!==26),_)return this._preserveStack(5,[],0,w,b),_;x===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&w}}}r.EscapeSequenceParser=g},6242:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const c=i(5770),f=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,S){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(S),{dispose:()=>{const g=y.indexOf(S);g!==-1&&y.splice(g,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||o,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,S,y){if(this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].put(p,S,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,S,y))}start(){this.reset(),this._state=1}put(p,S,y){if(this._state!==3){if(this._state===1)for(;S<y;){const g=p[S++];if(g===59){this._state=2,this._start();break}if(g<48||57<g)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+g-48}this._state===2&&y-S>0&&this._put(p,S,y)}}end(p,S=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,g=this._active.length-1,n=!1;if(this._stack.paused&&(g=this._stack.loopPosition-1,y=S,n=this._stack.fallThrough,this._stack.paused=!1),!n&&y===!1){for(;g>=0&&(y=this._active[g].end(p),y!==!0);g--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!1,y;g--}for(;g>=0;g--)if(y=this._active[g].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!0,y}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,S,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,S,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let S=!1;if(this._hitLimit)S=!1;else if(p&&(S=this._handler(this._data),S instanceof Promise))return S.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,S}}},8742:(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 S=Array.isArray(o[0])?1:0;S<o.length;++S){const y=o[S];if(Array.isArray(y))for(let g=0;g<y.length;++g)p.addSubParam(y[g]);else p.addParam(y)}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 S=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-S>0&&o.push(Array.prototype.slice.call(this._subParams,S,y))}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,S=255&this._subParamsIdx[o];return S-p>0?this._subParams.subarray(p,S):null}getSubParamsAll(){const o={};for(let p=0;p<this.length;++p){const S=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-S>0&&(o[p]=this._subParams.slice(S,y))}return o}addDigit(o){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const S=this._digitIsSub?this._subParams:this.params,y=S[p-1];S[p-1]=~y?Math.min(10*y+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 f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===i){c=f;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),f=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 f.CellData}}},3785:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const c=i(511);r.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,o){if(!(f<0||f>=this._line.length))return o?(this._line.loadCell(f,o),o):this._line.loadCell(f,new c.CellData)}translateToString(f,o,p){return this._line.translateToString(f,o,p)}}},8285:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const c=i(8771),f=i(8460),o=i(844);class p extends o.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}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,(f=>c(f.toArray())))}addCsiHandler(i,c){return this.registerCsiHandler(i,c)}registerDcsHandler(i,c){return this._core.registerDcsHandler(i,((f,o)=>c(f,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,d,h,u){var _,x=arguments.length,w=x<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(x<3?_(w):x>3?_(d,h,w):_(d,h))||w);return x>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const o=i(8460),p=i(844),S=i(5295),y=i(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let g=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 S.BufferSet(n,this))}resize(n,d){this.cols=n,this.rows=d,this.buffers.resize(n,d),this._onResize.fire({cols:n,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,d=!1){const h=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===n.fg&&u.getBg(0)===n.bg||(u=h.getBlankLine(n,d),this._cachedBlankLine=u),u.isWrapped=d;const _=h.ybase+h.scrollTop,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-_+1;h.lines.shiftElements(_+1,w-1,-1),h.lines.set(x,u.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(n,d,h){const u=this.buffer;if(n<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else n+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const _=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+n,u.ybase),0),_!==u.ydisp&&(d||this._onScroll.fire(u.ydisp))}};r.BufferService=g=c([f(0,y.IOptionsService)],g)},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,_,x,w){var E,b=arguments.length,R=b<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,x,w);else for(var j=u.length-1;j>=0;j--)(E=u[j])&&(R=(b<3?E(R):b>3?E(_,x,R):E(_,x))||R);return b>3&&R&&Object.defineProperty(_,x,R),R},f=this&&this.__param||function(u,_){return function(x,w){_(x,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const o=i(2585),p=i(8460),S=i(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function g(u,_){let 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||_||(x|=3)),x}const n=String.fromCharCode,d={DEFAULT:u=>{const _=[g(u,!1)+32,u.col+32,u.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${n(_[0])}${n(_[1])}${n(_[2])}`},SGR:u=>{const _=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.col};${u.row}${_}`},SGR_PIXELS:u=>{const _=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.x};${u.y}${_}`}};let h=r.CoreMouseService=class extends S.Disposable{constructor(u,_){super(),this._bufferService=u,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const x of Object.keys(y))this.addProtocol(x,y[x]);for(const x of Object.keys(d))this.addEncoding(x,d[x]);this.reset()}addProtocol(u,_){this._protocols[u]=_}addEncoding(u,_){this._encodings[u]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const _=this._encodings[this._activeEncoding](u);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,_,x){if(x){if(u.x!==_.x||u.y!==_.y)return!1}else if(u.col!==_.col||u.row!==_.row)return!1;return u.button===_.button&&u.action===_.action&&u.ctrl===_.ctrl&&u.alt===_.alt&&u.shift===_.shift}};r.CoreMouseService=h=c([f(0,o.IBufferService),f(1,o.ICoreService)],h)},6975:function(C,r,i){var c=this&&this.__decorate||function(h,u,_,x){var w,E=arguments.length,b=E<3?u:x===null?x=Object.getOwnPropertyDescriptor(u,_):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,u,_,x);else for(var R=h.length-1;R>=0;R--)(w=h[R])&&(b=(E<3?w(b):E>3?w(u,_,b):w(u,_))||b);return E>3&&b&&Object.defineProperty(u,_,b),b},f=this&&this.__param||function(h,u){return function(_,x){u(_,x,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const o=i(1439),p=i(8460),S=i(844),y=i(2585),g=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=r.CoreService=class extends S.Disposable{constructor(h,u,_){super(),this._bufferService=h,this._logService=u,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}reset(){this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}triggerDataEvent(h,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`,(()=>h.split("").map((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=d=c([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],d)},9074:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const c=i(8055),f=i(8460),o=i(844),p=i(6106);let S=0,y=0;class g extends o.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((h=>h?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,o.toDisposable)((()=>this.reset())))}registerDecoration(h){if(h.marker.isDisposed)return;const u=new n(h);if(u){const _=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),_.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const h of this._decorations.values())h.dispose();this._decorations.clear()}*getDecorationsAtCell(h,u,_){var x,w,E;let b=0,R=0;for(const j of this._decorations.getKeyIterator(u))b=(x=j.options.x)!==null&&x!==void 0?x:0,R=b+((w=j.options.width)!==null&&w!==void 0?w:1),h>=b&&h<R&&(!_||((E=j.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&(yield j)}forEachDecorationAtCell(h,u,_,x){this._decorations.forEachByKey(u,(w=>{var E,b,R;S=(E=w.options.x)!==null&&E!==void 0?E:0,y=S+((b=w.options.width)!==null&&b!==void 0?b:1),h>=S&&h<y&&(!_||((R=w.options.layer)!==null&&R!==void 0?R:"bottom")===_)&&x(w)}))}}r.DecorationService=g;class n extends o.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(h){super(),this.options=h,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=h.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const c=i(2585),f=i(8343);class o{constructor(...S){this._entries=new Map;for(const[y,g]of S)this.set(y,g)}set(S,y){const g=this._entries.get(S);return this._entries.set(S,y),g}forEach(S){for(const[y,g]of this._entries.entries())S(y,g)}has(S){return this._entries.has(S)}get(S){return this._entries.get(S)}}r.ServiceCollection=o,r.InstantiationService=class{constructor(){this._services=new o,this._services.set(c.IInstantiationService,this)}setService(p,S){this._services.set(p,S)}getService(p){return this._services.get(p)}createInstance(p,...S){const y=(0,f.getServiceDependencies)(p).sort(((d,h)=>d.index-h.index)),g=[];for(const d of y){const h=this._services.get(d.id);if(!h)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${d.id}.`);g.push(h)}const n=y.length>0?y[0].index:S.length;if(S.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${S.length} static arguments`);return new p(...S,...g)}}},7866:function(C,r,i){var c=this&&this.__decorate||function(n,d,h,u){var _,x=arguments.length,w=x<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(x<3?_(w):x>3?_(d,h,w):_(d,h))||w);return x>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const o=i(844),p=i(2585),S={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,g=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()))),y=this}_updateLogLevel(){this._logLevel=S[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let d=0;d<n.length;d++)typeof n[d]=="function"&&(n[d]=n[d]())}_log(n,d,h){this._evalLazyOptionalParams(h),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...h)}trace(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,d)}debug(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,d)}info(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.INFO&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,n,d)}warn(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.WARN&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,n,d)}error(n,...d){var h,u;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,n,d)}};r.LogService=g=c([f(0,p.IOptionsService)],g),r.setTraceLogger=function(n){y=n},r.traceCall=function(n,d,h){if(typeof h.value!="function")throw new Error("not supported");const u=h.value;h.value=function(..._){if(y.logLevel!==p.LogLevelEnum.TRACE)return u.apply(this,_);y.trace(`GlyphRenderer#${u.name}(${_.map((w=>JSON.stringify(w))).join(", ")})`);const x=u.apply(this,_);return y.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),f=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 S extends f.Disposable{constructor(g){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},r.DEFAULT_OPTIONS);for(const d in g)if(d in n)try{const h=g[d];n[d]=this._sanitizeAndValidateOption(d,h)}catch(h){console.error(h)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(g,n){return this.onOptionChange((d=>{d===g&&n(this.rawOptions[g])}))}onMultipleOptionChange(g,n){return this.onOptionChange((d=>{g.indexOf(d)!==-1&&n()}))}_setupOptions(){const g=d=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},n=(d,h)=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);h=this._sanitizeAndValidateOption(d,h),this.rawOptions[d]!==h&&(this.rawOptions[d]=h,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const h={get:g.bind(this,d),set:n.bind(this,d)};Object.defineProperty(this.options,d,h)}}_sanitizeAndValidateOption(g,n){switch(g){case"cursorStyle":if(n||(n=r.DEFAULT_OPTIONS[g]),!(function(d){return d==="block"||d==="underline"||d==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${g}`);break;case"wordSeparator":n||(n=r.DEFAULT_OPTIONS[g]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:r.DEFAULT_OPTIONS[g];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${g} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${g} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${g} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${g} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}r.OptionsService=S},2660:function(C,r,i){var c=this&&this.__decorate||function(S,y,g,n){var d,h=arguments.length,u=h<3?y:n===null?n=Object.getOwnPropertyDescriptor(y,g):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(S,y,g,n);else for(var _=S.length-1;_>=0;_--)(d=S[_])&&(u=(h<3?d(u):h>3?d(y,g,u):d(y,g))||u);return h>3&&u&&Object.defineProperty(y,g,u),u},f=this&&this.__param||function(S,y){return function(g,n){y(g,n,S)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const o=i(2585);let p=r.OscLinkService=class{constructor(S){this._bufferService=S,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(S){const y=this._bufferService.buffer;if(S.id===void 0){const _=y.addMarker(y.ybase+y.y),x={data:S,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(x,_))),this._dataByLinkId.set(x.id,x),x.id}const g=S,n=this._getEntryIdKey(g),d=this._entriesWithId.get(n);if(d)return this.addLineToLink(d.id,y.ybase+y.y),d.id;const h=y.addMarker(y.ybase+y.y),u={id:this._nextId++,key:this._getEntryIdKey(g),data:g,lines:[h]};return h.onDispose((()=>this._removeMarkerFromLink(u,h))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(S,y){const g=this._dataByLinkId.get(S);if(g&&g.lines.every((n=>n.line!==y))){const n=this._bufferService.buffer.addMarker(y);g.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(g,n)))}}getLinkData(S){var y;return(y=this._dataByLinkId.get(S))===null||y===void 0?void 0:y.data}_getEntryIdKey(S){return`${S.id};;${S.uri}`}_removeMarkerFromLink(S,y){const g=S.lines.indexOf(y);g!==-1&&(S.lines.splice(g,1),S.lines.length===0&&(S.data.id!==void 0&&this._entriesWithId.delete(S.key),this._dataByLinkId.delete(S.id)))}};r.OscLinkService=p=c([f(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(f){return f[c]||[]},r.createDecorator=function(f){if(r.serviceRegistry.has(f))return r.serviceRegistry.get(f);const o=function(p,S,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(g,n,d){n[i]===n?n[c].push({id:g,index:d}):(n[c]=[{id:g,index:d}],n[i]=n)})(o,p,y)};return o.toString=()=>f,r.serviceRegistry.set(f,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 f;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"})(f||(r.LogLevelEnum=f={})),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),f=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 f.UnicodeV6;this.register(o),this._active=o.version,this._activeProvider=o}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(o){if(!this._providers[o])throw new Error(`unknown Unicode version "${o}"`);this._active=o,this._activeProvider=this._providers[o],this._onChange.fire(o)}register(o){this._providers[o.version]=o}wcwidth(o){return this._activeProvider.wcwidth(o)}getStringCellWidth(o){let p=0;const S=o.length;for(let y=0;y<S;++y){let g=o.charCodeAt(y);if(55296<=g&&g<=56319){if(++y>=S)return p+this.wcwidth(g);const n=o.charCodeAt(y);56320<=n&&n<=57343?g=1024*(g-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(g)}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 v={};return(()=>{var C=v;Object.defineProperty(C,"__esModule",{value:!0}),C.Terminal=void 0;const r=m(9042),i=m(3236),c=m(844),f=m(5741),o=m(8285),p=m(7975),S=m(7090),y=["cols","rows"];class g extends c.Disposable{constructor(d){super(),this._core=this.register(new i.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const h=_=>this._core.options[_],u=(_,x)=>{this._checkReadonlyOptions(_),this._core.options[_]=x};for(const _ in this._core.options){const x={get:h.bind(this,_),set:u.bind(this,_)};Object.defineProperty(this._publicOptions,_,x)}}_checkReadonlyOptions(d){if(y.includes(d))throw new Error(`Option "${d}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new S.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new o.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let h="none";switch(this._core.coreMouseService.activeProtocol){case"X10":h="x10";break;case"VT200":h="vt200";break;case"DRAG":h="drag";break;case"ANY":h="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:h,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const h in d)this._publicOptions[h]=d[h]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,h){this._verifyIntegers(d,h),this._core.resize(d,h)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var h,u,_;return this._checkProposedApi(),this._verifyPositiveIntegers((h=d.x)!==null&&h!==void 0?h:0,(u=d.width)!==null&&u!==void 0?u:0,(_=d.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,h,u){this._verifyIntegers(d,h,u),this._core.select(d,h,u)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,h){this._verifyIntegers(d,h),this._core.selectLines(d,h)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,h){this._core.write(d,h)}writeln(d,h){this._core.write(d),this._core.write(`\r
19
- `,h)}paste(d){this._core.paste(d)}refresh(d,h){this._verifyIntegers(d,h),this._core.refresh(d,h)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return r}_verifyIntegers(...d){for(const h of d)if(h===1/0||isNaN(h)||h%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const h of d)if(h&&(h===1/0||isNaN(h)||h%1!=0||h<0))throw new Error("This API only accepts positive integers")}}C.Terminal=g})(),v})()))})(cr)),cr.exports}var Sh=xh();var yh=2,Ch=1,wh=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),m=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),C={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},r=C.top+C.bottom,i=C.right+C.left,c=l-r,f=m-i-t;return{cols:Math.max(yh,Math.floor(f/e.css.cell.width)),rows:Math.max(Ch,Math.floor(c/e.css.cell.height))}}};function Eh(e={}){const{cwd:t,cols:s,rows:l,onOutput:m,onExit:v}=e,[C,r]=k.useState(null),[i,c]=k.useState(()=>kt.isConnected()),[f,o]=k.useState(!1),[p,S]=k.useState(!1),[y,g]=k.useState(!1),n=k.useRef({onOutput:m,onExit:v});n.current={onOutput:m,onExit:v};const d=k.useRef(null);d.current=C,k.useEffect(()=>{if(!C)return;const w=kt.getSocket(),E=()=>{c(!0),o(!1),r(null),g(!0)},b=()=>{c(!1),o(!1)},R=T=>{T.terminalId===C&&n.current.onOutput?.(T.data)},j=T=>{T.terminalId===C&&(o(!1),n.current.onExit?.(T.exitCode),r(null))},L=T=>{T.terminalId===C&&o(!0)},M=T=>{T.terminalId===C&&o(!1)};return w.on("connect",E),w.on("disconnect",b),w.on(Ve.TERMINAL_STDOUT,R),w.on(Ve.TERMINAL_EXIT,j),w.on(Ve.TERMINAL_SUBSCRIBED,L),w.on(Ve.TERMINAL_UNSUBSCRIBED,M),c(w.connected),w.connected&&w.emit(Pt.SUBSCRIBE,{topic:"terminal",id:C},T=>{T.success&&o(!0)}),()=>{w.off("connect",E),w.off("disconnect",b),w.off(Ve.TERMINAL_STDOUT,R),w.off(Ve.TERMINAL_EXIT,j),w.off(Ve.TERMINAL_SUBSCRIBED,L),w.off(Ve.TERMINAL_UNSUBSCRIBED,M),w.emit(Pt.UNSUBSCRIBE,{topic:"terminal",id:C})}},[C]);const h=k.useCallback(async()=>{const w=kt.getSocket();if(!w.connected)return null;S(!0);try{const E=await ue.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:l});return r(E.terminalId),g(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{S(!1)}},[t,s,l]),u=k.useCallback(async()=>{const w=d.current;if(w){try{await ue.delete(`/terminals/${w}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}r(null),o(!1)}},[]),_=k.useCallback(w=>{const E=d.current;if(!E)return;kt.getSocket().emit(Pt.TERMINAL_INPUT,{terminalId:E,data:w})},[]),x=k.useCallback((w,E)=>{const b=d.current;if(!b)return;kt.getSocket().emit(Pt.TERMINAL_RESIZE,{terminalId:b,cols:w,rows:E})},[]);return k.useEffect(()=>()=>{const w=d.current;w&&ue.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:C,isConnected:i,isAttached:f,isCreating:p,needsRecreate:y,create:h,destroy:u,sendInput:_,resize:x}}const kh={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"},Rh=J.memo(function({cwd:t,onExit:s,onReady:l}){const m=k.useRef(null),v=k.useRef(null),C=k.useRef(null),r=k.useRef(!1),{terminalId:i,isAttached:c,needsRecreate:f,create:o,sendInput:p,resize:S}=Eh({cwd:t,onOutput:k.useCallback(y=>{v.current?.write(y)},[]),onExit:k.useCallback(y=>{v.current?.writeln(`\r
19
+ `,h)}paste(d){this._core.paste(d)}refresh(d,h){this._verifyIntegers(d,h),this._core.refresh(d,h)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return r}_verifyIntegers(...d){for(const h of d)if(h===1/0||isNaN(h)||h%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const h of d)if(h&&(h===1/0||isNaN(h)||h%1!=0||h<0))throw new Error("This API only accepts positive integers")}}C.Terminal=g})(),v})()))})(cr)),cr.exports}var Sh=xh();var yh=2,Ch=1,wh=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),m=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),C={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},r=C.top+C.bottom,i=C.right+C.left,c=l-r,f=m-i-t;return{cols:Math.max(yh,Math.floor(f/e.css.cell.width)),rows:Math.max(Ch,Math.floor(c/e.css.cell.height))}}};function Eh(e={}){const{cwd:t,cols:s,rows:l,onOutput:m,onExit:v}=e,[C,r]=k.useState(null),[i,c]=k.useState(()=>kt.isConnected()),[f,o]=k.useState(!1),[p,S]=k.useState(!1),[y,g]=k.useState(!1),n=k.useRef({onOutput:m,onExit:v});n.current={onOutput:m,onExit:v};const d=k.useRef(null);d.current=C,k.useEffect(()=>{if(!C)return;const w=kt.getSocket(),E=()=>{c(!0),o(!1),r(null),g(!0)},b=()=>{c(!1),o(!1)},R=T=>{T.terminalId===C&&n.current.onOutput?.(T.data)},j=T=>{T.terminalId===C&&(o(!1),n.current.onExit?.(T.exitCode),r(null))},L=T=>{T.terminalId===C&&o(!0)},M=T=>{T.terminalId===C&&o(!1)};return w.on("connect",E),w.on("disconnect",b),w.on(Ve.TERMINAL_STDOUT,R),w.on(Ve.TERMINAL_EXIT,j),w.on(Ve.TERMINAL_SUBSCRIBED,L),w.on(Ve.TERMINAL_UNSUBSCRIBED,M),c(w.connected),w.connected&&w.emit(Ht.SUBSCRIBE,{topic:"terminal",id:C},T=>{T.success&&o(!0)}),()=>{w.off("connect",E),w.off("disconnect",b),w.off(Ve.TERMINAL_STDOUT,R),w.off(Ve.TERMINAL_EXIT,j),w.off(Ve.TERMINAL_SUBSCRIBED,L),w.off(Ve.TERMINAL_UNSUBSCRIBED,M),w.emit(Ht.UNSUBSCRIBE,{topic:"terminal",id:C})}},[C]);const h=k.useCallback(async()=>{const w=kt.getSocket();if(!w.connected)return null;S(!0);try{const E=await ue.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:l});return r(E.terminalId),g(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{S(!1)}},[t,s,l]),u=k.useCallback(async()=>{const w=d.current;if(w){try{await ue.delete(`/terminals/${w}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}r(null),o(!1)}},[]),_=k.useCallback(w=>{const E=d.current;if(!E)return;kt.getSocket().emit(Ht.TERMINAL_INPUT,{terminalId:E,data:w})},[]),x=k.useCallback((w,E)=>{const b=d.current;if(!b)return;kt.getSocket().emit(Ht.TERMINAL_RESIZE,{terminalId:b,cols:w,rows:E})},[]);return k.useEffect(()=>()=>{const w=d.current;w&&ue.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:C,isConnected:i,isAttached:f,isCreating:p,needsRecreate:y,create:h,destroy:u,sendInput:_,resize:x}}const kh={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"},Rh=J.memo(function({cwd:t,onExit:s,onReady:l}){const m=k.useRef(null),v=k.useRef(null),C=k.useRef(null),r=k.useRef(!1),{terminalId:i,isAttached:c,needsRecreate:f,create:o,sendInput:p,resize:S}=Eh({cwd:t,onOutput:k.useCallback(y=>{v.current?.write(y)},[]),onExit:k.useCallback(y=>{v.current?.writeln(`\r
20
20
  \x1B[90m[Process exited with code ${y}]\x1B[0m`),s?.(y)},[s])});return k.useEffect(()=>{if(!f)return;const y=v.current;y&&y.writeln(`\r
21
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),o()},[f,o]),k.useLayoutEffect(()=>{if(!m.current)return;const y=new Sh.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:kh,scrollback:5e3,convertEol:!0}),g=new wh;y.loadAddon(g),y.open(m.current);const n=(d=0)=>{if(!(d>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>n(d+1),50);return}g.fit(),S(y.cols,y.rows)}catch{setTimeout(()=>n(d+1),50)}};return n(0),setTimeout(()=>n(1),100),v.current=y,C.current=g,()=>{y.dispose(),v.current=null,C.current=null}},[S]),k.useEffect(()=>{r.current||(r.current=!0,o())},[o]),k.useEffect(()=>{const y=v.current;if(!y||!c)return;const g=y.onData(n=>{p(n)});return()=>g.dispose()},[p,c]),k.useEffect(()=>{c&&l?.({sendInput:p})},[c,p,l]),k.useEffect(()=>{if(!m.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const g=C.current,n=v.current,d=m.current;g&&n&&d&&d.clientWidth>0&&d.clientHeight>0&&(g.fit(),S(n.cols,n.rows))}catch{}})});return y.observe(m.current),()=>y.disconnect()},[S]),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"})]})}),Dh=J.memo(function({commands:t,onSelect:s}){const{t:l}=he(),[m,v]=k.useState(!1),C=k.useRef(null),r=k.useRef(null);return k.useEffect(()=>{if(!m)return;const i=c=>{C.current&&!C.current.contains(c.target)&&r.current&&!r.current.contains(c.target)&&v(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[m]),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:r,onClick:()=>v(!m),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${m?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[a.jsx(Cl,{size:12}),a.jsx("span",{children:l("快捷命令")}),a.jsx(Ct,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&a.jsx("div",{ref:C,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:a.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((i,c)=>a.jsxs("button",{onClick:()=>{s(i.command),v(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[a.jsx(Ot,{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:i.name}),a.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},c))})})]})]})});let hr=0;function ji(){return hr+=1,{id:`shell-${hr}`,order:hr}}const Ah=J.memo(function({cwd:t,quickCommands:s=[]}){const{t:l}=he(),[m,v]=k.useState(()=>[ji()]),[C,r]=k.useState(()=>m[0].id),i=k.useRef(new Map),c=k.useCallback(()=>{const y=ji();v(g=>[...g,y]),r(y.id)},[]),f=k.useCallback((y,g)=>{g.stopPropagation(),i.current.delete(y),v(n=>{const d=n.filter(h=>h.id!==y);return y===C&&d.length>0&&r(d[d.length-1].id),d})},[C]),o=k.useCallback(y=>{i.current.delete(y),v(g=>{const n=g.filter(d=>d.id!==y);return y===C&&n.length>0&&r(n[n.length-1].id),n})},[C]),p=k.useCallback((y,g)=>{i.current.set(y,g.sendInput)},[]),S=k.useCallback(y=>{const g=i.current.get(C);g&&g(y+"\r")},[C]);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:m.map(y=>a.jsxs("button",{onClick:()=>r(y.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",y.id===C?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[a.jsx(Es,{size:11,className:"shrink-0"}),a.jsx("span",{children:l("Shell {count}",{count:y.order})}),m.length>1&&a.jsx("span",{onClick:g=>f(y.id,g),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a.jsx(Fs,{size:10})})]},y.id))}),a.jsx("button",{onClick:c,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:l("New Terminal"),children:a.jsx(xr,{size:14})}),s.length>0&&a.jsx(Dh,{commands:s,onSelect:S})]}),a.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.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(Es,{size:28}),a.jsx("span",{className:"text-xs",children:l("No terminals open")}),a.jsx("button",{onClick:c,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:l("New Terminal")})]})}):m.map(y=>a.jsx("div",{className:"absolute inset-0",style:{display:y.id===C?"block":"none"},children:a.jsx(Rh,{cwd:t,onExit:()=>o(y.id),onReady:g=>p(y.id,g)})},y.id))})]})});function Ti(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 jh(e){if(Array.isArray(e))return e}function Th(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 Lh(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,m,v,C,r=[],i=!0,c=!1;try{if(v=(s=s.call(e)).next,t!==0)for(;!(i=(l=v.call(s)).done)&&(r.push(l.value),r.length!==t);i=!0);}catch(f){c=!0,m=f}finally{try{if(!i&&s.return!=null&&(C=s.return(),Object(C)!==C))return}finally{if(c)throw m}}return r}}function Mh(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
21
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),o()},[f,o]),k.useLayoutEffect(()=>{if(!m.current)return;const y=new Sh.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:kh,scrollback:5e3,convertEol:!0}),g=new wh;y.loadAddon(g),y.open(m.current);const n=(d=0)=>{if(!(d>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>n(d+1),50);return}g.fit(),S(y.cols,y.rows)}catch{setTimeout(()=>n(d+1),50)}};return n(0),setTimeout(()=>n(1),100),v.current=y,C.current=g,()=>{y.dispose(),v.current=null,C.current=null}},[S]),k.useEffect(()=>{r.current||(r.current=!0,o())},[o]),k.useEffect(()=>{const y=v.current;if(!y||!c)return;const g=y.onData(n=>{p(n)});return()=>g.dispose()},[p,c]),k.useEffect(()=>{c&&l?.({sendInput:p})},[c,p,l]),k.useEffect(()=>{if(!m.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const g=C.current,n=v.current,d=m.current;g&&n&&d&&d.clientWidth>0&&d.clientHeight>0&&(g.fit(),S(n.cols,n.rows))}catch{}})});return y.observe(m.current),()=>y.disconnect()},[S]),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"})]})}),Dh=J.memo(function({commands:t,onSelect:s}){const{t:l}=he(),[m,v]=k.useState(!1),C=k.useRef(null),r=k.useRef(null);return k.useEffect(()=>{if(!m)return;const i=c=>{C.current&&!C.current.contains(c.target)&&r.current&&!r.current.contains(c.target)&&v(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[m]),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:r,onClick:()=>v(!m),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${m?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[a.jsx(Cl,{size:12}),a.jsx("span",{children:l("快捷命令")}),a.jsx(Ct,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&a.jsx("div",{ref:C,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:a.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((i,c)=>a.jsxs("button",{onClick:()=>{s(i.command),v(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[a.jsx(Pt,{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:i.name}),a.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},c))})})]})]})});let hr=0;function ji(){return hr+=1,{id:`shell-${hr}`,order:hr}}const Ah=J.memo(function({cwd:t,quickCommands:s=[]}){const{t:l}=he(),[m,v]=k.useState(()=>[ji()]),[C,r]=k.useState(()=>m[0].id),i=k.useRef(new Map),c=k.useCallback(()=>{const y=ji();v(g=>[...g,y]),r(y.id)},[]),f=k.useCallback((y,g)=>{g.stopPropagation(),i.current.delete(y),v(n=>{const d=n.filter(h=>h.id!==y);return y===C&&d.length>0&&r(d[d.length-1].id),d})},[C]),o=k.useCallback(y=>{i.current.delete(y),v(g=>{const n=g.filter(d=>d.id!==y);return y===C&&n.length>0&&r(n[n.length-1].id),n})},[C]),p=k.useCallback((y,g)=>{i.current.set(y,g.sendInput)},[]),S=k.useCallback(y=>{const g=i.current.get(C);g&&g(y+"\r")},[C]);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:m.map(y=>a.jsxs("button",{onClick:()=>r(y.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",y.id===C?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[a.jsx(Es,{size:11,className:"shrink-0"}),a.jsx("span",{children:l("Shell {count}",{count:y.order})}),m.length>1&&a.jsx("span",{onClick:g=>f(y.id,g),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a.jsx(Fs,{size:10})})]},y.id))}),a.jsx("button",{onClick:c,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:l("New Terminal"),children:a.jsx(xr,{size:14})}),s.length>0&&a.jsx(Dh,{commands:s,onSelect:S})]}),a.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.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(Es,{size:28}),a.jsx("span",{className:"text-xs",children:l("No terminals open")}),a.jsx("button",{onClick:c,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:l("New Terminal")})]})}):m.map(y=>a.jsx("div",{className:"absolute inset-0",style:{display:y.id===C?"block":"none"},children:a.jsx(Rh,{cwd:t,onExit:()=>o(y.id),onReady:g=>p(y.id,g)})},y.id))})]})});function Ti(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 jh(e){if(Array.isArray(e))return e}function Th(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 Lh(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,m,v,C,r=[],i=!0,c=!1;try{if(v=(s=s.call(e)).next,t!==0)for(;!(i=(l=v.call(s)).done)&&(r.push(l.value),r.length!==t);i=!0);}catch(f){c=!0,m=f}finally{try{if(!i&&s.return!=null&&(C=s.return(),Object(C)!==C))return}finally{if(c)throw m}}return r}}function Mh(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
22
22
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Li(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 Mi(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Li(Object(s),!0).forEach(function(l){Th(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Li(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function Nh(e,t){if(e==null)return{};var s,l,m=Ph(e,t);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(l=0;l<v.length;l++)s=v[l],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(m[s]=e[s])}return m}function Ph(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 Oh(e,t){return jh(e)||Lh(e,t)||Fh(e,t)||Mh()}function Bh(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=Bh(e,"string");return typeof t=="symbol"?t:t+""}function Fh(e,t){if(e){if(typeof e=="string")return Ti(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)?Ti(e,t):void 0}}function Hh(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Ni(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?Ni(Object(s),!0).forEach(function(l){Hh(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ni(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function zh(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(l){return t.reduceRight(function(m,v){return v(m)},l)}}function Qt(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),v=0;v<l;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function Ls(e){return{}.toString.call(e).includes("Object")}function Wh(e){return!Object.keys(e).length}function ls(e){return typeof e=="function"}function $h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Uh(e,t){return Ls(t)||Dt("changeType"),Object.keys(t).some(function(s){return!$h(e,s)})&&Dt("changeField"),t}function qh(e){ls(e)||Dt("selectorType")}function Kh(e){ls(e)||Ls(e)||Dt("handlerType"),Ls(e)&&Object.values(e).some(function(t){return!ls(t)})&&Dt("handlersType")}function Xh(e){e||Dt("initialIsRequired"),Ls(e)||Dt("initialType"),Wh(e)&&Dt("initialContent")}function Yh(e,t){throw new Error(e[t]||e.default)}var Vh={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"},Dt=Qt(Yh)(Vh),_s={changes:Uh,selector:qh,handler:Kh,initial:Xh};function Gh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_s.initial(e),_s.handler(t);var s={current:e},l=Qt(Jh)(s,t),m=Qt(Zh)(s),v=Qt(_s.changes)(e),C=Qt(Qh)(s);function r(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return _s.selector(c),c(s.current)}function i(c){zh(l,m,v,C)(c)}return[r,i]}function Qh(e,t){return ls(t)?t(e.current):t}function Zh(e,t){return e.current=Pi(Pi({},e.current),t),t}function Jh(e,t,s){return ls(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 eu={create:Gh},tu={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function su(e){return function t(){for(var s=this,l=arguments.length,m=new Array(l),v=0;v<l;v++)m[v]=arguments[v];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function ru(e){return{}.toString.call(e).includes("Object")}function iu(e){return e||Oi("configIsRequired"),ru(e)||Oi("configType"),e.urls?(nu(),{paths:{vs:e.urls.monacoBase}}):e}function nu(){console.warn(Zn.deprecation)}function ou(e,t){throw new Error(e[t]||e.default)}var Zn={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
23
  You are using deprecated way of configuration.
24
24
 
@@ -28,7 +28,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
28
28
  monaco.config({ paths: { vs: '...' } })
29
29
 
30
30
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
31
- `},Oi=su(ou)(Zn),au={config:iu},lu=function(){for(var t=arguments.length,s=new Array(t),l=0;l<t;l++)s[l]=arguments[l];return function(m){return s.reduceRight(function(v,C){return C(v)},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]))}),Mi(Mi({},e),t)}var cu={type:"cancelation",msg:"operation is manually canceled"};function ur(e){var t=!1,s=new Promise(function(l,m){e.then(function(v){return t?m(cu):l(v)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var hu=["monaco"],uu=eu.create({config:tu,isInitialized:!1,resolve:null,reject:null,monaco:null}),eo=Oh(uu,2),fs=eo[0],Ys=eo[1];function du(e){var t=au.config(e),s=t.monaco,l=Nh(t,hu);Ys(function(m){return{config:Jn(m.config,l),monaco:s}})}function fu(){var e=fs(function(t){var s=t.monaco,l=t.isInitialized,m=t.resolve;return{monaco:s,isInitialized:l,resolve:m}});if(!e.isInitialized){if(Ys({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ur(dr);if(window.monaco&&window.monaco.editor)return to(window.monaco),e.resolve(window.monaco),ur(dr);lu(mu,vu)(gu)}return ur(dr)}function mu(e){return document.body.appendChild(e)}function pu(e){var t=document.createElement("script");return e&&(t.src=e),t}function vu(e){var t=fs(function(l){var m=l.config,v=l.reject;return{config:m,reject:v}}),s=pu("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function gu(){var e=fs(function(s){var l=s.config,m=s.resolve,v=s.reject;return{config:l,resolve:m,reject:v}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var l=s.m||s;to(l),e.resolve(l)},function(s){e.reject(s)})}function to(e){fs().monaco||Ys({monaco:e})}function _u(){return fs(function(e){var t=e.monaco;return t})}var dr=new Promise(function(e,t){return Ys({resolve:e,reject:t})}),so={config:du,init:fu,__getMonacoInstance:_u},bu={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},fr=bu,xu={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Su=xu;function yu({children:e}){return J.createElement("div",{style:Su.container},e)}var Cu=yu,wu=Cu;function Eu({width:e,height:t,isEditorReady:s,loading:l,_ref:m,className:v,wrapperProps:C}){return J.createElement("section",{style:{...fr.wrapper,width:e,height:t},...C},!s&&J.createElement(wu,null,l),J.createElement("div",{ref:m,style:{...fr.fullWidth,...!s&&fr.hide},className:v}))}var ku=Eu,ro=k.memo(ku);function Ru(e){k.useEffect(e,[])}var io=Ru;function Du(e,t,s=!0){let l=k.useRef(!0);k.useEffect(l.current||!s?()=>{l.current=!1}:e,t)}var nt=Du;function ts(){}function zt(e,t,s,l){return Au(e,l)||ju(e,t,s,l)}function Au(e,t){return e.editor.getModel(no(e,t))}function ju(e,t,s,l){return e.editor.createModel(t,s,l?no(e,l):void 0)}function no(e,t){return e.Uri.parse(t)}function Tu({original:e,modified:t,language:s,originalLanguage:l,modifiedLanguage:m,originalModelPath:v,modifiedModelPath:C,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:i=!1,theme:c="light",loading:f="Loading...",options:o={},height:p="100%",width:S="100%",className:y,wrapperProps:g={},beforeMount:n=ts,onMount:d=ts}){let[h,u]=k.useState(!1),[_,x]=k.useState(!0),w=k.useRef(null),E=k.useRef(null),b=k.useRef(null),R=k.useRef(d),j=k.useRef(n),L=k.useRef(!1);io(()=>{let I=so.init();return I.then(H=>(E.current=H)&&x(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>w.current?B():I.cancel()}),nt(()=>{if(w.current&&E.current){let I=w.current.getOriginalEditor(),H=zt(E.current,e||"",l||s||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],h),nt(()=>{if(w.current&&E.current){let I=w.current.getModifiedEditor(),H=zt(E.current,t||"",m||s||"text",C||"");H!==I.getModel()&&I.setModel(H)}},[C],h),nt(()=>{let I=w.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(t||""):t!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[t],h),nt(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],h),nt(()=>{let{original:I,modified:H}=w.current.getModel();E.current.editor.setModelLanguage(I,l||s||"text"),E.current.editor.setModelLanguage(H,m||s||"text")},[s,l,m],h),nt(()=>{E.current?.editor.setTheme(c)},[c],h),nt(()=>{w.current?.updateOptions(o)},[o],h);let M=k.useCallback(()=>{if(!E.current)return;j.current(E.current);let I=zt(E.current,e||"",l||s||"text",v||""),H=zt(E.current,t||"",m||s||"text",C||"");w.current?.setModel({original:I,modified:H})},[s,t,m,e,l,v,C]),T=k.useCallback(()=>{!L.current&&b.current&&(w.current=E.current.editor.createDiffEditor(b.current,{automaticLayout:!0,...o}),M(),E.current?.editor.setTheme(c),u(!0),L.current=!0)},[o,c,M]);k.useEffect(()=>{h&&R.current(w.current,E.current)},[h]),k.useEffect(()=>{!_&&!h&&T()},[_,h,T]);function B(){let I=w.current?.getModel();r||I?.original?.dispose(),i||I?.modified?.dispose(),w.current?.dispose()}return J.createElement(ro,{width:S,height:p,isEditorReady:h,loading:f,_ref:b,className:y,wrapperProps:g})}var Lu=Tu;k.memo(Lu);function Mu(e){let t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}var Nu=Mu,bs=new Map;function Pu({defaultValue:e,defaultLanguage:t,defaultPath:s,value:l,language:m,path:v,theme:C="light",line:r,loading:i="Loading...",options:c={},overrideServices:f={},saveViewState:o=!0,keepCurrentModel:p=!1,width:S="100%",height:y="100%",className:g,wrapperProps:n={},beforeMount:d=ts,onMount:h=ts,onChange:u,onValidate:_=ts}){let[x,w]=k.useState(!1),[E,b]=k.useState(!0),R=k.useRef(null),j=k.useRef(null),L=k.useRef(null),M=k.useRef(h),T=k.useRef(d),B=k.useRef(),I=k.useRef(l),H=Nu(v),W=k.useRef(!1),A=k.useRef(!1);io(()=>{let O=so.init();return O.then($=>(R.current=$)&&b(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>j.current?P():O.cancel()}),nt(()=>{let O=zt(R.current,e||l||"",t||m||"",v||s||"");O!==j.current?.getModel()&&(o&&bs.set(H,j.current?.saveViewState()),j.current?.setModel(O),o&&j.current?.restoreViewState(bs.get(v)))},[v],x),nt(()=>{j.current?.updateOptions(c)},[c],x),nt(()=>{!j.current||l===void 0||(j.current.getOption(R.current.editor.EditorOption.readOnly)?j.current.setValue(l):l!==j.current.getValue()&&(A.current=!0,j.current.executeEdits("",[{range:j.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),j.current.pushUndoStop(),A.current=!1))},[l],x),nt(()=>{let O=j.current?.getModel();O&&m&&R.current?.editor.setModelLanguage(O,m)},[m],x),nt(()=>{r!==void 0&&j.current?.revealLine(r)},[r],x),nt(()=>{R.current?.editor.setTheme(C)},[C],x);let N=k.useCallback(()=>{if(!(!L.current||!R.current)&&!W.current){T.current(R.current);let O=v||s,$=zt(R.current,l||e||"",t||m||"",O||"");j.current=R.current?.editor.create(L.current,{model:$,automaticLayout:!0,...c},f),o&&j.current.restoreViewState(bs.get(O)),R.current.editor.setTheme(C),r!==void 0&&j.current.revealLine(r),w(!0),W.current=!0}},[e,t,s,l,m,v,c,f,o,C,r]);k.useEffect(()=>{x&&M.current(j.current,R.current)},[x]),k.useEffect(()=>{!E&&!x&&N()},[E,x,N]),I.current=l,k.useEffect(()=>{x&&u&&(B.current?.dispose(),B.current=j.current?.onDidChangeModelContent(O=>{A.current||u(j.current.getValue(),O)}))},[x,u]),k.useEffect(()=>{if(x){let O=R.current.editor.onDidChangeMarkers($=>{let X=j.current.getModel()?.uri;if(X&&$.find(K=>K.path===X.path)){let K=R.current.editor.getModelMarkers({resource:X});_?.(K)}});return()=>{O?.dispose()}}return()=>{}},[x,_]);function P(){B.current?.dispose(),p?o&&bs.set(v,j.current.saveViewState()):j.current.getModel()?.dispose(),j.current.dispose()}return J.createElement(ro,{width:S,height:y,isEditorReady:x,loading:i,_ref:L,className:g,wrapperProps:n})}var Ou=Pu,Bu=k.memo(Ou),Iu=Bu,ht=function(e,t){return Number(e.toFixed(t))},Fu=function(e,t){return typeof e=="number"?e:t},je=function(e,t,s){s&&typeof s=="function"&&s(e,t)},Hu=function(e){return-Math.cos(e*Math.PI)/2+.5},zu=function(e){return e},Wu=function(e){return e*e},$u=function(e){return e*(2-e)},Uu=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},qu=function(e){return e*e*e},Ku=function(e){return--e*e*e+1},Xu=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Yu=function(e){return e*e*e*e},Vu=function(e){return 1- --e*e*e*e},Gu=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Qu=function(e){return e*e*e*e*e},Zu=function(e){return 1+--e*e*e*e*e},Ju=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},oo={easeOut:Hu,linear:zu,easeInQuad:Wu,easeOutQuad:$u,easeInOutQuad:Uu,easeInCubic:qu,easeOutCubic:Ku,easeInOutCubic:Xu,easeInQuart:Yu,easeOutQuart:Vu,easeInOutQuart:Gu,easeInQuint:Qu,easeOutQuint:Zu,easeInOutQuint:Ju},ao=function(e){typeof e=="number"&&cancelAnimationFrame(e)},mt=function(e){e.mounted&&(ao(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function lo(e,t,s,l){if(e.mounted){var m=new Date().getTime(),v=1;mt(e),e.animation=function(){if(!e.mounted)return ao(e.animation);var C=new Date().getTime()-m,r=C/s,i=oo[t],c=i(r);C>=s?(l(v),e.animation=null):e.animation&&(l(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ed(e){var t=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(l))}function Tt(e,t,s,l){var m=ed(t);if(!(!e.mounted||!m)){var v=e.setTransformState,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,f=t.scale-r,o=t.positionX-i,p=t.positionY-c;s===0?v(t.scale,t.positionX,t.positionY):lo(e,l,s,function(S){var y=r+f*S,g=i+o*S,n=c+p*S;v(y,g,n)})}}function td(e,t,s){var l=e.offsetWidth,m=e.offsetHeight,v=t.offsetWidth,C=t.offsetHeight,r=v*s,i=C*s,c=l-r,f=m-i;return{wrapperWidth:l,wrapperHeight:m,newContentWidth:r,newDiffWidth:c,newContentHeight:i,newDiffHeight:f}}var sd=function(e,t,s,l,m,v,C){var r=e>t?s*(C?1:.5):0,i=l>m?v*(C?1:.5):0,c=e-t-r,f=r,o=l-m-i,p=i;return{minPositionX:c,maxPositionX:f,minPositionY:o,maxPositionY:p}},Xr=function(e,t){var s=e.wrapperComponent,l=e.contentComponent,m=e.setup.centerZoomedOut;if(!s||!l)throw new Error("Components are not mounted");var v=td(s,l,t),C=v.wrapperWidth,r=v.wrapperHeight,i=v.newContentWidth,c=v.newDiffWidth,f=v.newContentHeight,o=v.newDiffHeight,p=sd(C,i,c,r,f,o,!!m);return p},Er=function(e,t,s,l){return l?e<t?ht(t,2):e>s?ht(s,2):ht(e,2):ht(e,2)},Bt=function(e,t){var s=Xr(e,t);return e.bounds=s,s};function ms(e,t,s,l,m,v,C){var r=s.minPositionX,i=s.minPositionY,c=s.maxPositionX,f=s.maxPositionY,o=0,p=0;C&&(o=m,p=v);var S=Er(e,r-o,c+o,l),y=Er(t,i-p,f+p,l);return{x:S,y}}function Vs(e,t,s,l,m,v){var C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,f=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*f,p=c-s*f,S=ms(o,p,m,v,0,0,null);return S}function ps(e,t,s,l,m){var v=m?l:0,C=t-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=C?C:e}var Bi=function(e,t){var s=e.setup.panning.excluded,l=e.isInitialized,m=e.wrapperComponent,v=t.target,C="shadowRoot"in v&&"composedPath"in t,r=C?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(v),i=l&&v&&r;if(!i)return!1;var c=Gs(v,s);return!c},Ii=function(e){var t=e.isInitialized,s=e.isPanning,l=e.setup,m=l.panning.disabled,v=t&&s&&!m;return!!v},rd=function(e,t){var s=e.transformState,l=s.positionX,m=s.positionY;e.isPanning=!0;var v=t.clientX,C=t.clientY;e.startCoords={x:v-l,y:C-m}},id=function(e,t){var s=t.touches,l=e.transformState,m=l.positionX,v=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-v}}};function nd(e){var t=e.transformState,s=t.positionX,l=t.positionY,m=t.scale,v=e.setup,C=v.disabled,r=v.limitToBounds,i=v.centerZoomedOut,c=e.wrapperComponent;if(!(C||!c||!e.bounds)){var f=e.bounds,o=f.maxPositionX,p=f.minPositionX,S=f.maxPositionY,y=f.minPositionY,g=s>o||s<p,n=l>S||l<y,d=s>o?c.offsetWidth:e.setup.minPositionX||0,h=l>S?c.offsetHeight:e.setup.minPositionY||0,u=Vs(e,d,h,m,e.bounds,r||i),_=u.x,x=u.y;return{scale:m,positionX:g?_:s,positionY:n?x:l}}}function co(e,t,s,l,m){var v=e.setup.limitToBounds,C=e.wrapperComponent,r=e.bounds,i=e.transformState,c=i.scale,f=i.positionX,o=i.positionY;if(!(C===null||r===null||t===f&&s===o)){var p=ms(t,s,r,v,l,m,C),S=p.x,y=p.y;e.setTransformState(c,S,y)}}var od=function(e,t,s){var l=e.startCoords,m=e.transformState,v=e.setup.panning,C=v.lockAxisX,r=v.lockAxisY,i=m.positionX,c=m.positionY;if(!l)return{x:i,y:c};var f=t-l.x,o=s-l.y,p=C?i:f,S=r?c:o;return{x:p,y:S}},jt=function(e,t){var s=e.setup,l=e.transformState,m=l.scale,v=s.minScale,C=s.disablePadding;return t>0&&m>=v&&!C?t:0},ad=function(e){var t=e.mounted,s=e.setup,l=s.disabled,m=s.velocityAnimation,v=e.transformState.scale,C=m.disabled,r=!C||v>1||!l||t;return!!r},ld=function(e){var t=e.mounted,s=e.velocity,l=e.bounds,m=e.setup,v=m.disabled,C=m.velocityAnimation,r=e.transformState.scale,i=C.disabled,c=!i||r>1||!v||t;return!(!c||!s||!l)};function cd(e,t){var s=e.setup.velocityAnimation,l=s.equalToMove,m=s.animationTime,v=s.sensitivity;return l?m*t*v:m}function Fi(e,t,s,l,m,v,C,r,i,c){if(m){if(t>C&&s>C){var f=C+(e-C)*c;return f>i?i:f<C?C:f}if(t<v&&s<v){var f=v+(e-v)*c;return f<r?r:f>v?v:f}}return l?t:Er(e,v,C,m)}function hd(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function ud(e,t){var s=ad(e);if(s){var l=e.lastMousePosition,m=e.velocityTime,v=e.setup,C=e.wrapperComponent,r=v.velocityAnimation.equalToMove,i=Date.now();if(l&&m&&C){var c=hd(C,r),f=t.x-l.x,o=t.y-l.y,p=f/c,S=o/c,y=i-m,g=f*f+o*o,n=Math.sqrt(g)/y;e.velocity={velocityX:p,velocityY:S,total:n}}e.lastMousePosition=t,e.velocityTime=i}}function dd(e){var t=e.velocity,s=e.bounds,l=e.setup,m=e.wrapperComponent,v=ld(e);if(!(!v||!t||!s||!m)){var C=t.velocityX,r=t.velocityY,i=t.total,c=s.maxPositionX,f=s.minPositionX,o=s.maxPositionY,p=s.minPositionY,S=l.limitToBounds,y=l.alignmentAnimation,g=l.zoomAnimation,n=l.panning,d=n.lockAxisY,h=n.lockAxisX,u=g.animationType,_=y.sizeX,x=y.sizeY,w=y.velocityAlignmentTime,E=w,b=cd(e,i),R=Math.max(b,E),j=jt(e,_),L=jt(e,x),M=j*m.offsetWidth/100,T=L*m.offsetHeight/100,B=c+M,I=f-M,H=o+T,W=p-T,A=e.transformState,N=new Date().getTime();lo(e,u,R,function(P){var O=e.transformState,$=O.scale,X=O.positionX,K=O.positionY,Q=new Date().getTime()-N,se=Q/E,D=oo[y.animationType],F=1-D(Math.min(1,se)),U=1-P,z=X+C*U,ee=K+r*U,V=Fi(z,A.positionX,X,h,S,f,c,I,B,F),ne=Fi(ee,A.positionY,K,d,S,p,o,W,H,F);(X!==z||K!==ee)&&e.setTransformState($,V,ne)})}}function Hi(e,t){var s=e.transformState.scale;mt(e),Bt(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?id(e,t):rd(e,t)}function Yr(e,t){var s=e.transformState.scale,l=e.setup,m=l.minScale,v=l.alignmentAnimation,C=v.disabled,r=v.sizeX,i=v.sizeY,c=v.animationTime,f=v.animationType,o=C||s<m||!r&&!i;if(!o){var p=nd(e);p&&Tt(e,p,t??c,f)}}function zi(e,t,s){var l=e.startCoords,m=e.setup,v=m.alignmentAnimation,C=v.sizeX,r=v.sizeY;if(l){var i=od(e,t,s),c=i.x,f=i.y,o=jt(e,C),p=jt(e,r);ud(e,{x:c,y:f}),co(e,c,f,o,p)}}function fd(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,s=e.velocity,l=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=l?.getBoundingClientRect(),C=m?.getBoundingClientRect(),r=v?.width||0,i=v?.height||0,c=C?.width||0,f=C?.height||0,o=r<c||i<f,p=!t&&s&&s?.total>.1&&o;p?dd(e):Yr(e)}}function Vr(e,t,s,l){var m=e.setup,v=m.minScale,C=m.maxScale,r=m.limitToBounds,i=ps(ht(t,2),v,C,0,!1),c=Bt(e,i),f=Vs(e,s,l,i,c,r),o=f.x,p=f.y;return{scale:i,positionX:o,positionY:p}}function ho(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.minScale,r=v.limitToBounds,i=v.zoomAnimation,c=i.disabled,f=i.animationTime,o=i.animationType,p=c||l>=C;if((l>=1||r)&&Yr(e),!(p||!m||!e.mounted)){var S=t||m.offsetWidth/2,y=s||m.offsetHeight/2,g=Vr(e,C,S,y);g&&Tt(e,g,f,o)}}var At=function(){return At=Object.assign||function(t){for(var s,l=1,m=arguments.length;l<m;l++){s=arguments[l];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(t[v]=s[v])}return t},At.apply(this,arguments)};function Wi(e,t,s){for(var l=0,m=t.length,v;l<m;l++)(v||!(l in t))&&(v||(v=Array.prototype.slice.call(t,0,l)),v[l]=t[l]);return e.concat(v||Array.prototype.slice.call(t))}var xs={scale:1,positionX:0,positionY:0},Vt={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}},kr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},uo=function(e){var t,s,l,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:xs.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:xs.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:xs.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:xs.positionY}},$i=function(e){var t=At({},Vt);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",m=typeof Vt[s]<"u";if(m&&l){var v=Object.prototype.toString.call(Vt[s]),C=v==="[object Object]",r=v==="[object Array]";C?t[s]=At(At({},Vt[s]),e[s]):r?t[s]=Wi(Wi([],Vt[s],!0),e[s]):t[s]=e[s]}}),t},fo=function(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.maxScale,r=v.minScale,i=v.zoomAnimation,c=v.smooth,f=i.size;if(!m)throw new Error("Wrapper is not mounted");var o=c?l*Math.exp(t*s):l+t*s,p=ps(ht(o,3),r,C,f,!1);return p};function mo(e,t,s,l,m){var v=e.wrapperComponent,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,o=v.offsetHeight,p=(f/2-i)/r,S=(o/2-c)/r,y=fo(e,t,s),g=Vr(e,y,p,S);if(!g)return console.error("Error during zoom event. New transformation state was not calculated.");Tt(e,g,l,m)}function po(e,t,s,l){var m=e.setup,v=e.wrapperComponent,C=m.limitToBounds,r=uo(e.props),i=e.transformState,c=i.scale,f=i.positionX,o=i.positionY;if(v){var p=Xr(e,r.scale),S=ms(r.positionX,r.positionY,p,C,0,0,v),y={scale:r.scale,positionX:S.x,positionY:S.y};c===r.scale&&f===r.positionX&&o===r.positionY||(l?.(),Tt(e,y,t,s))}}function md(e,t,s,l){var m=e.getBoundingClientRect(),v=t.getBoundingClientRect(),C=s.getBoundingClientRect(),r=v.x*l.scale,i=v.y*l.scale;return{x:(m.x-C.x+r)/l.scale,y:(m.y-C.y+i)/l.scale}}function pd(e,t,s){var l=e.wrapperComponent,m=e.contentComponent,v=e.transformState,C=e.setup,r=C.limitToBounds,i=C.minScale,c=C.maxScale;if(!l||!m)return v;var f=l.getBoundingClientRect(),o=t.getBoundingClientRect(),p=md(t,l,m,v),S=p.x,y=p.y,g=o.width/v.scale,n=o.height/v.scale,d=l.offsetWidth/g,h=l.offsetHeight/n,u=ps(s||Math.min(d,h),i,c,0,!1),_=(f.width-g*u)/2,x=(f.height-n*u)/2,w=(f.left-S)*u+_,E=(f.top-y)*u+x,b=Xr(e,u),R=ms(w,E,b,r,0,0,l),j=R.x,L=R.y;return{positionX:j,positionY:L,scale:u}}var vd=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),mo(e,1,t,s,l)}},gd=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),mo(e,-1,t,s,l)}},_d=function(e){return function(t,s,l,m,v){m===void 0&&(m=300),v===void 0&&(v="easeOut");var C=e.transformState,r=C.positionX,i=C.positionY,c=C.scale,f=e.wrapperComponent,o=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!o)){var S={positionX:Number.isNaN(t)?r:t,positionY:Number.isNaN(s)?i:s,scale:Number.isNaN(l)?c:l};Tt(e,S,m,v)}}},bd=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),po(e,t,s)}},xd=function(e){return function(t,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var m=e.transformState,v=e.wrapperComponent,C=e.contentComponent;if(v&&C){var r=vo(t||m.scale,v,C);Tt(e,r,s,l)}}},Sd=function(e){return function(t,s,l,m){l===void 0&&(l=600),m===void 0&&(m="easeOut"),mt(e);var v=e.wrapperComponent,C=typeof t=="string"?document.getElementById(t):t;if(v&&C&&v.contains(C)){var r=pd(e,C,s);Tt(e,r,l,m)}}},Ms=function(e){return{instance:e,zoomIn:vd(e),zoomOut:gd(e),setTransform:_d(e),resetTransform:bd(e),centerView:xd(e),zoomToElement:Sd(e)}},Rr=function(e){return{instance:e,state:e.transformState}},De=function(e){var t={};return Object.assign(t,Rr(e)),Object.assign(t,Ms(e)),t},mr=!1;function pr(){try{var e={get passive(){return mr=!0,!1}};return e}catch{return mr=!1,mr}}var Ss=".".concat(kr.wrapperClass),Gs=function(e,t){return t.some(function(s){return e.matches("".concat(Ss," ").concat(s,", ").concat(Ss," .").concat(s,", ").concat(Ss," ").concat(s," *, ").concat(Ss," .").concat(s," *"))})},Dr=function(e){e&&clearTimeout(e)},yd=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},vo=function(e,t,s){var l=s.offsetWidth*e,m=s.offsetHeight*e,v=(t.offsetWidth-l)/2,C=(t.offsetHeight-m)/2;return{scale:e,positionX:v,positionY:C}};function Cd(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var wd=function(e,t){var s=e.setup.wheel,l=s.disabled,m=s.wheelDisabled,v=s.touchPadDisabled,C=s.excluded,r=e.isInitialized,i=e.isPanning,c=t.target,f=r&&!i&&!l&&c;if(!f||m&&!t.ctrlKey||v&&t.ctrlKey)return!1;var o=Gs(c,C);return!o},Ed=function(e){return e?e.deltaY<0?1:-1:0};function kd(e,t){var s=Ed(e),l=Fu(t,s);return l}function go(e,t,s){var l=t.getBoundingClientRect(),m=0,v=0;if("clientX"in e)m=(e.clientX-l.left)/s,v=(e.clientY-l.top)/s;else{var C=e.touches[0];m=(C.clientX-l.left)/s,v=(C.clientY-l.top)/s}return(Number.isNaN(m)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:m,y:v}}var Rd=function(e,t,s,l,m){var v=e.transformState.scale,C=e.wrapperComponent,r=e.setup,i=r.maxScale,c=r.minScale,f=r.zoomAnimation,o=r.disablePadding,p=f.size,S=f.disabled;if(!C)throw new Error("Wrapper is not mounted");var y=v+t*s,g=l?!1:!S,n=ps(ht(y,3),c,i,p,g&&!o);return n},Dd=function(e,t){var s=e.previousWheelEvent,l=e.transformState.scale,m=e.setup,v=m.maxScale,C=m.minScale;return s?l<v||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},Ad=function(e,t){var s=e.setup.pinch,l=s.disabled,m=s.excluded,v=e.isInitialized,C=t.target,r=v&&!l&&C;if(!r)return!1;var i=Gs(C,m);return!i},jd=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,m=s&&!t&&l;return!!m},Td=function(e,t,s){var l=s.getBoundingClientRect(),m=e.touches,v=ht(m[0].clientX-l.left,5),C=ht(m[0].clientY-l.top,5),r=ht(m[1].clientX-l.left,5),i=ht(m[1].clientY-l.top,5);return{x:(v+r)/2/t,y:(C+i)/2/t}},_o=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))},Ld=function(e,t){var s=e.pinchStartScale,l=e.pinchStartDistance,m=e.setup,v=m.maxScale,C=m.minScale,r=m.zoomAnimation,i=m.disablePadding,c=r.size,f=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 ps(ht(p,2),C,v,c,!f&&!i)},Md=160,Nd=100,Pd=function(e,t){var s=e.props,l=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(mt(e),je(De(e),t,l),je(De(e),t,m))},Od=function(e,t){var s=e.props,l=s.onWheel,m=s.onZoom,v=e.contentComponent,C=e.setup,r=e.transformState,i=r.scale,c=C.limitToBounds,f=C.centerZoomedOut,o=C.zoomAnimation,p=C.wheel,S=C.disablePadding,y=C.smooth,g=o.size,n=o.disabled,d=p.step,h=p.smoothStep;if(!v)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=kd(t,null),_=y?h*Math.abs(t.deltaY):d,x=Rd(e,u,_,!t.ctrlKey);if(i!==x){var w=Bt(e,x),E=go(t,v,i),b=n||g===0||f||S,R=c&&b,j=Vs(e,E.x,E.y,x,w,R),L=j.x,M=j.y;e.previousWheelEvent=t,e.setTransformState(x,L,M),je(De(e),t,l),je(De(e),t,m)}},Bd=function(e,t){var s=e.props,l=s.onWheelStop,m=s.onZoomStop;Dr(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ho(e,t.x,t.y),e.wheelAnimationTimer=null)},Nd);var v=Dd(e,t);v&&(Dr(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,je(De(e),t,l),je(De(e),t,m))},Md))},bo=function(e){for(var t=0,s=0,l=0;l<2;l+=1)t+=e.touches[l].clientX,s+=e.touches[l].clientY;var m=t/2,v=s/2;return{x:m,y:v}},Id=function(e,t){var s=_o(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=bo(t);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,mt(e)},Fd=function(e,t){var s=e.contentComponent,l=e.pinchStartDistance,m=e.wrapperComponent,v=e.transformState.scale,C=e.setup,r=C.limitToBounds,i=C.centerZoomedOut,c=C.zoomAnimation,f=C.alignmentAnimation,o=c.disabled,p=c.size;if(!(l===null||!s)){var S=Td(t,v,s);if(!(!Number.isFinite(S.x)||!Number.isFinite(S.y))){var y=_o(t),g=Ld(e,y),n=bo(t),d=n.x-(e.pinchLastCenterX||0),h=n.y-(e.pinchLastCenterY||0);if(!(g===v&&d===0&&h===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var u=Bt(e,g),_=o||p===0||i,x=r&&_,w=Vs(e,S.x,S.y,g,u,x),E=w.x,b=w.y;e.pinchMidpoint=S,e.lastDistance=y;var R=f.sizeX,j=f.sizeY,L=jt(e,R),M=jt(e,j),T=E+d,B=b+h,I=ms(T,B,u,r,L,M,m),H=I.x,W=I.y;e.setTransformState(g,H,W)}}}},Hd=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ho(e,t?.x,t?.y)},xo=function(e,t){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;Dr(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,je(De(e),t,s)},l)},zd=function(e,t){var s=e.props,l=s.onZoomStart,m=s.onZoom,v=e.setup.doubleClick,C=v.animationTime,r=v.animationType;je(De(e),t,l),po(e,C,r,function(){return je(De(e),t,m)}),xo(e,t)};function Wd(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function $d(e,t){var s=e.setup,l=e.doubleClickStopEventTimer,m=e.transformState,v=e.contentComponent,C=m.scale,r=e.props,i=r.onZoomStart,c=r.onZoom,f=s.doubleClick,o=f.disabled,p=f.mode,S=f.step,y=f.animationTime,g=f.animationType;if(!o&&!l){if(p==="reset")return zd(e,t);if(!v)return console.error("No ContentComponent found");var n=Wd(p,e.transformState.scale),d=fo(e,n,S);if(C!==d){je(De(e),t,i);var h=go(t,v,C),u=Vr(e,d,h.x,h.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");je(De(e),t,c),Tt(e,u,y,g),xo(e,t)}}}var Ud=function(e,t){var s=e.isInitialized,l=e.setup,m=e.wrapperComponent,v=l.doubleClick,C=v.disabled,r=v.excluded,i=t.target,c=m?.contains(i),f=s&&i&&c&&!C;if(!f)return!1;var o=Gs(i,r);return!o},qd=(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,Bt(s,s.transformState.scale),s.setup=$i(l)},this.initializeWindowEvents=function(){var l,m,v=pr(),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,v),r?.addEventListener("mousedown",s.onPanningStart,v),r?.addEventListener("mousemove",s.onPanning,v),r?.addEventListener("mouseup",s.onPanningStop,v),C?.addEventListener("mouseleave",s.clearPanning,v),r?.addEventListener("keyup",s.setKeyUnPressed,v),r?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var l,m,v=pr(),C=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=C?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,v),r?.removeEventListener("mousemove",s.onPanning,v),r?.removeEventListener("mouseup",s.onPanningStop,v),C?.removeEventListener("mouseleave",s.clearPanning,v),r?.removeEventListener("keyup",s.setKeyUnPressed,v),r?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),mt(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(l){var m=pr();l.addEventListener("wheel",s.onWheelZoom,m),l.addEventListener("dblclick",s.onDoubleClick,m),l.addEventListener("touchstart",s.onTouchPanningStart,m),l.addEventListener("touchmove",s.onTouchPanning,m),l.addEventListener("touchend",s.onTouchPanningStop,m)},this.handleInitialize=function(l,m){var v=!1,C=s.setup.centerOnInit,r=function(i,c){for(var f=0,o=i;f<o.length;f++){var p=o[f];if(p.target===c)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(i){i(De(s))}),s.observer=new ResizeObserver(function(i){if(r(i,l)||r(i,m))if(C&&!v){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(v=!0,s.setCenter())}else mt(s),Bt(s,s.transformState.scale),Yr(s,0)}),s.observer.observe(l),s.observer.observe(m)},this.onWheelZoom=function(l){var m=s.setup.disabled;if(!m){var v=wd(s,l);if(v){var C=s.isPressingKeys(s.setup.wheel.activationKeys);C&&(Pd(s,l),Od(s,l),Bd(s,l))}}},this.onWheelPanning=function(l){var m=s.setup,v=m.disabled,C=m.wheel,r=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!C.wheelDisabled||r.disabled||!r.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var i=s.transformState,c=i.positionX,f=i.positionY,o=c-l.deltaX,p=f-l.deltaY,S=r.lockAxisX?c:o,y=r.lockAxisY?f:p,g=s.setup.alignmentAnimation,n=g.sizeX,d=g.sizeY,h=jt(s,n),u=jt(s,d);S===c&&y===f||co(s,S,y,h,u)}},this.onPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Bi(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(),mt(s),Hi(s,l),je(De(s),l,v)))}}},this.onPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(!m){var C=Ii(s);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(l.preventDefault(),l.stopPropagation(),zi(s,l.clientX,l.clientY),je(De(s),l,v))}}},this.onPanningStop=function(l){var m=s.props.onPanningStop;s.isPanning&&(fd(s),je(De(s),l,m))},this.onPinchStart=function(l){var m=s.setup.disabled,v=s.props,C=v.onPinchingStart,r=v.onZoomStart;if(!m){var i=Ad(s,l);i&&(Id(s,l),mt(s),je(De(s),l,C),je(De(s),l,r))}},this.onPinch=function(l){var m=s.setup.disabled,v=s.props,C=v.onPinching,r=v.onZoom;if(!m){var i=jd(s);i&&(l.preventDefault(),l.stopPropagation(),Fd(s,l),je(De(s),l,C),je(De(s),l,r))}},this.onPinchStop=function(l){var m=s.props,v=m.onPinchingStop,C=m.onZoomStop;s.pinchStartScale&&(Hd(s),je(De(s),l,v),je(De(s),l,C))},this.onTouchPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Bi(s,l);if(C){var r=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!r){s.lastTouch=+new Date,mt(s);var i=l.touches,c=i.length===1,f=i.length===2;c&&(mt(s),Hi(s,l),je(De(s),l,v)),f&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(m)return;var C=Ii(s);if(!C)return;l.preventDefault(),l.stopPropagation();var r=l.touches[0];zi(s,r.clientX,r.clientY),je(De(s),l,v)}else l.touches.length>1&&s.onPinch(l)},this.onTouchPanningStop=function(l){s.onPanningStop(l),s.onPinchStop(l)},this.onDoubleClick=function(l){var m=s.setup.disabled;if(!m){var v=Ud(s,l);v&&$d(s,l)}},this.clearPanning=function(l){s.isPanning&&s.onPanningStop(l)},this.setKeyPressed=function(l){s.pressedKeys[l.key]=!0},this.setKeyUnPressed=function(l){s.pressedKeys[l.key]=!1},this.isPressingKeys=function(l){return l.length?!!l.find(function(m){return s.pressedKeys[m]}):!0},this.setTransformState=function(l,m,v){var C=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(m)&&!Number.isNaN(v)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=m,s.transformState.positionY=v,s.applyTransformation();var r=De(s);s.onChangeCallbacks.forEach(function(i){return i(r)}),je(r,{scale:l,positionX:m,positionY:v},C)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=vo(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,m,v){return s.props.customTransform?s.props.customTransform(l,m,v):yd(l,m,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,m=l.scale,v=l.positionX,C=l.positionY,r=s.handleTransformStyles(v,C,m);s.contentComponent.style.transform=r}},this.getContext=function(){return De(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,Bt(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,m),s.initializeWindowEvents(),s.isInitialized=!0;var v=De(s);je(v,void 0,s.props.onInit)},this.props=t,this.setup=$i(this.props),this.transformState=uo(this.props)}return e})(),Qs=J.createContext(null),Kd=function(e,t){return typeof e=="function"?e(t):e},Xd=J.forwardRef(function(e,t){var s=k.useRef(new qd(e)).current,l=Kd(e.children,Ms(s));return k.useImperativeHandle(t,function(){return Ms(s)},[s]),k.useEffect(function(){s.update(e)},[s,e]),J.createElement(Qs.Provider,{value:s},l)});J.forwardRef(function(e,t){var s=k.useRef(null),l=k.useContext(Qs);return k.useEffect(function(){return l.onChange(function(m){if(s.current){var v=0,C=0;s.current.style.transform=l.handleTransformStyles(v,C,1/m.instance.transformState.scale)}})},[l]),J.createElement("div",At({},e,{ref:Cd([s,t])}))});function Yd(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 Vd=`.transform-component-module_wrapper__SPB86 {
31
+ `},Oi=su(ou)(Zn),au={config:iu},lu=function(){for(var t=arguments.length,s=new Array(t),l=0;l<t;l++)s[l]=arguments[l];return function(m){return s.reduceRight(function(v,C){return C(v)},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]))}),Mi(Mi({},e),t)}var cu={type:"cancelation",msg:"operation is manually canceled"};function ur(e){var t=!1,s=new Promise(function(l,m){e.then(function(v){return t?m(cu):l(v)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var hu=["monaco"],uu=eu.create({config:tu,isInitialized:!1,resolve:null,reject:null,monaco:null}),eo=Oh(uu,2),fs=eo[0],Ys=eo[1];function du(e){var t=au.config(e),s=t.monaco,l=Nh(t,hu);Ys(function(m){return{config:Jn(m.config,l),monaco:s}})}function fu(){var e=fs(function(t){var s=t.monaco,l=t.isInitialized,m=t.resolve;return{monaco:s,isInitialized:l,resolve:m}});if(!e.isInitialized){if(Ys({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ur(dr);if(window.monaco&&window.monaco.editor)return to(window.monaco),e.resolve(window.monaco),ur(dr);lu(mu,vu)(gu)}return ur(dr)}function mu(e){return document.body.appendChild(e)}function pu(e){var t=document.createElement("script");return e&&(t.src=e),t}function vu(e){var t=fs(function(l){var m=l.config,v=l.reject;return{config:m,reject:v}}),s=pu("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function gu(){var e=fs(function(s){var l=s.config,m=s.resolve,v=s.reject;return{config:l,resolve:m,reject:v}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var l=s.m||s;to(l),e.resolve(l)},function(s){e.reject(s)})}function to(e){fs().monaco||Ys({monaco:e})}function _u(){return fs(function(e){var t=e.monaco;return t})}var dr=new Promise(function(e,t){return Ys({resolve:e,reject:t})}),so={config:du,init:fu,__getMonacoInstance:_u},bu={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},fr=bu,xu={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Su=xu;function yu({children:e}){return J.createElement("div",{style:Su.container},e)}var Cu=yu,wu=Cu;function Eu({width:e,height:t,isEditorReady:s,loading:l,_ref:m,className:v,wrapperProps:C}){return J.createElement("section",{style:{...fr.wrapper,width:e,height:t},...C},!s&&J.createElement(wu,null,l),J.createElement("div",{ref:m,style:{...fr.fullWidth,...!s&&fr.hide},className:v}))}var ku=Eu,ro=k.memo(ku);function Ru(e){k.useEffect(e,[])}var io=Ru;function Du(e,t,s=!0){let l=k.useRef(!0);k.useEffect(l.current||!s?()=>{l.current=!1}:e,t)}var nt=Du;function ts(){}function zt(e,t,s,l){return Au(e,l)||ju(e,t,s,l)}function Au(e,t){return e.editor.getModel(no(e,t))}function ju(e,t,s,l){return e.editor.createModel(t,s,l?no(e,l):void 0)}function no(e,t){return e.Uri.parse(t)}function Tu({original:e,modified:t,language:s,originalLanguage:l,modifiedLanguage:m,originalModelPath:v,modifiedModelPath:C,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:i=!1,theme:c="light",loading:f="Loading...",options:o={},height:p="100%",width:S="100%",className:y,wrapperProps:g={},beforeMount:n=ts,onMount:d=ts}){let[h,u]=k.useState(!1),[_,x]=k.useState(!0),w=k.useRef(null),E=k.useRef(null),b=k.useRef(null),R=k.useRef(d),j=k.useRef(n),L=k.useRef(!1);io(()=>{let I=so.init();return I.then(H=>(E.current=H)&&x(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>w.current?B():I.cancel()}),nt(()=>{if(w.current&&E.current){let I=w.current.getOriginalEditor(),H=zt(E.current,e||"",l||s||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],h),nt(()=>{if(w.current&&E.current){let I=w.current.getModifiedEditor(),H=zt(E.current,t||"",m||s||"text",C||"");H!==I.getModel()&&I.setModel(H)}},[C],h),nt(()=>{let I=w.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(t||""):t!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[t],h),nt(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],h),nt(()=>{let{original:I,modified:H}=w.current.getModel();E.current.editor.setModelLanguage(I,l||s||"text"),E.current.editor.setModelLanguage(H,m||s||"text")},[s,l,m],h),nt(()=>{E.current?.editor.setTheme(c)},[c],h),nt(()=>{w.current?.updateOptions(o)},[o],h);let M=k.useCallback(()=>{if(!E.current)return;j.current(E.current);let I=zt(E.current,e||"",l||s||"text",v||""),H=zt(E.current,t||"",m||s||"text",C||"");w.current?.setModel({original:I,modified:H})},[s,t,m,e,l,v,C]),T=k.useCallback(()=>{!L.current&&b.current&&(w.current=E.current.editor.createDiffEditor(b.current,{automaticLayout:!0,...o}),M(),E.current?.editor.setTheme(c),u(!0),L.current=!0)},[o,c,M]);k.useEffect(()=>{h&&R.current(w.current,E.current)},[h]),k.useEffect(()=>{!_&&!h&&T()},[_,h,T]);function B(){let I=w.current?.getModel();r||I?.original?.dispose(),i||I?.modified?.dispose(),w.current?.dispose()}return J.createElement(ro,{width:S,height:p,isEditorReady:h,loading:f,_ref:b,className:y,wrapperProps:g})}var Lu=Tu;k.memo(Lu);function Mu(e){let t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}var Nu=Mu,bs=new Map;function Pu({defaultValue:e,defaultLanguage:t,defaultPath:s,value:l,language:m,path:v,theme:C="light",line:r,loading:i="Loading...",options:c={},overrideServices:f={},saveViewState:o=!0,keepCurrentModel:p=!1,width:S="100%",height:y="100%",className:g,wrapperProps:n={},beforeMount:d=ts,onMount:h=ts,onChange:u,onValidate:_=ts}){let[x,w]=k.useState(!1),[E,b]=k.useState(!0),R=k.useRef(null),j=k.useRef(null),L=k.useRef(null),M=k.useRef(h),T=k.useRef(d),B=k.useRef(),I=k.useRef(l),H=Nu(v),W=k.useRef(!1),A=k.useRef(!1);io(()=>{let O=so.init();return O.then($=>(R.current=$)&&b(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>j.current?P():O.cancel()}),nt(()=>{let O=zt(R.current,e||l||"",t||m||"",v||s||"");O!==j.current?.getModel()&&(o&&bs.set(H,j.current?.saveViewState()),j.current?.setModel(O),o&&j.current?.restoreViewState(bs.get(v)))},[v],x),nt(()=>{j.current?.updateOptions(c)},[c],x),nt(()=>{!j.current||l===void 0||(j.current.getOption(R.current.editor.EditorOption.readOnly)?j.current.setValue(l):l!==j.current.getValue()&&(A.current=!0,j.current.executeEdits("",[{range:j.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),j.current.pushUndoStop(),A.current=!1))},[l],x),nt(()=>{let O=j.current?.getModel();O&&m&&R.current?.editor.setModelLanguage(O,m)},[m],x),nt(()=>{r!==void 0&&j.current?.revealLine(r)},[r],x),nt(()=>{R.current?.editor.setTheme(C)},[C],x);let N=k.useCallback(()=>{if(!(!L.current||!R.current)&&!W.current){T.current(R.current);let O=v||s,$=zt(R.current,l||e||"",t||m||"",O||"");j.current=R.current?.editor.create(L.current,{model:$,automaticLayout:!0,...c},f),o&&j.current.restoreViewState(bs.get(O)),R.current.editor.setTheme(C),r!==void 0&&j.current.revealLine(r),w(!0),W.current=!0}},[e,t,s,l,m,v,c,f,o,C,r]);k.useEffect(()=>{x&&M.current(j.current,R.current)},[x]),k.useEffect(()=>{!E&&!x&&N()},[E,x,N]),I.current=l,k.useEffect(()=>{x&&u&&(B.current?.dispose(),B.current=j.current?.onDidChangeModelContent(O=>{A.current||u(j.current.getValue(),O)}))},[x,u]),k.useEffect(()=>{if(x){let O=R.current.editor.onDidChangeMarkers($=>{let X=j.current.getModel()?.uri;if(X&&$.find(K=>K.path===X.path)){let K=R.current.editor.getModelMarkers({resource:X});_?.(K)}});return()=>{O?.dispose()}}return()=>{}},[x,_]);function P(){B.current?.dispose(),p?o&&bs.set(v,j.current.saveViewState()):j.current.getModel()?.dispose(),j.current.dispose()}return J.createElement(ro,{width:S,height:y,isEditorReady:x,loading:i,_ref:L,className:g,wrapperProps:n})}var Ou=Pu,Bu=k.memo(Ou),Iu=Bu,ht=function(e,t){return Number(e.toFixed(t))},Fu=function(e,t){return typeof e=="number"?e:t},je=function(e,t,s){s&&typeof s=="function"&&s(e,t)},Hu=function(e){return-Math.cos(e*Math.PI)/2+.5},zu=function(e){return e},Wu=function(e){return e*e},$u=function(e){return e*(2-e)},Uu=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},qu=function(e){return e*e*e},Ku=function(e){return--e*e*e+1},Xu=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Yu=function(e){return e*e*e*e},Vu=function(e){return 1- --e*e*e*e},Gu=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Qu=function(e){return e*e*e*e*e},Zu=function(e){return 1+--e*e*e*e*e},Ju=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},oo={easeOut:Hu,linear:zu,easeInQuad:Wu,easeOutQuad:$u,easeInOutQuad:Uu,easeInCubic:qu,easeOutCubic:Ku,easeInOutCubic:Xu,easeInQuart:Yu,easeOutQuart:Vu,easeInOutQuart:Gu,easeInQuint:Qu,easeOutQuint:Zu,easeInOutQuint:Ju},ao=function(e){typeof e=="number"&&cancelAnimationFrame(e)},mt=function(e){e.mounted&&(ao(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function lo(e,t,s,l){if(e.mounted){var m=new Date().getTime(),v=1;mt(e),e.animation=function(){if(!e.mounted)return ao(e.animation);var C=new Date().getTime()-m,r=C/s,i=oo[t],c=i(r);C>=s?(l(v),e.animation=null):e.animation&&(l(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ed(e){var t=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(l))}function Tt(e,t,s,l){var m=ed(t);if(!(!e.mounted||!m)){var v=e.setTransformState,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,f=t.scale-r,o=t.positionX-i,p=t.positionY-c;s===0?v(t.scale,t.positionX,t.positionY):lo(e,l,s,function(S){var y=r+f*S,g=i+o*S,n=c+p*S;v(y,g,n)})}}function td(e,t,s){var l=e.offsetWidth,m=e.offsetHeight,v=t.offsetWidth,C=t.offsetHeight,r=v*s,i=C*s,c=l-r,f=m-i;return{wrapperWidth:l,wrapperHeight:m,newContentWidth:r,newDiffWidth:c,newContentHeight:i,newDiffHeight:f}}var sd=function(e,t,s,l,m,v,C){var r=e>t?s*(C?1:.5):0,i=l>m?v*(C?1:.5):0,c=e-t-r,f=r,o=l-m-i,p=i;return{minPositionX:c,maxPositionX:f,minPositionY:o,maxPositionY:p}},Xr=function(e,t){var s=e.wrapperComponent,l=e.contentComponent,m=e.setup.centerZoomedOut;if(!s||!l)throw new Error("Components are not mounted");var v=td(s,l,t),C=v.wrapperWidth,r=v.wrapperHeight,i=v.newContentWidth,c=v.newDiffWidth,f=v.newContentHeight,o=v.newDiffHeight,p=sd(C,i,c,r,f,o,!!m);return p},Er=function(e,t,s,l){return l?e<t?ht(t,2):e>s?ht(s,2):ht(e,2):ht(e,2)},Ot=function(e,t){var s=Xr(e,t);return e.bounds=s,s};function ms(e,t,s,l,m,v,C){var r=s.minPositionX,i=s.minPositionY,c=s.maxPositionX,f=s.maxPositionY,o=0,p=0;C&&(o=m,p=v);var S=Er(e,r-o,c+o,l),y=Er(t,i-p,f+p,l);return{x:S,y}}function Vs(e,t,s,l,m,v){var C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY,f=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*f,p=c-s*f,S=ms(o,p,m,v,0,0,null);return S}function ps(e,t,s,l,m){var v=m?l:0,C=t-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=C?C:e}var Bi=function(e,t){var s=e.setup.panning.excluded,l=e.isInitialized,m=e.wrapperComponent,v=t.target,C="shadowRoot"in v&&"composedPath"in t,r=C?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(v),i=l&&v&&r;if(!i)return!1;var c=Gs(v,s);return!c},Ii=function(e){var t=e.isInitialized,s=e.isPanning,l=e.setup,m=l.panning.disabled,v=t&&s&&!m;return!!v},rd=function(e,t){var s=e.transformState,l=s.positionX,m=s.positionY;e.isPanning=!0;var v=t.clientX,C=t.clientY;e.startCoords={x:v-l,y:C-m}},id=function(e,t){var s=t.touches,l=e.transformState,m=l.positionX,v=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-v}}};function nd(e){var t=e.transformState,s=t.positionX,l=t.positionY,m=t.scale,v=e.setup,C=v.disabled,r=v.limitToBounds,i=v.centerZoomedOut,c=e.wrapperComponent;if(!(C||!c||!e.bounds)){var f=e.bounds,o=f.maxPositionX,p=f.minPositionX,S=f.maxPositionY,y=f.minPositionY,g=s>o||s<p,n=l>S||l<y,d=s>o?c.offsetWidth:e.setup.minPositionX||0,h=l>S?c.offsetHeight:e.setup.minPositionY||0,u=Vs(e,d,h,m,e.bounds,r||i),_=u.x,x=u.y;return{scale:m,positionX:g?_:s,positionY:n?x:l}}}function co(e,t,s,l,m){var v=e.setup.limitToBounds,C=e.wrapperComponent,r=e.bounds,i=e.transformState,c=i.scale,f=i.positionX,o=i.positionY;if(!(C===null||r===null||t===f&&s===o)){var p=ms(t,s,r,v,l,m,C),S=p.x,y=p.y;e.setTransformState(c,S,y)}}var od=function(e,t,s){var l=e.startCoords,m=e.transformState,v=e.setup.panning,C=v.lockAxisX,r=v.lockAxisY,i=m.positionX,c=m.positionY;if(!l)return{x:i,y:c};var f=t-l.x,o=s-l.y,p=C?i:f,S=r?c:o;return{x:p,y:S}},jt=function(e,t){var s=e.setup,l=e.transformState,m=l.scale,v=s.minScale,C=s.disablePadding;return t>0&&m>=v&&!C?t:0},ad=function(e){var t=e.mounted,s=e.setup,l=s.disabled,m=s.velocityAnimation,v=e.transformState.scale,C=m.disabled,r=!C||v>1||!l||t;return!!r},ld=function(e){var t=e.mounted,s=e.velocity,l=e.bounds,m=e.setup,v=m.disabled,C=m.velocityAnimation,r=e.transformState.scale,i=C.disabled,c=!i||r>1||!v||t;return!(!c||!s||!l)};function cd(e,t){var s=e.setup.velocityAnimation,l=s.equalToMove,m=s.animationTime,v=s.sensitivity;return l?m*t*v:m}function Fi(e,t,s,l,m,v,C,r,i,c){if(m){if(t>C&&s>C){var f=C+(e-C)*c;return f>i?i:f<C?C:f}if(t<v&&s<v){var f=v+(e-v)*c;return f<r?r:f>v?v:f}}return l?t:Er(e,v,C,m)}function hd(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function ud(e,t){var s=ad(e);if(s){var l=e.lastMousePosition,m=e.velocityTime,v=e.setup,C=e.wrapperComponent,r=v.velocityAnimation.equalToMove,i=Date.now();if(l&&m&&C){var c=hd(C,r),f=t.x-l.x,o=t.y-l.y,p=f/c,S=o/c,y=i-m,g=f*f+o*o,n=Math.sqrt(g)/y;e.velocity={velocityX:p,velocityY:S,total:n}}e.lastMousePosition=t,e.velocityTime=i}}function dd(e){var t=e.velocity,s=e.bounds,l=e.setup,m=e.wrapperComponent,v=ld(e);if(!(!v||!t||!s||!m)){var C=t.velocityX,r=t.velocityY,i=t.total,c=s.maxPositionX,f=s.minPositionX,o=s.maxPositionY,p=s.minPositionY,S=l.limitToBounds,y=l.alignmentAnimation,g=l.zoomAnimation,n=l.panning,d=n.lockAxisY,h=n.lockAxisX,u=g.animationType,_=y.sizeX,x=y.sizeY,w=y.velocityAlignmentTime,E=w,b=cd(e,i),R=Math.max(b,E),j=jt(e,_),L=jt(e,x),M=j*m.offsetWidth/100,T=L*m.offsetHeight/100,B=c+M,I=f-M,H=o+T,W=p-T,A=e.transformState,N=new Date().getTime();lo(e,u,R,function(P){var O=e.transformState,$=O.scale,X=O.positionX,K=O.positionY,Q=new Date().getTime()-N,se=Q/E,D=oo[y.animationType],F=1-D(Math.min(1,se)),U=1-P,z=X+C*U,ee=K+r*U,V=Fi(z,A.positionX,X,h,S,f,c,I,B,F),ne=Fi(ee,A.positionY,K,d,S,p,o,W,H,F);(X!==z||K!==ee)&&e.setTransformState($,V,ne)})}}function Hi(e,t){var s=e.transformState.scale;mt(e),Ot(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?id(e,t):rd(e,t)}function Yr(e,t){var s=e.transformState.scale,l=e.setup,m=l.minScale,v=l.alignmentAnimation,C=v.disabled,r=v.sizeX,i=v.sizeY,c=v.animationTime,f=v.animationType,o=C||s<m||!r&&!i;if(!o){var p=nd(e);p&&Tt(e,p,t??c,f)}}function zi(e,t,s){var l=e.startCoords,m=e.setup,v=m.alignmentAnimation,C=v.sizeX,r=v.sizeY;if(l){var i=od(e,t,s),c=i.x,f=i.y,o=jt(e,C),p=jt(e,r);ud(e,{x:c,y:f}),co(e,c,f,o,p)}}function fd(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,s=e.velocity,l=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=l?.getBoundingClientRect(),C=m?.getBoundingClientRect(),r=v?.width||0,i=v?.height||0,c=C?.width||0,f=C?.height||0,o=r<c||i<f,p=!t&&s&&s?.total>.1&&o;p?dd(e):Yr(e)}}function Vr(e,t,s,l){var m=e.setup,v=m.minScale,C=m.maxScale,r=m.limitToBounds,i=ps(ht(t,2),v,C,0,!1),c=Ot(e,i),f=Vs(e,s,l,i,c,r),o=f.x,p=f.y;return{scale:i,positionX:o,positionY:p}}function ho(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.minScale,r=v.limitToBounds,i=v.zoomAnimation,c=i.disabled,f=i.animationTime,o=i.animationType,p=c||l>=C;if((l>=1||r)&&Yr(e),!(p||!m||!e.mounted)){var S=t||m.offsetWidth/2,y=s||m.offsetHeight/2,g=Vr(e,C,S,y);g&&Tt(e,g,f,o)}}var At=function(){return At=Object.assign||function(t){for(var s,l=1,m=arguments.length;l<m;l++){s=arguments[l];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(t[v]=s[v])}return t},At.apply(this,arguments)};function Wi(e,t,s){for(var l=0,m=t.length,v;l<m;l++)(v||!(l in t))&&(v||(v=Array.prototype.slice.call(t,0,l)),v[l]=t[l]);return e.concat(v||Array.prototype.slice.call(t))}var xs={scale:1,positionX:0,positionY:0},Vt={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}},kr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},uo=function(e){var t,s,l,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:xs.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:xs.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:xs.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:xs.positionY}},$i=function(e){var t=At({},Vt);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",m=typeof Vt[s]<"u";if(m&&l){var v=Object.prototype.toString.call(Vt[s]),C=v==="[object Object]",r=v==="[object Array]";C?t[s]=At(At({},Vt[s]),e[s]):r?t[s]=Wi(Wi([],Vt[s],!0),e[s]):t[s]=e[s]}}),t},fo=function(e,t,s){var l=e.transformState.scale,m=e.wrapperComponent,v=e.setup,C=v.maxScale,r=v.minScale,i=v.zoomAnimation,c=v.smooth,f=i.size;if(!m)throw new Error("Wrapper is not mounted");var o=c?l*Math.exp(t*s):l+t*s,p=ps(ht(o,3),r,C,f,!1);return p};function mo(e,t,s,l,m){var v=e.wrapperComponent,C=e.transformState,r=C.scale,i=C.positionX,c=C.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,o=v.offsetHeight,p=(f/2-i)/r,S=(o/2-c)/r,y=fo(e,t,s),g=Vr(e,y,p,S);if(!g)return console.error("Error during zoom event. New transformation state was not calculated.");Tt(e,g,l,m)}function po(e,t,s,l){var m=e.setup,v=e.wrapperComponent,C=m.limitToBounds,r=uo(e.props),i=e.transformState,c=i.scale,f=i.positionX,o=i.positionY;if(v){var p=Xr(e,r.scale),S=ms(r.positionX,r.positionY,p,C,0,0,v),y={scale:r.scale,positionX:S.x,positionY:S.y};c===r.scale&&f===r.positionX&&o===r.positionY||(l?.(),Tt(e,y,t,s))}}function md(e,t,s,l){var m=e.getBoundingClientRect(),v=t.getBoundingClientRect(),C=s.getBoundingClientRect(),r=v.x*l.scale,i=v.y*l.scale;return{x:(m.x-C.x+r)/l.scale,y:(m.y-C.y+i)/l.scale}}function pd(e,t,s){var l=e.wrapperComponent,m=e.contentComponent,v=e.transformState,C=e.setup,r=C.limitToBounds,i=C.minScale,c=C.maxScale;if(!l||!m)return v;var f=l.getBoundingClientRect(),o=t.getBoundingClientRect(),p=md(t,l,m,v),S=p.x,y=p.y,g=o.width/v.scale,n=o.height/v.scale,d=l.offsetWidth/g,h=l.offsetHeight/n,u=ps(s||Math.min(d,h),i,c,0,!1),_=(f.width-g*u)/2,x=(f.height-n*u)/2,w=(f.left-S)*u+_,E=(f.top-y)*u+x,b=Xr(e,u),R=ms(w,E,b,r,0,0,l),j=R.x,L=R.y;return{positionX:j,positionY:L,scale:u}}var vd=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),mo(e,1,t,s,l)}},gd=function(e){return function(t,s,l){t===void 0&&(t=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),mo(e,-1,t,s,l)}},_d=function(e){return function(t,s,l,m,v){m===void 0&&(m=300),v===void 0&&(v="easeOut");var C=e.transformState,r=C.positionX,i=C.positionY,c=C.scale,f=e.wrapperComponent,o=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!o)){var S={positionX:Number.isNaN(t)?r:t,positionY:Number.isNaN(s)?i:s,scale:Number.isNaN(l)?c:l};Tt(e,S,m,v)}}},bd=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),po(e,t,s)}},xd=function(e){return function(t,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var m=e.transformState,v=e.wrapperComponent,C=e.contentComponent;if(v&&C){var r=vo(t||m.scale,v,C);Tt(e,r,s,l)}}},Sd=function(e){return function(t,s,l,m){l===void 0&&(l=600),m===void 0&&(m="easeOut"),mt(e);var v=e.wrapperComponent,C=typeof t=="string"?document.getElementById(t):t;if(v&&C&&v.contains(C)){var r=pd(e,C,s);Tt(e,r,l,m)}}},Ms=function(e){return{instance:e,zoomIn:vd(e),zoomOut:gd(e),setTransform:_d(e),resetTransform:bd(e),centerView:xd(e),zoomToElement:Sd(e)}},Rr=function(e){return{instance:e,state:e.transformState}},De=function(e){var t={};return Object.assign(t,Rr(e)),Object.assign(t,Ms(e)),t},mr=!1;function pr(){try{var e={get passive(){return mr=!0,!1}};return e}catch{return mr=!1,mr}}var Ss=".".concat(kr.wrapperClass),Gs=function(e,t){return t.some(function(s){return e.matches("".concat(Ss," ").concat(s,", ").concat(Ss," .").concat(s,", ").concat(Ss," ").concat(s," *, ").concat(Ss," .").concat(s," *"))})},Dr=function(e){e&&clearTimeout(e)},yd=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},vo=function(e,t,s){var l=s.offsetWidth*e,m=s.offsetHeight*e,v=(t.offsetWidth-l)/2,C=(t.offsetHeight-m)/2;return{scale:e,positionX:v,positionY:C}};function Cd(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var wd=function(e,t){var s=e.setup.wheel,l=s.disabled,m=s.wheelDisabled,v=s.touchPadDisabled,C=s.excluded,r=e.isInitialized,i=e.isPanning,c=t.target,f=r&&!i&&!l&&c;if(!f||m&&!t.ctrlKey||v&&t.ctrlKey)return!1;var o=Gs(c,C);return!o},Ed=function(e){return e?e.deltaY<0?1:-1:0};function kd(e,t){var s=Ed(e),l=Fu(t,s);return l}function go(e,t,s){var l=t.getBoundingClientRect(),m=0,v=0;if("clientX"in e)m=(e.clientX-l.left)/s,v=(e.clientY-l.top)/s;else{var C=e.touches[0];m=(C.clientX-l.left)/s,v=(C.clientY-l.top)/s}return(Number.isNaN(m)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:m,y:v}}var Rd=function(e,t,s,l,m){var v=e.transformState.scale,C=e.wrapperComponent,r=e.setup,i=r.maxScale,c=r.minScale,f=r.zoomAnimation,o=r.disablePadding,p=f.size,S=f.disabled;if(!C)throw new Error("Wrapper is not mounted");var y=v+t*s,g=l?!1:!S,n=ps(ht(y,3),c,i,p,g&&!o);return n},Dd=function(e,t){var s=e.previousWheelEvent,l=e.transformState.scale,m=e.setup,v=m.maxScale,C=m.minScale;return s?l<v||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},Ad=function(e,t){var s=e.setup.pinch,l=s.disabled,m=s.excluded,v=e.isInitialized,C=t.target,r=v&&!l&&C;if(!r)return!1;var i=Gs(C,m);return!i},jd=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,m=s&&!t&&l;return!!m},Td=function(e,t,s){var l=s.getBoundingClientRect(),m=e.touches,v=ht(m[0].clientX-l.left,5),C=ht(m[0].clientY-l.top,5),r=ht(m[1].clientX-l.left,5),i=ht(m[1].clientY-l.top,5);return{x:(v+r)/2/t,y:(C+i)/2/t}},_o=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))},Ld=function(e,t){var s=e.pinchStartScale,l=e.pinchStartDistance,m=e.setup,v=m.maxScale,C=m.minScale,r=m.zoomAnimation,i=m.disablePadding,c=r.size,f=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 ps(ht(p,2),C,v,c,!f&&!i)},Md=160,Nd=100,Pd=function(e,t){var s=e.props,l=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(mt(e),je(De(e),t,l),je(De(e),t,m))},Od=function(e,t){var s=e.props,l=s.onWheel,m=s.onZoom,v=e.contentComponent,C=e.setup,r=e.transformState,i=r.scale,c=C.limitToBounds,f=C.centerZoomedOut,o=C.zoomAnimation,p=C.wheel,S=C.disablePadding,y=C.smooth,g=o.size,n=o.disabled,d=p.step,h=p.smoothStep;if(!v)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=kd(t,null),_=y?h*Math.abs(t.deltaY):d,x=Rd(e,u,_,!t.ctrlKey);if(i!==x){var w=Ot(e,x),E=go(t,v,i),b=n||g===0||f||S,R=c&&b,j=Vs(e,E.x,E.y,x,w,R),L=j.x,M=j.y;e.previousWheelEvent=t,e.setTransformState(x,L,M),je(De(e),t,l),je(De(e),t,m)}},Bd=function(e,t){var s=e.props,l=s.onWheelStop,m=s.onZoomStop;Dr(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ho(e,t.x,t.y),e.wheelAnimationTimer=null)},Nd);var v=Dd(e,t);v&&(Dr(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,je(De(e),t,l),je(De(e),t,m))},Md))},bo=function(e){for(var t=0,s=0,l=0;l<2;l+=1)t+=e.touches[l].clientX,s+=e.touches[l].clientY;var m=t/2,v=s/2;return{x:m,y:v}},Id=function(e,t){var s=_o(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=bo(t);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,mt(e)},Fd=function(e,t){var s=e.contentComponent,l=e.pinchStartDistance,m=e.wrapperComponent,v=e.transformState.scale,C=e.setup,r=C.limitToBounds,i=C.centerZoomedOut,c=C.zoomAnimation,f=C.alignmentAnimation,o=c.disabled,p=c.size;if(!(l===null||!s)){var S=Td(t,v,s);if(!(!Number.isFinite(S.x)||!Number.isFinite(S.y))){var y=_o(t),g=Ld(e,y),n=bo(t),d=n.x-(e.pinchLastCenterX||0),h=n.y-(e.pinchLastCenterY||0);if(!(g===v&&d===0&&h===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var u=Ot(e,g),_=o||p===0||i,x=r&&_,w=Vs(e,S.x,S.y,g,u,x),E=w.x,b=w.y;e.pinchMidpoint=S,e.lastDistance=y;var R=f.sizeX,j=f.sizeY,L=jt(e,R),M=jt(e,j),T=E+d,B=b+h,I=ms(T,B,u,r,L,M,m),H=I.x,W=I.y;e.setTransformState(g,H,W)}}}},Hd=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ho(e,t?.x,t?.y)},xo=function(e,t){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;Dr(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,je(De(e),t,s)},l)},zd=function(e,t){var s=e.props,l=s.onZoomStart,m=s.onZoom,v=e.setup.doubleClick,C=v.animationTime,r=v.animationType;je(De(e),t,l),po(e,C,r,function(){return je(De(e),t,m)}),xo(e,t)};function Wd(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function $d(e,t){var s=e.setup,l=e.doubleClickStopEventTimer,m=e.transformState,v=e.contentComponent,C=m.scale,r=e.props,i=r.onZoomStart,c=r.onZoom,f=s.doubleClick,o=f.disabled,p=f.mode,S=f.step,y=f.animationTime,g=f.animationType;if(!o&&!l){if(p==="reset")return zd(e,t);if(!v)return console.error("No ContentComponent found");var n=Wd(p,e.transformState.scale),d=fo(e,n,S);if(C!==d){je(De(e),t,i);var h=go(t,v,C),u=Vr(e,d,h.x,h.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");je(De(e),t,c),Tt(e,u,y,g),xo(e,t)}}}var Ud=function(e,t){var s=e.isInitialized,l=e.setup,m=e.wrapperComponent,v=l.doubleClick,C=v.disabled,r=v.excluded,i=t.target,c=m?.contains(i),f=s&&i&&c&&!C;if(!f)return!1;var o=Gs(i,r);return!o},qd=(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,Ot(s,s.transformState.scale),s.setup=$i(l)},this.initializeWindowEvents=function(){var l,m,v=pr(),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,v),r?.addEventListener("mousedown",s.onPanningStart,v),r?.addEventListener("mousemove",s.onPanning,v),r?.addEventListener("mouseup",s.onPanningStop,v),C?.addEventListener("mouseleave",s.clearPanning,v),r?.addEventListener("keyup",s.setKeyUnPressed,v),r?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var l,m,v=pr(),C=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=C?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,v),r?.removeEventListener("mousemove",s.onPanning,v),r?.removeEventListener("mouseup",s.onPanningStop,v),C?.removeEventListener("mouseleave",s.clearPanning,v),r?.removeEventListener("keyup",s.setKeyUnPressed,v),r?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),mt(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(l){var m=pr();l.addEventListener("wheel",s.onWheelZoom,m),l.addEventListener("dblclick",s.onDoubleClick,m),l.addEventListener("touchstart",s.onTouchPanningStart,m),l.addEventListener("touchmove",s.onTouchPanning,m),l.addEventListener("touchend",s.onTouchPanningStop,m)},this.handleInitialize=function(l,m){var v=!1,C=s.setup.centerOnInit,r=function(i,c){for(var f=0,o=i;f<o.length;f++){var p=o[f];if(p.target===c)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(i){i(De(s))}),s.observer=new ResizeObserver(function(i){if(r(i,l)||r(i,m))if(C&&!v){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(v=!0,s.setCenter())}else mt(s),Ot(s,s.transformState.scale),Yr(s,0)}),s.observer.observe(l),s.observer.observe(m)},this.onWheelZoom=function(l){var m=s.setup.disabled;if(!m){var v=wd(s,l);if(v){var C=s.isPressingKeys(s.setup.wheel.activationKeys);C&&(Pd(s,l),Od(s,l),Bd(s,l))}}},this.onWheelPanning=function(l){var m=s.setup,v=m.disabled,C=m.wheel,r=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!C.wheelDisabled||r.disabled||!r.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var i=s.transformState,c=i.positionX,f=i.positionY,o=c-l.deltaX,p=f-l.deltaY,S=r.lockAxisX?c:o,y=r.lockAxisY?f:p,g=s.setup.alignmentAnimation,n=g.sizeX,d=g.sizeY,h=jt(s,n),u=jt(s,d);S===c&&y===f||co(s,S,y,h,u)}},this.onPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Bi(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(),mt(s),Hi(s,l),je(De(s),l,v)))}}},this.onPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(!m){var C=Ii(s);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(l.preventDefault(),l.stopPropagation(),zi(s,l.clientX,l.clientY),je(De(s),l,v))}}},this.onPanningStop=function(l){var m=s.props.onPanningStop;s.isPanning&&(fd(s),je(De(s),l,m))},this.onPinchStart=function(l){var m=s.setup.disabled,v=s.props,C=v.onPinchingStart,r=v.onZoomStart;if(!m){var i=Ad(s,l);i&&(Id(s,l),mt(s),je(De(s),l,C),je(De(s),l,r))}},this.onPinch=function(l){var m=s.setup.disabled,v=s.props,C=v.onPinching,r=v.onZoom;if(!m){var i=jd(s);i&&(l.preventDefault(),l.stopPropagation(),Fd(s,l),je(De(s),l,C),je(De(s),l,r))}},this.onPinchStop=function(l){var m=s.props,v=m.onPinchingStop,C=m.onZoomStop;s.pinchStartScale&&(Hd(s),je(De(s),l,v),je(De(s),l,C))},this.onTouchPanningStart=function(l){var m=s.setup.disabled,v=s.props.onPanningStart;if(!m){var C=Bi(s,l);if(C){var r=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!r){s.lastTouch=+new Date,mt(s);var i=l.touches,c=i.length===1,f=i.length===2;c&&(mt(s),Hi(s,l),je(De(s),l,v)),f&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var m=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(m)return;var C=Ii(s);if(!C)return;l.preventDefault(),l.stopPropagation();var r=l.touches[0];zi(s,r.clientX,r.clientY),je(De(s),l,v)}else l.touches.length>1&&s.onPinch(l)},this.onTouchPanningStop=function(l){s.onPanningStop(l),s.onPinchStop(l)},this.onDoubleClick=function(l){var m=s.setup.disabled;if(!m){var v=Ud(s,l);v&&$d(s,l)}},this.clearPanning=function(l){s.isPanning&&s.onPanningStop(l)},this.setKeyPressed=function(l){s.pressedKeys[l.key]=!0},this.setKeyUnPressed=function(l){s.pressedKeys[l.key]=!1},this.isPressingKeys=function(l){return l.length?!!l.find(function(m){return s.pressedKeys[m]}):!0},this.setTransformState=function(l,m,v){var C=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(m)&&!Number.isNaN(v)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=m,s.transformState.positionY=v,s.applyTransformation();var r=De(s);s.onChangeCallbacks.forEach(function(i){return i(r)}),je(r,{scale:l,positionX:m,positionY:v},C)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=vo(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,m,v){return s.props.customTransform?s.props.customTransform(l,m,v):yd(l,m,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,m=l.scale,v=l.positionX,C=l.positionY,r=s.handleTransformStyles(v,C,m);s.contentComponent.style.transform=r}},this.getContext=function(){return De(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,Ot(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,m),s.initializeWindowEvents(),s.isInitialized=!0;var v=De(s);je(v,void 0,s.props.onInit)},this.props=t,this.setup=$i(this.props),this.transformState=uo(this.props)}return e})(),Qs=J.createContext(null),Kd=function(e,t){return typeof e=="function"?e(t):e},Xd=J.forwardRef(function(e,t){var s=k.useRef(new qd(e)).current,l=Kd(e.children,Ms(s));return k.useImperativeHandle(t,function(){return Ms(s)},[s]),k.useEffect(function(){s.update(e)},[s,e]),J.createElement(Qs.Provider,{value:s},l)});J.forwardRef(function(e,t){var s=k.useRef(null),l=k.useContext(Qs);return k.useEffect(function(){return l.onChange(function(m){if(s.current){var v=0,C=0;s.current.style.transform=l.handleTransformStyles(v,C,1/m.instance.transformState.scale)}})},[l]),J.createElement("div",At({},e,{ref:Cd([s,t])}))});function Yd(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 Vd=`.transform-component-module_wrapper__SPB86 {
32
32
  position: relative;
33
33
  width: -moz-fit-content;
34
34
  width: fit-content;
@@ -59,28 +59,28 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
59
59
  .transform-component-module_content__FBWxo img {
60
60
  pointer-events: none;
61
61
  }
62
- `,Ui={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Yd(Vd);var Gd=function(e){var t=e.children,s=e.wrapperClass,l=s===void 0?"":s,m=e.contentClass,v=m===void 0?"":m,C=e.wrapperStyle,r=e.contentStyle,i=e.wrapperProps,c=i===void 0?{}:i,f=e.contentProps,o=f===void 0?{}:f,p=k.useContext(Qs),S=p.init,y=p.cleanupWindowEvents,g=k.useRef(null),n=k.useRef(null);return k.useEffect(function(){var d=g.current,h=n.current;return d!==null&&h!==null&&S&&S?.(d,h),function(){y?.()}},[]),J.createElement("div",At({},c,{ref:g,className:"".concat(kr.wrapperClass," ").concat(Ui.wrapper," ").concat(l),style:C}),J.createElement("div",At({},o,{ref:n,className:"".concat(kr.contentClass," ").concat(Ui.content," ").concat(v),style:r}),t))},So=function(){var e=k.useContext(Qs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Qd=function(){var e=So();return Ms(e)};function Zd(e){var t=So(),s=k.useState(e(Rr(t))),l=s[0],m=s[1];return k.useEffect(function(){var v=!0,C=t.onChange(function(r){v&&m(e(Rr(r.instance)))});return function(){C(),v=!1}},[e,t]),l}function Jd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function ef(e,t){return ut({queryKey:oe.files.tree(e||"",t),queryFn:()=>ue.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function tf(e,t){return ut({queryKey:oe.files.content(e||"",t||""),queryFn:()=>ue.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function sf(e){const t=ze();return k.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function rf(){const e=ze();return Je({mutationFn:t=>ue.post("/files/write",t),onSuccess:(t,s)=>{const l=oe.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||Jd(s.path)})}})}function nf(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function of(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const af=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function lf(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&af.has(t)?Ir:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?rs:t==="json"?za:t==="md"||t==="mdx"||t==="txt"?En:Ra}const qi=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:v})=>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:v})]}),yo=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})=>{const{t:r}=he(),{data:i,isLoading:c,isError:f}=ef(e,t),o=k.useMemo(()=>i?.items??[],[i?.items]);return c?a.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:r("Loading...")}):f?a.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:r("Failed to load")}):a.jsx("div",{className:"space-y-0.5",children:o.map(p=>{if(p.type==="directory"){const d=nf(t,p.name),h=l.has(d);return a.jsxs("div",{children:[a.jsx(qi,{depth:s,onClick:()=>m(d),rightIcon:h?a.jsx(Ct,{size:14,className:"text-neutral-400"}):a.jsx(Ft,{size:14,className:"text-neutral-400"}),leftIcon:h?a.jsx(kn,{size:14,className:"text-amber-500"}):a.jsx(ka,{size:14,className:"text-amber-500"}),label:p.name}),h&&a.jsx(yo,{workingDir:e,path:d,depth:s+1,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})]},d)}const S=of(t,p.name),y=lf(p),g=C===S,n=y===Ir;return a.jsx(qi,{depth:s,active:g,onClick:()=>v(S),rightIcon:a.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?a.jsx(y,{size:14,className:n?"text-emerald-600":"text-sky-600"}):null,label:p.name},S)})})},cf=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const{t:v}=he(),[C,r]=k.useState(()=>new Set),i=sf(e),c=k.useCallback(f=>{r(o=>{const p=new Set(o);return p.has(f)?p.delete(f):p.add(f),p})},[]);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:v("Files")}),a.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||v("No working directory")})]}),a.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&a.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:v("Refresh file tree"),children:a.jsx(_l,{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:v("Collapse file tree"),children:a.jsx(cl,{size:13})})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?a.jsx(yo,{workingDir:e,path:"/",depth:0,expanded:C,toggleDir:c,onFileSelect:s,selectedFilePath:l}):a.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:v("No workspace selected.")})})]})},hf=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function uf(e){const t=e.split(".").pop()?.toLowerCase();return t?hf.has(t):!1}function df(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${l.toString()}`}const ff=({filePath:e})=>{const{t}=he(),{zoomIn:s,zoomOut:l,centerView:m}=Qd(),v=Zd(r=>r.state.scale),C=Math.round(v*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:()=>l(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom out"),children:a.jsx(Rl,{size:14})}),a.jsxs("button",{type:"button",onClick:()=>m(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:t("Reset zoom"),children:[C,"%"]}),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:t("Zoom in"),children:a.jsx(El,{size:14})}),a.jsx("button",{type:"button",onClick:()=>m(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:t("Fit to view"),children:a.jsx(nl,{size:13})}),a.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},mf=({workingDir:e,filePath:t})=>{const{t:s}=he(),[l,m]=k.useState(!1),v=df(e,t);return l?a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("Failed to load image.")}):a.jsx(Xd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx(ff,{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(Gd,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsx("img",{src:v,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function pf(e){const t=e.split("/");return t[t.length-1]||e}function vf(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 gf=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>{const{t:v}=he();return 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":v("Close tab"),title:v("Close"),children:a.jsx(Fs,{size:12})})]})},_f=({workingDir:e,className:t,readOnly:s=!1})=>{const{t:l}=he(),[m,v]=k.useState([]),[C,r]=k.useState(null),i=rf(),[c,f]=k.useState(280),[o,p]=k.useState(!1),[S,y]=k.useState(!1),g=k.useRef(280),n=k.useCallback(()=>{p(T=>(T?f(g.current):g.current=c,!T))},[c]),d=k.useCallback(T=>{T.preventDefault(),y(!0);const B=T.clientX,I=c,H=A=>{const N=A.clientX-B,P=Math.min(480,Math.max(160,I+N));f(P)},W=()=>{y(!1),document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",H),document.addEventListener("mouseup",W)},[c]);k.useEffect(()=>{v([]),r(null)},[e]);const h=k.useMemo(()=>m.find(T=>T.path===C)||null,[m,C]),{data:u,isFetching:_,isError:x,error:w}=tf(e,h?.isImage?null:C);k.useEffect(()=>{!C||!u||v(T=>T.map(B=>B.path!==C||B.isDirty||B.loaded?B:{...B,language:u.language||B.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[C,u]);const E=k.useCallback(T=>{v(B=>{if(B.find(W=>W.path===T))return B;const H=uf(T);return[...B,{path:T,name:pf(T),language:vf(T),content:"",savedContent:"",isDirty:!1,loaded:H,isImage:H}]}),r(T)},[]),b=k.useCallback(T=>{v(B=>{const I=B.filter(H=>H.path!==T);return r(H=>H!==T?H:I.length?I[I.length-1].path:null),I})},[]),R=k.useCallback(T=>{v(B=>B.map(I=>{if(I.path!==C)return I;const H=T!==I.savedContent;return{...I,content:T,isDirty:H}}))},[C]),j=k.useCallback(async()=>{s||!e||!h||(await i.mutateAsync({workingDir:e,path:h.path,content:h.content}),v(T=>T.map(B=>B.path===h.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[h,s,i,e]),L=k.useRef(()=>{});k.useEffect(()=>{L.current=()=>{j().catch(()=>{})}},[j]),k.useEffect(()=>{const T=B=>{s||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),L.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[s]);const M=k.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{L.current()})},[]);return a.jsxs("div",{className:Se("flex h-full overflow-hidden bg-white",t),style:S?{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:o?36:c,transition:S?"none":"width 0.15s ease"},children:o?a.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:a.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:l("Expand file tree"),children:a.jsx(ul,{size:16})})}):a.jsx(a.Fragment,{children:a.jsx(cf,{workingDir:e,onFileSelect:E,selectedFilePath:h?.path||null,onCollapse:n},e||"no-working-dir")})}),!o&&a.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",S?"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:[m.length===0?a.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:l("No open files")}):m.map(T=>a.jsx(gf,{active:T.path===C,name:T.name,isDirty:T.isDirty,onClick:()=>r(T.path),onClose:B=>{B.stopPropagation(),b(T.path)}},T.path)),a.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[s&&a.jsx("span",{className:"text-[11px] text-neutral-400",children:l("Read-only")}),i.isPending&&a.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),l("Saving")]}),h?.isDirty&&!i.isPending&&a.jsx("span",{className:"text-[11px] text-amber-600",children:l("Unsaved")})]})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:e?h?h.isImage?a.jsx(mf,{workingDir:e,filePath:h.path}):a.jsxs(a.Fragment,{children:[a.jsx(Iu,{path:h.path,value:h.content,language:h.language,theme:"vs-light",height:"100%",onChange:s?void 0:T=>R(T??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:s}}),_&&!h.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(Ue,{size:14,className:"animate-spin"}),l("Loading file...")]})}),x&&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:[l("Failed to load file"),w instanceof Error?`: ${w.message}`:""]})]}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("Select a file from the tree to open.")}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("No workspace selected.")})})]})]})};function Co(e){return ut({queryKey:oe.git.changes(e||""),queryFn:()=>ue.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function wo(e,t,s){return ut({queryKey:oe.git.diff(e||"",t||"",s),queryFn:()=>ue.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function Eo(e,t){return ut({queryKey:oe.git.commitFiles(e||"",t||""),queryFn:()=>ue.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function ko(e,t,s){return ut({queryKey:oe.git.commitDiff(e||"",t||"",s||""),queryFn:()=>ue.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ki={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"},bf={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function xf(e){const t=e.split("/");return t[t.length-1]||e}function Sf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const yf=({entry:e,selected:t,onClick:s})=>{const{t:l}=he(),m=Ki[e.status]||Ki.M,v=bf[e.status]||e.status,C=Sf(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",m),title:l(v),children:e.status}),a.jsx("span",{className:"text-xs text-neutral-900 truncate",children:xf(e.path)}),C&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:C})]})},Xi=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>{const{t:v}=he();return 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:v(e)}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),a.jsx("div",{className:"space-y-0.5",children:t.map(C=>{const r=`${s}:${C.path}`;return a.jsx(yf,{entry:C,selected:l===r,onClick:()=>m(C.path,s)},r)})})]})},Cf=({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})]})},wf=({workingDir:e,filePath:t,type:s})=>{const{t:l}=he(),{data:m,isLoading:v,isError:C}=wo(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:l("No diff content available.")});const i=r.split(`
62
+ `,Ui={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Yd(Vd);var Gd=function(e){var t=e.children,s=e.wrapperClass,l=s===void 0?"":s,m=e.contentClass,v=m===void 0?"":m,C=e.wrapperStyle,r=e.contentStyle,i=e.wrapperProps,c=i===void 0?{}:i,f=e.contentProps,o=f===void 0?{}:f,p=k.useContext(Qs),S=p.init,y=p.cleanupWindowEvents,g=k.useRef(null),n=k.useRef(null);return k.useEffect(function(){var d=g.current,h=n.current;return d!==null&&h!==null&&S&&S?.(d,h),function(){y?.()}},[]),J.createElement("div",At({},c,{ref:g,className:"".concat(kr.wrapperClass," ").concat(Ui.wrapper," ").concat(l),style:C}),J.createElement("div",At({},o,{ref:n,className:"".concat(kr.contentClass," ").concat(Ui.content," ").concat(v),style:r}),t))},So=function(){var e=k.useContext(Qs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Qd=function(){var e=So();return Ms(e)};function Zd(e){var t=So(),s=k.useState(e(Rr(t))),l=s[0],m=s[1];return k.useEffect(function(){var v=!0,C=t.onChange(function(r){v&&m(e(Rr(r.instance)))});return function(){C(),v=!1}},[e,t]),l}function Jd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function ef(e,t){return ut({queryKey:oe.files.tree(e||"",t),queryFn:()=>ue.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function tf(e,t){return ut({queryKey:oe.files.content(e||"",t||""),queryFn:()=>ue.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function sf(e){const t=ze();return k.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function rf(){const e=ze();return Je({mutationFn:t=>ue.post("/files/write",t),onSuccess:(t,s)=>{const l=oe.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||Jd(s.path)})}})}function nf(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function of(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const af=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function lf(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&af.has(t)?Ir:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?rs:t==="json"?za:t==="md"||t==="mdx"||t==="txt"?En:wa}const qi=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:v})=>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:v})]}),yo=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})=>{const{t:r}=he(),{data:i,isLoading:c,isError:f}=ef(e,t),o=k.useMemo(()=>i?.items??[],[i?.items]);return c?a.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:r("Loading...")}):f?a.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:r("Failed to load")}):a.jsx("div",{className:"space-y-0.5",children:o.map(p=>{if(p.type==="directory"){const d=nf(t,p.name),h=l.has(d);return a.jsxs("div",{children:[a.jsx(qi,{depth:s,onClick:()=>m(d),rightIcon:h?a.jsx(Ct,{size:14,className:"text-neutral-400"}):a.jsx(It,{size:14,className:"text-neutral-400"}),leftIcon:h?a.jsx(kn,{size:14,className:"text-amber-500"}):a.jsx(Ca,{size:14,className:"text-amber-500"}),label:p.name}),h&&a.jsx(yo,{workingDir:e,path:d,depth:s+1,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})]},d)}const S=of(t,p.name),y=lf(p),g=C===S,n=y===Ir;return a.jsx(qi,{depth:s,active:g,onClick:()=>v(S),rightIcon:a.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?a.jsx(y,{size:14,className:n?"text-emerald-600":"text-sky-600"}):null,label:p.name},S)})})},cf=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const{t:v}=he(),[C,r]=k.useState(()=>new Set),i=sf(e),c=k.useCallback(f=>{r(o=>{const p=new Set(o);return p.has(f)?p.delete(f):p.add(f),p})},[]);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:v("Files")}),a.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||v("No working directory")})]}),a.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&a.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:v("Refresh file tree"),children:a.jsx(_l,{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:v("Collapse file tree"),children:a.jsx(cl,{size:13})})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?a.jsx(yo,{workingDir:e,path:"/",depth:0,expanded:C,toggleDir:c,onFileSelect:s,selectedFilePath:l}):a.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:v("No workspace selected.")})})]})},hf=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function uf(e){const t=e.split(".").pop()?.toLowerCase();return t?hf.has(t):!1}function df(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${l.toString()}`}const ff=({filePath:e})=>{const{t}=he(),{zoomIn:s,zoomOut:l,centerView:m}=Qd(),v=Zd(r=>r.state.scale),C=Math.round(v*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:()=>l(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom out"),children:a.jsx(Rl,{size:14})}),a.jsxs("button",{type:"button",onClick:()=>m(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:t("Reset zoom"),children:[C,"%"]}),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:t("Zoom in"),children:a.jsx(El,{size:14})}),a.jsx("button",{type:"button",onClick:()=>m(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:t("Fit to view"),children:a.jsx(nl,{size:13})}),a.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},mf=({workingDir:e,filePath:t})=>{const{t:s}=he(),[l,m]=k.useState(!1),v=df(e,t);return l?a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:s("Failed to load image.")}):a.jsx(Xd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx(ff,{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(Gd,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsx("img",{src:v,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function pf(e){const t=e.split("/");return t[t.length-1]||e}function vf(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 gf=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>{const{t:v}=he();return 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":v("Close tab"),title:v("Close"),children:a.jsx(Fs,{size:12})})]})},_f=({workingDir:e,className:t,readOnly:s=!1})=>{const{t:l}=he(),[m,v]=k.useState([]),[C,r]=k.useState(null),i=rf(),[c,f]=k.useState(280),[o,p]=k.useState(!1),[S,y]=k.useState(!1),g=k.useRef(280),n=k.useCallback(()=>{p(T=>(T?f(g.current):g.current=c,!T))},[c]),d=k.useCallback(T=>{T.preventDefault(),y(!0);const B=T.clientX,I=c,H=A=>{const N=A.clientX-B,P=Math.min(480,Math.max(160,I+N));f(P)},W=()=>{y(!1),document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",H),document.addEventListener("mouseup",W)},[c]);k.useEffect(()=>{v([]),r(null)},[e]);const h=k.useMemo(()=>m.find(T=>T.path===C)||null,[m,C]),{data:u,isFetching:_,isError:x,error:w}=tf(e,h?.isImage?null:C);k.useEffect(()=>{!C||!u||v(T=>T.map(B=>B.path!==C||B.isDirty||B.loaded?B:{...B,language:u.language||B.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[C,u]);const E=k.useCallback(T=>{v(B=>{if(B.find(W=>W.path===T))return B;const H=uf(T);return[...B,{path:T,name:pf(T),language:vf(T),content:"",savedContent:"",isDirty:!1,loaded:H,isImage:H}]}),r(T)},[]),b=k.useCallback(T=>{v(B=>{const I=B.filter(H=>H.path!==T);return r(H=>H!==T?H:I.length?I[I.length-1].path:null),I})},[]),R=k.useCallback(T=>{v(B=>B.map(I=>{if(I.path!==C)return I;const H=T!==I.savedContent;return{...I,content:T,isDirty:H}}))},[C]),j=k.useCallback(async()=>{s||!e||!h||(await i.mutateAsync({workingDir:e,path:h.path,content:h.content}),v(T=>T.map(B=>B.path===h.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[h,s,i,e]),L=k.useRef(()=>{});k.useEffect(()=>{L.current=()=>{j().catch(()=>{})}},[j]),k.useEffect(()=>{const T=B=>{s||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),L.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[s]);const M=k.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{L.current()})},[]);return a.jsxs("div",{className:Se("flex h-full overflow-hidden bg-white",t),style:S?{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:o?36:c,transition:S?"none":"width 0.15s ease"},children:o?a.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:a.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:l("Expand file tree"),children:a.jsx(ul,{size:16})})}):a.jsx(a.Fragment,{children:a.jsx(cf,{workingDir:e,onFileSelect:E,selectedFilePath:h?.path||null,onCollapse:n},e||"no-working-dir")})}),!o&&a.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",S?"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:[m.length===0?a.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:l("No open files")}):m.map(T=>a.jsx(gf,{active:T.path===C,name:T.name,isDirty:T.isDirty,onClick:()=>r(T.path),onClose:B=>{B.stopPropagation(),b(T.path)}},T.path)),a.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[s&&a.jsx("span",{className:"text-[11px] text-neutral-400",children:l("Read-only")}),i.isPending&&a.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),l("Saving")]}),h?.isDirty&&!i.isPending&&a.jsx("span",{className:"text-[11px] text-amber-600",children:l("Unsaved")})]})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:e?h?h.isImage?a.jsx(mf,{workingDir:e,filePath:h.path}):a.jsxs(a.Fragment,{children:[a.jsx(Iu,{path:h.path,value:h.content,language:h.language,theme:"vs-light",height:"100%",onChange:s?void 0:T=>R(T??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:s}}),_&&!h.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(Ue,{size:14,className:"animate-spin"}),l("Loading file...")]})}),x&&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:[l("Failed to load file"),w instanceof Error?`: ${w.message}`:""]})]}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("Select a file from the tree to open.")}):a.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:l("No workspace selected.")})})]})]})};function Co(e){return ut({queryKey:oe.git.changes(e||""),queryFn:()=>ue.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function wo(e,t,s){return ut({queryKey:oe.git.diff(e||"",t||"",s),queryFn:()=>ue.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function Eo(e,t){return ut({queryKey:oe.git.commitFiles(e||"",t||""),queryFn:()=>ue.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function ko(e,t,s){return ut({queryKey:oe.git.commitDiff(e||"",t||"",s||""),queryFn:()=>ue.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ki={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"},bf={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function xf(e){const t=e.split("/");return t[t.length-1]||e}function Sf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const yf=({entry:e,selected:t,onClick:s})=>{const{t:l}=he(),m=Ki[e.status]||Ki.M,v=bf[e.status]||e.status,C=Sf(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",m),title:l(v),children:e.status}),a.jsx("span",{className:"text-xs text-neutral-900 truncate",children:xf(e.path)}),C&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:C})]})},Xi=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>{const{t:v}=he();return 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:v(e)}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),a.jsx("div",{className:"space-y-0.5",children:t.map(C=>{const r=`${s}:${C.path}`;return a.jsx(yf,{entry:C,selected:l===r,onClick:()=>m(C.path,s)},r)})})]})},Cf=({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})]})},wf=({workingDir:e,filePath:t,type:s})=>{const{t:l}=he(),{data:m,isLoading:v,isError:C}=wo(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:l("No diff content available.")});const i=r.split(`
63
63
  `);return a.jsx("div",{className:"flex-1 overflow-auto font-mono text-xs leading-5",children:i.map((c,f)=>a.jsx(Cf,{line:c,lineNum:f+1},f))})},Ef=({workingDir:e})=>{const{t}=he(),{data:s,isLoading:l,isError:m}=Co(e),[v,C]=k.useState(null),[r,i]=k.useState(260),[c,f]=k.useState(!1),o=k.useCallback(d=>{d.preventDefault(),f(!0);const h=d.clientX,u=r,_=w=>{const E=w.clientX-h,b=Math.min(480,Math.max(160,u+E));i(b)},x=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",x)},[r]),p=v?`${v.type}:${v.path}`:null,S=(d,h)=>{C({path:d,type:h})};if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load changes.")});const y=s?.uncommitted||[],g=s?.committed||[],n=y.length+g.length;return a.jsxs("div",{className:"flex h-full bg-white",style:c?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:r},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(is,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("Changes")}),n>0&&a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n})]})}),a.jsx("div",{className:"flex-1 overflow-auto p-1.5",children:n===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[a.jsx(is,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:t("No pending changes")})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Xi,{title:"Uncommitted",entries:y,type:"uncommitted",selectedKey:p,onSelect:S}),a.jsx(Xi,{title:"Committed",entries:g,type:"committed",selectedKey:p,onSelect:S})]})})]}),a.jsx("div",{onMouseDown:o,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",c?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?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(rs,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:v.path}),a.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",t(v.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),a.jsx(wf,{workingDir:e,filePath:v.path,type:v.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(rs,{size:28}),a.jsx("span",{className:"text-xs",children:t("Select a file to view diff")})]})})})]})},vr=50,Yi={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 kf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Rt("{count}s ago",{count:s}):s<3600?Rt("{count}m ago",{count:Math.floor(s/60)}):s<86400?Rt("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Rt("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Rf(e){const t=e.split("/");return t[t.length-1]||e}function Df(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Af=`
64
64
  .history-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
65
65
  .history-scroll::-webkit-scrollbar-track { background: transparent; }
66
66
  .history-scroll::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 2px; }
67
67
  .history-scroll::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }
68
68
  `,jf=({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})]})},Tf=({workingDir:e,hash:t,filePath:s})=>{const{t:l}=he(),{data:m,isLoading:v,isError:C}=ko(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:l("No diff content available.")});const i=r.split(`
69
- `);return a.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:i.map((c,f)=>a.jsx(jf,{line:c,lineNum:f+1},f))})},Lf=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{t:m}=he(),{data:v,isLoading:C}=Eo(e,t);if(C)return a.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),a.jsx("span",{children:m("Loading...")})]});const r=v?.files||[];return r.length===0?a.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):a.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:r.map(i=>{const c=Yi[i.status]||Yi.M,f=Df(i.path);return a.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),l(i.path)},className:Se("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===i.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",c),children:i.status}),a.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:Rf(i.path)}),f&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},i.path)})})},Mf=({workingDir:e})=>{const{t}=he(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:x=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(vr),skip:String(x)}}),initialPageParam:0,getNextPageParam:(x,w)=>x.commits.length<vr?void 0:w.length*vr,enabled:!!e}),i=s?.pages.flatMap(x=>x.commits)||[],[c,f]=k.useState(null),[o,p]=k.useState(null),[S,y]=k.useState(280),[g,n]=k.useState(!1),d=k.useCallback(x=>{x.preventDefault(),n(!0);const w=x.clientX,E=S,b=j=>{const L=Math.min(480,Math.max(180,E+(j.clientX-w)));y(L)},R=()=>{n(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",R)},[S]),h=x=>{c===x?(f(null),p(null)):(f(x),p(null))},u=k.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:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(i.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(Ut,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:t("No commit history")})]});const _=i.find(x=>x.hash===c);return a.jsxs("div",{className:"flex h-full bg-white",style:g?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsx("style",{children:Af}),a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:S},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(Ut,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:i.length})]})}),a.jsxs("div",{ref:u,className:"flex-1 overflow-auto history-scroll p-1.5",children:[i.map(x=>{const w=c===x.hash;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>h(x.hash),className:Se("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",w?"bg-blue-50":"hover:bg-neutral-50"),children:[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",w?"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:x.shortHash}),a.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:x.message}),a.jsx(Ft,{size:12,className:Se("shrink-0 text-neutral-400 transition-transform",w&&"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:x.author}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:kf(x.timestamp)})]})]})]}),w&&a.jsxs(a.Fragment,{children:[x.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:x.body}),a.jsx(Lf,{workingDir:e,hash:x.hash,selectedPath:o,onSelectFile:p})]})]},x.hash)}),C&&a.jsx("button",{type:"button",onClick:()=>v(),disabled:r,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:r?a.jsxs(a.Fragment,{children:[a.jsx(Ue,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),a.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",g?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:o&&c?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(rs,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:o}),a.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",_?.shortHash,")"]})]}),a.jsx(Tf,{workingDir:e,hash:c,filePath:o})]}):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(rs,{size:28}),a.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Nf=[{key:"changes",label:"Changes",icon:a.jsx(is,{size:14})},{key:"history",label:"History",icon:a.jsx(Ut,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(zs,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(Es,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Is,{size:14})}],Pf=[{key:"history",label:"History",icon:a.jsx(Ut,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(zs,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(Es,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Is,{size:14})}],Of=({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})]}),Bf=({icon:e,title:t})=>{const{t:s}=he();return 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:s(t)}),a.jsx("span",{className:"text-xs",children:s("Coming soon...")})]})})},Ro=J.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:v,readOnly:C,repoDeleted:r}){const{t:i}=he(),c=k.useMemo(()=>{const d=v?Pf:Nf;return C?d.filter(h=>h.key!=="terminal"):d},[v,C]),[f,o]=k.useState(v?"history":"changes"),{data:p}=Sa(m??""),S=k.useMemo(()=>{if(!p?.quickCommands)return[];try{return JSON.parse(p.quickCommands)}catch{return[]}},[p?.quickCommands]),[y,g]=k.useState([]),n=k.useRef(void 0);return k.useEffect(()=>{l&&l!==n.current&&(n.current=l,g(d=>d.includes(l)?d:[...d,l]))},[l]),k.useEffect(()=>{C&&f==="terminal"&&o(v?"history":"changes")},[f,v,C]),a.jsxs("div",{className:Se("flex flex-col h-full bg-white",t),children:[C&&a.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:i(r?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),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(d=>a.jsx(Of,{active:f===d.key,onClick:()=>o(d.key),icon:d.icon,label:i(d.label)},d.key))}),a.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[f==="editor"&&a.jsx(_f,{workingDir:l,readOnly:C}),y.map(d=>a.jsx("div",{className:"h-full absolute inset-0",style:{display:f==="terminal"&&l===d?"block":"none"},children:a.jsx(Ah,{cwd:d,quickCommands:S})},d)),f==="preview"&&a.jsx(Bf,{icon:a.jsx(Is,{size:32}),title:"Preview"}),f==="changes"&&a.jsx(Ef,{workingDir:l}),f==="history"&&a.jsx(Mf,{workingDir:l})]})]})});function Do(e){return ut({queryKey:oe.workspaces.list(e),queryFn:()=>ue.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Ao(e){const t=ze();return Je({mutationFn:s=>ue.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.workspaces.list(e)}),t.invalidateQueries({queryKey:oe.tasks.all})}})}function If(){const e=ze();return Je({mutationFn:({id:t,commitMessage:s})=>ue.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Ff(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Gr(){return Je({mutationFn:({workspaceId:e,editorType:t})=>ue.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function jo(e){return ut({queryKey:oe.workspaces.gitStatus(e),queryFn:()=>ue.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Hf(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}function zf(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}const Vi=1500,Wf=3e3;function $f(e){const[t,s]=k.useState(null),l=k.useRef(0),m=k.useRef(null),v=k.useRef(null);return k.useEffect(()=>{if(!e)return;const C=()=>{v.current&&(clearTimeout(v.current),v.current=null)},r=kt.connect();r.emit(Pt.SUBSCRIBE,{topic:"task",id:e},f=>{});const i=f=>{s(f),v.current=setTimeout(()=>s(null),Wf)},c=f=>{if(f.taskId!==e)return;const o={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){C(),m.current=null,l.current===0&&(l.current=Date.now()),s(o);return}const p=l.current>0?Date.now()-l.current:0,S=Vi-p;l.current===0?(l.current=Date.now(),s({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=o,v.current=setTimeout(()=>i(o),Vi)):S>0?(m.current=o,C(),v.current=setTimeout(()=>i(o),S)):i(o)};return r.on(Ve.WORKSPACE_SETUP_PROGRESS,c),()=>{r.off(Ve.WORKSPACE_SETUP_PROGRESS,c),C(),l.current=0,m.current=null}},[e]),t}function Qr(){const e=ze();return Je({mutationFn:t=>ue.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function To(){const e=ze();return Je({mutationFn:t=>ue.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)})}})}function Zr(){const e=ze();return Je({mutationFn:({id:t,message:s,providerId:l})=>ue.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Uf(e,t){const s={};return ut({queryKey:oe.tasks.list(e,t),queryFn:()=>ue.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function qf(e){const t=ze();return Je({mutationFn:s=>ue.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.tasks.list(e)}),t.invalidateQueries({queryKey:oe.tasks.stats(e)})}})}function Kf(){const e=ze();return Je({mutationFn:({id:t,status:s})=>ue.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function Xf(){const e=ze();return Je({mutationFn:t=>ue.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tasks.all})}})}function Yf(){const e=ze();return Je({mutationFn:t=>ue.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function Lo(e,t){return k.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 Vf="/api";async function Gf(e){const t=new FormData;t.append("file",e);const s=await fetch(`${Vf}/attachments/upload`,{method:"POST",body:t});if(!s.ok){const l=await s.json().catch(()=>({}));throw new Error(l.error||`Upload failed (${s.status})`)}return s.json()}let Qf=0;function Jr(){const[e,t]=k.useState([]),s=k.useRef(e);s.current=e;const l=k.useCallback(async c=>{const f=c.map(o=>({tempId:`tmp-${++Qf}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...f]),await Promise.allSettled(f.map(async o=>{try{const p=await Gf(o.file);t(S=>S.map(y=>y.tempId===o.tempId?{...y,status:"done",progress:100,attachment:p}:y))}catch(p){t(S=>S.map(y=>y.tempId===o.tempId?{...y,status:"error",error:p instanceof Error?p.message:"Upload failed"}:y))}}))},[]),m=k.useCallback(c=>{t(f=>f.filter(o=>o.tempId!==c))},[]),v=k.useCallback(()=>{t([])},[]),C=k.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const o=f.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
69
+ `);return a.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:i.map((c,f)=>a.jsx(jf,{line:c,lineNum:f+1},f))})},Lf=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{t:m}=he(),{data:v,isLoading:C}=Eo(e,t);if(C)return a.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),a.jsx("span",{children:m("Loading...")})]});const r=v?.files||[];return r.length===0?a.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):a.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:r.map(i=>{const c=Yi[i.status]||Yi.M,f=Df(i.path);return a.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),l(i.path)},className:Se("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===i.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",c),children:i.status}),a.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:Rf(i.path)}),f&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},i.path)})})},Mf=({workingDir:e})=>{const{t}=he(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:x=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(vr),skip:String(x)}}),initialPageParam:0,getNextPageParam:(x,w)=>x.commits.length<vr?void 0:w.length*vr,enabled:!!e}),i=s?.pages.flatMap(x=>x.commits)||[],[c,f]=k.useState(null),[o,p]=k.useState(null),[S,y]=k.useState(280),[g,n]=k.useState(!1),d=k.useCallback(x=>{x.preventDefault(),n(!0);const w=x.clientX,E=S,b=j=>{const L=Math.min(480,Math.max(180,E+(j.clientX-w)));y(L)},R=()=>{n(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",R)},[S]),h=x=>{c===x?(f(null),p(null)):(f(x),p(null))},u=k.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:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(i.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(Ut,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:t("No commit history")})]});const _=i.find(x=>x.hash===c);return a.jsxs("div",{className:"flex h-full bg-white",style:g?{userSelect:"none",cursor:"col-resize"}:void 0,children:[a.jsx("style",{children:Af}),a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:S},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(Ut,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:i.length})]})}),a.jsxs("div",{ref:u,className:"flex-1 overflow-auto history-scroll p-1.5",children:[i.map(x=>{const w=c===x.hash;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>h(x.hash),className:Se("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",w?"bg-blue-50":"hover:bg-neutral-50"),children:[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",w?"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:x.shortHash}),a.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:x.message}),a.jsx(It,{size:12,className:Se("shrink-0 text-neutral-400 transition-transform",w&&"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:x.author}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:kf(x.timestamp)})]})]})]}),w&&a.jsxs(a.Fragment,{children:[x.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:x.body}),a.jsx(Lf,{workingDir:e,hash:x.hash,selectedPath:o,onSelectFile:p})]})]},x.hash)}),C&&a.jsx("button",{type:"button",onClick:()=>v(),disabled:r,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:r?a.jsxs(a.Fragment,{children:[a.jsx(Ue,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),a.jsx("div",{onMouseDown:d,className:Se("w-1 shrink-0 cursor-col-resize transition-colors",g?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),a.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:o&&c?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(rs,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:o}),a.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",_?.shortHash,")"]})]}),a.jsx(Tf,{workingDir:e,hash:c,filePath:o})]}):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(rs,{size:28}),a.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Nf=[{key:"changes",label:"Changes",icon:a.jsx(is,{size:14})},{key:"history",label:"History",icon:a.jsx(Ut,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(zs,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(Es,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Is,{size:14})}],Pf=[{key:"history",label:"History",icon:a.jsx(Ut,{size:14})},{key:"editor",label:"Editor",icon:a.jsx(zs,{size:14})},{key:"terminal",label:"Terminal",icon:a.jsx(Es,{size:14})},{key:"preview",label:"Preview",icon:a.jsx(Is,{size:14})}],Of=({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})]}),Bf=({icon:e,title:t})=>{const{t:s}=he();return 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:s(t)}),a.jsx("span",{className:"text-xs",children:s("Coming soon...")})]})})},Ro=J.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:v,readOnly:C,repoDeleted:r}){const{t:i}=he(),c=k.useMemo(()=>{const d=v?Pf:Nf;return C?d.filter(h=>h.key!=="terminal"):d},[v,C]),[f,o]=k.useState(v?"history":"changes"),{data:p}=Ea(m??""),S=k.useMemo(()=>{if(!p?.quickCommands)return[];try{return JSON.parse(p.quickCommands)}catch{return[]}},[p?.quickCommands]),[y,g]=k.useState([]),n=k.useRef(void 0);return k.useEffect(()=>{l&&l!==n.current&&(n.current=l,g(d=>d.includes(l)?d:[...d,l]))},[l]),k.useEffect(()=>{C&&f==="terminal"&&o(v?"history":"changes")},[f,v,C]),a.jsxs("div",{className:Se("flex flex-col h-full bg-white",t),children:[C&&a.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:i(r?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),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(d=>a.jsx(Of,{active:f===d.key,onClick:()=>o(d.key),icon:d.icon,label:i(d.label)},d.key))}),a.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[f==="editor"&&a.jsx(_f,{workingDir:l,readOnly:C}),y.map(d=>a.jsx("div",{className:"h-full absolute inset-0",style:{display:f==="terminal"&&l===d?"block":"none"},children:a.jsx(Ah,{cwd:d,quickCommands:S})},d)),f==="preview"&&a.jsx(Bf,{icon:a.jsx(Is,{size:32}),title:"Preview"}),f==="changes"&&a.jsx(Ef,{workingDir:l}),f==="history"&&a.jsx(Mf,{workingDir:l})]})]})});function Do(e){return ut({queryKey:oe.workspaces.list(e),queryFn:()=>ue.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Ao(e){const t=ze();return Je({mutationFn:s=>ue.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.workspaces.list(e)}),t.invalidateQueries({queryKey:oe.tasks.all})}})}function If(){const e=ze();return Je({mutationFn:({id:t,commitMessage:s})=>ue.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Ff(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Gr(){return Je({mutationFn:({workspaceId:e,editorType:t})=>ue.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function jo(e){return ut({queryKey:oe.workspaces.gitStatus(e),queryFn:()=>ue.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Hf(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}function zf(){const e=ze();return Je({mutationFn:t=>ue.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(s)})}})}const Vi=1500,Wf=3e3;function $f(e){const[t,s]=k.useState(null),l=k.useRef(0),m=k.useRef(null),v=k.useRef(null);return k.useEffect(()=>{if(!e)return;const C=()=>{v.current&&(clearTimeout(v.current),v.current=null)},r=kt.connect(),i=f=>{s(f),v.current=setTimeout(()=>s(null),Wf)},c=f=>{if(f.taskId!==e)return;const o={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){C(),m.current=null,l.current===0&&(l.current=Date.now()),s(o);return}const p=l.current>0?Date.now()-l.current:0,S=Vi-p;l.current===0?(l.current=Date.now(),s({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=o,v.current=setTimeout(()=>i(o),Vi)):S>0?(m.current=o,C(),v.current=setTimeout(()=>i(o),S)):i(o)};return r.on(Ve.WORKSPACE_SETUP_PROGRESS,c),()=>{r.off(Ve.WORKSPACE_SETUP_PROGRESS,c),C(),l.current=0,m.current=null}},[e]),t}function Qr(){const e=ze();return Je({mutationFn:t=>ue.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function To(){const e=ze();return Je({mutationFn:t=>ue.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:oe.sessions.detail(s)})}})}function Zr(){const e=ze();return Je({mutationFn:({id:t,message:s,providerId:l})=>ue.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Uf(e,t){const s={};return ut({queryKey:oe.tasks.list(e,t),queryFn:()=>ue.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function qf(e){const t=ze();return Je({mutationFn:s=>ue.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:oe.tasks.list(e)}),t.invalidateQueries({queryKey:oe.tasks.stats(e)})}})}function Kf(){const e=ze();return Je({mutationFn:({id:t,status:s})=>ue.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function Xf(){const e=ze();return Je({mutationFn:t=>ue.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tasks.all})}})}function Yf(){const e=ze();return Je({mutationFn:t=>ue.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.detail(t.id)})}})}function Lo(e,t){return k.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 Vf="/api";async function Gf(e){const t=new FormData;t.append("file",e);const s=await fetch(`${Vf}/attachments/upload`,{method:"POST",body:t});if(!s.ok){const l=await s.json().catch(()=>({}));throw new Error(l.error||`Upload failed (${s.status})`)}return s.json()}let Qf=0;function Jr(){const[e,t]=k.useState([]),s=k.useRef(e);s.current=e;const l=k.useCallback(async c=>{const f=c.map(o=>({tempId:`tmp-${++Qf}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...f]),await Promise.allSettled(f.map(async o=>{try{const p=await Gf(o.file);t(S=>S.map(y=>y.tempId===o.tempId?{...y,status:"done",progress:100,attachment:p}:y))}catch(p){t(S=>S.map(y=>y.tempId===o.tempId?{...y,status:"error",error:p instanceof Error?p.message:"Upload failed"}:y))}}))},[]),m=k.useCallback(c=>{t(f=>f.filter(o=>o.tempId!==c))},[]),v=k.useCallback(()=>{t([])},[]),C=k.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const o=f.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
70
70
  `)},[]),r=e.length>0,i=e.some(c=>c.status==="uploading");return{files:e,addFiles:l,removeFile:m,clear:v,buildMarkdownLinks:C,hasFiles:r,isUploading:i}}const Zf="/api";function Jf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Ns({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(em,{item:s,onRemove:t},s.tempId))})}function em({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:`${Zf}${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(Ue,{size:16,className:"animate-spin text-neutral-400"}):s?a.jsx(Ir,{size:16,className:"text-neutral-400"}):a.jsx(En,{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:Jf(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(Fs,{size:10})})]})}function Mo({isOpen:e,onClose:t,taskId:s,taskTitle:l,taskDescription:m}){const{t:v}=he(),[C,r]=k.useState(""),[i,c]=k.useState(""),[f,o]=k.useState("idle"),[p,S]=k.useState(null),y=ze(),g=Ao(s),n=Qr(),{data:d,isLoading:h}=Hs();k.useEffect(()=>{if(!e||!d)return;const w=d.find(E=>E.availability.type!=="NOT_FOUND");w&&r(w.provider.id)},[e,d]),k.useEffect(()=>{if(e){const w=[l];m&&w.push(m),c(w.join(`
71
71
 
72
72
  `)),o("idle"),S(null)}},[e,l,m]);const u=f!=="idle",_=async()=>{if(!(!C||!i.trim())){S(null);try{o("creating-workspace");const w=await g.mutateAsync({});o("creating-session");const E=await ue.post(`/workspaces/${w.id}/sessions`,{providerId:C,prompt:i.trim()});o("starting-session"),await n.mutateAsync(E.id),await y.invalidateQueries({queryKey:oe.workspaces.list(s)}),o("idle"),t()}catch(w){o("idle"),S(w instanceof Error?w.message:v("启动失败,请重试"))}}},x={idle:v("启动"),"creating-workspace":v("创建工作空间..."),"creating-session":v("创建会话..."),"starting-session":v("启动 Agent...")};return a.jsx(Br,{isOpen:e,onClose:u?()=>{}:t,title:v("启动 Agent"),action:a.jsxs(a.Fragment,{children:[a.jsx(pt,{variant:"outline",onClick:t,disabled:u,children:v("取消")}),a.jsx(pt,{onClick:_,disabled:u||!C||!i.trim(),children:x[f]})]}),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:v("选择 Provider")}),a.jsxs("div",{className:"flex gap-2 flex-wrap",children:[h&&a.jsx("span",{className:"text-sm text-neutral-400",children:v("加载中...")}),d?.map(({provider:w,availability:E})=>{const b=E.type!=="NOT_FOUND";return a.jsxs(pt,{variant:C===w.id?"default":"outline",size:"sm",disabled:!b||u,onClick:()=>r(w.id),children:[w.name,!b&&v(" (不可用)")]},w.id)})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("任务描述")}),a.jsx("textarea",{value:i,onChange:w=>c(w.target.value),rows:5,disabled:u,placeholder:v("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),p&&a.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:p})]})})}function No({providers:e,currentProviderId:t,agentType:s,onSelect:l}){const{t:m}=he(),[v,C]=k.useState(!1),r=k.useRef(null),i=e.filter(f=>String(f.provider.agentType)===s),c=e.find(f=>f.provider.id===t);return k.useEffect(()=>{function f(o){r.current&&!r.current.contains(o.target)&&C(!1)}if(v)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[v]),i.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(oi,{size:14,className:"shrink-0"}),a.jsx("span",{children:c?.provider.name?hi(c.provider.name,12):s})]}):a.jsxs("div",{className:"relative",ref:r,children:[a.jsxs("button",{onClick:()=>C(!v),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${c?.provider.name??s} (click to change)`,children:[a.jsx(oi,{size:14,className:"shrink-0"}),a.jsx("span",{children:c?.provider.name?hi(c.provider.name,12):s}),a.jsx(Ct,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&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:m("切换渠道")}),i.map(f=>a.jsxs("button",{onClick:()=>{l(f.provider.id),C(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${f.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&a.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===t&&a.jsx(ss,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function tm({commands:e,selectedIndex:t,query:s,hasCatalog:l,title:m="Slash Commands",queryPrefix:v="/",emptyCatalogMessage:C="No slash commands catalog for this agent yet.",emptyQueryMessage:r,insertionHint:i="Enter / Tab to insert",compact:c=!1,onSelect:f}){const o=c?"px-1.5 pb-1.5":"px-2 pb-2",p=c?"px-2 py-1.5":"px-2.5 py-2",S=c?"max-h-36":"max-h-48";return a.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[a.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[a.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:i})]}),e.length===0?a.jsx("div",{className:`${c?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:l?r??`No matches for ${v}${s}`:C}):a.jsx("div",{className:`${o} ${S} overflow-y-auto`,children:e.map((y,g)=>a.jsxs("button",{type:"button",onMouseDown:n=>n.preventDefault(),onClick:()=>f(y),className:`w-full rounded-lg border text-left transition-colors ${g===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${p}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?a.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),a.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const wt=12,ys=8;function Ps({open:e,anchorRef:t,commands:s,selectedIndex:l,query:m,hasCatalog:v,title:C,queryPrefix:r,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:f,compact:o=!1,onSelect:p}){const S=k.useRef(null),[y,g]=k.useState(null);return k.useLayoutEffect(()=>{if(!e){g(null);return}const n=t.current;if(!n)return;let d=0;const h=()=>{const x=t.current;if(!x)return;const w=x.getBoundingClientRect(),E=window.innerWidth,b=window.innerHeight,R=o?260:320,j=o?E-wt*2:560,L=Math.min(Math.max(w.width,R),Math.max(R,j)),M=Math.min(Math.max(wt,w.left),Math.max(wt,E-wt-L)),T=b-w.bottom-ys-wt,B=w.top-ys-wt,I=S.current?.offsetHeight??(o?220:280),H=o?240:320,W=T<180&&B>T,N=Math.max(120,Math.min(H,W?B:T)),P=W?Math.max(wt,w.top-ys-Math.min(I,N)):Math.min(b-wt-Math.min(I,N),w.bottom+ys);g({top:P,left:M,width:L,maxHeight:N})},u=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(h)};u();const _=new ResizeObserver(u);return _.observe(n),S.current&&_.observe(S.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(d),_.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,s.length,o,e,m,l]),!e||!y||typeof document>"u"?null:Nt.createPortal(a.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:a.jsx("div",{ref:S,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:a.jsx(tm,{commands:s,selectedIndex:l,query:m,hasCatalog:v,title:C,queryPrefix:r,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:f,compact:o,onSelect:p})})}),document.body)}function sm({workspaceId:e,gitStatus:t,onResolve:s}){const{t:l}=he(),m=zf();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const v=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(bn,{size:18,className:"text-amber-600 shrink-0"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-sm font-medium text-amber-900",children:l("{opLabel} 冲突 — {count} 个文件",{opLabel:v,count:t.conflictedFiles.length})})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx(pt,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:l("中止操作")}),a.jsx(pt,{size:"sm",onClick:s,children:l("解决冲突")})]})]})}function rm(e,t,s,l){const m=s.map(v=>`- ${v}`).join(`
73
- `);return l===Ea.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
73
+ `);return l===ya.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
74
74
  `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"].join(`
75
- `)}function im({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:v,targetBranch:C,sessions:r}){const{t:i}=he(),[c,f]=k.useState(""),o=Zr(),p=Gr(),S=()=>{if(!c)return;const n=rm(v,C,m,l);o.mutate({id:c,message:n},{onSuccess:()=>t(!1)})},y=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},g=l==="REBASE"?"Rebase":"Merge";return a.jsx(Br,{isOpen:e,onClose:()=>t(!1),title:i("解决 {opLabel} 冲突",{opLabel:g}),action:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(pt,{variant:"outline",onClick:y,children:i("在 IDE 中打开")}),a.jsx(pt,{onClick:S,disabled:!c||o.isPending,children:o.isPending?i("发送中..."):i("AI 辅助解决")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:i("冲突文件({count})",{count:m.length})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(n=>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:n},n))})]}),r.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:i("选择 Session(AI 辅助解决)")}),a.jsxs("select",{value:c,onChange:n=>f(n.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[a.jsx("option",{value:"",children:i("选择一个 Session...")}),r.map(n=>a.jsxs("option",{value:n.id,children:[n.agentType," — ",n.status]},n.id))]})]}),r.length===0&&a.jsx("p",{className:"text-sm text-neutral-500",children:i("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Mt({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 nm({gitStatus:e,branchName:t,targetBranch:s}){const{t:l}=he();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(yn,{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(Mt,{variant:"danger",children:[a.jsx(Ua,{size:12}),l("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(bn,{size:12}),l("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),l("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),l("合并进行中")]}),e.ahead>0&&a.jsxs(Mt,{variant:"success",children:[a.jsx(di,{size:12}),l("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&a.jsx(Mt,{variant:"warning",children:l("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&a.jsxs(Mt,{variant:"neutral",children:[a.jsx(di,{size:12}),l("已是最新")]})]}),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:l("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function om({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:v,onRefreshCommitMessage:C,onConflict:r}){const{t:i}=he(),{data:c,isLoading:f}=jo(s),o=Hf(),p=If(),[S,y]=k.useState(null),[g,n]=k.useState("select"),[d,h]=k.useState(""),[u,_]=k.useState(!1),x=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;k.useEffect(()=>{e&&(n("select"),y(null),_(!1),C?.())},[e,C]),k.useEffect(()=>{!e||u||h(v??"")},[e,v,u]);const b=T=>{_(!0),h(B=>typeof T=="function"?T(B):T)},R=()=>{y(null),o.mutate(s,{onSuccess:()=>t(!1),onError:T=>{const B=T;B.status===409?(t(!1),r()):y(B.message??i("变基失败"))}})},j=()=>{y(null),n("confirm")},L=()=>{y(null);const T=d.trim()||void 0;p.mutate({id:s,commitMessage:T},{onSuccess:()=>t(!1),onError:B=>{const I=B;I.status===409?(t(!1),r()):y(I.message??i("合并失败"))}})},M=i(g==="confirm"?"确认合并":"Git 操作");return a.jsx(Br,{isOpen:e,onClose:()=>t(!1),title:M,children:f||!c?a.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[a.jsx(Ue,{size:18,className:"animate-spin"}),a.jsx("span",{className:"text-sm",children:i("加载分支状态...")})]}):g==="confirm"?a.jsx(lm,{editableMessage:d,setEditableMessage:b,error:S,isPending:p.isPending,onConfirm:L,onBack:()=>n("select"),branchName:l,targetBranch:m}):a.jsx(am,{gitStatus:c,branchName:l,targetBranch:m,error:S,isDirty:E,hasConflicts:x,isOperationInProgress:w,rebasePending:o.isPending,mergePending:p.isPending,onRebase:R,onMerge:j})})}function am({gitStatus:e,branchName:t,targetBranch:s,error:l,isDirty:m,hasConflicts:v,isOperationInProgress:C,rebasePending:r,mergePending:i,onRebase:c,onMerge:f}){const{t:o}=he();return a.jsxs("div",{className:"space-y-5",children:[a.jsx(nm,{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||v||C||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[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:o(r?"变基中...":"变基 (Rebase)")}),a.jsx("div",{className:"text-xs text-neutral-500",children:o("将当前分支变基到最新的 {targetBranch}",{targetBranch:s})})]})]}),a.jsxs("button",{onClick:f,disabled:i||v||C||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:a.jsx(Rn,{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:o(i?"合并中...":"合并 (Merge)")}),a.jsx("div",{className:"text-xs text-neutral-500",children:o("Squash merge 到 {targetBranch}",{targetBranch:s})})]})]})]})]})}function lm({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:v,branchName:C,targetBranch:r}){const{t:i}=he();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(yn,{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:i("提交消息")}),a.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:i("输入提交消息..."),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:i("留空将使用默认消息")})]}),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:v,disabled:l,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:i("返回")}),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(Ue,{size:14,className:"animate-spin"}),i("合并中...")]}):a.jsxs(a.Fragment,{children:[a.jsx(Rn,{size:14}),i("确认合并")]})})]})]})}function cm({agentType:e,workingDir:t}){return ut({queryKey:oe.system.slashCommandCatalog(e,t),queryFn:async()=>(await ue.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function hm(e,t){const s=new Set,l=[];for(const m of[...e,...t]){const v=m.command.trim().toLowerCase();!v||s.has(v)||(s.add(v),l.push(m.kind?m:{...m,kind:"builtin"}))}return l}function Zs(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function um(e){return Zs(e.command)}function dm(e,t){if(!t)return 1e3;const s=um(e),l=e.aliases?.map(Zs)??[],m=[s,...l];let v=0;for(const r of m)r===t?v=Math.max(v,500):r.startsWith(t)?v=Math.max(v,400-(r.length-t.length)):r.includes(t)&&(v=Math.max(v,250-r.indexOf(t)));return v>0?v:`${s} ${l.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function Gi(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const s=t.index+t[1].length;return{query:Zs(t[2]),replaceStart:s}}function Po(e,t){const s=Zs(t);return s?e.map((l,m)=>({command:l,index:m,score:dm(l,s)})).filter(l=>l.score>0).sort((l,m)=>m.score-l.score||l.index-m.index||l.command.command.localeCompare(m.command.command)).map(l=>l.command):e.slice()}const fm=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],mm=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],pm=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],vm=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],gm={[bt.CODEX]:fm,[bt.CLAUDE_CODE]:mm,[bt.GEMINI_CLI]:pm,[bt.CURSOR_AGENT]:vm};function Oo(e){return e.trim().toLowerCase().replace(/^\//,"")}function _m(e){return e?(gm[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function bm(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Oo(t[1]):null}function xm(e,t){return Po(e,Oo(t))}function Sm(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function Bo({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=cm({agentType:e,workingDir:t}),f=k.useMemo(()=>hm(_m(e),c),[e,c]),o=k.useMemo(()=>bm(s),[s]),p=k.useMemo(()=>o===null?[]:xm(f,o),[f,o]),S=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{i(0)},[e,o]),k.useEffect(()=>{r<p.length||i(0)},[p.length,r]);const y=k.useCallback(n=>{const h=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(S(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,S,l,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),i(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),i(d=>(d-1+p.length)%p.length),!0):Sm(n)?(n.preventDefault(),y(p[r]??p[0]),!0):!1,[y,p,o,r]);return{allCommands:f,query:o,filteredCommands:p,selectedIndex:r,setSelectedIndex:i,applyCommand:y,handleKeyDown:g}}function ym({agentType:e,workingDir:t}){return ut({queryKey:oe.system.skillCatalog(e,t),queryFn:async()=>(await ue.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===bt.CODEX,staleTime:3e4})}function Cm(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function Io({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=ym({agentType:e,workingDir:t}),o=k.useMemo(()=>e===bt.CODEX?Gi(s):null,[e,s])?.query??null,p=k.useMemo(()=>o===null?[]:Po(c,o),[o,c]),S=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{i(0)},[e,o]),k.useEffect(()=>{r<p.length||i(0)},[p.length,r]);const y=k.useCallback(n=>{const d=Gi(s);if(!d)return;const h=`${s.slice(0,d.replaceStart)}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(S(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,S,l,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),i(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),i(d=>(d-1+p.length)%p.length),!0):Cm(n)?(n.preventDefault(),y(p[r]??p[0]),!0):!1,[y,p,o,r]);return{allSkills:c,query:o,filteredSkills:p,selectedIndex:r,setSelectedIndex:i,applySkill:y,handleKeyDown:g}}const wm="/api",Em=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${wm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,km=({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"})}),Rm={img:km},Dm=675,Qi=320,Zi=1200;function Am(){const{t:e}=he();return 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:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Ji=[{status:ce.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:a.jsx(Lr,{className:"w-3 h-3"})},{status:ce.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:a.jsx(Mr,{className:"w-3 h-3"})},{status:ce.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:a.jsx(Nr,{className:"w-3 h-3"})},{status:ce.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:a.jsx(Pr,{className:"w-3 h-3"})},{status:ce.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:a.jsx(Or,{className:"w-3 h-3"})}];function jm({status:e,onChangeStatus:t}){const{t:s}=he(),[l,m]=k.useState(!1),v=k.useRef(null);k.useEffect(()=>{if(!l)return;const r=i=>{v.current&&!v.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[l]);const C=Ji.find(r=>r.status===e);return a.jsxs("div",{className:"relative",ref:v,children:[a.jsxs("button",{onClick:()=>t&&m(r=>!r),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${C.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[C.icon,a.jsx("span",{children:s(e)}),t&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${l?"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"})})]}),l&&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:Ji.filter(r=>r.status!==e).map(r=>a.jsxs("button",{onClick:()=>{t?.(r.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${r.hoverClass}`,children:[a.jsx("span",{className:r.className.split(" ").find(i=>i.startsWith("text-")),children:r.icon}),a.jsx("span",{className:"text-neutral-700",children:s(r.status)})]},r.status))})]})}function Tm({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const{t:m}=he(),[v,C]=k.useState(""),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[S,y]=k.useState(!1),[g,n]=k.useState(!1),[d,h]=k.useState(!1),[u,_]=k.useState(!1),[x,w]=k.useState(!1),E=k.useRef(null),b=k.useRef(null),R=k.useRef(null),j=k.useRef(null),{scrollRef:L,contentRef:M,isAtBottom:T,scrollToBottom:B}=Vn({resize:"smooth",initial:"instant"}),[I,H]=k.useState(Dm),[W,A]=k.useState(!0),[N,P]=k.useState(!1),O=k.useRef(0),$=k.useRef(0),X=k.useRef(null),{data:K,isLoading:Q}=Do(e?.id??""),se=$f(e?.id);k.useEffect(()=>{w(!1)},[e?.id]),k.useEffect(()=>{if(!x||!K)return;K.some(te=>te.status==="ACTIVE"&&te.sessions&&te.sessions.length>0)&&w(!1)},[K,x]);const D=k.useMemo(()=>{if(x||!K)return null;const G=$e=>{const sr=$e.createdAt,Yt=$e.endedAt??$e.startedAt??sr;if(!Yt)return 0;const Ht=Date.parse(Yt);return Number.isNaN(Ht)?0:Ht},te=($e,sr)=>{const Yt=$e.filter(Ht=>sr.includes(Ht.status));return Yt.length===0?null:Yt.sort((Ht,oa)=>G(oa)-G(Ht))[0]??null},Re=K.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),lt=te(Re,[Te.RUNNING])??te(Re,[Te.PENDING])??te(Re,[Te.COMPLETED,Te.FAILED,Te.CANCELLED]);if(lt)return lt;const Ze=K.filter($e=>($e.status==="MERGED"||$e.status==="ABANDONED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]);return te(Ze,[Te.COMPLETED,Te.FAILED,Te.CANCELLED])},[K,x]),F=D?.id??"",U=D?.status===Te.RUNNING||D?.status===Te.PENDING,z=!!e?.projectArchivedAt,ee=!!e?.projectRepoDeletedAt,V=m(ee?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ne}=Hs(),[ve,fe]=k.useState(null);k.useEffect(()=>{fe(D?.providerId??null)},[D?.providerId]);const Le=k.useMemo(()=>!D||!K?!1:!K.some(te=>te.status==="ACTIVE"&&te.sessions?.some(Re=>Re.id===D.id)),[D,K]),re=k.useMemo(()=>{if(!(!K||x)){for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[K,x]),Be=Bo({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),ye=Io({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),ae=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.id:void 0,[K]),{data:Me}=jo(ae??""),Ke=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.sessions??[]:[],[K]),Ae=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.branchName??"":"",[K]),Xe=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.commitMessage:void 0,[K]),ge=ze(),rt=k.useCallback(()=>e?.id?ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,ge]);k.useEffect(()=>{if(!u)return;const G=te=>{b.current&&!b.current.contains(te.target)&&_(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[u]);const Ye=Zr(),Ne=Gr(),Pe=Yf(),He=Ao(e?.id??""),we=Qr(),Y=Ff(),ie=k.useMemo(()=>!K||K.some(te=>te.status==="ACTIVE")?null:K.find(te=>te.status==="HIBERNATED")??null,[K]),Ce=k.useRef(null);k.useEffect(()=>{ie&&Ce.current!==ie.id&&(Y.isPending||(Ce.current=ie.id,Y.mutate(ie.id,{onSettled:()=>{Ce.current=null}})))},[ie,Y]);const _e=k.useCallback(async()=>{if(!e?.id)return;const G=D?.providerId??ne?.find(Re=>Re.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const te=[e.title,e.description].filter(Boolean).join(`
75
+ `)}function im({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:v,targetBranch:C,sessions:r}){const{t:i}=he(),[c,f]=k.useState(""),o=Zr(),p=Gr(),S=()=>{if(!c)return;const n=rm(v,C,m,l);o.mutate({id:c,message:n},{onSuccess:()=>t(!1)})},y=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},g=l==="REBASE"?"Rebase":"Merge";return a.jsx(Br,{isOpen:e,onClose:()=>t(!1),title:i("解决 {opLabel} 冲突",{opLabel:g}),action:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(pt,{variant:"outline",onClick:y,children:i("在 IDE 中打开")}),a.jsx(pt,{onClick:S,disabled:!c||o.isPending,children:o.isPending?i("发送中..."):i("AI 辅助解决")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:i("冲突文件({count})",{count:m.length})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(n=>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:n},n))})]}),r.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:i("选择 Session(AI 辅助解决)")}),a.jsxs("select",{value:c,onChange:n=>f(n.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[a.jsx("option",{value:"",children:i("选择一个 Session...")}),r.map(n=>a.jsxs("option",{value:n.id,children:[n.agentType," — ",n.status]},n.id))]})]}),r.length===0&&a.jsx("p",{className:"text-sm text-neutral-500",children:i("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Mt({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 nm({gitStatus:e,branchName:t,targetBranch:s}){const{t:l}=he();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(yn,{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(Mt,{variant:"danger",children:[a.jsx(Ua,{size:12}),l("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(bn,{size:12}),l("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),l("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(Ue,{size:12,className:"animate-spin"}),l("合并进行中")]}),e.ahead>0&&a.jsxs(Mt,{variant:"success",children:[a.jsx(di,{size:12}),l("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&a.jsx(Mt,{variant:"warning",children:l("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&a.jsxs(Mt,{variant:"neutral",children:[a.jsx(di,{size:12}),l("已是最新")]})]}),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:l("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function om({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:v,onRefreshCommitMessage:C,onConflict:r}){const{t:i}=he(),{data:c,isLoading:f}=jo(s),o=Hf(),p=If(),[S,y]=k.useState(null),[g,n]=k.useState("select"),[d,h]=k.useState(""),[u,_]=k.useState(!1),x=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;k.useEffect(()=>{e&&(n("select"),y(null),_(!1),C?.())},[e,C]),k.useEffect(()=>{!e||u||h(v??"")},[e,v,u]);const b=T=>{_(!0),h(B=>typeof T=="function"?T(B):T)},R=()=>{y(null),o.mutate(s,{onSuccess:()=>t(!1),onError:T=>{const B=T;B.status===409?(t(!1),r()):y(B.message??i("变基失败"))}})},j=()=>{y(null),n("confirm")},L=()=>{y(null);const T=d.trim()||void 0;p.mutate({id:s,commitMessage:T},{onSuccess:()=>t(!1),onError:B=>{const I=B;I.status===409?(t(!1),r()):y(I.message??i("合并失败"))}})},M=i(g==="confirm"?"确认合并":"Git 操作");return a.jsx(Br,{isOpen:e,onClose:()=>t(!1),title:M,children:f||!c?a.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[a.jsx(Ue,{size:18,className:"animate-spin"}),a.jsx("span",{className:"text-sm",children:i("加载分支状态...")})]}):g==="confirm"?a.jsx(lm,{editableMessage:d,setEditableMessage:b,error:S,isPending:p.isPending,onConfirm:L,onBack:()=>n("select"),branchName:l,targetBranch:m}):a.jsx(am,{gitStatus:c,branchName:l,targetBranch:m,error:S,isDirty:E,hasConflicts:x,isOperationInProgress:w,rebasePending:o.isPending,mergePending:p.isPending,onRebase:R,onMerge:j})})}function am({gitStatus:e,branchName:t,targetBranch:s,error:l,isDirty:m,hasConflicts:v,isOperationInProgress:C,rebasePending:r,mergePending:i,onRebase:c,onMerge:f}){const{t:o}=he();return a.jsxs("div",{className:"space-y-5",children:[a.jsx(nm,{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||v||C||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[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:o(r?"变基中...":"变基 (Rebase)")}),a.jsx("div",{className:"text-xs text-neutral-500",children:o("将当前分支变基到最新的 {targetBranch}",{targetBranch:s})})]})]}),a.jsxs("button",{onClick:f,disabled:i||v||C||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:a.jsx(Rn,{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:o(i?"合并中...":"合并 (Merge)")}),a.jsx("div",{className:"text-xs text-neutral-500",children:o("Squash merge 到 {targetBranch}",{targetBranch:s})})]})]})]})]})}function lm({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:v,branchName:C,targetBranch:r}){const{t:i}=he();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(yn,{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:i("提交消息")}),a.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:i("输入提交消息..."),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:i("留空将使用默认消息")})]}),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:v,disabled:l,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:i("返回")}),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(Ue,{size:14,className:"animate-spin"}),i("合并中...")]}):a.jsxs(a.Fragment,{children:[a.jsx(Rn,{size:14}),i("确认合并")]})})]})]})}function cm({agentType:e,workingDir:t}){return ut({queryKey:oe.system.slashCommandCatalog(e,t),queryFn:async()=>(await ue.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function hm(e,t){const s=new Set,l=[];for(const m of[...e,...t]){const v=m.command.trim().toLowerCase();!v||s.has(v)||(s.add(v),l.push(m.kind?m:{...m,kind:"builtin"}))}return l}function Zs(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function um(e){return Zs(e.command)}function dm(e,t){if(!t)return 1e3;const s=um(e),l=e.aliases?.map(Zs)??[],m=[s,...l];let v=0;for(const r of m)r===t?v=Math.max(v,500):r.startsWith(t)?v=Math.max(v,400-(r.length-t.length)):r.includes(t)&&(v=Math.max(v,250-r.indexOf(t)));return v>0?v:`${s} ${l.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function Gi(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const s=t.index+t[1].length;return{query:Zs(t[2]),replaceStart:s}}function Po(e,t){const s=Zs(t);return s?e.map((l,m)=>({command:l,index:m,score:dm(l,s)})).filter(l=>l.score>0).sort((l,m)=>m.score-l.score||l.index-m.index||l.command.command.localeCompare(m.command.command)).map(l=>l.command):e.slice()}const fm=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],mm=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],pm=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],vm=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],gm={[bt.CODEX]:fm,[bt.CLAUDE_CODE]:mm,[bt.GEMINI_CLI]:pm,[bt.CURSOR_AGENT]:vm};function Oo(e){return e.trim().toLowerCase().replace(/^\//,"")}function _m(e){return e?(gm[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function bm(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Oo(t[1]):null}function xm(e,t){return Po(e,Oo(t))}function Sm(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function Bo({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=cm({agentType:e,workingDir:t}),f=k.useMemo(()=>hm(_m(e),c),[e,c]),o=k.useMemo(()=>bm(s),[s]),p=k.useMemo(()=>o===null?[]:xm(f,o),[f,o]),S=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{i(0)},[e,o]),k.useEffect(()=>{r<p.length||i(0)},[p.length,r]);const y=k.useCallback(n=>{const h=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(S(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,S,l,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),i(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),i(d=>(d-1+p.length)%p.length),!0):Sm(n)?(n.preventDefault(),y(p[r]??p[0]),!0):!1,[y,p,o,r]);return{allCommands:f,query:o,filteredCommands:p,selectedIndex:r,setSelectedIndex:i,applyCommand:y,handleKeyDown:g}}function ym({agentType:e,workingDir:t}){return ut({queryKey:oe.system.skillCatalog(e,t),queryFn:async()=>(await ue.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===bt.CODEX,staleTime:3e4})}function Cm(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return t||s}function Io({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=ym({agentType:e,workingDir:t}),o=k.useMemo(()=>e===bt.CODEX?Gi(s):null,[e,s])?.query??null,p=k.useMemo(()=>o===null?[]:Po(c,o),[o,c]),S=k.useCallback(()=>{const n=m.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,C))}px`)},[C,v,m]);k.useEffect(()=>{i(0)},[e,o]),k.useEffect(()=>{r<p.length||i(0)},[p.length,r]);const y=k.useCallback(n=>{const d=Gi(s);if(!d)return;const h=`${s.slice(0,d.replaceStart)}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(S(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,S,l,m]),g=k.useCallback(n=>o===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),i(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),i(d=>(d-1+p.length)%p.length),!0):Cm(n)?(n.preventDefault(),y(p[r]??p[0]),!0):!1,[y,p,o,r]);return{allSkills:c,query:o,filteredSkills:p,selectedIndex:r,setSelectedIndex:i,applySkill:y,handleKeyDown:g}}const wm="/api",Em=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${wm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,km=({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"})}),Rm={img:km},Dm=675,Qi=320,Zi=1200;function Am(){const{t:e}=he();return 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:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Ji=[{status:ce.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:a.jsx(Lr,{className:"w-3 h-3"})},{status:ce.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:a.jsx(Mr,{className:"w-3 h-3"})},{status:ce.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:a.jsx(Nr,{className:"w-3 h-3"})},{status:ce.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:a.jsx(Pr,{className:"w-3 h-3"})},{status:ce.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:a.jsx(Or,{className:"w-3 h-3"})}];function jm({status:e,onChangeStatus:t}){const{t:s}=he(),[l,m]=k.useState(!1),v=k.useRef(null);k.useEffect(()=>{if(!l)return;const r=i=>{v.current&&!v.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[l]);const C=Ji.find(r=>r.status===e);return a.jsxs("div",{className:"relative",ref:v,children:[a.jsxs("button",{onClick:()=>t&&m(r=>!r),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${C.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[C.icon,a.jsx("span",{children:s(e)}),t&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${l?"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"})})]}),l&&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:Ji.filter(r=>r.status!==e).map(r=>a.jsxs("button",{onClick:()=>{t?.(r.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${r.hoverClass}`,children:[a.jsx("span",{className:r.className.split(" ").find(i=>i.startsWith("text-")),children:r.icon}),a.jsx("span",{className:"text-neutral-700",children:s(r.status)})]},r.status))})]})}function Tm({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const{t:m}=he(),[v,C]=k.useState(""),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[S,y]=k.useState(!1),[g,n]=k.useState(!1),[d,h]=k.useState(!1),[u,_]=k.useState(!1),[x,w]=k.useState(!1),E=k.useRef(null),b=k.useRef(null),R=k.useRef(null),j=k.useRef(null),{scrollRef:L,contentRef:M,isAtBottom:T,scrollToBottom:B}=Vn({resize:"smooth",initial:"instant"}),[I,H]=k.useState(Dm),[W,A]=k.useState(!0),[N,P]=k.useState(!1),O=k.useRef(0),$=k.useRef(0),X=k.useRef(null),{data:K,isLoading:Q}=Do(e?.id??""),se=$f(e?.id);k.useEffect(()=>{w(!1)},[e?.id]),k.useEffect(()=>{if(!x||!K)return;K.some(te=>te.status==="ACTIVE"&&te.sessions&&te.sessions.length>0)&&w(!1)},[K,x]);const D=k.useMemo(()=>{if(x||!K)return null;const G=$e=>{const sr=$e.createdAt,Yt=$e.endedAt??$e.startedAt??sr;if(!Yt)return 0;const Ft=Date.parse(Yt);return Number.isNaN(Ft)?0:Ft},te=($e,sr)=>{const Yt=$e.filter(Ft=>sr.includes(Ft.status));return Yt.length===0?null:Yt.sort((Ft,oa)=>G(oa)-G(Ft))[0]??null},Re=K.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),lt=te(Re,[Te.RUNNING])??te(Re,[Te.PENDING])??te(Re,[Te.COMPLETED,Te.FAILED,Te.CANCELLED]);if(lt)return lt;const Ze=K.filter($e=>($e.status==="MERGED"||$e.status==="ABANDONED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]);return te(Ze,[Te.COMPLETED,Te.FAILED,Te.CANCELLED])},[K,x]),F=D?.id??"",U=D?.status===Te.RUNNING||D?.status===Te.PENDING,z=!!e?.projectArchivedAt,ee=!!e?.projectRepoDeletedAt,V=m(ee?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ne}=Hs(),[ve,fe]=k.useState(null);k.useEffect(()=>{fe(D?.providerId??null)},[D?.providerId]);const Le=k.useMemo(()=>!D||!K?!1:!K.some(te=>te.status==="ACTIVE"&&te.sessions?.some(Re=>Re.id===D.id)),[D,K]),re=k.useMemo(()=>{if(!(!K||x)){for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[K,x]),Be=Bo({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),ye=Io({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),ae=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.id:void 0,[K]),{data:Me}=jo(ae??""),Ke=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.sessions??[]:[],[K]),Ae=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.branchName??"":"",[K]),Xe=k.useMemo(()=>K?K.find(te=>te.status==="ACTIVE")?.commitMessage:void 0,[K]),ge=ze(),rt=k.useCallback(()=>e?.id?ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,ge]);k.useEffect(()=>{if(!u)return;const G=te=>{b.current&&!b.current.contains(te.target)&&_(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[u]);const Ye=Zr(),Ne=Gr(),Pe=Yf(),He=Ao(e?.id??""),we=Qr(),Y=Ff(),ie=k.useMemo(()=>!K||K.some(te=>te.status==="ACTIVE")?null:K.find(te=>te.status==="HIBERNATED")??null,[K]),Ce=k.useRef(null);k.useEffect(()=>{ie&&Ce.current!==ie.id&&(Y.isPending||(Ce.current=ie.id,Y.mutate(ie.id,{onSettled:()=>{Ce.current=null}})))},[ie,Y]);const _e=k.useCallback(async()=>{if(!e?.id)return;const G=D?.providerId??ne?.find(Re=>Re.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const te=[e.title,e.description].filter(Boolean).join(`
76
76
 
77
- `);p(!1),y(!0);try{await Pe.mutateAsync(e.id),w(!0);const Re=await He.mutateAsync({}),lt=await ue.post(`/workspaces/${Re.id}/sessions`,{providerId:G,prompt:te});await we.mutateAsync(lt.id),await ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})}catch(Re){console.error("[retry] failed:",Re),w(!1)}finally{y(!1)}},[e?.id,e?.title,e?.description,D?.providerId,ne,Pe,He,we,ge]),We=k.useCallback(()=>{ae&&Ne.mutate({workspaceId:ae})},[ae,Ne]),Qe=k.useCallback(()=>{!e?.id||!t||(t(e.id),f(!1))},[e?.id,t]),{isConnected:me,isLoadingSnapshot:it,logs:et,entries:dt,attach:Ie}=dn({sessionId:F,sessionStatus:D?.status,onExit:k.useCallback(()=>{ge.invalidateQueries({queryKey:["workspaces"]})},[ge])});k.useEffect(()=>{if(!e?.id)return;const G=kt.connect();G.emit(Pt.SUBSCRIBE,{topic:"task",id:e.id});const te=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:["tasks"]})},Re=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})},lt=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})};return G.on(Ve.TASK_UPDATED,te),G.on(Ve.WORKSPACE_COMMIT_MESSAGE_UPDATED,Re),G.on(Ve.WORKSPACE_HIBERNATED,lt),()=>{G.off(Ve.TASK_UPDATED,te),G.off(Ve.WORKSPACE_COMMIT_MESSAGE_UPDATED,Re),G.off(Ve.WORKSPACE_HIBERNATED,lt),G.emit(Pt.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,ge]),k.useEffect(()=>{if(!F)return;const G=kt.connect(),te=Re=>{Re.sessionId===F&&ge.invalidateQueries({queryKey:["workspaces"]})};return G.on(Ve.SESSION_COMPLETED,te),()=>{G.off(Ve.SESSION_COMPLETED,te)}},[F,ge]);const{todos:q}=fn(dt),{files:Z,addFiles:le,removeFile:pe,clear:be,buildMarkdownLinks:ke,hasFiles:st,isUploading:Oe}=Jr(),gt=k.useMemo(()=>{if(!D?.tokenUsage)return;const G=D.tokenUsage;if(typeof G.totalTokens=="number")return G},[D?.tokenUsage]),ot=Lo(et,gt);k.useEffect(()=>{F&&me&&Ie()},[F,me,Ie]);const at=k.useRef(e?.id);k.useEffect(()=>{if(at.current!==e?.id&&L.current){const G=L.current;requestAnimationFrame(()=>{G.scrollTop=G.scrollHeight})}at.current=e?.id},[e?.id,L]);const xt=To(),St=k.useRef(!1),ft=k.useCallback(async()=>{if(!v.trim()&&!st||!F||St.current||Oe)return;St.current=!0;const G=ke(),te=[v.trim(),G].filter(Boolean).join(`
77
+ `);p(!1),y(!0);try{await Pe.mutateAsync(e.id),w(!0);const Re=await He.mutateAsync({}),lt=await ue.post(`/workspaces/${Re.id}/sessions`,{providerId:G,prompt:te});await we.mutateAsync(lt.id),await ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})}catch(Re){console.error("[retry] failed:",Re),w(!1)}finally{y(!1)}},[e?.id,e?.title,e?.description,D?.providerId,ne,Pe,He,we,ge]),We=k.useCallback(()=>{ae&&Ne.mutate({workspaceId:ae})},[ae,Ne]),Qe=k.useCallback(()=>{!e?.id||!t||(t(e.id),f(!1))},[e?.id,t]),{isConnected:me,isLoadingSnapshot:it,logs:et,entries:dt,attach:Ie}=dn({sessionId:F,sessionStatus:D?.status,onExit:k.useCallback(()=>{ge.invalidateQueries({queryKey:["workspaces"]})},[ge])});k.useEffect(()=>{if(!e?.id)return;const G=kt.connect();G.emit(Ht.SUBSCRIBE,{topic:"task",id:e.id});const te=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:["tasks"]})},Re=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})},lt=Ze=>{Ze.taskId===e.id&&ge.invalidateQueries({queryKey:oe.workspaces.list(e.id)})};return G.on(Ve.TASK_UPDATED,te),G.on(Ve.WORKSPACE_COMMIT_MESSAGE_UPDATED,Re),G.on(Ve.WORKSPACE_HIBERNATED,lt),()=>{G.off(Ve.TASK_UPDATED,te),G.off(Ve.WORKSPACE_COMMIT_MESSAGE_UPDATED,Re),G.off(Ve.WORKSPACE_HIBERNATED,lt),G.emit(Ht.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,ge]),k.useEffect(()=>{if(!F)return;const G=kt.connect(),te=Re=>{Re.sessionId===F&&ge.invalidateQueries({queryKey:["workspaces"]})};return G.on(Ve.SESSION_COMPLETED,te),()=>{G.off(Ve.SESSION_COMPLETED,te)}},[F,ge]);const{todos:q}=fn(dt),{files:Z,addFiles:le,removeFile:pe,clear:be,buildMarkdownLinks:ke,hasFiles:st,isUploading:Oe}=Jr(),gt=k.useMemo(()=>{if(!D?.tokenUsage)return;const G=D.tokenUsage;if(typeof G.totalTokens=="number")return G},[D?.tokenUsage]),ot=Lo(et,gt);k.useEffect(()=>{F&&me&&Ie()},[F,me,Ie]);const at=k.useRef(e?.id);k.useEffect(()=>{if(at.current!==e?.id&&L.current){const G=L.current;requestAnimationFrame(()=>{G.scrollTop=G.scrollHeight})}at.current=e?.id},[e?.id,L]);const xt=To(),St=k.useRef(!1),ft=k.useCallback(async()=>{if(!v.trim()&&!st||!F||St.current||Oe)return;St.current=!0;const G=ke(),te=[v.trim(),G].filter(Boolean).join(`
78
78
 
79
- `);C(""),be(),R.current&&(R.current.style.height="60px"),Ye.mutate({id:F,message:te,providerId:ve??void 0},{onSuccess:()=>{Ie()},onSettled:()=>{St.current=!1}})},[v,F,Ye,Ie,st,Oe,ke,be,ve]),Lt=k.useCallback(async()=>{F&&(await xt.mutateAsync(F),ge.invalidateQueries({queryKey:["workspaces"]}))},[F,xt,ge]),Xt=k.useCallback(G=>{const te=G.target.files;te&&te.length>0&&le(Array.from(te)),G.target.value=""},[le]),Jo=k.useCallback(G=>{const te=G.clipboardData.items,Re=[];for(const lt of te)if(lt.kind==="file"){const Ze=lt.getAsFile();Ze&&Re.push(Ze)}Re.length>0&&(G.preventDefault(),le(Re))},[le]),[ti,Js]=k.useState(!1),ea=k.useCallback(G=>{G.preventDefault(),Js(!0)},[]),ta=k.useCallback(G=>{G.preventDefault(),Js(!1)},[]),sa=k.useCallback(G=>{G.preventDefault(),Js(!1);const te=G.dataTransfer.files;te.length>0&&le(Array.from(te))},[le]),er=k.useCallback(G=>{const te=G.clientX-O.current,Re=Math.max(Qi,Math.min($.current+te,Zi));X.current&&(X.current.style.width=`${Re}px`)},[]),tr=k.useCallback(()=>{if(P(!1),X.current){const G=X.current.getBoundingClientRect().width;H(Math.max(Qi,Math.min(Math.round(G),Zi)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);k.useEffect(()=>{if(N)return document.addEventListener("mousemove",er),document.addEventListener("mouseup",tr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",er),document.removeEventListener("mouseup",tr),document.body.style.cursor="",document.body.style.userSelect=""}},[N,er,tr]);const ra=k.useCallback(G=>{G.preventDefault(),O.current=G.clientX,$.current=I,P(!0)},[I]),ia=k.useCallback(()=>{A(G=>!G)},[]),na=k.useCallback(G=>{C(G.target.value);const te=G.target;te.style.height="auto";const Re=te.scrollHeight;te.style.height=`${Math.max(60,Math.min(Re,300))}px`},[]),si=k.useMemo(()=>{const G=[];if(K&&K.length>0){const te=K.some(Ze=>Ze.status==="ACTIVE"),Re=K.some(Ze=>Ze.sessions?.some($e=>$e.status===Te.RUNNING||$e.status===Te.PENDING)),lt=K.some(Ze=>Ze.status==="ACTIVE");Re&&G.push(m("正在运行的 Agent 将被停止")),lt&&G.push(m("分支上未合并的变更将丢失")),te&&G.push(m("关联的工作目录(worktree)将被清理"))}return G},[K,m]);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}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),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(jm,{status:e.status,onChangeStatus:!z&&l?G=>l(e.id,G):void 0}),ae&&!z&&a.jsx("button",{onClick:()=>h(!0),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Git 操作"),children:a.jsx(Za,{size:18})}),a.jsx("button",{onClick:We,disabled:!ae||z,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:a.jsx(zs,{size:18})}),a.jsx("button",{onClick:ia,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:W?a.jsx(fl,{size:18}):a.jsx(pl,{size:18})}),t&&!z&&a.jsxs("div",{className:"relative",ref:b,children:[a.jsx("button",{onClick:()=>_(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:a.jsx(wn,{size:18})}),u&&a.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[a.jsxs("button",{onClick:()=>{p(!0),_(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[a.jsx(Da,{size:15}),a.jsx("span",{children:m("重新开始")})]}),a.jsxs("button",{onClick:()=>{f(!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(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})]})]})]})]}),ae&&Me&&a.jsx(sm,{workspaceId:ae,gitStatus:Me,onResolve:()=>n(!0)}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{ref:X,className:`flex flex-col bg-white relative ${W?"flex-shrink-0":"flex-1"}`,style:{width:W?I:"100%"},children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:L,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:a.jsxs("div",{ref:M,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(mn,{urlTransform:Em,components:Rm,children:e.description})}):a.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),se&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[se.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.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:se.currentIndex,total:se.totalCommands,command:se.currentCommand})})]}),se.status==="completed"&&a.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),se.status==="failed"&&a.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:se.error})})]}),Q?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:m("Loading...")})]}):F?it?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:m("Loading logs...")})]}):et.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(U?"Waiting for agent output...":"No logs recorded for this session.")}):a.jsx(pn,{logs:et}):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(Ot,{size:24,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(z?"项目为只读历史":"尚未启动 Agent")}),a.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:z?V:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!z&&a.jsxs(pt,{onClick:()=>i(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!T&&a.jsxs("button",{onClick:()=>B(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[a.jsx(Sn,{size:14}),a.jsx("span",{children:m("回到底部")})]})]}),q.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(vn,{todos:q})}),z?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.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:V})}):Le?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:m("代码已合并,以上为历史沟通记录")}),a.jsxs(pt,{size:"sm",onClick:()=>i(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):a.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:ea,onDragLeave:ta,onDrop:sa,children:[a.jsxs("div",{ref:E,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 ${ti?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[a.jsx(Ns,{files:Z,onRemove:pe}),a.jsx("textarea",{ref:R,value:v,onChange:na,onPaste:Jo,onKeyDown:G=>{ye.handleKeyDown(G)||Be.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),ft())},rows:1,placeholder:m(ti?"Drop files here...":F&&!U?"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:j,type:"file",multiple:!0,className:"hidden",onChange:Xt}),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:()=>j.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:a.jsx(ws,{size:18})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[D&&ne&&a.jsx(No,{providers:ne,currentProviderId:ve,agentType:D.agentType,onSelect:fe}),a.jsx(Gn,{usage:ot}),U&&!v.trim()&&!st?a.jsx("button",{onClick:Lt,disabled:xt.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(gn,{size:14})}):a.jsx("button",{onClick:ft,disabled:!v.trim()&&!st||Oe,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||st)&&!Oe?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:a.jsx(Cn,{size:18})})]})]})]}),a.jsx(Ps,{open:Be.query!==null,anchorRef:E,commands:Be.filteredCommands,selectedIndex:Be.selectedIndex,query:Be.query??"",hasCatalog:Be.allCommands.length>0,onSelect:Be.applyCommand}),a.jsx(Ps,{open:ye.query!==null,anchorRef:E,commands:ye.filteredSkills,selectedIndex:ye.selectedIndex,query:ye.query??"",hasCatalog:ye.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:ye.applySkill})]})]}),W&&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:ra}),W&&a.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:a.jsx(Ro,{sessionId:F||void 0,workingDir:re,projectId:e.projectId,readOnly:z,repoDeleted:ee})})]}),!z&&a.jsx(Mo,{isOpen:r,onClose:()=>i(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),ae&&!z&&a.jsx(om,{open:d,onOpenChange:h,workspaceId:ae,branchName:Ae,targetBranch:e.mainBranch,commitMessage:Xe,onRefreshCommitMessage:rt,onConflict:()=>n(!0)}),ae&&Me&&Me.conflictOp&&a.jsx(im,{open:g,onOpenChange:n,workspaceId:ae,conflictOp:Me.conflictOp,conflictedFiles:Me.conflictedFiles,sourceBranch:Ae,targetBranch:e.mainBranch,sessions:Ke}),a.jsx(Sr,{isOpen:o,onClose:()=>p(!1),onConfirm:_e,title:m("重新开始任务"),description:a.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:S}),a.jsx(Sr,{isOpen:c,onClose:()=>f(!1),onConfirm:Qe,title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),si.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:si.map((G,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:G})]},te))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):a.jsx(Am,{})}function ei(e){switch(e){case _t.TODO:return ce.Pending;case _t.IN_PROGRESS:return ce.Running;case _t.IN_REVIEW:return ce.Review;case _t.DONE:return ce.Done;case _t.CANCELLED:return ce.Cancelled}}function Lm(e){switch(e){case ce.Pending:return _t.TODO;case ce.Running:return _t.IN_PROGRESS;case ce.Review:return _t.IN_REVIEW;case ce.Done:return _t.DONE;case ce.Cancelled:return _t.CANCELLED}}function Mm(e){switch(e){case bt.CLAUDE_CODE:return"Claude Code";case bt.GEMINI_CLI:return"Gemini CLI";case bt.CURSOR_AGENT:return"Cursor Agent";case bt.CODEX:return"Codex"}}const Os=["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 Fo(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 Ho(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function Nm(e){return{id:e.id,name:e.name,color:e.color||Os[Fo(e.name,Os.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Pm(e){const t=Ho(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:Mm(m.agentType),branch:s}}return{agent:"—",branch:s}}function Om(e){const{agent:t,branch:s}=Pm(e.workspaces),l=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:ei(e.status),agent:t,branch:s,description:e.description??"",projectArchivedAt:l?.archivedAt??null,projectRepoDeletedAt:l?.repoDeletedAt??null}}function Bm(e,t,s){const l=Ho(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Os[Fo(t.name,Os.length)],title:e.title,status:ei(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const en={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 Im(e){const t=e.split("/");return t[t.length-1]||e}function Fm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Hm({workingDir:e,filePath:t,type:s}){const{t:l}=he(),{data:m,isLoading:v,isError:C}=wo(e,t,s);if(v)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const i=r.split(`
80
- `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function zm({entry:e,type:t,workingDir:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=Fm(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",v),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:Im(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(Ct,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Hm,{workingDir:s,filePath:e.path,type:t})]})}function tn({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=he(),[C,r]=k.useState(m);return t.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>r(i=>!i),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:C?a.jsx(Ct,{size:14}):a.jsx(Ft,{size:14})}),a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),C&&a.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(i=>a.jsx(zm,{entry:i,type:s,workingDir:l},`${s}:${i.path}`))})]})}function Wm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m}=Co(e);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const v=s?.uncommitted||[],C=s?.committed||[];return v.length+C.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(is,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx(tn,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(tn,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const gr=50,sn={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 $m(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Rt("{count}s ago",{count:s}):s<3600?Rt("{count}m ago",{count:Math.floor(s/60)}):s<86400?Rt("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Rt("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Um(e){const t=e.split("/");return t[t.length-1]||e}function qm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Km({workingDir:e,hash:t,filePath:s}){const{t:l}=he(),{data:m,isLoading:v,isError:C}=ko(e,t,s);if(v)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const i=r.split(`
81
- `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function Xm({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=sn[e.status]||sn.M,C=qm(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",v),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:Um(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(Ct,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Km,{workingDir:t,hash:s,filePath:e.path})]})}function Ym({commit:e,workingDir:t}){const{t:s}=he(),[l,m]=k.useState(!1),{data:v,isLoading:C}=Eo(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:Se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"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",l?"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:$m(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(Ct,{size:14}):a.jsx(Ft,{size:14})})]}),l&&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}),C?a.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:s("Loading files...")})]}):r.length===0?a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:s("No files changed")}):a.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>a.jsx(Xm,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function Vm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:c=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(gr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<gr?void 0:f.length*gr,enabled:!!e}),i=s?.pages.flatMap(c=>c.commits)||[];return e?l?a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):i.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(Ut,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("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:i.map(c=>a.jsx(Ym,{commit:c,workingDir:e},c.hash))}),C&&a.jsx("button",{type:"button",onClick:()=>v(),disabled:r,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:r?a.jsxs(a.Fragment,{children:[a.jsx(Ue,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const Gm="/api",Qm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Gm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Zm=({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"})}),Jm={img:Zm};function ep({status:e}){const t={[ce.Running]:"bg-blue-500",[ce.Review]:"bg-amber-500",[ce.Pending]:"bg-neutral-400",[ce.Done]:"bg-emerald-500",[ce.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const tp=[{key:"chat",label:"Chat",icon:al},{key:"changes",label:"Changes",icon:is},{key:"history",label:"History",icon:Ut},{key:"workspace",label:"Workspace",icon:kn}];function sp({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=he(),[v,C]=k.useState("chat"),[r,i]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[S,y]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:x,scrollToBottom:w}=Vn({resize:"smooth",initial:"instant"}),E=ze();k.useEffect(()=>{if(!S)return;const Y=ie=>{n.current&&!n.current.contains(ie.target)&&y(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[S]);const{data:b,isLoading:R}=Do(e.id),j=k.useMemo(()=>{if(!b)return null;const Y=b.filter(me=>me.status==="ACTIVE"&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]),ie=me=>{const it=me.createdAt,et=me.endedAt??me.startedAt??it;if(!et)return 0;const dt=Date.parse(et);return Number.isNaN(dt)?0:dt},Ce=me=>{const it=Y.filter(et=>me.includes(et.status));return it.length===0?null:it.sort((et,dt)=>ie(dt)-ie(et))[0]??null},_e=Ce([Te.RUNNING])??Ce([Te.PENDING])??Ce([Te.COMPLETED,Te.FAILED,Te.CANCELLED]);if(_e)return _e;const Qe=b.filter(me=>(me.status==="ABANDONED"||me.status==="MERGED"||me.status==="HIBERNATED")&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]).filter(me=>[Te.COMPLETED,Te.FAILED,Te.CANCELLED].includes(me.status));return Qe.length===0?null:Qe.sort((me,it)=>ie(it)-ie(me))[0]??null},[b]),L=j?.id??"",M=j?.status===Te.RUNNING||j?.status===Te.PENDING,T=!!e.projectArchivedAt,B=!!e.projectRepoDeletedAt,I=m(B?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),H=k.useMemo(()=>!j||!b?!1:!b.some(ie=>ie.status==="ACTIVE"&&ie.sessions?.some(Ce=>Ce.id===j.id)),[j,b]),{data:W}=Hs(),[A,N]=k.useState(null);k.useEffect(()=>{N(j?.providerId??null)},[j?.providerId]);const P=k.useMemo(()=>{if(b){for(const Y of b)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return b[0]?.worktreePath}},[b]),O=Bo({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),$=Io({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),X=k.useMemo(()=>{if(b)return b.find(Y=>Y.status==="ACTIVE")?.id},[b]),K=k.useMemo(()=>{const Y=[];if(b&&b.length>0){const ie=b.some(_e=>_e.status==="ACTIVE");b.some(_e=>_e.sessions?.some(We=>We.status===Te.RUNNING||We.status===Te.PENDING))&&Y.push(m("正在运行的 Agent 将被停止")),ie&&(Y.push(m("分支上未合并的变更将丢失")),Y.push(m("关联的工作目录(worktree)将被清理")))}return Y},[b,m]),Q=Zr(),se=Gr(),D=To(),{isConnected:F,isLoadingSnapshot:U,logs:z,entries:ee,attach:V}=dn({sessionId:L,sessionStatus:j?.status,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:ne}=fn(ee),{files:ve,addFiles:fe,removeFile:Le,clear:re,buildMarkdownLinks:Be,hasFiles:ye,isUploading:ae}=Jr(),Me=k.useMemo(()=>{if(!j?.tokenUsage)return;const Y=j.tokenUsage;if(typeof Y.totalTokens=="number")return Y},[j?.tokenUsage]),Ke=Lo(z,Me);k.useEffect(()=>{L&&F&&V()},[L,F,V]);const Ae=k.useRef(null);k.useEffect(()=>{if(Ae.current!==e.id&&u.current){const Y=u.current;requestAnimationFrame(()=>{Y.scrollTop=Y.scrollHeight})}Ae.current=e.id},[e.id,u]);const Xe=k.useRef(!1),ge=k.useCallback(async()=>{if(!r.trim()&&!ye||!L||Xe.current||ae)return;Xe.current=!0;const Y=Be(),ie=[r.trim(),Y].filter(Boolean).join(`
79
+ `);C(""),be(),R.current&&(R.current.style.height="60px"),Ye.mutate({id:F,message:te,providerId:ve??void 0},{onSuccess:()=>{Ie()},onSettled:()=>{St.current=!1}})},[v,F,Ye,Ie,st,Oe,ke,be,ve]),Lt=k.useCallback(async()=>{F&&(await xt.mutateAsync(F),ge.invalidateQueries({queryKey:["workspaces"]}))},[F,xt,ge]),Xt=k.useCallback(G=>{const te=G.target.files;te&&te.length>0&&le(Array.from(te)),G.target.value=""},[le]),Jo=k.useCallback(G=>{const te=G.clipboardData.items,Re=[];for(const lt of te)if(lt.kind==="file"){const Ze=lt.getAsFile();Ze&&Re.push(Ze)}Re.length>0&&(G.preventDefault(),le(Re))},[le]),[ti,Js]=k.useState(!1),ea=k.useCallback(G=>{G.preventDefault(),Js(!0)},[]),ta=k.useCallback(G=>{G.preventDefault(),Js(!1)},[]),sa=k.useCallback(G=>{G.preventDefault(),Js(!1);const te=G.dataTransfer.files;te.length>0&&le(Array.from(te))},[le]),er=k.useCallback(G=>{const te=G.clientX-O.current,Re=Math.max(Qi,Math.min($.current+te,Zi));X.current&&(X.current.style.width=`${Re}px`)},[]),tr=k.useCallback(()=>{if(P(!1),X.current){const G=X.current.getBoundingClientRect().width;H(Math.max(Qi,Math.min(Math.round(G),Zi)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);k.useEffect(()=>{if(N)return document.addEventListener("mousemove",er),document.addEventListener("mouseup",tr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",er),document.removeEventListener("mouseup",tr),document.body.style.cursor="",document.body.style.userSelect=""}},[N,er,tr]);const ra=k.useCallback(G=>{G.preventDefault(),O.current=G.clientX,$.current=I,P(!0)},[I]),ia=k.useCallback(()=>{A(G=>!G)},[]),na=k.useCallback(G=>{C(G.target.value);const te=G.target;te.style.height="auto";const Re=te.scrollHeight;te.style.height=`${Math.max(60,Math.min(Re,300))}px`},[]),si=k.useMemo(()=>{const G=[];if(K&&K.length>0){const te=K.some(Ze=>Ze.status==="ACTIVE"),Re=K.some(Ze=>Ze.sessions?.some($e=>$e.status===Te.RUNNING||$e.status===Te.PENDING)),lt=K.some(Ze=>Ze.status==="ACTIVE");Re&&G.push(m("正在运行的 Agent 将被停止")),lt&&G.push(m("分支上未合并的变更将丢失")),te&&G.push(m("关联的工作目录(worktree)将被清理"))}return G},[K,m]);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}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),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(jm,{status:e.status,onChangeStatus:!z&&l?G=>l(e.id,G):void 0}),ae&&!z&&a.jsx("button",{onClick:()=>h(!0),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Git 操作"),children:a.jsx(Za,{size:18})}),a.jsx("button",{onClick:We,disabled:!ae||z,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:a.jsx(zs,{size:18})}),a.jsx("button",{onClick:ia,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:W?a.jsx(fl,{size:18}):a.jsx(pl,{size:18})}),t&&!z&&a.jsxs("div",{className:"relative",ref:b,children:[a.jsx("button",{onClick:()=>_(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:a.jsx(wn,{size:18})}),u&&a.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[a.jsxs("button",{onClick:()=>{p(!0),_(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[a.jsx(ka,{size:15}),a.jsx("span",{children:m("重新开始")})]}),a.jsxs("button",{onClick:()=>{f(!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(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})]})]})]})]}),ae&&Me&&a.jsx(sm,{workspaceId:ae,gitStatus:Me,onResolve:()=>n(!0)}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{ref:X,className:`flex flex-col bg-white relative ${W?"flex-shrink-0":"flex-1"}`,style:{width:W?I:"100%"},children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:L,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:a.jsxs("div",{ref:M,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(mn,{urlTransform:Em,components:Rm,children:e.description})}):a.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),se&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[se.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.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:se.currentIndex,total:se.totalCommands,command:se.currentCommand})})]}),se.status==="completed"&&a.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),se.status==="failed"&&a.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:se.error})})]}),Q?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:m("Loading...")})]}):F?it?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:m("Loading logs...")})]}):et.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(U?"Waiting for agent output...":"No logs recorded for this session.")}):a.jsx(pn,{logs:et}):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(Pt,{size:24,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(z?"项目为只读历史":"尚未启动 Agent")}),a.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:z?V:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!z&&a.jsxs(pt,{onClick:()=>i(!0),children:[a.jsx(Pt,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!T&&a.jsxs("button",{onClick:()=>B(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[a.jsx(Sn,{size:14}),a.jsx("span",{children:m("回到底部")})]})]}),q.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(vn,{todos:q})}),z?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.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:V})}):Le?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:m("代码已合并,以上为历史沟通记录")}),a.jsxs(pt,{size:"sm",onClick:()=>i(!0),children:[a.jsx(Pt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):a.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:ea,onDragLeave:ta,onDrop:sa,children:[a.jsxs("div",{ref:E,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 ${ti?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[a.jsx(Ns,{files:Z,onRemove:pe}),a.jsx("textarea",{ref:R,value:v,onChange:na,onPaste:Jo,onKeyDown:G=>{ye.handleKeyDown(G)||Be.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),ft())},rows:1,placeholder:m(ti?"Drop files here...":F&&!U?"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:j,type:"file",multiple:!0,className:"hidden",onChange:Xt}),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:()=>j.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:a.jsx(ws,{size:18})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[D&&ne&&a.jsx(No,{providers:ne,currentProviderId:ve,agentType:D.agentType,onSelect:fe}),a.jsx(Gn,{usage:ot}),U&&!v.trim()&&!st?a.jsx("button",{onClick:Lt,disabled:xt.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(gn,{size:14})}):a.jsx("button",{onClick:ft,disabled:!v.trim()&&!st||Oe,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||st)&&!Oe?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:a.jsx(Cn,{size:18})})]})]})]}),a.jsx(Ps,{open:Be.query!==null,anchorRef:E,commands:Be.filteredCommands,selectedIndex:Be.selectedIndex,query:Be.query??"",hasCatalog:Be.allCommands.length>0,onSelect:Be.applyCommand}),a.jsx(Ps,{open:ye.query!==null,anchorRef:E,commands:ye.filteredSkills,selectedIndex:ye.selectedIndex,query:ye.query??"",hasCatalog:ye.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:ye.applySkill})]})]}),W&&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:ra}),W&&a.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:a.jsx(Ro,{sessionId:F||void 0,workingDir:re,projectId:e.projectId,readOnly:z,repoDeleted:ee})})]}),!z&&a.jsx(Mo,{isOpen:r,onClose:()=>i(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),ae&&!z&&a.jsx(om,{open:d,onOpenChange:h,workspaceId:ae,branchName:Ae,targetBranch:e.mainBranch,commitMessage:Xe,onRefreshCommitMessage:rt,onConflict:()=>n(!0)}),ae&&Me&&Me.conflictOp&&a.jsx(im,{open:g,onOpenChange:n,workspaceId:ae,conflictOp:Me.conflictOp,conflictedFiles:Me.conflictedFiles,sourceBranch:Ae,targetBranch:e.mainBranch,sessions:Ke}),a.jsx(Sr,{isOpen:o,onClose:()=>p(!1),onConfirm:_e,title:m("重新开始任务"),description:a.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:S}),a.jsx(Sr,{isOpen:c,onClose:()=>f(!1),onConfirm:Qe,title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),si.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:si.map((G,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:G})]},te))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):a.jsx(Am,{})}function ei(e){switch(e){case _t.TODO:return ce.Pending;case _t.IN_PROGRESS:return ce.Running;case _t.IN_REVIEW:return ce.Review;case _t.DONE:return ce.Done;case _t.CANCELLED:return ce.Cancelled}}function Lm(e){switch(e){case ce.Pending:return _t.TODO;case ce.Running:return _t.IN_PROGRESS;case ce.Review:return _t.IN_REVIEW;case ce.Done:return _t.DONE;case ce.Cancelled:return _t.CANCELLED}}function Mm(e){switch(e){case bt.CLAUDE_CODE:return"Claude Code";case bt.GEMINI_CLI:return"Gemini CLI";case bt.CURSOR_AGENT:return"Cursor Agent";case bt.CODEX:return"Codex"}}const Os=["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 Fo(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 Ho(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function Nm(e){return{id:e.id,name:e.name,color:e.color||Os[Fo(e.name,Os.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Pm(e){const t=Ho(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:Mm(m.agentType),branch:s}}return{agent:"—",branch:s}}function Om(e){const{agent:t,branch:s}=Pm(e.workspaces),l=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:ei(e.status),agent:t,branch:s,description:e.description??"",projectArchivedAt:l?.archivedAt??null,projectRepoDeletedAt:l?.repoDeletedAt??null}}function Bm(e,t,s){const l=Ho(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Os[Fo(t.name,Os.length)],title:e.title,status:ei(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const en={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 Im(e){const t=e.split("/");return t[t.length-1]||e}function Fm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Hm({workingDir:e,filePath:t,type:s}){const{t:l}=he(),{data:m,isLoading:v,isError:C}=wo(e,t,s);if(v)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const i=r.split(`
80
+ `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function zm({entry:e,type:t,workingDir:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=Fm(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",v),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:Im(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(Ct,{size:14}):a.jsx(It,{size:14})})]}),l&&a.jsx(Hm,{workingDir:s,filePath:e.path,type:t})]})}function tn({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=he(),[C,r]=k.useState(m);return t.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>r(i=>!i),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:C?a.jsx(Ct,{size:14}):a.jsx(It,{size:14})}),a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),C&&a.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(i=>a.jsx(zm,{entry:i,type:s,workingDir:l},`${s}:${i.path}`))})]})}function Wm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m}=Co(e);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const v=s?.uncommitted||[],C=s?.committed||[];return v.length+C.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(is,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx(tn,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(tn,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const gr=50,sn={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 $m(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Rt("{count}s ago",{count:s}):s<3600?Rt("{count}m ago",{count:Math.floor(s/60)}):s<86400?Rt("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Rt("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Um(e){const t=e.split("/");return t[t.length-1]||e}function qm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Km({workingDir:e,hash:t,filePath:s}){const{t:l}=he(),{data:m,isLoading:v,isError:C}=ko(e,t,s);if(v)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const i=r.split(`
81
+ `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function Xm({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=sn[e.status]||sn.M,C=qm(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",v),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:Um(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(Ct,{size:14}):a.jsx(It,{size:14})})]}),l&&a.jsx(Km,{workingDir:t,hash:s,filePath:e.path})]})}function Ym({commit:e,workingDir:t}){const{t:s}=he(),[l,m]=k.useState(!1),{data:v,isLoading:C}=Eo(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:Se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"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",l?"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:$m(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(Ct,{size:14}):a.jsx(It,{size:14})})]}),l&&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}),C?a.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[a.jsx(Ue,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:s("Loading files...")})]}):r.length===0?a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:s("No files changed")}):a.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>a.jsx(Xm,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function Vm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:c=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(gr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<gr?void 0:f.length*gr,enabled:!!e}),i=s?.pages.flatMap(c=>c.commits)||[];return e?l?a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(Ue,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):i.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(Ut,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("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:i.map(c=>a.jsx(Ym,{commit:c,workingDir:e},c.hash))}),C&&a.jsx("button",{type:"button",onClick:()=>v(),disabled:r,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:r?a.jsxs(a.Fragment,{children:[a.jsx(Ue,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const Gm="/api",Qm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Gm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Zm=({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"})}),Jm={img:Zm};function ep({status:e}){const t={[ce.Running]:"bg-blue-500",[ce.Review]:"bg-amber-500",[ce.Pending]:"bg-neutral-400",[ce.Done]:"bg-emerald-500",[ce.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const tp=[{key:"chat",label:"Chat",icon:al},{key:"changes",label:"Changes",icon:is},{key:"history",label:"History",icon:Ut},{key:"workspace",label:"Workspace",icon:kn}];function sp({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=he(),[v,C]=k.useState("chat"),[r,i]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[S,y]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:x,scrollToBottom:w}=Vn({resize:"smooth",initial:"instant"}),E=ze();k.useEffect(()=>{if(!S)return;const Y=ie=>{n.current&&!n.current.contains(ie.target)&&y(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[S]);const{data:b,isLoading:R}=Do(e.id),j=k.useMemo(()=>{if(!b)return null;const Y=b.filter(me=>me.status==="ACTIVE"&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]),ie=me=>{const it=me.createdAt,et=me.endedAt??me.startedAt??it;if(!et)return 0;const dt=Date.parse(et);return Number.isNaN(dt)?0:dt},Ce=me=>{const it=Y.filter(et=>me.includes(et.status));return it.length===0?null:it.sort((et,dt)=>ie(dt)-ie(et))[0]??null},_e=Ce([Te.RUNNING])??Ce([Te.PENDING])??Ce([Te.COMPLETED,Te.FAILED,Te.CANCELLED]);if(_e)return _e;const Qe=b.filter(me=>(me.status==="ABANDONED"||me.status==="MERGED"||me.status==="HIBERNATED")&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]).filter(me=>[Te.COMPLETED,Te.FAILED,Te.CANCELLED].includes(me.status));return Qe.length===0?null:Qe.sort((me,it)=>ie(it)-ie(me))[0]??null},[b]),L=j?.id??"",M=j?.status===Te.RUNNING||j?.status===Te.PENDING,T=!!e.projectArchivedAt,B=!!e.projectRepoDeletedAt,I=m(B?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),H=k.useMemo(()=>!j||!b?!1:!b.some(ie=>ie.status==="ACTIVE"&&ie.sessions?.some(Ce=>Ce.id===j.id)),[j,b]),{data:W}=Hs(),[A,N]=k.useState(null);k.useEffect(()=>{N(j?.providerId??null)},[j?.providerId]);const P=k.useMemo(()=>{if(b){for(const Y of b)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return b[0]?.worktreePath}},[b]),O=Bo({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),$=Io({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),X=k.useMemo(()=>{if(b)return b.find(Y=>Y.status==="ACTIVE")?.id},[b]),K=k.useMemo(()=>{const Y=[];if(b&&b.length>0){const ie=b.some(_e=>_e.status==="ACTIVE");b.some(_e=>_e.sessions?.some(We=>We.status===Te.RUNNING||We.status===Te.PENDING))&&Y.push(m("正在运行的 Agent 将被停止")),ie&&(Y.push(m("分支上未合并的变更将丢失")),Y.push(m("关联的工作目录(worktree)将被清理")))}return Y},[b,m]),Q=Zr(),se=Gr(),D=To(),{isConnected:F,isLoadingSnapshot:U,logs:z,entries:ee,attach:V}=dn({sessionId:L,sessionStatus:j?.status,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:ne}=fn(ee),{files:ve,addFiles:fe,removeFile:Le,clear:re,buildMarkdownLinks:Be,hasFiles:ye,isUploading:ae}=Jr(),Me=k.useMemo(()=>{if(!j?.tokenUsage)return;const Y=j.tokenUsage;if(typeof Y.totalTokens=="number")return Y},[j?.tokenUsage]),Ke=Lo(z,Me);k.useEffect(()=>{L&&F&&V()},[L,F,V]);const Ae=k.useRef(null);k.useEffect(()=>{if(Ae.current!==e.id&&u.current){const Y=u.current;requestAnimationFrame(()=>{Y.scrollTop=Y.scrollHeight})}Ae.current=e.id},[e.id,u]);const Xe=k.useRef(!1),ge=k.useCallback(async()=>{if(!r.trim()&&!ye||!L||Xe.current||ae)return;Xe.current=!0;const Y=Be(),ie=[r.trim(),Y].filter(Boolean).join(`
82
82
 
83
- `);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:L,message:ie,providerId:A??void 0},{onSuccess:()=>V(),onSettled:()=>{Xe.current=!1}})},[r,L,Q,V,ye,ae,Be,re,A]),rt=k.useCallback(async()=>{L&&(await D.mutateAsync(L),E.invalidateQueries({queryKey:["workspaces"]}))},[L,D,E]),Ye=k.useCallback(Y=>{const ie=Y.target.files;ie&&ie.length>0&&fe(Array.from(ie)),Y.target.value=""},[fe]),Ne=k.useCallback(Y=>{const ie=Y.clipboardData.items,Ce=[];for(const _e of ie)if(_e.kind==="file"){const We=_e.getAsFile();We&&Ce.push(We)}Ce.length>0&&(Y.preventDefault(),fe(Ce))},[fe]),Pe=k.useCallback(Y=>{i(Y.target.value);const ie=Y.target;ie.style.height="auto",ie.style.height=`${Math.max(40,Math.min(ie.scrollHeight,140))}px`},[]),He=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),we=k.useRef(null);return k.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let ie=!1;const Ce=()=>{we.current&&(we.current.style.height=`${Y.height}px`,we.current.style.top=`${Y.offsetTop}px`)},_e=()=>Ce(),We=()=>{ie||Ce()},Qe=()=>{ie=!0},me=()=>{ie=!1,requestAnimationFrame(Ce)};return Y.addEventListener("resize",_e),Y.addEventListener("scroll",We),document.addEventListener("touchstart",Qe,{passive:!0}),document.addEventListener("touchend",me,{passive:!0}),document.addEventListener("touchcancel",me,{passive:!0}),()=>{Y.removeEventListener("resize",_e),Y.removeEventListener("scroll",We),document.removeEventListener("touchstart",Qe),document.removeEventListener("touchend",me),document.removeEventListener("touchcancel",me)}},[]),k.useEffect(()=>{const Y=we.current;if(!Y)return;const ie=Ce=>{let _e=Ce.target;for(;_e&&_e!==Y;){if(_e.tagName==="TEXTAREA"){if(_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement;continue}const Qe=window.getComputedStyle(_e).overflowY;if((Qe==="auto"||Qe==="scroll")&&_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement}Ce.preventDefault()};return Y.addEventListener("touchmove",ie,{passive:!1}),()=>Y.removeEventListener("touchmove",ie)},[]),a.jsxs("div",{ref:we,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(ya,{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}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(ep,{status:e.status}),a.jsx("button",{onClick:He,disabled:!X||T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(zs,{size:16})}),s&&!T&&a.jsxs("div",{className:"relative",ref:n,children:[a.jsx("button",{onClick:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(wn,{size:16})}),S&&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:()=>{p(!0),y(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:tp.map(({key:Y,label:ie,icon:Ce})=>a.jsxs("button",{onClick:()=>C(Y),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(Ce,{size:13}),a.jsx("span",{children:ie})]},Y))})]}),v==="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:u,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:_,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(mn,{urlTransform:Qm,components:Jm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(rn,{label:"Loading..."}):L?U?a.jsx(rn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:M?"Waiting for agent output...":"No logs recorded."}):a.jsx(pn,{logs:z}):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(Ot,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:T?I:m("选择一个 Agent 来执行此任务")}),!T&&a.jsxs(pt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!x&&a.jsxs("button",{onClick:()=>w(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(Sn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ne.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(vn,{todos:ne,compact:!0})}),T?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:I})}):H?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[a.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),a.jsxs(pt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):L&&a.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[a.jsxs("div",{ref:g,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Ns,{files:ve,onRemove:Le}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ne,onKeyDown:Y=>{$.handleKeyDown(Y)||O.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),ge())},rows:1,placeholder:M?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:Ye}),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:()=>h.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ws,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[j&&W&&a.jsx(No,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Gn,{usage:Ke}),M&&!r.trim()&&!ye?a.jsx("button",{onClick:rt,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(gn,{size:12})}):a.jsx("button",{onClick:ge,disabled:!r.trim()&&!ye||ae,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||ye)&&!ae?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Cn,{size:15})})]})]})]}),a.jsx(Ps,{open:O.query!==null,anchorRef:g,commands:O.filteredCommands,selectedIndex:O.selectedIndex,query:O.query??"",hasCatalog:O.allCommands.length>0,compact:!0,onSelect:O.applyCommand}),a.jsx(Ps,{open:$.query!==null,anchorRef:g,commands:$.filteredSkills,selectedIndex:$.selectedIndex,query:$.query??"",hasCatalog:$.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:$.applySkill})]})]}),v==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Wm,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Ro,{sessionId:L||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Mo,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(Sr,{isOpen:o,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),K.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:K.map((Y,ie)=>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:Y})]},ie))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function rn({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 rp=Object.defineProperty,Bs=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable,nn=(e,t,s)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ar=(e,t)=>{for(var s in t||(t={}))zo.call(t,s)&&nn(e,s,t[s]);if(Bs)for(var s of Bs(t))Wo.call(t,s)&&nn(e,s,t[s]);return e},jr=(e,t)=>{var s={};for(var l in e)zo.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&Bs)for(var l of Bs(e))t.indexOf(l)<0&&Wo.call(e,l)&&(s[l]=e[l]);return s};var It;(e=>{const t=class de{constructor(i,c,f,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<de.MIN_VERSION||i>de.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 y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(f);if(this.drawCodewords(S),o==-1){let y=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<y&&(o=g,y=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const f=e.QrSegment.makeSegments(i);return de.encodeSegments(f,c)}static encodeBinary(i,c){const f=e.QrSegment.makeBytes(i);return de.encodeSegments([f],c)}static encodeSegments(i,c,f=1,o=40,p=-1,S=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,g;for(y=f;;y++){const u=de.getNumDataCodewords(y,c)*8,_=C.getTotalBits(i,y);if(_<=u){g=_;break}if(y>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])S&&g<=de.getNumDataCodewords(y,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(y),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(y,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(y,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 f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let f=0;f<c;f++)for(let o=0;o<c;o++)f==0&&o==0||f==0&&o==c-1||f==c-1&&o==0||this.drawAlignmentPattern(i[f],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const o=(c<<10|f)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,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 f=0;f<12;f++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let f=0;f<18;f++){const o=l(c,f),p=this.size-11+f%3,S=Math.floor(f/3);this.setFunctionModule(p,S,o),this.setFunctionModule(S,p,o)}}drawFinderPattern(i,c){for(let f=-4;f<=4;f++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(f)),S=i+o,y=c+f;0<=S&&S<this.size&&0<=y&&y<this.size&&this.setFunctionModule(S,y,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let f=-2;f<=2;f++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+f,Math.max(Math.abs(o),Math.abs(f))!=1)}setFunctionModule(i,c,f){this.modules[c][i]=f,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,f=this.errorCorrectionLevel;if(i.length!=de.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const o=de.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=de.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],S=Math.floor(de.getNumRawDataModules(c)/8),y=o-S%o,g=Math.floor(S/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let x=i.slice(_,_+g-p+(u<y?0:1));_+=x.length;const w=de.reedSolomonComputeRemainder(x,d);u<y&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,x)=>{(u!=g-p||x>=y)&&h.push(_[u])});return m(h.length==S),h}drawCodewords(i){if(i.length!=Math.floor(de.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const S=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][S]&&c<i.length*8&&(this.modules[g][S]=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 f=0;f<this.size;f++){let o;switch(i){case 0:o=(f+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=f%3==0;break;case 3:o=(f+c)%3==0;break;case 4:o=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:o=f*c%2+f*c%3==0;break;case 6:o=(f*c%2+f*c%3)%2==0;break;case 7:o=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&o&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[p][n],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[n][p],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let S=0;S<this.size-1;S++){const y=this.modules[p][S];y==this.modules[p][S+1]&&y==this.modules[p+1][S]&&y==this.modules[p+1][S+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((S,y)=>S+(y?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),i+=o*de.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 f=[6];for(let o=this.size-7;f.length<i;o-=c)f.splice(1,0,o);return f}}static getNumRawDataModules(i){if(i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const f=Math.floor(i/7)+2;c-=(25*f-10)*f-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(de.getNumRawDataModules(i)/8)-de.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*de.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 f=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=de.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=de.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(i,c){let f=c.map(o=>0);for(const o of i){const p=o^f.shift();f.push(0),c.forEach((S,y)=>f[y]^=de.reedSolomonMultiply(S,p))}return f}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let o=7;o>=0;o--)f=f<<1^(f>>>7)*285,f^=(c>>>o&1)*i;return m(f>>>8==0),f}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const f=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(f&&i[0]>=c*4&&i[6]>=c?1:0)+(f&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,f){return i&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}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 f=i-1;f>=0;f--)c.push(r>>>f&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const v=class Fe{constructor(i,c,f){if(this.mode=i,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(i){let c=[];for(const f of i)s(f,8,c);return new Fe(Fe.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Fe.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<i.length;){const o=Math.min(i.length-f,3);s(parseInt(i.substring(f,f+o),10),o*3+1,c),f+=o}return new Fe(Fe.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Fe.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=i.length;f+=2){let o=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Fe(Fe.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Fe.isNumeric(i)?[Fe.makeNumeric(i)]:Fe.isAlphanumeric(i)?[Fe.makeAlphanumeric(i)]:[Fe.makeBytes(Fe.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 Fe(Fe.Mode.ECI,0,c)}static isNumeric(i){return Fe.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Fe.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let f=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;f+=4+p+o.bitData.length}return f}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let f=0;f<i.length;f++)i.charAt(f)!="%"?c.push(i.charCodeAt(f)):(c.push(parseInt(i.substring(f+1,f+3),16)),f+=2);return c}};v.NUMERIC_REGEX=/^[0-9]*$/,v.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,v.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=v;e.QrSegment=v})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.ordinal=m,this.formatBits=v}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.modeBits=m,this.numBitsCharCount=v}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(It||(It={}));var Wt=It;var ip={L:Wt.QrCode.Ecc.LOW,M:Wt.QrCode.Ecc.MEDIUM,Q:Wt.QrCode.Ecc.QUARTILE,H:Wt.QrCode.Ecc.HIGH},$o=128,Uo="L",qo="#FFFFFF",Ko="#000000",Xo=!1,Yo=1,np=4,op=0,ap=.1;function Vo(e,t=0){const s=[];return e.forEach(function(l,m){let v=null;l.forEach(function(C,r){if(!C&&v!==null){s.push(`M${v+t} ${m+t}h${r-v}v1H${v+t}z`),v=null;return}if(r===l.length-1){if(!C)return;v===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${v+t},${m+t} h${r+1-v}v1H${v+t}z`);return}C&&v===null&&(v=r)})}),s.join("")}function Go(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function lp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*ap),C=m/t,r=(l.width||v)*C,i=(l.height||v)*C,c=l.x==null?e.length/2-r/2:l.x*C,f=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 y=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-y),d=Math.ceil(i+f-g);p={x:y,y:g,w:n,h:d}}const S=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:S}}function cp(e,t){return t!=null?Math.max(Math.floor(t),0):e?np:op}function Qo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=J.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Wt.QrSegment.makeSegments(n)),g),[]);return Wt.QrCode.encodeSegments(y,ip[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=J.useMemo(()=>{let S=i.getModules();const y=cp(l,m),g=S.length+y*2,n=lp(S,C,y,v);return{cells:S,margin:y,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var hp=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),up=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,marginSize:p,imageSettings:S}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=jr(g,["style"]),h=S?.src,u=J.useRef(null),_=J.useRef(null),x=J.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=J.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:L}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:S,size:v});J.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&L.excavation!=null&&(H=Go(R,L.excavation));const N=window.devicePixelRatio||1;B.height=B.width=v*N;const P=v/j*N;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,hp?I.fill(new Path2D(Vo(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(W,L.x+b,L.y+b,L.w,L.h)}}),J.useEffect(()=>{E(!1)},[h]);const M=Ar({height:v,width:v},n);let T=null;return h!=null&&(T=J.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:L?.crossOrigin})),J.createElement(J.Fragment,null,J.createElement("canvas",Ar({style:M,height:v,width:v,ref:x,role:"img"},d)),T)});up.displayName="QRCodeCanvas";var Zo=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,title:p,marginSize:S,imageSettings:y}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:S,imageSettings:y,size:v});let _=d,x=null;y!=null&&u!=null&&(u.excavation!=null&&(_=Go(d,u.excavation)),x=J.createElement("image",{href:y.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=Vo(_,n);return J.createElement("svg",Ar({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&J.createElement("title",null,p),J.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),J.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Zo.displayName="QRCodeSVG";function dp(){return ut({queryKey:oe.tunnel.status,queryFn:()=>ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function fp(){const e=ze();return Je({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ue.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function mp(){const e=ze();return Je({mutationFn:()=>ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function on(){const{t:e}=he(),{data:t}=dp(),s=fp(),l=mp(),[m,v]=k.useState(!1),[C,r]=k.useState(null),i=k.useRef(null),[c,f]=k.useState({top:0,right:0}),[o,p]=k.useState(!1),S=t?.running??!1,y=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const x=i.current.getBoundingClientRect();f({top:x.bottom+8,right:window.innerWidth-x.right})}},[m]);const d=k.useCallback(()=>{S?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[S,s]),h=k.useCallback(()=>{g&&(navigator.clipboard.writeText(g),r("url"),setTimeout(()=>r(null),2e3))},[g]),u=k.useCallback(()=>{n&&(navigator.clipboard.writeText(n),r("token"),setTimeout(()=>r(null),2e3))},[n]),_=k.useCallback(()=>{l.mutate(),v(!1),p(!1)},[l]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:i,onClick:d,disabled:y,className:`p-1.5 rounded-md transition-colors ${S?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(S?"Tunnel active":"Share via tunnel"),children:y?a.jsx(Ue,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),S&&!y&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&S&&Nt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:c.top,right:c.right},children:[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"}),e("Tunnel Active")]}),a.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(Fs,{size:14})})]}),n&&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(xl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Zo,{value:g,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:g??t?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:x=>x.target.select()}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:e("Copy shareable link"),children:C==="url"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(fi,{size:14})})]}),n&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>p(!o),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(o?"Hide token":"Show token")}),o&&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:n}),a.jsx("button",{onClick:u,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:C==="token"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(fi,{size:14})})]})]}),a.jsx("button",{onClick:_,disabled:l.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:l.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}const an={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>un(()=>import("./modal-CvoxLn2x.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),_r=k.lazy(()=>un(()=>import("./folder-picker-CTcrs_BC.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),ln=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"})]}),cn=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),pp=260,vp=600,hn=400;function Lp(){const{t:e}=he(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(hn),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[S,y]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[x,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:L,clear:M,buildMarkdownLinks:T,isUploading:B}=Jr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(hn),N=k.useRef(null),P=ze(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=Ca(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(Nm),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Uf(D??""),z=La({queries:D?[]:Q.map(q=>({queryKey:oe.tasks.list(q.id),queryFn:()=>ue.get(`/projects/${q.id}/tasks`,{params:{limit:"500"}})}))}),ee=!D&&z.some(q=>q.isLoading),V=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const Z of z)Z.data?.data&&q.push(...Z.data.data);return q},[D,F,z]),ne=t&&V.some(q=>q.id===t)?t:null,ve=k.useMemo(()=>{const q=new Map;for(const Z of V){const le=Z.createdAt?new Date(Z.createdAt).getTime():0,pe=q.get(Z.projectId)??0;le>pe&&q.set(Z.projectId,le)}return[...Q].sort((Z,le)=>{const pe=q.get(Z.id)??(Z.createdAt?new Date(Z.createdAt).getTime():0);return(q.get(le.id)??(le.createdAt?new Date(le.createdAt).getTime():0))-pe})},[Q,V]),fe=k.useMemo(()=>ve.filter(q=>!q.archivedAt),[ve]),Le=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),Z=q?JSON.parse(q):{};return[...O].sort((le,pe)=>{const be=le.availability.type!=="NOT_FOUND",ke=pe.availability.type!=="NOT_FOUND";if(be!==ke)return be?-1:1;const st=Z[le.provider.id]??0;return(Z[pe.provider.id]??0)-st})},[O]),re=k.useMemo(()=>V.map(Om),[V]),Be=k.useMemo(()=>new Set,[]),ye=k.useMemo(()=>{if(!ne)return null;const q=V.find(le=>le.id===ne);if(!q)return null;const Z=Q.find(le=>le.id===q.projectId);if(!Z){const le=q.workspaces?.find(pe=>pe.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:ei(q.status),branch:le,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Bm(q,Z)},[ne,V,Q]),ae=wa(),Me=qf(u),Ke=Xf(),Ae=Kf(),Xe=k.useCallback(q=>{Ke.mutate(q,{onSuccess:()=>{ne===q&&s(null),P.invalidateQueries({queryKey:oe.tasks.all})}})},[Ke,ne,P]),ge=k.useCallback((q,Z)=>{Ae.mutate({id:q,status:Lm(Z)},{onError:()=>{ai.error(e("状态变更失败,该操作不被允许"))}})},[Ae,e]),rt=k.useCallback(q=>{q.preventDefault(),H.current=!0,W.current=q.clientX,A.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);k.useEffect(()=>{const q=le=>{if(!H.current)return;const pe=le.clientX-W.current,be=Math.max(pp,Math.min(vp,A.current+pe));C(be)},Z=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Z),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z)}},[]);const Ye=k.useCallback(()=>{i(!0)},[]),Ne=k.useCallback(()=>{if(fe.length===0){ai.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),Z=localStorage.getItem("lastSelectedProviderId"),le=q&&fe.find(ke=>ke.id===q)?q:(D&&fe.find(ke=>ke.id===D)?.id)??fe[0]?.id??"";_(le);const pe=Le?.find(ke=>ke.availability.type!=="NOT_FOUND"),be=Z&&Le?.find(ke=>ke.provider.id===Z&&ke.availability.type!=="NOT_FOUND")?Z:pe?.provider.id??"";w(be),b("idle"),f(!0)},[fe,D,Le,e]),Pe=k.useCallback(()=>{i(!1),p(""),y("")},[]),He=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),M())},[E,M]),we=k.useCallback(async()=>{if(!(!o.trim()||!S.trim()))try{await ae.mutateAsync({name:o.trim(),repoPath:S.trim()}),Pe()}catch{}},[o,S,ae,Pe]),Y=Qr(),ie=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),Z=[d.trim(),q].filter(Boolean).join(`
83
+ `);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:L,message:ie,providerId:A??void 0},{onSuccess:()=>V(),onSettled:()=>{Xe.current=!1}})},[r,L,Q,V,ye,ae,Be,re,A]),rt=k.useCallback(async()=>{L&&(await D.mutateAsync(L),E.invalidateQueries({queryKey:["workspaces"]}))},[L,D,E]),Ye=k.useCallback(Y=>{const ie=Y.target.files;ie&&ie.length>0&&fe(Array.from(ie)),Y.target.value=""},[fe]),Ne=k.useCallback(Y=>{const ie=Y.clipboardData.items,Ce=[];for(const _e of ie)if(_e.kind==="file"){const We=_e.getAsFile();We&&Ce.push(We)}Ce.length>0&&(Y.preventDefault(),fe(Ce))},[fe]),Pe=k.useCallback(Y=>{i(Y.target.value);const ie=Y.target;ie.style.height="auto",ie.style.height=`${Math.max(40,Math.min(ie.scrollHeight,140))}px`},[]),He=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),we=k.useRef(null);return k.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let ie=!1;const Ce=()=>{we.current&&(we.current.style.height=`${Y.height}px`,we.current.style.top=`${Y.offsetTop}px`)},_e=()=>Ce(),We=()=>{ie||Ce()},Qe=()=>{ie=!0},me=()=>{ie=!1,requestAnimationFrame(Ce)};return Y.addEventListener("resize",_e),Y.addEventListener("scroll",We),document.addEventListener("touchstart",Qe,{passive:!0}),document.addEventListener("touchend",me,{passive:!0}),document.addEventListener("touchcancel",me,{passive:!0}),()=>{Y.removeEventListener("resize",_e),Y.removeEventListener("scroll",We),document.removeEventListener("touchstart",Qe),document.removeEventListener("touchend",me),document.removeEventListener("touchcancel",me)}},[]),k.useEffect(()=>{const Y=we.current;if(!Y)return;const ie=Ce=>{let _e=Ce.target;for(;_e&&_e!==Y;){if(_e.tagName==="TEXTAREA"){if(_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement;continue}const Qe=window.getComputedStyle(_e).overflowY;if((Qe==="auto"||Qe==="scroll")&&_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement}Ce.preventDefault()};return Y.addEventListener("touchmove",ie,{passive:!1}),()=>Y.removeEventListener("touchmove",ie)},[]),a.jsxs("div",{ref:we,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(Sa,{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}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(ep,{status:e.status}),a.jsx("button",{onClick:He,disabled:!X||T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(zs,{size:16})}),s&&!T&&a.jsxs("div",{className:"relative",ref:n,children:[a.jsx("button",{onClick:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(wn,{size:16})}),S&&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:()=>{p(!0),y(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:tp.map(({key:Y,label:ie,icon:Ce})=>a.jsxs("button",{onClick:()=>C(Y),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(Ce,{size:13}),a.jsx("span",{children:ie})]},Y))})]}),v==="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:u,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:_,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(mn,{urlTransform:Qm,components:Jm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(rn,{label:"Loading..."}):L?U?a.jsx(rn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:M?"Waiting for agent output...":"No logs recorded."}):a.jsx(pn,{logs:z}):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(Pt,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:T?I:m("选择一个 Agent 来执行此任务")}),!T&&a.jsxs(pt,{onClick:()=>f(!0),children:[a.jsx(Pt,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!x&&a.jsxs("button",{onClick:()=>w(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(Sn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ne.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(vn,{todos:ne,compact:!0})}),T?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:I})}):H?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[a.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),a.jsxs(pt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Pt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):L&&a.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[a.jsxs("div",{ref:g,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Ns,{files:ve,onRemove:Le}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ne,onKeyDown:Y=>{$.handleKeyDown(Y)||O.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),ge())},rows:1,placeholder:M?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:Ye}),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:()=>h.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ws,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[j&&W&&a.jsx(No,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Gn,{usage:Ke}),M&&!r.trim()&&!ye?a.jsx("button",{onClick:rt,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(gn,{size:12})}):a.jsx("button",{onClick:ge,disabled:!r.trim()&&!ye||ae,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||ye)&&!ae?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Cn,{size:15})})]})]})]}),a.jsx(Ps,{open:O.query!==null,anchorRef:g,commands:O.filteredCommands,selectedIndex:O.selectedIndex,query:O.query??"",hasCatalog:O.allCommands.length>0,compact:!0,onSelect:O.applyCommand}),a.jsx(Ps,{open:$.query!==null,anchorRef:g,commands:$.filteredSkills,selectedIndex:$.selectedIndex,query:$.query??"",hasCatalog:$.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:$.applySkill})]})]}),v==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Wm,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Ro,{sessionId:L||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Mo,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(Sr,{isOpen:o,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),K.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:K.map((Y,ie)=>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:Y})]},ie))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function rn({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 rp=Object.defineProperty,Bs=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable,nn=(e,t,s)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ar=(e,t)=>{for(var s in t||(t={}))zo.call(t,s)&&nn(e,s,t[s]);if(Bs)for(var s of Bs(t))Wo.call(t,s)&&nn(e,s,t[s]);return e},jr=(e,t)=>{var s={};for(var l in e)zo.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&Bs)for(var l of Bs(e))t.indexOf(l)<0&&Wo.call(e,l)&&(s[l]=e[l]);return s};var Bt;(e=>{const t=class de{constructor(i,c,f,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<de.MIN_VERSION||i>de.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 y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(f);if(this.drawCodewords(S),o==-1){let y=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<y&&(o=g,y=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const f=e.QrSegment.makeSegments(i);return de.encodeSegments(f,c)}static encodeBinary(i,c){const f=e.QrSegment.makeBytes(i);return de.encodeSegments([f],c)}static encodeSegments(i,c,f=1,o=40,p=-1,S=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,g;for(y=f;;y++){const u=de.getNumDataCodewords(y,c)*8,_=C.getTotalBits(i,y);if(_<=u){g=_;break}if(y>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])S&&g<=de.getNumDataCodewords(y,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(y),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(y,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(y,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 f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let f=0;f<c;f++)for(let o=0;o<c;o++)f==0&&o==0||f==0&&o==c-1||f==c-1&&o==0||this.drawAlignmentPattern(i[f],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const o=(c<<10|f)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,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 f=0;f<12;f++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let f=0;f<18;f++){const o=l(c,f),p=this.size-11+f%3,S=Math.floor(f/3);this.setFunctionModule(p,S,o),this.setFunctionModule(S,p,o)}}drawFinderPattern(i,c){for(let f=-4;f<=4;f++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(f)),S=i+o,y=c+f;0<=S&&S<this.size&&0<=y&&y<this.size&&this.setFunctionModule(S,y,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let f=-2;f<=2;f++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+f,Math.max(Math.abs(o),Math.abs(f))!=1)}setFunctionModule(i,c,f){this.modules[c][i]=f,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,f=this.errorCorrectionLevel;if(i.length!=de.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const o=de.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=de.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],S=Math.floor(de.getNumRawDataModules(c)/8),y=o-S%o,g=Math.floor(S/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let x=i.slice(_,_+g-p+(u<y?0:1));_+=x.length;const w=de.reedSolomonComputeRemainder(x,d);u<y&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,x)=>{(u!=g-p||x>=y)&&h.push(_[u])});return m(h.length==S),h}drawCodewords(i){if(i.length!=Math.floor(de.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const S=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][S]&&c<i.length*8&&(this.modules[g][S]=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 f=0;f<this.size;f++){let o;switch(i){case 0:o=(f+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=f%3==0;break;case 3:o=(f+c)%3==0;break;case 4:o=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:o=f*c%2+f*c%3==0;break;case 6:o=(f*c%2+f*c%3)%2==0;break;case 7:o=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&o&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[p][n],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[n][p],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let S=0;S<this.size-1;S++){const y=this.modules[p][S];y==this.modules[p][S+1]&&y==this.modules[p+1][S]&&y==this.modules[p+1][S+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((S,y)=>S+(y?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),i+=o*de.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 f=[6];for(let o=this.size-7;f.length<i;o-=c)f.splice(1,0,o);return f}}static getNumRawDataModules(i){if(i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const f=Math.floor(i/7)+2;c-=(25*f-10)*f-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(de.getNumRawDataModules(i)/8)-de.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*de.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 f=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=de.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=de.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(i,c){let f=c.map(o=>0);for(const o of i){const p=o^f.shift();f.push(0),c.forEach((S,y)=>f[y]^=de.reedSolomonMultiply(S,p))}return f}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let o=7;o>=0;o--)f=f<<1^(f>>>7)*285,f^=(c>>>o&1)*i;return m(f>>>8==0),f}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const f=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(f&&i[0]>=c*4&&i[6]>=c?1:0)+(f&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,f){return i&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}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 f=i-1;f>=0;f--)c.push(r>>>f&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const v=class Fe{constructor(i,c,f){if(this.mode=i,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(i){let c=[];for(const f of i)s(f,8,c);return new Fe(Fe.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Fe.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<i.length;){const o=Math.min(i.length-f,3);s(parseInt(i.substring(f,f+o),10),o*3+1,c),f+=o}return new Fe(Fe.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Fe.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=i.length;f+=2){let o=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Fe(Fe.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Fe.isNumeric(i)?[Fe.makeNumeric(i)]:Fe.isAlphanumeric(i)?[Fe.makeAlphanumeric(i)]:[Fe.makeBytes(Fe.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 Fe(Fe.Mode.ECI,0,c)}static isNumeric(i){return Fe.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Fe.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let f=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;f+=4+p+o.bitData.length}return f}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let f=0;f<i.length;f++)i.charAt(f)!="%"?c.push(i.charCodeAt(f)):(c.push(parseInt(i.substring(f+1,f+3),16)),f+=2);return c}};v.NUMERIC_REGEX=/^[0-9]*$/,v.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,v.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=v;e.QrSegment=v})(Bt||(Bt={}));(e=>{(t=>{const s=class{constructor(m,v){this.ordinal=m,this.formatBits=v}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(Bt||(Bt={}));(e=>{(t=>{const s=class{constructor(m,v){this.modeBits=m,this.numBitsCharCount=v}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(Bt||(Bt={}));var Wt=Bt;var ip={L:Wt.QrCode.Ecc.LOW,M:Wt.QrCode.Ecc.MEDIUM,Q:Wt.QrCode.Ecc.QUARTILE,H:Wt.QrCode.Ecc.HIGH},$o=128,Uo="L",qo="#FFFFFF",Ko="#000000",Xo=!1,Yo=1,np=4,op=0,ap=.1;function Vo(e,t=0){const s=[];return e.forEach(function(l,m){let v=null;l.forEach(function(C,r){if(!C&&v!==null){s.push(`M${v+t} ${m+t}h${r-v}v1H${v+t}z`),v=null;return}if(r===l.length-1){if(!C)return;v===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${v+t},${m+t} h${r+1-v}v1H${v+t}z`);return}C&&v===null&&(v=r)})}),s.join("")}function Go(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function lp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*ap),C=m/t,r=(l.width||v)*C,i=(l.height||v)*C,c=l.x==null?e.length/2-r/2:l.x*C,f=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 y=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-y),d=Math.ceil(i+f-g);p={x:y,y:g,w:n,h:d}}const S=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:S}}function cp(e,t){return t!=null?Math.max(Math.floor(t),0):e?np:op}function Qo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=J.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Wt.QrSegment.makeSegments(n)),g),[]);return Wt.QrCode.encodeSegments(y,ip[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=J.useMemo(()=>{let S=i.getModules();const y=cp(l,m),g=S.length+y*2,n=lp(S,C,y,v);return{cells:S,margin:y,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var hp=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),up=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,marginSize:p,imageSettings:S}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=jr(g,["style"]),h=S?.src,u=J.useRef(null),_=J.useRef(null),x=J.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=J.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:L}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:S,size:v});J.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&L.excavation!=null&&(H=Go(R,L.excavation));const N=window.devicePixelRatio||1;B.height=B.width=v*N;const P=v/j*N;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,hp?I.fill(new Path2D(Vo(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(W,L.x+b,L.y+b,L.w,L.h)}}),J.useEffect(()=>{E(!1)},[h]);const M=Ar({height:v,width:v},n);let T=null;return h!=null&&(T=J.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:L?.crossOrigin})),J.createElement(J.Fragment,null,J.createElement("canvas",Ar({style:M,height:v,width:v,ref:x,role:"img"},d)),T)});up.displayName="QRCodeCanvas";var Zo=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,title:p,marginSize:S,imageSettings:y}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:S,imageSettings:y,size:v});let _=d,x=null;y!=null&&u!=null&&(u.excavation!=null&&(_=Go(d,u.excavation)),x=J.createElement("image",{href:y.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=Vo(_,n);return J.createElement("svg",Ar({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&J.createElement("title",null,p),J.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),J.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Zo.displayName="QRCodeSVG";function dp(){return ut({queryKey:oe.tunnel.status,queryFn:()=>ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function fp(){const e=ze();return Je({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ue.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function mp(){const e=ze();return Je({mutationFn:()=>ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function on(){const{t:e}=he(),{data:t}=dp(),s=fp(),l=mp(),[m,v]=k.useState(!1),[C,r]=k.useState(null),i=k.useRef(null),[c,f]=k.useState({top:0,right:0}),[o,p]=k.useState(!1),S=t?.running??!1,y=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const x=i.current.getBoundingClientRect();f({top:x.bottom+8,right:window.innerWidth-x.right})}},[m]);const d=k.useCallback(()=>{S?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[S,s]),h=k.useCallback(()=>{g&&(navigator.clipboard.writeText(g),r("url"),setTimeout(()=>r(null),2e3))},[g]),u=k.useCallback(()=>{n&&(navigator.clipboard.writeText(n),r("token"),setTimeout(()=>r(null),2e3))},[n]),_=k.useCallback(()=>{l.mutate(),v(!1),p(!1)},[l]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:i,onClick:d,disabled:y,className:`p-1.5 rounded-md transition-colors ${S?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(S?"Tunnel active":"Share via tunnel"),children:y?a.jsx(Ue,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),S&&!y&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&S&&Nt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:c.top,right:c.right},children:[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"}),e("Tunnel Active")]}),a.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(Fs,{size:14})})]}),n&&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(xl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Zo,{value:g,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:g??t?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:x=>x.target.select()}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:e("Copy shareable link"),children:C==="url"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(fi,{size:14})})]}),n&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>p(!o),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(o?"Hide token":"Show token")}),o&&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:n}),a.jsx("button",{onClick:u,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:C==="token"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(fi,{size:14})})]})]}),a.jsx("button",{onClick:_,disabled:l.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:l.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}const an={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>un(()=>import("./modal-D_AU4URz.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),_r=k.lazy(()=>un(()=>import("./folder-picker-CUbhsnhi.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),ln=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"})]}),cn=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),pp=260,vp=600,hn=400;function Lp(){const{t:e}=he(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(hn),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[S,y]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[x,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:L,clear:M,buildMarkdownLinks:T,isUploading:B}=Jr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(hn),N=k.useRef(null),P=ze(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=Ra(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(Nm),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Uf(D??""),z=La({queries:D?[]:Q.map(q=>({queryKey:oe.tasks.list(q.id),queryFn:()=>ue.get(`/projects/${q.id}/tasks`,{params:{limit:"500"}})}))}),ee=!D&&z.some(q=>q.isLoading),V=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const Z of z)Z.data?.data&&q.push(...Z.data.data);return q},[D,F,z]),ne=t&&V.some(q=>q.id===t)?t:null,ve=k.useMemo(()=>{const q=new Map;for(const Z of V){const le=Z.createdAt?new Date(Z.createdAt).getTime():0,pe=q.get(Z.projectId)??0;le>pe&&q.set(Z.projectId,le)}return[...Q].sort((Z,le)=>{const pe=q.get(Z.id)??(Z.createdAt?new Date(Z.createdAt).getTime():0);return(q.get(le.id)??(le.createdAt?new Date(le.createdAt).getTime():0))-pe})},[Q,V]),fe=k.useMemo(()=>ve.filter(q=>!q.archivedAt),[ve]),Le=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),Z=q?JSON.parse(q):{};return[...O].sort((le,pe)=>{const be=le.availability.type!=="NOT_FOUND",ke=pe.availability.type!=="NOT_FOUND";if(be!==ke)return be?-1:1;const st=Z[le.provider.id]??0;return(Z[pe.provider.id]??0)-st})},[O]),re=k.useMemo(()=>V.map(Om),[V]),Be=k.useMemo(()=>new Set,[]),ye=k.useMemo(()=>{if(!ne)return null;const q=V.find(le=>le.id===ne);if(!q)return null;const Z=Q.find(le=>le.id===q.projectId);if(!Z){const le=q.workspaces?.find(pe=>pe.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:ei(q.status),branch:le,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Bm(q,Z)},[ne,V,Q]),ae=Da(),Me=qf(u),Ke=Xf(),Ae=Kf(),Xe=k.useCallback(q=>{Ke.mutate(q,{onSuccess:()=>{ne===q&&s(null),P.invalidateQueries({queryKey:oe.tasks.all})}})},[Ke,ne,P]),ge=k.useCallback((q,Z)=>{Ae.mutate({id:q,status:Lm(Z)},{onError:()=>{ai.error(e("状态变更失败,该操作不被允许"))}})},[Ae,e]),rt=k.useCallback(q=>{q.preventDefault(),H.current=!0,W.current=q.clientX,A.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);k.useEffect(()=>{const q=le=>{if(!H.current)return;const pe=le.clientX-W.current,be=Math.max(pp,Math.min(vp,A.current+pe));C(be)},Z=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Z),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z)}},[]);const Ye=k.useCallback(()=>{i(!0)},[]),Ne=k.useCallback(()=>{if(fe.length===0){ai.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),Z=localStorage.getItem("lastSelectedProviderId"),le=q&&fe.find(ke=>ke.id===q)?q:(D&&fe.find(ke=>ke.id===D)?.id)??fe[0]?.id??"";_(le);const pe=Le?.find(ke=>ke.availability.type!=="NOT_FOUND"),be=Z&&Le?.find(ke=>ke.provider.id===Z&&ke.availability.type!=="NOT_FOUND")?Z:pe?.provider.id??"";w(be),b("idle"),f(!0)},[fe,D,Le,e]),Pe=k.useCallback(()=>{i(!1),p(""),y("")},[]),He=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),M())},[E,M]),we=k.useCallback(async()=>{if(!(!o.trim()||!S.trim()))try{await ae.mutateAsync({name:o.trim(),repoPath:S.trim()}),Pe()}catch{}},[o,S,ae,Pe]),Y=Qr(),ie=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),Z=[d.trim(),q].filter(Boolean).join(`
84
84
 
85
85
  `);b("creating-task");const le=await Me.mutateAsync({title:g.trim(),description:Z||void 0});if(localStorage.setItem("lastSelectedProjectId",u),x){localStorage.setItem("lastSelectedProviderId",x);const pe=localStorage.getItem("providerUsageCount"),be=pe?JSON.parse(pe):{};be[x]=(be[x]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(be))}if(x){const pe=[g.trim(),Z].filter(Boolean).join(`
86
86