agent-tower 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/tasks.js +1 -1
- package/dist/routes/tasks.js.map +1 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +7 -5
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +18 -2
- package/dist/services/task.service.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-2AqgX6Cf.js → AgentDemoPage-BUPbcSby.js} +1 -1
- package/dist/web/assets/{DemoPage-DyFtRa8x.js → DemoPage-uHfzPUab.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-B6uXd3Wp.js → GeneralSettingsPage-DVSPNDtk.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-B0m5t4qH.js → NotificationSettingsPage-BjBLQYkg.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-CwRQ5Wr1.js → ProfileSettingsPage-DITLVxy_.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DwSI2gad.js → ProjectKanbanPage-DTnH6aUV.js} +14 -14
- package/dist/web/assets/{ProjectSettingsPage-BxGCUc3h.js → ProjectSettingsPage-pWGUwpGW.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-BF3I_Oba.js → ProviderSettingsPage-BGPxvueB.js} +1 -1
- package/dist/web/assets/{button-Dh8FHptl.js → button-DuN2FFq9.js} +1 -1
- package/dist/web/assets/{chevron-down-B-UCtkpw.js → chevron-down-CvsW1oAT.js} +1 -1
- package/dist/web/assets/{chevron-right-CIJ95cIu.js → chevron-right-DZtn7is5.js} +1 -1
- package/dist/web/assets/{circle-alert-DwzV6nbB.js → circle-alert-D4JMaf0f.js} +1 -1
- package/dist/web/assets/{circle-check-MgjzSuSN.js → circle-check-BVPufIx1.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-DVFIuiT3.js → code-block-OCS4YCEC-CoXafGdj.js} +1 -1
- package/dist/web/assets/{confirm-dialog-B4CDGom7.js → confirm-dialog-BfzwS6Vt.js} +1 -1
- package/dist/web/assets/{folder-picker-CzSKXweo.js → folder-picker-_XMcl4vl.js} +1 -1
- package/dist/web/assets/{index-CFjAe6OM.js → index-CHW7rgrO.js} +6 -6
- package/dist/web/assets/{loader-circle-BiT33tiH.js → loader-circle-DpY5Gzeb.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-BeW1Fb1_.js → mermaid-NOHMQCX5-BFTc-buD.js} +3 -3
- package/dist/web/assets/{modal-hQOddjel.js → modal-CZQt_i5V.js} +1 -1
- package/dist/web/assets/{pencil-Ca4AsZLH.js → pencil-B-BmKNqG.js} +1 -1
- package/dist/web/assets/{rotate-ccw-Dx6ZIa1R.js → rotate-ccw-CMDcJ6i6.js} +1 -1
- package/dist/web/assets/{select-DN0KH4Bi.js → select-CK7fiECE.js} +1 -1
- package/dist/web/assets/{use-profiles-CUlWd_po.js → use-profiles-CoQe5f2Q.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-
|
|
2
|
-
import{Q as jr,l as ti,m as ra,n as ia,o as na,p as _r,v as oa,w as aa,b as We,x as la,y as ca,r as k,z as ha,A as ua,B as da,D as fa,E as si,G as ri,H as ma,I as pa,J as va,e as _e,R as ee,K as Nt,u as ce,j as a,s as wt,S as Qe,C as Pt,d as fe,c as Ze,q as le,a as ht,k as Et,M as ga,N as ii,O as _a,f as ba,P as xa,t as ni,L as oi,_ as cn}from"./index-CFjAe6OM.js";import{h as Tr,b as Lr,d as Mr,c as Nr,i as Pr,G as Is,u as hn,a as un,Q as dn,e as fn,T as mn,P as ws,f as pn,S as ai}from"./mermaid-NOHMQCX5-BeW1Fb1_.js";import{C as xt,a as ss}from"./chevron-down-B-UCtkpw.js";import{C as Ft}from"./chevron-right-CIJ95cIu.js";import{P as br,X as Fs,M as Or,T as vn}from"./modal-hQOddjel.js";import{u as Hs,T as gn,g as Sa,A as _t,S as Le,C as xr,h as gt}from"./confirm-dialog-B4CDGom7.js";import"./log-adapter-50wgehrc.js";import{B as dt}from"./button-Dh8FHptl.js";import{c as ye,t as li}from"./utils-CkSf8FUe.js";import{F as ya,a as Ca,R as wa}from"./rotate-ccw-Dx6ZIa1R.js";import{L as ze}from"./loader-circle-BiT33tiH.js";import{S as vs}from"./select-DN0KH4Bi.js";var Ea=class extends jr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ti()})}getOptimisticResult(e){return e.behavior=ti(),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:ia(t,s.data),hasPreviousPage:ra(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ci(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ka(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ra=class extends na{#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,_r.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||!oa(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ci(s,m).forEach(f=>{f.destroy()}),ci(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=aa(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 jr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ka(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&&_r.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Da({queries:e,...t},s){const l=We(),m=la(),v=ca(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ha(g);const n=l.getQueryCache().get(g.queryHash);ua(g,v,n)}),da(v);const[r]=k.useState(()=>new Ra(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(_r.batchCalls(g)):fa,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const x=i.some((g,n)=>si(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new jr(l,d);if(si(d,g))return ri(d,h,v);ma(g,m)&&ri(d,h,v)}return[]}):[];if(x.length>0)throw Promise.all(x);const S=i.find((g,n)=>{const d=C[n];return d&&pa({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(S?.error)throw S.error;return c(f())}function _n(e,t){return va(e,Ea)}const Aa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bn=_e("arrow-down",Aa);const ja=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xn=_e("arrow-right",ja);const Ta=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sn=_e("arrow-up",Ta);const La=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hi=_e("circle-check-big",La);const Ma=[["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=_e("code-xml",Ma);const Na=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ui=_e("copy",Na);const Pa=[["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"}]],yn=_e("ellipsis-vertical",Pa);const Oa=[["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"}]],Ba=_e("file-braces-corner",Oa);const Ia=[["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=_e("file-code-corner",Ia);const Fa=[["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"}]],Ha=_e("file-exclamation-point",Fa);const za=[["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"}]],Cn=_e("file-text",za);const Wa=[["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"}]],wn=_e("folder-open",Wa);const $a=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ua=_e("gauge",$a);const qa=[["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"}]],Ka=_e("git-branch",qa);const Xa=[["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"}]],Ya=_e("git-fork",Xa);const Va=[["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=_e("git-graph",Va);const Ga=[["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"}]],En=_e("git-merge",Ga);const Qa=[["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"}]],qt=_e("history",Qa);const Za=[["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"}]],Br=_e("image",Za);const Ja=[["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"}]],di=_e("layers",Ja);const el=[["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"}]],tl=_e("maximize",el);const sl=[["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"}]],rl=_e("message-square",sl);const il=[["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"}]],nl=_e("panel-left-close",il);const ol=[["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"}]],al=_e("panel-left-open",ol);const ll=[["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"}]],cl=_e("panel-right-close",ll);const hl=[["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"}]],ul=_e("panel-right-open",hl);const dl=[["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=_e("play",dl);const fl=[["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"}]],ml=_e("refresh-cw",fl);const pl=[["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"}]],vl=_e("shield",pl);const gl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=_e("terminal",gl);const _l=[["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"}]],bl=_e("zap",_l);const xl=[["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"}]],Sl=_e("zoom-in",xl);const yl=[["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"}]],Cl=_e("zoom-out",yl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Je(e){var t,s;return e?Kt(e)?e:Ir(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Fr(e){const{Document:t}=Je(e);return e instanceof t}function cs(e){return Kt(e)?!1:e instanceof Je(e).HTMLElement}function kn(e){return e instanceof Je(e).SVGElement}function Xt(e){return e?Kt(e)?e.document:Ir(e)?Fr(e)?e:cs(e)||kn(e)?e.ownerDocument:document:document:document}const bt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return bt(()=>{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 wl(){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 bt(()=>{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 sr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=sr[e]==null?0:sr[e]+1;return sr[e]=s,e+"-"+s},[e,t])}function Rn(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 Ut=Rn(1),Ds=Rn(-1);function El(e){return"clientX"in e&&"clientY"in e}function Hr(e){if(!e)return!1;const{KeyboardEvent:t}=Je(e.target);return t&&e instanceof t}function kl(e){if(!e)return!1;const{TouchEvent:t}=Je(e.target);return t&&e instanceof t}function As(e){if(kl(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 El(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}}}),fi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Rl(e){return e.matches(fi)?e:e.querySelector(fi)}const Dl={display:"none"};function Al(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Dl},s)}function jl(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Tl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const Dn=k.createContext(null);function Ll(e){const t=k.useContext(Dn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ml(){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 Nl={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-CZQt_i5V.js","assets/index-CHW7rgrO.js","assets/index-CnQr7qh9.css","assets/utils-CkSf8FUe.js","assets/folder-picker-_XMcl4vl.js","assets/chevron-right-DZtn7is5.js","assets/loader-circle-DpY5Gzeb.js","assets/circle-alert-D4JMaf0f.js","assets/rotate-ccw-CMDcJ6i6.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Q as jr,l as ti,m as ra,n as ia,o as na,p as _r,v as oa,w as aa,b as We,x as la,y as ca,r as k,z as ha,A as ua,B as da,D as fa,E as si,G as ri,H as ma,I as pa,J as va,e as _e,R as ee,K as Nt,u as ce,j as a,s as wt,S as Qe,C as Pt,d as fe,c as Ze,q as ae,a as ht,k as Et,M as ga,N as ii,O as _a,f as ba,P as xa,t as ni,L as oi,_ as cn}from"./index-CHW7rgrO.js";import{h as Tr,b as Lr,d as Mr,c as Nr,i as Pr,G as Is,u as hn,a as un,Q as dn,e as fn,T as mn,P as ws,f as pn,S as ai}from"./mermaid-NOHMQCX5-BFTc-buD.js";import{C as xt,a as ss}from"./chevron-down-CvsW1oAT.js";import{C as Ft}from"./chevron-right-DZtn7is5.js";import{P as br,X as Fs,M as Or,T as vn}from"./modal-CZQt_i5V.js";import{u as Hs,T as gn,g as Sa,A as _t,S as Le,C as xr,h as gt}from"./confirm-dialog-BfzwS6Vt.js";import"./log-adapter-50wgehrc.js";import{B as dt}from"./button-DuN2FFq9.js";import{c as ye,t as li}from"./utils-CkSf8FUe.js";import{F as ya,a as Ca,R as wa}from"./rotate-ccw-CMDcJ6i6.js";import{L as ze}from"./loader-circle-DpY5Gzeb.js";import{S as vs}from"./select-CK7fiECE.js";var Ea=class extends jr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ti()})}getOptimisticResult(e){return e.behavior=ti(),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:ia(t,s.data),hasPreviousPage:ra(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ci(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ka(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ra=class extends na{#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,_r.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||!oa(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ci(s,m).forEach(f=>{f.destroy()}),ci(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=aa(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 jr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ka(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&&_r.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Da({queries:e,...t},s){const l=We(),m=la(),v=ca(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ha(g);const n=l.getQueryCache().get(g.queryHash);ua(g,v,n)}),da(v);const[r]=k.useState(()=>new Ra(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(_r.batchCalls(g)):fa,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const x=i.some((g,n)=>si(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new jr(l,d);if(si(d,g))return ri(d,h,v);ma(g,m)&&ri(d,h,v)}return[]}):[];if(x.length>0)throw Promise.all(x);const S=i.find((g,n)=>{const d=C[n];return d&&pa({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(S?.error)throw S.error;return c(f())}function _n(e,t){return va(e,Ea)}const Aa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bn=_e("arrow-down",Aa);const ja=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xn=_e("arrow-right",ja);const Ta=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sn=_e("arrow-up",Ta);const La=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hi=_e("circle-check-big",La);const Ma=[["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=_e("code-xml",Ma);const Na=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ui=_e("copy",Na);const Pa=[["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"}]],yn=_e("ellipsis-vertical",Pa);const Oa=[["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"}]],Ba=_e("file-braces-corner",Oa);const Ia=[["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=_e("file-code-corner",Ia);const Fa=[["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"}]],Ha=_e("file-exclamation-point",Fa);const za=[["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"}]],Cn=_e("file-text",za);const Wa=[["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"}]],wn=_e("folder-open",Wa);const $a=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ua=_e("gauge",$a);const qa=[["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"}]],Ka=_e("git-branch",qa);const Xa=[["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"}]],Ya=_e("git-fork",Xa);const Va=[["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=_e("git-graph",Va);const Ga=[["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"}]],En=_e("git-merge",Ga);const Qa=[["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"}]],qt=_e("history",Qa);const Za=[["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"}]],Br=_e("image",Za);const Ja=[["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"}]],di=_e("layers",Ja);const el=[["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"}]],tl=_e("maximize",el);const sl=[["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"}]],rl=_e("message-square",sl);const il=[["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"}]],nl=_e("panel-left-close",il);const ol=[["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"}]],al=_e("panel-left-open",ol);const ll=[["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"}]],cl=_e("panel-right-close",ll);const hl=[["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"}]],ul=_e("panel-right-open",hl);const dl=[["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=_e("play",dl);const fl=[["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"}]],ml=_e("refresh-cw",fl);const pl=[["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"}]],vl=_e("shield",pl);const gl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=_e("terminal",gl);const _l=[["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"}]],bl=_e("zap",_l);const xl=[["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"}]],Sl=_e("zoom-in",xl);const yl=[["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"}]],Cl=_e("zoom-out",yl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Je(e){var t,s;return e?Kt(e)?e:Ir(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Fr(e){const{Document:t}=Je(e);return e instanceof t}function cs(e){return Kt(e)?!1:e instanceof Je(e).HTMLElement}function kn(e){return e instanceof Je(e).SVGElement}function Xt(e){return e?Kt(e)?e.document:Ir(e)?Fr(e)?e:cs(e)||kn(e)?e.ownerDocument:document:document:document}const bt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return bt(()=>{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 wl(){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 bt(()=>{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 sr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=sr[e]==null?0:sr[e]+1;return sr[e]=s,e+"-"+s},[e,t])}function Rn(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 Ut=Rn(1),Ds=Rn(-1);function El(e){return"clientX"in e&&"clientY"in e}function Hr(e){if(!e)return!1;const{KeyboardEvent:t}=Je(e.target);return t&&e instanceof t}function kl(e){if(!e)return!1;const{TouchEvent:t}=Je(e.target);return t&&e instanceof t}function As(e){if(kl(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 El(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}}}),fi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Rl(e){return e.matches(fi)?e:e.querySelector(fi)}const Dl={display:"none"};function Al(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Dl},s)}function jl(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Tl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const Dn=k.createContext(null);function Ll(e){const t=k.useContext(Dn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ml(){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 Nl={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
|
-
`},Pl={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 Ol(e){let{announcements:t=Pl,container:s,hiddenTextDescribedById:l,screenReaderInstructions:m=Nl}=e;const{announce:v,announcement:C}=Tl(),r=Us("DndLiveRegion"),[i,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),Ll(k.useMemo(()=>({onDragStart(o){let{active:p}=o;v(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:x}=o;t.onDragMove&&v(t.onDragMove({active:p,over:x}))},onDragOver(o){let{active:p,over:x}=o;v(t.onDragOver({active:p,over:x}))},onDragEnd(o){let{active:p,over:x}=o;v(t.onDragEnd({active:p,over:x}))},onDragCancel(o){let{active:p,over:x}=o;v(t.onDragCancel({active:p,over:x}))}}),[v,t])),!i)return null;const f=ee.createElement(ee.Fragment,null,ee.createElement(Al,{id:l,value:m.draggable}),ee.createElement(jl,{id:r,announcement:C}));return s?Nt.createPortal(f,s):f}var Ue;(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"})(Ue||(Ue={}));function js(){}function Bl(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Il(){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 ft=Object.freeze({x:0,y:0});function Fl(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 Hl(e,t){let{data:{value:s}}=e,{data:{value:l}}=t;return l-s}function zl(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function Wl(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 $l=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=Wl(r,t);i>0&&m.push({id:C,data:{droppableContainer:v,value:i}})}}return m.sort(Hl)};function Ul(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function An(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ft}function ql(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 Kl=ql(1);function jn(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 Xl(e,t,s){const l=jn(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 Yl={ignoreTransform:!1};function us(e,t){t===void 0&&(t=Yl);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=Je(e).getComputedStyle(e);c&&(s=Xl(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 mi(e){return us(e,{ignoreTransform:!0})}function Vl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function Gl(e,t){return t===void 0&&(t=Je(e).getComputedStyle(e)),t.position==="fixed"}function Ql(e,t){t===void 0&&(t=Je(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 zr(e,t){const s=[];function l(m){if(t!=null&&s.length>=t||!m)return s;if(Fr(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!cs(m)||kn(m)||s.includes(m))return s;const v=Je(e).getComputedStyle(m);return m!==e&&Ql(m,v)&&s.push(m),Gl(m,v)?s:l(m.parentNode)}return e?l(e):s}function Tn(e){const[t]=zr(e,1);return t??null}function rr(e){return!Ws||!e?null:Kt(e)?e:Ir(e)?Fr(e)||e===Xt(e).scrollingElement?window:cs(e)?e:null:null}function Ln(e){return Kt(e)?e.scrollX:e.scrollLeft}function Mn(e){return Kt(e)?e.scrollY:e.scrollTop}function Sr(e){return{x:Ln(e),y:Mn(e)}}var Ye;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ye||(Ye={}));function Nn(e){return!Ws||!e?!1:e===document.scrollingElement}function Pn(e){const t={x:0,y:0},s=Nn(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 Zl={x:.2,y:.2};function Jl(e,t,s,l,m){let{top:v,left:C,right:r,bottom:i}=s;l===void 0&&(l=10),m===void 0&&(m=Zl);const{isTop:c,isBottom:f,isLeft:o,isRight:p}=Pn(e),x={x:0,y:0},S={x:0,y:0},g={height:t.height*m.y,width:t.width*m.x};return!c&&v<=t.top+g.height?(x.y=Ye.Backward,S.y=l*Math.abs((t.top+g.height-v)/g.height)):!f&&i>=t.bottom-g.height&&(x.y=Ye.Forward,S.y=l*Math.abs((t.bottom-g.height-i)/g.height)),!p&&r>=t.right-g.width?(x.x=Ye.Forward,S.x=l*Math.abs((t.right-g.width-r)/g.width)):!o&&C<=t.left+g.width&&(x.x=Ye.Backward,S.x=l*Math.abs((t.left+g.width-C)/g.width)),{direction:x,speed:S}}function ec(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 On(e){return e.reduce((t,s)=>Ut(t,Sr(s)),ft)}function tc(e){return e.reduce((t,s)=>t+Ln(s),0)}function sc(e){return e.reduce((t,s)=>t+Mn(s),0)}function Bn(e,t){if(t===void 0&&(t=us),!e)return;const{top:s,left:l,bottom:m,right:v}=t(e);Tn(e)&&(m<=0||v<=0||s>=window.innerHeight||l>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const rc=[["x",["left","right"],tc],["y",["top","bottom"],sc]];class Wr{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=zr(s),m=On(l);this.rect={...t},this.width=t.width,this.height=t.height;for(const[v,C,r]of rc)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 ic(e){const{EventTarget:t}=Je(e);return e instanceof t?e:Xt(e)}function ir(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 lt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(lt||(lt={}));function pi(e){e.preventDefault()}function nc(e){e.stopPropagation()}var we;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(we||(we={}));const In={start:[we.Space,we.Enter],cancel:[we.Esc],end:[we.Space,we.Enter,we.Tab]},oc=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case we.Right:return{...s,x:s.x+25};case we.Left:return{...s,x:s.x-25};case we.Down:return{...s,y:s.y+25};case we.Up:return{...s,y:s.y-25}}};class Fn{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(Xt(s)),this.windowListeners=new Zt(Je(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(lt.Resize,this.handleCancel),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(lt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,l=t.node.current;l&&Bn(l),s(ft)}handleKeyDown(t){if(Hr(t)){const{active:s,context:l,options:m}=this.props,{keyboardCodes:v=In,coordinateGetter:C=oc,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}:ft;this.referenceCoordinates||(this.referenceCoordinates=f);const o=C(t,{active:s,context:l.current,currentCoordinates:f});if(o){const p=Ds(o,f),x={x:0,y:0},{scrollableAncestors:S}=l.current;for(const g of S){const n=t.code,{isTop:d,isRight:h,isLeft:u,isBottom:_,maxScroll:y,minScroll:w}=Pn(g),E=ec(g),b={x:Math.min(n===we.Right?E.right-E.width/2:E.right,Math.max(n===we.Right?E.left:E.left+E.width/2,o.x)),y:Math.min(n===we.Down?E.bottom-E.height/2:E.bottom,Math.max(n===we.Down?E.top:E.top+E.height/2,o.y))},R=n===we.Right&&!h||n===we.Left&&!u,j=n===we.Down&&!_||n===we.Up&&!d;if(R&&b.x!==o.x){const M=g.scrollLeft+p.x,L=n===we.Right&&M<=y.x||n===we.Left&&M>=w.x;if(L&&!p.y){g.scrollTo({left:M,behavior:r});return}L?x.x=g.scrollLeft-M:x.x=n===we.Right?g.scrollLeft-y.x:g.scrollLeft-w.x,x.x&&g.scrollBy({left:-x.x,behavior:r});break}else if(j&&b.y!==o.y){const M=g.scrollTop+p.y,L=n===we.Down&&M<=y.y||n===we.Up&&M>=w.y;if(L&&!p.x){g.scrollTo({top:M,behavior:r});return}L?x.y=g.scrollTop-M:x.y=n===we.Down?g.scrollTop-y.y:g.scrollTop-w.y,x.y&&g.scrollBy({top:-x.y,behavior:r});break}}this.handleMove(t,Ut(Ds(o,this.referenceCoordinates),x))}}}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()}}Fn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:l=In,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 vi(e){return!!(e&&"distance"in e)}function gi(e){return!!(e&&"delay"in e)}class $r{constructor(t,s,l){var m;l===void 0&&(l=ic(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=Xt(C),this.documentListeners=new Zt(this.document),this.listeners=new Zt(l),this.windowListeners=new Zt(Je(C)),this.initialCoordinates=(m=As(v))!=null?m:ft,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(lt.Resize,this.handleCancel),this.windowListeners.add(lt.DragStart,pi),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),this.windowListeners.add(lt.ContextMenu,pi),this.documentListeners.add(lt.Keydown,this.handleKeydown),s){if(l!=null&&l({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gi(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(vi(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(lt.Click,nc,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(lt.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:ft,c=Ds(m,i);if(!l&&r){if(vi(r)){if(r.tolerance!=null&&ir(c,r.tolerance))return this.handleCancel();if(ir(c,r.distance))return this.handleStart()}if(gi(r)&&ir(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===we.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ac={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ur extends $r{constructor(t){const{event:s}=t,l=Xt(s.target);super(t,ac,l)}}Ur.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 lc={move:{name:"mousemove"},end:{name:"mouseup"}};var yr;(function(e){e[e.RightClick=2]="RightClick"})(yr||(yr={}));class cc extends $r{constructor(t){super(t,lc,Xt(t.event.target))}}cc.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return s.button===yr.RightClick?!1:(l?.({event:s}),!0)}}];const nr={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class hc extends $r{constructor(t){super(t,nr)}static setup(){return window.addEventListener(nr.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(nr.move.name,t)};function t(){}}}hc.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 uc(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 x=fc({delta:o,disabled:!v}),[S,g]=wl(),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)},[]),y=k.useMemo(()=>r===Ts.TreeOrder?[...c].reverse():c,[r,c]);k.useEffect(()=>{if(!v||!c.length||!h){g();return}for(const w of y){if(l?.(w)===!1)continue;const E=c.indexOf(w),b=f[E];if(!b)continue;const{direction:R,speed:j}=Jl(w,b,h,t,p);for(const M of["x","y"])x[M][R[M]]||(j[M]=0,R[M]=0);if(j.x>0||j.y>0){g(),u.current=w,S(_,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(x),S,c,y,f,JSON.stringify(p)])}const dc={x:{[Ye.Backward]:!1,[Ye.Forward]:!1},y:{[Ye.Backward]:!1,[Ye.Forward]:!1}};function fc(e){let{delta:t,disabled:s}=e;const l=Rs(t);return hs(m=>{if(s||!l||!m)return dc;const v={x:Math.sign(t.x-l.x),y:Math.sign(t.y-l.y)};return{x:{[Ye.Backward]:m.x[Ye.Backward]||v.x===-1,[Ye.Forward]:m.x[Ye.Forward]||v.x===1},y:{[Ye.Backward]:m.y[Ye.Backward]||v.y===-1,[Ye.Forward]:m.y[Ye.Forward]||v.y===1}}},[s,t,l])}function mc(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 pc(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 Cr;(function(e){e.Optimized="optimized"})(Cr||(Cr={}));const _i=new Map;function vc(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),x=k.useCallback(function(d){d===void 0&&(d=[]),!p.current&&C(h=>h===null?d:h.concat(d.filter(u=>!h.includes(u))))},[p]),S=k.useRef(null),g=hs(d=>{if(o&&!s)return _i;if(!d||d===_i||f.current!==e||v!=null){const h=new Map;for(let u of e){if(!u)continue;if(v&&v.length>0&&!v.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const _=u.node.current,y=_?new Wr(i(_),_):null;u.rect.current=y,y&&h.set(u.id,y)}return h}return d},[e,v,s,o,i]);return k.useEffect(()=>{f.current=e},[e]),k.useEffect(()=>{o||x()},[s,o]),k.useEffect(()=>{v&&v.length>0&&C(null)},[JSON.stringify(v)]),k.useEffect(()=>{o||typeof r!="number"||S.current!==null||(S.current=setTimeout(()=>{x(),S.current=null},r))},[r,o,x,...l]),{droppableRects:g,measureDroppableContainers:x,measuringScheduled:v!=null};function n(){switch(c){case as.Always:return!1;case as.BeforeDragging:return s;default:return!s}}}function qr(e,t){return hs(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function gc(e,t){return qr(e,t)}function _c(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 bc(e){return new Wr(us(e),e)}function bi(e,t,s){t===void 0&&(t=bc);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=_c({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 bt(()=>{v(),e?(r?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(r?.disconnect(),C?.disconnect())},[e]),l}function xc(e){const t=qr(e);return An(e,t)}const xi=[];function Sc(e){const t=k.useRef(e),s=hs(l=>e?l&&l!==xi&&e&&t.current&&e.parentNode===t.current.parentNode?l:zr(e):xi,[e]);return k.useEffect(()=>{t.current=e},[e]),s}function yc(e){const[t,s]=k.useState(null),l=k.useRef(e),m=k.useCallback(v=>{const C=rr(v.target);C&&s(r=>r?(r.set(C,Sr(C)),new Map(r)):null)},[]);return k.useEffect(()=>{const v=l.current;if(e!==v){C(v);const r=e.map(i=>{const c=rr(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,Sr(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=rr(i);c?.removeEventListener("scroll",m)})}},[m,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((v,C)=>Ut(v,C),ft):On(e):ft,[e,t])}function Si(e,t){t===void 0&&(t=[]);const s=k.useRef(null);return k.useEffect(()=>{s.current=null},t),k.useEffect(()=>{const l=e!==ft;l&&!s.current&&(s.current=e),!l&&s.current&&(s.current=null)},[e]),s.current?Ds(e,s.current):ft}function Cc(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 wc(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 Hn(e){return k.useMemo(()=>e?Vl(e):null,[e])}const yi=[];function Ec(e,t){t===void 0&&(t=us);const[s]=e,l=Hn(s?Je(s):null),[m,v]=k.useState(yi);function C(){v(()=>e.length?e.map(i=>Nn(i)?l:new Wr(t(i),i)):yi)}const r=qs({callback:C});return bt(()=>{r?.disconnect(),C(),e.forEach(i=>r?.observe(i))},[e]),m}function zn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return cs(t)?t:e}function kc(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=zn(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 Rc=[{sensor:Ur,options:{}},{sensor:Fn,options:{}}],Dc={current:{}},Cs={draggable:{measure:mi},droppable:{measure:mi,strategy:as.WhileDragging,frequency:Cr.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 Ac={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},Wn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:js,draggableNodes:new Map,over:null,measureDroppableContainers:js},ds=k.createContext(Wn),$n=k.createContext(Ac);function jc(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new es}}}function Tc(e,t){switch(t.type){case Ue.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ue.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 Ue.DragEnd:case Ue.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ue.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 Ue.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 Ue.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 Lc(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(!Hr(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=Rl(f);if(o){o.focus();break}}})}},[l,t,m,C,v]),null}function Un(e,t){let{transform:s,...l}=t;return e!=null&&e.length?e.reduce((m,v)=>v({transform:m,...l}),s):s}function Mc(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 Nc(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;bt(()=>{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=An(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=Tn(c);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,r,l,s])}const Ks=k.createContext({...ft,scaleX:1,scaleY:1});var Ct;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ct||(Ct={}));const Pc=k.memo(function(t){var s,l,m,v;let{id:C,accessibility:r,autoScroll:i=!0,children:c,sensors:f=Rc,collisionDetection:o=$l,measuring:p,modifiers:x,...S}=t;const g=k.useReducer(Tc,void 0,jc),[n,d]=g,[h,u]=Ml(),[_,y]=k.useState(Ct.Uninitialized),w=_===Ct.Initialized,{draggable:{active:E,nodes:b,translate:R},droppable:{containers:j}}=n,M=E!=null?b.get(E):null,L=k.useRef({initial:null,translated:null}),T=k.useMemo(()=>{var je;return E!=null?{id:E,data:(je=M?.data)!=null?je:Dc,rect:L}:null},[E,M]),B=k.useRef(null),[I,H]=k.useState(null),[W,A]=k.useState(null),N=ns(S,Object.values(S)),P=Us("DndDescribedBy",C),O=k.useMemo(()=>j.getEnabled(),[j]),$=Mc(p),{droppableRects:X,measureDroppableContainers:K,measuringScheduled:Q}=vc(O,{dragging:w,dependencies:[R.x,R.y],config:$.droppable}),se=mc(b,E),D=k.useMemo(()=>W?As(W):null,[W]),F=Ht(),U=gc(se,$.draggable.measure);Nc({activeNode:E!=null?b.get(E):null,config:F.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const z=bi(se,$.draggable.measure,U),te=bi(se?se.parentElement:null),Y=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}),ie=j.getNodeFor((s=Y.current.over)==null?void 0:s.id),ge=kc({measure:$.dragOverlay.measure}),me=(l=ge.nodeRef.current)!=null?l:se,Me=w?(m=ge.rect)!=null?m:z:null,re=!!(ge.nodeRef.current&&ge.rect),Be=xc(re?null:z),Ce=Hn(me?Je(me):null),oe=Sc(w?ie??se:null),Ne=Ec(oe),qe=Un(x,{transform:{x:R.x-Be.x,y:R.y-Be.y,scaleX:1,scaleY:1},activatorEvent:W,active:T,activeNodeRect:z,containerNodeRect:te,draggingNodeRect:Me,over:Y.current.over,overlayNodeRect:ge.rect,scrollableAncestors:oe,scrollableAncestorRects:Ne,windowRect:Ce}),Re=D?Ut(D,R):null,Ve=yc(oe),be=Si(Ve),st=Si(Ve,[z]),Ke=Ut(qe,be),Pe=Me?Kl(Me,qe):null,Oe=T&&Pe?o({active:T,collisionRect:Pe,droppableRects:X,droppableContainers:O,pointerCoordinates:Re}):null,De=zl(Oe,"id"),[V,Z]=k.useState(null),xe=re?qe:Ut(qe,st),Se=Ul(xe,(v=V?.rect)!=null?v:null,z),He=k.useRef(null),Xe=k.useCallback((je,q)=>{let{sensor:J,options:he}=q;if(B.current==null)return;const ue=b.get(B.current);if(!ue)return;const ve=je.nativeEvent,Ae=new J({active:B.current,activeNode:ue,event:ve,options:he,context:Y,onAbort(Fe){if(!b.get(Fe))return;const{onDragAbort:tt}=N.current,at={id:Fe};tt?.(at),h({type:"onDragAbort",event:at})},onPending(Fe,ot,tt,at){if(!b.get(Fe))return;const{onDragPending:Tt}=N.current,pt={id:Fe,constraint:ot,initialCoordinates:tt,offset:at};Tt?.(pt),h({type:"onDragPending",event:pt})},onStart(Fe){const ot=B.current;if(ot==null)return;const tt=b.get(ot);if(!tt)return;const{onDragStart:at}=N.current,jt={activatorEvent:ve,active:{id:ot,data:tt.data,rect:L}};Nt.unstable_batchedUpdates(()=>{at?.(jt),y(Ct.Initializing),d({type:Ue.DragStart,initialCoordinates:Fe,active:ot}),h({type:"onDragStart",event:jt}),H(He.current),A(ve)})},onMove(Fe){d({type:Ue.DragMove,coordinates:Fe})},onEnd:mt(Ue.DragEnd),onCancel:mt(Ue.DragCancel)});He.current=Ae;function mt(Fe){return async function(){const{active:tt,collisions:at,over:jt,scrollAdjustedTranslate:Tt}=Y.current;let pt=null;if(tt&&Tt){const{cancelDrop:St}=N.current;pt={activatorEvent:ve,active:tt,collisions:at,delta:Tt,over:jt},Fe===Ue.DragEnd&&typeof St=="function"&&await Promise.resolve(St(pt))&&(Fe=Ue.DragCancel)}B.current=null,Nt.unstable_batchedUpdates(()=>{d({type:Fe}),y(Ct.Uninitialized),Z(null),H(null),A(null),He.current=null;const St=Fe===Ue.DragEnd?"onDragEnd":"onDragCancel";if(pt){const Lt=N.current[St];Lt?.(pt),h({type:St,event:pt})}})}}},[b]),pe=k.useCallback((je,q)=>(J,he)=>{const ue=J.nativeEvent,ve=b.get(he);if(B.current!==null||!ve||ue.dndKit||ue.defaultPrevented)return;const Ae={active:ve};je(J,q.options,Ae)===!0&&(ue.dndKit={capturedBy:q.sensor},B.current=he,Xe(J,q))},[b,Xe]),et=pc(f,pe);Cc(f),bt(()=>{z&&_===Ct.Initializing&&y(Ct.Initialized)},[z,_]),k.useEffect(()=>{const{onDragMove:je}=N.current,{active:q,activatorEvent:J,collisions:he,over:ue}=Y.current;if(!q||!J)return;const ve={active:q,activatorEvent:J,collisions:he,delta:{x:Ke.x,y:Ke.y},over:ue};Nt.unstable_batchedUpdates(()=>{je?.(ve),h({type:"onDragMove",event:ve})})},[Ke.x,Ke.y]),k.useEffect(()=>{const{active:je,activatorEvent:q,collisions:J,droppableContainers:he,scrollAdjustedTranslate:ue}=Y.current;if(!je||B.current==null||!q||!ue)return;const{onDragOver:ve}=N.current,Ae=he.get(De),mt=Ae&&Ae.rect.current?{id:Ae.id,rect:Ae.rect.current,data:Ae.data,disabled:Ae.disabled}:null,Fe={active:je,activatorEvent:q,collisions:J,delta:{x:ue.x,y:ue.y},over:mt};Nt.unstable_batchedUpdates(()=>{Z(mt),ve?.(Fe),h({type:"onDragOver",event:Fe})})},[De]),bt(()=>{Y.current={activatorEvent:W,active:T,activeNode:se,collisionRect:Pe,collisions:Oe,droppableRects:X,draggableNodes:b,draggingNode:me,draggingNodeRect:Me,droppableContainers:j,over:V,scrollableAncestors:oe,scrollAdjustedTranslate:Ke},L.current={initial:Me,translated:Pe}},[T,se,Oe,Pe,b,me,Me,X,j,V,oe,Ke]),uc({...F,delta:R,draggingRect:Pe,pointerCoordinates:Re,scrollableAncestors:oe,scrollableAncestorRects:Ne});const Ge=k.useMemo(()=>({active:T,activeNode:se,activeNodeRect:z,activatorEvent:W,collisions:Oe,containerNodeRect:te,dragOverlay:ge,draggableNodes:b,droppableContainers:j,droppableRects:X,over:V,measureDroppableContainers:K,scrollableAncestors:oe,scrollableAncestorRects:Ne,measuringConfiguration:$,measuringScheduled:Q,windowRect:Ce}),[T,se,z,W,Oe,te,ge,b,j,X,V,K,oe,Ne,$,Q,Ce]),nt=k.useMemo(()=>({activatorEvent:W,activators:et,active:T,activeNodeRect:z,ariaDescribedById:{draggable:P},dispatch:d,draggableNodes:b,over:V,measureDroppableContainers:K}),[W,et,T,z,d,P,b,V,K]);return ee.createElement(Dn.Provider,{value:u},ee.createElement(ds.Provider,{value:nt},ee.createElement($n.Provider,{value:Ge},ee.createElement(Ks.Provider,{value:Se},c)),ee.createElement(Lc,{disabled:r?.restoreFocus===!1})),ee.createElement(Ol,{...r,hiddenTextDescribedById:P}));function Ht(){const je=I?.autoScrollEnabled===!1,q=typeof i=="object"?i.enabled===!1:i===!1,J=w&&!je&&!q;return typeof i=="object"?{...i,enabled:J}:{enabled:J}}}),Oc=k.createContext(null),Ci="button",Bc="Draggable";function Ic(e){let{id:t,data:s,disabled:l=!1,attributes:m}=e;const v=Us(Bc),{activators:C,activatorEvent:r,active:i,activeNodeRect:c,ariaDescribedById:f,draggableNodes:o,over:p}=k.useContext(ds),{role:x=Ci,roleDescription:S="draggable",tabIndex:g=0}=m??{},n=i?.id===t,d=k.useContext(n?Ks:Oc),[h,u]=ks(),[_,y]=ks(),w=wc(C,t),E=ns(s);bt(()=>(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:x,tabIndex:g,"aria-disabled":l,"aria-pressed":n&&x===Ci?!0:void 0,"aria-roledescription":S,"aria-describedby":f.draggable}),[l,x,g,n,S,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:y,transform:d}}function Fc(){return k.useContext($n)}const Hc="Droppable",zc={timeout:25};function Wc(e){let{data:t,disabled:s=!1,id:l,resizeObserverConfig:m}=e;const v=Us(Hc),{active:C,dispatch:r,over:i,measureDroppableContainers:c}=k.useContext(ds),f=k.useRef({disabled:s}),o=k.useRef(!1),p=k.useRef(null),x=k.useRef(null),{disabled:S,updateMeasurementsFor:g,timeout:n}={...zc,...m},d=ns(g??l),h=k.useCallback(()=>{if(!o.current){o.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{c(Array.isArray(d.current)?d.current:[d.current]),x.current=null},n)},[n]),u=qs({callback:h,disabled:S||!C}),_=k.useCallback((b,R)=>{u&&(R&&(u.unobserve(R),o.current=!1),b&&u.observe(b))},[u]),[y,w]=ks(_),E=ns(t);return k.useEffect(()=>{!u||!y.current||(u.disconnect(),o.current=!1,u.observe(y.current))},[y,u]),k.useEffect(()=>(r({type:Ue.RegisterDroppable,element:{id:l,key:v,disabled:s,node:y,rect:p,data:E}}),()=>r({type:Ue.UnregisterDroppable,key:v,id:l})),[l]),k.useEffect(()=>{s!==f.current.disabled&&(r({type:Ue.SetDroppableDisabled,id:l,key:v,disabled:s}),f.current.disabled=s)},[l,v,s,r]),{active:C,rect:p,isOver:i?.id===l,node:y,over:i,setNodeRef:w}}function $c(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),bt(()=>{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]),ee.createElement(ee.Fragment,null,s,l?k.cloneElement(l,{ref:C}):null)}const Uc={x:0,y:0,scaleX:1,scaleY:1};function qc(e){let{children:t}=e;return ee.createElement(ds.Provider,{value:Wn},ee.createElement(Ks.Provider,{value:Uc},t))}const Kc={position:"fixed",touchAction:"none"},Xc=e=>Hr(e)?"transform 250ms ease":void 0,Yc=k.forwardRef((e,t)=>{let{as:s,activatorEvent:l,adjustScale:m,children:v,className:C,rect:r,style:i,transform:c,transition:f=Xc}=e;if(!r)return null;const o=m?c:{...c,scaleX:1,scaleY:1},p={...Kc,width:r.width,height:r.height,top:r.top,left:r.left,transform:os.Transform.toString(o),transformOrigin:m&&l?Fl(l,r):void 0,transition:typeof f=="function"?f(l):f,...i};return ee.createElement(s,{className:C,style:p,ref:t},v)}),Vc=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)}},Gc=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:os.Transform.toString(t)},{transform:os.Transform.toString(s)}]},Qc={duration:250,easing:"ease",keyframes:Gc,sideEffects:Vc({styles:{active:{opacity:"0"}}})};function Zc(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=zn(C);if(!c)return;const{transform:f}=Je(C).getComputedStyle(C),o=jn(f);if(!o)return;const p=typeof t=="function"?t:Jc(t);return Bn(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 Jc(e){const{duration:t,easing:s,sideEffects:l,keyframes:m}={...Qc,...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},x=m({...c,active:C,dragOverlay:r,transform:{initial:i,final:p}}),[S]=x,g=x[x.length-1];if(JSON.stringify(S)===JSON.stringify(g))return;const n=l?.({active:C,dragOverlay:r,...c}),d=r.node.animate(x,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{d.onfinish=()=>{n?.(),h()}})}}let wi=0;function eh(e){return k.useMemo(()=>{if(e!=null)return wi++,wi},[e])}const th=ee.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:x,draggableNodes:S,droppableContainers:g,dragOverlay:n,over:d,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:_,windowRect:y}=Fc(),w=k.useContext(Ks),E=eh(o?.id),b=Un(C,{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:x,draggingNodeRect:n.rect,over:d,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:_,transform:w,windowRect:y}),R=qr(p),j=Zc({config:l,draggableNodes:S,droppableContainers:g,measuringConfiguration:h}),M=R?n.setRef:void 0;return ee.createElement(qc,null,ee.createElement($c,{animation:j},o&&E?ee.createElement(Yc,{key:E,id:o.id,ref:M,as:r,activatorEvent:f,adjustScale:t,className:i,transition:v,rect:R,style:{zIndex:c,...m},transform:b},s):null))}),ae={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},sh=[{status:ae.Review,label:"Review",icon:Tr,color:"text-amber-600"},{status:ae.Running,label:"Running",icon:Lr,color:"text-blue-600"},{status:ae.Pending,label:"Pending",icon:Mr,color:"text-neutral-600"},{status:ae.Done,label:"Done",icon:Nr,color:"text-emerald-600"},{status:ae.Cancelled,label:"Cancelled",icon:Pr,color:"text-neutral-500"}];function rh({task:e,status:t,isSelected:s,isAgentActive:l,project:m,onSelectTask:v,onTaskStatusChange:C,onDeleteTask:r}){const{t:i}=ce(),c=!!e.projectArchivedAt,{attributes:f,listeners:o,setNodeRef:p,isDragging:x}=Ic({id:e.id,data:{task:e,fromStatus:t},disabled:c}),[S,g]=k.useState(null),n=k.useRef(null),d=k.useCallback(h=>{c||!C&&!r||(h.preventDefault(),g({x:h.clientX,y:h.clientY}))},[c,C,r]);return k.useEffect(()=>{if(!S)return;const h=u=>{n.current&&!n.current.contains(u.target)&&g(null)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[S]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:p,onClick:()=>v(e.id),onContextMenu:d,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
6
|
+
`},Pl={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 Ol(e){let{announcements:t=Pl,container:s,hiddenTextDescribedById:l,screenReaderInstructions:m=Nl}=e;const{announce:v,announcement:C}=Tl(),r=Us("DndLiveRegion"),[i,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),Ll(k.useMemo(()=>({onDragStart(o){let{active:p}=o;v(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:x}=o;t.onDragMove&&v(t.onDragMove({active:p,over:x}))},onDragOver(o){let{active:p,over:x}=o;v(t.onDragOver({active:p,over:x}))},onDragEnd(o){let{active:p,over:x}=o;v(t.onDragEnd({active:p,over:x}))},onDragCancel(o){let{active:p,over:x}=o;v(t.onDragCancel({active:p,over:x}))}}),[v,t])),!i)return null;const f=ee.createElement(ee.Fragment,null,ee.createElement(Al,{id:l,value:m.draggable}),ee.createElement(jl,{id:r,announcement:C}));return s?Nt.createPortal(f,s):f}var Ue;(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"})(Ue||(Ue={}));function js(){}function Bl(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Il(){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 ft=Object.freeze({x:0,y:0});function Fl(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 Hl(e,t){let{data:{value:s}}=e,{data:{value:l}}=t;return l-s}function zl(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function Wl(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 $l=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=Wl(r,t);i>0&&m.push({id:C,data:{droppableContainer:v,value:i}})}}return m.sort(Hl)};function Ul(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function An(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ft}function ql(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 Kl=ql(1);function jn(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 Xl(e,t,s){const l=jn(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 Yl={ignoreTransform:!1};function us(e,t){t===void 0&&(t=Yl);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=Je(e).getComputedStyle(e);c&&(s=Xl(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 mi(e){return us(e,{ignoreTransform:!0})}function Vl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function Gl(e,t){return t===void 0&&(t=Je(e).getComputedStyle(e)),t.position==="fixed"}function Ql(e,t){t===void 0&&(t=Je(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 zr(e,t){const s=[];function l(m){if(t!=null&&s.length>=t||!m)return s;if(Fr(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!cs(m)||kn(m)||s.includes(m))return s;const v=Je(e).getComputedStyle(m);return m!==e&&Ql(m,v)&&s.push(m),Gl(m,v)?s:l(m.parentNode)}return e?l(e):s}function Tn(e){const[t]=zr(e,1);return t??null}function rr(e){return!Ws||!e?null:Kt(e)?e:Ir(e)?Fr(e)||e===Xt(e).scrollingElement?window:cs(e)?e:null:null}function Ln(e){return Kt(e)?e.scrollX:e.scrollLeft}function Mn(e){return Kt(e)?e.scrollY:e.scrollTop}function Sr(e){return{x:Ln(e),y:Mn(e)}}var Ye;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ye||(Ye={}));function Nn(e){return!Ws||!e?!1:e===document.scrollingElement}function Pn(e){const t={x:0,y:0},s=Nn(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 Zl={x:.2,y:.2};function Jl(e,t,s,l,m){let{top:v,left:C,right:r,bottom:i}=s;l===void 0&&(l=10),m===void 0&&(m=Zl);const{isTop:c,isBottom:f,isLeft:o,isRight:p}=Pn(e),x={x:0,y:0},S={x:0,y:0},g={height:t.height*m.y,width:t.width*m.x};return!c&&v<=t.top+g.height?(x.y=Ye.Backward,S.y=l*Math.abs((t.top+g.height-v)/g.height)):!f&&i>=t.bottom-g.height&&(x.y=Ye.Forward,S.y=l*Math.abs((t.bottom-g.height-i)/g.height)),!p&&r>=t.right-g.width?(x.x=Ye.Forward,S.x=l*Math.abs((t.right-g.width-r)/g.width)):!o&&C<=t.left+g.width&&(x.x=Ye.Backward,S.x=l*Math.abs((t.left+g.width-C)/g.width)),{direction:x,speed:S}}function ec(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 On(e){return e.reduce((t,s)=>Ut(t,Sr(s)),ft)}function tc(e){return e.reduce((t,s)=>t+Ln(s),0)}function sc(e){return e.reduce((t,s)=>t+Mn(s),0)}function Bn(e,t){if(t===void 0&&(t=us),!e)return;const{top:s,left:l,bottom:m,right:v}=t(e);Tn(e)&&(m<=0||v<=0||s>=window.innerHeight||l>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const rc=[["x",["left","right"],tc],["y",["top","bottom"],sc]];class Wr{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=zr(s),m=On(l);this.rect={...t},this.width=t.width,this.height=t.height;for(const[v,C,r]of rc)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 ic(e){const{EventTarget:t}=Je(e);return e instanceof t?e:Xt(e)}function ir(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 lt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(lt||(lt={}));function pi(e){e.preventDefault()}function nc(e){e.stopPropagation()}var we;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(we||(we={}));const In={start:[we.Space,we.Enter],cancel:[we.Esc],end:[we.Space,we.Enter,we.Tab]},oc=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case we.Right:return{...s,x:s.x+25};case we.Left:return{...s,x:s.x-25};case we.Down:return{...s,y:s.y+25};case we.Up:return{...s,y:s.y-25}}};class Fn{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(Xt(s)),this.windowListeners=new Zt(Je(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(lt.Resize,this.handleCancel),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(lt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,l=t.node.current;l&&Bn(l),s(ft)}handleKeyDown(t){if(Hr(t)){const{active:s,context:l,options:m}=this.props,{keyboardCodes:v=In,coordinateGetter:C=oc,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}:ft;this.referenceCoordinates||(this.referenceCoordinates=f);const o=C(t,{active:s,context:l.current,currentCoordinates:f});if(o){const p=Ds(o,f),x={x:0,y:0},{scrollableAncestors:S}=l.current;for(const g of S){const n=t.code,{isTop:d,isRight:h,isLeft:u,isBottom:_,maxScroll:y,minScroll:w}=Pn(g),E=ec(g),b={x:Math.min(n===we.Right?E.right-E.width/2:E.right,Math.max(n===we.Right?E.left:E.left+E.width/2,o.x)),y:Math.min(n===we.Down?E.bottom-E.height/2:E.bottom,Math.max(n===we.Down?E.top:E.top+E.height/2,o.y))},R=n===we.Right&&!h||n===we.Left&&!u,j=n===we.Down&&!_||n===we.Up&&!d;if(R&&b.x!==o.x){const M=g.scrollLeft+p.x,L=n===we.Right&&M<=y.x||n===we.Left&&M>=w.x;if(L&&!p.y){g.scrollTo({left:M,behavior:r});return}L?x.x=g.scrollLeft-M:x.x=n===we.Right?g.scrollLeft-y.x:g.scrollLeft-w.x,x.x&&g.scrollBy({left:-x.x,behavior:r});break}else if(j&&b.y!==o.y){const M=g.scrollTop+p.y,L=n===we.Down&&M<=y.y||n===we.Up&&M>=w.y;if(L&&!p.x){g.scrollTo({top:M,behavior:r});return}L?x.y=g.scrollTop-M:x.y=n===we.Down?g.scrollTop-y.y:g.scrollTop-w.y,x.y&&g.scrollBy({top:-x.y,behavior:r});break}}this.handleMove(t,Ut(Ds(o,this.referenceCoordinates),x))}}}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()}}Fn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:l=In,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 vi(e){return!!(e&&"distance"in e)}function gi(e){return!!(e&&"delay"in e)}class $r{constructor(t,s,l){var m;l===void 0&&(l=ic(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=Xt(C),this.documentListeners=new Zt(this.document),this.listeners=new Zt(l),this.windowListeners=new Zt(Je(C)),this.initialCoordinates=(m=As(v))!=null?m:ft,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(lt.Resize,this.handleCancel),this.windowListeners.add(lt.DragStart,pi),this.windowListeners.add(lt.VisibilityChange,this.handleCancel),this.windowListeners.add(lt.ContextMenu,pi),this.documentListeners.add(lt.Keydown,this.handleKeydown),s){if(l!=null&&l({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gi(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(vi(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(lt.Click,nc,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(lt.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:ft,c=Ds(m,i);if(!l&&r){if(vi(r)){if(r.tolerance!=null&&ir(c,r.tolerance))return this.handleCancel();if(ir(c,r.distance))return this.handleStart()}if(gi(r)&&ir(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===we.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ac={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ur extends $r{constructor(t){const{event:s}=t,l=Xt(s.target);super(t,ac,l)}}Ur.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 lc={move:{name:"mousemove"},end:{name:"mouseup"}};var yr;(function(e){e[e.RightClick=2]="RightClick"})(yr||(yr={}));class cc extends $r{constructor(t){super(t,lc,Xt(t.event.target))}}cc.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:l}=t;return s.button===yr.RightClick?!1:(l?.({event:s}),!0)}}];const nr={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class hc extends $r{constructor(t){super(t,nr)}static setup(){return window.addEventListener(nr.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(nr.move.name,t)};function t(){}}}hc.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 uc(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 x=fc({delta:o,disabled:!v}),[S,g]=wl(),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)},[]),y=k.useMemo(()=>r===Ts.TreeOrder?[...c].reverse():c,[r,c]);k.useEffect(()=>{if(!v||!c.length||!h){g();return}for(const w of y){if(l?.(w)===!1)continue;const E=c.indexOf(w),b=f[E];if(!b)continue;const{direction:R,speed:j}=Jl(w,b,h,t,p);for(const M of["x","y"])x[M][R[M]]||(j[M]=0,R[M]=0);if(j.x>0||j.y>0){g(),u.current=w,S(_,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(x),S,c,y,f,JSON.stringify(p)])}const dc={x:{[Ye.Backward]:!1,[Ye.Forward]:!1},y:{[Ye.Backward]:!1,[Ye.Forward]:!1}};function fc(e){let{delta:t,disabled:s}=e;const l=Rs(t);return hs(m=>{if(s||!l||!m)return dc;const v={x:Math.sign(t.x-l.x),y:Math.sign(t.y-l.y)};return{x:{[Ye.Backward]:m.x[Ye.Backward]||v.x===-1,[Ye.Forward]:m.x[Ye.Forward]||v.x===1},y:{[Ye.Backward]:m.y[Ye.Backward]||v.y===-1,[Ye.Forward]:m.y[Ye.Forward]||v.y===1}}},[s,t,l])}function mc(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 pc(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 Cr;(function(e){e.Optimized="optimized"})(Cr||(Cr={}));const _i=new Map;function vc(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),x=k.useCallback(function(d){d===void 0&&(d=[]),!p.current&&C(h=>h===null?d:h.concat(d.filter(u=>!h.includes(u))))},[p]),S=k.useRef(null),g=hs(d=>{if(o&&!s)return _i;if(!d||d===_i||f.current!==e||v!=null){const h=new Map;for(let u of e){if(!u)continue;if(v&&v.length>0&&!v.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const _=u.node.current,y=_?new Wr(i(_),_):null;u.rect.current=y,y&&h.set(u.id,y)}return h}return d},[e,v,s,o,i]);return k.useEffect(()=>{f.current=e},[e]),k.useEffect(()=>{o||x()},[s,o]),k.useEffect(()=>{v&&v.length>0&&C(null)},[JSON.stringify(v)]),k.useEffect(()=>{o||typeof r!="number"||S.current!==null||(S.current=setTimeout(()=>{x(),S.current=null},r))},[r,o,x,...l]),{droppableRects:g,measureDroppableContainers:x,measuringScheduled:v!=null};function n(){switch(c){case as.Always:return!1;case as.BeforeDragging:return s;default:return!s}}}function qr(e,t){return hs(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function gc(e,t){return qr(e,t)}function _c(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 bc(e){return new Wr(us(e),e)}function bi(e,t,s){t===void 0&&(t=bc);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=_c({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 bt(()=>{v(),e?(r?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(r?.disconnect(),C?.disconnect())},[e]),l}function xc(e){const t=qr(e);return An(e,t)}const xi=[];function Sc(e){const t=k.useRef(e),s=hs(l=>e?l&&l!==xi&&e&&t.current&&e.parentNode===t.current.parentNode?l:zr(e):xi,[e]);return k.useEffect(()=>{t.current=e},[e]),s}function yc(e){const[t,s]=k.useState(null),l=k.useRef(e),m=k.useCallback(v=>{const C=rr(v.target);C&&s(r=>r?(r.set(C,Sr(C)),new Map(r)):null)},[]);return k.useEffect(()=>{const v=l.current;if(e!==v){C(v);const r=e.map(i=>{const c=rr(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,Sr(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=rr(i);c?.removeEventListener("scroll",m)})}},[m,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((v,C)=>Ut(v,C),ft):On(e):ft,[e,t])}function Si(e,t){t===void 0&&(t=[]);const s=k.useRef(null);return k.useEffect(()=>{s.current=null},t),k.useEffect(()=>{const l=e!==ft;l&&!s.current&&(s.current=e),!l&&s.current&&(s.current=null)},[e]),s.current?Ds(e,s.current):ft}function Cc(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 wc(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 Hn(e){return k.useMemo(()=>e?Vl(e):null,[e])}const yi=[];function Ec(e,t){t===void 0&&(t=us);const[s]=e,l=Hn(s?Je(s):null),[m,v]=k.useState(yi);function C(){v(()=>e.length?e.map(i=>Nn(i)?l:new Wr(t(i),i)):yi)}const r=qs({callback:C});return bt(()=>{r?.disconnect(),C(),e.forEach(i=>r?.observe(i))},[e]),m}function zn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return cs(t)?t:e}function kc(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=zn(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 Rc=[{sensor:Ur,options:{}},{sensor:Fn,options:{}}],Dc={current:{}},Cs={draggable:{measure:mi},droppable:{measure:mi,strategy:as.WhileDragging,frequency:Cr.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 Ac={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},Wn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:js,draggableNodes:new Map,over:null,measureDroppableContainers:js},ds=k.createContext(Wn),$n=k.createContext(Ac);function jc(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new es}}}function Tc(e,t){switch(t.type){case Ue.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ue.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 Ue.DragEnd:case Ue.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ue.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 Ue.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 Ue.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 Lc(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(!Hr(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=Rl(f);if(o){o.focus();break}}})}},[l,t,m,C,v]),null}function Un(e,t){let{transform:s,...l}=t;return e!=null&&e.length?e.reduce((m,v)=>v({transform:m,...l}),s):s}function Mc(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 Nc(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;bt(()=>{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=An(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=Tn(c);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,r,l,s])}const Ks=k.createContext({...ft,scaleX:1,scaleY:1});var Ct;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ct||(Ct={}));const Pc=k.memo(function(t){var s,l,m,v;let{id:C,accessibility:r,autoScroll:i=!0,children:c,sensors:f=Rc,collisionDetection:o=$l,measuring:p,modifiers:x,...S}=t;const g=k.useReducer(Tc,void 0,jc),[n,d]=g,[h,u]=Ml(),[_,y]=k.useState(Ct.Uninitialized),w=_===Ct.Initialized,{draggable:{active:E,nodes:b,translate:R},droppable:{containers:j}}=n,M=E!=null?b.get(E):null,L=k.useRef({initial:null,translated:null}),T=k.useMemo(()=>{var je;return E!=null?{id:E,data:(je=M?.data)!=null?je:Dc,rect:L}:null},[E,M]),B=k.useRef(null),[I,H]=k.useState(null),[W,A]=k.useState(null),N=ns(S,Object.values(S)),P=Us("DndDescribedBy",C),O=k.useMemo(()=>j.getEnabled(),[j]),$=Mc(p),{droppableRects:X,measureDroppableContainers:K,measuringScheduled:Q}=vc(O,{dragging:w,dependencies:[R.x,R.y],config:$.droppable}),se=mc(b,E),D=k.useMemo(()=>W?As(W):null,[W]),F=Ht(),U=gc(se,$.draggable.measure);Nc({activeNode:E!=null?b.get(E):null,config:F.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const z=bi(se,$.draggable.measure,U),te=bi(se?se.parentElement:null),Y=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}),ie=j.getNodeFor((s=Y.current.over)==null?void 0:s.id),ge=kc({measure:$.dragOverlay.measure}),me=(l=ge.nodeRef.current)!=null?l:se,Me=w?(m=ge.rect)!=null?m:z:null,re=!!(ge.nodeRef.current&&ge.rect),Be=xc(re?null:z),Ce=Hn(me?Je(me):null),oe=Sc(w?ie??se:null),Ne=Ec(oe),qe=Un(x,{transform:{x:R.x-Be.x,y:R.y-Be.y,scaleX:1,scaleY:1},activatorEvent:W,active:T,activeNodeRect:z,containerNodeRect:te,draggingNodeRect:Me,over:Y.current.over,overlayNodeRect:ge.rect,scrollableAncestors:oe,scrollableAncestorRects:Ne,windowRect:Ce}),Re=D?Ut(D,R):null,Ve=yc(oe),be=Si(Ve),st=Si(Ve,[z]),Ke=Ut(qe,be),Pe=Me?Kl(Me,qe):null,Oe=T&&Pe?o({active:T,collisionRect:Pe,droppableRects:X,droppableContainers:O,pointerCoordinates:Re}):null,De=zl(Oe,"id"),[V,Z]=k.useState(null),xe=re?qe:Ut(qe,st),Se=Ul(xe,(v=V?.rect)!=null?v:null,z),He=k.useRef(null),Xe=k.useCallback((je,q)=>{let{sensor:J,options:he}=q;if(B.current==null)return;const ue=b.get(B.current);if(!ue)return;const ve=je.nativeEvent,Ae=new J({active:B.current,activeNode:ue,event:ve,options:he,context:Y,onAbort(Fe){if(!b.get(Fe))return;const{onDragAbort:tt}=N.current,at={id:Fe};tt?.(at),h({type:"onDragAbort",event:at})},onPending(Fe,ot,tt,at){if(!b.get(Fe))return;const{onDragPending:Tt}=N.current,pt={id:Fe,constraint:ot,initialCoordinates:tt,offset:at};Tt?.(pt),h({type:"onDragPending",event:pt})},onStart(Fe){const ot=B.current;if(ot==null)return;const tt=b.get(ot);if(!tt)return;const{onDragStart:at}=N.current,jt={activatorEvent:ve,active:{id:ot,data:tt.data,rect:L}};Nt.unstable_batchedUpdates(()=>{at?.(jt),y(Ct.Initializing),d({type:Ue.DragStart,initialCoordinates:Fe,active:ot}),h({type:"onDragStart",event:jt}),H(He.current),A(ve)})},onMove(Fe){d({type:Ue.DragMove,coordinates:Fe})},onEnd:mt(Ue.DragEnd),onCancel:mt(Ue.DragCancel)});He.current=Ae;function mt(Fe){return async function(){const{active:tt,collisions:at,over:jt,scrollAdjustedTranslate:Tt}=Y.current;let pt=null;if(tt&&Tt){const{cancelDrop:St}=N.current;pt={activatorEvent:ve,active:tt,collisions:at,delta:Tt,over:jt},Fe===Ue.DragEnd&&typeof St=="function"&&await Promise.resolve(St(pt))&&(Fe=Ue.DragCancel)}B.current=null,Nt.unstable_batchedUpdates(()=>{d({type:Fe}),y(Ct.Uninitialized),Z(null),H(null),A(null),He.current=null;const St=Fe===Ue.DragEnd?"onDragEnd":"onDragCancel";if(pt){const Lt=N.current[St];Lt?.(pt),h({type:St,event:pt})}})}}},[b]),pe=k.useCallback((je,q)=>(J,he)=>{const ue=J.nativeEvent,ve=b.get(he);if(B.current!==null||!ve||ue.dndKit||ue.defaultPrevented)return;const Ae={active:ve};je(J,q.options,Ae)===!0&&(ue.dndKit={capturedBy:q.sensor},B.current=he,Xe(J,q))},[b,Xe]),et=pc(f,pe);Cc(f),bt(()=>{z&&_===Ct.Initializing&&y(Ct.Initialized)},[z,_]),k.useEffect(()=>{const{onDragMove:je}=N.current,{active:q,activatorEvent:J,collisions:he,over:ue}=Y.current;if(!q||!J)return;const ve={active:q,activatorEvent:J,collisions:he,delta:{x:Ke.x,y:Ke.y},over:ue};Nt.unstable_batchedUpdates(()=>{je?.(ve),h({type:"onDragMove",event:ve})})},[Ke.x,Ke.y]),k.useEffect(()=>{const{active:je,activatorEvent:q,collisions:J,droppableContainers:he,scrollAdjustedTranslate:ue}=Y.current;if(!je||B.current==null||!q||!ue)return;const{onDragOver:ve}=N.current,Ae=he.get(De),mt=Ae&&Ae.rect.current?{id:Ae.id,rect:Ae.rect.current,data:Ae.data,disabled:Ae.disabled}:null,Fe={active:je,activatorEvent:q,collisions:J,delta:{x:ue.x,y:ue.y},over:mt};Nt.unstable_batchedUpdates(()=>{Z(mt),ve?.(Fe),h({type:"onDragOver",event:Fe})})},[De]),bt(()=>{Y.current={activatorEvent:W,active:T,activeNode:se,collisionRect:Pe,collisions:Oe,droppableRects:X,draggableNodes:b,draggingNode:me,draggingNodeRect:Me,droppableContainers:j,over:V,scrollableAncestors:oe,scrollAdjustedTranslate:Ke},L.current={initial:Me,translated:Pe}},[T,se,Oe,Pe,b,me,Me,X,j,V,oe,Ke]),uc({...F,delta:R,draggingRect:Pe,pointerCoordinates:Re,scrollableAncestors:oe,scrollableAncestorRects:Ne});const Ge=k.useMemo(()=>({active:T,activeNode:se,activeNodeRect:z,activatorEvent:W,collisions:Oe,containerNodeRect:te,dragOverlay:ge,draggableNodes:b,droppableContainers:j,droppableRects:X,over:V,measureDroppableContainers:K,scrollableAncestors:oe,scrollableAncestorRects:Ne,measuringConfiguration:$,measuringScheduled:Q,windowRect:Ce}),[T,se,z,W,Oe,te,ge,b,j,X,V,K,oe,Ne,$,Q,Ce]),nt=k.useMemo(()=>({activatorEvent:W,activators:et,active:T,activeNodeRect:z,ariaDescribedById:{draggable:P},dispatch:d,draggableNodes:b,over:V,measureDroppableContainers:K}),[W,et,T,z,d,P,b,V,K]);return ee.createElement(Dn.Provider,{value:u},ee.createElement(ds.Provider,{value:nt},ee.createElement($n.Provider,{value:Ge},ee.createElement(Ks.Provider,{value:Se},c)),ee.createElement(Lc,{disabled:r?.restoreFocus===!1})),ee.createElement(Ol,{...r,hiddenTextDescribedById:P}));function Ht(){const je=I?.autoScrollEnabled===!1,q=typeof i=="object"?i.enabled===!1:i===!1,J=w&&!je&&!q;return typeof i=="object"?{...i,enabled:J}:{enabled:J}}}),Oc=k.createContext(null),Ci="button",Bc="Draggable";function Ic(e){let{id:t,data:s,disabled:l=!1,attributes:m}=e;const v=Us(Bc),{activators:C,activatorEvent:r,active:i,activeNodeRect:c,ariaDescribedById:f,draggableNodes:o,over:p}=k.useContext(ds),{role:x=Ci,roleDescription:S="draggable",tabIndex:g=0}=m??{},n=i?.id===t,d=k.useContext(n?Ks:Oc),[h,u]=ks(),[_,y]=ks(),w=wc(C,t),E=ns(s);bt(()=>(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:x,tabIndex:g,"aria-disabled":l,"aria-pressed":n&&x===Ci?!0:void 0,"aria-roledescription":S,"aria-describedby":f.draggable}),[l,x,g,n,S,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:y,transform:d}}function Fc(){return k.useContext($n)}const Hc="Droppable",zc={timeout:25};function Wc(e){let{data:t,disabled:s=!1,id:l,resizeObserverConfig:m}=e;const v=Us(Hc),{active:C,dispatch:r,over:i,measureDroppableContainers:c}=k.useContext(ds),f=k.useRef({disabled:s}),o=k.useRef(!1),p=k.useRef(null),x=k.useRef(null),{disabled:S,updateMeasurementsFor:g,timeout:n}={...zc,...m},d=ns(g??l),h=k.useCallback(()=>{if(!o.current){o.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{c(Array.isArray(d.current)?d.current:[d.current]),x.current=null},n)},[n]),u=qs({callback:h,disabled:S||!C}),_=k.useCallback((b,R)=>{u&&(R&&(u.unobserve(R),o.current=!1),b&&u.observe(b))},[u]),[y,w]=ks(_),E=ns(t);return k.useEffect(()=>{!u||!y.current||(u.disconnect(),o.current=!1,u.observe(y.current))},[y,u]),k.useEffect(()=>(r({type:Ue.RegisterDroppable,element:{id:l,key:v,disabled:s,node:y,rect:p,data:E}}),()=>r({type:Ue.UnregisterDroppable,key:v,id:l})),[l]),k.useEffect(()=>{s!==f.current.disabled&&(r({type:Ue.SetDroppableDisabled,id:l,key:v,disabled:s}),f.current.disabled=s)},[l,v,s,r]),{active:C,rect:p,isOver:i?.id===l,node:y,over:i,setNodeRef:w}}function $c(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),bt(()=>{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]),ee.createElement(ee.Fragment,null,s,l?k.cloneElement(l,{ref:C}):null)}const Uc={x:0,y:0,scaleX:1,scaleY:1};function qc(e){let{children:t}=e;return ee.createElement(ds.Provider,{value:Wn},ee.createElement(Ks.Provider,{value:Uc},t))}const Kc={position:"fixed",touchAction:"none"},Xc=e=>Hr(e)?"transform 250ms ease":void 0,Yc=k.forwardRef((e,t)=>{let{as:s,activatorEvent:l,adjustScale:m,children:v,className:C,rect:r,style:i,transform:c,transition:f=Xc}=e;if(!r)return null;const o=m?c:{...c,scaleX:1,scaleY:1},p={...Kc,width:r.width,height:r.height,top:r.top,left:r.left,transform:os.Transform.toString(o),transformOrigin:m&&l?Fl(l,r):void 0,transition:typeof f=="function"?f(l):f,...i};return ee.createElement(s,{className:C,style:p,ref:t},v)}),Vc=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)}},Gc=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:os.Transform.toString(t)},{transform:os.Transform.toString(s)}]},Qc={duration:250,easing:"ease",keyframes:Gc,sideEffects:Vc({styles:{active:{opacity:"0"}}})};function Zc(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=zn(C);if(!c)return;const{transform:f}=Je(C).getComputedStyle(C),o=jn(f);if(!o)return;const p=typeof t=="function"?t:Jc(t);return Bn(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 Jc(e){const{duration:t,easing:s,sideEffects:l,keyframes:m}={...Qc,...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},x=m({...c,active:C,dragOverlay:r,transform:{initial:i,final:p}}),[S]=x,g=x[x.length-1];if(JSON.stringify(S)===JSON.stringify(g))return;const n=l?.({active:C,dragOverlay:r,...c}),d=r.node.animate(x,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{d.onfinish=()=>{n?.(),h()}})}}let wi=0;function eh(e){return k.useMemo(()=>{if(e!=null)return wi++,wi},[e])}const th=ee.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:x,draggableNodes:S,droppableContainers:g,dragOverlay:n,over:d,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:_,windowRect:y}=Fc(),w=k.useContext(Ks),E=eh(o?.id),b=Un(C,{activatorEvent:f,active:o,activeNodeRect:p,containerNodeRect:x,draggingNodeRect:n.rect,over:d,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:_,transform:w,windowRect:y}),R=qr(p),j=Zc({config:l,draggableNodes:S,droppableContainers:g,measuringConfiguration:h}),M=R?n.setRef:void 0;return ee.createElement(qc,null,ee.createElement($c,{animation:j},o&&E?ee.createElement(Yc,{key:E,id:o.id,ref:M,as:r,activatorEvent:f,adjustScale:t,className:i,transition:v,rect:R,style:{zIndex:c,...m},transform:b},s):null))}),le={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},sh=[{status:le.Review,label:"Review",icon:Tr,color:"text-amber-600"},{status:le.Running,label:"Running",icon:Lr,color:"text-blue-600"},{status:le.Pending,label:"Pending",icon:Mr,color:"text-neutral-600"},{status:le.Done,label:"Done",icon:Nr,color:"text-emerald-600"},{status:le.Cancelled,label:"Cancelled",icon:Pr,color:"text-neutral-500"}];function rh({task:e,status:t,isSelected:s,isAgentActive:l,project:m,onSelectTask:v,onTaskStatusChange:C,onDeleteTask:r}){const{t:i}=ce(),c=!!e.projectArchivedAt,{attributes:f,listeners:o,setNodeRef:p,isDragging:x}=Ic({id:e.id,data:{task:e,fromStatus:t},disabled:c}),[S,g]=k.useState(null),n=k.useRef(null),d=k.useCallback(h=>{c||!C&&!r||(h.preventDefault(),g({x:h.clientX,y:h.clientY}))},[c,C,r]);return k.useEffect(()=>{if(!S)return;const h=u=>{n.current&&!n.current.contains(u.target)&&g(null)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[S]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:p,onClick:()=>v(e.id),onContextMenu:d,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
7
7
|
${x?"opacity-30":""}
|
|
8
|
-
${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...c?{}:o,...c?{}:f,children:[a.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===
|
|
8
|
+
${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...c?{}:o,...c?{}:f,children:[a.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===le.Running?"text-blue-600":"text-neutral-500"}`,children:[t===le.Review&&a.jsx(Tr,{className:s?"text-amber-600":"text-neutral-500"}),t===le.Running&&a.jsx(Lr,{className:"animate-pulse"}),t===le.Pending&&a.jsx(Mr,{}),t===le.Done&&a.jsx(Nr,{className:"text-neutral-400"}),t===le.Cancelled&&a.jsx(Pr,{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?i("源码已删除"):i("已删除")}),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})]})]}),S&&a.jsxs("div",{ref:n,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:S.x,top:S.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:i("Move to")}),sh.filter(h=>h.status!==t).map(h=>{const u=h.icon;return a.jsxs("button",{onClick:()=>{C(e.id,h.status),g(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[a.jsx(u,{className:`w-3.5 h-3.5 ${h.color}`}),a.jsx("span",{className:"text-neutral-700",children:i(h.label)})]},h.status)})]}),r&&a.jsxs(a.Fragment,{children:[C&&a.jsx("div",{className:"my-1 border-t border-neutral-100"}),a.jsxs("button",{onClick:()=>{r(e.id),g(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[a.jsx("path",{d:"M3 6h18"}),a.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),a.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),a.jsx("span",{children:i("Delete Task")})]})]})]})]})}const ih=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}){const{t:x}=ce(),[S,g]=k.useState(m),n=s.length===0,d=c&&f===l,h=c&&f!==l,{setNodeRef:u,isOver:_}=Wc({id:`group-${l}`,data:{status:l}}),y=l===le.Review,w=x(t),E=c?d&&(S||!0):S;return a.jsxs("div",{className:"mb-2",children:[a.jsxs("button",{onClick:()=>!c&&g(b=>!b),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:E?a.jsx(xt,{size:14}):a.jsx(Ft,{size:14})}),a.jsx("span",{className:"flex-1 text-left",children:w}),y&&!n?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,")"]})]}),h&&a.jsx("div",{ref:u,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
9
|
${_?"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("Drop into {title}",{title:w}):x("Drop here")})}),E&&!h&&a.jsx("div",{ref:d?void 0:u,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
|
|
10
10
|
${_&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
|
|
11
|
-
${n&&c?"border border-dashed border-neutral-300":""}`,children:n?a.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:x("No tasks")}):s.map(b=>{const R=r.find(L=>L.id===b.projectId),j=v===b.id,M=i?.has(b.id)??!1;return a.jsx(rh,{task:b,status:l,isSelected:j,isAgentActive:M,project:R,onSelectTask:C,onTaskStatusChange:b.projectArchivedAt?void 0:o,onDeleteTask:b.projectArchivedAt?void 0:p},b.id)})})]})});function nh(e){const t={[ae.Review]:[],[ae.Running]:[],[ae.Pending]:[],[ae.Done]:[],[ae.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const oh=[{status:ae.Review,title:"Review",defaultOpen:!0},{status:ae.Running,title:"Running",defaultOpen:!0},{status:ae.Pending,title:"Pending",defaultOpen:!1},{status:ae.Done,title:"Done",defaultOpen:!1},{status:ae.Cancelled,title:"Cancelled",defaultOpen:!1}];function Ei({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}=ce(),[x,S]=k.useState(!1),[g,n]=k.useState(null),[d,h]=k.useState(null),u=Il(Bl(Ur,{activationConstraint:{distance:8}})),_=k.useCallback(T=>{const B=T.active.data.current?.task,I=T.active.data.current?.fromStatus;B&&n(B),I&&h(I)},[]),y=k.useCallback(T=>{n(null),h(null);const{active:B,over:I}=T;if(!I)return;const H=B.data.current?.task,W=B.data.current?.fromStatus,A=I.data.current?.status;!H||!W||!A||H.projectArchivedAt||W!==A&&f?.(H.id,A)},[f]),w=m?e.filter(T=>T.projectId===m):e,E=m?t.find(T=>T.id===m)??null:null,b=t.filter(T=>!T.archivedAt),j=!!!E?.archivedAt,M=nh(w),L=C==="100%";return a.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${L?"":"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:()=>S(T=>!T),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&E?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${E.color.replace("text-","bg-")}`}),a.jsx("span",{className:"truncate",children:E.name})]}):a.jsxs(a.Fragment,{children:[a.jsx(di,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),a.jsx("span",{children:p("All Projects")})]}),a.jsx(xt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${x?"rotate-180":""}`})]}),x?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>S(!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),S(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[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(di,{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"}),b.map(T=>{const B=m===T.id,I=T.color.replace("text-","bg-");return a.jsxs("button",{onClick:()=>{v(T.id),S(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[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 ${I}`}),a.jsx("span",{className:B?"text-neutral-900 font-medium":"text-neutral-600",children:T.name})]}),B?a.jsx(ss,{size:14,className:"text-neutral-900"}):null]},T.id)}),a.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),a.jsxs("button",{onClick:()=>{S(!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(br,{size:14}),a.jsx("span",{children:p("Create New Project...")})]})]})]}):null]}),a.jsx("button",{onClick:i,disabled:!j,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(j?"New Task":"Deleted projects are read-only"),children:a.jsx(br,{size:18})})]}),a.jsxs(Pc,{sensors:u,onDragStart:_,onDragEnd:y,children:[a.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:oh.map(({status:T,title:B,defaultOpen:I})=>a.jsx(ih,{title:B,tasks:M[T],status:T,defaultOpen:I,selectedTaskId:s,onSelectTask:l,projects:t,activeTaskIds:c,isDragging:g!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:o},T))}),a.jsx(th,{dropAnimation:null,children:g?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:g.title})}):null})]}),w.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:w.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 ah={damping:.7,stiffness:.05,mass:1.25},lh=70,ch=1e3/60,hh=350;let Xs=!1;globalThis.document?.addEventListener("mousedown",()=>{Xs=!0});globalThis.document?.addEventListener("mouseup",()=>{Xs=!1});globalThis.document?.addEventListener("click",()=>{Xs=!1});const qn=(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<=lh}}},[]),p=k.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||c(!0);const u=Date.now()+(Number(h.wait)||0),_=ar(r.current,h.animation),{ignoreEscapes:y=!1}=h;let w,E=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const b=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:j}=o,M=performance.now(),L=(M-(o.lastTick??M))/ch;if(o.animation||(o.animation={behavior:_,promise:R,ignoreEscapes:y}),o.animation.behavior===_&&(o.lastTick=M),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*L,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:ar(r.current,r.current.resize),ignoreEscapes:y,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]),x=k.useCallback(()=>{f(!0),c(!1)},[f,c]),S=k.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:_}=o;let{lastScrollTop:y=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,_&&_>u&&(y=_),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===_)return;if(i()){f(!0),c(!1);return}const w=u>y,E=u<y;if(o.animation?.ignoreEscapes){o.scrollTop=y;return}E&&(f(!0),c(!1)),w&&f(!1),!o.escapedFromLock&&o.isNearBottom&&c(!0)},1)},[f,c,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=ki(h=>{n.current?.removeEventListener("scroll",S),n.current?.removeEventListener("wheel",g),h?.addEventListener("scroll",S,{passive:!0}),h?.addEventListener("wheel",g,{passive:!0})},[]),d=ki(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([_])=>{const{height:y}=_.contentRect,w=y-(u??y);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const E=ar(r.current,u?r.current.resize:r.current.initial);p({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:hh})}else o.isNearBottom&&(f(!1),c(!0));u=y,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:d,scrollRef:n,scrollToBottom:p,stopScroll:x,isAtBottom:l||v,isNearBottom:v,escapedFromLock:t,state:o}};function ki(e,t){const s=k.useCallback(l=>(s.current=l,e(l)),t);return s}const or=new Map;function ar(...e){const t={...ah};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 or.has(l)||or.set(l,Object.freeze(t)),s?"instant":or.get(l)}function uh({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 dh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Kn({usage:e}){const{t}=ce();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?dh(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(uh,{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(Ua,{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 lr={exports:{}},Ri;function fh(){return Ri||(Ri=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,_,y,w){var E,b=arguments.length,R=b<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,y):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,y,w);else for(var j=u.length-1;j>=0;j--)(E=u[j])&&(R=(b<3?E(R):b>3?E(_,y,R):E(_,y))||R);return b>3&&R&&Object.defineProperty(_,y,R),R},f=this&&this.__param||function(u,_){return function(y,w){_(y,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const o=i(9042),p=i(6114),x=i(9924),S=i(844),g=i(5596),n=i(4725),d=i(3656);let h=r.AccessibilityManager=class extends S.Disposable{constructor(u,_){super(),this._terminal=u,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let y=0;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);if(this._topBoundaryFocusListener=y=>this._handleBoundaryFocus(y,0),this._bottomBoundaryFocusListener=y=>this._handleBoundaryFocus(y,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((y=>this._handleResize(y.rows)))),this.register(this._terminal.onRender((y=>this._refreshRows(y.start,y.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((y=>this._handleChar(y)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
11
|
+
${n&&c?"border border-dashed border-neutral-300":""}`,children:n?a.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:x("No tasks")}):s.map(b=>{const R=r.find(L=>L.id===b.projectId),j=v===b.id,M=i?.has(b.id)??!1;return a.jsx(rh,{task:b,status:l,isSelected:j,isAgentActive:M,project:R,onSelectTask:C,onTaskStatusChange:b.projectArchivedAt?void 0:o,onDeleteTask:b.projectArchivedAt?void 0:p},b.id)})})]})});function nh(e){const t={[le.Review]:[],[le.Running]:[],[le.Pending]:[],[le.Done]:[],[le.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const oh=[{status:le.Review,title:"Review",defaultOpen:!0},{status:le.Running,title:"Running",defaultOpen:!0},{status:le.Pending,title:"Pending",defaultOpen:!1},{status:le.Done,title:"Done",defaultOpen:!1},{status:le.Cancelled,title:"Cancelled",defaultOpen:!1}];function Ei({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}=ce(),[x,S]=k.useState(!1),[g,n]=k.useState(null),[d,h]=k.useState(null),u=Il(Bl(Ur,{activationConstraint:{distance:8}})),_=k.useCallback(T=>{const B=T.active.data.current?.task,I=T.active.data.current?.fromStatus;B&&n(B),I&&h(I)},[]),y=k.useCallback(T=>{n(null),h(null);const{active:B,over:I}=T;if(!I)return;const H=B.data.current?.task,W=B.data.current?.fromStatus,A=I.data.current?.status;!H||!W||!A||H.projectArchivedAt||W!==A&&f?.(H.id,A)},[f]),w=m?e.filter(T=>T.projectId===m):e,E=m?t.find(T=>T.id===m)??null:null,b=t.filter(T=>!T.archivedAt),j=!!!E?.archivedAt,M=nh(w),L=C==="100%";return a.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${L?"":"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:()=>S(T=>!T),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&E?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${E.color.replace("text-","bg-")}`}),a.jsx("span",{className:"truncate",children:E.name})]}):a.jsxs(a.Fragment,{children:[a.jsx(di,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),a.jsx("span",{children:p("All Projects")})]}),a.jsx(xt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${x?"rotate-180":""}`})]}),x?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>S(!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),S(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[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(di,{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"}),b.map(T=>{const B=m===T.id,I=T.color.replace("text-","bg-");return a.jsxs("button",{onClick:()=>{v(T.id),S(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[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 ${I}`}),a.jsx("span",{className:B?"text-neutral-900 font-medium":"text-neutral-600",children:T.name})]}),B?a.jsx(ss,{size:14,className:"text-neutral-900"}):null]},T.id)}),a.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),a.jsxs("button",{onClick:()=>{S(!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(br,{size:14}),a.jsx("span",{children:p("Create New Project...")})]})]})]}):null]}),a.jsx("button",{onClick:i,disabled:!j,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(j?"New Task":"Deleted projects are read-only"),children:a.jsx(br,{size:18})})]}),a.jsxs(Pc,{sensors:u,onDragStart:_,onDragEnd:y,children:[a.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:oh.map(({status:T,title:B,defaultOpen:I})=>a.jsx(ih,{title:B,tasks:M[T],status:T,defaultOpen:I,selectedTaskId:s,onSelectTask:l,projects:t,activeTaskIds:c,isDragging:g!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:o},T))}),a.jsx(th,{dropAnimation:null,children:g?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:g.title})}):null})]}),w.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:w.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 ah={damping:.7,stiffness:.05,mass:1.25},lh=70,ch=1e3/60,hh=350;let Xs=!1;globalThis.document?.addEventListener("mousedown",()=>{Xs=!0});globalThis.document?.addEventListener("mouseup",()=>{Xs=!1});globalThis.document?.addEventListener("click",()=>{Xs=!1});const qn=(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<=lh}}},[]),p=k.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||c(!0);const u=Date.now()+(Number(h.wait)||0),_=ar(r.current,h.animation),{ignoreEscapes:y=!1}=h;let w,E=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const b=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:j}=o,M=performance.now(),L=(M-(o.lastTick??M))/ch;if(o.animation||(o.animation={behavior:_,promise:R,ignoreEscapes:y}),o.animation.behavior===_&&(o.lastTick=M),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*L,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:ar(r.current,r.current.resize),ignoreEscapes:y,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]),x=k.useCallback(()=>{f(!0),c(!1)},[f,c]),S=k.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:_}=o;let{lastScrollTop:y=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,_&&_>u&&(y=_),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===_)return;if(i()){f(!0),c(!1);return}const w=u>y,E=u<y;if(o.animation?.ignoreEscapes){o.scrollTop=y;return}E&&(f(!0),c(!1)),w&&f(!1),!o.escapedFromLock&&o.isNearBottom&&c(!0)},1)},[f,c,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=ki(h=>{n.current?.removeEventListener("scroll",S),n.current?.removeEventListener("wheel",g),h?.addEventListener("scroll",S,{passive:!0}),h?.addEventListener("wheel",g,{passive:!0})},[]),d=ki(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([_])=>{const{height:y}=_.contentRect,w=y-(u??y);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const E=ar(r.current,u?r.current.resize:r.current.initial);p({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:hh})}else o.isNearBottom&&(f(!1),c(!0));u=y,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:d,scrollRef:n,scrollToBottom:p,stopScroll:x,isAtBottom:l||v,isNearBottom:v,escapedFromLock:t,state:o}};function ki(e,t){const s=k.useCallback(l=>(s.current=l,e(l)),t);return s}const or=new Map;function ar(...e){const t={...ah};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 or.has(l)||or.set(l,Object.freeze(t)),s?"instant":or.get(l)}function uh({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 dh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Kn({usage:e}){const{t}=ce();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?dh(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(uh,{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(Ua,{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 lr={exports:{}},Ri;function fh(){return Ri||(Ri=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,_,y,w){var E,b=arguments.length,R=b<3?_:w===null?w=Object.getOwnPropertyDescriptor(_,y):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(u,_,y,w);else for(var j=u.length-1;j>=0;j--)(E=u[j])&&(R=(b<3?E(R):b>3?E(_,y,R):E(_,y))||R);return b>3&&R&&Object.defineProperty(_,y,R),R},f=this&&this.__param||function(u,_){return function(y,w){_(y,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const o=i(9042),p=i(6114),x=i(9924),S=i(844),g=i(5596),n=i(4725),d=i(3656);let h=r.AccessibilityManager=class extends S.Disposable{constructor(u,_){super(),this._terminal=u,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let y=0;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);if(this._topBoundaryFocusListener=y=>this._handleBoundaryFocus(y,0),this._bottomBoundaryFocusListener=y=>this._handleBoundaryFocus(y,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((y=>this._handleResize(y.rows)))),this.register(this._terminal.onRender((y=>this._refreshRows(y.start,y.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((y=>this._handleChar(y)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
12
12
|
`)))),this.register(this._terminal.onA11yTab((y=>this._handleTab(y)))),this.register(this._terminal.onKey((y=>this._handleKey(y.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new g.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,d.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let _=0;_<u;_++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
|
|
13
13
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=o.tooMuchOutput)),p.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,p.isMac&&this._liveRegion.remove()}_handleKey(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,_){this._liveRegionDebouncer.refresh(u,_,this._terminal.rows)}_renderRows(u,_){const y=this._terminal.buffer,w=y.lines.length.toString();for(let E=u;E<=_;E++){const b=y.translateBufferLineToString(y.ydisp+E,!0),R=(y.ydisp+E+1).toString(),j=this._rowElements[E];j&&(b.length===0?j.innerText=" ":j.textContent=b,j.setAttribute("aria-posinset",R),j.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,_){const y=u.target,w=this._rowElements[_===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==w)return;let E,b;if(_===0?(E=y,b=this._rowElements.pop(),this._rowContainer.removeChild(b)):(E=this._rowElements.shift(),b=y,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),b.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const R=this._createAccessibilityTreeNode();this._rowElements.unshift(R),this._rowContainer.insertAdjacentElement("afterbegin",R)}else{const R=this._createAccessibilityTreeNode();this._rowElements.push(R),this._rowContainer.appendChild(R)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=h=c([f(1,n.IRenderService)],h)},3614:(C,r)=>{function i(p){return p.replace(/\r?\n/g,"\r")}function c(p,x){return x?"\x1B[200~"+p+"\x1B[201~":p}function f(p,x,S,g){p=c(p=i(p),S.decPrivateModes.bracketedPasteMode&&g.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(p,!0),x.value=""}function o(p,x,S){const g=S.getBoundingClientRect(),n=p.clientX-g.left-10,d=p.clientY-g.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${n}px`,x.style.top=`${d}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=i,r.bracketTextForPaste=c,r.copyHandler=function(p,x){p.clipboardData&&p.clipboardData.setData("text/plain",x.selectionText),p.preventDefault()},r.handlePasteEvent=function(p,x,S,g){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),x,S,g)},r.paste=f,r.moveTextAreaUnderMouseCursor=o,r.rightClickHandler=function(p,x,S,g,n){o(p,x,S),n&&g.rightClickSelect(p),x.value=g.selectionText,x.select()}},7239:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const c=i(1505);r.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,o,p){this._css.set(f,o,p)}getCss(f,o){return this._css.get(f,o)}setColor(f,o,p){this._color.set(f,o,p)}getColor(f,o){return this._color.get(f,o)}clear(){this._color.clear(),this._css.clear()}}},3656:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(i,c,f,o){i.addEventListener(c,f,o);let p=!1;return{dispose:()=>{p||(p=!0,i.removeEventListener(c,f,o))}}}},6465:function(C,r,i){var c=this&&this.__decorate||function(n,d,h,u){var _,y=arguments.length,w=y<3?d:u===null?u=Object.getOwnPropertyDescriptor(d,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,d,h,u);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(w=(y<3?_(w):y>3?_(d,h,w):_(d,h))||w);return y>3&&w&&Object.defineProperty(d,h,w),w},f=this&&this.__param||function(n,d){return function(h,u){d(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const o=i(3656),p=i(8460),x=i(844),S=i(2585);let g=r.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const d=this._linkProviders.indexOf(n);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(n,d,h){this._element=n,this._mouseService=d,this._renderService=h,this.register((0,o.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,o.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const h=n.composedPath();for(let u=0;u<h.length;u++){const _=h[u];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,d){var h,u;this._activeProviderReplies&&d||((h=this._activeProviderReplies)===null||h===void 0||h.forEach((y=>{y?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let _=!1;for(const[y,w]of this._linkProviders.entries())d?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(y)&&(_=this._checkLinkProviderResult(y,n,_)):w.provideLinks(n.y,(E=>{var b,R;if(this._isMouseOut)return;const j=E?.map((M=>({link:M})));(b=this._activeProviderReplies)===null||b===void 0||b.set(y,j),_=this._checkLinkProviderResult(y,n,_),((R=this._activeProviderReplies)===null||R===void 0?void 0:R.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,d){const h=new Set;for(let u=0;u<d.size;u++){const _=d.get(u);if(_)for(let y=0;y<_.length;y++){const w=_[y],E=w.link.range.start.y<n?0:w.link.range.start.x,b=w.link.range.end.y>n?this._bufferService.cols:w.link.range.end.x;for(let R=E;R<=b;R++){if(h.has(R)){_.splice(y--,1);break}h.add(R)}}}}_checkLinkProviderResult(n,d,h){var u;if(!this._activeProviderReplies)return h;const _=this._activeProviderReplies.get(n);let y=!1;for(let w=0;w<n;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(y=!0);if(!y&&_){const w=_.find((E=>this._linkAtPosition(E.link,d)));w&&(h=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviders.length&&!h)for(let w=0;w<this._activeProviderReplies.size;w++){const E=(u=this._activeProviderReplies.get(w))===null||u===void 0?void 0:u.find((b=>this._linkAtPosition(b.link,d)));if(E){h=!0,this._handleNewLink(E);break}}return h}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!d||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(n.link,d)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:h=>{var u,_;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==h&&(this._currentLink.state.decorations.pointerCursor=h,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",h)))}},underline:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.underline},set:h=>{var u,_,y;!((u=this._currentLink)===null||u===void 0)&&u.state&&((y=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||y===void 0?void 0:y.decorations.underline)!==h&&(this._currentLink.state.decorations.underline=h,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,h))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((h=>{if(!this._currentLink)return;const u=h.start===0?0:h.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+h.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(u,_),this._lastMouseEvent&&this._element)){const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._askForLink(y,!1)}}))))}_linkHover(n,d,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(h,d.text)}_fireUnderlineEvent(n,d){const h=n.range,u=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(h.start.x-1,h.start.y-u-1,h.end.x,h.end.y-u-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(n,d,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(h,d.text)}_linkAtPosition(n,d){const h=n.range.start.y*this._bufferService.cols+n.range.start.x,u=n.range.end.y*this._bufferService.cols+n.range.end.x,_=d.y*this._bufferService.cols+d.x;return h<=_&&_<=u}_positionFromMouseEvent(n,d,h){const u=h.getCoords(n,d,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,d,h,u,_){return{x1:n,y1:d,x2:h,y2:u,cols:this._bufferService.cols,fg:_}}};r.Linkifier2=g=c([f(0,S.IBufferService)],g)},9042:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(C,r,i){var c=this&&this.__decorate||function(g,n,d,h){var u,_=arguments.length,y=_<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(g,n,d,h);else for(var w=g.length-1;w>=0;w--)(u=g[w])&&(y=(_<3?u(y):_>3?u(n,d,y):u(n,d))||y);return _>3&&y&&Object.defineProperty(n,d,y),y},f=this&&this.__param||function(g,n){return function(d,h){n(d,h,g)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const o=i(511),p=i(2585);let x=r.OscLinkProvider=class{constructor(g,n,d){this._bufferService=g,this._optionsService=n,this._oscLinkService=d}provideLinks(g,n){var d;const h=this._bufferService.buffer.lines.get(g-1);if(!h)return void n(void 0);const u=[],_=this._optionsService.rawOptions.linkHandler,y=new o.CellData,w=h.getTrimmedLength();let E=-1,b=-1,R=!1;for(let j=0;j<w;j++)if(b!==-1||h.hasContent(j)){if(h.loadCell(j,y),y.hasExtendedAttrs()&&y.extended.urlId){if(b===-1){b=j,E=y.extended.urlId;continue}R=y.extended.urlId!==E}else b!==-1&&(R=!0);if(R||b!==-1&&j===w-1){const M=(d=this._oscLinkService.getLinkData(E))===null||d===void 0?void 0:d.uri;if(M){const L={start:{x:b+1,y:g},end:{x:j+(R||j!==w-1?0:1),y:g}};let T=!1;if(!_?.allowNonHttpProtocols)try{const B=new URL(M);["http:","https:"].includes(B.protocol)||(T=!0)}catch{T=!0}T||u.push({text:M,range:L,activate:(B,I)=>_?_.activate(B,I,L):S(0,I),hover:(B,I)=>{var H;return(H=_?.hover)===null||H===void 0?void 0:H.call(_,B,I,L)},leave:(B,I)=>{var H;return(H=_?.leave)===null||H===void 0?void 0:H.call(_,B,I,L)}})}R=!1,y.hasExtendedAttrs()&&y.extended.urlId?(b=j,E=y.extended.urlId):(b=-1,E=-1)}}n(u)}};function S(g,n){if(confirm(`Do you want to navigate to ${n}?
|
|
14
14
|
|
|
@@ -59,29 +59,29 @@ 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
|
-
`,Wi={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};zd(Wd);var $d=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),x=p.init,S=p.cleanupWindowEvents,g=k.useRef(null),n=k.useRef(null);return k.useEffect(function(){var d=g.current,h=n.current;return d!==null&&h!==null&&x&&x?.(d,h),function(){S?.()}},[]),ee.createElement("div",Rt({},c,{ref:g,className:"".concat(Er.wrapperClass," ").concat(Wi.wrapper," ").concat(l),style:C}),ee.createElement("div",Rt({},o,{ref:n,className:"".concat(Er.contentClass," ").concat(Wi.content," ").concat(v),style:r}),t))},go=function(){var e=k.useContext(Qs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Ud=function(){var e=go();return Ms(e)};function qd(e){var t=go(),s=k.useState(e(kr(t))),l=s[0],m=s[1];return k.useEffect(function(){var v=!0,C=t.onChange(function(r){v&&m(e(kr(r.instance)))});return function(){C(),v=!1}},[e,t]),l}function Kd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Xd(e,t){return ht({queryKey:le.files.tree(e||"",t),queryFn:()=>fe.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Yd(e,t){return ht({queryKey:le.files.content(e||"",t||""),queryFn:()=>fe.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Vd(e){const t=We();return k.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Gd(){const e=We();return Ze({mutationFn:t=>fe.post("/files/write",t),onSuccess:(t,s)=>{const l=le.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||Kd(s.path)})}})}function Qd(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Zd(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Jd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function ef(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Jd.has(t)?Br:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?rs:t==="json"?Ba:t==="md"||t==="mdx"||t==="txt"?Cn:Ca}const $i=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:v})=>a.jsxs("button",{type:"button",onClick:s,className:ye("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})]}),_o=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})=>{const{t:r}=ce(),{data:i,isLoading:c,isError:f}=Xd(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=Qd(t,p.name),h=l.has(d);return a.jsxs("div",{children:[a.jsx($i,{depth:s,onClick:()=>m(d),rightIcon:h?a.jsx(xt,{size:14,className:"text-neutral-400"}):a.jsx(Ft,{size:14,className:"text-neutral-400"}),leftIcon:h?a.jsx(wn,{size:14,className:"text-amber-500"}):a.jsx(ya,{size:14,className:"text-amber-500"}),label:p.name}),h&&a.jsx(_o,{workingDir:e,path:d,depth:s+1,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})]},d)}const x=Zd(t,p.name),S=ef(p),g=C===x,n=S===Br;return a.jsx($i,{depth:s,active:g,onClick:()=>v(x),rightIcon:a.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?a.jsx(S,{size:14,className:n?"text-emerald-600":"text-sky-600"}):null,label:p.name},x)})})},tf=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const{t:v}=ce(),[C,r]=k.useState(()=>new Set),i=Vd(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:ye("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(ml,{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(nl,{size:13})})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?a.jsx(_o,{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.")})})]})},sf=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function rf(e){const t=e.split(".").pop()?.toLowerCase();return t?sf.has(t):!1}function nf(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${l.toString()}`}const of=({filePath:e})=>{const{t}=ce(),{zoomIn:s,zoomOut:l,centerView:m}=Ud(),v=qd(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(Cl,{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(Sl,{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(tl,{size:13})}),a.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},af=({workingDir:e,filePath:t})=>{const{t:s}=ce(),[l,m]=k.useState(!1),v=nf(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(Hd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx(of,{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($d,{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 lf(e){const t=e.split("/");return t[t.length-1]||e}function cf(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 hf=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>{const{t:v}=ce();return a.jsxs("button",{type:"button",onClick:l,className:ye("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:ye("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})})]})},uf=({workingDir:e,className:t,readOnly:s=!1})=>{const{t:l}=ce(),[m,v]=k.useState([]),[C,r]=k.useState(null),i=Gd(),[c,f]=k.useState(280),[o,p]=k.useState(!1),[x,S]=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(),S(!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=()=>{S(!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:y,error:w}=Yd(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=rf(T);return[...B,{path:T,name:lf(T),language:cf(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]),M=k.useRef(()=>{});k.useEffect(()=>{M.current=()=>{j().catch(()=>{})}},[j]),k.useEffect(()=>{const T=B=>{s||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),M.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[s]);const L=k.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{M.current()})},[]);return a.jsxs("div",{className:ye("flex h-full overflow-hidden bg-white",t),style:x?{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:x?"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(al,{size:16})})}):a.jsx(a.Fragment,{children:a.jsx(tf,{workingDir:e,onFileSelect:E,selectedFilePath:h?.path||null,onCollapse:n},e||"no-working-dir")})}),!o&&a.jsx("div",{onMouseDown:d,className:ye("w-1 shrink-0 cursor-col-resize transition-colors",x?"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(hf,{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(ze,{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(af,{workingDir:e,filePath:h.path}):a.jsxs(a.Fragment,{children:[a.jsx(Tu,{path:h.path,value:h.content,language:h.language,theme:"vs-light",height:"100%",onChange:s?void 0:T=>R(T??""),onMount:L,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(ze,{size:14,className:"animate-spin"}),l("Loading file...")]})}),y&&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 bo(e){return ht({queryKey:le.git.changes(e||""),queryFn:()=>fe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function xo(e,t,s){return ht({queryKey:le.git.diff(e||"",t||"",s),queryFn:()=>fe.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function So(e,t){return ht({queryKey:le.git.commitFiles(e||"",t||""),queryFn:()=>fe.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function yo(e,t,s){return ht({queryKey:le.git.commitDiff(e||"",t||"",s||""),queryFn:()=>fe.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ui={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},df={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function ff(e){const t=e.split("/");return t[t.length-1]||e}function mf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const pf=({entry:e,selected:t,onClick:s})=>{const{t:l}=ce(),m=Ui[e.status]||Ui.M,v=df[e.status]||e.status,C=mf(e.path);return a.jsxs("button",{type:"button",onClick:s,className:ye("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:ye("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:ff(e.path)}),C&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:C})]})},qi=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>{const{t:v}=ce();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(pf,{entry:C,selected:l===r,onClick:()=>m(C.path,s)},r)})})]})},vf=({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:ye("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:ye("pl-2 whitespace-pre",l),children:e})]})},gf=({workingDir:e,filePath:t,type:s})=>{const{t:l}=ce(),{data:m,isLoading:v,isError:C}=xo(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(ze,{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
|
+
`,Wi={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};zd(Wd);var $d=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),x=p.init,S=p.cleanupWindowEvents,g=k.useRef(null),n=k.useRef(null);return k.useEffect(function(){var d=g.current,h=n.current;return d!==null&&h!==null&&x&&x?.(d,h),function(){S?.()}},[]),ee.createElement("div",Rt({},c,{ref:g,className:"".concat(Er.wrapperClass," ").concat(Wi.wrapper," ").concat(l),style:C}),ee.createElement("div",Rt({},o,{ref:n,className:"".concat(Er.contentClass," ").concat(Wi.content," ").concat(v),style:r}),t))},go=function(){var e=k.useContext(Qs);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Ud=function(){var e=go();return Ms(e)};function qd(e){var t=go(),s=k.useState(e(kr(t))),l=s[0],m=s[1];return k.useEffect(function(){var v=!0,C=t.onChange(function(r){v&&m(e(kr(r.instance)))});return function(){C(),v=!1}},[e,t]),l}function Kd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Xd(e,t){return ht({queryKey:ae.files.tree(e||"",t),queryFn:()=>fe.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Yd(e,t){return ht({queryKey:ae.files.content(e||"",t||""),queryFn:()=>fe.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Vd(e){const t=We();return k.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Gd(){const e=We();return Ze({mutationFn:t=>fe.post("/files/write",t),onSuccess:(t,s)=>{const l=ae.files.content(s.workingDir,s.path),m=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:m?.language||Kd(s.path)})}})}function Qd(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Zd(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Jd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function ef(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Jd.has(t)?Br:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?rs:t==="json"?Ba:t==="md"||t==="mdx"||t==="txt"?Cn:Ca}const $i=({depth:e,active:t,onClick:s,leftIcon:l,rightIcon:m,label:v})=>a.jsxs("button",{type:"button",onClick:s,className:ye("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})]}),_o=({workingDir:e,path:t,depth:s,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})=>{const{t:r}=ce(),{data:i,isLoading:c,isError:f}=Xd(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=Qd(t,p.name),h=l.has(d);return a.jsxs("div",{children:[a.jsx($i,{depth:s,onClick:()=>m(d),rightIcon:h?a.jsx(xt,{size:14,className:"text-neutral-400"}):a.jsx(Ft,{size:14,className:"text-neutral-400"}),leftIcon:h?a.jsx(wn,{size:14,className:"text-amber-500"}):a.jsx(ya,{size:14,className:"text-amber-500"}),label:p.name}),h&&a.jsx(_o,{workingDir:e,path:d,depth:s+1,expanded:l,toggleDir:m,onFileSelect:v,selectedFilePath:C})]},d)}const x=Zd(t,p.name),S=ef(p),g=C===x,n=S===Br;return a.jsx($i,{depth:s,active:g,onClick:()=>v(x),rightIcon:a.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?a.jsx(S,{size:14,className:n?"text-emerald-600":"text-sky-600"}):null,label:p.name},x)})})},tf=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:l,onCollapse:m})=>{const{t:v}=ce(),[C,r]=k.useState(()=>new Set),i=Vd(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:ye("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(ml,{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(nl,{size:13})})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?a.jsx(_o,{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.")})})]})},sf=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function rf(e){const t=e.split(".").pop()?.toLowerCase();return t?sf.has(t):!1}function nf(e,t){const s="/api",l=new URLSearchParams({workingDir:e,path:t});return`${s}/files/image?${l.toString()}`}const of=({filePath:e})=>{const{t}=ce(),{zoomIn:s,zoomOut:l,centerView:m}=Ud(),v=qd(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(Cl,{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(Sl,{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(tl,{size:13})}),a.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},af=({workingDir:e,filePath:t})=>{const{t:s}=ce(),[l,m]=k.useState(!1),v=nf(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(Hd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx(of,{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($d,{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 lf(e){const t=e.split("/");return t[t.length-1]||e}function cf(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 hf=({active:e,name:t,isDirty:s,onClick:l,onClose:m})=>{const{t:v}=ce();return a.jsxs("button",{type:"button",onClick:l,className:ye("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:ye("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})})]})},uf=({workingDir:e,className:t,readOnly:s=!1})=>{const{t:l}=ce(),[m,v]=k.useState([]),[C,r]=k.useState(null),i=Gd(),[c,f]=k.useState(280),[o,p]=k.useState(!1),[x,S]=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(),S(!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=()=>{S(!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:y,error:w}=Yd(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=rf(T);return[...B,{path:T,name:lf(T),language:cf(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]),M=k.useRef(()=>{});k.useEffect(()=>{M.current=()=>{j().catch(()=>{})}},[j]),k.useEffect(()=>{const T=B=>{s||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),M.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[s]);const L=k.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{M.current()})},[]);return a.jsxs("div",{className:ye("flex h-full overflow-hidden bg-white",t),style:x?{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:x?"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(al,{size:16})})}):a.jsx(a.Fragment,{children:a.jsx(tf,{workingDir:e,onFileSelect:E,selectedFilePath:h?.path||null,onCollapse:n},e||"no-working-dir")})}),!o&&a.jsx("div",{onMouseDown:d,className:ye("w-1 shrink-0 cursor-col-resize transition-colors",x?"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(hf,{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(ze,{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(af,{workingDir:e,filePath:h.path}):a.jsxs(a.Fragment,{children:[a.jsx(Tu,{path:h.path,value:h.content,language:h.language,theme:"vs-light",height:"100%",onChange:s?void 0:T=>R(T??""),onMount:L,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(ze,{size:14,className:"animate-spin"}),l("Loading file...")]})}),y&&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 bo(e){return ht({queryKey:ae.git.changes(e||""),queryFn:()=>fe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function xo(e,t,s){return ht({queryKey:ae.git.diff(e||"",t||"",s),queryFn:()=>fe.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function So(e,t){return ht({queryKey:ae.git.commitFiles(e||"",t||""),queryFn:()=>fe.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function yo(e,t,s){return ht({queryKey:ae.git.commitDiff(e||"",t||"",s||""),queryFn:()=>fe.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const Ui={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},df={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function ff(e){const t=e.split("/");return t[t.length-1]||e}function mf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const pf=({entry:e,selected:t,onClick:s})=>{const{t:l}=ce(),m=Ui[e.status]||Ui.M,v=df[e.status]||e.status,C=mf(e.path);return a.jsxs("button",{type:"button",onClick:s,className:ye("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:ye("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:ff(e.path)}),C&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:C})]})},qi=({title:e,entries:t,type:s,selectedKey:l,onSelect:m})=>{const{t:v}=ce();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(pf,{entry:C,selected:l===r,onClick:()=>m(C.path,s)},r)})})]})},vf=({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:ye("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:ye("pl-2 whitespace-pre",l),children:e})]})},gf=({workingDir:e,filePath:t,type:s})=>{const{t:l}=ce(),{data:m,isLoading:v,isError:C}=xo(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(ze,{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(vf,{line:c,lineNum:f+1},f))})},_f=({workingDir:e})=>{const{t}=ce(),{data:s,isLoading:l,isError:m}=bo(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)},y=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",y)},[r]),p=v?`${v.type}:${v.path}`:null,x=(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(ze,{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 S=s?.uncommitted||[],g=s?.committed||[],n=S.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(qi,{title:"Uncommitted",entries:S,type:"uncommitted",selectedKey:p,onSelect:x}),a.jsx(qi,{title:"Committed",entries:g,type:"committed",selectedKey:p,onSelect:x})]})})]}),a.jsx("div",{onMouseDown:o,className:ye("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(gf,{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")})]})})})]})},pr=50,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"};function bf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Et("{count}s ago",{count:s}):s<3600?Et("{count}m ago",{count:Math.floor(s/60)}):s<86400?Et("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Et("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}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=`
|
|
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
|
`,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:ye("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:ye("pl-2 whitespace-pre",l),children:e})]})},wf=({workingDir:e,hash:t,filePath:s})=>{const{t:l}=ce(),{data:m,isLoading:v,isError:C}=yo(e,t,s);if(v)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[a.jsx(ze,{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(Cf,{line:c,lineNum:f+1},f))})},Ef=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{t:m}=ce(),{data:v,isLoading:C}=So(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(ze,{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=Ki[i.status]||Ki.M,f=Sf(i.path);return a.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),l(i.path)},className:ye("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:ye("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:xf(i.path)}),f&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},i.path)})})},kf=({workingDir:e})=>{const{t}=ce(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=_n({queryKey:le.git.log(e||""),queryFn:({pageParam:y=0})=>fe.get("/git/log",{params:{workingDir:e||"",limit:String(pr),skip:String(y)}}),initialPageParam:0,getNextPageParam:(y,w)=>y.commits.length<pr?void 0:w.length*pr,enabled:!!e}),i=s?.pages.flatMap(y=>y.commits)||[],[c,f]=k.useState(null),[o,p]=k.useState(null),[x,S]=k.useState(280),[g,n]=k.useState(!1),d=k.useCallback(y=>{y.preventDefault(),n(!0);const w=y.clientX,E=x,b=j=>{const M=Math.min(480,Math.max(180,E+(j.clientX-w)));S(M)},R=()=>{n(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",R)},[x]),h=y=>{c===y?(f(null),p(null)):(f(y),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(ze,{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(qt,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:t("No commit history")})]});const _=i.find(y=>y.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:yf}),a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:x},children:[a.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children: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(y=>{const w=c===y.hash;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>h(y.hash),className:ye("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:ye("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:y.shortHash}),a.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:y.message}),a.jsx(Ft,{size:12,className:ye("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:y.author}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:bf(y.timestamp)})]})]})]}),w&&a.jsxs(a.Fragment,{children:[y.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:y.body}),a.jsx(Ef,{workingDir:e,hash:y.hash,selectedPath:o,onSelectFile:p})]})]},y.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(ze,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),a.jsx("div",{onMouseDown:d,className:ye("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(wf,{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")})]})})})]})},Rf=[{key:"changes",label:"Changes",icon:a.jsx(is,{size:14})},{key:"history",label:"History",icon:a.jsx(qt,{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})}],Df=[{key:"history",label:"History",icon:a.jsx(qt,{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})}],Af=({active:e,onClick:t,icon:s,label:l})=>a.jsxs("button",{onClick:t,className:ye("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})]}),jf=({icon:e,title:t})=>{const{t:s}=ce();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...")})]})})},Co=ee.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:v,readOnly:C,repoDeleted:r}){const{t:i}=ce(),c=k.useMemo(()=>{const d=v?Df:Rf;return C?d.filter(h=>h.key!=="terminal"):d},[v,C]),[f,o]=k.useState(v?"history":"changes"),{data:p}=ga(m??""),x=k.useMemo(()=>{if(!p?.quickCommands)return[];try{return JSON.parse(p.quickCommands)}catch{return[]}},[p?.quickCommands]),[S,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:ye("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(Af,{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(uf,{workingDir:l,readOnly:C}),S.map(d=>a.jsx("div",{className:"h-full absolute inset-0",style:{display:f==="terminal"&&l===d?"block":"none"},children:a.jsx(yh,{cwd:d,quickCommands:x})},d)),f==="preview"&&a.jsx(jf,{icon:a.jsx(Is,{size:32}),title:"Preview"}),f==="changes"&&a.jsx(_f,{workingDir:l}),f==="history"&&a.jsx(kf,{workingDir:l})]})]})});function wo(e){return ht({queryKey:le.workspaces.list(e),queryFn:()=>fe.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Eo(e){const t=We();return Ze({mutationFn:s=>fe.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:le.workspaces.list(e)}),t.invalidateQueries({queryKey:le.tasks.all})}})}function Tf(){const e=We();return Ze({mutationFn:({id:t,commitMessage:s})=>fe.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Vr(){return Ze({mutationFn:({workspaceId:e,editorType:t})=>fe.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function ko(e){return ht({queryKey:le.workspaces.gitStatus(e),queryFn:()=>fe.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Lf(){const e=We();return Ze({mutationFn:t=>fe.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})}})}function Mf(){const e=We();return Ze({mutationFn:t=>fe.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})}})}const Xi=1500,Nf=3e3;function Pf(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=wt.connect();r.emit(Pt.SUBSCRIBE,{topic:"task",id:e},f=>{});const i=f=>{s(f),v.current=setTimeout(()=>s(null),Nf)},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,x=Xi-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),Xi)):x>0?(m.current=o,C(),v.current=setTimeout(()=>i(o),x)):i(o)};return r.on(Qe.WORKSPACE_SETUP_PROGRESS,c),()=>{r.off(Qe.WORKSPACE_SETUP_PROGRESS,c),C(),l.current=0,m.current=null}},[e]),t}function Gr(){const e=We();return Ze({mutationFn:t=>fe.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.sessions.detail(s)})}})}function Ro(){const e=We();return Ze({mutationFn:t=>fe.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.sessions.detail(s)})}})}function Qr(){const e=We();return Ze({mutationFn:({id:t,message:s,providerId:l})=>fe.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all})}})}function Of(e,t){const s={};return ht({queryKey:le.tasks.list(e,t),queryFn:()=>fe.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function Bf(e){const t=We();return Ze({mutationFn:s=>fe.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:le.tasks.list(e)}),t.invalidateQueries({queryKey:le.tasks.stats(e)})}})}function If(){const e=We();return Ze({mutationFn:({id:t,status:s})=>fe.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.tasks.detail(t.id)})}})}function Ff(){const e=We();return Ze({mutationFn:t=>fe.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:le.tasks.all})}})}function Hf(){const e=We();return Ze({mutationFn:t=>fe.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.detail(t.id)})}})}function Do(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 zf="/api";async function Wf(e){const t=new FormData;t.append("file",e);const s=await fetch(`${zf}/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 $f=0;function Zr(){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-${++$f}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...f]),await Promise.allSettled(f.map(async o=>{try{const p=await Wf(o.file);t(x=>x.map(S=>S.tempId===o.tempId?{...S,status:"done",progress:100,attachment:p}:S))}catch(p){t(x=>x.map(S=>S.tempId===o.tempId?{...S,status:"error",error:p instanceof Error?p.message:"Upload failed"}:S))}}))},[]),m=k.useCallback(c=>{t(f=>f.filter(o=>o.tempId!==c))},[]),v=k.useCallback(()=>{t([])},[]),C=k.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const o=f.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
|
|
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(Cf,{line:c,lineNum:f+1},f))})},Ef=({workingDir:e,hash:t,selectedPath:s,onSelectFile:l})=>{const{t:m}=ce(),{data:v,isLoading:C}=So(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(ze,{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=Ki[i.status]||Ki.M,f=Sf(i.path);return a.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),l(i.path)},className:ye("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:ye("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:xf(i.path)}),f&&a.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},i.path)})})},kf=({workingDir:e})=>{const{t}=ce(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=_n({queryKey:ae.git.log(e||""),queryFn:({pageParam:y=0})=>fe.get("/git/log",{params:{workingDir:e||"",limit:String(pr),skip:String(y)}}),initialPageParam:0,getNextPageParam:(y,w)=>y.commits.length<pr?void 0:w.length*pr,enabled:!!e}),i=s?.pages.flatMap(y=>y.commits)||[],[c,f]=k.useState(null),[o,p]=k.useState(null),[x,S]=k.useState(280),[g,n]=k.useState(!1),d=k.useCallback(y=>{y.preventDefault(),n(!0);const w=y.clientX,E=x,b=j=>{const M=Math.min(480,Math.max(180,E+(j.clientX-w)));S(M)},R=()=>{n(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",R)},[x]),h=y=>{c===y?(f(null),p(null)):(f(y),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(ze,{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(qt,{size:28,className:"mb-2"}),a.jsx("span",{className:"text-xs",children:t("No commit history")})]});const _=i.find(y=>y.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:yf}),a.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:x},children:[a.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qt,{size:14,className:"text-neutral-500"}),a.jsx("span",{className:"text-xs font-semibold text-neutral-900",children: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(y=>{const w=c===y.hash;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>h(y.hash),className:ye("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:ye("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:y.shortHash}),a.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:y.message}),a.jsx(Ft,{size:12,className:ye("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:y.author}),a.jsx("span",{className:"text-[10px] text-neutral-400",children:bf(y.timestamp)})]})]})]}),w&&a.jsxs(a.Fragment,{children:[y.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:y.body}),a.jsx(Ef,{workingDir:e,hash:y.hash,selectedPath:o,onSelectFile:p})]})]},y.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(ze,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),a.jsx("div",{onMouseDown:d,className:ye("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(wf,{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")})]})})})]})},Rf=[{key:"changes",label:"Changes",icon:a.jsx(is,{size:14})},{key:"history",label:"History",icon:a.jsx(qt,{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})}],Df=[{key:"history",label:"History",icon:a.jsx(qt,{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})}],Af=({active:e,onClick:t,icon:s,label:l})=>a.jsxs("button",{onClick:t,className:ye("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})]}),jf=({icon:e,title:t})=>{const{t:s}=ce();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...")})]})})},Co=ee.memo(function({className:t,sessionId:s,workingDir:l,projectId:m,hideChanges:v,readOnly:C,repoDeleted:r}){const{t:i}=ce(),c=k.useMemo(()=>{const d=v?Df:Rf;return C?d.filter(h=>h.key!=="terminal"):d},[v,C]),[f,o]=k.useState(v?"history":"changes"),{data:p}=ga(m??""),x=k.useMemo(()=>{if(!p?.quickCommands)return[];try{return JSON.parse(p.quickCommands)}catch{return[]}},[p?.quickCommands]),[S,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:ye("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(Af,{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(uf,{workingDir:l,readOnly:C}),S.map(d=>a.jsx("div",{className:"h-full absolute inset-0",style:{display:f==="terminal"&&l===d?"block":"none"},children:a.jsx(yh,{cwd:d,quickCommands:x})},d)),f==="preview"&&a.jsx(jf,{icon:a.jsx(Is,{size:32}),title:"Preview"}),f==="changes"&&a.jsx(_f,{workingDir:l}),f==="history"&&a.jsx(kf,{workingDir:l})]})]})});function wo(e){return ht({queryKey:ae.workspaces.list(e),queryFn:()=>fe.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Eo(e){const t=We();return Ze({mutationFn:s=>fe.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:ae.workspaces.list(e)}),t.invalidateQueries({queryKey:ae.tasks.all})}})}function Tf(){const e=We();return Ze({mutationFn:({id:t,commitMessage:s})=>fe.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function Vr(){return Ze({mutationFn:({workspaceId:e,editorType:t})=>fe.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function ko(e){return ht({queryKey:ae.workspaces.gitStatus(e),queryFn:()=>fe.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Lf(){const e=We();return Ze({mutationFn:t=>fe.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(s)})}})}function Mf(){const e=We();return Ze({mutationFn:t=>fe.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(s)})}})}const Xi=1500,Nf=3e3;function Pf(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=wt.connect();r.emit(Pt.SUBSCRIBE,{topic:"task",id:e},f=>{});const i=f=>{s(f),v.current=setTimeout(()=>s(null),Nf)},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,x=Xi-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),Xi)):x>0?(m.current=o,C(),v.current=setTimeout(()=>i(o),x)):i(o)};return r.on(Qe.WORKSPACE_SETUP_PROGRESS,c),()=>{r.off(Qe.WORKSPACE_SETUP_PROGRESS,c),C(),l.current=0,m.current=null}},[e]),t}function Gr(){const e=We();return Ze({mutationFn:t=>fe.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:ae.sessions.detail(s)}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function Ro(){const e=We();return Ze({mutationFn:t=>fe.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:ae.sessions.detail(s)})}})}function Qr(){const e=We();return Ze({mutationFn:({id:t,message:s,providerId:l})=>fe.post(`/sessions/${t}/message`,{message:s,providerId:l}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function Of(e,t){const s={};return ht({queryKey:ae.tasks.list(e,t),queryFn:()=>fe.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function Bf(e){const t=We();return Ze({mutationFn:s=>fe.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:ae.tasks.list(e)}),t.invalidateQueries({queryKey:ae.tasks.stats(e)})}})}function If(){const e=We();return Ze({mutationFn:({id:t,status:s})=>fe.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:ae.tasks.all}),e.invalidateQueries({queryKey:ae.tasks.detail(t.id)})}})}function Ff(){const e=We();return Ze({mutationFn:t=>fe.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tasks.all})}})}function Hf(){const e=We();return Ze({mutationFn:t=>fe.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:ae.tasks.all}),e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.detail(t.id)})}})}function Do(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 zf="/api";async function Wf(e){const t=new FormData;t.append("file",e);const s=await fetch(`${zf}/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 $f=0;function Zr(){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-${++$f}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...f]),await Promise.allSettled(f.map(async o=>{try{const p=await Wf(o.file);t(x=>x.map(S=>S.tempId===o.tempId?{...S,status:"done",progress:100,attachment:p}:S))}catch(p){t(x=>x.map(S=>S.tempId===o.tempId?{...S,status:"error",error:p instanceof Error?p.message:"Upload failed"}:S))}}))},[]),m=k.useCallback(c=>{t(f=>f.filter(o=>o.tempId!==c))},[]),v=k.useCallback(()=>{t([])},[]),C=k.useCallback(()=>{const c=s.current.filter(f=>f.status==="done"&&f.attachment);return c.length===0?"":c.map(f=>{const o=f.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
|
|
70
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 Uf="/api";function qf(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(Kf,{item:s,onRemove:t},s.tempId))})}function Kf({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:`${Uf}${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(ze,{size:16,className:"animate-spin text-neutral-400"}):s?a.jsx(Br,{size:16,className:"text-neutral-400"}):a.jsx(Cn,{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:qf(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 Ao({isOpen:e,onClose:t,taskId:s,taskTitle:l,taskDescription:m}){const{t:v}=ce(),[C,r]=k.useState(""),[i,c]=k.useState(""),[f,o]=k.useState("idle"),[p,x]=k.useState(null),S=We(),g=Eo(s),n=Gr(),{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
|
-
`)),o("idle"),x(null)}},[e,l,m]);const u=f!=="idle",_=async()=>{if(!(!C||!i.trim())){x(null);try{o("creating-workspace");const w=await g.mutateAsync({});o("creating-session");const E=await fe.post(`/workspaces/${w.id}/sessions`,{providerId:C,prompt:i.trim()});o("starting-session"),await n.mutateAsync(E.id),await S.invalidateQueries({queryKey:
|
|
72
|
+
`)),o("idle"),x(null)}},[e,l,m]);const u=f!=="idle",_=async()=>{if(!(!C||!i.trim())){x(null);try{o("creating-workspace");const w=await g.mutateAsync({});o("creating-session");const E=await fe.post(`/workspaces/${w.id}/sessions`,{providerId:C,prompt:i.trim()});o("starting-session"),await n.mutateAsync(E.id),await S.invalidateQueries({queryKey:ae.workspaces.list(s)}),o("idle"),t()}catch(w){o("idle"),x(w instanceof Error?w.message:v("启动失败,请重试"))}}},y={idle:v("启动"),"creating-workspace":v("创建工作空间..."),"creating-session":v("创建会话..."),"starting-session":v("启动 Agent...")};return a.jsx(Or,{isOpen:e,onClose:u?()=>{}:t,title:v("启动 Agent"),action:a.jsxs(a.Fragment,{children:[a.jsx(dt,{variant:"outline",onClick:t,disabled:u,children:v("取消")}),a.jsx(dt,{onClick:_,disabled:u||!C||!i.trim(),children:y[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(dt,{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 jo({providers:e,currentProviderId:t,agentType:s,onSelect:l}){const{t:m}=ce(),[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(ii,{size:14,className:"shrink-0"}),a.jsx("span",{children:c?.provider.name?li(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(ii,{size:14,className:"shrink-0"}),a.jsx("span",{children:c?.provider.name?li(c.provider.name,12):s}),a.jsx(xt,{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 Xf({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",x=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} ${x} overflow-y-auto`,children:e.map((S,g)=>a.jsxs("button",{type:"button",onMouseDown:n=>n.preventDefault(),onClick:()=>f(S),className:`w-full rounded-lg border text-left transition-colors ${g===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${p}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:S.command}),S.kind&&S.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:S.scope?`${S.scope} ${S.kind}`:S.kind}):null]}),a.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:S.description})]},S.command))})]})}const yt=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 x=k.useRef(null),[S,g]=k.useState(null);return k.useLayoutEffect(()=>{if(!e){g(null);return}const n=t.current;if(!n)return;let d=0;const h=()=>{const y=t.current;if(!y)return;const w=y.getBoundingClientRect(),E=window.innerWidth,b=window.innerHeight,R=o?260:320,j=o?E-yt*2:560,M=Math.min(Math.max(w.width,R),Math.max(R,j)),L=Math.min(Math.max(yt,w.left),Math.max(yt,E-yt-M)),T=b-w.bottom-ys-yt,B=w.top-ys-yt,I=x.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(yt,w.top-ys-Math.min(I,N)):Math.min(b-yt-Math.min(I,N),w.bottom+ys);g({top:P,left:L,width:M,maxHeight:N})},u=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(h)};u();const _=new ResizeObserver(u);return _.observe(n),x.current&&_.observe(x.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||!S||typeof document>"u"?null:Nt.createPortal(a.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:a.jsx("div",{ref:x,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:S.top,left:S.left,width:S.width,maxHeight:S.maxHeight},children:a.jsx(Xf,{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 Yf({workspaceId:e,gitStatus:t,onResolve:s}){const{t:l}=ce(),m=Mf();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(gn,{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(dt,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:l("中止操作")}),a.jsx(dt,{size:"sm",onClick:s,children:l("解决冲突")})]})]})}function Vf(e,t,s,l){const m=s.map(v=>`- ${v}`).join(`
|
|
73
73
|
`);return l===Sa.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 Gf({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:v,targetBranch:C,sessions:r}){const{t:i}=ce(),[c,f]=k.useState(""),o=Qr(),p=Vr(),x=()=>{if(!c)return;const n=Vf(v,C,m,l);o.mutate({id:c,message:n},{onSuccess:()=>t(!1)})},S=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},g=l==="REBASE"?"Rebase":"Merge";return a.jsx(Or,{isOpen:e,onClose:()=>t(!1),title:i("解决 {opLabel} 冲突",{opLabel:g}),action:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(dt,{variant:"outline",onClick:S,children:i("在 IDE 中打开")}),a.jsx(dt,{onClick:x,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 Qf({gitStatus:e,branchName:t,targetBranch:s}){const{t:l}=ce();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(xn,{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(Ha,{size:12}),l("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(gn,{size:12}),l("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(ze,{size:12,className:"animate-spin"}),l("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(ze,{size:12,className:"animate-spin"}),l("合并进行中")]}),e.ahead>0&&a.jsxs(Mt,{variant:"success",children:[a.jsx(hi,{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(hi,{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 Zf({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:v,onRefreshCommitMessage:C,onConflict:r}){const{t:i}=ce(),{data:c,isLoading:f}=ko(s),o=Lf(),p=Tf(),[x,S]=k.useState(null),[g,n]=k.useState("select"),[d,h]=k.useState(""),[u,_]=k.useState(!1),y=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;k.useEffect(()=>{e&&(n("select"),S(null),_(!1),C?.())},[e,C]),k.useEffect(()=>{!e||u||h(v??"")},[e,v,u]);const b=T=>{_(!0),h(B=>typeof T=="function"?T(B):T)},R=()=>{S(null),o.mutate(s,{onSuccess:()=>t(!1),onError:T=>{const B=T;B.status===409?(t(!1),r()):S(B.message??i("变基失败"))}})},j=()=>{S(null),n("confirm")},M=()=>{S(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()):S(I.message??i("合并失败"))}})},L=i(g==="confirm"?"确认合并":"Git 操作");return a.jsx(Or,{isOpen:e,onClose:()=>t(!1),title:L,children:f||!c?a.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[a.jsx(ze,{size:18,className:"animate-spin"}),a.jsx("span",{className:"text-sm",children:i("加载分支状态...")})]}):g==="confirm"?a.jsx(em,{editableMessage:d,setEditableMessage:b,error:x,isPending:p.isPending,onConfirm:M,onBack:()=>n("select"),branchName:l,targetBranch:m}):a.jsx(Jf,{gitStatus:c,branchName:l,targetBranch:m,error:x,isDirty:E,hasConflicts:y,isOperationInProgress:w,rebasePending:o.isPending,mergePending:p.isPending,onRebase:R,onMerge:j})})}function Jf({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}=ce();return a.jsxs("div",{className:"space-y-5",children:[a.jsx(Qf,{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(Ka,{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(En,{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 em({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:v,branchName:C,targetBranch:r}){const{t:i}=ce();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(xn,{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(ze,{size:14,className:"animate-spin"}),i("合并中...")]}):a.jsxs(a.Fragment,{children:[a.jsx(En,{size:14}),i("确认合并")]})})]})]})}function tm({agentType:e,workingDir:t}){return ht({queryKey:le.system.slashCommandCatalog(e,t),queryFn:async()=>(await fe.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function sm(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 rm(e){return Zs(e.command)}function im(e,t){if(!t)return 1e3;const s=rm(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 Yi(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 To(e,t){const s=Zs(t);return s?e.map((l,m)=>({command:l,index:m,score:im(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 nm=[{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"}],om=[{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"}],am=[{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"}],lm=[{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"}],cm={[_t.CODEX]:nm,[_t.CLAUDE_CODE]:om,[_t.GEMINI_CLI]:am,[_t.CURSOR_AGENT]:lm};function Lo(e){return e.trim().toLowerCase().replace(/^\//,"")}function hm(e){return e?(cm[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function um(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Lo(t[1]):null}function dm(e,t){return To(e,Lo(t))}function fm(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 Mo({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=tm({agentType:e,workingDir:t}),f=k.useMemo(()=>sm(hm(e),c),[e,c]),o=k.useMemo(()=>um(s),[s]),p=k.useMemo(()=>o===null?[]:dm(f,o),[f,o]),x=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 S=k.useCallback(n=>{const h=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,x,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):fm(n)?(n.preventDefault(),S(p[r]??p[0]),!0):!1,[S,p,o,r]);return{allCommands:f,query:o,filteredCommands:p,selectedIndex:r,setSelectedIndex:i,applyCommand:S,handleKeyDown:g}}function mm({agentType:e,workingDir:t}){return ht({queryKey:le.system.skillCatalog(e,t),queryFn:async()=>(await fe.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===_t.CODEX,staleTime:3e4})}function pm(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 No({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=mm({agentType:e,workingDir:t}),o=k.useMemo(()=>e===_t.CODEX?Yi(s):null,[e,s])?.query??null,p=k.useMemo(()=>o===null?[]:To(c,o),[o,c]),x=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 S=k.useCallback(n=>{const d=Yi(s);if(!d)return;const h=`${s.slice(0,d.replaceStart)}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,x,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):pm(n)?(n.preventDefault(),S(p[r]??p[0]),!0):!1,[S,p,o,r]);return{allSkills:c,query:o,filteredSkills:p,selectedIndex:r,setSelectedIndex:i,applySkill:S,handleKeyDown:g}}const vm="/api",gm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${vm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,_m=({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"})}),bm={img:_m},xm=675,Vi=320,Gi=1200;function Sm(){const{t:e}=ce();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 Qi=[{status:ae.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:a.jsx(Tr,{className:"w-3 h-3"})},{status:ae.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:a.jsx(Lr,{className:"w-3 h-3"})},{status:ae.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:a.jsx(Mr,{className:"w-3 h-3"})},{status:ae.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:a.jsx(Nr,{className:"w-3 h-3"})},{status:ae.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:a.jsx(Pr,{className:"w-3 h-3"})}];function ym({status:e,onChangeStatus:t}){const{t:s}=ce(),[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=Qi.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:Qi.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 Cm({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const{t:m}=ce(),[v,C]=k.useState(""),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[x,S]=k.useState(!1),[g,n]=k.useState(!1),[d,h]=k.useState(!1),[u,_]=k.useState(!1),[y,w]=k.useState(!1),E=k.useRef(null),b=k.useRef(null),R=k.useRef(null),j=k.useRef(null),{scrollRef:M,contentRef:L,isAtBottom:T,scrollToBottom:B}=qn({resize:"smooth",initial:"instant"}),[I,H]=k.useState(xm),[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}=wo(e?.id??""),se=Pf(e?.id);k.useEffect(()=>{w(!1)},[e?.id]),k.useEffect(()=>{if(!y||!K)return;K.some(ne=>ne.status==="ACTIVE"&&ne.sessions&&ne.sessions.length>0)&&w(!1)},[K,y]);const D=k.useMemo(()=>{if(y||!K)return null;const G=$e=>{const tr=$e.createdAt,Yt=$e.endedAt??$e.startedAt??tr;if(!Yt)return 0;const zt=Date.parse(Yt);return Number.isNaN(zt)?0:zt},ne=($e,tr)=>{const Yt=$e.filter(zt=>tr.includes(zt.status));return Yt.length===0?null:Yt.sort((zt,sa)=>G(sa)-G(zt))[0]??null},Ee=K.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),rt=ne(Ee,[Le.RUNNING])??ne(Ee,[Le.PENDING])??ne(Ee,[Le.COMPLETED,Le.FAILED,Le.CANCELLED]);if(rt)return rt;const vt=K.filter($e=>($e.status==="MERGED"||$e.status==="ABANDONED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]);return ne(vt,[Le.COMPLETED,Le.FAILED,Le.CANCELLED])},[K,y]),F=D?.id??"",U=D?.status===Le.RUNNING||D?.status===Le.PENDING,z=!!e?.projectArchivedAt,te=!!e?.projectRepoDeletedAt,Y=m(te?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ie}=Hs(),[ge,me]=k.useState(null);k.useEffect(()=>{me(D?.providerId??null)},[D?.providerId]);const Me=k.useMemo(()=>!D||!K?!1:!K.some(ne=>ne.status==="ACTIVE"&&ne.sessions?.some(Ee=>Ee.id===D.id)),[D,K]),re=k.useMemo(()=>{if(!(!K||y)){for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[K,y]),Be=Mo({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),Ce=No({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),oe=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.id:void 0,[K]),{data:Ne}=ko(oe??""),qe=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.sessions??[]:[],[K]),Re=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.branchName??"":"",[K]),Ve=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.commitMessage:void 0,[K]),be=We(),st=k.useCallback(()=>e?.id?be.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,be]);k.useEffect(()=>{if(!u)return;const G=ne=>{b.current&&!b.current.contains(ne.target)&&_(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[u]);const Ke=Qr(),Pe=Vr(),Oe=Hf(),De=Eo(e?.id??""),V=Gr(),Z=k.useCallback(async()=>{if(!e?.id)return;const G=D?.providerId??ie?.find(Ee=>Ee.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const ne=[e.title,e.description].filter(Boolean).join(`
|
|
75
|
+
`)}function Gf({open:e,onOpenChange:t,workspaceId:s,conflictOp:l,conflictedFiles:m,sourceBranch:v,targetBranch:C,sessions:r}){const{t:i}=ce(),[c,f]=k.useState(""),o=Qr(),p=Vr(),x=()=>{if(!c)return;const n=Vf(v,C,m,l);o.mutate({id:c,message:n},{onSuccess:()=>t(!1)})},S=()=>{p.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},g=l==="REBASE"?"Rebase":"Merge";return a.jsx(Or,{isOpen:e,onClose:()=>t(!1),title:i("解决 {opLabel} 冲突",{opLabel:g}),action:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(dt,{variant:"outline",onClick:S,children:i("在 IDE 中打开")}),a.jsx(dt,{onClick:x,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 Qf({gitStatus:e,branchName:t,targetBranch:s}){const{t:l}=ce();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(xn,{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(Ha,{size:12}),l("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(gn,{size:12}),l("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(ze,{size:12,className:"animate-spin"}),l("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&a.jsxs(Mt,{variant:"warning",children:[a.jsx(ze,{size:12,className:"animate-spin"}),l("合并进行中")]}),e.ahead>0&&a.jsxs(Mt,{variant:"success",children:[a.jsx(hi,{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(hi,{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 Zf({open:e,onOpenChange:t,workspaceId:s,branchName:l,targetBranch:m,commitMessage:v,onRefreshCommitMessage:C,onConflict:r}){const{t:i}=ce(),{data:c,isLoading:f}=ko(s),o=Lf(),p=Tf(),[x,S]=k.useState(null),[g,n]=k.useState("select"),[d,h]=k.useState(""),[u,_]=k.useState(!1),y=c?c.conflictedFiles.length>0:!1,w=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;k.useEffect(()=>{e&&(n("select"),S(null),_(!1),C?.())},[e,C]),k.useEffect(()=>{!e||u||h(v??"")},[e,v,u]);const b=T=>{_(!0),h(B=>typeof T=="function"?T(B):T)},R=()=>{S(null),o.mutate(s,{onSuccess:()=>t(!1),onError:T=>{const B=T;B.status===409?(t(!1),r()):S(B.message??i("变基失败"))}})},j=()=>{S(null),n("confirm")},M=()=>{S(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()):S(I.message??i("合并失败"))}})},L=i(g==="confirm"?"确认合并":"Git 操作");return a.jsx(Or,{isOpen:e,onClose:()=>t(!1),title:L,children:f||!c?a.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[a.jsx(ze,{size:18,className:"animate-spin"}),a.jsx("span",{className:"text-sm",children:i("加载分支状态...")})]}):g==="confirm"?a.jsx(em,{editableMessage:d,setEditableMessage:b,error:x,isPending:p.isPending,onConfirm:M,onBack:()=>n("select"),branchName:l,targetBranch:m}):a.jsx(Jf,{gitStatus:c,branchName:l,targetBranch:m,error:x,isDirty:E,hasConflicts:y,isOperationInProgress:w,rebasePending:o.isPending,mergePending:p.isPending,onRebase:R,onMerge:j})})}function Jf({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}=ce();return a.jsxs("div",{className:"space-y-5",children:[a.jsx(Qf,{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(Ka,{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(En,{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 em({editableMessage:e,setEditableMessage:t,error:s,isPending:l,onConfirm:m,onBack:v,branchName:C,targetBranch:r}){const{t:i}=ce();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(xn,{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(ze,{size:14,className:"animate-spin"}),i("合并中...")]}):a.jsxs(a.Fragment,{children:[a.jsx(En,{size:14}),i("确认合并")]})})]})]})}function tm({agentType:e,workingDir:t}){return ht({queryKey:ae.system.slashCommandCatalog(e,t),queryFn:async()=>(await fe.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function sm(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 rm(e){return Zs(e.command)}function im(e,t){if(!t)return 1e3;const s=rm(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 Yi(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 To(e,t){const s=Zs(t);return s?e.map((l,m)=>({command:l,index:m,score:im(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 nm=[{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"}],om=[{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"}],am=[{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"}],lm=[{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"}],cm={[_t.CODEX]:nm,[_t.CLAUDE_CODE]:om,[_t.GEMINI_CLI]:am,[_t.CURSOR_AGENT]:lm};function Lo(e){return e.trim().toLowerCase().replace(/^\//,"")}function hm(e){return e?(cm[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function um(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Lo(t[1]):null}function dm(e,t){return To(e,Lo(t))}function fm(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 Mo({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=tm({agentType:e,workingDir:t}),f=k.useMemo(()=>sm(hm(e),c),[e,c]),o=k.useMemo(()=>um(s),[s]),p=k.useMemo(()=>o===null?[]:dm(f,o),[f,o]),x=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 S=k.useCallback(n=>{const h=`${s.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,x,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):fm(n)?(n.preventDefault(),S(p[r]??p[0]),!0):!1,[S,p,o,r]);return{allCommands:f,query:o,filteredCommands:p,selectedIndex:r,setSelectedIndex:i,applyCommand:S,handleKeyDown:g}}function mm({agentType:e,workingDir:t}){return ht({queryKey:ae.system.skillCatalog(e,t),queryFn:async()=>(await fe.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===_t.CODEX,staleTime:3e4})}function pm(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 No({agentType:e,workingDir:t,input:s,setInput:l,textareaRef:m,minHeight:v,maxHeight:C}){const[r,i]=k.useState(0),{data:c=[]}=mm({agentType:e,workingDir:t}),o=k.useMemo(()=>e===_t.CODEX?Yi(s):null,[e,s])?.query??null,p=k.useMemo(()=>o===null?[]:To(c,o),[o,c]),x=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 S=k.useCallback(n=>{const d=Yi(s);if(!d)return;const h=`${s.slice(0,d.replaceStart)}${n.command} `;l(h),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(h.length,h.length))})},[s,x,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):pm(n)?(n.preventDefault(),S(p[r]??p[0]),!0):!1,[S,p,o,r]);return{allSkills:c,query:o,filteredSkills:p,selectedIndex:r,setSelectedIndex:i,applySkill:S,handleKeyDown:g}}const vm="/api",gm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${vm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,_m=({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"})}),bm={img:_m},xm=675,Vi=320,Gi=1200;function Sm(){const{t:e}=ce();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 Qi=[{status:le.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:a.jsx(Tr,{className:"w-3 h-3"})},{status:le.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:a.jsx(Lr,{className:"w-3 h-3"})},{status:le.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:a.jsx(Mr,{className:"w-3 h-3"})},{status:le.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:a.jsx(Nr,{className:"w-3 h-3"})},{status:le.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:a.jsx(Pr,{className:"w-3 h-3"})}];function ym({status:e,onChangeStatus:t}){const{t:s}=ce(),[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=Qi.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:Qi.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 Cm({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:l}){const{t:m}=ce(),[v,C]=k.useState(""),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[x,S]=k.useState(!1),[g,n]=k.useState(!1),[d,h]=k.useState(!1),[u,_]=k.useState(!1),[y,w]=k.useState(!1),E=k.useRef(null),b=k.useRef(null),R=k.useRef(null),j=k.useRef(null),{scrollRef:M,contentRef:L,isAtBottom:T,scrollToBottom:B}=qn({resize:"smooth",initial:"instant"}),[I,H]=k.useState(xm),[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}=wo(e?.id??""),se=Pf(e?.id);k.useEffect(()=>{w(!1)},[e?.id]),k.useEffect(()=>{if(!y||!K)return;K.some(ne=>ne.status==="ACTIVE"&&ne.sessions&&ne.sessions.length>0)&&w(!1)},[K,y]);const D=k.useMemo(()=>{if(y||!K)return null;const G=$e=>{const tr=$e.createdAt,Yt=$e.endedAt??$e.startedAt??tr;if(!Yt)return 0;const zt=Date.parse(Yt);return Number.isNaN(zt)?0:zt},ne=($e,tr)=>{const Yt=$e.filter(zt=>tr.includes(zt.status));return Yt.length===0?null:Yt.sort((zt,sa)=>G(sa)-G(zt))[0]??null},Ee=K.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),rt=ne(Ee,[Le.RUNNING])??ne(Ee,[Le.PENDING])??ne(Ee,[Le.COMPLETED,Le.FAILED,Le.CANCELLED]);if(rt)return rt;const vt=K.filter($e=>($e.status==="MERGED"||$e.status==="ABANDONED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]);return ne(vt,[Le.COMPLETED,Le.FAILED,Le.CANCELLED])},[K,y]),F=D?.id??"",U=D?.status===Le.RUNNING||D?.status===Le.PENDING,z=!!e?.projectArchivedAt,te=!!e?.projectRepoDeletedAt,Y=m(te?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ie}=Hs(),[ge,me]=k.useState(null);k.useEffect(()=>{me(D?.providerId??null)},[D?.providerId]);const Me=k.useMemo(()=>!D||!K?!1:!K.some(ne=>ne.status==="ACTIVE"&&ne.sessions?.some(Ee=>Ee.id===D.id)),[D,K]),re=k.useMemo(()=>{if(!(!K||y)){for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[K,y]),Be=Mo({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),Ce=No({agentType:D?.agentType,workingDir:re,input:v,setInput:C,textareaRef:R,minHeight:60,maxHeight:300}),oe=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.id:void 0,[K]),{data:Ne}=ko(oe??""),qe=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.sessions??[]:[],[K]),Re=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.branchName??"":"",[K]),Ve=k.useMemo(()=>K?K.find(ne=>ne.status==="ACTIVE")?.commitMessage:void 0,[K]),be=We(),st=k.useCallback(()=>e?.id?be.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,be]);k.useEffect(()=>{if(!u)return;const G=ne=>{b.current&&!b.current.contains(ne.target)&&_(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[u]);const Ke=Qr(),Pe=Vr(),Oe=Hf(),De=Eo(e?.id??""),V=Gr(),Z=k.useCallback(async()=>{if(!e?.id)return;const G=D?.providerId??ie?.find(Ee=>Ee.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const ne=[e.title,e.description].filter(Boolean).join(`
|
|
76
76
|
|
|
77
|
-
`);p(!1),S(!0);try{await Oe.mutateAsync(e.id),w(!0);const Ee=await De.mutateAsync({}),rt=await fe.post(`/workspaces/${Ee.id}/sessions`,{providerId:G,prompt:ne});await V.mutateAsync(rt.id),await be.invalidateQueries({queryKey:
|
|
77
|
+
`);p(!1),S(!0);try{await Oe.mutateAsync(e.id),w(!0);const Ee=await De.mutateAsync({}),rt=await fe.post(`/workspaces/${Ee.id}/sessions`,{providerId:G,prompt:ne});await V.mutateAsync(rt.id),await be.invalidateQueries({queryKey:ae.workspaces.list(e.id)})}catch(Ee){console.error("[retry] failed:",Ee),w(!1)}finally{S(!1)}},[e?.id,e?.title,e?.description,D?.providerId,ie,Oe,De,V,be]),xe=k.useCallback(()=>{oe&&Pe.mutate({workspaceId:oe})},[oe,Pe]),Se=k.useCallback(()=>{!e?.id||!t||(t(e.id),f(!1))},[e?.id,t]),{isConnected:He,isLoadingSnapshot:Xe,logs:pe,entries:et,attach:Ge}=hn({sessionId:F,onExit:k.useCallback(()=>{be.invalidateQueries({queryKey:["workspaces"]})},[be])});k.useEffect(()=>{if(!e?.id)return;const G=wt.connect();G.emit(Pt.SUBSCRIBE,{topic:"task",id:e.id});const ne=rt=>{rt.taskId===e.id&&be.invalidateQueries({queryKey:["tasks"]})},Ee=rt=>{rt.taskId===e.id&&be.invalidateQueries({queryKey:ae.workspaces.list(e.id)})};return G.on(Qe.TASK_UPDATED,ne),G.on(Qe.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ee),()=>{G.off(Qe.TASK_UPDATED,ne),G.off(Qe.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ee),G.emit(Pt.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,be]),k.useEffect(()=>{if(!F)return;const G=wt.connect(),ne=Ee=>{Ee.sessionId===F&&be.invalidateQueries({queryKey:["workspaces"]})};return G.on(Qe.SESSION_COMPLETED,ne),()=>{G.off(Qe.SESSION_COMPLETED,ne)}},[F,be]);const{todos:nt}=un(et),{files:Ht,addFiles:je,removeFile:q,clear:J,buildMarkdownLinks:he,hasFiles:ue,isUploading:ve}=Zr(),Ae=k.useMemo(()=>{if(!D?.tokenUsage)return;const G=D.tokenUsage;if(typeof G.totalTokens=="number")return G},[D?.tokenUsage]),mt=Do(pe,Ae);k.useEffect(()=>{F&&He&&Ge()},[F,He,Ge]);const Fe=k.useRef(e?.id);k.useEffect(()=>{Fe.current!==e?.id&&B(),Fe.current=e?.id},[e?.id,B]);const ot=Ro(),tt=k.useRef(!1),at=k.useCallback(async()=>{if(!v.trim()&&!ue||!F||tt.current||ve)return;tt.current=!0;const G=he(),ne=[v.trim(),G].filter(Boolean).join(`
|
|
78
78
|
|
|
79
|
-
`);C(""),J(),R.current&&(R.current.style.height="60px"),Ke.mutate({id:F,message:ne,providerId:ge??void 0},{onSuccess:()=>{Ge()},onSettled:()=>{tt.current=!1}})},[v,F,Ke,Ge,ue,ve,he,J,ge]),jt=k.useCallback(async()=>{F&&(await ot.mutateAsync(F),be.invalidateQueries({queryKey:["workspaces"]}))},[F,ot,be]),Tt=k.useCallback(G=>{const ne=G.target.files;ne&&ne.length>0&&je(Array.from(ne)),G.target.value=""},[je]),pt=k.useCallback(G=>{const ne=G.clipboardData.items,Ee=[];for(const rt of ne)if(rt.kind==="file"){const vt=rt.getAsFile();vt&&Ee.push(vt)}Ee.length>0&&(G.preventDefault(),je(Ee))},[je]),[St,Lt]=k.useState(!1),Go=k.useCallback(G=>{G.preventDefault(),Lt(!0)},[]),Qo=k.useCallback(G=>{G.preventDefault(),Lt(!1)},[]),Zo=k.useCallback(G=>{G.preventDefault(),Lt(!1);const ne=G.dataTransfer.files;ne.length>0&&je(Array.from(ne))},[je]),Js=k.useCallback(G=>{const ne=G.clientX-O.current,Ee=Math.max(Vi,Math.min($.current+ne,Gi));X.current&&(X.current.style.width=`${Ee}px`)},[]),er=k.useCallback(()=>{if(P(!1),X.current){const G=X.current.getBoundingClientRect().width;H(Math.max(Vi,Math.min(Math.round(G),Gi)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);k.useEffect(()=>{if(N)return document.addEventListener("mousemove",Js),document.addEventListener("mouseup",er),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Js),document.removeEventListener("mouseup",er),document.body.style.cursor="",document.body.style.userSelect=""}},[N,Js,er]);const Jo=k.useCallback(G=>{G.preventDefault(),O.current=G.clientX,$.current=I,P(!0)},[I]),ea=k.useCallback(()=>{A(G=>!G)},[]),ta=k.useCallback(G=>{C(G.target.value);const ne=G.target;ne.style.height="auto";const Ee=ne.scrollHeight;ne.style.height=`${Math.max(60,Math.min(Ee,300))}px`},[]),ei=k.useMemo(()=>{const G=[];if(K&&K.length>0){const ne=K.some(vt=>vt.status==="ACTIVE"),Ee=K.some(vt=>vt.sessions?.some($e=>$e.status===Le.RUNNING||$e.status===Le.PENDING)),rt=K.some(vt=>vt.status==="ACTIVE");Ee&&G.push(m("正在运行的 Agent 将被停止")),rt&&G.push(m("分支上未合并的变更将丢失")),ne&&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(ym,{status:e.status,onChangeStatus:!z&&l?G=>l(e.id,G):void 0}),oe&&!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(Ya,{size:18})}),a.jsx("button",{onClick:xe,disabled:!oe||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:ea,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(cl,{size:18}):a.jsx(ul,{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(yn,{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(wa,{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(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})]})]})]})]}),oe&&Ne&&a.jsx(Yf,{workspaceId:oe,gitStatus:Ne,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:M,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:a.jsxs("div",{ref:L,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(dn,{urlTransform:gm,components:bm,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?Xe?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...")})]}):pe.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(fn,{logs:pe}):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?Y:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!z&&a.jsxs(dt,{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(bn,{size:14}),a.jsx("span",{children:m("回到底部")})]})]}),nt.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(mn,{todos:nt})}),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:Y})}):Me?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(dt,{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:Go,onDragLeave:Qo,onDrop:Zo,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 ${St?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[a.jsx(Ns,{files:Ht,onRemove:q}),a.jsx("textarea",{ref:R,value:v,onChange:ta,onPaste:pt,onKeyDown:G=>{Ce.handleKeyDown(G)||Be.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),at())},rows:1,placeholder:m(St?"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:Tt}),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&&ie&&a.jsx(jo,{providers:ie,currentProviderId:ge,agentType:D.agentType,onSelect:me}),a.jsx(Kn,{usage:mt}),U&&!v.trim()&&!ue?a.jsx("button",{onClick:jt,disabled:ot.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(pn,{size:14})}):a.jsx("button",{onClick:at,disabled:!v.trim()&&!ue||ve,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||ue)&&!ve?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:a.jsx(Sn,{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:Ce.query!==null,anchorRef:E,commands:Ce.filteredSkills,selectedIndex:Ce.selectedIndex,query:Ce.query??"",hasCatalog:Ce.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ce.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:Jo}),W&&a.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:a.jsx(Co,{sessionId:F||void 0,workingDir:re,projectId:e.projectId,readOnly:z,repoDeleted:te})})]}),!z&&a.jsx(Ao,{isOpen:r,onClose:()=>i(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),oe&&!z&&a.jsx(Zf,{open:d,onOpenChange:h,workspaceId:oe,branchName:Re,targetBranch:e.mainBranch,commitMessage:Ve,onRefreshCommitMessage:st,onConflict:()=>n(!0)}),oe&&Ne&&Ne.conflictOp&&a.jsx(Gf,{open:g,onOpenChange:n,workspaceId:oe,conflictOp:Ne.conflictOp,conflictedFiles:Ne.conflictedFiles,sourceBranch:Re,targetBranch:e.mainBranch,sessions:qe}),a.jsx(xr,{isOpen:o,onClose:()=>p(!1),onConfirm:Z,title:m("重新开始任务"),description:a.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:x}),a.jsx(xr,{isOpen:c,onClose:()=>f(!1),onConfirm:Se,title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),ei.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:ei.map((G,ne)=>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})]},ne))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):a.jsx(Sm,{})}function Jr(e){switch(e){case gt.TODO:return ae.Pending;case gt.IN_PROGRESS:return ae.Running;case gt.IN_REVIEW:return ae.Review;case gt.DONE:return ae.Done;case gt.CANCELLED:return ae.Cancelled}}function wm(e){switch(e){case ae.Pending:return gt.TODO;case ae.Running:return gt.IN_PROGRESS;case ae.Review:return gt.IN_REVIEW;case ae.Done:return gt.DONE;case ae.Cancelled:return gt.CANCELLED}}function Em(e){switch(e){case _t.CLAUDE_CODE:return"Claude Code";case _t.GEMINI_CLI:return"Gemini CLI";case _t.CURSOR_AGENT:return"Cursor Agent";case _t.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 Po(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 Oo(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function km(e){return{id:e.id,name:e.name,color:e.color||Os[Po(e.name,Os.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Rm(e){const t=Oo(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:Em(m.agentType),branch:s}}return{agent:"—",branch:s}}function Dm(e){const{agent:t,branch:s}=Rm(e.workspaces),l=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Jr(e.status),agent:t,branch:s,description:e.description??"",projectArchivedAt:l?.archivedAt??null,projectRepoDeletedAt:l?.repoDeletedAt??null}}function Am(e,t,s){const l=Oo(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Os[Po(t.name,Os.length)],title:e.title,status:Jr(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const Bo=768;function jm(e){const t=window.matchMedia(`(max-width: ${Bo-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Tm(){return window.innerWidth<Bo}function Lm(){return!1}function Mm(){return k.useSyncExternalStore(jm,Tm,Lm)}const Zi={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 Nm(e){const t=e.split("/");return t[t.length-1]||e}function Pm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Om({workingDir:e,filePath:t,type:s}){const{t:l}=ce(),{data:m,isLoading:v,isError:C}=xo(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(ze,{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(`
|
|
79
|
+
`);C(""),J(),R.current&&(R.current.style.height="60px"),Ke.mutate({id:F,message:ne,providerId:ge??void 0},{onSuccess:()=>{Ge()},onSettled:()=>{tt.current=!1}})},[v,F,Ke,Ge,ue,ve,he,J,ge]),jt=k.useCallback(async()=>{F&&(await ot.mutateAsync(F),be.invalidateQueries({queryKey:["workspaces"]}))},[F,ot,be]),Tt=k.useCallback(G=>{const ne=G.target.files;ne&&ne.length>0&&je(Array.from(ne)),G.target.value=""},[je]),pt=k.useCallback(G=>{const ne=G.clipboardData.items,Ee=[];for(const rt of ne)if(rt.kind==="file"){const vt=rt.getAsFile();vt&&Ee.push(vt)}Ee.length>0&&(G.preventDefault(),je(Ee))},[je]),[St,Lt]=k.useState(!1),Go=k.useCallback(G=>{G.preventDefault(),Lt(!0)},[]),Qo=k.useCallback(G=>{G.preventDefault(),Lt(!1)},[]),Zo=k.useCallback(G=>{G.preventDefault(),Lt(!1);const ne=G.dataTransfer.files;ne.length>0&&je(Array.from(ne))},[je]),Js=k.useCallback(G=>{const ne=G.clientX-O.current,Ee=Math.max(Vi,Math.min($.current+ne,Gi));X.current&&(X.current.style.width=`${Ee}px`)},[]),er=k.useCallback(()=>{if(P(!1),X.current){const G=X.current.getBoundingClientRect().width;H(Math.max(Vi,Math.min(Math.round(G),Gi)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);k.useEffect(()=>{if(N)return document.addEventListener("mousemove",Js),document.addEventListener("mouseup",er),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Js),document.removeEventListener("mouseup",er),document.body.style.cursor="",document.body.style.userSelect=""}},[N,Js,er]);const Jo=k.useCallback(G=>{G.preventDefault(),O.current=G.clientX,$.current=I,P(!0)},[I]),ea=k.useCallback(()=>{A(G=>!G)},[]),ta=k.useCallback(G=>{C(G.target.value);const ne=G.target;ne.style.height="auto";const Ee=ne.scrollHeight;ne.style.height=`${Math.max(60,Math.min(Ee,300))}px`},[]),ei=k.useMemo(()=>{const G=[];if(K&&K.length>0){const ne=K.some(vt=>vt.status==="ACTIVE"),Ee=K.some(vt=>vt.sessions?.some($e=>$e.status===Le.RUNNING||$e.status===Le.PENDING)),rt=K.some(vt=>vt.status==="ACTIVE");Ee&&G.push(m("正在运行的 Agent 将被停止")),rt&&G.push(m("分支上未合并的变更将丢失")),ne&&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(ym,{status:e.status,onChangeStatus:!z&&l?G=>l(e.id,G):void 0}),oe&&!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(Ya,{size:18})}),a.jsx("button",{onClick:xe,disabled:!oe||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:ea,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(cl,{size:18}):a.jsx(ul,{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(yn,{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(wa,{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(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})]})]})]})]}),oe&&Ne&&a.jsx(Yf,{workspaceId:oe,gitStatus:Ne,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:M,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:a.jsxs("div",{ref:L,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(dn,{urlTransform:gm,components:bm,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?Xe?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...")})]}):pe.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(fn,{logs:pe}):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?Y:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!z&&a.jsxs(dt,{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(bn,{size:14}),a.jsx("span",{children:m("回到底部")})]})]}),nt.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(mn,{todos:nt})}),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:Y})}):Me?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(dt,{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:Go,onDragLeave:Qo,onDrop:Zo,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 ${St?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[a.jsx(Ns,{files:Ht,onRemove:q}),a.jsx("textarea",{ref:R,value:v,onChange:ta,onPaste:pt,onKeyDown:G=>{Ce.handleKeyDown(G)||Be.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),at())},rows:1,placeholder:m(St?"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:Tt}),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&&ie&&a.jsx(jo,{providers:ie,currentProviderId:ge,agentType:D.agentType,onSelect:me}),a.jsx(Kn,{usage:mt}),U&&!v.trim()&&!ue?a.jsx("button",{onClick:jt,disabled:ot.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(pn,{size:14})}):a.jsx("button",{onClick:at,disabled:!v.trim()&&!ue||ve,className:`p-2 rounded-lg transition-all duration-200 ${(v.trim()||ue)&&!ve?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:a.jsx(Sn,{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:Ce.query!==null,anchorRef:E,commands:Ce.filteredSkills,selectedIndex:Ce.selectedIndex,query:Ce.query??"",hasCatalog:Ce.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ce.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:Jo}),W&&a.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:a.jsx(Co,{sessionId:F||void 0,workingDir:re,projectId:e.projectId,readOnly:z,repoDeleted:te})})]}),!z&&a.jsx(Ao,{isOpen:r,onClose:()=>i(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),oe&&!z&&a.jsx(Zf,{open:d,onOpenChange:h,workspaceId:oe,branchName:Re,targetBranch:e.mainBranch,commitMessage:Ve,onRefreshCommitMessage:st,onConflict:()=>n(!0)}),oe&&Ne&&Ne.conflictOp&&a.jsx(Gf,{open:g,onOpenChange:n,workspaceId:oe,conflictOp:Ne.conflictOp,conflictedFiles:Ne.conflictedFiles,sourceBranch:Re,targetBranch:e.mainBranch,sessions:qe}),a.jsx(xr,{isOpen:o,onClose:()=>p(!1),onConfirm:Z,title:m("重新开始任务"),description:a.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:x}),a.jsx(xr,{isOpen:c,onClose:()=>f(!1),onConfirm:Se,title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),ei.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:ei.map((G,ne)=>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})]},ne))})]}),confirmText:m("删除"),variant:"danger",isLoading:s})]}):a.jsx(Sm,{})}function Jr(e){switch(e){case gt.TODO:return le.Pending;case gt.IN_PROGRESS:return le.Running;case gt.IN_REVIEW:return le.Review;case gt.DONE:return le.Done;case gt.CANCELLED:return le.Cancelled}}function wm(e){switch(e){case le.Pending:return gt.TODO;case le.Running:return gt.IN_PROGRESS;case le.Review:return gt.IN_REVIEW;case le.Done:return gt.DONE;case le.Cancelled:return gt.CANCELLED}}function Em(e){switch(e){case _t.CLAUDE_CODE:return"Claude Code";case _t.GEMINI_CLI:return"Gemini CLI";case _t.CURSOR_AGENT:return"Cursor Agent";case _t.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 Po(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 Oo(e,t){return t??e?.find(s=>s.status==="ACTIVE")??e?.[0]}function km(e){return{id:e.id,name:e.name,color:e.color||Os[Po(e.name,Os.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Rm(e){const t=Oo(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:Em(m.agentType),branch:s}}return{agent:"—",branch:s}}function Dm(e){const{agent:t,branch:s}=Rm(e.workspaces),l=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Jr(e.status),agent:t,branch:s,description:e.description??"",projectArchivedAt:l?.archivedAt??null,projectRepoDeletedAt:l?.repoDeletedAt??null}}function Am(e,t,s){const l=Oo(e.workspaces,s),m=l?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||Os[Po(t.name,Os.length)],title:e.title,status:Jr(e.status),branch:m,mainBranch:l?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const Bo=768;function jm(e){const t=window.matchMedia(`(max-width: ${Bo-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Tm(){return window.innerWidth<Bo}function Lm(){return!1}function Mm(){return k.useSyncExternalStore(jm,Tm,Lm)}const Zi={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 Nm(e){const t=e.split("/");return t[t.length-1]||e}function Pm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Om({workingDir:e,filePath:t,type:s}){const{t:l}=ce(),{data:m,isLoading:v,isError:C}=xo(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(ze,{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
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:ye("px-3 whitespace-pre",o,p),children:c},f)})})}function Bm({entry:e,type:t,workingDir:s}){const[l,m]=k.useState(!1),v=Zi[e.status]||Zi.M,C=Pm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:ye("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:ye("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:Nm(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(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Om,{workingDir:s,filePath:e.path,type:t})]})}function Ji({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=ce(),[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(xt,{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(Bm,{entry:i,type:s,workingDir:l},`${s}:${i.path}`))})]})}function Im({workingDir:e}){const{t}=ce(),{data:s,isLoading:l,isError:m}=bo(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(ze,{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(Ji,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(Ji,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const vr=50,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 Fm(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Et("{count}s ago",{count:s}):s<3600?Et("{count}m ago",{count:Math.floor(s/60)}):s<86400?Et("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Et("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Hm(e){const t=e.split("/");return t[t.length-1]||e}function zm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Wm({workingDir:e,hash:t,filePath:s}){const{t:l}=ce(),{data:m,isLoading:v,isError:C}=yo(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(ze,{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:ye("px-3 whitespace-pre",o,p),children:c},f)})})}function $m({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=zm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:ye("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:ye("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:Hm(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(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Wm,{workingDir:t,hash:s,filePath:e.path})]})}function Um({commit:e,workingDir:t}){const{t:s}=ce(),[l,m]=k.useState(!1),{data:v,isLoading:C}=So(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:ye("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:ye("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:Fm(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(xt,{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(ze,{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($m,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function qm({workingDir:e}){const{t}=ce(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=_n({queryKey:
|
|
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:ye("px-3 whitespace-pre",o,p),children:c},f)})})}function $m({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=zm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:ye("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:ye("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:Hm(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(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Wm,{workingDir:t,hash:s,filePath:e.path})]})}function Um({commit:e,workingDir:t}){const{t:s}=ce(),[l,m]=k.useState(!1),{data:v,isLoading:C}=So(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:ye("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:ye("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:Fm(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(xt,{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(ze,{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($m,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function qm({workingDir:e}){const{t}=ce(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=_n({queryKey:ae.git.log(e||""),queryFn:({pageParam:c=0})=>fe.get("/git/log",{params:{workingDir:e||"",limit:String(vr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<vr?void 0:f.length*vr,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(ze,{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(qt,{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(Um,{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(ze,{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 Km="/api",Xm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Km}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ym=({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"})}),Vm={img:Ym};function Gm({status:e}){const t={[le.Running]:"bg-blue-500",[le.Review]:"bg-amber-500",[le.Pending]:"bg-neutral-400",[le.Done]:"bg-emerald-500",[le.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Qm=[{key:"chat",label:"Chat",icon:rl},{key:"changes",label:"Changes",icon:is},{key:"history",label:"History",icon:qt},{key:"workspace",label:"Workspace",icon:wn}];function Zm({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=ce(),[v,C]=k.useState("chat"),[r,i]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[x,S]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:y,scrollToBottom:w}=qn({resize:"smooth",initial:"instant"}),E=We();k.useEffect(()=>{if(!x)return;const V=Z=>{n.current&&!n.current.contains(Z.target)&&S(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[x]);const{data:b,isLoading:R}=wo(e.id),j=k.useMemo(()=>{if(!b)return null;const V=b.filter(pe=>pe.status==="ACTIVE"&&Array.isArray(pe.sessions)).flatMap(pe=>pe.sessions??[]),Z=pe=>{const et=pe.createdAt,Ge=pe.endedAt??pe.startedAt??et;if(!Ge)return 0;const nt=Date.parse(Ge);return Number.isNaN(nt)?0:nt},xe=pe=>{const et=V.filter(Ge=>pe.includes(Ge.status));return et.length===0?null:et.sort((Ge,nt)=>Z(nt)-Z(Ge))[0]??null},Se=xe([Le.RUNNING])??xe([Le.PENDING])??xe([Le.COMPLETED,Le.FAILED,Le.CANCELLED]);if(Se)return Se;const Xe=b.filter(pe=>(pe.status==="ABANDONED"||pe.status==="MERGED")&&Array.isArray(pe.sessions)).flatMap(pe=>pe.sessions??[]).filter(pe=>[Le.COMPLETED,Le.FAILED,Le.CANCELLED].includes(pe.status));return Xe.length===0?null:Xe.sort((pe,et)=>Z(et)-Z(pe))[0]??null},[b]),M=j?.id??"",L=j?.status===Le.RUNNING||j?.status===Le.PENDING,T=!!e.projectArchivedAt,B=!!e.projectRepoDeletedAt,I=m(B?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),H=k.useMemo(()=>!j||!b?!1:!b.some(Z=>Z.status==="ACTIVE"&&Z.sessions?.some(xe=>xe.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 V of b)if(V.status==="ACTIVE"&&V.worktreePath)return V.worktreePath;return b[0]?.worktreePath}},[b]),O=Mo({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),$=No({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),X=k.useMemo(()=>{if(b)return b.find(V=>V.status==="ACTIVE")?.id},[b]),K=k.useMemo(()=>{const V=[];if(b&&b.length>0){const Z=b.some(Se=>Se.status==="ACTIVE");b.some(Se=>Se.sessions?.some(He=>He.status===Le.RUNNING||He.status===Le.PENDING))&&V.push(m("正在运行的 Agent 将被停止")),Z&&(V.push(m("分支上未合并的变更将丢失")),V.push(m("关联的工作目录(worktree)将被清理")))}return V},[b,m]),Q=Qr(),se=Vr(),D=Ro(),{isConnected:F,isLoadingSnapshot:U,logs:z,entries:te,attach:Y}=hn({sessionId:M,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:ie}=un(te),{files:ge,addFiles:me,removeFile:Me,clear:re,buildMarkdownLinks:Be,hasFiles:Ce,isUploading:oe}=Zr(),Ne=k.useMemo(()=>{if(!j?.tokenUsage)return;const V=j.tokenUsage;if(typeof V.totalTokens=="number")return V},[j?.tokenUsage]),qe=Do(z,Ne);k.useEffect(()=>{M&&F&&Y()},[M,F,Y]),k.useEffect(()=>{w()},[e.id,w]);const Re=k.useRef(!1),Ve=k.useCallback(async()=>{if(!r.trim()&&!Ce||!M||Re.current||oe)return;Re.current=!0;const V=Be(),Z=[r.trim(),V].filter(Boolean).join(`
|
|
82
82
|
|
|
83
|
-
`);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:M,message:Z,providerId:A??void 0},{onSuccess:()=>Y(),onSettled:()=>{Re.current=!1}})},[r,M,Q,Y,Ce,oe,Be,re,A]),be=k.useCallback(async()=>{M&&(await D.mutateAsync(M),E.invalidateQueries({queryKey:["workspaces"]}))},[M,D,E]),st=k.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&me(Array.from(Z)),V.target.value=""},[me]),Ke=k.useCallback(V=>{const Z=V.clipboardData.items,xe=[];for(const Se of Z)if(Se.kind==="file"){const He=Se.getAsFile();He&&xe.push(He)}xe.length>0&&(V.preventDefault(),me(xe))},[me]),Pe=k.useCallback(V=>{i(V.target.value);const Z=V.target;Z.style.height="auto",Z.style.height=`${Math.max(40,Math.min(Z.scrollHeight,140))}px`},[]),Oe=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),De=k.useRef(null);return k.useEffect(()=>{const V=window.visualViewport;if(!V)return;let Z=!1;const xe=()=>{De.current&&(De.current.style.height=`${V.height}px`,De.current.style.top=`${V.offsetTop}px`)},Se=()=>xe(),He=()=>{Z||xe()},Xe=()=>{Z=!0},pe=()=>{Z=!1,requestAnimationFrame(xe)};return V.addEventListener("resize",Se),V.addEventListener("scroll",He),document.addEventListener("touchstart",Xe,{passive:!0}),document.addEventListener("touchend",pe,{passive:!0}),document.addEventListener("touchcancel",pe,{passive:!0}),()=>{V.removeEventListener("resize",Se),V.removeEventListener("scroll",He),document.removeEventListener("touchstart",Xe),document.removeEventListener("touchend",pe),document.removeEventListener("touchcancel",pe)}},[]),k.useEffect(()=>{const V=De.current;if(!V)return;const Z=xe=>{let Se=xe.target;for(;Se&&Se!==V;){if(Se.tagName==="TEXTAREA"){if(Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement;continue}const Xe=window.getComputedStyle(Se).overflowY;if((Xe==="auto"||Xe==="scroll")&&Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement}xe.preventDefault()};return V.addEventListener("touchmove",Z,{passive:!1}),()=>V.removeEventListener("touchmove",Z)},[]),a.jsxs("div",{ref:De,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(_a,{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(Gm,{status:e.status}),a.jsx("button",{onClick:Oe,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:()=>S(V=>!V),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(yn,{size:16})}),x&&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),S(!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(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:Qm.map(({key:V,label:Z,icon:xe})=>a.jsxs("button",{onClick:()=>C(V),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===V?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(xe,{size:13}),a.jsx("span",{children:Z})]},V))})]}),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(dn,{urlTransform:Xm,components:Vm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(tn,{label:"Loading..."}):M?U?a.jsx(tn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:L?"Waiting for agent output...":"No logs recorded."}):a.jsx(fn,{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(dt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!y&&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(bn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ie.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(mn,{todos:ie,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(dt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):M&&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:ge,onRemove:Me}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ke,onKeyDown:V=>{$.handleKeyDown(V)||O.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),Ve())},rows:1,placeholder:L?"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:st}),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(jo,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Kn,{usage:qe}),L&&!r.trim()&&!Ce?a.jsx("button",{onClick:be,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(pn,{size:12})}):a.jsx("button",{onClick:Ve,disabled:!r.trim()&&!Ce||oe,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||Ce)&&!oe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Sn,{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(Im,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(qm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Co,{sessionId:M||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Ao,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(xr,{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((V,Z)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:V})]},Z))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function tn({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 Jm=Object.defineProperty,Bs=Object.getOwnPropertySymbols,Io=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,sn=(e,t,s)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dr=(e,t)=>{for(var s in t||(t={}))Io.call(t,s)&&sn(e,s,t[s]);if(Bs)for(var s of Bs(t))Fo.call(t,s)&&sn(e,s,t[s]);return e},Ar=(e,t)=>{var s={};for(var l in e)Io.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&&Fo.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 S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(f);if(this.drawCodewords(x),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(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,x=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=f;;S++){const u=de.getNumDataCodewords(S,c)*8,_=C.getTotalBits(i,S);if(_<=u){g=_;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])x&&g<=de.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(S,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let 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,x=Math.floor(f/3);this.setFunctionModule(p,x,o),this.setFunctionModule(x,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)),x=i+o,S=c+f;0<=x&&x<this.size&&0<=S&&S<this.size&&this.setFunctionModule(x,S,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],x=Math.floor(de.getNumRawDataModules(c)/8),S=o-x%o,g=Math.floor(x/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let y=i.slice(_,_+g-p+(u<S?0:1));_+=y.length;const w=de.reedSolomonComputeRemainder(y,d);u<S&&y.push(0),n.push(y.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,y)=>{(u!=g-p||y>=S)&&h.push(_[u])});return m(h.length==x),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 x=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][x]&&c<i.length*8&&(this.modules[g][x]=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 x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let x=0;x<this.size-1;x++){const S=this.modules[p][x];S==this.modules[p][x+1]&&S==this.modules[p+1][x]&&S==this.modules[p+1][x+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((x,S)=>x+(S?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),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((x,S)=>f[S]^=de.reedSolomonMultiply(x,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 Ie{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 Ie(Ie.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ie.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 Ie(Ie.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ie.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=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Ie(Ie.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ie.isNumeric(i)?[Ie.makeNumeric(i)]:Ie.isAlphanumeric(i)?[Ie.makeAlphanumeric(i)]:[Ie.makeBytes(Ie.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 Ie(Ie.Mode.ECI,0,c)}static isNumeric(i){return Ie.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ie.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 $t=It;var ep={L:$t.QrCode.Ecc.LOW,M:$t.QrCode.Ecc.MEDIUM,Q:$t.QrCode.Ecc.QUARTILE,H:$t.QrCode.Ecc.HIGH},Ho=128,zo="L",Wo="#FFFFFF",$o="#000000",Uo=!1,qo=1,tp=4,sp=0,rp=.1;function Ko(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 Xo(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 ip(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*rp),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 S=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-S),d=Math.ceil(i+f-g);p={x:S,y:g,w:n,h:d}}const x=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:x}}function np(e,t){return t!=null?Math.max(Math.floor(t),0):e?tp:sp}function Yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...$t.QrSegment.makeSegments(n)),g),[]);return $t.QrCode.encodeSegments(S,ep[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let x=i.getModules();const S=np(l,m),g=x.length+S*2,n=ip(x,C,S,v);return{cells:x,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var op=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ap=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,marginSize:p,imageSettings:x}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=Ar(g,["style"]),h=x?.src,u=ee.useRef(null),_=ee.useRef(null),y=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=ee.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:M}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:x,size:v});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=M!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&M.excavation!=null&&(H=Xo(R,M.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,op?I.fill(new Path2D(Ko(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),M&&(I.globalAlpha=M.opacity),A&&I.drawImage(W,M.x+b,M.y+b,M.w,M.h)}}),ee.useEffect(()=>{E(!1)},[h]);const L=Dr({height:v,width:v},n);let T=null;return h!=null&&(T=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:M?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",Dr({style:L,height:v,width:v,ref:y,role:"img"},d)),T)});ap.displayName="QRCodeCanvas";var Vo=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,title:p,marginSize:x,imageSettings:S}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:x,imageSettings:S,size:v});let _=d,y=null;S!=null&&u!=null&&(u.excavation!=null&&(_=Xo(d,u.excavation)),y=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Ko(_,n);return ee.createElement("svg",Dr({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),y)});Vo.displayName="QRCodeSVG";function lp(){return ht({queryKey:le.tunnel.status,queryFn:()=>fe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function cp(){const e=We();return Ze({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return fe.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function hp(){const e=We();return Ze({mutationFn:()=>fe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function rn(){const{t:e}=ce(),{data:t}=lp(),s=cp(),l=hp(),[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),x=t?.running??!1,S=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const y=i.current.getBoundingClientRect();f({top:y.bottom+8,right:window.innerWidth-y.right})}},[m]);const d=k.useCallback(()=>{x?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[x,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:S,className:`p-1.5 rounded-md transition-colors ${x?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(x?"Tunnel active":"Share via tunnel"),children:S?a.jsx(ze,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),x&&!S&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&x&&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(vl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Vo,{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:y=>y.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(ui,{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(ui,{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 nn={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>cn(()=>import("./modal-hQOddjel.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),gr=k.lazy(()=>cn(()=>import("./folder-picker-CzSKXweo.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),on=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"})]}),an=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),up=260,dp=600,ln=400;function Rp(){const{t:e}=ce(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(ln),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[x,S]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[y,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:M,clear:L,buildMarkdownLinks:T,isUploading:B}=Zr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(ln),N=k.useRef(null),P=We(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=ba(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(km),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Of(D??""),z=Da({queries:D?[]:Q.map(q=>({queryKey:le.tasks.list(q.id),queryFn:()=>fe.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),te=!D&&z.some(q=>q.isLoading),Y=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const J of z)J.data?.data&&q.push(...J.data.data);return q},[D,F,z]),ie=t&&Y.some(q=>q.id===t)?t:null,ge=k.useMemo(()=>{const q=new Map;for(const J of Y){const he=J.createdAt?new Date(J.createdAt).getTime():0,ue=q.get(J.projectId)??0;he>ue&&q.set(J.projectId,he)}return[...Q].sort((J,he)=>{const ue=q.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(q.get(he.id)??(he.createdAt?new Date(he.createdAt).getTime():0))-ue})},[Q,Y]),me=k.useMemo(()=>ge.filter(q=>!q.archivedAt),[ge]),Me=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),J=q?JSON.parse(q):{};return[...O].sort((he,ue)=>{const ve=he.availability.type!=="NOT_FOUND",Ae=ue.availability.type!=="NOT_FOUND";if(ve!==Ae)return ve?-1:1;const mt=J[he.provider.id]??0;return(J[ue.provider.id]??0)-mt})},[O]),re=k.useMemo(()=>Y.map(Dm),[Y]),Be=k.useMemo(()=>new Set,[]),Ce=k.useMemo(()=>{if(!ie)return null;const q=Y.find(he=>he.id===ie);if(!q)return null;const J=Q.find(he=>he.id===q.projectId);if(!J){const he=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Jr(q.status),branch:he,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Am(q,J)},[ie,Y,Q]),oe=xa(),Ne=Bf(u),qe=Ff(),Re=If(),Ve=k.useCallback(q=>{qe.mutate(q,{onSuccess:()=>{ie===q&&s(null),P.invalidateQueries({queryKey:le.tasks.all})}})},[qe,ie,P]),be=k.useCallback((q,J)=>{Re.mutate({id:q,status:wm(J)},{onError:()=>{ni.error(e("状态变更失败,该操作不被允许"))}})},[Re,e]),st=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=he=>{if(!H.current)return;const ue=he.clientX-W.current,ve=Math.max(up,Math.min(dp,A.current+ue));C(ve)},J=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",J)}},[]);const Ke=k.useCallback(()=>{i(!0)},[]),Pe=k.useCallback(()=>{if(me.length===0){ni.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),J=localStorage.getItem("lastSelectedProviderId"),he=q&&me.find(Ae=>Ae.id===q)?q:(D&&me.find(Ae=>Ae.id===D)?.id)??me[0]?.id??"";_(he);const ue=Me?.find(Ae=>Ae.availability.type!=="NOT_FOUND"),ve=J&&Me?.find(Ae=>Ae.provider.id===J&&Ae.availability.type!=="NOT_FOUND")?J:ue?.provider.id??"";w(ve),b("idle"),f(!0)},[me,D,Me,e]),Oe=k.useCallback(()=>{i(!1),p(""),S("")},[]),De=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),L())},[E,L]),V=k.useCallback(async()=>{if(!(!o.trim()||!x.trim()))try{await oe.mutateAsync({name:o.trim(),repoPath:x.trim()}),Oe()}catch{}},[o,x,oe,Oe]),Z=Gr(),xe=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),J=[d.trim(),q].filter(Boolean).join(`
|
|
83
|
+
`);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:M,message:Z,providerId:A??void 0},{onSuccess:()=>Y(),onSettled:()=>{Re.current=!1}})},[r,M,Q,Y,Ce,oe,Be,re,A]),be=k.useCallback(async()=>{M&&(await D.mutateAsync(M),E.invalidateQueries({queryKey:["workspaces"]}))},[M,D,E]),st=k.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&me(Array.from(Z)),V.target.value=""},[me]),Ke=k.useCallback(V=>{const Z=V.clipboardData.items,xe=[];for(const Se of Z)if(Se.kind==="file"){const He=Se.getAsFile();He&&xe.push(He)}xe.length>0&&(V.preventDefault(),me(xe))},[me]),Pe=k.useCallback(V=>{i(V.target.value);const Z=V.target;Z.style.height="auto",Z.style.height=`${Math.max(40,Math.min(Z.scrollHeight,140))}px`},[]),Oe=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),De=k.useRef(null);return k.useEffect(()=>{const V=window.visualViewport;if(!V)return;let Z=!1;const xe=()=>{De.current&&(De.current.style.height=`${V.height}px`,De.current.style.top=`${V.offsetTop}px`)},Se=()=>xe(),He=()=>{Z||xe()},Xe=()=>{Z=!0},pe=()=>{Z=!1,requestAnimationFrame(xe)};return V.addEventListener("resize",Se),V.addEventListener("scroll",He),document.addEventListener("touchstart",Xe,{passive:!0}),document.addEventListener("touchend",pe,{passive:!0}),document.addEventListener("touchcancel",pe,{passive:!0}),()=>{V.removeEventListener("resize",Se),V.removeEventListener("scroll",He),document.removeEventListener("touchstart",Xe),document.removeEventListener("touchend",pe),document.removeEventListener("touchcancel",pe)}},[]),k.useEffect(()=>{const V=De.current;if(!V)return;const Z=xe=>{let Se=xe.target;for(;Se&&Se!==V;){if(Se.tagName==="TEXTAREA"){if(Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement;continue}const Xe=window.getComputedStyle(Se).overflowY;if((Xe==="auto"||Xe==="scroll")&&Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement}xe.preventDefault()};return V.addEventListener("touchmove",Z,{passive:!1}),()=>V.removeEventListener("touchmove",Z)},[]),a.jsxs("div",{ref:De,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(_a,{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(Gm,{status:e.status}),a.jsx("button",{onClick:Oe,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:()=>S(V=>!V),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(yn,{size:16})}),x&&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),S(!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(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:Qm.map(({key:V,label:Z,icon:xe})=>a.jsxs("button",{onClick:()=>C(V),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===V?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(xe,{size:13}),a.jsx("span",{children:Z})]},V))})]}),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(dn,{urlTransform:Xm,components:Vm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(tn,{label:"Loading..."}):M?U?a.jsx(tn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:L?"Waiting for agent output...":"No logs recorded."}):a.jsx(fn,{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(dt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!y&&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(bn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ie.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(mn,{todos:ie,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(dt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):M&&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:ge,onRemove:Me}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ke,onKeyDown:V=>{$.handleKeyDown(V)||O.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),Ve())},rows:1,placeholder:L?"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:st}),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(jo,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Kn,{usage:qe}),L&&!r.trim()&&!Ce?a.jsx("button",{onClick:be,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(pn,{size:12})}):a.jsx("button",{onClick:Ve,disabled:!r.trim()&&!Ce||oe,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||Ce)&&!oe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Sn,{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(Im,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(qm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Co,{sessionId:M||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Ao,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(xr,{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((V,Z)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:V})]},Z))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function tn({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 Jm=Object.defineProperty,Bs=Object.getOwnPropertySymbols,Io=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,sn=(e,t,s)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dr=(e,t)=>{for(var s in t||(t={}))Io.call(t,s)&&sn(e,s,t[s]);if(Bs)for(var s of Bs(t))Fo.call(t,s)&&sn(e,s,t[s]);return e},Ar=(e,t)=>{var s={};for(var l in e)Io.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&&Fo.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 S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(f);if(this.drawCodewords(x),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(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,x=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=f;;S++){const u=de.getNumDataCodewords(S,c)*8,_=C.getTotalBits(i,S);if(_<=u){g=_;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])x&&g<=de.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(S,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let 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,x=Math.floor(f/3);this.setFunctionModule(p,x,o),this.setFunctionModule(x,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)),x=i+o,S=c+f;0<=x&&x<this.size&&0<=S&&S<this.size&&this.setFunctionModule(x,S,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],x=Math.floor(de.getNumRawDataModules(c)/8),S=o-x%o,g=Math.floor(x/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let y=i.slice(_,_+g-p+(u<S?0:1));_+=y.length;const w=de.reedSolomonComputeRemainder(y,d);u<S&&y.push(0),n.push(y.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,y)=>{(u!=g-p||y>=S)&&h.push(_[u])});return m(h.length==x),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 x=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][x]&&c<i.length*8&&(this.modules[g][x]=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 x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let x=0;x<this.size-1;x++){const S=this.modules[p][x];S==this.modules[p][x+1]&&S==this.modules[p+1][x]&&S==this.modules[p+1][x+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((x,S)=>x+(S?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),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((x,S)=>f[S]^=de.reedSolomonMultiply(x,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 Ie{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 Ie(Ie.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ie.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 Ie(Ie.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ie.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=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Ie(Ie.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ie.isNumeric(i)?[Ie.makeNumeric(i)]:Ie.isAlphanumeric(i)?[Ie.makeAlphanumeric(i)]:[Ie.makeBytes(Ie.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 Ie(Ie.Mode.ECI,0,c)}static isNumeric(i){return Ie.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ie.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 $t=It;var ep={L:$t.QrCode.Ecc.LOW,M:$t.QrCode.Ecc.MEDIUM,Q:$t.QrCode.Ecc.QUARTILE,H:$t.QrCode.Ecc.HIGH},Ho=128,zo="L",Wo="#FFFFFF",$o="#000000",Uo=!1,qo=1,tp=4,sp=0,rp=.1;function Ko(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 Xo(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 ip(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*rp),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 S=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-S),d=Math.ceil(i+f-g);p={x:S,y:g,w:n,h:d}}const x=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:x}}function np(e,t){return t!=null?Math.max(Math.floor(t),0):e?tp:sp}function Yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...$t.QrSegment.makeSegments(n)),g),[]);return $t.QrCode.encodeSegments(S,ep[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let x=i.getModules();const S=np(l,m),g=x.length+S*2,n=ip(x,C,S,v);return{cells:x,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var op=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ap=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,marginSize:p,imageSettings:x}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=Ar(g,["style"]),h=x?.src,u=ee.useRef(null),_=ee.useRef(null),y=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=ee.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:M}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:x,size:v});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=M!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&M.excavation!=null&&(H=Xo(R,M.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,op?I.fill(new Path2D(Ko(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),M&&(I.globalAlpha=M.opacity),A&&I.drawImage(W,M.x+b,M.y+b,M.w,M.h)}}),ee.useEffect(()=>{E(!1)},[h]);const L=Dr({height:v,width:v},n);let T=null;return h!=null&&(T=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:M?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",Dr({style:L,height:v,width:v,ref:y,role:"img"},d)),T)});ap.displayName="QRCodeCanvas";var Vo=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,title:p,marginSize:x,imageSettings:S}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:x,imageSettings:S,size:v});let _=d,y=null;S!=null&&u!=null&&(u.excavation!=null&&(_=Xo(d,u.excavation)),y=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Ko(_,n);return ee.createElement("svg",Dr({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),y)});Vo.displayName="QRCodeSVG";function lp(){return ht({queryKey:ae.tunnel.status,queryFn:()=>fe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function cp(){const e=We();return Ze({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return fe.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function hp(){const e=We();return Ze({mutationFn:()=>fe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function rn(){const{t:e}=ce(),{data:t}=lp(),s=cp(),l=hp(),[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),x=t?.running??!1,S=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const y=i.current.getBoundingClientRect();f({top:y.bottom+8,right:window.innerWidth-y.right})}},[m]);const d=k.useCallback(()=>{x?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[x,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:S,className:`p-1.5 rounded-md transition-colors ${x?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(x?"Tunnel active":"Share via tunnel"),children:S?a.jsx(ze,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),x&&!S&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&x&&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(vl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Vo,{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:y=>y.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(ui,{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(ui,{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 nn={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>cn(()=>import("./modal-CZQt_i5V.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),gr=k.lazy(()=>cn(()=>import("./folder-picker-_XMcl4vl.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),on=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"})]}),an=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),up=260,dp=600,ln=400;function Rp(){const{t:e}=ce(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(ln),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[x,S]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[y,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:M,clear:L,buildMarkdownLinks:T,isUploading:B}=Zr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(ln),N=k.useRef(null),P=We(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=ba(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(km),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Of(D??""),z=Da({queries:D?[]:Q.map(q=>({queryKey:ae.tasks.list(q.id),queryFn:()=>fe.get(`/projects/${q.id}/tasks`,{params:{limit:"500"}})}))}),te=!D&&z.some(q=>q.isLoading),Y=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const J of z)J.data?.data&&q.push(...J.data.data);return q},[D,F,z]),ie=t&&Y.some(q=>q.id===t)?t:null,ge=k.useMemo(()=>{const q=new Map;for(const J of Y){const he=J.createdAt?new Date(J.createdAt).getTime():0,ue=q.get(J.projectId)??0;he>ue&&q.set(J.projectId,he)}return[...Q].sort((J,he)=>{const ue=q.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(q.get(he.id)??(he.createdAt?new Date(he.createdAt).getTime():0))-ue})},[Q,Y]),me=k.useMemo(()=>ge.filter(q=>!q.archivedAt),[ge]),Me=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),J=q?JSON.parse(q):{};return[...O].sort((he,ue)=>{const ve=he.availability.type!=="NOT_FOUND",Ae=ue.availability.type!=="NOT_FOUND";if(ve!==Ae)return ve?-1:1;const mt=J[he.provider.id]??0;return(J[ue.provider.id]??0)-mt})},[O]),re=k.useMemo(()=>Y.map(Dm),[Y]),Be=k.useMemo(()=>new Set,[]),Ce=k.useMemo(()=>{if(!ie)return null;const q=Y.find(he=>he.id===ie);if(!q)return null;const J=Q.find(he=>he.id===q.projectId);if(!J){const he=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Jr(q.status),branch:he,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Am(q,J)},[ie,Y,Q]),oe=xa(),Ne=Bf(u),qe=Ff(),Re=If(),Ve=k.useCallback(q=>{qe.mutate(q,{onSuccess:()=>{ie===q&&s(null),P.invalidateQueries({queryKey:ae.tasks.all})}})},[qe,ie,P]),be=k.useCallback((q,J)=>{Re.mutate({id:q,status:wm(J)},{onError:()=>{ni.error(e("状态变更失败,该操作不被允许"))}})},[Re,e]),st=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=he=>{if(!H.current)return;const ue=he.clientX-W.current,ve=Math.max(up,Math.min(dp,A.current+ue));C(ve)},J=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",J)}},[]);const Ke=k.useCallback(()=>{i(!0)},[]),Pe=k.useCallback(()=>{if(me.length===0){ni.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),J=localStorage.getItem("lastSelectedProviderId"),he=q&&me.find(Ae=>Ae.id===q)?q:(D&&me.find(Ae=>Ae.id===D)?.id)??me[0]?.id??"";_(he);const ue=Me?.find(Ae=>Ae.availability.type!=="NOT_FOUND"),ve=J&&Me?.find(Ae=>Ae.provider.id===J&&Ae.availability.type!=="NOT_FOUND")?J:ue?.provider.id??"";w(ve),b("idle"),f(!0)},[me,D,Me,e]),Oe=k.useCallback(()=>{i(!1),p(""),S("")},[]),De=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),L())},[E,L]),V=k.useCallback(async()=>{if(!(!o.trim()||!x.trim()))try{await oe.mutateAsync({name:o.trim(),repoPath:x.trim()}),Oe()}catch{}},[o,x,oe,Oe]),Z=Gr(),xe=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),J=[d.trim(),q].filter(Boolean).join(`
|
|
84
84
|
|
|
85
85
|
`);b("creating-task");const he=await Ne.mutateAsync({title:g.trim(),description:J||void 0});if(localStorage.setItem("lastSelectedProjectId",u),y){localStorage.setItem("lastSelectedProviderId",y);const ue=localStorage.getItem("providerUsageCount"),ve=ue?JSON.parse(ue):{};ve[y]=(ve[y]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ve))}if(y){const ue=[g.trim(),J].filter(Boolean).join(`
|
|
86
86
|
|
|
87
|
-
`);b("creating-workspace");const ve=await fe.post(`/tasks/${he.id}/workspaces`,{});b("creating-session");const Ae=await fe.post(`/workspaces/${ve.id}/sessions`,{providerId:y,prompt:ue});b("starting-session"),await Z.mutateAsync(Ae.id),await P.invalidateQueries({queryKey:le.workspaces.list(he.id)})}s(he.id),b("idle"),f(!1),n(""),h(""),_(""),w(""),L()}catch{b("idle")}},[g,d,u,y,Ne,Z,P,T,L]),Se=k.useCallback(q=>{const J=q.target.files;J&&J.length>0&&j(Array.from(J)),q.target.value=""},[j]),He=k.useCallback(q=>{const J=q.clipboardData.items,he=[];for(const ue of J)if(ue.kind==="file"){const ve=ue.getAsFile();ve&&he.push(ve)}he.length>0&&(q.preventDefault(),j(he))},[j]),[Xe,pe]=k.useState(!1),et=k.useCallback(q=>{q.preventDefault(),pe(!0)},[]),Ge=k.useCallback(q=>{q.preventDefault(),pe(!1)},[]),nt=k.useCallback(q=>{q.preventDefault(),pe(!1);const J=q.dataTransfer.files;J.length>0&&j(Array.from(J))},[j]),Ht=K||U||te;return Mm()?ie&&Ce?a.jsxs(a.Fragment,{children:[a.jsx(Zm,{task:Ce,onBack:()=>s(null),onDeleteTask:Ce.projectArchivedAt?void 0:Ve,isDeleting:qe.isPending}),a.jsx(k.Suspense,{fallback:null,children:a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]})]})})})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[a.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[on,an]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(rn,{}),a.jsx(oi,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:a.jsx(ai,{size:16})})]})]}),Ht&&re.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):a.jsx(Ei,{tasks:re,projects:se,selectedTaskId:null,onSelectTask:s,filterProjectId:D,setFilterProjectId:m,width:"100%",onCreateProject:Ke,onCreateTask:Pe,activeTaskIds:Be,onTaskStatusChange:be})]}),a.jsxs(k.Suspense,{fallback:null,children:[a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]})]})}),a.jsx(Gt,{isOpen:c,onClose:De,title:e("Create New Task"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:De,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 disabled:opacity-50",children:e("Cancel")}),a.jsx("button",{onClick:xe,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(nn[E])})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),a.jsx(vs,{value:u,onChange:_,options:me.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Provider")}),a.jsx(vs,{value:y,onChange:w,options:Me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),a.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",disabled:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${Xe?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:et,onDragLeave:Ge,onDrop:nt,children:[a.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:He,placeholder:e("Optional..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}}),Xe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>I.current?.click(),disabled:E!=="idle"||B,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 active:text-neutral-900 active:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(ws,{size:14}),e("Attach files")]}),a.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste files")})]}),a.jsx("input",{ref:I,type:"file",multiple:!0,onChange:Se,className:"hidden"}),a.jsx(Ns,{files:R,onRemove:M})]})]})})]})]}):a.jsxs("div",{ref:N,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[a.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[on,an]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(rn,{}),a.jsx(oi,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:a.jsx(ai,{size:16})})]})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ht&&re.length===0?a.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:v},children:e("Loading...")}):a.jsx(Ei,{tasks:re,projects:se,selectedTaskId:ie,onSelectTask:s,filterProjectId:D,setFilterProjectId:m,width:v,onCreateProject:Ke,onCreateTask:Pe,activeTaskIds:Be,onTaskStatusChange:be,onDeleteTask:Ve}),a.jsx("div",{onMouseDown:st,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),a.jsx(Cm,{task:Ce,onDeleteTask:Ce?.projectArchivedAt?void 0:Ve,isDeleting:qe.isPending,onTaskStatusChange:Ce?.projectArchivedAt?void 0:be})]}),a.jsxs(k.Suspense,{fallback:null,children:[a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create Project")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]}),oe.isError&&a.jsx("p",{className:"text-xs text-red-500",children:oe.error instanceof Error?oe.error.message:e("Failed to create project")})]})}),a.jsx(Gt,{isOpen:c,onClose:De,title:e("Create New Task"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:De,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),a.jsx("button",{onClick:xe,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(nn[E])})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),a.jsx(vs,{value:u,onChange:_,options:me.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),a.jsx(vs,{value:y,onChange:w,options:Me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),a.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",disabled:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${Xe?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:et,onDragLeave:Ge,onDrop:nt,children:[a.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:He,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}}),Xe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>I.current?.click(),disabled:E!=="idle"||B,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(ws,{size:14}),e("Attach files")]}),a.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),a.jsx("input",{ref:I,type:"file",multiple:!0,onChange:Se,className:"hidden"}),a.jsx(Ns,{files:R,onRemove:M})]}),Ne.isError&&a.jsx("p",{className:"text-xs text-red-500",children:Ne.error instanceof Error?Ne.error.message:"Failed to create task"})]})})]})]})}export{Rp as ProjectKanbanPage};
|
|
87
|
+
`);b("creating-workspace");const ve=await fe.post(`/tasks/${he.id}/workspaces`,{});b("creating-session");const Ae=await fe.post(`/workspaces/${ve.id}/sessions`,{providerId:y,prompt:ue});b("starting-session"),await Z.mutateAsync(Ae.id),await P.invalidateQueries({queryKey:ae.workspaces.list(he.id)})}s(he.id),b("idle"),f(!1),n(""),h(""),_(""),w(""),L()}catch{b("idle")}},[g,d,u,y,Ne,Z,P,T,L]),Se=k.useCallback(q=>{const J=q.target.files;J&&J.length>0&&j(Array.from(J)),q.target.value=""},[j]),He=k.useCallback(q=>{const J=q.clipboardData.items,he=[];for(const ue of J)if(ue.kind==="file"){const ve=ue.getAsFile();ve&&he.push(ve)}he.length>0&&(q.preventDefault(),j(he))},[j]),[Xe,pe]=k.useState(!1),et=k.useCallback(q=>{q.preventDefault(),pe(!0)},[]),Ge=k.useCallback(q=>{q.preventDefault(),pe(!1)},[]),nt=k.useCallback(q=>{q.preventDefault(),pe(!1);const J=q.dataTransfer.files;J.length>0&&j(Array.from(J))},[j]),Ht=K||U||te;return Mm()?ie&&Ce?a.jsxs(a.Fragment,{children:[a.jsx(Zm,{task:Ce,onBack:()=>s(null),onDeleteTask:Ce.projectArchivedAt?void 0:Ve,isDeleting:qe.isPending}),a.jsx(k.Suspense,{fallback:null,children:a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]})]})})})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[a.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[on,an]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(rn,{}),a.jsx(oi,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:a.jsx(ai,{size:16})})]})]}),Ht&&re.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):a.jsx(Ei,{tasks:re,projects:se,selectedTaskId:null,onSelectTask:s,filterProjectId:D,setFilterProjectId:m,width:"100%",onCreateProject:Ke,onCreateTask:Pe,activeTaskIds:Be,onTaskStatusChange:be})]}),a.jsxs(k.Suspense,{fallback:null,children:[a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]})]})}),a.jsx(Gt,{isOpen:c,onClose:De,title:e("Create New Task"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:De,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 disabled:opacity-50",children:e("Cancel")}),a.jsx("button",{onClick:xe,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(nn[E])})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),a.jsx(vs,{value:u,onChange:_,options:me.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Provider")}),a.jsx(vs,{value:y,onChange:w,options:Me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),a.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",disabled:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${Xe?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:et,onDragLeave:Ge,onDrop:nt,children:[a.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:He,placeholder:e("Optional..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}}),Xe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>I.current?.click(),disabled:E!=="idle"||B,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 active:text-neutral-900 active:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(ws,{size:14}),e("Attach files")]}),a.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste files")})]}),a.jsx("input",{ref:I,type:"file",multiple:!0,onChange:Se,className:"hidden"}),a.jsx(Ns,{files:R,onRemove:M})]})]})})]})]}):a.jsxs("div",{ref:N,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[a.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[on,an]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(rn,{}),a.jsx(oi,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:a.jsx(ai,{size:16})})]})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ht&&re.length===0?a.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:v},children:e("Loading...")}):a.jsx(Ei,{tasks:re,projects:se,selectedTaskId:ie,onSelectTask:s,filterProjectId:D,setFilterProjectId:m,width:v,onCreateProject:Ke,onCreateTask:Pe,activeTaskIds:Be,onTaskStatusChange:be,onDeleteTask:Ve}),a.jsx("div",{onMouseDown:st,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),a.jsx(Cm,{task:Ce,onDeleteTask:Ce?.projectArchivedAt?void 0:Ve,isDeleting:qe.isPending,onTaskStatusChange:Ce?.projectArchivedAt?void 0:be})]}),a.jsxs(k.Suspense,{fallback:null,children:[a.jsx(Gt,{isOpen:r,onClose:Oe,title:e("Create New Project"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:Oe,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:e("Cancel")}),a.jsx("button",{onClick:V,disabled:!o.trim()||!x.trim()||oe.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${o.trim()&&x.trim()&&!oe.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe.isPending?e("Creating..."):e("Create Project")})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project Name")}),a.jsx("input",{type:"text",value:o,onChange:q=>p(q.target.value),placeholder:e("e.g., Agent Tower"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Repository Path")}),a.jsx(gr,{value:x,onChange:S})]}),oe.isError&&a.jsx("p",{className:"text-xs text-red-500",children:oe.error instanceof Error?oe.error.message:e("Failed to create project")})]})}),a.jsx(Gt,{isOpen:c,onClose:De,title:e("Create New Task"),action:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:De,disabled:E!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),a.jsx("button",{onClick:xe,disabled:!g.trim()||!u||E!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${g.trim()&&u&&E==="idle"?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:e(nn[E])})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),a.jsx(vs,{value:u,onChange:_,options:me.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:E!=="idle"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),a.jsx(vs,{value:y,onChange:w,options:Me.map(({provider:q,availability:J})=>({value:q.id,label:q.name+(J.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:J.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:E!=="idle"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),a.jsx("input",{type:"text",value:g,onChange:q=>n(q.target.value),placeholder:e("e.g., Implement login flow"),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",disabled:E!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),a.jsxs("div",{className:`relative border rounded-lg transition-colors ${Xe?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:et,onDragLeave:Ge,onDrop:nt,children:[a.jsx("textarea",{rows:3,value:d,onChange:q=>h(q.target.value),onPaste:He,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:E!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&xe()}}),Xe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:a.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>I.current?.click(),disabled:E!=="idle"||B,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(ws,{size:14}),e("Attach files")]}),a.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),a.jsx("input",{ref:I,type:"file",multiple:!0,onChange:Se,className:"hidden"}),a.jsx(Ns,{files:R,onRemove:M})]}),Ne.isError&&a.jsx("p",{className:"text-xs text-red-500",children:Ne.error instanceof Error?Ne.error.message:"Failed to create task"})]})})]})]})}export{Rp as ProjectKanbanPage};
|