agent-tower 0.5.2-beta.5 → 0.5.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -1
- package/dist/executors/__tests__/base.executor.test.js +12 -0
- package/dist/executors/__tests__/base.executor.test.js.map +1 -1
- package/dist/executors/execution-env.d.ts +1 -1
- package/dist/executors/execution-env.d.ts.map +1 -1
- package/dist/executors/execution-env.js +4 -0
- package/dist/executors/execution-env.js.map +1 -1
- package/dist/routes/conversations.d.ts +3 -0
- package/dist/routes/conversations.d.ts.map +1 -0
- package/dist/routes/conversations.js +102 -0
- package/dist/routes/conversations.js.map +1 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +3 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +37 -21
- package/dist/routes/sessions.js.map +1 -1
- package/dist/services/__tests__/conversation.service.test.d.ts +2 -0
- package/dist/services/__tests__/conversation.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/conversation.service.test.js +102 -0
- package/dist/services/__tests__/conversation.service.test.js.map +1 -0
- package/dist/services/commit-message.service.d.ts.map +1 -1
- package/dist/services/commit-message.service.js +4 -0
- package/dist/services/commit-message.service.js.map +1 -1
- package/dist/services/conversation.service.d.ts +26 -0
- package/dist/services/conversation.service.d.ts.map +1 -0
- package/dist/services/conversation.service.js +224 -0
- package/dist/services/conversation.service.js.map +1 -0
- package/dist/services/session-manager.d.ts +69 -13
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +107 -42
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task.service.d.ts +2 -2
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +2 -0
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/services/workspace.service.d.ts +9 -7
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-CUgqAjq9.js +1 -0
- package/dist/web/assets/ConversationPage-Cyiw8Hra.js +3 -0
- package/dist/web/assets/CreateTaskInput-BILlpv9b.js +2 -0
- package/dist/web/assets/{DemoPage-CaV94VWQ.js → DemoPage-SywVXjL0.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-CyBUcF5g.js → GeneralSettingsPage-CTymytF6.js} +1 -1
- package/dist/web/assets/Icons-DmLVnVdg.js +1 -0
- package/dist/web/assets/{McpSettingsPage-CzE9eriX.js → McpSettingsPage-DyolUN8C.js} +1 -1
- package/dist/web/assets/{MemberAvatar-ChVx4wRa.js → MemberAvatar-u6jTOiDY.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-BBop2Bu4.js +1 -0
- package/dist/web/assets/ProfileSettingsPage-Bw-eI0cF.js +3 -0
- package/dist/web/assets/ProjectKanbanPage-BFf2FZVz.js +89 -0
- package/dist/web/assets/ProjectSettingsPage-BJ4sOhMl.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-DRUxVjQu.js → ProviderSettingsPage-BlLaN0i2.js} +19 -19
- package/dist/web/assets/{SettingsMasterDetail-CTXxGe3o.js → SettingsMasterDetail-CdimTj5n.js} +1 -1
- package/dist/web/assets/TeamSettingsPage-CqQTc5AI.js +1 -0
- package/dist/web/assets/arc-Ddp5hhH6.js +1 -0
- package/dist/web/assets/architectureDiagram-3BPJPVTR-CpK7WDLU.js +36 -0
- package/dist/web/assets/{arrow-left-D8mdzO_t.js → arrow-left-B6KMicbE.js} +1 -1
- package/dist/web/assets/blockDiagram-GPEHLZMM-6_0hov2h.js +132 -0
- package/dist/web/assets/c4Diagram-AAUBKEIU-Br6Tzu3R.js +10 -0
- package/dist/web/assets/channel-Bg_GO2e9.js +1 -0
- package/dist/web/assets/check-D9lM__p8.js +1 -0
- package/dist/web/assets/{chevron-down-DBS9-_Q3.js → chevron-down-Cur5jANy.js} +1 -1
- package/dist/web/assets/{chevron-right-pRSZZk-l.js → chevron-right-R3KVa8oQ.js} +1 -1
- package/dist/web/assets/{chevron-up-Bv9reJY4.js → chevron-up-DcLdFanO.js} +1 -1
- package/dist/web/assets/chunk-2J33WTMH-D8zyttB-.js +1 -0
- package/dist/web/assets/chunk-4BX2VUAB-Cqi9xJ8M.js +1 -0
- package/dist/web/assets/chunk-55IACEB6-Dxjaitf1.js +1 -0
- package/dist/web/assets/chunk-727SXJPM-CAn8Y9XB.js +206 -0
- package/dist/web/assets/chunk-AQP2D5EJ-B4sECH9U.js +231 -0
- package/dist/web/assets/chunk-FMBD7UC4-Ckd3e1dg.js +15 -0
- package/dist/web/assets/chunk-ND2GUHAM-h5WBT7BK.js +1 -0
- package/dist/web/assets/chunk-QZHKN3VN-Cdzk46MK.js +1 -0
- package/dist/web/assets/{circle-alert-DdGuxtmq.js → circle-alert-OKyZ9U2p.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BeJctdRx.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BeJctdRx.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-k5CJUaBc.js → code-block-OCS4YCEC-VMJOsrkF.js} +1 -1
- package/dist/web/assets/{confirm-dialog-Bit5jNx2.js → confirm-dialog-BAnxa2C9.js} +1 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-CbFey2pd.js +1 -0
- package/dist/web/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
- package/dist/web/assets/dagre-BM42HDAG-Bd2eIyf3.js +4 -0
- package/dist/web/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/web/assets/diagram-2AECGRRQ-CXONvVnW.js +43 -0
- package/dist/web/assets/diagram-5GNKFQAL-B2E90mVs.js +10 -0
- package/dist/web/assets/diagram-KO2AKTUF-ByaC99pb.js +3 -0
- package/dist/web/assets/diagram-LMA3HP47-DwVBF2fn.js +24 -0
- package/dist/web/assets/diagram-OG6HWLK6-FWRddceo.js +24 -0
- package/dist/web/assets/erDiagram-TEJ5UH35-ye6i3SGj.js +85 -0
- package/dist/web/assets/flowDiagram-I6XJVG4X-B6l7qTcg.js +162 -0
- package/dist/web/assets/folder-B0m3OL2U.js +1 -0
- package/dist/web/assets/folder-picker-D5XrSfLA.js +1 -0
- package/dist/web/assets/ganttDiagram-6RSMTGT7-BCCqDrep.js +292 -0
- package/dist/web/assets/gitGraphDiagram-PVQCEYII-Ca4ANaSw.js +106 -0
- package/dist/web/assets/graph--OzhPTMs.js +1 -0
- package/dist/web/assets/index-C4twOgZR.css +1 -0
- package/dist/web/assets/index-C9hQg1KT.js +303 -0
- package/dist/web/assets/{index-B48HCCvn.js → index-DbO4YyUv.js} +6 -6
- package/dist/web/assets/infoDiagram-5YYISTIA-D1V1Tezr.js +2 -0
- package/dist/web/assets/init-Gi6I4Gst.js +1 -0
- package/dist/web/assets/{input-CapacyJb.js → input-Dqnd4oTj.js} +1 -1
- package/dist/web/assets/ishikawaDiagram-YF4QCWOH-DnGiJn9p.js +70 -0
- package/dist/web/assets/journeyDiagram-JHISSGLW-QFxbLfhN.js +139 -0
- package/dist/web/assets/kanban-definition-UN3LZRKU-BA2nBc7B.js +89 -0
- package/dist/web/assets/katex-HP8lGamR.js +257 -0
- package/dist/web/assets/{layers-CifLa7KP.js → layers-CfFYGUtI.js} +1 -1
- package/dist/web/assets/layout-SsrduOYp.js +1 -0
- package/dist/web/assets/linear-DpASQZmA.js +1 -0
- package/dist/web/assets/{loader-circle-CRx0_e2Z.js → loader-circle-B5Lfi46Y.js} +1 -1
- package/dist/web/assets/log-adapter-CjgRCCYG.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-TDWqrpYr.js → mermaid-NOHMQCX5-7FmPQynq.js} +60 -60
- package/dist/web/assets/{message-square-BQB-4uFy.js → message-square-CEefL0sf.js} +1 -1
- package/dist/web/assets/mindmap-definition-RKZ34NQL-C7QuD-ms.js +96 -0
- package/dist/web/assets/modal-CAB_bs-c.js +1 -0
- package/dist/web/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/web/assets/{pencil-D0ZsDzqo.js → pencil-B__GQn9r.js} +1 -1
- package/dist/web/assets/pieDiagram-4H26LBE5-Bf5diCKb.js +30 -0
- package/dist/web/assets/quadrantDiagram-W4KKPZXB-BMbcPnH3.js +7 -0
- package/dist/web/assets/requirementDiagram-4Y6WPE33-CUPvJXMk.js +84 -0
- package/dist/web/assets/{rotate-ccw-Cm5Zx65C.js → rotate-ccw-5d-eMwsw.js} +1 -1
- package/dist/web/assets/sankeyDiagram-5OEKKPKP-C77g6vmK.js +40 -0
- package/dist/web/assets/{select-YFykpbyQ.js → select-BJfNuuIV.js} +1 -1
- package/dist/web/assets/sequenceDiagram-3UESZ5HK-xGOV8CdQ.js +162 -0
- package/dist/web/assets/stateDiagram-AJRCARHV-Bc0piegy.js +1 -0
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CiRT9t6d.js +1 -0
- package/dist/web/assets/{switch-D5RS57YU.js → switch-bLlDOWNp.js} +1 -1
- package/dist/web/assets/{terminal-r3vqhdyt.js → terminal-Bh2qSv0U.js} +1 -1
- package/dist/web/assets/{textarea-PjCFOxmD.js → textarea-BcVRpxhF.js} +1 -1
- package/dist/web/assets/timeline-definition-PNZ67QCA-CcACRt_V.js +120 -0
- package/dist/web/assets/trash-2-8Pu6lwnW.js +1 -0
- package/dist/web/assets/{upload-BkWqEmQd.js → upload-DNwyW_bv.js} +1 -1
- package/dist/web/assets/{use-profiles-Ch0Rlrh-.js → use-profiles-BIqkQu69.js} +1 -1
- package/dist/web/assets/{use-providers-CSQgeUSp.js → use-providers-BOyY0DcV.js} +1 -1
- package/dist/web/assets/vennDiagram-CIIHVFJN-BC9RHBQ5.js +34 -0
- package/dist/web/assets/wardley-L42UT6IY-BgPj73Dc.js +161 -0
- package/dist/web/assets/wardleyDiagram-YWT4CUSO-PbfDUndy.js +78 -0
- package/dist/web/assets/xychartDiagram-2RQKCTM6-D87KYJUM.js +7 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +41 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js +8 -0
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +21 -6
- package/node_modules/@prisma/client/.prisma/client/index-browser.js +14 -0
- package/node_modules/@prisma/client/.prisma/client/index.d.ts +1789 -211
- package/node_modules/@prisma/client/.prisma/client/index.js +21 -6
- package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
- package/node_modules/@prisma/client/.prisma/client/schema.prisma +34 -14
- package/node_modules/@prisma/client/.prisma/client/wasm.js +14 -0
- package/package.json +1 -1
- package/prisma/migrations/20260618000000_add_conversations/migration.sql +79 -0
- package/prisma/schema.prisma +22 -2
- package/dist/web/assets/AgentDemoPage-DYU0dSD9.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-C68vNTcP.js +0 -1
- package/dist/web/assets/ProfileSettingsPage-CRz5C2OS.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-Tmp1bu4q.js +0 -89
- package/dist/web/assets/ProjectSettingsPage-CVTWLRxT.js +0 -2
- package/dist/web/assets/TeamSettingsPage-DjP8gj71.js +0 -1
- package/dist/web/assets/check-CadkXmJ-.js +0 -1
- package/dist/web/assets/folder-picker-DSfmubl6.js +0 -1
- package/dist/web/assets/index-LbQD7FZK.css +0 -1
- package/dist/web/assets/log-adapter-CtvxzS4j.js +0 -1
- package/dist/web/assets/modal-B6TZLhQ2.js +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import{U as ln,V as Zn,W as Qc,Y as Zc,Z as Jc,_ as Ui,$ as ed,a0 as td,k as at,a1 as sd,a2 as rd,r as y,a3 as id,a4 as nd,a5 as od,a6 as ad,a7 as Jn,a8 as eo,a9 as ld,aa as cd,ab as dd,h as _e,ac as he,P as ss,i as kt,l as yt,m as ve,q as le,u as ue,j as t,T as pt,X as Ht,g as G,B as Ie,ad as wa,ae as Ca,af as ka,ag as us,ah as ud,s as Ea,ai as hd,aj as fd,ak as md,t as ut,E as ts,F as ct,G as ws,al as ja,am as cn,an as qi,v as pd,L as to,ao as Na,R as so,ap as dn,aq as Ra,ar as Ta,as as Aa,at as gd,au as vd,av as xd,aw as bd,ax as _d,H as ro,ay as io}from"./index-B48HCCvn.js";import{S as rt,W as lt,a as Rt,C as Ys,A as Wt,T as zt}from"./log-adapter-CtvxzS4j.js";import{C as Kr}from"./confirm-dialog-Bit5jNx2.js";import{f as Ma,c as Da,d as La,b as Pa,h as Oa,S as Ns,A as no,P as Vr,Q as un,s as hn,G as Ia,u as Ba,a as Fa,e as Rr,T as Tr}from"./mermaid-NOHMQCX5-TDWqrpYr.js";import{C as ht}from"./chevron-down-DBS9-_Q3.js";import{C as Mt}from"./chevron-right-pRSZZk-l.js";import{b as yd,a as za,F as Sd,g as wd,h as Cd,f as kd,u as Ed}from"./folder-picker-DSfmubl6.js";import{L as Rs}from"./layers-CifLa7KP.js";import{L as ze}from"./loader-circle-CRx0_e2Z.js";import{M as At}from"./MemberAvatar-ChVx4wRa.js";import{C as Wa}from"./chevron-up-Bv9reJY4.js";import{C as bt}from"./check-CadkXmJ-.js";import{M as As,P as Vt,a as sr,T as fn}from"./modal-B6TZLhQ2.js";import{S as cs}from"./select-YFykpbyQ.js";import{u as Ms}from"./use-providers-CSQgeUSp.js";import{M as mn}from"./message-square-BQB-4uFy.js";import{T as Ar,C as oo}from"./terminal-r3vqhdyt.js";import{U as Mr,C as jd}from"./upload-BkWqEmQd.js";import{A as Gs}from"./arrow-left-D8mdzO_t.js";import{R as Nd}from"./rotate-ccw-Cm5Zx65C.js";import"./circle-alert-DdGuxtmq.js";var Rd=class extends ln{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Zn()})}getOptimisticResult(e){return e.behavior=Zn(),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,s){const{state:r}=e,n=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:i}=n,o=r.fetchMeta?.fetchMore?.direction,l=v&&o==="forward",u=p&&o==="forward",c=v&&o==="backward",g=p&&o==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Zc(s,r.data),hasPreviousPage:Qc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!l&&!c,isRefetching:m&&!u&&!g}}};function ao(e,s){const r=new Set(s);return e.filter(n=>!r.has(n))}function Td(e,s,r){const n=e.slice(0);return n[s]=r,n}var Ad=class extends Jc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Ui.batch(()=>{const r=this.#t,n=this.#h(this.#i);n.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const p=n.map(u=>u.observer),m=p.map(u=>u.getCurrentResult()),v=r.length!==p.length,i=p.some((u,c)=>u!==r[c]),o=v||i,l=o?!0:m.some((u,c)=>{const g=this.#e[c];return!g||!ed(u,g)});!o&&!l||(o&&(this.#c=n,this.#t=p),this.#e=m,this.hasListeners()&&(o&&(ao(r,p).forEach(u=>{u.destroy()}),ao(p,r).forEach(u=>{u.subscribe(c=>{this.#f(u,c)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),n=r.map(m=>m.observer.getOptimisticResult(m.defaultedQueryOptions)),p=r.map(m=>m.defaultedQueryOptions.queryHash);return[n,m=>this.#u(m??n,s,p),()=>this.#d(n,r)]}#d(e,s){return s.map((r,n)=>{const p=e[n];return r.defaultedQueryOptions.notifyOnChangeProps?p:r.observer.trackResult(p,m=>{s.forEach(v=>{v.observer.trackProp(m)})})})}#u(e,s,r){if(s){const n=this.#l,p=r!==void 0&&n!==void 0&&(n.length!==r.length||r.some((m,v)=>m!==n[v]));return(!this.#s||this.#e!==this.#a||p||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=td(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(n=>{const p=n.options.queryHash;if(!p)return;const m=s.get(p);m?m.push(n):s.set(p,[n])});const r=[];return e.forEach(n=>{const p=this.#r.defaultQueryOptions(n),v=s.get(p.queryHash)?.shift()??new ln(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Td(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Ui.batch(()=>{this.listeners.forEach(n=>{n(this.#e)})})}}};function Md({queries:e,...s},r){const n=at(),p=sd(),m=rd(),v=y.useMemo(()=>e.map(x=>{const a=n.defaultQueryOptions(x);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,n,p]);v.forEach(x=>{id(x);const a=n.getQueryCache().get(x.queryHash);nd(x,m,a)}),od(m);const[i]=y.useState(()=>new Ad(n,v,s)),[o,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;y.useSyncExternalStore(y.useCallback(x=>c?i.subscribe(Ui.batchCalls(x)):ad,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),y.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const b=o.some((x,a)=>Jn(v[a],x))?o.flatMap((x,a)=>{const f=v[a];if(f){const d=new ln(n,f);if(Jn(f,x))return eo(f,d,m);ld(x,p)&&eo(f,d,m)}return[]}):[];if(b.length>0)throw Promise.all(b);const S=o.find((x,a)=>{const f=v[a];return f&&cd({result:x,errorResetBoundary:m,throwOnError:f.throwOnError,query:n.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(S?.error)throw S.error;return l(u())}function pn(e,s){return dd(e,Rd)}const Dd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Qs=_e("arrow-down",Dd);const Ld=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Pd=_e("arrow-right",Ld);const Od=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Xr=_e("arrow-up",Od);const Id=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ha=_e("ban",Id);const Bd=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Fd=_e("bot",Bd);const zd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wd=_e("chevron-left",zd);const Hd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Cs=_e("clock-3",Hd);const $d=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],rr=_e("code-xml",$d);const Ud=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["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"}]],lo=_e("copy-plus",Ud);const qd=[["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"}]],$a=_e("ellipsis-vertical",qd);const Kd=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],gn=_e("external-link",Kd);const Vd=[["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"}]],Xd=_e("file-braces-corner",Vd);const Yd=[["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"}]],Dr=_e("file-code-corner",Yd);const Gd=[["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"}]],Qd=_e("file-exclamation-point",Gd);const Zd=[["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"}]],vn=_e("file-text",Zd);const Jd=[["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"}]],Yr=_e("folder-open",Jd);const eu=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],tu=_e("gauge",eu);const su=[["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"}]],xn=_e("git-branch",su);const ru=[["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"}]],Ds=_e("git-graph",ru);const iu=[["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"}]],Ts=_e("history",iu);const nu=[["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"}]],bn=_e("image",nu);const ou=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],au=_e("info",ou);const lu=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],cu=_e("lock-keyhole",lu);const du=[["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"}]],uu=_e("maximize",du);const hu=[["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"}]],fu=_e("panel-left-close",hu);const mu=[["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"}]],pu=_e("panel-left-open",mu);const gu=[["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"}]],vu=_e("panel-right-close",gu);const xu=[["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"}]],Ki=_e("panel-right-open",xu);const bu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],_u=_e("pen-line",bu);const yu=[["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"}]],Xt=_e("play",yu);const Su=[["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"}]],ir=_e("refresh-cw",Su);const wu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Cu=_e("save",wu);const ku=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_n=_e("search",ku);const Eu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ua=_e("settings-2",Eu);const ju=[["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"}]],qa=_e("shield",ju);const Nu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],co=_e("smartphone",Nu);const Ru=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Tu=_e("square-pen",Ru);const Au=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],xr=_e("user-plus",Au);const Mu=[["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"}]],Ka=_e("zap",Mu);const Du=[["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"}]],Lu=_e("zoom-in",Du);const Pu=[["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"}]],Ou=_e("zoom-out",Pu),Gr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ls(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function yn(e){return"nodeType"in e}function _t(e){var s,r;return e?Ls(e)?e:yn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Sn(e){const{Document:s}=_t(e);return e instanceof s}function nr(e){return Ls(e)?!1:e instanceof _t(e).HTMLElement}function Va(e){return e instanceof _t(e).SVGElement}function Ps(e){return e?Ls(e)?e.document:yn(e)?Sn(e)?e:nr(e)||Va(e)?e.ownerDocument:document:document:document}const Yt=Gr?y.useLayoutEffect:y.useEffect;function Qr(e){const s=y.useRef(e);return Yt(()=>{s.current=e}),y.useCallback(function(){for(var r=arguments.length,n=new Array(r),p=0;p<r;p++)n[p]=arguments[p];return s.current==null?void 0:s.current(...n)},[])}function Iu(){const e=y.useRef(null),s=y.useCallback((n,p)=>{e.current=setInterval(n,p)},[]),r=y.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Zs(e,s){s===void 0&&(s=[e]);const r=y.useRef(e);return Yt(()=>{r.current!==e&&(r.current=e)},s),r}function or(e,s){const r=y.useRef();return y.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...s])}function Lr(e){const s=Qr(e),r=y.useRef(null),n=y.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,n]}function Pr(e){const s=y.useRef();return y.useEffect(()=>{s.current=e},[e]),s.current}let yi={};function Zr(e,s){return y.useMemo(()=>{if(s)return s;const r=yi[e]==null?0:yi[e]+1;return yi[e]=r,e+"-"+r},[e,s])}function Xa(e){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),p=1;p<r;p++)n[p-1]=arguments[p];return n.reduce((m,v)=>{const i=Object.entries(v);for(const[o,l]of i){const u=m[o];u!=null&&(m[o]=u+e*l)}return m},{...s})}}const js=Xa(1),Or=Xa(-1);function Bu(e){return"clientX"in e&&"clientY"in e}function wn(e){if(!e)return!1;const{KeyboardEvent:s}=_t(e.target);return s&&e instanceof s}function Fu(e){if(!e)return!1;const{TouchEvent:s}=_t(e.target);return s&&e instanceof s}function Ir(e){if(Fu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Bu(e)?{x:e.clientX,y:e.clientY}:null}const Js=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Js.Translate.toString(e),Js.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:n}=e;return s+" "+r+"ms "+n}}}),uo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zu(e){return e.matches(uo)?e:e.querySelector(uo)}const Wu={display:"none"};function Hu(e){let{id:s,value:r}=e;return he.createElement("div",{id:s,style:Wu},r)}function $u(e){let{id:s,announcement:r,ariaLiveType:n="assertive"}=e;const p={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 he.createElement("div",{id:s,style:p,role:"status","aria-live":n,"aria-atomic":!0},r)}function Uu(){const[e,s]=y.useState("");return{announce:y.useCallback(n=>{n!=null&&s(n)},[]),announcement:e}}const Ya=y.createContext(null);function qu(e){const s=y.useContext(Ya);y.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Ku(){const[e]=y.useState(()=>new Set),s=y.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[y.useCallback(n=>{let{type:p,event:m}=n;e.forEach(v=>{var i;return(i=v[p])==null?void 0:i.call(v,m)})},[e]),s]}const Vu={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},Xu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Yu(e){let{announcements:s=Xu,container:r,hiddenTextDescribedById:n,screenReaderInstructions:p=Vu}=e;const{announce:m,announcement:v}=Uu(),i=Zr("DndLiveRegion"),[o,l]=y.useState(!1);if(y.useEffect(()=>{l(!0)},[]),qu(y.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:b}=c;s.onDragMove&&m(s.onDragMove({active:g,over:b}))},onDragOver(c){let{active:g,over:b}=c;m(s.onDragOver({active:g,over:b}))},onDragEnd(c){let{active:g,over:b}=c;m(s.onDragEnd({active:g,over:b}))},onDragCancel(c){let{active:g,over:b}=c;m(s.onDragCancel({active:g,over:b}))}}),[m,s])),!o)return null;const u=he.createElement(he.Fragment,null,he.createElement(Hu,{id:n,value:p.draggable}),he.createElement($u,{id:i,announcement:v}));return r?ss.createPortal(u,r):u}var ot;(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"})(ot||(ot={}));function Br(){}function Gu(e,s){return y.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Qu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return y.useMemo(()=>[...s].filter(n=>n!=null),[...s])}const Pt=Object.freeze({x:0,y:0});function Zu(e,s){const r=Ir(e);if(!r)return"0 0";const n={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return n.x+"% "+n.y+"%"}function Ju(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return n-r}function eh(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function th(e,s){const r=Math.max(s.top,e.top),n=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-n,i=m-r;if(n<p&&r<m){const o=s.width*s.height,l=e.width*e.height,u=v*i,c=u/(o+l-u);return Number(c.toFixed(4))}return 0}const sh=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const p=[];for(const m of n){const{id:v}=m,i=r.get(v);if(i){const o=th(i,s);o>0&&p.push({id:v,data:{droppableContainer:m,value:o}})}}return p.sort(Ju)};function rh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ga(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Pt}function ih(e){return function(r){for(var n=arguments.length,p=new Array(n>1?n-1:0),m=1;m<n;m++)p[m-1]=arguments[m];return p.reduce((v,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const nh=ih(1);function Qa(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function oh(e,s,r){const n=Qa(s);if(!n)return e;const{scaleX:p,scaleY:m,x:v,y:i}=n,o=e.left-v-(1-p)*parseFloat(r),l=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:l,right:o+u,bottom:l+c,left:o}}const ah={ignoreTransform:!1};function ar(e,s){s===void 0&&(s=ah);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=_t(e).getComputedStyle(e);l&&(r=oh(r,l,u))}const{top:n,left:p,width:m,height:v,bottom:i,right:o}=r;return{top:n,left:p,width:m,height:v,bottom:i,right:o}}function ho(e){return ar(e,{ignoreTransform:!0})}function lh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function ch(e,s){return s===void 0&&(s=_t(e).getComputedStyle(e)),s.position==="fixed"}function dh(e,s){s===void 0&&(s=_t(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function Cn(e,s){const r=[];function n(p){if(s!=null&&r.length>=s||!p)return r;if(Sn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!nr(p)||Va(p)||r.includes(p))return r;const m=_t(e).getComputedStyle(p);return p!==e&&dh(p,m)&&r.push(p),ch(p,m)?r:n(p.parentNode)}return e?n(e):r}function Za(e){const[s]=Cn(e,1);return s??null}function Si(e){return!Gr||!e?null:Ls(e)?e:yn(e)?Sn(e)||e===Ps(e).scrollingElement?window:nr(e)?e:null:null}function Ja(e){return Ls(e)?e.scrollX:e.scrollLeft}function el(e){return Ls(e)?e.scrollY:e.scrollTop}function Vi(e){return{x:Ja(e),y:el(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function tl(e){return!Gr||!e?!1:e===document.scrollingElement}function sl(e){const s={x:0,y:0},r=tl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=n.y,i=e.scrollLeft>=n.x;return{isTop:p,isLeft:m,isBottom:v,isRight:i,maxScroll:n,minScroll:s}}const uh={x:.2,y:.2};function hh(e,s,r,n,p){let{top:m,left:v,right:i,bottom:o}=r;n===void 0&&(n=10),p===void 0&&(p=uh);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=sl(e),b={x:0,y:0},S={x:0,y:0},x={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+x.height?(b.y=dt.Backward,S.y=n*Math.abs((s.top+x.height-m)/x.height)):!u&&o>=s.bottom-x.height&&(b.y=dt.Forward,S.y=n*Math.abs((s.bottom-x.height-o)/x.height)),!g&&i>=s.right-x.width?(b.x=dt.Forward,S.x=n*Math.abs((s.right-x.width-i)/x.width)):!c&&v<=s.left+x.width&&(b.x=dt.Backward,S.x=n*Math.abs((s.left+x.width-v)/x.width)),{direction:b,speed:S}}function fh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:n,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:n,bottom:p,width:e.clientWidth,height:e.clientHeight}}function rl(e){return e.reduce((s,r)=>js(s,Vi(r)),Pt)}function mh(e){return e.reduce((s,r)=>s+Ja(r),0)}function ph(e){return e.reduce((s,r)=>s+el(r),0)}function il(e,s){if(s===void 0&&(s=ar),!e)return;const{top:r,left:n,bottom:p,right:m}=s(e);Za(e)&&(p<=0||m<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const gh=[["x",["left","right"],mh],["y",["top","bottom"],ph]];class kn{constructor(s,r){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 n=Cn(r),p=rl(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,i]of gh)for(const o of v)Object.defineProperty(this,o,{get:()=>{const l=i(n),u=p[m]-l;return this.rect[o]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class qs{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var p;(p=this.target)==null||p.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function vh(e){const{EventTarget:s}=_t(e);return e instanceof s?e:Ps(e)}function wi(e,s){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var Nt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Nt||(Nt={}));function fo(e){e.preventDefault()}function xh(e){e.stopPropagation()}var Ke;(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"})(Ke||(Ke={}));const nl={start:[Ke.Space,Ke.Enter],cancel:[Ke.Esc],end:[Ke.Space,Ke.Enter,Ke.Tab]},bh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ke.Right:return{...r,x:r.x+25};case Ke.Left:return{...r,x:r.x-25};case Ke.Down:return{...r,y:r.y+25};case Ke.Up:return{...r,y:r.y-25}}};class ol{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new qs(Ps(r)),this.windowListeners=new qs(_t(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Nt.Resize,this.handleCancel),this.windowListeners.add(Nt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Nt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&il(n),r(Pt)}handleKeyDown(s){if(wn(s)){const{active:r,context:n,options:p}=this.props,{keyboardCodes:m=nl,coordinateGetter:v=bh,scrollBehavior:i="smooth"}=p,{code:o}=s;if(m.end.includes(o)){this.handleEnd(s);return}if(m.cancel.includes(o)){this.handleCancel(s);return}const{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:Pt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:n.current,currentCoordinates:u});if(c){const g=Or(c,u),b={x:0,y:0},{scrollableAncestors:S}=n.current;for(const x of S){const a=s.code,{isTop:f,isRight:d,isLeft:h,isBottom:_,maxScroll:w,minScroll:k}=sl(x),j=fh(x),C={x:Math.min(a===Ke.Right?j.right-j.width/2:j.right,Math.max(a===Ke.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===Ke.Down?j.bottom-j.height/2:j.bottom,Math.max(a===Ke.Down?j.top:j.top+j.height/2,c.y))},E=a===Ke.Right&&!d||a===Ke.Left&&!h,N=a===Ke.Down&&!_||a===Ke.Up&&!f;if(E&&C.x!==c.x){const D=x.scrollLeft+g.x,A=a===Ke.Right&&D<=w.x||a===Ke.Left&&D>=k.x;if(A&&!g.y){x.scrollTo({left:D,behavior:i});return}A?b.x=x.scrollLeft-D:b.x=a===Ke.Right?x.scrollLeft-w.x:x.scrollLeft-k.x,b.x&&x.scrollBy({left:-b.x,behavior:i});break}else if(N&&C.y!==c.y){const D=x.scrollTop+g.y,A=a===Ke.Down&&D<=w.y||a===Ke.Up&&D>=k.y;if(A&&!g.x){x.scrollTo({top:D,behavior:i});return}A?b.y=x.scrollTop-D:b.y=a===Ke.Down?x.scrollTop-w.y:x.scrollTop-k.y,b.y&&x.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(s,js(Or(c,this.referenceCoordinates),b))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}ol.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:n=nl,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(n.start.includes(v)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function mo(e){return!!(e&&"distance"in e)}function po(e){return!!(e&&"delay"in e)}class En{constructor(s,r,n){var p;n===void 0&&(n=vh(s.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=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Ps(v),this.documentListeners=new qs(this.document),this.listeners=new qs(n),this.windowListeners=new qs(_t(v)),this.initialCoordinates=(p=Ir(m))!=null?p:Pt,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:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Nt.Resize,this.handleCancel),this.windowListeners.add(Nt.DragStart,fo),this.windowListeners.add(Nt.VisibilityChange,this.handleCancel),this.windowListeners.add(Nt.ContextMenu,fo),this.documentListeners.add(Nt.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(po(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(mo(r)){this.handlePending(r);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(s,r){const{active:n,onPending:p}=this.props;p(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Nt.Click,xh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Nt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:i}}=m;if(!p)return;const o=(r=Ir(s))!=null?r:Pt,l=Or(p,o);if(!n&&i){if(mo(i)){if(i.tolerance!=null&&wi(l,i.tolerance))return this.handleCancel();if(wi(l,i.distance))return this.handleStart()}if(po(i)&&wi(l,i.tolerance))return this.handleCancel();this.handlePending(i,l);return}s.cancelable&&s.preventDefault(),v(o)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ke.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const _h={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jn extends En{constructor(s){const{event:r}=s,n=Ps(r.target);super(s,_h,n)}}jn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const yh={move:{name:"mousemove"},end:{name:"mouseup"}};var Xi;(function(e){e[e.RightClick=2]="RightClick"})(Xi||(Xi={}));class Sh extends En{constructor(s){super(s,yh,Ps(s.event.target))}}Sh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return r.button===Xi.RightClick?!1:(n?.({event:r}),!0)}}];const Ci={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class wh extends En{constructor(s){super(s,Ci)}static setup(){return window.addEventListener(Ci.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Ci.move.name,s)};function s(){}}}wh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;const{touches:p}=r;return p.length>1?!1:(n?.({event:r}),!0)}}];var Ks;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ks||(Ks={}));var Fr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Fr||(Fr={}));function Ch(e){let{acceleration:s,activator:r=Ks.Pointer,canScroll:n,draggingRect:p,enabled:m,interval:v=5,order:i=Fr.TreeOrder,pointerCoordinates:o,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const b=Eh({delta:c,disabled:!m}),[S,x]=Iu(),a=y.useRef({x:0,y:0}),f=y.useRef({x:0,y:0}),d=y.useMemo(()=>{switch(r){case Ks.Pointer:return o?{top:o.y,bottom:o.y,left:o.x,right:o.x}:null;case Ks.DraggableRect:return p}},[r,p,o]),h=y.useRef(null),_=y.useCallback(()=>{const k=h.current;if(!k)return;const j=a.current.x*f.current.x,C=a.current.y*f.current.y;k.scrollBy(j,C)},[]),w=y.useMemo(()=>i===Fr.TreeOrder?[...l].reverse():l,[i,l]);y.useEffect(()=>{if(!m||!l.length||!d){x();return}for(const k of w){if(n?.(k)===!1)continue;const j=l.indexOf(k),C=u[j];if(!C)continue;const{direction:E,speed:N}=hh(k,C,d,s,g);for(const D of["x","y"])b[D][E[D]]||(N[D]=0,E[D]=0);if(N.x>0||N.y>0){x(),h.current=k,S(_,v),a.current=N,f.current=E;return}}a.current={x:0,y:0},f.current={x:0,y:0},x()},[s,_,n,x,m,v,JSON.stringify(d),JSON.stringify(b),S,l,w,u,JSON.stringify(g)])}const kh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function Eh(e){let{delta:s,disabled:r}=e;const n=Pr(s);return or(p=>{if(r||!n||!p)return kh;const m={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[dt.Backward]:p.x[dt.Backward]||m.x===-1,[dt.Forward]:p.x[dt.Forward]||m.x===1},y:{[dt.Backward]:p.y[dt.Backward]||m.y===-1,[dt.Forward]:p.y[dt.Forward]||m.y===1}}},[r,s,n])}function jh(e,s){const r=s!=null?e.get(s):void 0,n=r?r.node.current:null;return or(p=>{var m;return s==null?null:(m=n??p)!=null?m:null},[n,s])}function Nh(e,s){return y.useMemo(()=>e.reduce((r,n)=>{const{sensor:p}=n,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,n)}));return[...r,...m]},[]),[e,s])}var er;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(er||(er={}));var Yi;(function(e){e.Optimized="optimized"})(Yi||(Yi={}));const go=new Map;function Rh(e,s){let{dragging:r,dependencies:n,config:p}=s;const[m,v]=y.useState(null),{frequency:i,measure:o,strategy:l}=p,u=y.useRef(e),c=a(),g=Zs(c),b=y.useCallback(function(f){f===void 0&&(f=[]),!g.current&&v(d=>d===null?f:d.concat(f.filter(h=>!d.includes(h))))},[g]),S=y.useRef(null),x=or(f=>{if(c&&!r)return go;if(!f||f===go||u.current!==e||m!=null){const d=new Map;for(let h of e){if(!h)continue;if(m&&m.length>0&&!m.includes(h.id)&&h.rect.current){d.set(h.id,h.rect.current);continue}const _=h.node.current,w=_?new kn(o(_),_):null;h.rect.current=w,w&&d.set(h.id,w)}return d}return f},[e,m,r,c,o]);return y.useEffect(()=>{u.current=e},[e]),y.useEffect(()=>{c||b()},[r,c]),y.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),y.useEffect(()=>{c||typeof i!="number"||S.current!==null||(S.current=setTimeout(()=>{b(),S.current=null},i))},[i,c,b,...n]),{droppableRects:x,measureDroppableContainers:b,measuringScheduled:m!=null};function a(){switch(l){case er.Always:return!1;case er.BeforeDragging:return r;default:return!r}}}function Nn(e,s){return or(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Th(e,s){return Nn(e,s)}function Ah(e){let{callback:s,disabled:r}=e;const n=Qr(s),p=y.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(n)},[n,r]);return y.useEffect(()=>()=>p?.disconnect(),[p]),p}function Jr(e){let{callback:s,disabled:r}=e;const n=Qr(s),p=y.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(n)},[r]);return y.useEffect(()=>()=>p?.disconnect(),[p]),p}function Mh(e){return new kn(ar(e),e)}function vo(e,s,r){s===void 0&&(s=Mh);const[n,p]=y.useState(null);function m(){p(o=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=o??r)!=null?l:null}const u=s(e);return JSON.stringify(o)===JSON.stringify(u)?o:u})}const v=Ah({callback(o){if(e)for(const l of o){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=Jr({callback:m});return Yt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),n}function Dh(e){const s=Nn(e);return Ga(e,s)}const xo=[];function Lh(e){const s=y.useRef(e),r=or(n=>e?n&&n!==xo&&e&&s.current&&e.parentNode===s.current.parentNode?n:Cn(e):xo,[e]);return y.useEffect(()=>{s.current=e},[e]),r}function Ph(e){const[s,r]=y.useState(null),n=y.useRef(e),p=y.useCallback(m=>{const v=Si(m.target);v&&r(i=>i?(i.set(v,Vi(v)),new Map(i)):null)},[]);return y.useEffect(()=>{const m=n.current;if(e!==m){v(m);const i=e.map(o=>{const l=Si(o);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,Vi(l)]):null}).filter(o=>o!=null);r(i.length?new Map(i):null),n.current=e}return()=>{v(e),v(m)};function v(i){i.forEach(o=>{const l=Si(o);l?.removeEventListener("scroll",p)})}},[p,e]),y.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>js(m,v),Pt):rl(e):Pt,[e,s])}function bo(e,s){s===void 0&&(s=[]);const r=y.useRef(null);return y.useEffect(()=>{r.current=null},s),y.useEffect(()=>{const n=e!==Pt;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?Or(e,r.current):Pt}function Oh(e){y.useEffect(()=>{if(!Gr)return;const s=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function Ih(e,s){return y.useMemo(()=>e.reduce((r,n)=>{let{eventName:p,handler:m}=n;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function al(e){return y.useMemo(()=>e?lh(e):null,[e])}const _o=[];function Bh(e,s){s===void 0&&(s=ar);const[r]=e,n=al(r?_t(r):null),[p,m]=y.useState(_o);function v(){m(()=>e.length?e.map(o=>tl(o)?n:new kn(s(o),o)):_o)}const i=Jr({callback:v});return Yt(()=>{i?.disconnect(),v(),e.forEach(o=>i?.observe(o))},[e]),p}function ll(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return nr(s)?s:e}function Fh(e){let{measure:s}=e;const[r,n]=y.useState(null),p=y.useCallback(l=>{for(const{target:u}of l)if(nr(u)){n(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Jr({callback:p}),v=y.useCallback(l=>{const u=ll(l);m?.disconnect(),u&&m?.observe(u),n(u?s(u):null)},[s,m]),[i,o]=Lr(v);return y.useMemo(()=>({nodeRef:i,rect:r,setRef:o}),[r,i,o])}const zh=[{sensor:jn,options:{}},{sensor:ol,options:{}}],Wh={current:{}},jr={draggable:{measure:ho},droppable:{measure:ho,strategy:er.WhileDragging,frequency:Yi.Optimized},dragOverlay:{measure:ar}};class Vs extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const Hh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Br},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jr,measureDroppableContainers:Br,windowRect:null,measuringScheduled:!1},cl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Br,draggableNodes:new Map,over:null,measureDroppableContainers:Br},lr=y.createContext(cl),dl=y.createContext(Hh);function $h(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vs}}}function Uh(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:n}=r,p=new Vs(e.droppable.containers);return p.set(n,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:n,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||n!==m.key)return e;const v=new Vs(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:n}=s,p=e.droppable.containers.get(r);if(!p||n!==p.key)return e;const m=new Vs(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function qh(e){let{disabled:s}=e;const{active:r,activatorEvent:n,draggableNodes:p}=y.useContext(lr),m=Pr(n),v=Pr(r?.id);return y.useEffect(()=>{if(!s&&!n&&m&&v!=null){if(!wn(m)||document.activeElement===m.target)return;const i=p.get(v);if(!i)return;const{activatorNode:o,node:l}=i;if(!o.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[o.current,l.current]){if(!u)continue;const c=zu(u);if(c){c.focus();break}}})}},[n,s,p,v,m]),null}function ul(e,s){let{transform:r,...n}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...n}),r):r}function Kh(e){return y.useMemo(()=>({draggable:{...jr.draggable,...e?.draggable},droppable:{...jr.droppable,...e?.droppable},dragOverlay:{...jr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Vh(e){let{activeNode:s,measure:r,initialRect:n,config:p=!0}=e;const m=y.useRef(!1),{x:v,y:i}=typeof p=="boolean"?{x:p,y:p}:p;Yt(()=>{if(!v&&!i||!s){m.current=!1;return}if(m.current||!n)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=Ga(u,n);if(v||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Za(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,i,n,r])}const ei=y.createContext({...Pt,scaleX:1,scaleY:1});var es;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(es||(es={}));const Xh=y.memo(function(s){var r,n,p,m;let{id:v,accessibility:i,autoScroll:o=!0,children:l,sensors:u=zh,collisionDetection:c=sh,measuring:g,modifiers:b,...S}=s;const x=y.useReducer(Uh,void 0,$h),[a,f]=x,[d,h]=Ku(),[_,w]=y.useState(es.Uninitialized),k=_===es.Initialized,{draggable:{active:j,nodes:C,translate:E},droppable:{containers:N}}=a,D=j!=null?C.get(j):null,A=y.useRef({initial:null,translated:null}),M=y.useMemo(()=>{var Ae;return j!=null?{id:j,data:(Ae=D?.data)!=null?Ae:Wh,rect:A}:null},[j,D]),I=y.useRef(null),[L,F]=y.useState(null),[H,T]=y.useState(null),O=Zs(S,Object.values(S)),P=Zr("DndDescribedBy",v),B=y.useMemo(()=>N.getEnabled(),[N]),$=Kh(g),{droppableRects:X,measureDroppableContainers:U,measuringScheduled:W}=Rh(B,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),q=jh(C,j),R=y.useMemo(()=>H?Ir(H):null,[H]),z=Ee(),V=Th(q,$.draggable.measure);Vh({activeNode:j!=null?C.get(j):null,config:z.layoutShiftCompensation,initialRect:V,measure:$.draggable.measure});const K=vo(q,$.draggable.measure,V),ee=vo(q?q.parentElement:null),Z=y.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=N.getNodeFor((r=Z.current.over)==null?void 0:r.id),xe=Fh({measure:$.dragOverlay.measure}),be=(n=xe.nodeRef.current)!=null?n:q,Be=k?(p=xe.rect)!=null?p:K:null,ce=!!(xe.nodeRef.current&&xe.rect),nt=Dh(ce?null:K),pe=al(be?_t(be):null),je=Lh(k?se??q:null),Ye=Bh(je),Ze=ul(b,{transform:{x:E.x-nt.x,y:E.y-nt.y,scaleX:1,scaleY:1},activatorEvent:H,active:M,activeNodeRect:K,containerNodeRect:ee,draggingNodeRect:Be,over:Z.current.over,overlayNodeRect:xe.rect,scrollableAncestors:je,scrollableAncestorRects:Ye,windowRect:pe}),Re=R?js(R,E):null,re=Ph(je),fe=bo(re),ke=bo(re,[K]),Oe=js(Ze,fe),De=Be?nh(Be,Ze):null,Fe=M&&De?c({active:M,collisionRect:De,droppableRects:X,droppableContainers:B,pointerCoordinates:Re}):null,Ge=eh(Fe,"id"),[Ne,we]=y.useState(null),Q=ce?Ze:js(Ze,ke),oe=rh(Q,(m=Ne?.rect)!=null?m:null,K),ae=y.useRef(null),Y=y.useCallback((Ae,ye)=>{let{sensor:Me,options:et}=ye;if(I.current==null)return;const Ve=C.get(I.current);if(!Ve)return;const it=Ae.nativeEvent,Le=new Me({active:I.current,activeNode:Ve,event:it,options:et,context:Z,onAbort(He){if(!C.get(He))return;const{onDragAbort:gt}=O.current,ft={id:He};gt?.(ft),d({type:"onDragAbort",event:ft})},onPending(He,St,gt,ft){if(!C.get(He))return;const{onDragPending:Et}=O.current,$e={id:He,constraint:St,initialCoordinates:gt,offset:ft};Et?.($e),d({type:"onDragPending",event:$e})},onStart(He){const St=I.current;if(St==null)return;const gt=C.get(St);if(!gt)return;const{onDragStart:ft}=O.current,Dt={activatorEvent:it,active:{id:St,data:gt.data,rect:A}};ss.unstable_batchedUpdates(()=>{ft?.(Dt),w(es.Initializing),f({type:ot.DragStart,initialCoordinates:He,active:St}),d({type:"onDragStart",event:Dt}),F(ae.current),T(it)})},onMove(He){f({type:ot.DragMove,coordinates:He})},onEnd:Pe(ot.DragEnd),onCancel:Pe(ot.DragCancel)});ae.current=Le;function Pe(He){return async function(){const{active:gt,collisions:ft,over:Dt,scrollAdjustedTranslate:Et}=Z.current;let $e=null;if(gt&&Et){const{cancelDrop:Ot}=O.current;$e={activatorEvent:it,active:gt,collisions:ft,delta:Et,over:Dt},He===ot.DragEnd&&typeof Ot=="function"&&await Promise.resolve(Ot($e))&&(He=ot.DragCancel)}I.current=null,ss.unstable_batchedUpdates(()=>{f({type:He}),w(es.Uninitialized),we(null),F(null),T(null),ae.current=null;const Ot=He===ot.DragEnd?"onDragEnd":"onDragCancel";if($e){const It=O.current[Ot];It?.($e),d({type:Ot,event:$e})}})}}},[C]),te=y.useCallback((Ae,ye)=>(Me,et)=>{const Ve=Me.nativeEvent,it=C.get(et);if(I.current!==null||!it||Ve.dndKit||Ve.defaultPrevented)return;const Le={active:it};Ae(Me,ye.options,Le)===!0&&(Ve.dndKit={capturedBy:ye.sensor},I.current=et,Y(Me,ye))},[C,Y]),ne=Nh(u,te);Oh(u),Yt(()=>{K&&_===es.Initializing&&w(es.Initialized)},[K,_]),y.useEffect(()=>{const{onDragMove:Ae}=O.current,{active:ye,activatorEvent:Me,collisions:et,over:Ve}=Z.current;if(!ye||!Me)return;const it={active:ye,activatorEvent:Me,collisions:et,delta:{x:Oe.x,y:Oe.y},over:Ve};ss.unstable_batchedUpdates(()=>{Ae?.(it),d({type:"onDragMove",event:it})})},[Oe.x,Oe.y]),y.useEffect(()=>{const{active:Ae,activatorEvent:ye,collisions:Me,droppableContainers:et,scrollAdjustedTranslate:Ve}=Z.current;if(!Ae||I.current==null||!ye||!Ve)return;const{onDragOver:it}=O.current,Le=et.get(Ge),Pe=Le&&Le.rect.current?{id:Le.id,rect:Le.rect.current,data:Le.data,disabled:Le.disabled}:null,He={active:Ae,activatorEvent:ye,collisions:Me,delta:{x:Ve.x,y:Ve.y},over:Pe};ss.unstable_batchedUpdates(()=>{we(Pe),it?.(He),d({type:"onDragOver",event:He})})},[Ge]),Yt(()=>{Z.current={activatorEvent:H,active:M,activeNode:q,collisionRect:De,collisions:Fe,droppableRects:X,draggableNodes:C,draggingNode:be,draggingNodeRect:Be,droppableContainers:N,over:Ne,scrollableAncestors:je,scrollAdjustedTranslate:Oe},A.current={initial:Be,translated:De}},[M,q,Fe,De,C,be,Be,X,N,Ne,je,Oe]),Ch({...z,delta:E,draggingRect:De,pointerCoordinates:Re,scrollableAncestors:je,scrollableAncestorRects:Ye});const me=y.useMemo(()=>({active:M,activeNode:q,activeNodeRect:K,activatorEvent:H,collisions:Fe,containerNodeRect:ee,dragOverlay:xe,draggableNodes:C,droppableContainers:N,droppableRects:X,over:Ne,measureDroppableContainers:U,scrollableAncestors:je,scrollableAncestorRects:Ye,measuringConfiguration:$,measuringScheduled:W,windowRect:pe}),[M,q,K,H,Fe,ee,xe,C,N,X,Ne,U,je,Ye,$,W,pe]),Te=y.useMemo(()=>({activatorEvent:H,activators:ne,active:M,activeNodeRect:K,ariaDescribedById:{draggable:P},dispatch:f,draggableNodes:C,over:Ne,measureDroppableContainers:U}),[H,ne,M,K,f,P,C,Ne,U]);return he.createElement(Ya.Provider,{value:h},he.createElement(lr.Provider,{value:Te},he.createElement(dl.Provider,{value:me},he.createElement(ei.Provider,{value:oe},l)),he.createElement(qh,{disabled:i?.restoreFocus===!1})),he.createElement(Yu,{...i,hiddenTextDescribedById:P}));function Ee(){const Ae=L?.autoScrollEnabled===!1,ye=typeof o=="object"?o.enabled===!1:o===!1,Me=k&&!Ae&&!ye;return typeof o=="object"?{...o,enabled:Me}:{enabled:Me}}}),Yh=y.createContext(null),yo="button",Gh="Draggable";function Qh(e){let{id:s,data:r,disabled:n=!1,attributes:p}=e;const m=Zr(Gh),{activators:v,activatorEvent:i,active:o,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=y.useContext(lr),{role:b=yo,roleDescription:S="draggable",tabIndex:x=0}=p??{},a=o?.id===s,f=y.useContext(a?ei:Yh),[d,h]=Lr(),[_,w]=Lr(),k=Ih(v,s),j=Zs(r);Yt(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:_,data:j}),()=>{const E=c.get(s);E&&E.key===m&&c.delete(s)}),[c,s]);const C=y.useMemo(()=>({role:b,tabIndex:x,"aria-disabled":n,"aria-pressed":a&&b===yo?!0:void 0,"aria-roledescription":S,"aria-describedby":u.draggable}),[n,b,x,a,S,u.draggable]);return{active:o,activatorEvent:i,activeNodeRect:l,attributes:C,isDragging:a,listeners:n?void 0:k,node:d,over:g,setNodeRef:h,setActivatorNodeRef:w,transform:f}}function Zh(){return y.useContext(dl)}const Jh="Droppable",ef={timeout:25};function tf(e){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:p}=e;const m=Zr(Jh),{active:v,dispatch:i,over:o,measureDroppableContainers:l}=y.useContext(lr),u=y.useRef({disabled:r}),c=y.useRef(!1),g=y.useRef(null),b=y.useRef(null),{disabled:S,updateMeasurementsFor:x,timeout:a}={...ef,...p},f=Zs(x??n),d=y.useCallback(()=>{if(!c.current){c.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{l(Array.isArray(f.current)?f.current:[f.current]),b.current=null},a)},[a]),h=Jr({callback:d,disabled:S||!v}),_=y.useCallback((C,E)=>{h&&(E&&(h.unobserve(E),c.current=!1),C&&h.observe(C))},[h]),[w,k]=Lr(_),j=Zs(s);return y.useEffect(()=>{!h||!w.current||(h.disconnect(),c.current=!1,h.observe(w.current))},[w,h]),y.useEffect(()=>(i({type:ot.RegisterDroppable,element:{id:n,key:m,disabled:r,node:w,rect:g,data:j}}),()=>i({type:ot.UnregisterDroppable,key:m,id:n})),[n]),y.useEffect(()=>{r!==u.current.disabled&&(i({type:ot.SetDroppableDisabled,id:n,key:m,disabled:r}),u.current.disabled=r)},[n,m,r,i]),{active:v,rect:g,isOver:o?.id===n,node:w,over:o,setNodeRef:k}}function sf(e){let{animation:s,children:r}=e;const[n,p]=y.useState(null),[m,v]=y.useState(null),i=Pr(r);return!r&&!n&&i&&p(i),Yt(()=>{if(!m)return;const o=n?.key,l=n?.props.id;if(o==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,n,m]),he.createElement(he.Fragment,null,r,n?y.cloneElement(n,{ref:v}):null)}const rf={x:0,y:0,scaleX:1,scaleY:1};function nf(e){let{children:s}=e;return he.createElement(lr.Provider,{value:cl},he.createElement(ei.Provider,{value:rf},s))}const of={position:"fixed",touchAction:"none"},af=e=>wn(e)?"transform 250ms ease":void 0,lf=y.forwardRef((e,s)=>{let{as:r,activatorEvent:n,adjustScale:p,children:m,className:v,rect:i,style:o,transform:l,transition:u=af}=e;if(!i)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...of,width:i.width,height:i.height,top:i.top,left:i.left,transform:Js.Transform.toString(c),transformOrigin:p&&n?Zu(n,i):void 0,transition:typeof u=="function"?u(n):u,...o};return he.createElement(r,{className:v,style:g,ref:s},m)}),cf=e=>s=>{let{active:r,dragOverlay:n}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[i,o]of Object.entries(m.active))o!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,o));if(m!=null&&m.dragOverlay)for(const[i,o]of Object.entries(m.dragOverlay))o!==void 0&&n.node.style.setProperty(i,o);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&n.node.classList.add(v.dragOverlay),function(){for(const[o,l]of Object.entries(p))r.node.style.setProperty(o,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},df=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:Js.Transform.toString(s)},{transform:Js.Transform.toString(r)}]},uf={duration:250,easing:"ease",keyframes:df,sideEffects:cf({styles:{active:{opacity:"0"}}})};function hf(e){let{config:s,draggableNodes:r,droppableContainers:n,measuringConfiguration:p}=e;return Qr((m,v)=>{if(s===null)return;const i=r.get(m);if(!i)return;const o=i.node.current;if(!o)return;const l=ll(v);if(!l)return;const{transform:u}=_t(v).getComputedStyle(v),c=Qa(u);if(!c)return;const g=typeof s=="function"?s:ff(s);return il(o,p.draggable.measure),g({active:{id:m,data:i.data,node:o,rect:p.draggable.measure(o)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:n,measuringConfiguration:p,transform:c})})}function ff(e){const{duration:s,easing:r,sideEffects:n,keyframes:p}={...uf,...e};return m=>{let{active:v,dragOverlay:i,transform:o,...l}=m;if(!s)return;const u={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},c={scaleX:o.scaleX!==1?v.rect.width*o.scaleX/i.rect.width:1,scaleY:o.scaleY!==1?v.rect.height*o.scaleY/i.rect.height:1},g={x:o.x-u.x,y:o.y-u.y,...c},b=p({...l,active:v,dragOverlay:i,transform:{initial:o,final:g}}),[S]=b,x=b[b.length-1];if(JSON.stringify(S)===JSON.stringify(x))return;const a=n?.({active:v,dragOverlay:i,...l}),f=i.node.animate(b,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{f.onfinish=()=>{a?.(),d()}})}}let So=0;function mf(e){return y.useMemo(()=>{if(e!=null)return So++,So},[e])}const pf=he.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:n,style:p,transition:m,modifiers:v,wrapperElement:i="div",className:o,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:b,draggableNodes:S,droppableContainers:x,dragOverlay:a,over:f,measuringConfiguration:d,scrollableAncestors:h,scrollableAncestorRects:_,windowRect:w}=Zh(),k=y.useContext(ei),j=mf(c?.id),C=ul(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:b,draggingNodeRect:a.rect,over:f,overlayNodeRect:a.rect,scrollableAncestors:h,scrollableAncestorRects:_,transform:k,windowRect:w}),E=Nn(g),N=hf({config:n,draggableNodes:S,droppableContainers:x,measuringConfiguration:d}),D=E?a.setRef:void 0;return he.createElement(nf,null,he.createElement(sf,{animation:N},c&&j?he.createElement(lf,{key:j,id:c.id,ref:D,as:i,activatorEvent:u,adjustScale:s,className:o,transition:m,rect:E,style:{zIndex:l,...p},transform:C},r):null))}),hl=768;function gf(e){const s=window.matchMedia(`(max-width: ${hl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function vf(){return window.innerWidth<hl}function xf(){return!1}function fl(){return y.useSyncExternalStore(gf,vf,xf)}function Rn(e){return kt({queryKey:le.workspaces.list(e),queryFn:()=>ve.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ml(e){const s=at();return yt({mutationFn:r=>ve.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:le.workspaces.list(e)}),s.invalidateQueries({queryKey:le.tasks.all})}})}function pl(){const e=at();return yt({mutationFn:({id:s,commitMessage:r})=>ve.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.git.all})},onError:()=>{e.invalidateQueries({queryKey:le.git.all})}})}function bf(){const e=at();return yt({mutationFn:s=>ve.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Tn(){return yt({mutationFn:({workspaceId:e,editorType:s})=>ve.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function An(e,s={}){return kt({queryKey:le.workspaces.gitStatus(e),queryFn:()=>ve.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function gl(){const e=at();return yt({mutationFn:s=>ve.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})}})}function Mn(){const e=at();return yt({mutationFn:s=>ve.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:le.git.all})}})}function _f(e,s){const r=[];if(!e||e.length===0)return r;const n=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===rt.RUNNING||v.status===rt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),n&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Dn({isOpen:e,onClose:s,onConfirm:r,taskId:n,taskTitle:p,workspaces:m,isLoading:v}){const{t:i}=ue(),{data:o,isLoading:l}=Rn(m===void 0&&e?n:""),u=m??o,c=m===void 0&&e&&l,g=y.useMemo(()=>_f(u,i),[u,i]);return t.jsx(Kr,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((b,S)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:b})]},S))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const ge={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Gi={[ge.Review]:{label:"Review",icon:Oa,iconClass:"text-warning",accentClass:"text-warning"},[ge.Running]:{label:"Running",icon:Pa,iconClass:"text-info",accentClass:"text-info"},[ge.Pending]:{label:"Pending",icon:La,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ge.Done]:{label:"Done",icon:Da,iconClass:"text-success/80",accentClass:"text-success"},[ge.Cancelled]:{label:"Cancelled",icon:Ma,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},yf=[ge.Review,ge.Running,ge.Pending,ge.Done,ge.Cancelled],vl=y.createContext(null),Sf=3e4;function wf(e=Sf){const[,s]=y.useState(0);y.useEffect(()=>{const r=setInterval(()=>s(n=>n+1),e);return()=>clearInterval(r)},[e])}function Cf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?pt("{count}s ago",{count:s}):s<3600?pt("{count}m ago",{count:Math.floor(s/60)}):s<86400?pt("{count}h ago",{count:Math.floor(s/3600)}):pt("{count}d ago",{count:Math.floor(s/86400)})}function kf({task:e,status:s,isSelected:r,isAgentActive:n,project:p,onSelectTask:m,onTaskStatusChange:v,onDeleteTask:i,disableDrag:o}){const{t:l}=ue(),u=y.useContext(vl),c=y.useRef(null),g=!!e.projectArchivedAt,b=g||!!o,{attributes:S,listeners:x,setNodeRef:a,isDragging:f}=Qh({id:e.id,data:{task:e,fromStatus:s},disabled:b}),d=y.useCallback(M=>{c.current=M,a(M),u&&(M?u.registry.set(e.id,M):u.registry.delete(e.id))},[a,u,e.id]);y.useEffect(()=>()=>{u?.registry.delete(e.id)},[e.id,u]);const[h,_]=y.useState(null),[w,k]=y.useState(!1),j=y.useRef(null),C=y.useRef(null),E=y.useCallback(M=>{g||!v&&!i||(M.preventDefault(),_({x:M.clientX,y:M.clientY}))},[g,v,i]),N=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),D=y.useCallback(M=>{if(!o||g||!v&&!i)return;const I=M.touches[0];if(!I)return;const{clientX:L,clientY:F}=I;C.current=setTimeout(()=>{C.current=null,_({x:L,y:F})},500)},[o,g,v,i]);y.useEffect(()=>{if(!h)return;const M=I=>{j.current&&!j.current.contains(I.target)&&_(null)};return document.addEventListener("mousedown",M),document.addEventListener("touchstart",M),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("touchstart",M)}},[h]);const A=p?p.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>m(e.id),onContextMenu:E,onTouchStart:D,onTouchEnd:N,onTouchMove:N,title:A,"aria-label":A?`${e.title} — ${A}`:e.title,className:`flex items-center gap-2.5 mx-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
6
|
-
${f?"opacity-30":""}
|
|
7
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...b?{}:x,...b?{}:S,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:M,iconClass:I}=Gi[s];return t.jsx(M,{className:`${I} ${s===ge.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?l("源码已删除"):l("已删除")}),n&&t.jsxs("span",{className:"relative inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-success/70"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-success"})]}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:Cf(e.updatedAt)}),p&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${p.color.replace("text-","bg-")}`})]}),h&&t.jsxs("div",{ref:j,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:h.x,top:h.y},children:[v&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:l("Move to")}),yf.filter(M=>M!==s).map(M=>{const{icon:I,label:L,accentClass:F}=Gi[M];return t.jsxs("button",{onClick:()=>{v(e.id,M),_(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(I,{className:`w-3.5 h-3.5 ${F}`}),t.jsx("span",{className:"text-foreground/80",children:l(L)})]},M)})]}),i&&t.jsxs(t.Fragment,{children:[v&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{k(!0),_(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.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:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:l("Delete Task")})]})]})]}),t.jsx(Dn,{isOpen:w,onClose:()=>k(!1),onConfirm:()=>{i?.(e.id),k(!1)},taskId:e.id,taskTitle:e.title})]})}const Ef=y.memo(function({title:s,tasks:r,status:n,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:i,activeTaskIds:o,isDragging:l,dragFromStatus:u,onTaskStatusChange:c,onDeleteTask:g,disableDrag:b}){const{t:S}=ue(),[x,a]=y.useState(p);wf();const f=r.length===0,d=l&&u===n,h=l&&u!==n,{setNodeRef:_,isOver:w}=tf({id:`group-${n}`,data:{status:n}}),k=n===ge.Review,j=S(s),C=l?d&&(x||!0):x;return t.jsxs("div",{className:"mb-2","data-task-group-status":n,children:[t.jsxs("button",{onClick:()=>!l&&a(E=>!E),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:j}),k&&!f?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:C?t.jsx(ht,{size:12}):t.jsx(Mt,{size:12})})]}),h&&t.jsx("div",{ref:_,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
8
|
-
${w?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:w?S("Drop into {title}",{title:j}):S("Drop here")})}),C&&!h&&t.jsx("div",{ref:d?void 0:_,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
9
|
-
${w&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
10
|
-
${f&&l?"border border-dashed border-border mx-2":""}`,children:f?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:S("No tasks")}):r.map(E=>{const N=m===E.id,D=o?.has(E.id)??!1,A=E.projectId?i.find(M=>M.id===E.projectId):void 0;return t.jsx(kf,{task:E,status:n,isSelected:N,isAgentActive:D,project:A,onSelectTask:v,onTaskStatusChange:E.projectArchivedAt?void 0:c,onDeleteTask:E.projectArchivedAt?void 0:g,disableDrag:b},E.id)})})]})}),jf=12,Nf=50;function Rf({isOpen:e,onClose:s,tasks:r,projects:n,onSelectTask:p}){const{t:m}=ue(),[v,i]=y.useState(""),[o,l]=y.useState(0),u=y.useRef(null);y.useEffect(()=>{e&&(i(""),l(0))},[e]);const c=y.useMemo(()=>{const S=v.trim().toLowerCase();return S?r.filter(x=>x.title.toLowerCase().includes(S)).slice(0,Nf):r.slice(0,jf)},[r,v]);y.useEffect(()=>{l(0)},[v]),y.useEffect(()=>{u.current?.children[o]?.scrollIntoView({block:"nearest"})},[o]);const g=y.useCallback(S=>{p(S),s()},[p,s]),b=y.useCallback(S=>{if(S.key==="Escape")S.preventDefault(),s();else if(S.key==="ArrowDown")S.preventDefault(),l(x=>Math.min(x+1,c.length-1));else if(S.key==="ArrowUp")S.preventDefault(),l(x=>Math.max(x-1,0));else if(S.key==="Enter"&&!S.nativeEvent.isComposing){S.preventDefault();const x=c[o];x&&g(x.id)}},[s,c,o,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(_n,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:S=>i(S.target.value),onKeyDown:b,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((S,x)=>{const a=n.find(h=>h.id===S.projectId),{icon:f,iconClass:d}=Gi[S.status];return t.jsxs("button",{onClick:()=>g(S.id),onMouseEnter:()=>l(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
11
|
-
${x===o?"bg-accent":""}`,children:[t.jsx(f,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:S.title,children:S.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},S.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const Tf=260,Af=220;function Mf(e){const s={[ge.Review]:[],[ge.Running]:[],[ge.Pending]:[],[ge.Done]:[],[ge.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const Df=[{status:ge.Review,title:"Review",defaultOpen:!0},{status:ge.Running,title:"Running",defaultOpen:!0},{status:ge.Pending,title:"Pending",defaultOpen:!1},{status:ge.Done,title:"Done",defaultOpen:!1},{status:ge.Cancelled,title:"Cancelled",defaultOpen:!1}];function wo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:n,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:i,onCreateProject:o,isCreateActive:l,activeTaskIds:u,onTaskStatusChange:c,onDeleteTask:g}){const{t:b}=ue(),S=fl(),[x,a]=y.useState(null),[f,d]=y.useState(null),[h,_]=y.useState(!1),w=y.useRef(new Map),k=y.useRef(new Set),j=y.useRef(new Map),C=y.useMemo(()=>({registry:w.current}),[]),E=y.useCallback(P=>{P.remove(),k.current.delete(P)},[]),N=p?e.filter(P=>P.projectId===p):e,D=y.useCallback((P,B)=>{const $=document.querySelector(`[data-task-group-status="${P}"]`);if(!$)return null;const U=($.querySelector("button")??$).getBoundingClientRect();return U.width===0||U.height===0?null:new DOMRect(U.left+8,U.bottom+4,B.width,B.height)},[]),A=y.useCallback((P,B,$,X=!1)=>{const U=document.createElement("div");U.setAttribute("aria-hidden","true"),U.innerHTML=$;const W=U.firstElementChild;W&&(W.style.cssText="",W.className=W.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),W.style.pointerEvents="none",W.style.width=`${P.width}px`,W.style.height=`${P.height}px`,W.style.margin="0",W.style.backgroundColor="var(--sidebar-accent)",W.style.borderRadius="0.375rem",W.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",W.style.opacity="0.96",W.style.transition="none",W.setAttribute("tabindex","-1")),Object.assign(U.style,{position:"fixed",left:`${P.left}px`,top:`${P.top}px`,width:`${P.width}px`,height:`${P.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(U),k.current.add(U);const q=B.left-P.left,R=B.top-P.top;U.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${q}px, ${R}px)`,opacity:X?.12:.96,offset:1}],{duration:X?Af:Tf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>E(U),()=>E(U))},[E]);y.useLayoutEffect(()=>{const P=window.matchMedia("(prefers-reduced-motion: reduce)").matches,B=new Map;for(const $ of N){const X=w.current.get($.id);if(!X)continue;const U={status:$.status,rect:X.getBoundingClientRect(),html:X.outerHTML};if(B.set($.id,U),P)continue;const W=j.current.get($.id);if(!W||W.status===$.status)continue;const q=U.rect.left-W.rect.left,R=U.rect.top-W.rect.top;Math.abs(q)<1&&Math.abs(R)<1||A(W.rect,U.rect,W.html)}if(!P)for(const[$,X]of j.current){if(B.has($))continue;const U=N.find(q=>q.id===$);if(!U||U.status===X.status)continue;const W=D(U.status,X.rect);W&&A(X.rect,W,X.html,!0)}j.current=B},[N,A,D]),y.useEffect(()=>()=>{for(const P of k.current)P.remove();k.current.clear()},[]);const M=Qu(Gu(jn,{activationConstraint:{distance:8}})),I=y.useCallback(P=>{const B=P.active.data.current?.task,$=P.active.data.current?.fromStatus;B&&a(B),$&&d($)},[]),L=y.useCallback(P=>{a(null),d(null);const{active:B,over:$}=P;if(!$)return;const X=B.data.current?.task,U=B.data.current?.fromStatus,W=$.data.current?.status;!X||!U||!W||X.projectArchivedAt||U!==W&&c?.(X.id,W)},[c]),T=!!!(p?s.find(P=>P.id===p)??null:null)?.archivedAt,O=Mf(N);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[o&&t.jsxs("button",{onClick:o,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:b("New Project"),children:[t.jsx(yd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("New Project")})]}),t.jsxs("button",{onClick:i,disabled:!T,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
12
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:b(T?"New Task":"Deleted projects are read-only"),children:[t.jsx(Tu,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("New Task")})]}),t.jsxs("button",{onClick:()=>_(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:b("Search"),children:[t.jsx(_n,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:b("Search")})]})]}),N.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Rs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:b("No tasks")}),T&&i?t.jsx("button",{onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:b("New Task")}):null]}):t.jsx(vl.Provider,{value:C,children:t.jsxs(Xh,{sensors:M,onDragStart:I,onDragEnd:L,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:Df.map(({status:P,title:B,defaultOpen:$})=>t.jsx(Ef,{title:B,tasks:O[P],status:P,defaultOpen:$,selectedTaskId:r,onSelectTask:n,projects:s,activeTaskIds:u,isDragging:x!==null,dragFromStatus:f,onTaskStatusChange:c,onDeleteTask:g,disableDrag:S},P))}),t.jsx(pf,{dropAnimation:null,children:x?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:x.title,children:x.title})}):null})]})}),N.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:b("{count} tasks",{count:N.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:b("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:b("{count} tasks",{count:0})})}),t.jsx(Rf,{isOpen:h,onClose:()=>_(!1),tasks:N,projects:s,onSelectTask:n})]})}const Lf={damping:.7,stiffness:.05,mass:1.25},Pf=70,Of=1e3/60,If=350;let ti=!1;globalThis.document?.addEventListener("mousedown",()=>{ti=!0});globalThis.document?.addEventListener("mouseup",()=>{ti=!1});globalThis.document?.addEventListener("click",()=>{ti=!1});const Ln=(e={})=>{const[s,r]=y.useState(!1),[n,p]=y.useState(e.initial!==!1),[m,v]=y.useState(!1),i=y.useRef(null);i.current=e;const o=y.useCallback(()=>{if(!ti)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const h=d.getRangeAt(0);return h.commonAncestorContainer.contains(a.current)||a.current?.contains(h.commonAncestorContainer)},[]),l=y.useCallback(d=>{c.isAtBottom=d,p(d)},[]),u=y.useCallback(d=>{c.escapedFromLock=d,r(d)},[]),c=y.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(h){a.current&&(a.current.scrollTop=h,c.ignoreScrollToTop=a.current.scrollTop)},get targetScrollTop(){return!a.current||!f.current?0:a.current.scrollHeight-1-a.current.clientHeight},get calculatedTargetScrollTop(){if(!a.current||!f.current)return 0;const{targetScrollTop:h}=this;if(!e.targetScrollTop)return h;if(d?.targetScrollTop===h)return d.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(h,{scrollElement:a.current,contentElement:f.current}),h),0);return d={targetScrollTop:h,calculatedScrollTop:_},requestAnimationFrame(()=>{d=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Pf}}},[]),g=y.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||l(!0);const h=Date.now()+(Number(d.wait)||0),_=Ei(i.current,d.animation),{ignoreEscapes:w=!1}=d;let k,j=c.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=h+(d.duration??0);const C=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!c.isAtBottom)return c.animation=void 0,!1;const{scrollTop:N}=c,D=performance.now(),A=(D-(c.lastTick??D))/Of;if(c.animation||(c.animation={behavior:_,promise:E,ignoreEscapes:w}),c.animation.behavior===_&&(c.lastTick=D),o()||h>Date.now())return C();if(N<Math.min(j,c.calculatedTargetScrollTop)){if(c.animation?.behavior===_){if(_==="instant")return c.scrollTop=c.calculatedTargetScrollTop,C();c.velocity=(_.damping*c.velocity+_.stiffness*c.scrollDifference)/_.mass,c.accumulated+=c.velocity*A,c.scrollTop+=c.accumulated,c.scrollTop!==N&&(c.accumulated=0)}return C()}return k>Date.now()?(j=c.calculatedTargetScrollTop,C()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?g({animation:Ei(i.current,i.current.resize),ignoreEscapes:w,duration:Math.max(0,k-Date.now())||void 0}):c.isAtBottom)});return E.then(N=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),N))};return d.wait!==!0&&(c.animation=void 0),c.animation?.behavior===_?c.animation.promise:C()},[l,o,c]),b=y.useCallback(()=>{u(!0),l(!1)},[u,l]),S=y.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:h,ignoreScrollToTop:_}=c;let{lastScrollTop:w=h}=c;c.lastScrollTop=h,c.ignoreScrollToTop=void 0,_&&_>h&&(w=_),v(c.isNearBottom),setTimeout(()=>{if(c.resizeDifference||h===_)return;if(o()){u(!0),l(!1);return}const k=h>w,j=h<w;if(c.animation?.ignoreEscapes){c.scrollTop=w;return}j&&(u(!0),l(!1)),k&&u(!1),!c.escapedFromLock&&c.isNearBottom&&l(!0)},1)},[u,l,o,c]),x=y.useCallback(({target:d,deltaY:h})=>{let _=d;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===a.current&&h<0&&a.current.scrollHeight>a.current.clientHeight&&!c.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,c]),a=Co(d=>{a.current?.removeEventListener("scroll",S),a.current?.removeEventListener("wheel",x),d?.addEventListener("scroll",S,{passive:!0}),d?.addEventListener("wheel",x,{passive:!0})},[]),f=Co(d=>{if(c.resizeObserver?.disconnect(),!d)return;let h;c.resizeObserver=new ResizeObserver(([_])=>{const{height:w}=_.contentRect,k=w-(h??w);if(c.resizeDifference=k,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),v(c.isNearBottom),k>=0){const j=Ei(i.current,h?i.current.resize:i.current.initial);g({animation:j,wait:!0,preserveScrollPosition:!0,duration:j==="instant"?void 0:If})}else c.isNearBottom&&(u(!1),l(!0));h=w,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===k&&(c.resizeDifference=0)},1)})}),c.resizeObserver?.observe(d)},[]);return{contentRef:f,scrollRef:a,scrollToBottom:g,stopScroll:b,isAtBottom:n||m,isNearBottom:m,escapedFromLock:s,state:c}};function Co(e,s){const r=y.useCallback(n=>(r.current=n,e(n)),s);return r}const ki=new Map;function Ei(...e){const s={...Lf};let r=!1;for(const p of e){if(p==="instant"){r=!0;continue}typeof p=="object"&&(r=!1,s.damping=p.damping??s.damping,s.stiffness=p.stiffness??s.stiffness,s.mass=p.mass??s.mass)}const n=JSON.stringify(s);return ki.has(n)||ki.set(n,Object.freeze(s)),r?"instant":ki.get(n)}function Bf({content:e,children:s,className:r="",side:n="top"}){const p=n==="bottom"?"top-full mt-2":"bottom-full mb-2",m=n==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return t.jsxs("div",{className:`group/tooltip relative ${r}`,children:[s,t.jsxs("div",{className:`absolute ${p} left-1/2 -translate-x-1/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-[100] shadow-lg`,children:[e,t.jsx("div",{className:`absolute ${m} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function br(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ff(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Pn({usage:e,tooltipSide:s="top"}){const{t:r}=ue();if(!e)return null;const n=e.modelContextWindow,p=n?e.totalTokens/n:0,m=n?Math.min(Math.round(p*100),100):null,v=n?Ff(p):"text-neutral-400",i=n?t.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:br(e.totalTokens),max:br(n)})}):t.jsx("span",{children:r("已使用: {used} tokens",{used:br(e.totalTokens)})});return t.jsx(Bf,{content:i,side:s,children:t.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:[t.jsx(tu,{size:14,className:v}),t.jsxs("span",{className:`tabular-nums ${v}`,children:[br(e.totalTokens),m!==null&&t.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",m,"%"]})]})]})})}const zf="/api";async function Wf(e){const s=new FormData;s.append("file",e);const r=await fetch(`${zf}/attachments/upload`,{method:"POST",body:s});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(n.error||`Upload failed (${r.status})`)}return r.json()}let Hf=0;function si(){const[e,s]=y.useState([]),r=y.useRef(e);r.current=e;const n=y.useCallback(async c=>{const g=c.map(b=>({tempId:`tmp-${++Hf}`,file:b,progress:0,status:"uploading"}));s(b=>[...b,...g]),await Promise.allSettled(g.map(async b=>{try{const S=await Wf(b.file);s(x=>x.map(a=>a.tempId===b.tempId?{...a,status:"done",progress:100,attachment:S}:a))}catch(S){s(x=>x.map(a=>a.tempId===b.tempId?{...a,status:"error",error:S instanceof Error?S.message:"Upload failed"}:a))}}))},[]),p=y.useCallback(()=>r.current.filter(c=>c.status==="done"&&c.attachment).map(c=>c.attachment),[]),m=y.useCallback(c=>{s(g=>g.filter(b=>b.tempId!==c))},[]),v=y.useCallback(()=>{s([])},[]),i=y.useCallback(c=>{c.length!==0&&s(g=>{const b=new Set(g.map(x=>x.attachment?.id??x.tempId)),S=c.filter(x=>{const a=x.attachment?.id??x.tempId;return b.has(a)?!1:(b.add(a),!0)});return S.length>0?[...g,...S]:g})},[]),o=y.useCallback(()=>{const c=p();return c.length===0?"":c.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
|
|
13
|
-
`)},[p]),l=e.length>0,u=e.some(c=>c.status==="uploading");return{files:e,addFiles:n,removeFile:m,clear:v,restoreFiles:i,buildMarkdownLinks:o,getDoneAttachments:p,hasFiles:l,isUploading:u}}function $f(e){const s=y.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return kt({queryKey:["attachments","metadata",s],queryFn:()=>ve.get("/attachments/metadata",{params:{ids:s.join(",")}}),enabled:s.length>0,staleTime:300*1e3})}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 ri({files:e,onRemove:s}){return e.length===0?null:t.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>t.jsx(Kf,{item:r,onRemove:s},r.tempId))})}function Kf({item:e,onRemove:s}){const r=e.file.type.startsWith("image/"),n=e.status==="error",p=e.status==="uploading";return t.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${n?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[r&&e.status==="done"&&e.attachment?t.jsx("img",{src:`${Uf}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):t.jsx("span",{className:"flex-shrink-0",children:p?t.jsx(ze,{size:16,className:"animate-spin text-neutral-400"}):r?t.jsx(bn,{size:16,className:"text-neutral-400"}):t.jsx(vn,{size:16,className:"text-neutral-400"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate font-medium",children:e.file.name}),n?t.jsx("div",{className:"truncate text-red-500",children:e.error}):t.jsx("div",{className:"text-neutral-400",children:qf(e.file.size)})]}),t.jsx("button",{onClick:()=>s(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:t.jsx(Ht,{size:10})})]})}const Vf=10,Xf=24,xl=Vf*Xf,Yf=8;function Gf(e,s=xl){return e>s+Yf}function Qf(e,s){return e.includes(s)?e:[...e,s]}function Zf(e,s){return e.filter(r=>r!==s)}function Jf(e,s){const r=new Map(s.map(n=>[n.id,n]));return e.map(n=>r.get(n)).filter(n=>!!n).map(n=>({memberId:n.id,label:n.name}))}const ii=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function ko(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function em(e,s=[],r=[]){const n=new Set(r.filter(m=>ii.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!n.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const i=ko(m.sortTime)-ko(v.sortTime);return i!==0?i:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function tm(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function sm(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function rm(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const v=r[p];return v?`${v} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function im(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function nm({status:e}){const{t:s}=ue();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(tm(e))})}function om({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:n,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:i,onToggleStopConfirm:o}){const{t:l}=ue(),[u,c]=y.useState(im),g=y.useMemo(()=>e.filter(S=>ii.has(S.status)).sort((S,x)=>Date.parse(x.updatedAt??x.createdAt??"")-Date.parse(S.updatedAt??S.createdAt??"")),[e]);if(g.length===0)return null;const b=rm(g,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(S=>!S),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:b})]}),u?t.jsx(ht,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Wa,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(S=>{const x=s.get(S.memberId),a=r.get(S.workRequestId),f=!!(S.sessionId&&n),d=!!x,h=i===S.id,_=m&&v===S.memberId,w=a?.instruction??S.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:w,className:G("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",f?"cursor-pointer hover:bg-white":"cursor-default"),role:f?"button":void 0,tabIndex:f?0:void 0,onClick:()=>S.sessionId&&n?.(S.sessionId),onKeyDown:k=>{!f||!S.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),n?.(S.sessionId))},children:[t.jsx(At,{name:x?.name??l("Agent"),avatar:x?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:x?.name??l("Agent")}),t.jsx("span",{className:G("shrink-0",sm(S.status)),children:t.jsx(nm,{status:S.status})})]}),f&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),S.sessionId&&n?.(S.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${x?.name??l("Agent")}`,children:t.jsx(Ki,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),o(S.id)},onKeyDown:k=>k.stopPropagation(),disabled:_,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${x?.name??l("Agent")}`,children:t.jsx(Ns,{size:12})})]}),d&&h&&x&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:_,onClick:()=>p(x.id,!1),children:[t.jsx(Ns,{size:11}),t.jsx("span",{children:l(_?"Stopping":"Stop only")})]}),t.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:_,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(x.id,!0),children:[t.jsx(Ha,{size:11}),t.jsx("span",{children:l(_?"Stopping":"Stop + clear queue")})]})]})]},S.id)})})]})}const zr="/api",am=240;let Eo=0;function lm(e,s){return Eo+=1,{id:`pending-room-message-${Date.now()}-${Eo}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function bl(e){return"pendingStatus"in e}const cm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${zr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function dm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function um(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Qi(e,s){if(s.length===0)return e;const r=new Set(s.map(um));return e.split(`
|
|
14
|
-
`).map(n=>{const p=n.match(/^\s*/)?.[0]??"",m=n.trimStart();for(const v of r){if(m===v)return null;if(m.startsWith(`${v} `)||m.startsWith(`${v} `))return`${p}${m.slice(v.length).trimStart()}`}return n}).filter(n=>n!=null).join(`
|
|
15
|
-
`).replace(/\n{3,}/g,`
|
|
16
|
-
|
|
17
|
-
`).trim()}function hm(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zi(e,s){return e instanceof Error?e.message:s}function fm(e,s=am){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function mm(e,s){const n=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!n||n.index==null?null:{start:n.index+n[1].length,end:s,query:n[2]??""}}function pm(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function jo(e){return e.membershipStatus!=="REMOVED"}function gm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function vm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function xm(e,s){const r=e.mentions??[],n=e.contentPreview??e.content;if(r.length===0)return n;const p=r.map(v=>gm(v,s)).filter(v=>v&&!n.includes(`@${v}`));if(p.length===0)return n;const m=p.map(v=>`@${v}`).join(" ");return n.trimEnd()?`${n.trimEnd()} ${m}`:m}function bm(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const n=r.get(e.senderInvocationId);if(n?.memberId&&s.has(n.memberId))return s.get(n.memberId)??null}return null}function _m({content:e,isUser:s}){return t.jsx("div",{className:G("prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(un,{urlTransform:cm,components:hn,children:e})})}function ym({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:n}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,i)=>[v.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const i=`${zr}${v.url}`;if(v.mimeType.startsWith("image/")){const l=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>n(p,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:i,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(vn,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:dm(v.sizeBytes)})]}),t.jsx(gn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Sm({message:e,content:s,attachmentIds:r,isUser:n,tone:p,onOpenImage:m}){const v=y.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:i=[],isLoading:o}=$f(v),l=i.length>0?Qi(s,i):s;return t.jsxs(t.Fragment,{children:[l.trim()&&t.jsx(km,{message:e,content:l,attachments:i,isUser:n,tone:p}),t.jsx(ym,{hasAttachmentIds:v.length>0,attachments:i,isLoading:o,onOpenImage:m})]})}function wm({images:e,index:s,onClose:r,onSelect:n}){const p=e[s];if(!p)return null;const m=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Ht,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>n(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(Wd,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${zr}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${zr}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(gn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>n(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Mt,{size:24,"aria-hidden":!0})})]})}function Cm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:n}){const m=[e.trim(),s].filter(Boolean).join(`
|
|
18
|
-
|
|
19
|
-
`);return m?{content:m,mentions:n,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function km({message:e,content:s,attachments:r,isUser:n,tone:p=n?"user":"agent"}){const{t:m}=ue(),v=y.useId(),i=y.useRef(null),[o,l]=y.useState(null),[u,c]=y.useState(!1),[g,b]=y.useState(null),S=ud(e.teamRunId,e.id,!1),x=S.data?.content,a=x?Qi(x,r):void 0,d=!!(a&&a!==s)?a:s,h=!!(e.isTruncated&&!bl(e)),_=o?.messageId===e.id&&o.content===d&&o.expanded,w=y.useCallback(()=>{const N=i.current;N&&c(Gf(N.scrollHeight))},[]);y.useLayoutEffect(()=>{w();const N=i.current;if(!N)return;const D=window.requestAnimationFrame(w),A=typeof ResizeObserver>"u"?null:new ResizeObserver(w);return A?.observe(N),window.addEventListener("resize",w),()=>{window.cancelAnimationFrame(D),A?.disconnect(),window.removeEventListener("resize",w)}},[d,w]);const k=y.useCallback(async()=>{if(b(null),_){l({messageId:e.id,content:d,expanded:!1});return}if(h&&!x){const N=await S.refetch();if(N.error){b(Zi(N.error,m("Failed to load full message")));return}const D=N.data?.content?Qi(N.data.content,r):d;l({messageId:e.id,content:D,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,h,x,S,_,e.id,d,m]),j=(u||h)&&!_,C=u||h,E=S.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:v,ref:i,onLoadCapture:w,className:G("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:xl}:void 0,children:[t.jsx(_m,{content:d,isUser:n}),j&&t.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),C&&t.jsxs("button",{type:"button","aria-expanded":_,"aria-controls":v,"aria-label":m(_?"Collapse message":"Expand full message"),disabled:E,onClick:()=>{k()},className:G("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",E?"cursor-wait opacity-70":""),children:[_?t.jsx(Wa,{size:13}):t.jsx(ht,{size:13}),t.jsx("span",{children:m(E?"Loading":_?"Collapse message":"Expand full message")})]}),g&&t.jsx("div",{className:G("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:g})]})}function _l({senderName:e,avatar:s,createdAt:r,isUser:n,isSystem:p,children:m,headerAddon:v,bubbleClassName:i,isPending:o}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:G("group flex items-start gap-3",n?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!n&&t.jsx(At,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:G("flex min-w-0 max-w-[min(86%,46rem)] flex-col",n?"items-end":"items-start"),children:[t.jsxs("div",{className:G("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",n?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:hm(r)}),v]}),t.jsx("div",{className:G("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",n?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,o?"opacity-70":""),children:m})]}),n&&t.jsx(At,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Em({message:e,senderName:s,senderMember:r,memberById:n,displayContent:p,onOpenImage:m}){const{t:v}=ue(),i=e.senderType==="user",o=e.senderType==="system",l=bl(e)?e.pendingStatus:null,u=e.mentions??[],c=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",b=g?vm(e,n):[],S=t.jsxs(t.Fragment,{children:[g&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:b.join(", "),children:[t.jsx(cu,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),b.length>0?`: ${b.join(", ")}`:""]})]}),!o&&c>0&&u.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",c]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(_l,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:o,headerAddon:S,bubbleClassName:i&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Sm,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:i&&l!=="failed",tone:o?"system":void 0,onOpenImage:m})})}function jm({request:e,member:s,onApprove:r,onReject:n,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:i}=ue();return t.jsx(_l,{senderName:s?.name??i("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Cs,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??fm(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(bt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:n,children:[t.jsx(Ht,{size:12}),t.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function yl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:n,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:i,centered:o}){const{t:l}=ue(),u=wa(e.id),c=Ca(e.id),g=ka(e.id),[b,S]=y.useState(""),[x,a]=y.useState(!1),[f,d]=y.useState(null),[h,_]=y.useState(0),[w,k]=y.useState([]),[j,C]=y.useState(!1),[E,N]=y.useState(null),[D,A]=y.useState([]),[M,I]=y.useState(null),L=y.useRef(null),F=y.useRef(null),{files:H,addFiles:T,removeFile:O,clear:P,restoreFiles:B,buildMarkdownLinks:$,getDoneAttachments:X,isUploading:U}=si(),W=H.some(Q=>Q.status==="done"&&Q.attachment),[q,R]=y.useState(null),{scrollRef:z,contentRef:V,isAtBottom:K,scrollToBottom:ee}=Ln({resize:"smooth",initial:"instant"}),Z=y.useMemo(()=>new Map((e.members??[]).map(Q=>[Q.id,Q])),[e.members]),se=y.useMemo(()=>(e.members??[]).filter(jo),[e.members]),xe=y.useMemo(()=>new Map((e.invocations??[]).map(Q=>[Q.id,Q])),[e.invocations]),be=y.useMemo(()=>{const Q=new Set(s.map(ae=>ae.id)),oe=D.filter(ae=>!Q.has(ae.id));return[...s,...oe].sort((ae,Y)=>{const te=Date.parse(ae.createdAt??""),ne=Date.parse(Y.createdAt??"");return(Number.isNaN(te)?0:te)-(Number.isNaN(ne)?0:ne)})},[s,D]),Be=y.useMemo(()=>new Map((e.workRequests??[]).map(Q=>[Q.id,Q])),[e.workRequests]),ce=y.useMemo(()=>em(be,e.workRequests??[],e.invocations??[]),[be,e.invocations,e.workRequests]),nt=y.useMemo(()=>(e.invocations??[]).filter(Q=>ii.has(Q.status)),[e.invocations]),pe=y.useMemo(()=>w.map(Q=>Z.get(Q)).filter(Q=>!!Q).filter(jo),[Z,w]),je=y.useMemo(()=>{const Q=f?.query??"";return se.filter(oe=>pm(oe,Q)).sort((oe,ae)=>{const Y=w.includes(oe.id),te=w.includes(ae.id);return Y!==te?Y?1:-1:oe.name.localeCompare(ae.name)})},[se,f?.query,w]),Ye=!r&&(x||!!f)&&je.length>0,Ze=y.useCallback((Q,oe)=>{if(oe==null){d(null);return}d(mm(Q,oe)),_(0)},[]),Re=y.useCallback(Q=>{k(ne=>Qf(ne,Q.id));const oe=`@${Q.name} `;if(f){const ne=`${b.slice(0,f.start)}${oe}${b.slice(f.end)}`,me=f.start+oe.length;S(ne),d(null),a(!1),requestAnimationFrame(()=>{L.current?.focus(),L.current?.setSelectionRange(me,me)});return}const ae=b.length===0||/\s$/.test(b)?"":" ",Y=`${b}${ae}${oe}`,te=Y.length;S(Y),a(!1),requestAnimationFrame(()=>{L.current?.focus(),L.current?.setSelectionRange(te,te)})},[b,f]),re=y.useCallback(Q=>{k(oe=>Zf(oe,Q))},[]),fe=y.useCallback(Q=>{const oe=Q.target.value;S(oe),N(null);const ae=Q.target;ae.style.height="auto",ae.style.height=`${Math.max(i?40:72,Math.min(ae.scrollHeight,i?140:240))}px`,a(!1),Ze(oe,ae.selectionStart)},[i,Ze]),ke=y.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&(T(Array.from(oe)),N(null)),Q.target.value=""},[T]),Oe=y.useCallback(Q=>{const oe=[];for(const ae of Q.clipboardData.items)if(ae.kind==="file"){const Y=ae.getAsFile();Y&&oe.push(Y)}oe.length>0&&(Q.preventDefault(),T(oe),N(null))},[T]),De=y.useCallback(async()=>{if(r||j||U)return;const Q=$(),oe=X().map(Ee=>Ee.id),ae=Jf(w,se),Y=Cm({draft:b,attachmentMarkdown:Q,attachmentIds:oe,mentions:ae});if(!Y||!b.trim()&&!W)return;const te=lm(e.id,Y),ne=b,me=w,Te=H;A(Ee=>[...Ee,te]),S(""),k([]),a(!1),d(null),P(),L.current&&(L.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>ee()),C(!0),N(null);try{const Ee=await p(Y);A(Ae=>Ae.filter(ye=>ye.id!==te.id)),Ee&&typeof Ee=="object"&&"id"in Ee&&requestAnimationFrame(()=>ee())}catch(Ee){const Ae=Ee instanceof Error?Ee.message:"Failed to send room message";A(ye=>ye.map(Me=>Me.id===te.id?{...Me,pendingStatus:"failed",error:Ae}:Me)),S(ye=>ye.length===0?ne:ye),k(ye=>ye.length===0?me:ye),B(Te),N(Ae),requestAnimationFrame(()=>ee())}finally{C(!1)}},[se,H,$,P,i,b,X,W,j,U,p,r,B,ee,w,e.id]),Fe=y.useCallback(Q=>{const oe=Q.nativeEvent.isComposing||Q.nativeEvent.keyCode===229;if(Ye){if(Q.key==="ArrowDown"){Q.preventDefault(),_(ae=>(ae+1)%je.length);return}if(Q.key==="ArrowUp"){Q.preventDefault(),_(ae=>(ae-1+je.length)%je.length);return}if(Q.key==="Enter"&&!oe||Q.key==="Tab"){Q.preventDefault();const ae=je[h]??je[0];ae&&Re(ae);return}if(Q.key==="Escape"){Q.preventDefault(),d(null),a(!1);return}}Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!oe&&(Q.preventDefault(),De())},[Re,De,h,je,Ye]);y.useEffect(()=>{S(""),k([]),a(!1),d(null),N(null),A([]),P(),I(null),L.current&&(L.current.style.height=i?"40px":"72px")},[P,i,e.id]);const Ge=u.isError?u.error:c.isError?c.error:null,Ne=u.isPending||c.isPending,we=y.useCallback((Q,oe)=>{g.mutate({memberId:Q,cancelQueued:oe},{onSuccess:()=>I(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[q&&t.jsx(wm,{images:q.images,index:q.index,onClose:()=>R(null),onSelect:Q=>R(oe=>oe&&{...oe,index:Q})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:z,className:G("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:V,className:G(i?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[ce.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(us,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:l("No room messages yet")})]}):ce.map(Q=>{if(Q.kind==="pendingApproval"){const ne=Q.request,me=Z.get(ne.targetMemberId),Te=u.isPending&&u.variables===ne.id,Ee=c.isPending&&c.variables===ne.id;return t.jsx(jm,{request:ne,member:me,onApprove:()=>u.mutate(ne.id),onReject:()=>c.mutate(ne.id),isActionPending:Ne,isApprovePending:Te,isRejectPending:Ee},Q.key)}const oe=Q.message,ae=bm(oe,Z,xe),Y=oe.senderType==="user"?l("你"):oe.senderType==="system"?l("System"):ae?.name??l("Agent"),te=xm(oe,Z);return t.jsx(Em,{message:oe,senderName:Y,senderMember:ae,memberById:Z,displayContent:te,onOpenImage:(ne,me)=>R({images:ne,index:me})},Q.key)}),Ge&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(Ge,l("Failed to update work request"))}),g.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(g.error,l("Failed to stop member work"))})]})}),!K&&t.jsxs("button",{type:"button",onClick:()=>ee(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(Qs,{size:14}),t.jsx("span",{children:l("Back to bottom")})]})]}),t.jsx("div",{className:G("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:G(o&&"max-w-4xl mx-auto"),children:[t.jsx(om,{invocations:nt,memberById:Z,workRequestById:Be,onViewInvocationSession:m,onStopMember:we,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:M,onToggleStopConfirm:Q=>I(oe=>oe===Q?null:Q)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:n??l("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ye&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:l(f?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:je.map((Q,oe)=>{const ae=w.includes(Q.id),Y=oe===h;return t.jsxs("button",{type:"button",onMouseEnter:()=>_(oe),onMouseDown:te=>{te.preventDefault(),Re(Q)},className:G("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",Y?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(At,{name:Q.name,avatar:Q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:Q.name}),ae&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:l("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Q.providerId,Q.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(no,{size:15,className:"text-neutral-400"})]},Q.id)})})]}),pe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:pe.map(Q=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Q.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Q.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>re(Q.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:l("Remove mention"),"aria-label":`${l("Remove mention")} ${Q.name}`,children:t.jsx(Ht,{size:12})})]},Q.id))}),t.jsx(ri,{files:H,onRemove:O}),t.jsx("textarea",{ref:L,value:b,rows:i?1:void 0,onChange:fe,onKeyDown:Fe,onPaste:Oe,onClick:Q=>Ze(b,Q.currentTarget.selectionStart),onSelect:Q=>Ze(b,Q.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:G("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:G("flex items-center justify-between",i?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:ke}),t.jsx("button",{type:"button",onClick:()=>F.current?.click(),title:l("Upload file"),"aria-label":l("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Vr,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{a(Q=>!Q),d(null),requestAnimationFrame(()=>L.current?.focus())},disabled:pe.length===0&&se.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:G("rounded-lg transition-colors",i?"p-1.5":"p-2",x?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",pe.length===0&&se.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(no,{size:i?15:18})}),pe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[pe.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{De()},disabled:r||j||U||!b.trim()&&!W,title:l(U?"Uploading...":j?"发送中...":"发送"),"aria-label":l(U?"Uploading...":j?"发送中...":"发送"),className:G("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(b.trim()||W)&&!r&&!j&&!U?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||U?"opacity-70":""),children:t.jsx(Xr,{size:i?15:18})})]}),E&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:E})]})]})})]})}function Nm(e){return e?e.slice(0,8):""}function No(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function On(e){return e?.workspaceKind===lt.MAIN_DIRECTORY}function hs(e){return e?On(e)?"Project directory":e.branchName:"—"}function rs(e){return e?.workingDir||e?.worktreePath||void 0}function In(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),n=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?n.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,o=!!(p&&m.id===p),l=o?"main":m.parentWorkspaceId?"child":"root",u=i?.name??(m.ownerMemberId?`Member ${Nm(m.ownerMemberId)}`:void 0),c=On(m)?"Project directory":o?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:o?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?hs(v):void 0,isMain:o}}).sort((m,v)=>{const i=l=>l.kind==="main"?0:l.kind==="child"?1:2,o=i(m)-i(v);return o!==0?o:No(m.workspace.createdAt)-No(v.workspace.createdAt)})}function Sl(e,s,r){if(e?.length)return r&&e.some(n=>n.id===r)?r:s?.mainWorkspaceId&&e.some(n=>n.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(n=>n.status===Rt.ACTIVE)?.id??e[0]?.id}function wl(e,s){return!e||e.status!==Rt.ACTIVE||On(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Cl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Bn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Rm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],kl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Tm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],El=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Am=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Ws(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Bn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function _s(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Bn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ji(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Bn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Mm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Dm(e){return{name:e.name.trim(),aliases:Mm(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Ro(e,s){return e instanceof Error?e.message:s}function To(e){return e.membershipStatus!=="REMOVED"}function Ji(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Ao(e){return Ji(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Mo(e){return kl.find(s=>s.value===e)?.label??e}function Lm(e){return El.find(s=>s.value===e)?.label??e}function Ft({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Do({icon:e,title:s,description:r,action:n}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,n?t.jsx("div",{className:"mt-4",children:n}):null]})}function Pm({isOpen:e,onClose:s,teamRun:r}){const{t:n}=ue(),{data:p=[]}=Ea(),{data:m=[]}=Ms(),v=hd(r.id),i=fd(r.id),o=md(r.id),l=y.useRef(!1),[u,c]=y.useState("edit"),[g,b]=y.useState(null),[S,x]=y.useState(""),[a,f]=y.useState(Ws()),[d,h]=y.useState(null),[_,w]=y.useState(null),k=r.members??[],j=y.useMemo(()=>k.filter(To),[k]),C=y.useMemo(()=>_&&To(_)&&!j.some(q=>q.id===_.id)?[...j,_]:j,[_,j]),E=g?j.find(q=>q.id===g)??null:null,N=_?.id===g?_:E,D=S?p.find(q=>q.id===S)??null:null,A=v.isPending||i.isPending||o.isPending,M=C.filter(Ji).length,I=y.useMemo(()=>{const q=m.map(({provider:R,availability:z})=>({value:R.id,label:R.name+(z.type==="NOT_FOUND"?n(" (不可用)"):""),disabled:z.type==="NOT_FOUND"}));return a.providerId&&!q.some(R=>R.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${n(" (不可用)")}`,disabled:!0}),q},[a.providerId,m,n]);y.useEffect(()=>{if(!e){l.current=!1,w(null);return}if(l.current)return;l.current=!0;const q=C[0]??null;c(q?"edit":"add-preset"),b(q?.id??null),x(""),f(q?_s(q):Ws()),h(null)},[C,e]),y.useEffect(()=>{_&&j.some(q=>q.id===_.id)&&w(null)},[_,j]),y.useEffect(()=>{u==="add-preset"&&D&&f(ji(D))},[u,D]);const L=(q,R)=>{f(z=>({...z,[q]:R}))},F=(q,R)=>{f(z=>({...z,capabilities:{...z.capabilities,[q]:R}}))},H=q=>{c("edit"),b(q.id),x(""),f(_s(q))},T=()=>{c("add-preset"),b(null);const q=D??p[0]??null;x(q?.id??""),f(q?ji(q):Ws())},O=()=>{c("add-custom"),b(null),x(""),f(Ws())},P=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),B=u==="add-preset"?!!S:u==="edit"?!!(N&&P):P,$=async()=>{try{if(u==="add-preset"){if(!S)return;const R=await v.mutateAsync({memberPresetId:S});ut.success(n("Member added")),w(R),c("edit"),b(R.id),x(""),f(_s(R));return}const q=Dm(a);if(!q.name||!q.providerId||!q.rolePrompt){ut.error(n("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const R=await v.mutateAsync({member:q});ut.success(n("Member added")),w(R),c("edit"),b(R.id),f(_s(R));return}if(N){const R=await i.mutateAsync({memberId:N.id,data:q});ut.success(n("Member updated")),w(z=>z?.id===R.id?R:z),b(R.id),f(_s(R))}}catch(q){ut.error(Ro(q,n("Failed to save member")))}},X=async()=>{if(d)try{if(await o.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const q=C.find(R=>R.id!==d.id)??null;b(q?.id??null),c(q?"edit":"add-preset"),f(q?_s(q):Ws())}w(q=>q?.id===d.id?null:q),h(null),ut.success(n("Member removed"))}catch(q){ut.error(Ro(q,n("Failed to remove member")))}},U=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(xr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:n("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:A,children:[t.jsx(lo,{size:13}),n("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Do,{icon:t.jsx(xr,{size:18}),title:n("No member presets"),description:n("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:A,children:[t.jsx(Vt,{size:13}),n("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(q=>{const R=S===q.id;return t.jsxs("button",{type:"button",onClick:()=>{x(q.id),f(ji(q))},className:G("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",R?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(At,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[n(Mo(q.workspacePolicy))," · ",n(Lm(q.sessionPolicy))]})]}),R?t.jsx(bt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),W=()=>{const q=u==="edit";return q&&!N?t.jsx("div",{className:"p-5",children:t.jsx(Do,{icon:t.jsx(us,{size:18}),title:n("Select a member"),description:n("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:A,children:[t.jsx(Vt,{size:13}),n("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Ua,{size:15,className:"text-neutral-500"}):t.jsx(Vt,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:n(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&N?t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:()=>h(N),disabled:A,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(fn,{size:13}),n("Remove")]}):t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:A,children:[t.jsx(xr,{size:13}),n("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&N?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(At,{name:N.name,avatar:N.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:G("h-2 w-2 shrink-0 rounded-full",Ao(N))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:N.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[N.providerId," · ",n(Mo(N.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Name")}),t.jsx("input",{value:a.name,onChange:R=>L("name",R.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:R=>L("aliasesText",R.target.value),placeholder:n("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Provider")}),t.jsx(cs,{value:a.providerId,onChange:R=>L("providerId",R),options:I})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Avatar")}),t.jsx("input",{value:a.avatar,onChange:R=>L("avatar",R.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Workspace policy")}),t.jsx(cs,{value:a.workspacePolicy,onChange:R=>L("workspacePolicy",R),options:kl.map(R=>({value:R.value,label:n(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Trigger policy")}),t.jsx(cs,{value:a.triggerPolicy,onChange:R=>L("triggerPolicy",R),options:Tm.map(R=>({value:R.value,label:n(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Session policy")}),t.jsx(cs,{value:a.sessionPolicy,onChange:R=>L("sessionPolicy",R),options:El.map(R=>({value:R.value,label:n(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Queue policy")}),t.jsx(cs,{value:a.queueManagementPolicy,onChange:R=>L("queueManagementPolicy",R),options:Am.map(R=>({value:R.value,label:n(R.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ft,{children:n("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:R=>L("rolePrompt",R.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ft,{children:n("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Rm.map(R=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[R.key],onChange:z=>F(R.key,z.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:n(R.label)})]},R.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(As,{isOpen:e,onClose:A?()=>{}:s,title:n("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ie,{type:"button",variant:"outline",onClick:s,disabled:A,children:n("Close")}),t.jsx(Ie,{type:"button",onClick:$,disabled:A||!B,children:n(A?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[C.length," ",n("active")," · ",M," ",n("working")]})]}),t.jsx(Ie,{type:"button",size:"icon-sm",variant:"outline",onClick:T,disabled:A,title:n("Add member"),children:t.jsx(Vt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:C.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:n("No active members")}):t.jsx("div",{className:"space-y-1",children:C.map(q=>{const R=u==="edit"&&g===q.id;return t.jsxs("button",{type:"button",onClick:()=>H(q),className:G("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",R?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(At,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:G("h-1.5 w-1.5 shrink-0 rounded-full",Ao(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(_u,{size:13,className:G("shrink-0 text-neutral-300 transition-opacity",R?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:T,disabled:A,className:G("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(xr,{size:12}),n("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:A,className:G("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(lo,{size:12}),n("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?U():W()})]})}),t.jsx(Kr,{isOpen:!!d,onClose:()=>h(null),onConfirm:X,title:n("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:n("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?n("Remove this member from future TeamRun work?"):""}),d&&Ji(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(sr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:n("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Om=[],Im=[],Bm=[],Fm=240;function zm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Lo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Ni(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Po(e,s){return e instanceof Error?e.message:s}function Wm(e,s=Fm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function _r(e){return e?e.instructionPreview??Wm(e.instruction):""}function Hm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function $m(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Um(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function qm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Km(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Vm(e){switch(e){case Rt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Rt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Rt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Rt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Xm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Ym(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Gm(e,s){return s.find(r=>r.memberId===e.id&&ii.has(r.status))}function jl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:n,onViewInvocationSession:p}){const{t:m}=ue(),v=wa(e.id),i=Ca(e.id),o=ka(e.id),[l,u]=y.useState(null),[c,g]=y.useState(null),[b,S]=y.useState(!1),[x,a]=y.useState(!1),f=e.members??Om,d=y.useMemo(()=>f.filter(L=>L.membershipStatus!=="REMOVED"),[f]),h=e.workRequests??Im,_=e.invocations??Bm,w=y.useMemo(()=>In(s,e),[e,s]),k=y.useMemo(()=>new Map(h.map(L=>[L.id,L])),[h]),j=y.useMemo(()=>[...h].filter(L=>L.status==="PENDING_APPROVAL").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[h]),C=y.useMemo(()=>[...h].filter(L=>L.status==="QUEUED").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[h]),E=y.useMemo(()=>[...f].map(L=>({member:L,status:zm(L.status)})).sort((L,F)=>Lo[L.status]-Lo[F.status]),[f]),N=v.isError?v.error:i.isError?i.error:null,D=v.isPending||i.isPending,A=w.find(L=>L.workspace.id===r),M=e.messages??[],I=E.filter(({status:L})=>L==="running"||L==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Pm,{isOpen:x,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Rs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(mn,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:M.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:I>0?`${I}/${d.length}`:d.length}),I>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),C.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:C.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(Cs,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(L=>{const F=f.find(O=>O.id===L.targetMemberId),H=v.isPending&&v.variables===L.id,T=i.isPending&&i.variables===L.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(At,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:_r(L)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(qm(L.requesterType))}),t.jsx("span",{children:Ni(L.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(L.id),disabled:D,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(bt,{size:11}),t.jsx("span",{className:"truncate",children:m(H?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(L.id),disabled:D,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ht,{size:11}),t.jsx("span",{className:"truncate",children:m(T?"Rejecting":"Reject")})]})]})]},L.id)})}),N&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Po(N,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(Ua,{size:13})})]}),f.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:L,status:F})=>{const H=Gm(L,_),T=Ym(_.filter(W=>W.memberId===L.id)),O=H?k.get(H.workRequestId):void 0,P=c===L.id,B=F==="running"||F==="waiting room reply",$=B&&!!H,X=l===L.id,U=o.isPending&&o.variables?.memberId===L.id;return t.jsxs("div",{className:G("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(At,{name:L.name,avatar:L.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:G("h-1.5 w-1.5 shrink-0 rounded-full",Um(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:L.name}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",$m(F)),children:m(Hm(F))})]}),B&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:_r(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(X?null:L.id),disabled:o.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Ns,{size:12})}),H?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(H.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(Ki,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(P?null:L.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":P,children:P?t.jsx(ht,{size:13}):t.jsx(Mt,{size:13})})]})]}),$&&X&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:L.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ns,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:L.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ha,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),P&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:L.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:T.length})]}),T.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:T.map(W=>{const q=k.get(W.workRequestId),R=!!(W.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:G("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Km(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Ni(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(q)||W.workRequestId})]}),R&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&p?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(Ki,{size:10}),t.jsx("span",{children:m("Log")})]})]})},W.id)})})]}),E[E.length-1]?.member.id!==L.id&&!P&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},L.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Po(o.error,m("Failed to stop member work"))})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length})]}),t.jsx("div",{className:"space-y-1",children:C.map(L=>{const F=f.find(H=>H.id===L.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(At,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(L)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Ni(L.createdAt)})]})},L.id)})})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>S(L=>!L),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":b,"aria-label":m("Workspaces"),children:[t.jsx(Rs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[A&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:hs(A.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:w.length}),b?t.jsx(ht,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),b&&t.jsx("div",{className:"space-y-1.5",children:w.map(L=>{const F=r===L.workspace.id;return t.jsx("div",{className:G("rounded-md border bg-white px-3 py-2",F?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(L.displayName)}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Xm(L.roleLabel)),children:m(L.roleLabel)}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Vm(L.workspace.status)),children:L.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:hs(L.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[L.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",L.ownerName]}),L.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",L.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>n?.(L.workspace.id),disabled:!n||F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[F?t.jsx(bt,{size:11}):t.jsx(xn,{size:11}),t.jsx("span",{children:m(F?"Selected":"Select")})]})]})},L.workspace.id)})})]}),j.length===0&&C.length===0&&E.every(({status:L})=>L==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Ri={exports:{}},Oo;function Qm(){return Oo||(Oo=1,(function(e,s){(function(r,n){e.exports=n()})(self,(()=>(()=>{var r={4567:function(v,i,o){var l=this&&this.__decorate||function(h,_,w,k){var j,C=arguments.length,E=C<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,_,w,k);else for(var N=h.length-1;N>=0;N--)(j=h[N])&&(E=(C<3?j(E):C>3?j(_,w,E):j(_,w))||E);return C>3&&E&&Object.defineProperty(_,w,E),E},u=this&&this.__param||function(h,_){return function(w,k){_(w,k,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=o(9042),g=o(6114),b=o(9924),S=o(844),x=o(5596),a=o(4725),f=o(3656);let d=i.AccessibilityManager=class extends S.Disposable{constructor(h,_){super(),this._terminal=h,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 w=0;w<this._terminal.rows;w++)this._rowElements[w]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[w]);if(this._topBoundaryFocusListener=w=>this._handleBoundaryFocus(w,0),this._bottomBoundaryFocusListener=w=>this._handleBoundaryFocus(w,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new b.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((w=>this._handleResize(w.rows)))),this.register(this._terminal.onRender((w=>this._refreshRows(w.start,w.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((w=>this._handleChar(w)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
-
`)))),this.register(this._terminal.onA11yTab((w=>this._handleTab(w)))),this.register(this._terminal.onKey((w=>this._handleKey(w.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new x.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,f.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(h){for(let _=0;_<h;_++)this._handleChar(" ")}_handleChar(h){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==h&&(this._charsToAnnounce+=h):this._charsToAnnounce+=h,h===`
|
|
21
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.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,g.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,_){this._liveRegionDebouncer.refresh(h,_,this._terminal.rows)}_renderRows(h,_){const w=this._terminal.buffer,k=w.lines.length.toString();for(let j=h;j<=_;j++){const C=w.translateBufferLineToString(w.ydisp+j,!0),E=(w.ydisp+j+1).toString(),N=this._rowElements[j];N&&(C.length===0?N.innerText=" ":N.textContent=C,N.setAttribute("aria-posinset",E),N.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,_){const w=h.target,k=this._rowElements[_===0?1:this._rowElements.length-2];if(w.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==k)return;let j,C;if(_===0?(j=w,C=this._rowElements.pop(),this._rowContainer.removeChild(C)):(j=this._rowElements.shift(),C=w,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),C.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){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>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_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 h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(v,i)=>{function o(g){return g.replace(/\r?\n/g,"\r")}function l(g,b){return b?"\x1B[200~"+g+"\x1B[201~":g}function u(g,b,S,x){g=l(g=o(g),S.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(g,!0),b.value=""}function c(g,b,S){const x=S.getBoundingClientRect(),a=g.clientX-x.left-10,f=g.clientY-x.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${a}px`,b.style.top=`${f}px`,b.style.zIndex="1000",b.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=o,i.bracketTextForPaste=l,i.copyHandler=function(g,b){g.clipboardData&&g.clipboardData.setData("text/plain",b.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,b,S,x){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),b,S,x)},i.paste=u,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,b,S,x,a){c(g,b,S),a&&x.rightClickSelect(g),b.value=x.selectionText,b.select()}},7239:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const l=o(1505);i.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(u,c,g){this._css.set(u,c,g)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,g){this._color.set(u,c,g)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(o,l,u,c){o.addEventListener(l,u,c);let g=!1;return{dispose:()=>{g||(g=!0,o.removeEventListener(l,u,c))}}}},6465:function(v,i,o){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=o(3656),g=o(8460),b=o(844),S=o(2585);let x=i.Linkifier2=class extends b.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,b.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,b.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const f=this._linkProviders.indexOf(a);f!==-1&&this._linkProviders.splice(f,1)}}}attachToDom(a,f,d){this._element=a,this._mouseService=f,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const f=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const d=a.composedPath();for(let h=0;h<d.length;h++){const _=d[h];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,f){var d,h;this._activeProviderReplies&&f||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((w=>{w?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let _=!1;for(const[w,k]of this._linkProviders.entries())f?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(w)&&(_=this._checkLinkProviderResult(w,a,_)):k.provideLinks(a.y,(j=>{var C,E;if(this._isMouseOut)return;const N=j?.map((D=>({link:D})));(C=this._activeProviderReplies)===null||C===void 0||C.set(w,N),_=this._checkLinkProviderResult(w,a,_),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,f){const d=new Set;for(let h=0;h<f.size;h++){const _=f.get(h);if(_)for(let w=0;w<_.length;w++){const k=_[w],j=k.link.range.start.y<a?0:k.link.range.start.x,C=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=C;E++){if(d.has(E)){_.splice(w--,1);break}d.add(E)}}}}_checkLinkProviderResult(a,f,d){var h;if(!this._activeProviderReplies)return d;const _=this._activeProviderReplies.get(a);let w=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(w=!0);if(!w&&_){const k=_.find((j=>this._linkAtPosition(j.link,f)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const j=(h=this._activeProviderReplies.get(k))===null||h===void 0?void 0:h.find((C=>this._linkAtPosition(C.link,f)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const f=this._positionFromMouseEvent(a,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,f){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!f||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,b.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(a.link,f)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,h;return(h=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:d=>{var h,_;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,h;return(h=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||h===void 0?void 0:h.decorations.underline},set:d=>{var h,_,w;!((h=this._currentLink)===null||h===void 0)&&h.state&&((w=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||w===void 0?void 0:w.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const h=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(h,_),this._lastMouseEvent&&this._element)){const w=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);w&&this._askForLink(w,!1)}}))))}_linkHover(a,f,d){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(d,f.text)}_fireUnderlineEvent(a,f){const d=a.range,h=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-h-1,d.end.x,d.end.y-h-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(a,f,d){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(d,f.text)}_linkAtPosition(a,f){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,h=a.range.end.y*this._bufferService.cols+a.range.end.x,_=f.y*this._bufferService.cols+f.x;return d<=_&&_<=h}_positionFromMouseEvent(a,f,d){const h=d.getCoords(a,f,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,f,d,h,_){return{x1:a,y1:f,x2:d,y2:h,cols:this._bufferService.cols,fg:_}}};i.Linkifier2=x=l([u(0,S.IBufferService)],x)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,o){var l=this&&this.__decorate||function(x,a,f,d){var h,_=arguments.length,w=_<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,f,d);else for(var k=x.length-1;k>=0;k--)(h=x[k])&&(w=(_<3?h(w):_>3?h(a,f,w):h(a,f))||w);return _>3&&w&&Object.defineProperty(a,f,w),w},u=this&&this.__param||function(x,a){return function(f,d){a(f,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=o(511),g=o(2585);let b=i.OscLinkProvider=class{constructor(x,a,f){this._bufferService=x,this._optionsService=a,this._oscLinkService=f}provideLinks(x,a){var f;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const h=[],_=this._optionsService.rawOptions.linkHandler,w=new c.CellData,k=d.getTrimmedLength();let j=-1,C=-1,E=!1;for(let N=0;N<k;N++)if(C!==-1||d.hasContent(N)){if(d.loadCell(N,w),w.hasExtendedAttrs()&&w.extended.urlId){if(C===-1){C=N,j=w.extended.urlId;continue}E=w.extended.urlId!==j}else C!==-1&&(E=!0);if(E||C!==-1&&N===k-1){const D=(f=this._oscLinkService.getLinkData(j))===null||f===void 0?void 0:f.uri;if(D){const A={start:{x:C+1,y:x},end:{x:N+(E||N!==k-1?0:1),y:x}};let M=!1;if(!_?.allowNonHttpProtocols)try{const I=new URL(D);["http:","https:"].includes(I.protocol)||(M=!0)}catch{M=!0}M||h.push({text:D,range:A,activate:(I,L)=>_?_.activate(I,L,A):S(0,L),hover:(I,L)=>{var F;return(F=_?.hover)===null||F===void 0?void 0:F.call(_,I,L,A)},leave:(I,L)=>{var F;return(F=_?.leave)===null||F===void 0?void 0:F.call(_,I,L,A)}})}E=!1,w.hasExtendedAttrs()&&w.extended.urlId?(C=N,j=w.extended.urlId):(C=-1,j=-1)}}a(h)}};function S(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
|
-
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=b=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],b)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(o,l){this._parentWindow=o,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,l,u){this._rowCount=u,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const l=o(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=u},3236:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const l=o(3614),u=o(3656),c=o(6465),g=o(9042),b=o(3730),S=o(1680),x=o(3107),a=o(5744),f=o(2950),d=o(1296),h=o(428),_=o(4269),w=o(5114),k=o(8934),j=o(3230),C=o(9312),E=o(4725),N=o(6731),D=o(8055),A=o(8969),M=o(8460),I=o(844),L=o(6114),F=o(8437),H=o(2584),T=o(7399),O=o(5941),P=o(9074),B=o(2585),$=o(5435),X=o(4567),U=typeof window<"u"?window.document:null;class W extends A.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(R={}){super(R),this.browser=L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((z,V)=>this.refresh(z,V)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((z=>this._reportWindowsOptions(z)))),this.register(this._inputHandler.onColor((z=>this._handleColorEvent(z)))),this.register((0,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((z=>this._afterResize(z.cols,z.rows)))),this.register((0,I.toDisposable)((()=>{var z,V;this._customKeyEventHandler=void 0,(V=(z=this.element)===null||z===void 0?void 0:z.parentNode)===null||V===void 0||V.removeChild(this.element)})))}_handleColorEvent(R){if(this._themeService)for(const z of R){let V,K="";switch(z.index){case 256:V="foreground",K="10";break;case 257:V="background",K="11";break;case 258:V="cursor",K="12";break;default:V="ansi",K="4;"+z.index}switch(z.type){case 0:const ee=D.color.toColorRGB(V==="ansi"?this._themeService.colors.ansi[z.index]:this._themeService.colors[V]);this.coreService.triggerDataEvent(`${H.C0.ESC}]${K};${(0,O.toRgbString)(ee)}${H.C1_ESCAPED.ST}`);break;case 1:if(V==="ansi")this._themeService.modifyColors((Z=>Z.ansi[z.index]=D.rgba.toColor(...z.color)));else{const Z=V;this._themeService.modifyColors((se=>se[Z]=D.rgba.toColor(...z.color)))}break;case 2:this._themeService.restoreColor(z.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(R){R?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(R){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[I"),this.updateCursorStyle(R),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var R;return(R=this.textarea)===null||R===void 0?void 0:R.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const R=this.buffer.ybase+this.buffer.y,z=this.buffer.lines.get(R);if(!z)return;const V=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,ee=z.getWidth(V),Z=this._renderService.dimensions.css.cell.width*ee,se=this.buffer.y*this._renderService.dimensions.css.cell.height,xe=V*this._renderService.dimensions.css.cell.width;this.textarea.style.left=xe+"px",this.textarea.style.top=se+"px",this.textarea.style.width=Z+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(z=>{this.hasSelection()&&(0,l.copyHandler)(z,this._selectionService)})));const R=z=>(0,l.handlePasteEvent)(z,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",R)),this.register((0,u.addDisposableDomListener)(this.element,"paste",R)),L.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(z=>{z.button===2&&(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(z=>{(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),L.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(z=>{z.button===1&&(0,l.moveTextAreaUnderMouseCursor)(z,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(R=>this._keyUp(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(R=>this._keyDown(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(R=>this._keyPress(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(R=>this._compositionHelper.compositionupdate(R)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(R=>this._inputEvent(R)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(R){var z;if(!R)throw new Error("Terminal requires a parent element.");R.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=R.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),R.appendChild(this.element);const V=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),V.appendChild(this._viewportElement),this._viewportScrollArea=U.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=U.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=U.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),V.appendChild(this.screenElement),this.textarea=U.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),L.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(w.CoreBrowserService,this.textarea,(z=this._document.defaultView)!==null&&z!==void 0?z:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=U.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(f.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(V);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(C.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const R=this,z=this.element;function V(Z){const se=R._mouseService.getMouseReportCoords(Z,R.screenElement);if(!se)return!1;let xe,be;switch(Z.overrideType||Z.type){case"mousemove":be=32,Z.buttons===void 0?(xe=3,Z.button!==void 0&&(xe=Z.button<3?Z.button:3)):xe=1&Z.buttons?0:4&Z.buttons?1:2&Z.buttons?2:3;break;case"mouseup":be=0,xe=Z.button<3?Z.button:3;break;case"mousedown":be=1,xe=Z.button<3?Z.button:3;break;case"wheel":if(R.viewport.getLinesScrolled(Z)===0)return!1;be=Z.deltaY<0?0:1,xe=4;break;default:return!1}return!(be===void 0||xe===void 0||xe>4)&&R.coreMouseService.triggerMouseEvent({col:se.col,row:se.row,x:se.x,y:se.y,button:xe,action:be,ctrl:Z.ctrlKey,alt:Z.altKey,shift:Z.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ee={mouseup:Z=>(V(Z),Z.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(Z)),wheel:Z=>(V(Z),this.cancel(Z,!0)),mousedrag:Z=>{Z.buttons&&V(Z)},mousemove:Z=>{Z.buttons||V(Z)}};this.register(this.coreMouseService.onProtocolChange((Z=>{Z?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Z)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&Z?K.mousemove||(z.addEventListener("mousemove",ee.mousemove),K.mousemove=ee.mousemove):(z.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&Z?K.wheel||(z.addEventListener("wheel",ee.wheel,{passive:!1}),K.wheel=ee.wheel):(z.removeEventListener("wheel",K.wheel),K.wheel=null),2&Z?K.mouseup||(z.addEventListener("mouseup",ee.mouseup),K.mouseup=ee.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),z.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&Z?K.mousedrag||(K.mousedrag=ee.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(z,"mousedown",(Z=>{if(Z.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Z))return V(Z),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(Z)}))),this.register((0,u.addDisposableDomListener)(z,"wheel",(Z=>{if(!K.wheel){if(!this.buffer.hasScrollback){const se=this.viewport.getLinesScrolled(Z);if(se===0)return;const xe=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Z.deltaY<0?"A":"B");let be="";for(let Be=0;Be<Math.abs(se);Be++)be+=xe;return this.coreService.triggerDataEvent(be,!0),this.cancel(Z,!0)}return this.viewport.handleWheel(Z)?this.cancel(Z):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(z,"touchstart",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Z),this.cancel(Z)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(z,"touchmove",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Z)?void 0:this.cancel(Z)}),{passive:!1}))}refresh(R,z){var V;(V=this._renderService)===null||V===void 0||V.refreshRows(R,z)}updateCursorStyle(R){var z;!((z=this._selectionService)===null||z===void 0)&&z.shouldColumnSelect(R)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(R,z,V=0){var K;V===1?(super.scrollLines(R,z,V),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(R)}paste(R){(0,l.paste)(R,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(R){this._customKeyEventHandler=R}registerLinkProvider(R){return this.linkifier2.registerLinkProvider(R)}registerCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const z=this._characterJoinerService.register(R);return this.refresh(0,this.rows-1),z}deregisterCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(R)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(R){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+R)}registerDecoration(R){return this._decorationService.registerDecoration(R)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(R,z,V){this._selectionService.setSelection(R,z,V)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var R;(R=this._selectionService)===null||R===void 0||R.clearSelection()}selectAll(){var R;(R=this._selectionService)===null||R===void 0||R.selectAll()}selectLines(R,z){var V;(V=this._selectionService)===null||V===void 0||V.selectLines(R,z)}_keyDown(R){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;const z=this.browser.isMac&&this.options.macOptionIsMeta&&R.altKey;if(!z&&!this._compositionHelper.keydown(R))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;z||R.key!=="Dead"&&R.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const V=(0,T.evaluateKeyboardEvent)(R,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(R),V.type===3||V.type===2){const K=this.rows-1;return this.scrollLines(V.type===2?-K:K),this.cancel(R,!0)}return V.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,R)||(V.cancel&&this.cancel(R,!0),!V.key||!!(R.key&&!R.ctrlKey&&!R.altKey&&!R.metaKey&&R.key.length===1&&R.key.charCodeAt(0)>=65&&R.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(V.key!==H.C0.ETX&&V.key!==H.C0.CR||(this.textarea.value=""),this._onKey.fire({key:V.key,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(V.key,!0),!this.optionsService.rawOptions.screenReaderMode||R.altKey||R.ctrlKey?this.cancel(R,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(R,z){const V=R.isMac&&!this.options.macOptionIsMeta&&z.altKey&&!z.ctrlKey&&!z.metaKey||R.isWindows&&z.altKey&&z.ctrlKey&&!z.metaKey||R.isWindows&&z.getModifierState("AltGraph");return z.type==="keypress"?V:V&&(!z.keyCode||z.keyCode>47)}_keyUp(R){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1||((function(z){return z.keyCode===16||z.keyCode===17||z.keyCode===18})(R)||this.focus(),this.updateCursorStyle(R),this._keyPressHandled=!1)}_keyPress(R){let z;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;if(this.cancel(R),R.charCode)z=R.charCode;else if(R.which===null||R.which===void 0)z=R.keyCode;else{if(R.which===0||R.charCode===0)return!1;z=R.which}return!(!z||(R.altKey||R.ctrlKey||R.metaKey)&&!this._isThirdLevelShift(this.browser,R)||(z=String.fromCharCode(z),this._onKey.fire({key:z,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(z,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(R){if(R.data&&R.inputType==="insertText"&&(!R.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const z=R.data;return this.coreService.triggerDataEvent(z,!0),this.cancel(R),!0}return!1}resize(R,z){R!==this.cols||z!==this.rows?super.resize(R,z):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(R,z){var V,K;(V=this._charSizeService)===null||V===void 0||V.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var R;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let z=1;z<this.rows;z++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(R=this.viewport)===null||R===void 0||R.reset(),this.refresh(0,this.rows-1)}}reset(){var R,z;this.options.rows=this.rows,this.options.cols=this.cols;const V=this._customKeyEventHandler;this._setup(),super.reset(),(R=this._selectionService)===null||R===void 0||R.reset(),this._decorationService.reset(),(z=this.viewport)===null||z===void 0||z.reset(),this._customKeyEventHandler=V,this.refresh(0,this.rows-1)}clearTextureAtlas(){var R;(R=this._renderService)===null||R===void 0||R.clearTextureAtlas()}_reportFocus(){var R;!((R=this.element)===null||R===void 0)&&R.classList.contains("focus")?this.coreService.triggerDataEvent(H.C0.ESC+"[I"):this.coreService.triggerDataEvent(H.C0.ESC+"[O")}_reportWindowsOptions(R){if(this._renderService)switch(R){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const z=this._renderService.dimensions.css.canvas.width.toFixed(0),V=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[4;${V};${z}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ee=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[6;${ee};${K}t`)}}cancel(R,z){if(this.options.cancelEvents||z)return R.preventDefault(),R.stopPropagation(),!1}}i.Terminal=W},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(o,l=1e3){this._renderCallback=o,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,l,u){this._rowCount=u,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,b=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),b)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l)}}},1680:function(v,i,o){var l=this&&this.__decorate||function(f,d,h,_){var w,k=arguments.length,j=k<3?d:_===null?_=Object.getOwnPropertyDescriptor(d,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,h,_);else for(var C=f.length-1;C>=0;C--)(w=f[C])&&(j=(k<3?w(j):k>3?w(d,h,j):w(d,h))||j);return k>3&&j&&Object.defineProperty(d,h,j),j},u=this&&this.__param||function(f,d){return function(h,_){d(h,_,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=o(3656),g=o(4725),b=o(8460),S=o(844),x=o(2585);let a=i.Viewport=class extends S.Disposable{constructor(f,d,h,_,w,k,j,C){super(),this._viewportElement=f,this._scrollArea=d,this._bufferService=h,this._optionsService=_,this._charSizeService=w,this._renderService=k,this._coreBrowserService=j,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(C.colors),this.register(C.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(f){this._viewportElement.style.backgroundColor=f.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(f){if(f)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const f=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==f&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=f),this._refreshAnimationFrame=null}syncScrollArea(f=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(f);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(f)}_handleScroll(f){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const f=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(f*(this._smoothScrollState.target-this._smoothScrollState.origin)),f<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(f,d){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&h<this._lastRecordedBufferHeight)||(f.cancelable&&f.preventDefault(),!1)}handleWheel(f){const d=this._getPixelsScrolled(f);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(f,d))}scrollLines(f){if(f!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=f*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:f,suppressScrollEvent:!1})}_getPixelsScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let d=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(f,d){var h;let _,w="";const k=[],j=d??this._bufferService.buffer.lines.length,C=this._bufferService.buffer.lines;for(let E=f;E<j;E++){const N=C.get(E);if(!N)continue;const D=(h=C.get(E+1))===null||h===void 0?void 0:h.isWrapped;if(w+=N.translateToString(!D),!D||E===C.length-1){const A=document.createElement("div");A.textContent=w,k.push(A),w.length>0&&(_=A),w=""}}return{bufferElements:k,cursorElement:_}}getLinesScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let d=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(f,d){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&d.altKey||h==="ctrl"&&d.ctrlKey||h==="shift"&&d.shiftKey?f*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:f*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(f){this._lastTouchY=f.touches[0].pageY}handleTouchMove(f){const d=this._lastTouchY-f.touches[0].pageY;return this._lastTouchY=f.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(f,d))}};i.Viewport=a=l([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,i,o){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=o(3656),g=o(4725),b=o(844),S=o(2585);let x=i.BufferDecorationRenderer=class extends b.Disposable{constructor(a,f,d,h){super(),this._screenElement=a,this._bufferService=f,this._decorationService=d,this._renderService=h,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,b.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var f,d;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((f=a?.options)===null||f===void 0?void 0:f.layer)==="top"),h.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=(d=a.options.x)!==null&&d!==void 0?d:0;return _&&_>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(a,h),h}_refreshStyle(a){const f=a.marker.line-this._bufferService.buffers.active.ydisp;if(f<0||f>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=f*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,f=a.element){var d;if(!f)return;const h=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?f.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":f.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var f;(f=this._decorationElements.get(a))===null||f===void 0||f.remove(),this._decorationElements.delete(a),a.dispose()}};i.BufferDecorationRenderer=x=l([u(1,S.IBufferService),u(2,S.IDecorationService),u(3,g.IRenderService)],x)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(o){if(o.options.overviewRulerOptions){for(const l of this._zones)if(l.color===o.options.overviewRulerOptions.color&&l.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,o.marker.line))return;if(this._lineAdjacentToZone(l,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(l,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,l){return l>=o.startBufferLine&&l<=o.endBufferLine}_lineAdjacentToZone(o,l,u){return l>=o.startBufferLine-this._linePadding[u||"full"]&&l<=o.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(o,l){o.startBufferLine=Math.min(o.startBufferLine,l),o.endBufferLine=Math.max(o.endBufferLine,l)}}},5744:function(v,i,o){var l=this&&this.__decorate||function(_,w,k,j){var C,E=arguments.length,N=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,w,k,j);else for(var D=_.length-1;D>=0;D--)(C=_[D])&&(N=(E<3?C(N):E>3?C(w,k,N):C(w,k))||N);return E>3&&N&&Object.defineProperty(w,k,N),N},u=this&&this.__param||function(_,w){return function(k,j){w(k,j,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=o(5871),g=o(3656),b=o(4725),S=o(844),x=o(2585),a={full:0,left:0,center:0,right:0},f={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let h=i.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,w,k,j,C,E,N){var D;super(),this._viewportElement=_,this._screenElement=w,this._bufferService=k,this._decorationService=j,this._renderService=C,this._optionsService=E,this._coreBrowseService=N,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(D=this._viewportElement.parentElement)===null||D===void 0||D.insertBefore(this._canvas,this._viewportElement);const A=this._canvas.getContext("2d");if(!A)throw new Error("Ctx cannot be null");this._ctx=A,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,S.toDisposable)((()=>{var M;(M=this._canvas)===null||M===void 0||M.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),w=Math.ceil(this._canvas.width/3);f.full=this._canvas.width,f.left=_,f.center=w,f.right=_,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=f.left,d.right=f.left+f.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,w=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);a.left=w,a.center=w,a.right=w}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const w of this._decorationService.decorations)this._colorZoneStore.addDecoration(w);this._ctx.lineWidth=1;const _=this._colorZoneStore.zones;for(const w of _)w.position!=="full"&&this._renderColorZone(w);for(const w of _)w.position==="full"&&this._renderColorZone(w);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(d[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-a[_.position||"full"]/2),f[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[_.position||"full"]))}_queueRefresh(_,w){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=w||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=h=l([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,b.IRenderService),u(5,x.IOptionsService),u(6,b.ICoreBrowserService)],h)},2950:function(v,i,o){var l=this&&this.__decorate||function(x,a,f,d){var h,_=arguments.length,w=_<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,f):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,f,d);else for(var k=x.length-1;k>=0;k--)(h=x[k])&&(w=(_<3?h(w):_>3?h(a,f,w):h(a,f))||w);return _>3&&w&&Object.defineProperty(a,f,w),w},u=this&&this.__param||function(x,a){return function(f,d){a(f,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=o(4725),g=o(2585),b=o(2584);let S=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,f,d,h,_){this._textarea=x,this._compositionView=a,this._bufferService=f,this._optionsService=d,this._coreService=h,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let f;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,f=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),f.length>0&&this._coreService.triggerDataEvent(f,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,f=a.replace(x,"");this._dataAlreadySent=f,a.length>x.length?this._coreService.triggerDataEvent(f,!0):a.length<x.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),f=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=f+"px",this._compositionView.style.lineHeight=f+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=S=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],S)},9806:(v,i)=>{function o(l,u,c){const g=c.getBoundingClientRect(),b=l.getComputedStyle(c),S=parseInt(b.getPropertyValue("padding-left")),x=parseInt(b.getPropertyValue("padding-top"));return[u.clientX-g.left-S,u.clientY-g.top-x]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=o,i.getCoords=function(l,u,c,g,b,S,x,a,f){if(!S)return;const d=o(l,u,c);return d?(d[0]=Math.ceil((d[0]+(f?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(f?1:0)),d[1]=Math.min(Math.max(d[1],1),b),d):void 0}},9504:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const l=o(2584);function u(a,f,d,h){const _=a-c(a,d),w=f-c(f,d),k=Math.abs(_-w)-(function(j,C,E){let N=0;const D=j-c(j,E),A=C-c(C,E);for(let M=0;M<Math.abs(D-A);M++){const I=g(j,C)==="A"?-1:1,L=E.buffer.lines.get(D+I*M);L?.isWrapped&&N++}return N})(a,f,d);return x(k,S(g(a,f),h))}function c(a,f){let d=0,h=f.buffer.lines.get(a),_=h?.isWrapped;for(;_&&a>=0&&a<f.rows;)d++,h=f.buffer.lines.get(--a),_=h?.isWrapped;return d}function g(a,f){return a>f?"A":"B"}function b(a,f,d,h,_,w){let k=a,j=f,C="";for(;k!==d||j!==h;)k+=_?1:-1,_&&k>w.cols-1?(C+=w.buffer.translateBufferLineToString(j,!1,a,k),k=0,a=0,j++):!_&&k<0&&(C+=w.buffer.translateBufferLineToString(j,!1,0,a+1),k=w.cols-1,a=k,j--);return C+w.buffer.translateBufferLineToString(j,!1,a,k)}function S(a,f){const d=f?"O":"[";return l.C0.ESC+d+a}function x(a,f){a=Math.floor(a);let d="";for(let h=0;h<a;h++)d+=f;return d}i.moveToCellSequence=function(a,f,d,h){const _=d.buffer.x,w=d.buffer.y;if(!d.buffer.hasScrollback)return(function(C,E,N,D,A,M){return u(E,D,A,M).length===0?"":x(b(C,E,C,E-c(E,A),!1,A).length,S("D",M))})(_,w,0,f,d,h)+u(w,f,d,h)+(function(C,E,N,D,A,M){let I;I=u(E,D,A,M).length>0?D-c(D,A):E;const L=D,F=(function(H,T,O,P,B,$){let X;return X=u(O,P,B,$).length>0?P-c(P,B):T,H<O&&X<=P||H>=O&&X<P?"C":"D"})(C,E,N,D,A,M);return x(b(C,I,N,L,F==="C",A).length,S(F,M))})(_,w,a,f,d,h);let k;if(w===f)return k=_>a?"D":"C",x(Math.abs(_-a),S(k,h));k=w>f?"D":"C";const j=Math.abs(w-f);return x((function(C,E){return E.cols-C})(w>f?a:_,d)+(j-1)*d.cols+1+((w>f?_:a)-1),S(k,h))}},1296:function(v,i,o){var l=this&&this.__decorate||function(A,M,I,L){var F,H=arguments.length,T=H<3?M:L===null?L=Object.getOwnPropertyDescriptor(M,I):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(A,M,I,L);else for(var O=A.length-1;O>=0;O--)(F=A[O])&&(T=(H<3?F(T):H>3?F(M,I,T):F(M,I))||T);return H>3&&T&&Object.defineProperty(M,I,T),T},u=this&&this.__param||function(A,M){return function(I,L){M(I,L,A)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=o(3787),g=o(2550),b=o(2223),S=o(6171),x=o(4725),a=o(8055),f=o(8460),d=o(844),h=o(2585),_="xterm-dom-renderer-owner-",w="xterm-rows",k="xterm-fg-",j="xterm-bg-",C="xterm-focus",E="xterm-selection";let N=1,D=i.DomRenderer=class extends d.Disposable{constructor(A,M,I,L,F,H,T,O,P,B){super(),this._element=A,this._screenElement=M,this._viewportElement=I,this._linkifier2=L,this._charSizeService=H,this._optionsService=T,this._bufferService=O,this._coreBrowserService=P,this._themeService=B,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(w),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const A=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*A,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*A),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/A),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/A),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${w} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(A){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${w} { color: ${A.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${w} .xterm-dim { color: ${a.color.multiplyOpacity(A.foreground,.5).css};}`,M+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,M+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",M+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${A.cursor.css}; color: ${A.cursorAccent.css}; } 50% { background-color: inherit; color: ${A.cursor.css}; }}`,M+=`${this._terminalSelector} .${w}.${C} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w}.${C} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-block { background-color: ${A.cursor.css}; color: ${A.cursorAccent.css};}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${A.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${A.cursor.css} inset;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${A.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${A.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${A.selectionInactiveBackgroundOpaque.css};}`;for(const[I,L]of A.ansi.entries())M+=`${this._terminalSelector} .${k}${I} { color: ${L.css}; }${this._terminalSelector} .${k}${I}.xterm-dim { color: ${a.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${j}${I} { background-color: ${L.css}; }`;M+=`${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(A.background).css}; }${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(A.background),.5).css}; }${this._terminalSelector} .${j}${b.INVERTED_DEFAULT_COLOR} { background-color: ${A.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const A=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${A}px`,this._rowFactory.defaultSpacing=A}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(A,M){for(let I=this._rowElements.length;I<=M;I++){const L=document.createElement("div");this._rowContainer.appendChild(L),this._rowElements.push(L)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(A,M){this._refreshRowElements(A,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(C)}handleFocus(){this._rowContainer.classList.add(C),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(A,M,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(A,M,I),this.renderRows(0,this._bufferService.rows-1),!A||!M)return;const L=A[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,H=Math.max(L,0),T=Math.min(F,this._bufferService.rows-1);if(H>=this._bufferService.rows||T<0)return;const O=document.createDocumentFragment();if(I){const P=A[0]>M[0];O.appendChild(this._createSelectionElement(H,P?M[0]:A[0],P?A[0]:M[0],T-H+1))}else{const P=L===H?A[0]:0,B=H===F?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,P,B));const $=T-H-1;if(O.appendChild(this._createSelectionElement(H+1,0,this._bufferService.cols,$)),H!==T){const X=F===T?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(T,0,X))}}this._selectionContainer.appendChild(O)}_createSelectionElement(A,M,I,L=1){const F=document.createElement("div");return F.style.height=L*this.dimensions.css.cell.height+"px",F.style.top=A*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(I-M)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const A of this._rowElements)A.replaceChildren()}renderRows(A,M){const I=this._bufferService.buffer,L=I.ybase+I.y,F=Math.min(I.x,this._bufferService.cols-1),H=this._optionsService.rawOptions.cursorBlink,T=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=A;P<=M;P++){const B=P+I.ydisp,$=this._rowElements[P],X=I.lines.get(B);if(!$||!X)break;$.replaceChildren(...this._rowFactory.createRow(X,B,B===L,T,O,F,H,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(A){this._setCellUnderline(A.x1,A.x2,A.y1,A.y2,A.cols,!0)}_handleLinkLeave(A){this._setCellUnderline(A.x1,A.x2,A.y1,A.y2,A.cols,!1)}_setCellUnderline(A,M,I,L,F,H){I<0&&(A=0),L<0&&(M=0);const T=this._bufferService.rows-1;I=Math.max(Math.min(I,T),0),L=Math.max(Math.min(L,T),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,P=O.ybase+O.y,B=Math.min(O.x,F-1),$=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=I;W<=L;++W){const q=W+O.ydisp,R=this._rowElements[W],z=O.lines.get(q);if(!R||!z)break;R.replaceChildren(...this._rowFactory.createRow(z,q,q===P,X,U,B,$,this.dimensions.css.cell.width,this._widthCache,H?W===I?A:0:-1,H?(W===L?M:F)-1:-1))}}};i.DomRenderer=D=l([u(4,h.IInstantiationService),u(5,x.ICharSizeService),u(6,h.IOptionsService),u(7,h.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],D)},3787:function(v,i,o){var l=this&&this.__decorate||function(k,j,C,E){var N,D=arguments.length,A=D<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,C):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(k,j,C,E);else for(var M=k.length-1;M>=0;M--)(N=k[M])&&(A=(D<3?N(A):D>3?N(j,C,A):N(j,C))||A);return D>3&&A&&Object.defineProperty(j,C,A),A},u=this&&this.__param||function(k,j){return function(C,E){j(C,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=o(2223),g=o(643),b=o(511),S=o(2585),x=o(8055),a=o(4725),f=o(4269),d=o(6171),h=o(3734);let _=i.DomRendererRowFactory=class{constructor(k,j,C,E,N,D,A){this._document=k,this._characterJoinerService=j,this._optionsService=C,this._coreBrowserService=E,this._coreService=N,this._decorationService=D,this._themeService=A,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,C){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=C}createRow(k,j,C,E,N,D,A,M,I,L,F){const H=[],T=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let P,B=k.getNoBgTrimmedLength();C&&B<D+1&&(B=D+1);let $=0,X="",U=0,W=0,q=0,R=!1,z=0,V=!1,K=0;const ee=[],Z=L!==-1&&F!==-1;for(let se=0;se<B;se++){k.loadCell(se,this._workCell);let xe=this._workCell.getWidth();if(xe===0)continue;let be=!1,Be=se,ce=this._workCell;if(T.length>0&&se===T[0][0]){be=!0;const we=T.shift();ce=new f.JoinedCellData(this._workCell,k.translateToString(!0,we[0],we[1]),we[1]-we[0]),Be=we[1]-1,xe=ce.getWidth()}const nt=this._isCellInSelection(se,j),pe=C&&se===D,je=Z&&se>=L&&se<=F;let Ye=!1;this._decorationService.forEachDecorationAtCell(se,j,void 0,(we=>{Ye=!0}));let Ze=ce.getChars()||g.WHITESPACE_CELL_CHAR;if(Ze===" "&&(ce.isUnderline()||ce.isOverline())&&(Ze=" "),K=xe*M-I.get(Ze,ce.isBold(),ce.isItalic()),P){if($&&(nt&&V||!nt&&!V&&ce.bg===U)&&(nt&&V&&O.selectionForeground||ce.fg===W)&&ce.extended.ext===q&&je===R&&K===z&&!pe&&!be&&!Ye){X+=Ze,$++;continue}$&&(P.textContent=X),P=this._document.createElement("span"),$=0,X=""}else P=this._document.createElement("span");if(U=ce.bg,W=ce.fg,q=ce.extended.ext,R=je,z=K,V=nt,be&&D>=se&&D<=Be&&(D=se),!this._coreService.isCursorHidden&&pe){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)A&&ee.push("xterm-cursor-blink"),ee.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline")}}if(ce.isBold()&&ee.push("xterm-bold"),ce.isItalic()&&ee.push("xterm-italic"),ce.isDim()&&ee.push("xterm-dim"),X=ce.isInvisible()?g.WHITESPACE_CELL_CHAR:ce.getChars()||g.WHITESPACE_CELL_CHAR,ce.isUnderline()&&(ee.push(`xterm-underline-${ce.extended.underlineStyle}`),X===" "&&(X=" "),!ce.isUnderlineColorDefault()))if(ce.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(ce.getUnderlineColor()).join(",")})`;else{let we=ce.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ce.isBold()&&we<8&&(we+=8),P.style.textDecorationColor=O.ansi[we].css}ce.isOverline()&&(ee.push("xterm-overline"),X===" "&&(X=" ")),ce.isStrikethrough()&&ee.push("xterm-strikethrough"),je&&(P.style.textDecoration="underline");let Re=ce.getFgColor(),re=ce.getFgColorMode(),fe=ce.getBgColor(),ke=ce.getBgColorMode();const Oe=!!ce.isInverse();if(Oe){const we=Re;Re=fe,fe=we;const Q=re;re=ke,ke=Q}let De,Fe,Ge,Ne=!1;switch(this._decorationService.forEachDecorationAtCell(se,j,void 0,(we=>{we.options.layer!=="top"&&Ne||(we.backgroundColorRGB&&(ke=50331648,fe=we.backgroundColorRGB.rgba>>8&16777215,De=we.backgroundColorRGB),we.foregroundColorRGB&&(re=50331648,Re=we.foregroundColorRGB.rgba>>8&16777215,Fe=we.foregroundColorRGB),Ne=we.options.layer==="top")})),!Ne&&nt&&(De=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,fe=De.rgba>>8&16777215,ke=50331648,Ne=!0,O.selectionForeground&&(re=50331648,Re=O.selectionForeground.rgba>>8&16777215,Fe=O.selectionForeground)),Ne&&ee.push("xterm-decoration-top"),ke){case 16777216:case 33554432:Ge=O.ansi[fe],ee.push(`xterm-bg-${fe}`);break;case 50331648:Ge=x.rgba.toColor(fe>>16,fe>>8&255,255&fe),this._addStyle(P,`background-color:#${w((fe>>>0).toString(16),"0",6)}`);break;default:Oe?(Ge=O.foreground,ee.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Ge=O.background}switch(De||ce.isDim()&&(De=x.color.multiplyOpacity(Ge,.5)),re){case 16777216:case 33554432:ce.isBold()&&Re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Re+=8),this._applyMinimumContrast(P,Ge,O.ansi[Re],ce,De,void 0)||ee.push(`xterm-fg-${Re}`);break;case 50331648:const we=x.rgba.toColor(Re>>16&255,Re>>8&255,255&Re);this._applyMinimumContrast(P,Ge,we,ce,De,Fe)||this._addStyle(P,`color:#${w(Re.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Ge,O.foreground,ce,De,void 0)||Oe&&ee.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ee.length&&(P.className=ee.join(" "),ee.length=0),pe||be||Ye?P.textContent=X:$++,K!==this.defaultSpacing&&(P.style.letterSpacing=`${K}px`),H.push(P),se=Be}return P&&$&&(P.textContent=X),H}_applyMinimumContrast(k,j,C,E,N,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const A=this._getContrastCache(E);let M;if(N||D||(M=A.getColor(j.rgba,C.rgba)),M===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);M=x.color.ensureContrastRatio(N||j,D||C,I),A.setColor((N||j).rgba,(D||C).rgba,M??null)}return!!M&&(this._addStyle(k,`color:${M.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const C=this._selectionStart,E=this._selectionEnd;return!(!C||!E)&&(this._columnSelectMode?C[0]<=E[0]?k>=C[0]&&j>=C[1]&&k<E[0]&&j<=E[1]:k<C[0]&&j>=C[1]&&k>=E[0]&&j<=E[1]:j>C[1]&&j<E[1]||C[1]===E[1]&&j===C[1]&&k>=C[0]&&k<E[0]||C[1]<E[1]&&j===E[1]&&k<E[0]||C[1]<E[1]&&j===C[1]&&k>=C[0])}};function w(k,j,C){for(;k.length<C;)k=j+k;return k}i.DomRendererRowFactory=_=l([u(1,a.ICharacterJoinerService),u(2,S.IOptionsService),u(3,a.ICoreBrowserService),u(4,S.ICoreService),u(5,S.IDecorationService),u(6,a.IThemeService)],_)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=o.createElement("span"),u=o.createElement("span");u.style.fontWeight="bold";const c=o.createElement("span");c.style.fontStyle="italic";const g=o.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),o.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(o,l,u,c){o===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=o,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(o,l,u){let c=0;if(!l&&!u&&o.length===1&&(c=o.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(o,0);let g=o;l&&(g+="B"),u&&(g+="I");let b=this._holey.get(g);if(b===void 0){let S=0;l&&(S|=1),u&&(S|=2),b=this._measure(o,S),this._holey.set(g,b)}return b}_measure(o,l){const u=this._measureElements[l];return u.textContent=o.repeat(32),u.offsetWidth/32}}},2223:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const l=o(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function o(l){return 57508<=l&&l<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},i.isPowerlineGlyph=o,i.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},i.excludeFromContrastRatioDemands=function(l){return o(l)||(function(u){return 9472<=u&&u<=9631})(l)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(o){this._bufferService=o,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,l=this.selectionEnd;return!(!o||!l)&&(o[1]>l[1]||o[1]===l[1]&&o[0]>l[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,o){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=o(2585),g=o(8460),b=o(844);let S=i.CharSizeService=class extends b.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,f,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new x(a,f,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};i.CharSizeService=S=l([u(2,c.IOptionsService)],S);class x{constructor(f,d,h){this._document=f,this._parentElement=d,this._optionsService=h,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const f={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return f.width!==0&&f.height!==0&&(this._result.width=f.width/32,this._result.height=Math.ceil(f.height)),this._result}}},4269:function(v,i,o){var l=this&&this.__decorate||function(f,d,h,_){var w,k=arguments.length,j=k<3?d:_===null?_=Object.getOwnPropertyDescriptor(d,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,d,h,_);else for(var C=f.length-1;C>=0;C--)(w=f[C])&&(j=(k<3?w(j):k>3?w(d,h,j):w(d,h))||j);return k>3&&j&&Object.defineProperty(d,h,j),j},u=this&&this.__param||function(f,d){return function(h,_){d(h,_,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=o(3734),g=o(643),b=o(511),S=o(2585);class x extends c.AttributeData{constructor(d,h,_){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=h,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=x;let a=i.CharacterJoinerService=class Nl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(d){const h={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(h),h.id}deregister(d){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===d)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(d);if(!h||h.length===0)return[];const _=[],w=h.translateToString(!0);let k=0,j=0,C=0,E=h.getFg(0),N=h.getBg(0);for(let D=0;D<h.getTrimmedLength();D++)if(h.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==N){if(D-k>1){const A=this._getJoinedRanges(w,C,j,h,k);for(let M=0;M<A.length;M++)_.push(A[M])}k=D,C=j,E=this._workCell.fg,N=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const D=this._getJoinedRanges(w,C,j,h,k);for(let A=0;A<D.length;A++)_.push(D[A])}return _}_getJoinedRanges(d,h,_,w,k){const j=d.substring(h,_);let C=[];try{C=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const N=this._characterJoiners[E].handler(j);for(let D=0;D<N.length;D++)Nl._mergeRanges(C,N[D])}catch(N){console.error(N)}return this._stringRangesToCellRanges(C,w,k),C}_stringRangesToCellRanges(d,h,_){let w=0,k=!1,j=0,C=d[w];if(C){for(let E=_;E<this._bufferService.cols;E++){const N=h.getWidth(E),D=h.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&C[0]<=j&&(C[0]=E,k=!0),C[1]<=j){if(C[1]=E,C=d[++w],!C)break;C[0]<=j?(C[0]=E,k=!0):k=!1}j+=D}}C&&(C[1]=this._bufferService.cols)}}static _mergeRanges(d,h){let _=!1;for(let w=0;w<d.length;w++){const k=d[w];if(_){if(h[1]<=k[0])return d[w-1][1]=h[1],d;if(h[1]<=k[1])return d[w-1][1]=Math.max(h[1],k[1]),d.splice(w,1),d;d.splice(w,1),w--}else{if(h[1]<=k[0])return d.splice(w,0,h),d;if(h[1]<=k[1])return k[0]=Math.min(h[0],k[0]),d;h[0]<k[1]&&(k[0]=Math.min(h[0],k[0]),_=!0)}}return _?d[d.length-1][1]=h[1]:d.push(h),d}};i.CharacterJoinerService=a=l([u(0,S.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(o,l){this._textarea=o,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,i,o){var l=this&&this.__decorate||function(S,x,a,f){var d,h=arguments.length,_=h<3?x:f===null?f=Object.getOwnPropertyDescriptor(x,a):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(S,x,a,f);else for(var w=S.length-1;w>=0;w--)(d=S[w])&&(_=(h<3?d(_):h>3?d(x,a,_):d(x,a))||_);return h>3&&_&&Object.defineProperty(x,a,_),_},u=this&&this.__param||function(S,x){return function(a,f){x(a,f,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=o(4725),g=o(9806);let b=i.MouseService=class{constructor(S,x){this._renderService=S,this._charSizeService=x}getCoords(S,x,a,f,d){return(0,g.getCoords)(window,S,x,a,f,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(S,x){const a=(0,g.getCoordsRelativeToElement)(window,S,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};i.MouseService=b=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],b)},3230:function(v,i,o){var l=this&&this.__decorate||function(_,w,k,j){var C,E=arguments.length,N=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,w,k,j);else for(var D=_.length-1;D>=0;D--)(C=_[D])&&(N=(E<3?C(N):E>3?C(w,k,N):C(w,k))||N);return E>3&&N&&Object.defineProperty(w,k,N),N},u=this&&this.__param||function(_,w){return function(k,j){w(k,j,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=o(3656),g=o(6193),b=o(5596),S=o(4725),x=o(8460),a=o(844),f=o(7226),d=o(2585);let h=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,w,k,j,C,E,N,D){if(super(),this._rowCount=_,this._charSizeService=j,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new f.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((A,M)=>this._renderRows(A,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new b.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var A;return(A=this._renderer.value)===null||A===void 0?void 0:A.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(C.onDecorationRegistered((()=>this._fullRefresh()))),this.register(C.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(D.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const A=new N.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});A.observe(w),this.register({dispose:()=>A.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,w,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,w,this._rowCount))}_renderRows(_,w){this._renderer.value&&(_=Math.min(_,this._rowCount-1),w=Math.min(w,this._rowCount-1),this._renderer.value.renderRows(_,w),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:w}),this._onRender.fire({start:_,end:w}),this._isNextRenderRedrawOnly=!0)}resize(_,w){this._rowCount=w,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((w=>this.refreshRows(w.start,w.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,w;this._renderer.value&&((w=(_=this._renderer.value).clearTextureAtlas)===null||w===void 0||w.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,w){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,w))):this._renderer.value.handleResize(_,w),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,w,k){var j;this._selectionState.start=_,this._selectionState.end=w,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(_,w,k)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};i.RenderService=h=l([u(2,d.IOptionsService),u(3,S.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,S.ICoreBrowserService),u(7,S.IThemeService)],h)},9312:function(v,i,o){var l=this&&this.__decorate||function(C,E,N,D){var A,M=arguments.length,I=M<3?E:D===null?D=Object.getOwnPropertyDescriptor(E,N):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(C,E,N,D);else for(var L=C.length-1;L>=0;L--)(A=C[L])&&(I=(M<3?A(I):M>3?A(E,N,I):A(E,N))||I);return M>3&&I&&Object.defineProperty(E,N,I),I},u=this&&this.__param||function(C,E){return function(N,D){E(N,D,C)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=o(9806),g=o(9504),b=o(456),S=o(4725),x=o(8460),a=o(844),f=o(6114),d=o(4841),h=o(511),_=o(2585),w=" ",k=new RegExp(w,"g");let j=i.SelectionService=class extends a.Disposable{constructor(C,E,N,D,A,M,I,L,F){super(),this._element=C,this._screenElement=E,this._linkifier=N,this._bufferService=D,this._coreService=A,this._mouseService=M,this._optionsService=I,this._renderService=L,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=H=>this._handleMouseMove(H),this._mouseUpListener=H=>this._handleMouseUp(H),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((H=>this._handleTrim(H))),this.register(this._bufferService.buffers.onBufferActivate((H=>this._handleBufferActivate(H)))),this.enable(),this._model=new b.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!C||!E||C[0]===E[0]&&C[1]===E[1])}get selectionText(){const C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!C||!E)return"";const N=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(C[0]===E[0])return"";const A=C[0]<E[0]?C[0]:E[0],M=C[0]<E[0]?E[0]:C[0];for(let I=C[1];I<=E[1];I++){const L=N.translateBufferLineToString(I,!0,A,M);D.push(L)}}else{const A=C[1]===E[1]?E[0]:void 0;D.push(N.translateBufferLineToString(C[1],!0,C[0],A));for(let M=C[1]+1;M<=E[1]-1;M++){const I=N.lines.get(M),L=N.translateBufferLineToString(M,!0);I?.isWrapped?D[D.length-1]+=L:D.push(L)}if(C[1]!==E[1]){const M=N.lines.get(E[1]),I=N.translateBufferLineToString(E[1],!0,0,E[0]);M&&M.isWrapped?D[D.length-1]+=I:D.push(I)}}return D.map((A=>A.replace(k," "))).join(f.isWindows?`\r
|
|
24
|
-
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(C){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),f.isLinux&&C&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(C){const E=this._getMouseBufferCoords(C),N=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(N&&D&&E)&&this._areCoordsInSelection(E,N,D)}isCellInSelection(C,E){const N=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!N||!D)&&this._areCoordsInSelection([C,E],N,D)}_areCoordsInSelection(C,E,N){return C[1]>E[1]&&C[1]<N[1]||E[1]===N[1]&&C[1]===E[1]&&C[0]>=E[0]&&C[0]<N[0]||E[1]<N[1]&&C[1]===N[1]&&C[0]<N[0]||E[1]<N[1]&&C[1]===E[1]&&C[0]>=E[0]}_selectWordAtCursor(C,E){var N,D;const A=(D=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||D===void 0?void 0:D.range;if(A)return this._model.selectionStart=[A.start.x-1,A.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(A,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(C);return!!M&&(this._selectWordAt(M,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(C,E){this._model.clearSelection(),C=Math.max(C,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,C],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(C){this._model.handleTrim(C)&&this.refresh()}_getMouseBufferCoords(C){const E=this._mouseService.getCoords(C,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(C){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,C,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=N?0:(E>N&&(E-=N),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(C){return f.isMac?C.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:C.shiftKey}handleMouseDown(C){if(this._mouseDownTimeStamp=C.timeStamp,(C.button!==2||!this.hasSelection)&&C.button===0){if(!this._enabled){if(!this.shouldForceSelection(C))return;C.stopPropagation()}C.preventDefault(),this._dragScrollAmount=0,this._enabled&&C.shiftKey?this._handleIncrementalClick(C):C.detail===1?this._handleSingleClick(C):C.detail===2?this._handleDoubleClick(C):C.detail===3&&this._handleTripleClick(C),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(C){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(C))}_handleSingleClick(C){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(C)?3:0,this._model.selectionStart=this._getMouseBufferCoords(C),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(C){this._selectWordAtCursor(C,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(C){const E=this._getMouseBufferCoords(C);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(C){return C.altKey&&!(f.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(C){if(C.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(C),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(C),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const N=this._bufferService.buffer;if(this._model.selectionEnd[1]<N.lines.length){const D=N.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}E&&E[0]===this._model.selectionEnd[0]&&E[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const C=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(C.ydisp+this._bufferService.rows,C.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=C.ydisp),this.refresh()}}_handleMouseUp(C){const E=C.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&C.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(C,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const D=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const C=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,N=!(!C||!E||C[0]===E[0]&&C[1]===E[1]);N?C&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&C[0]===this._oldSelectionStart[0]&&C[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(C,E,N)):this._oldHasSelection&&this._fireOnSelectionChange(C,E,N)}_fireOnSelectionChange(C,E,N){this._oldSelectionStart=C,this._oldSelectionEnd=E,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(C){this.clearSelection(),this._trimListener.dispose(),this._trimListener=C.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(C,E){let N=E;for(let D=0;E>=D;D++){const A=C.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:A>1&&E!==D&&(N+=A-1)}return N}setSelection(C,E,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[C,E],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(C){this._isClickInSelection(C)||(this._selectWordAtCursor(C,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(C,E,N=!0,D=!0){if(C[0]>=this._bufferService.cols)return;const A=this._bufferService.buffer,M=A.lines.get(C[1]);if(!M)return;const I=A.translateBufferLineToString(C[1],!1);let L=this._convertViewportColToCharacterIndex(M,C[0]),F=L;const H=C[0]-L;let T=0,O=0,P=0,B=0;if(I.charAt(L)===" "){for(;L>0&&I.charAt(L-1)===" ";)L--;for(;F<I.length&&I.charAt(F+1)===" ";)F++}else{let U=C[0],W=C[0];M.getWidth(U)===0&&(T++,U--),M.getWidth(W)===2&&(O++,W++);const q=M.getString(W).length;for(q>1&&(B+=q-1,F+=q-1);U>0&&L>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===0?(T++,U--):R>1&&(P+=R-1,L-=R-1),L--,U--}for(;W<M.length&&F+1<I.length&&!this._isCharWordSeparator(M.loadCell(W+1,this._workCell));){M.loadCell(W+1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,W++):R>1&&(B+=R-1,F+=R-1),F++,W++}}F++;let $=L+H-T+P,X=Math.min(this._bufferService.cols,F-L+T+O-P-B);if(E||I.slice(L,F).trim()!==""){if(N&&$===0&&M.getCodePoint(0)!==32){const U=A.lines.get(C[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,C[1]-1],!1,!0,!1);if(W){const q=this._bufferService.cols-W.start;$-=q,X+=q}}}if(D&&$+X===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=A.lines.get(C[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const W=this._getWordAt([0,C[1]+1],!1,!1,!0);W&&(X+=W.length)}}return{start:$,length:X}}}_selectWordAt(C,E){const N=this._getWordAt(C,E);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,C[1]--;this._model.selectionStart=[N.start,C[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(C){const E=this._getWordAt(C,!0);if(E){let N=C[1];for(;E.start<0;)E.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,N]}}_isCharWordSeparator(C){return C.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(C.getChars())>=0}_selectLineAt(C){const E=this._bufferService.buffer.getWrappedRangeForLine(C),N={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(N,this._bufferService.cols)}};i.SelectionService=j=l([u(3,_.IBufferService),u(4,_.ICoreService),u(5,S.IMouseService),u(6,_.IOptionsService),u(7,S.IRenderService),u(8,S.ICoreBrowserService)],j)},4725:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const l=o(8343);i.ICharSizeService=(0,l.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),i.IMouseService=(0,l.createDecorator)("MouseService"),i.IRenderService=(0,l.createDecorator)("RenderService"),i.ISelectionService=(0,l.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,i,o){var l=this&&this.__decorate||function(j,C,E,N){var D,A=arguments.length,M=A<3?C:N===null?N=Object.getOwnPropertyDescriptor(C,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,C,E,N);else for(var I=j.length-1;I>=0;I--)(D=j[I])&&(M=(A<3?D(M):A>3?D(C,E,M):D(C,E))||M);return A>3&&M&&Object.defineProperty(C,E,M),M},u=this&&this.__param||function(j,C){return function(E,N){C(E,N,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=o(7239),g=o(8055),b=o(8460),S=o(844),x=o(2585),a=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],C=[0,95,135,175,215,255];for(let E=0;E<216;E++){const N=C[E/36%6|0],D=C[E/6%6|0],A=C[E%6];j.push({css:g.channels.toCss(N,D,A),rgba:g.channels.toRgba(N,D,A)})}for(let E=0;E<24;E++){const N=8+10*E;j.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return j})());let w=i.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:f,cursor:d,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:g.color.blend(f,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:g.color.blend(f,_),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(j={}){const C=this._colors;if(C.foreground=k(j.foreground,a),C.background=k(j.background,f),C.cursor=k(j.cursor,d),C.cursorAccent=k(j.cursorAccent,h),C.selectionBackgroundTransparent=k(j.selectionBackground,_),C.selectionBackgroundOpaque=g.color.blend(C.background,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundOpaque=g.color.blend(C.background,C.selectionInactiveBackgroundTransparent),C.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,C.selectionForeground===g.NULL_COLOR&&(C.selectionForeground=void 0),g.color.isOpaque(C.selectionBackgroundTransparent)&&(C.selectionBackgroundTransparent=g.color.opacity(C.selectionBackgroundTransparent,.3)),g.color.isOpaque(C.selectionInactiveBackgroundTransparent)&&(C.selectionInactiveBackgroundTransparent=g.color.opacity(C.selectionInactiveBackgroundTransparent,.3)),C.ansi=i.DEFAULT_ANSI_COLORS.slice(),C.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),C.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),C.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),C.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),C.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),C.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),C.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),C.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),C.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),C.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),C.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),C.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),C.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),C.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),C.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),C.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(C.ansi.length-16,j.extendedAnsi.length);for(let N=0;N<E;N++)C.ansi[N+16]=k(j.extendedAnsi[N],i.DEFAULT_ANSI_COLORS[N+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[j]=this._restoreColors.ansi[j]}else for(let C=0;C<this._restoreColors.ansi.length;++C)this._colors.ansi[C]=this._restoreColors.ansi[C]}modifyColors(j){j(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(j,C){if(j!==void 0)try{return g.css.toColor(j)}catch{}return C}i.ThemeService=w=l([u(0,x.IOptionsService)],w)},6349:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const l=o(8460),u=o(844);class c extends u.Disposable{constructor(b){super(),this._maxLength=b,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(b){if(this._maxLength===b)return;const S=new Array(b);for(let x=0;x<Math.min(b,this.length);x++)S[x]=this._array[this._getCyclicIndex(x)];this._array=S,this._maxLength=b,this._startIndex=0}get length(){return this._length}set length(b){if(b>this._length)for(let S=this._length;S<b;S++)this._array[S]=void 0;this._length=b}get(b){return this._array[this._getCyclicIndex(b)]}set(b,S){this._array[this._getCyclicIndex(b)]=S}push(b){this._array[this._getCyclicIndex(this._length)]=b,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(b,S,...x){if(S){for(let a=b;a<this._length-S;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+S)];this._length-=S,this.onDeleteEmitter.fire({index:b,amount:S})}for(let a=this._length-1;a>=b;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(b+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:b,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,S,x){if(!(S<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let f=S-1;f>=0;f--)this.set(b+f+x,this.get(b+f));const a=b+S+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<S;a++)this.set(b+a+x,this.get(b+a))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}i.CircularList=c},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function o(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=u<=1?l[g]:l[g]&&o(l[g],u-1);return c}},8055:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const l=o(6114);let u=0,c=0,g=0,b=0;var S,x,a,f,d;function h(w){const k=w.toString(16);return k.length<2?"0"+k:k}function _(w,k){return w<k?(k+.05)/(w+.05):(w+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(w){w.toCss=function(k,j,C,E){return E!==void 0?`#${h(k)}${h(j)}${h(C)}${h(E)}`:`#${h(k)}${h(j)}${h(C)}`},w.toRgba=function(k,j,C,E=255){return(k<<24|j<<16|C<<8|E)>>>0}})(S||(i.channels=S={})),(function(w){function k(j,C){return b=Math.round(255*C),[u,c,g]=d.toChannels(j.rgba),{css:S.toCss(u,c,g,b),rgba:S.toRgba(u,c,g,b)}}w.blend=function(j,C){if(b=(255&C.rgba)/255,b===1)return{css:C.css,rgba:C.rgba};const E=C.rgba>>24&255,N=C.rgba>>16&255,D=C.rgba>>8&255,A=j.rgba>>24&255,M=j.rgba>>16&255,I=j.rgba>>8&255;return u=A+Math.round((E-A)*b),c=M+Math.round((N-M)*b),g=I+Math.round((D-I)*b),{css:S.toCss(u,c,g),rgba:S.toRgba(u,c,g)}},w.isOpaque=function(j){return(255&j.rgba)==255},w.ensureContrastRatio=function(j,C,E){const N=d.ensureContrastRatio(j.rgba,C.rgba,E);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},w.opaque=function(j){const C=(255|j.rgba)>>>0;return[u,c,g]=d.toChannels(C),{css:S.toCss(u,c,g),rgba:C}},w.opacity=k,w.multiplyOpacity=function(j,C){return b=255&j.rgba,k(j,b*C/255)},w.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(x||(i.color=x={})),(function(w){let k,j;if(!l.isNode){const C=document.createElement("canvas");C.width=1,C.height=1;const E=C.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}w.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return u=parseInt(C.slice(1,2).repeat(2),16),c=parseInt(C.slice(2,3).repeat(2),16),g=parseInt(C.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(C.slice(1,2).repeat(2),16),c=parseInt(C.slice(2,3).repeat(2),16),g=parseInt(C.slice(3,4).repeat(2),16),b=parseInt(C.slice(4,5).repeat(2),16),d.toColor(u,c,g,b);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const E=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return u=parseInt(E[1]),c=parseInt(E[2]),g=parseInt(E[3]),b=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,b);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=C,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,b]=k.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(u,c,g,b),css:C}}})(a||(i.css=a={})),(function(w){function k(j,C,E){const N=j/255,D=C/255,A=E/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))}w.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},w.relativeLuminance2=k})(f||(i.rgb=f={})),(function(w){function k(C,E,N){const D=C>>24&255,A=C>>16&255,M=C>>8&255;let I=E>>24&255,L=E>>16&255,F=E>>8&255,H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));for(;H<N&&(I>0||L>0||F>0);)I-=Math.max(0,Math.ceil(.1*I)),L-=Math.max(0,Math.ceil(.1*L)),F-=Math.max(0,Math.ceil(.1*F)),H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));return(I<<24|L<<16|F<<8|255)>>>0}function j(C,E,N){const D=C>>24&255,A=C>>16&255,M=C>>8&255;let I=E>>24&255,L=E>>16&255,F=E>>8&255,H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));for(;H<N&&(I<255||L<255||F<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=Math.min(255,F+Math.ceil(.1*(255-F))),H=_(f.relativeLuminance2(I,L,F),f.relativeLuminance2(D,A,M));return(I<<24|L<<16|F<<8|255)>>>0}w.ensureContrastRatio=function(C,E,N){const D=f.relativeLuminance(C>>8),A=f.relativeLuminance(E>>8);if(_(D,A)<N){if(A<D){const L=k(C,E,N),F=_(D,f.relativeLuminance(L>>8));if(F<N){const H=j(C,E,N);return F>_(D,f.relativeLuminance(H>>8))?L:H}return L}const M=j(C,E,N),I=_(D,f.relativeLuminance(M>>8));if(I<N){const L=k(C,E,N);return I>_(D,f.relativeLuminance(L>>8))?M:L}return M}},w.reduceLuminance=k,w.increaseLuminance=j,w.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]},w.toColor=function(C,E,N,D){return{css:S.toCss(C,E,N,D),rgba:S.toRgba(C,E,N,D)}}})(d||(i.rgba=d={})),i.toPaddedHex=h,i.contrastRatio=_},8969:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const l=o(844),u=o(2585),c=o(4348),g=o(7866),b=o(744),S=o(7302),x=o(6975),a=o(8460),f=o(1753),d=o(1480),h=o(7994),_=o(9282),w=o(5435),k=o(5981),j=o(2660);let C=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((D=>{var A;(A=this._onScrollApi)===null||A===void 0||A.fire(D.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(D){for(const A in D)this.optionsService.options[A]=D[A]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new S.OptionsService(D)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(x.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(f.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new w.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((A=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((A=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((A,M)=>this._inputHandler.parse(A,M)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,A){this._writeBuffer.write(D,A)}writeSync(D,A){this._logService.logLevel<=u.LogLevelEnum.WARN&&!C&&(this._logService.warn("writeSync is unreliable and will be removed soon."),C=!0),this._writeBuffer.writeSync(D,A)}resize(D,A){isNaN(D)||isNaN(A)||(D=Math.max(D,b.MINIMUM_COLS),A=Math.max(A,b.MINIMUM_ROWS),this._bufferService.resize(D,A))}scroll(D,A=!1){this._bufferService.scroll(D,A)}scrollLines(D,A,M){this._bufferService.scrollLines(D,A,M)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const A=D-this._bufferService.buffer.ydisp;A!==0&&this.scrollLines(A)}registerEscHandler(D,A){return this._inputHandler.registerEscHandler(D,A)}registerDcsHandler(D,A){return this._inputHandler.registerDcsHandler(D,A)}registerCsiHandler(D,A){return this._inputHandler.registerCsiHandler(D,A)}registerOscHandler(D,A){return this._inputHandler.registerOscHandler(D,A)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const A=this.optionsService.rawOptions.windowsPty;A&&A.buildNumber!==void 0&&A.buildNumber!==void 0?D=A.backend==="conpty"&&A.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const A of D)A.dispose()}))}}}i.CoreTerminal=E},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===o)return void this._listeners.splice(l,1)}}})),this._event}fire(o,l){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,o,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(o,l){return o((u=>l.fire(u)))}},5435:function(v,i,o){var l=this&&this.__decorate||function(H,T,O,P){var B,$=arguments.length,X=$<3?T:P===null?P=Object.getOwnPropertyDescriptor(T,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(H,T,O,P);else for(var U=H.length-1;U>=0;U--)(B=H[U])&&(X=($<3?B(X):$>3?B(T,O,X):B(T,O))||X);return $>3&&X&&Object.defineProperty(T,O,X),X},u=this&&this.__param||function(H,T){return function(O,P){T(O,P,H)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=o(2584),g=o(7116),b=o(2015),S=o(844),x=o(482),a=o(8437),f=o(8460),d=o(643),h=o(511),_=o(3734),w=o(2585),k=o(6242),j=o(6351),C=o(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function D(H,T){if(H>24)return T.setWinLines||!1;switch(H){case 1:return!!T.restoreWin;case 2:return!!T.minimizeWin;case 3:return!!T.setWinPosition;case 4:return!!T.setWinSizePixels;case 5:return!!T.raiseWin;case 6:return!!T.lowerWin;case 7:return!!T.refreshWin;case 8:return!!T.setWinSizeChars;case 9:return!!T.maximizeWin;case 10:return!!T.fullscreenWin;case 11:return!!T.getWinState;case 13:return!!T.getWinPosition;case 14:return!!T.getWinSizePixels;case 15:return!!T.getScreenSizePixels;case 16:return!!T.getCellSizePixels;case 18:return!!T.getWinSizeChars;case 19:return!!T.getScreenSizeChars;case 20:return!!T.getIconTitle;case 21:return!!T.getWinTitle;case 22:return!!T.pushTitle;case 23:return!!T.popTitle;case 24:return!!T.setWinLines}return!1}var A;(function(H){H[H.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",H[H.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(A||(i.WindowsOptionsReportType=A={}));let M=0;class I extends S.Disposable{getAttrData(){return this._curAttrData}constructor(T,O,P,B,$,X,U,W,q=new b.EscapeSequenceParser){super(),this._bufferService=T,this._charsetService=O,this._coreService=P,this._logService=B,this._optionsService=$,this._oscLinkService=X,this._coreMouseService=U,this._unicodeService=W,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new f.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new f.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new f.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new f.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new f.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new f.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new f.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new f.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new f.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new f.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new f.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new f.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new L(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._parser.setCsiHandlerFallback(((R,z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:z.toArray()})})),this._parser.setEscHandlerFallback((R=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})})),this._parser.setExecuteHandlerFallback((R=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})})),this._parser.setOscHandlerFallback(((R,z,V)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:z,data:V})})),this._parser.setDcsHandlerFallback(((R,z,V)=>{z==="HOOK"&&(V=V.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:z,payload:V})})),this._parser.setPrintHandler(((R,z,V)=>this.print(R,z,V))),this._parser.registerCsiHandler({final:"@"},(R=>this.insertChars(R))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R=>this.scrollLeft(R))),this._parser.registerCsiHandler({final:"A"},(R=>this.cursorUp(R))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R=>this.scrollRight(R))),this._parser.registerCsiHandler({final:"B"},(R=>this.cursorDown(R))),this._parser.registerCsiHandler({final:"C"},(R=>this.cursorForward(R))),this._parser.registerCsiHandler({final:"D"},(R=>this.cursorBackward(R))),this._parser.registerCsiHandler({final:"E"},(R=>this.cursorNextLine(R))),this._parser.registerCsiHandler({final:"F"},(R=>this.cursorPrecedingLine(R))),this._parser.registerCsiHandler({final:"G"},(R=>this.cursorCharAbsolute(R))),this._parser.registerCsiHandler({final:"H"},(R=>this.cursorPosition(R))),this._parser.registerCsiHandler({final:"I"},(R=>this.cursorForwardTab(R))),this._parser.registerCsiHandler({final:"J"},(R=>this.eraseInDisplay(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R=>this.eraseInDisplay(R,!0))),this._parser.registerCsiHandler({final:"K"},(R=>this.eraseInLine(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R=>this.eraseInLine(R,!0))),this._parser.registerCsiHandler({final:"L"},(R=>this.insertLines(R))),this._parser.registerCsiHandler({final:"M"},(R=>this.deleteLines(R))),this._parser.registerCsiHandler({final:"P"},(R=>this.deleteChars(R))),this._parser.registerCsiHandler({final:"S"},(R=>this.scrollUp(R))),this._parser.registerCsiHandler({final:"T"},(R=>this.scrollDown(R))),this._parser.registerCsiHandler({final:"X"},(R=>this.eraseChars(R))),this._parser.registerCsiHandler({final:"Z"},(R=>this.cursorBackwardTab(R))),this._parser.registerCsiHandler({final:"`"},(R=>this.charPosAbsolute(R))),this._parser.registerCsiHandler({final:"a"},(R=>this.hPositionRelative(R))),this._parser.registerCsiHandler({final:"b"},(R=>this.repeatPrecedingCharacter(R))),this._parser.registerCsiHandler({final:"c"},(R=>this.sendDeviceAttributesPrimary(R))),this._parser.registerCsiHandler({prefix:">",final:"c"},(R=>this.sendDeviceAttributesSecondary(R))),this._parser.registerCsiHandler({final:"d"},(R=>this.linePosAbsolute(R))),this._parser.registerCsiHandler({final:"e"},(R=>this.vPositionRelative(R))),this._parser.registerCsiHandler({final:"f"},(R=>this.hVPosition(R))),this._parser.registerCsiHandler({final:"g"},(R=>this.tabClear(R))),this._parser.registerCsiHandler({final:"h"},(R=>this.setMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R=>this.setModePrivate(R))),this._parser.registerCsiHandler({final:"l"},(R=>this.resetMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R=>this.resetModePrivate(R))),this._parser.registerCsiHandler({final:"m"},(R=>this.charAttributes(R))),this._parser.registerCsiHandler({final:"n"},(R=>this.deviceStatus(R))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R=>this.deviceStatusPrivate(R))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R=>this.softReset(R))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R=>this.setCursorStyle(R))),this._parser.registerCsiHandler({final:"r"},(R=>this.setScrollRegion(R))),this._parser.registerCsiHandler({final:"s"},(R=>this.saveCursor(R))),this._parser.registerCsiHandler({final:"t"},(R=>this.windowOptions(R))),this._parser.registerCsiHandler({final:"u"},(R=>this.restoreCursor(R))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R=>this.insertColumns(R))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R=>this.deleteColumns(R))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R=>this.selectProtected(R))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R=>this.requestMode(R,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R=>this.requestMode(R,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((R=>(this.setTitle(R),this.setIconName(R),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((R=>this.setIconName(R)))),this._parser.registerOscHandler(2,new k.OscHandler((R=>this.setTitle(R)))),this._parser.registerOscHandler(4,new k.OscHandler((R=>this.setOrReportIndexedColor(R)))),this._parser.registerOscHandler(8,new k.OscHandler((R=>this.setHyperlink(R)))),this._parser.registerOscHandler(10,new k.OscHandler((R=>this.setOrReportFgColor(R)))),this._parser.registerOscHandler(11,new k.OscHandler((R=>this.setOrReportBgColor(R)))),this._parser.registerOscHandler(12,new k.OscHandler((R=>this.setOrReportCursorColor(R)))),this._parser.registerOscHandler(104,new k.OscHandler((R=>this.restoreIndexedColor(R)))),this._parser.registerOscHandler(110,new k.OscHandler((R=>this.restoreFgColor(R)))),this._parser.registerOscHandler(111,new k.OscHandler((R=>this.restoreBgColor(R)))),this._parser.registerOscHandler(112,new k.OscHandler((R=>this.restoreCursorColor(R)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const R in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},(()=>this.selectCharset("("+R))),this._parser.registerEscHandler({intermediates:")",final:R},(()=>this.selectCharset(")"+R))),this._parser.registerEscHandler({intermediates:"*",final:R},(()=>this.selectCharset("*"+R))),this._parser.registerEscHandler({intermediates:"+",final:R},(()=>this.selectCharset("+"+R))),this._parser.registerEscHandler({intermediates:"-",final:R},(()=>this.selectCharset("-"+R))),this._parser.registerEscHandler({intermediates:".",final:R},(()=>this.selectCharset("."+R))),this._parser.registerEscHandler({intermediates:"/",final:R},(()=>this.selectCharset("/"+R)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((R=>(this._logService.error("Parsing error: ",R),R))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((R,z)=>this.requestStatusString(R,z))))}_preserveStack(T,O,P,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=T,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=P,this._parseStack.position=B}_logSlowResolvingAsync(T){this._logService.logLevel<=w.LogLevelEnum.WARN&&Promise.race([T,new Promise(((O,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(T,O){let P,B=this._activeBuffer.x,$=this._activeBuffer.y,X=0;const U=this._parseStack.paused;if(U){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(P),P;B=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,T.length>N&&(X=this._parseStack.position+N)}if(this._logService.logLevel<=w.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof T=="string"?` "${T}"`:` "${Array.prototype.map.call(T,(W=>String.fromCharCode(W))).join("")}"`),typeof T=="string"?T.split("").map((W=>W.charCodeAt(0))):T),this._parseBuffer.length<T.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(T.length,N))),U||this._dirtyRowTracker.clearRange(),T.length>N)for(let W=X;W<T.length;W+=N){const q=W+N<T.length?W+N:T.length,R=typeof T=="string"?this._stringDecoder.decode(T.substring(W,q),this._parseBuffer):this._utf8Decoder.decode(T.subarray(W,q),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,R))return this._preserveStack(B,$,R,W),this._logSlowResolvingAsync(P),P}else if(!U){const W=typeof T=="string"?this._stringDecoder.decode(T,this._parseBuffer):this._utf8Decoder.decode(T,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,W))return this._preserveStack(B,$,W,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===B&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(T,O,P){let B,$;const X=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,z=this._curAttrData;let V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-O>0&&V.getWidth(this._activeBuffer.x-1)===2&&V.setCellFromCodePoint(this._activeBuffer.x-1,0,1,z.fg,z.bg,z.extended);for(let K=O;K<P;++K){if(B=T[K],$=this._unicodeService.wcwidth(B),B<127&&X){const ee=X[String.fromCharCode(B)];ee&&(B=ee.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,x.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=W){if(q){for(;this._activeBuffer.x<W;)V.setCellFromCodePoint(this._activeBuffer.x++,0,1,z.fg,z.bg,z.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,$===2)continue}if(R&&(V.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(z),z),V.getWidth(W-1)===2&&V.setCellFromCodePoint(W-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,z.fg,z.bg,z.extended)),V.setCellFromCodePoint(this._activeBuffer.x++,B,$,z.fg,z.bg,z.extended),$>0)for(;--$;)V.setCellFromCodePoint(this._activeBuffer.x++,0,0,z.fg,z.bg,z.extended)}else V.getWidth(this._activeBuffer.x-1)?V.addCodepointToCell(this._activeBuffer.x-1,B):V.addCodepointToCell(this._activeBuffer.x-2,B)}P-O>0&&(V.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<W&&P-O>0&&V.getWidth(this._activeBuffer.x)===0&&!V.hasContent(this._activeBuffer.x)&&V.setCellFromCodePoint(this._activeBuffer.x,0,1,z.fg,z.bg,z.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(T,O){return T.final!=="t"||T.prefix||T.intermediates?this._parser.registerCsiHandler(T,O):this._parser.registerCsiHandler(T,(P=>!D(P.params[0],this._optionsService.rawOptions.windowOptions)||O(P)))}registerDcsHandler(T,O){return this._parser.registerDcsHandler(T,new j.DcsHandler(O))}registerEscHandler(T,O){return this._parser.registerEscHandler(T,O)}registerOscHandler(T,O){return this._parser.registerOscHandler(T,new k.OscHandler(O))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var T;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||T===void 0)&&T.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const T=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-T),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(T=this._bufferService.cols-1){this._activeBuffer.x=Math.min(T,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(T,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=T,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=T,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(T,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+T,this._activeBuffer.y+O)}cursorUp(T){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,T.params[0]||1)):this._moveCursor(0,-(T.params[0]||1)),!0}cursorDown(T){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,T.params[0]||1)):this._moveCursor(0,T.params[0]||1),!0}cursorForward(T){return this._moveCursor(T.params[0]||1,0),!0}cursorBackward(T){return this._moveCursor(-(T.params[0]||1),0),!0}cursorNextLine(T){return this.cursorDown(T),this._activeBuffer.x=0,!0}cursorPrecedingLine(T){return this.cursorUp(T),this._activeBuffer.x=0,!0}cursorCharAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(T){return this._setCursor(T.length>=2?(T.params[1]||1)-1:0,(T.params[0]||1)-1),!0}charPosAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(T){return this._moveCursor(T.params[0]||1,0),!0}linePosAbsolute(T){return this._setCursor(this._activeBuffer.x,(T.params[0]||1)-1),!0}vPositionRelative(T){return this._moveCursor(0,T.params[0]||1),!0}hVPosition(T){return this.cursorPosition(T),!0}tabClear(T){const O=T.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=T.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=T.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(T){const O=T.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(T,O,P,B=!1,$=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);X.replaceCells(O,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),B&&(X.isWrapped=!1)}_resetBufferLine(T,O=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+T),P.isWrapped=!1)}eraseInDisplay(T,O=!1){let P;switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);P<this._bufferService.rows;P++)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,0),this._onScroll.fire(0))}return!0}eraseInLine(T,O=!1){switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(T){this._restrictCursor();let O=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;O--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(T){this._restrictCursor();let O=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;O--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(T){let O=T.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(T){let O=T.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=T.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);B.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(T){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(T.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(T){if(!this._parser.precedingCodepoint)return!0;const O=T.params[0]||1,P=new Uint32Array(O);for(let B=0;B<O;++B)P[B]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(T){return T.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(T){return T.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(T.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(T){return(this._optionsService.rawOptions.termName+"").indexOf(T)===0}setMode(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(T){for(let O=0;O<T.length;O++)switch(T.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),T.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(T,O){const P=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:$}=this._coreMouseService,X=this._coreService,{buffers:U,cols:W}=this._bufferService,{active:q,alt:R}=U,z=this._optionsService.rawOptions,V=se=>se?1:2,K=T.params[0];return ee=K,Z=O?K===2?4:K===4?V(X.modes.insertMode):K===12?3:K===20?V(z.convertEol):0:K===1?V(P.applicationCursorKeys):K===3?z.windowOptions.setWinLines?W===80?2:W===132?1:0:0:K===6?V(P.origin):K===7?V(P.wraparound):K===8?3:K===9?V(B==="X10"):K===12?V(z.cursorBlink):K===25?V(!X.isCursorHidden):K===45?V(P.reverseWraparound):K===66?V(P.applicationKeypad):K===67?4:K===1e3?V(B==="VT200"):K===1002?V(B==="DRAG"):K===1003?V(B==="ANY"):K===1004?V(P.sendFocus):K===1005?4:K===1006?V($==="SGR"):K===1015?4:K===1016?V($==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?V(q===R):K===2004?V(P.bracketedPasteMode):0,X.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${ee};${Z}$y`),!0;var ee,Z}_updateAttrColor(T,O,P,B,$){return O===2?(T|=50331648,T&=-16777216,T|=_.AttributeData.fromColorRGB([P,B,$])):O===5&&(T&=-50331904,T|=33554432|255&P),T}_extractColor(T,O,P){const B=[0,0,-1,0,0,0];let $=0,X=0;do{if(B[X+$]=T.params[O+X],T.hasSubParams(O+X)){const U=T.getSubParams(O+X);let W=0;do B[1]===5&&($=1),B[X+W+1+$]=U[W];while(++W<U.length&&W+X+1+$<B.length);break}if(B[1]===5&&X+$>=2||B[1]===2&&X+$>=5)break;B[1]&&($=1)}while(++X+O<T.length&&X+$<B.length);for(let U=2;U<B.length;++U)B[U]===-1&&(B[U]=0);switch(B[0]){case 38:P.fg=this._updateAttrColor(P.fg,B[1],B[3],B[4],B[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,B[1],B[3],B[4],B[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,B[1],B[3],B[4],B[5])}return X}_processUnderline(T,O){O.extended=O.extended.clone(),(!~T||T>5)&&(T=1),O.extended.underlineStyle=T,O.fg|=268435456,T===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(T){T.fg=a.DEFAULT_ATTR_DATA.fg,T.bg=a.DEFAULT_ATTR_DATA.bg,T.extended=T.extended.clone(),T.extended.underlineStyle=0,T.extended.underlineColor&=-67108864,T.updateExtended()}charAttributes(T){if(T.length===1&&T.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=T.length;let P;const B=this._curAttrData;for(let $=0;$<O;$++)P=T.params[$],P>=30&&P<=37?(B.fg&=-50331904,B.fg|=16777216|P-30):P>=40&&P<=47?(B.bg&=-50331904,B.bg|=16777216|P-40):P>=90&&P<=97?(B.fg&=-50331904,B.fg|=16777224|P-90):P>=100&&P<=107?(B.bg&=-50331904,B.bg|=16777224|P-100):P===0?this._processSGR0(B):P===1?B.fg|=134217728:P===3?B.bg|=67108864:P===4?(B.fg|=268435456,this._processUnderline(T.hasSubParams($)?T.getSubParams($)[0]:1,B)):P===5?B.fg|=536870912:P===7?B.fg|=67108864:P===8?B.fg|=1073741824:P===9?B.fg|=2147483648:P===2?B.bg|=134217728:P===21?this._processUnderline(2,B):P===22?(B.fg&=-134217729,B.bg&=-134217729):P===23?B.bg&=-67108865:P===24?(B.fg&=-268435457,this._processUnderline(0,B)):P===25?B.fg&=-536870913:P===27?B.fg&=-67108865:P===28?B.fg&=-1073741825:P===29?B.fg&=2147483647:P===39?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):P===49?(B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(T,$,B):P===53?B.bg|=1073741824:P===55?B.bg&=-1073741825:P===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):P===100?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(T){switch(T.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${P}R`)}return!0}deviceStatusPrivate(T){if(T.params[0]===6){const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${P}R`)}return!0}softReset(T){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(T){const O=T.params[0]||1;switch(O){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const P=O%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(T){const O=T.params[0]||1;let P;return(T.length<2||(P=T.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(T){if(!D(T.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=T.length>1?T.params[1]:0;switch(T.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(A.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(A.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(T){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(T){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(T){return this._windowTitle=T,this._onTitleChange.fire(T),!0}setIconName(T){return this._iconName=T,!0}setOrReportIndexedColor(T){const O=[],P=T.split(";");for(;P.length>1;){const B=P.shift(),$=P.shift();if(/^\d+$/.exec(B)){const X=parseInt(B);if(F(X))if($==="?")O.push({type:0,index:X});else{const U=(0,C.parseColor)($);U&&O.push({type:1,index:X,color:U})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(T){const O=T.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(T,O){this._getCurrentLinkId()&&this._finishHyperlink();const P=T.split(":");let B;const $=P.findIndex((X=>X.startsWith("id=")));return $!==-1&&(B=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(T,O){const P=T.split(";");for(let B=0;B<P.length&&!(O>=this._specialColors.length);++B,++O)if(P[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const $=(0,C.parseColor)(P[B]);$&&this._onColor.fire([{type:1,index:this._specialColors[O],color:$}])}return!0}setOrReportFgColor(T){return this._setOrReportSpecialColor(T,0)}setOrReportBgColor(T){return this._setOrReportSpecialColor(T,1)}setOrReportCursorColor(T){return this._setOrReportSpecialColor(T,2)}restoreIndexedColor(T){if(!T)return this._onColor.fire([{type:2}]),!0;const O=[],P=T.split(";");for(let B=0;B<P.length;++B)if(/^\d+$/.exec(P[B])){const $=parseInt(P[B]);F($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(T){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(T){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(T){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(T){return T.length!==2?(this.selectDefaultCharset(),!0):(T[0]==="/"||this._charsetService.setgCharset(E[T[0]],g.CHARSETS[T[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const T=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,T,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(T){return this._charsetService.setgLevel(T),!0}screenAlignmentPattern(){const T=new h.CellData;T.content=4194373,T.fg=this._curAttrData.fg,T.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const P=this._activeBuffer.ybase+this._activeBuffer.y+O,B=this._activeBuffer.lines.get(P);B&&(B.fill(T),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(T,O){const P=this._bufferService.buffer,B=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(T==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:T==='"p'?'P1$r61;1"p':T==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:T==="m"?"P1$r0m":T===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(T,O){this._dirtyRowTracker.markRangeDirty(T,O)}}i.InputHandler=I;let L=class{constructor(H){this._bufferService=H,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(H){H<this.start?this.start=H:H>this.end&&(this.end=H)}markRangeDirty(H,T){H>T&&(M=H,H=T,T=M),H<this.start&&(this.start=H),T>this.end&&(this.end=T)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(H){return 0<=H&&H<256}L=l([u(0,w.IBufferService)],L)},844:(v,i)=>{function o(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},i.toDisposable=function(l){return{dispose:l}},i.disposeArray=o,i.getDisposeArrayDisposable=function(l){return{dispose:()=>o(l)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(u,c,g){this._data[u]||(this._data[u]={}),this._data[u][c]=g}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=o,i.FourKeyMap=class{constructor(){this._data=new o}set(l,u,c,g,b){this._data.get(l,u)||this._data.set(l,u,new o),this._data.get(l,u).set(c,g,b)}get(l,u,c,g){var b;return(b=this._data.get(l,u))===null||b===void 0?void 0:b.get(c,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const o=i.isNode?"node":navigator.userAgent,l=i.isNode?"node":navigator.platform;i.isFirefox=o.includes("Firefox"),i.isLegacyEdge=o.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(o),i.getSafariVersion=function(){if(!i.isSafari)return 0;const u=o.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),i.isIpad=l==="iPad",i.isIphone=l==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),i.isLinux=l.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(o)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let o=0;i.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(o=this._search(this._getKey(l)),this._array.splice(o,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(o=this._search(u),o===-1)||this._getKey(this._array[o])!==u)return!1;do if(this._array[o]===l)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(o=this._search(l),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===l))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===l)}forEachByKey(l,u){if(this._array.length!==0&&(o=this._search(l),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===l))do u(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const b=this._getKey(this._array[g]);if(b>l)c=g-1;else{if(!(b<l)){for(;g>0&&this._getKey(this._array[g-1])===l;)g--;return g}u=g+1}}return u}}},7226:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const l=o(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(b){this._tasks.push(b),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(b){this._idleCallback=void 0;let S=0,x=0,a=b.timeRemaining(),f=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),x=Math.max(S,x),f=b.timeRemaining(),1.5*x>f)return a-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-S))}ms`),void this._start();a=f}this.clear()}}class c extends u{_requestCallback(b){return setTimeout((()=>b(this._createDeadline(16))))}_cancelCallback(b){clearTimeout(b)}_createDeadline(b){const S=Date.now()+b;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const l=o(643);i.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),b=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);b&&g&&(b.isWrapped=g[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&g[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new o;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=o;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=l},9092:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const l=o(6349),u=o(7226),c=o(3734),g=o(8437),b=o(4634),S=o(511),x=o(643),a=o(4863),f=o(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,h,_){this._hasScrollback=d,this._optionsService=h,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,h){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const h=d+this._optionsService.rawOptions.scrollback;return h>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:h}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,h){const _=this.getNullCell(g.DEFAULT_ATTR_DATA);let w=0;const k=this._getCorrectBufferLength(h);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let C=0;C<this.lines.length;C++)w+=+this.lines.get(C).resize(d,_);let j=0;if(this._rows<h)for(let C=this._rows;C<h;C++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,_)));else for(let C=this._rows;C>h;C--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const C=this.lines.length-k;C>0&&(this.lines.trimStart(C),this.ybase=Math.max(this.ybase-C,0),this.ydisp=Math.max(this.ydisp-C,0),this.savedY=Math.max(this.savedY-C,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,h-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(d,h),this._cols>d))for(let j=0;j<this.lines.length;j++)w+=+this.lines.get(j).resize(d,_);this._cols=d,this._rows=h,this._memoryCleanupQueue.clear(),w>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,h){this._cols!==d&&(d>this._cols?this._reflowLarger(d,h):this._reflowSmaller(d,h))}_reflowLarger(d,h){const _=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(_.length>0){const w=(0,b.reflowLargerCreateNewLayout)(this.lines,_);(0,b.reflowLargerApplyNewLayout)(this.lines,w.layout),this._reflowLargerAdjustViewport(d,h,w.countRemoved)}}_reflowLargerAdjustViewport(d,h,_){const w=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=_;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new g.BufferLine(d,w))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(d,h){const _=this.getNullCell(g.DEFAULT_ATTR_DATA),w=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let C=this.lines.get(j);if(!C||!C.isWrapped&&C.getTrimmedLength()<=d)continue;const E=[C];for(;C.isWrapped&&j>0;)C=this.lines.get(--j),E.unshift(C);const N=this.ybase+this.y;if(N>=j&&N<j+E.length)continue;const D=E[E.length-1].getTrimmedLength(),A=(0,b.reflowSmallerGetNewLineLengths)(E,this._cols,d),M=A.length-E.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const L=[];for(let B=0;B<M;B++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);L.push($)}L.length>0&&(w.push({start:j+E.length+k,newLines:L}),k+=L.length),E.push(...L);let F=A.length-1,H=A[F];H===0&&(F--,H=A[F]);let T=E.length-M-1,O=D;for(;T>=0;){const B=Math.min(O,H);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[T],O-B,H-B,B,!0),H-=B,H===0&&(F--,H=A[F]),O-=B,O===0){T--;const $=Math.max(T,0);O=(0,b.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let B=0;B<E.length;B++)A[B]<d&&E[B].setCell(A[B],_);let P=M-I;for(;P-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+h-1)}if(w.length>0){const j=[],C=[];for(let F=0;F<this.lines.length;F++)C.push(this.lines.get(F));const E=this.lines.length;let N=E-1,D=0,A=w[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let M=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(A&&A.start>N+M){for(let H=A.newLines.length-1;H>=0;H--)this.lines.set(F--,A.newLines[H]);F++,j.push({index:N+1,amount:A.newLines.length}),M+=A.newLines.length,A=w[++D]}else this.lines.set(F,C[N--]);let I=0;for(let F=j.length-1;F>=0;F--)j[F].index+=I,this.lines.onInsertEmitter.fire(j[F]),I+=j[F].amount;const L=Math.max(0,E+k-this.lines.maxLength);L>0&&this.lines.onTrimEmitter.fire(L)}}translateBufferLineToString(d,h,_=0,w){const k=this.lines.get(d);return k?k.translateToString(h,_,w):""}getWrappedRangeForLine(d){let h=d,_=d;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:h,last:_}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===d&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const h=new a.Marker(d);return this.markers.push(h),h.register(this.lines.onTrim((_=>{h.line-=_,h.line<0&&h.dispose()}))),h.register(this.lines.onInsert((_=>{h.line>=_.index&&(h.line+=_.amount)}))),h.register(this.lines.onDelete((_=>{h.line>=_.index&&h.line<_.index+_.amount&&h.dispose(),h.line>_.index&&(h.line-=_.amount)}))),h.register(h.onDispose((()=>this._removeMarker(h)))),h}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const l=o(3734),u=o(511),c=o(643),g=o(482);i.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let b=0;class S{constructor(a,f,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const h=f||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let _=0;_<a;++_)this.setCell(_,h);this.length=a}get(a){const f=this._data[3*a+0],d=2097151&f;return[this._data[3*a+1],2097152&f?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",f>>22,2097152&f?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,f){this._data[3*a+1]=f[c.CHAR_DATA_ATTR_INDEX],f[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=f[1],this._data[3*a+0]=2097152|a|f[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=f[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const f=this._data[3*a+0];return 2097152&f?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&f}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const f=this._data[3*a+0];return 2097152&f?this._combined[a]:2097151&f?(0,g.stringFromCodePoint)(2097151&f):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,f){return b=3*a,f.content=this._data[b+0],f.fg=this._data[b+1],f.bg=this._data[b+2],2097152&f.content&&(f.combinedData=this._combined[a]),268435456&f.bg&&(f.extended=this._extendedAttrs[a]),f}setCell(a,f){2097152&f.content&&(this._combined[a]=f.combinedData),268435456&f.bg&&(this._extendedAttrs[a]=f.extended),this._data[3*a+0]=f.content,this._data[3*a+1]=f.fg,this._data[3*a+2]=f.bg}setCellFromCodePoint(a,f,d,h,_,w){268435456&_&&(this._extendedAttrs[a]=w),this._data[3*a+0]=f|d<<22,this._data[3*a+1]=h,this._data[3*a+2]=_}addCodepointToCell(a,f){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(f):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(f),d&=-2097152,d|=2097152):d=f|4194304,this._data[3*a+0]=d)}insertCells(a,f,d,h){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length-a){const _=new u.CellData;for(let w=this.length-a-f-1;w>=0;--w)this.setCell(a+f+w,this.loadCell(a+w,_));for(let w=0;w<f;++w)this.setCell(a+w,d)}else for(let _=a;_<this.length;++_)this.setCell(_,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs)}deleteCells(a,f,d,h){if(a%=this.length,f<this.length-a){const _=new u.CellData;for(let w=0;w<this.length-a-f;++w)this.setCell(a+w,this.loadCell(a+f+w,_));for(let w=this.length-f;w<this.length;++w)this.setCell(w,d)}else for(let _=a;_<this.length;++_)this.setCell(_,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs)}replaceCells(a,f,d,h,_=!1){if(_)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&!this.isProtected(f)&&this.setCellFromCodePoint(f,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs);a<f&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f,0,1,h?.fg||0,h?.bg||0,h?.extended||new l.ExtendedAttrs);a<f&&a<this.length;)this.setCell(a++,d)}resize(a,f){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const h=new Uint32Array(d);h.set(this._data),this._data=h}for(let h=this.length;h<a;++h)this.setCell(h,f)}else{this._data=this._data.subarray(0,d);const h=Object.keys(this._combined);for(let w=0;w<h.length;w++){const k=parseInt(h[w],10);k>=a&&delete this._combined[k]}const _=Object.keys(this._extendedAttrs);for(let w=0;w<_.length;w++){const k=parseInt(_[w],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,f=!1){if(f)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const f in a._combined)this._combined[f]=a._combined[f];this._extendedAttrs={};for(const f in a._extendedAttrs)this._extendedAttrs[f]=a._extendedAttrs[f];this.isWrapped=a.isWrapped}clone(){const a=new S(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const f in this._combined)a._combined[f]=this._combined[f];for(const f in this._extendedAttrs)a._extendedAttrs[f]=this._extendedAttrs[f];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,f,d,h,_){const w=a._data;if(_)for(let j=h-1;j>=0;j--){for(let C=0;C<3;C++)this._data[3*(d+j)+C]=w[3*(f+j)+C];268435456&w[3*(f+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[f+j])}else for(let j=0;j<h;j++){for(let C=0;C<3;C++)this._data[3*(d+j)+C]=w[3*(f+j)+C];268435456&w[3*(f+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[f+j])}const k=Object.keys(a._combined);for(let j=0;j<k.length;j++){const C=parseInt(k[j],10);C>=f&&(this._combined[C-f+d]=a._combined[C])}}translateToString(a=!1,f=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let h="";for(;f<d;){const _=this._data[3*f+0],w=2097151&_;h+=2097152&_?this._combined[f]:w?(0,g.stringFromCodePoint)(w):c.WHITESPACE_CELL_CHAR,f+=_>>22||1}return h}}i.BufferLine=S},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(o,l){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return l*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(v,i)=>{function o(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const g=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,b=l[u+1].getWidth(0)===2;return g&&b?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(l,u,c,g,b){const S=[];for(let x=0;x<l.length-1;x++){let a=x,f=l.get(++a);if(!f.isWrapped)continue;const d=[l.get(x)];for(;a<l.length&&f.isWrapped;)d.push(f),f=l.get(++a);if(g>=x&&g<a){x+=d.length-1;continue}let h=0,_=o(d,h,u),w=1,k=0;for(;w<d.length;){const C=o(d,w,u),E=C-k,N=c-_,D=Math.min(E,N);d[h].copyCellsFrom(d[w],k,_,D,!1),_+=D,_===c&&(h++,_=0),k+=D,k===C&&(w++,k=0),_===0&&h!==0&&d[h-1].getWidth(c-1)===2&&(d[h].copyCellsFrom(d[h-1],c-1,_++,1,!1),d[h-1].setCell(c-1,b))}d[h].replaceCells(_,c,b);let j=0;for(let C=d.length-1;C>0&&(C>h||d[C].getTrimmedLength()===0);C--)j++;j>0&&(S.push(x+d.length-j),S.push(j)),x+=d.length-1}return S},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,b=u[g],S=0;for(let x=0;x<l.length;x++)if(b===x){const a=u[++g];l.onDeleteEmitter.fire({index:x-S,amount:a}),x+=a-1,S+=a,b=u[++g]}else c.push(x);return{layout:c,countRemoved:S}},i.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let g=0;g<u.length;g++)c.push(l.get(u[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=u.length},i.reflowSmallerGetNewLineLengths=function(l,u,c){const g=[],b=l.map(((f,d)=>o(l,d,u))).reduce(((f,d)=>f+d));let S=0,x=0,a=0;for(;a<b;){if(b-a<c){g.push(b-a);break}S+=c;const f=o(l,x,u);S>f&&(S-=f,x++);const d=l[x].getWidth(S-1)===2;d&&S--;const h=d?c-1:c;g.push(h),a+=h}return g},i.getWrappedLineTrimmedLength=o},5295:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const l=o(8460),u=o(844),c=o(9092);class g extends u.Disposable{constructor(S,x){super(),this._optionsService=S,this._bufferService=x,this._onBufferActivate=this.register(new l.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(S,x){this._normal.resize(S,x),this._alt.resize(S,x),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}i.BufferSet=g},511:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const l=o(482),u=o(643),c=o(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const x=new g;return x.setFromCharData(S),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(S[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(S[u.CHAR_DATA_CHAR_INDEX].length===2){const a=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const f=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=f&&f<=57343?this.content=1024*(a-55296)+f-56320+65536|S[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=S[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const l=o(8460),u=o(844);class c{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}i.Marker=c,c._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var o,l,u;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
-
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(o||(i.C0=o={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(l||(i.C1=l={})),(function(c){c.ST=`${o.ESC}\\`})(u||(i.C1_ESCAPED=u={}))},7399:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const l=o(2584),u={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(c,g,b,S){const x={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){x.key=l.C0.ESC+l.C0.DEL;break}x.key=l.C0.DEL;break;case 9:if(c.shiftKey){x.key=l.C0.ESC+"[Z";break}x.key=l.C0.HT,x.cancel=!0;break;case 13:x.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,x.cancel=!0;break;case 27:x.key=l.C0.ESC,c.altKey&&(x.key=l.C0.ESC+l.C0.ESC),x.cancel=!0;break;case 37:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"D",x.key===l.C0.ESC+"[1;3D"&&(x.key=l.C0.ESC+(b?"b":"[1;5D"))):x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"C",x.key===l.C0.ESC+"[1;3C"&&(x.key=l.C0.ESC+(b?"f":"[1;5C"))):x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"A",b||x.key!==l.C0.ESC+"[1;3A"||(x.key=l.C0.ESC+"[1;5A")):x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"B",b||x.key!==l.C0.ESC+"[1;3B"||(x.key=l.C0.ESC+"[1;5B")):x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(x.key=l.C0.ESC+"[2~");break;case 46:x.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:x.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:x.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?x.type=2:c.ctrlKey?x.key=l.C0.ESC+"[5;"+(a+1)+"~":x.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?x.type=3:c.ctrlKey?x.key=l.C0.ESC+"[6;"+(a+1)+"~":x.key=l.C0.ESC+"[6~";break;case 112:x.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:x.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:x.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:x.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:x.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:x.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:x.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:x.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:x.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:x.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:x.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:x.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(b&&!S||!c.altKey||c.metaKey)!b||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?x.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(x.key=l.C0.US),c.key==="@"&&(x.key=l.C0.NUL)):c.keyCode===65&&(x.type=1);else{const f=u[c.keyCode],d=f?.[c.shiftKey?1:0];if(d)x.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const h=c.ctrlKey?c.keyCode-64:c.keyCode+32;let _=String.fromCharCode(h);c.shiftKey&&(_=_.toUpperCase()),x.key=l.C0.ESC+_}else if(c.keyCode===32)x.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let h=c.code.slice(3,4);c.shiftKey||(h=h.toLowerCase()),x.key=l.C0.ESC+h,x.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?x.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?x.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?x.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?x.key=l.C0.DEL:c.keyCode===219?x.key=l.C0.ESC:c.keyCode===220?x.key=l.C0.FS:c.keyCode===221&&(x.key=l.C0.GS)}return x}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},i.utf32ToString=function(o,l=0,u=o.length){let c="";for(let g=l;g<u;++g){let b=o[g];b>65535?(b-=65536,c+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):c+=String.fromCharCode(b)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,l){const u=o.length;if(!u)return 0;let c=0,g=0;if(this._interim){const b=o.charCodeAt(g++);56320<=b&&b<=57343?l[c++]=1024*(this._interim-55296)+b-56320+65536:(l[c++]=this._interim,l[c++]=b),this._interim=0}for(let b=g;b<u;++b){const S=o.charCodeAt(b);if(55296<=S&&S<=56319){if(++b>=u)return this._interim=S,c;const x=o.charCodeAt(b);56320<=x&&x<=57343?l[c++]=1024*(S-55296)+x-56320+65536:(l[c++]=S,l[c++]=x)}else S!==65279&&(l[c++]=S)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,l){const u=o.length;if(!u)return 0;let c,g,b,S,x=0,a=0,f=0;if(this.interim[0]){let _=!1,w=this.interim[0];w&=(224&w)==192?31:(240&w)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)w<<=6,w|=k;const C=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=C-j;for(;f<E;){if(f>=u)return 0;if(k=o[f++],(192&k)!=128){f--,_=!0;break}this.interim[j++]=k,w<<=6,w|=63&k}_||(C===2?w<128?f--:l[x++]=w:C===3?w<2048||w>=55296&&w<=57343||w===65279||(l[x++]=w):w<65536||w>1114111||(l[x++]=w)),this.interim.fill(0)}const d=u-4;let h=f;for(;h<u;){for(;!(!(h<d)||128&(c=o[h])||128&(g=o[h+1])||128&(b=o[h+2])||128&(S=o[h+3]));)l[x++]=c,l[x++]=g,l[x++]=b,l[x++]=S,h+=4;if(c=o[h++],c<128)l[x++]=c;else if((224&c)==192){if(h>=u)return this.interim[0]=c,x;if(g=o[h++],(192&g)!=128){h--;continue}if(a=(31&c)<<6|63&g,a<128){h--;continue}l[x++]=a}else if((240&c)==224){if(h>=u)return this.interim[0]=c,x;if(g=o[h++],(192&g)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=g,x;if(b=o[h++],(192&b)!=128){h--;continue}if(a=(15&c)<<12|(63&g)<<6|63&b,a<2048||a>=55296&&a<=57343||a===65279)continue;l[x++]=a}else if((248&c)==240){if(h>=u)return this.interim[0]=c,x;if(g=o[h++],(192&g)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=g,x;if(b=o[h++],(192&b)!=128){h--;continue}if(h>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=b,x;if(S=o[h++],(192&S)!=128){h--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&b)<<6|63&S,a<65536||a>1114111)continue;l[x++]=a}}return x}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let u;i.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<o.length;++c)u.fill(0,o[c][0],o[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,b){let S,x=0,a=b.length-1;if(g<b[0][0]||g>b[a][1])return!1;for(;a>=x;)if(S=x+a>>1,g>b[S][1])x=S+1;else{if(!(g<b[S][0]))return!0;a=S-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const l=o(8460),u=o(844);class c extends u.Disposable{constructor(b){super(),this._action=b,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(b,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(b,S){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(S),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(S)}_innerWrite(b=0,S=!0){const x=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],f=this._action(a,S);if(f){const h=_=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(x,_);return void f.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(h)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=c},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const o=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function u(c,g){const b=c.toString(16),S=b.length<2?"0"+b:b;switch(g){case 4:return b[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const b=o.exec(g);if(b){const S=b[1]?15:b[4]?255:b[7]?4095:65535;return[Math.round(parseInt(b[1]||b[4]||b[7]||b[10],16)/S*255),Math.round(parseInt(b[2]||b[5]||b[8]||b[11],16)/S*255),Math.round(parseInt(b[3]||b[6]||b[9]||b[12],16)/S*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const b=g.length/3,S=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(g.slice(b*x,b*x+b),16);S[x]=b===1?a<<4:b===2?a:b===3?a>>4:a>>8}return S}},i.toRgbString=function(c,g=16){const[b,S,x]=c;return`rgb:${u(b,g)}/${u(S,g)}/${u(x,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const l=o(482),u=o(8742),c=o(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(S,x){this._handlers[S]===void 0&&(this._handlers[S]=[]);const a=this._handlers[S];return a.push(x),{dispose:()=>{const f=a.indexOf(x);f!==-1&&a.splice(f,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(S,x){if(this.reset(),this._ident=S,this._active=this._handlers[S]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(S,x,a){if(this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].put(S,x,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(S,x,a))}unhook(S,x=!0){if(this._active.length){let a=!1,f=this._active.length-1,d=!1;if(this._stack.paused&&(f=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;f>=0&&(a=this._active[f].unhook(S),a!==!0);f--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!1,a;f--}for(;f>=0;f--)if(a=this._active[f].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",S);this._active=g,this._ident=0}};const b=new u.Params;b.addParam(0),i.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=b,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():b,this._data="",this._hitLimit=!1}put(S,x,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(S,x,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let x=!1;if(this._hitLimit)x=!1;else if(S&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=b,this._data="",this._hitLimit=!1,a)));return this._params=b,this._data="",this._hitLimit=!1,x}}},2015:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const l=o(844),u=o(8742),c=o(6242),g=o(6351);class b{constructor(f){this.table=new Uint8Array(f)}setDefault(f,d){this.table.fill(f<<4|d)}add(f,d,h,_){this.table[d<<8|f]=h<<4|_}addMany(f,d,h,_){for(let w=0;w<f.length;w++)this.table[d<<8|f[w]]=h<<4|_}}i.TransitionTable=b;const S=160;i.VT500_TRANSITION_TABLE=(function(){const a=new b(4095),f=Array.apply(null,Array(256)).map(((j,C)=>C)),d=(j,C)=>f.slice(j,C),h=d(32,127),_=d(0,24);_.push(25),_.push.apply(_,d(28,32));const w=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(h,0,2,0),w)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(_,0,3,0),a.addMany(_,1,3,1),a.add(127,1,0,1),a.addMany(_,8,0,8),a.addMany(_,3,3,3),a.add(127,3,0,3),a.addMany(_,4,3,4),a.add(127,4,0,4),a.addMany(_,6,3,6),a.addMany(_,5,3,5),a.add(127,5,0,5),a.addMany(_,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(h,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(h,7,0,7),a.addMany(_,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(_,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(_,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(_,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(_,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(_,13,13,13),a.addMany(h,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(S,0,2,0),a.add(S,8,5,8),a.add(S,6,0,6),a.add(S,11,0,11),a.add(S,13,13,13),a})();class x extends l.Disposable{constructor(f=i.VT500_TRANSITION_TABLE){super(),this._transitions=f,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,h,_)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,h)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(f,d=[64,126]){let h=0;if(f.prefix){if(f.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=f.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(f.intermediates){if(f.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let w=0;w<f.intermediates.length;++w){const k=f.intermediates.charCodeAt(w);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=k}}if(f.final.length!==1)throw new Error("final must be a single byte");const _=f.final.charCodeAt(0);if(d[0]>_||_>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return h<<=8,h|=_,h}identToString(f){const d=[];for(;f;)d.push(String.fromCharCode(255&f)),f>>=8;return d.reverse().join("")}setPrintHandler(f){this._printHandler=f}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(f,d){const h=this._identifier(f,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const _=this._escHandlers[h];return _.push(d),{dispose:()=>{const w=_.indexOf(d);w!==-1&&_.splice(w,1)}}}clearEscHandler(f){this._escHandlers[this._identifier(f,[48,126])]&&delete this._escHandlers[this._identifier(f,[48,126])]}setEscHandlerFallback(f){this._escHandlerFb=f}setExecuteHandler(f,d){this._executeHandlers[f.charCodeAt(0)]=d}clearExecuteHandler(f){this._executeHandlers[f.charCodeAt(0)]&&delete this._executeHandlers[f.charCodeAt(0)]}setExecuteHandlerFallback(f){this._executeHandlerFb=f}registerCsiHandler(f,d){const h=this._identifier(f);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const _=this._csiHandlers[h];return _.push(d),{dispose:()=>{const w=_.indexOf(d);w!==-1&&_.splice(w,1)}}}clearCsiHandler(f){this._csiHandlers[this._identifier(f)]&&delete this._csiHandlers[this._identifier(f)]}setCsiHandlerFallback(f){this._csiHandlerFb=f}registerDcsHandler(f,d){return this._dcsParser.registerHandler(this._identifier(f),d)}clearDcsHandler(f){this._dcsParser.clearHandler(this._identifier(f))}setDcsHandlerFallback(f){this._dcsParser.setHandlerFallback(f)}registerOscHandler(f,d){return this._oscParser.registerHandler(f,d)}clearOscHandler(f){this._oscParser.clearHandler(f)}setOscHandlerFallback(f){this._oscParser.setHandlerFallback(f)}setErrorHandler(f){this._errorHandler=f}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(f,d,h,_,w){this._parseStack.state=f,this._parseStack.handlers=d,this._parseStack.handlerPos=h,this._parseStack.transition=_,this._parseStack.chunkPos=w}parse(f,d,h){let _,w=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const C=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&E>-1){for(;E>=0&&(_=C[E](this._params),_!==!0);E--)if(_ instanceof Promise)return this._parseStack.handlerPos=E,_}this._parseStack.handlers=[];break;case 4:if(h===!1&&E>-1){for(;E>=0&&(_=C[E](),_!==!0);E--)if(_ instanceof Promise)return this._parseStack.handlerPos=E,_}this._parseStack.handlers=[];break;case 6:if(w=f[this._parseStack.chunkPos],_=this._dcsParser.unhook(w!==24&&w!==26,h),_)return _;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(w=f[this._parseStack.chunkPos],_=this._oscParser.end(w!==24&&w!==26,h),_)return _;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let C=j;C<d;++C){switch(w=f[C],k=this._transitions.table[this.currentState<<8|(w<160?w:S)],k>>4){case 2:for(let M=C+1;;++M){if(M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}if(++M>=d||(w=f[M])<32||w>126&&w<S){this._printHandler(f,C,M),C=M-1;break}}break;case 3:this._executeHandlers[w]?this._executeHandlers[w]():this._executeHandlerFb(w),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:C,code:w,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|w];let N=E?E.length-1:-1;for(;N>=0&&(_=E[N](this._params),_!==!0);N--)if(_ instanceof Promise)return this._preserveStack(3,E,N,k,C),_;N<0&&this._csiHandlerFb(this._collect<<8|w,this._params),this.precedingCodepoint=0;break;case 8:do switch(w){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(w-48)}while(++C<d&&(w=f[C])>47&&w<60);C--;break;case 9:this._collect<<=8,this._collect|=w;break;case 10:const D=this._escHandlers[this._collect<<8|w];let A=D?D.length-1:-1;for(;A>=0&&(_=D[A](),_!==!0);A--)if(_ instanceof Promise)return this._preserveStack(4,D,A,k,C),_;A<0&&this._escHandlerFb(this._collect<<8|w),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|w,this._params);break;case 13:for(let M=C+1;;++M)if(M>=d||(w=f[M])===24||w===26||w===27||w>127&&w<S){this._dcsParser.put(f,C,M),C=M-1;break}break;case 14:if(_=this._dcsParser.unhook(w!==24&&w!==26),_)return this._preserveStack(6,[],0,k,C),_;w===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let M=C+1;;M++)if(M>=d||(w=f[M])<32||w>127&&w<S){this._oscParser.put(f,C,M),C=M-1;break}break;case 6:if(_=this._oscParser.end(w!==24&&w!==26),_)return this._preserveStack(5,[],0,k,C),_;w===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=x},6242:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const l=o(5770),u=o(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,b){this._handlers[g]===void 0&&(this._handlers[g]=[]);const S=this._handlers[g];return S.push(b),{dispose:()=>{const x=S.indexOf(b);x!==-1&&S.splice(x,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,b,S){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(g,b,S);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,b,S))}start(){this.reset(),this._state=1}put(g,b,S){if(this._state!==3){if(this._state===1)for(;b<S;){const x=g[b++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&S-b>0&&this._put(g,b,S)}}end(g,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,S=b,a=this._stack.fallThrough,this._stack.paused=!1),!a&&S===!1){for(;x>=0&&(S=this._active[x].end(g),S!==!0);x--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,S;x--}for(;x>=0;x--)if(S=this._active[x].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,b,S){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,b,S),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let b=!1;if(this._hitLimit)b=!1;else if(g&&(b=this._handler(this._data),b instanceof Promise))return b.then((S=>(this._data="",this._hitLimit=!1,S)));return this._data="",this._hitLimit=!1,b}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const o=2147483647;class l{static fromArray(c){const g=new l;if(!c.length)return g;for(let b=Array.isArray(c[0])?1:0;b<c.length;++b){const S=c[b];if(Array.isArray(S))for(let x=0;x<S.length;++x)g.addSubParam(S[x]);else g.addParam(S)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const b=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-b>0&&c.push(Array.prototype.slice.call(this._subParams,b,S))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>o?o:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>o?o:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,b=255&this._subParamsIdx[c];return b-g>0?this._subParams.subarray(g,b):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const b=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-b>0&&(c[g]=this._subParams.slice(b,S))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,S=b[g-1];b[g-1]=~S?Math.min(10*S+c,o):c}}i.Params=l},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===o){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(l,1)}}},8771:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const l=o(3785),u=o(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const g=this._buffer.lines.get(c);if(g)return new l.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const l=o(511);i.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new l.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const l=o(8771),u=o(8460),c=o(844);class g extends c.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,l){return this._core.registerCsiHandler(o,(u=>l(u.toArray())))}addCsiHandler(o,l){return this.registerCsiHandler(o,l)}registerDcsHandler(o,l){return this._core.registerDcsHandler(o,((u,c)=>l(u,c.toArray())))}addDcsHandler(o,l){return this.registerDcsHandler(o,l)}registerEscHandler(o,l){return this._core.registerEscHandler(o,l)}addEscHandler(o,l){return this.registerEscHandler(o,l)}registerOscHandler(o,l){return this._core.registerOscHandler(o,l)}addOscHandler(o,l){return this.registerOscHandler(o,l)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(v,i,o){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=o(8460),g=o(844),b=o(5295),S=o(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let x=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(a,this))}resize(a,f){this.cols=a,this.rows=f,this.buffers.resize(a,f),this._onResize.fire({cols:a,rows:f})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,f=!1){const d=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===a.fg&&h.getBg(0)===a.bg||(h=d.getBlankLine(a,f),this._cachedBlankLine=h),h.isWrapped=f;const _=d.ybase+d.scrollTop,w=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;w===d.lines.length-1?k?d.lines.recycle().copyFrom(h):d.lines.push(h.clone()):d.lines.splice(w+1,0,h.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=w-_+1;d.lines.shiftElements(_+1,k-1,-1),d.lines.set(w,h.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,f,d){const h=this.buffer;if(a<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else a+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const _=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+a,h.ybase),0),_!==h.ydisp&&(f||this._onScroll.fire(h.ydisp))}};i.BufferService=x=l([u(0,S.IOptionsService)],x)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,l){this._charsets[o]=l,this.glevel===o&&(this.charset=l)}}},1753:function(v,i,o){var l=this&&this.__decorate||function(h,_,w,k){var j,C=arguments.length,E=C<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,_,w,k);else for(var N=h.length-1;N>=0;N--)(j=h[N])&&(E=(C<3?j(E):C>3?j(_,w,E):j(_,w))||E);return C>3&&E&&Object.defineProperty(_,w,E),E},u=this&&this.__param||function(h,_){return function(w,k){_(w,k,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=o(2585),g=o(8460),b=o(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function x(h,_){let w=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(w|=64,w|=h.action):(w|=3&h.button,4&h.button&&(w|=64),8&h.button&&(w|=128),h.action===32?w|=32:h.action!==0||_||(w|=3)),w}const a=String.fromCharCode,f={DEFAULT:h=>{const _=[x(h,!1)+32,h.col+32,h.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${a(_[0])}${a(_[1])}${a(_[2])}`},SGR:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${x(h,!0)};${h.col};${h.row}${_}`},SGR_PIXELS:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${x(h,!0)};${h.x};${h.y}${_}`}};let d=i.CoreMouseService=class extends b.Disposable{constructor(h,_){super(),this._bufferService=h,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const w of Object.keys(S))this.addProtocol(w,S[w]);for(const w of Object.keys(f))this.addEncoding(w,f[w]);this.reset()}addProtocol(h,_){this._protocols[h]=_}addEncoding(h,_){this._encodings[h]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const _=this._encodings[this._activeEncoding](h);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,_,w){if(w){if(h.x!==_.x||h.y!==_.y)return!1}else if(h.col!==_.col||h.row!==_.row)return!1;return h.button===_.button&&h.action===_.action&&h.ctrl===_.ctrl&&h.alt===_.alt&&h.shift===_.shift}};i.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,i,o){var l=this&&this.__decorate||function(d,h,_,w){var k,j=arguments.length,C=j<3?h:w===null?w=Object.getOwnPropertyDescriptor(h,_):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(d,h,_,w);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(C=(j<3?k(C):j>3?k(h,_,C):k(h,_))||C);return j>3&&C&&Object.defineProperty(h,_,C),C},u=this&&this.__param||function(d,h){return function(_,w){h(_,w,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=o(1439),g=o(8460),b=o(844),S=o(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let f=i.CoreService=class extends b.Disposable{constructor(d,h,_){super(),this._bufferService=d,this._logService=h,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((w=>w.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((h=>h.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=f=l([u(0,S.IBufferService),u(1,S.ILogService),u(2,S.IOptionsService)],f)},9074:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const l=o(8055),u=o(8460),c=o(844),g=o(6106);let b=0,S=0;class x extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const h=new a(d);if(h){const _=h.marker.onDispose((()=>h.dispose()));h.onDispose((()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),_.dispose())})),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,h,_){var w,k,j;let C=0,E=0;for(const N of this._decorations.getKeyIterator(h))C=(w=N.options.x)!==null&&w!==void 0?w:0,E=C+((k=N.options.width)!==null&&k!==void 0?k:1),d>=C&&d<E&&(!_||((j=N.options.layer)!==null&&j!==void 0?j:"bottom")===_)&&(yield N)}forEachDecorationAtCell(d,h,_,w){this._decorations.forEachByKey(h,(k=>{var j,C,E;b=(j=k.options.x)!==null&&j!==void 0?j:0,S=b+((C=k.options.width)!==null&&C!==void 0?C:1),d>=b&&d<S&&(!_||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&w(k)}))}}i.DecorationService=x;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const l=o(2585),u=o(8343);class c{constructor(...b){this._entries=new Map;for(const[S,x]of b)this.set(S,x)}set(b,S){const x=this._entries.get(b);return this._entries.set(b,S),x}forEach(b){for(const[S,x]of this._entries.entries())b(S,x)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,b){this._services.set(g,b)}getService(g){return this._services.get(g)}createInstance(g,...b){const S=(0,u.getServiceDependencies)(g).sort(((f,d)=>f.index-d.index)),x=[];for(const f of S){const d=this._services.get(f.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${f.id}.`);x.push(d)}const a=S.length>0?S[0].index:b.length;if(b.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${b.length} static arguments`);return new g(...b,...x)}}},7866:function(v,i,o){var l=this&&this.__decorate||function(a,f,d,h){var _,w=arguments.length,k=w<3?f:h===null?h=Object.getOwnPropertyDescriptor(f,d):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,f,d,h);else for(var j=a.length-1;j>=0;j--)(_=a[j])&&(k=(w<3?_(k):w>3?_(f,d,k):_(f,d))||k);return w>3&&k&&Object.defineProperty(f,d,k),k},u=this&&this.__param||function(a,f){return function(d,h){f(d,h,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=o(844),g=o(2585),b={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let S,x=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let f=0;f<a.length;f++)typeof a[f]=="function"&&(a[f]=a[f]())}_log(a,f,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+f,...d)}trace(a,...f){var d,h;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,a,f)}debug(a,...f){var d,h;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,a,f)}info(a,...f){var d,h;this._logLevel<=g.LogLevelEnum.INFO&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,a,f)}warn(a,...f){var d,h;this._logLevel<=g.LogLevelEnum.WARN&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,a,f)}error(a,...f){var d,h;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((h=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,a,f)}};i.LogService=x=l([u(0,g.IOptionsService)],x),i.setTraceLogger=function(a){S=a},i.traceCall=function(a,f,d){if(typeof d.value!="function")throw new Error("not supported");const h=d.value;d.value=function(..._){if(S.logLevel!==g.LogLevelEnum.TRACE)return h.apply(this,_);S.trace(`GlyphRenderer#${h.name}(${_.map((k=>JSON.stringify(k))).join(", ")})`);const w=h.apply(this,_);return S.trace(`GlyphRenderer#${h.name} return`,w),w}}},7302:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const l=o(8460),u=o(844),c=o(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class b extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const f in x)if(f in a)try{const d=x[f];a[f]=this._sanitizeAndValidateOption(f,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((f=>{f===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((f=>{x.indexOf(f)!==-1&&a()}))}_setupOptions(){const x=f=>{if(!(f in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);return this.rawOptions[f]},a=(f,d)=>{if(!(f in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);d=this._sanitizeAndValidateOption(f,d),this.rawOptions[f]!==d&&(this.rawOptions[f]=d,this._onOptionChange.fire(f))};for(const f in this.rawOptions){const d={get:x.bind(this,f),set:a.bind(this,f)};Object.defineProperty(this.options,f,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[x]),!(function(f){return f==="block"||f==="underline"||f==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=b},2660:function(v,i,o){var l=this&&this.__decorate||function(b,S,x,a){var f,d=arguments.length,h=d<3?S:a===null?a=Object.getOwnPropertyDescriptor(S,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(b,S,x,a);else for(var _=b.length-1;_>=0;_--)(f=b[_])&&(h=(d<3?f(h):d>3?f(S,x,h):f(S,x))||h);return d>3&&h&&Object.defineProperty(S,x,h),h},u=this&&this.__param||function(b,S){return function(x,a){S(x,a,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=o(2585);let g=i.OscLinkService=class{constructor(b){this._bufferService=b,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(b){const S=this._bufferService.buffer;if(b.id===void 0){const _=S.addMarker(S.ybase+S.y),w={data:b,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(w,_))),this._dataByLinkId.set(w.id,w),w.id}const x=b,a=this._getEntryIdKey(x),f=this._entriesWithId.get(a);if(f)return this.addLineToLink(f.id,S.ybase+S.y),f.id;const d=S.addMarker(S.ybase+S.y),h={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(h,d))),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(b,S){const x=this._dataByLinkId.get(b);if(x&&x.lines.every((a=>a.line!==S))){const a=this._bufferService.buffer.addMarker(S);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(b){var S;return(S=this._dataByLinkId.get(b))===null||S===void 0?void 0:S.data}_getEntryIdKey(b){return`${b.id};;${b.uri}`}_removeMarkerFromLink(b,S){const x=b.lines.indexOf(S);x!==-1&&(b.lines.splice(x,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};i.OscLinkService=g=l([u(0,c.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const o="di$target",l="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(u){return u[l]||[]},i.createDecorator=function(u){if(i.serviceRegistry.has(u))return i.serviceRegistry.get(u);const c=function(g,b,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,f){a[o]===a?a[l].push({id:x,index:f}):(a[l]=[{id:x,index:f}],a[o]=a)})(c,g,S)};return c.toString=()=>u,i.serviceRegistry.set(u,c),c}},2585:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const l=o(8343);var u;i.IBufferService=(0,l.createDecorator)("BufferService"),i.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),i.ICoreService=(0,l.createDecorator)("CoreService"),i.ICharsetService=(0,l.createDecorator)("CharsetService"),i.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(u||(i.LogLevelEnum=u={})),i.ILogService=(0,l.createDecorator)("LogService"),i.IOptionsService=(0,l.createDecorator)("OptionsService"),i.IOscLinkService=(0,l.createDecorator)("OscLinkService"),i.IUnicodeService=(0,l.createDecorator)("UnicodeService"),i.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const l=o(8460),u=o(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const b=c.length;for(let S=0;S<b;++S){let x=c.charCodeAt(S);if(55296<=x&&x<=56319){if(++S>=b)return g+this.wcwidth(x);const a=c.charCodeAt(S);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(x)}return g}}}},n={};function p(v){var i=n[v];if(i!==void 0)return i.exports;var o=n[v]={exports:{}};return r[v].call(o.exports,o,o.exports,p),o.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=p(9042),o=p(3236),l=p(844),u=p(5741),c=p(8285),g=p(7975),b=p(7090),S=["cols","rows"];class x extends l.Disposable{constructor(f){super(),this._core=this.register(new o.Terminal(f)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=_=>this._core.options[_],h=(_,w)=>{this._checkReadonlyOptions(_),this._core.options[_]=w};for(const _ in this._core.options){const w={get:d.bind(this,_),set:h.bind(this,_)};Object.defineProperty(this._publicOptions,_,w)}}_checkReadonlyOptions(f){if(S.includes(f))throw new Error(`Option "${f}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new b.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const f=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:f.applicationCursorKeys,applicationKeypadMode:f.applicationKeypad,bracketedPasteMode:f.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:f.origin,reverseWraparoundMode:f.reverseWraparound,sendFocusMode:f.sendFocus,wraparoundMode:f.wraparound}}get options(){return this._publicOptions}set options(f){for(const d in f)this._publicOptions[d]=f[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(f,d){this._verifyIntegers(f,d),this._core.resize(f,d)}open(f){this._core.open(f)}attachCustomKeyEventHandler(f){this._core.attachCustomKeyEventHandler(f)}registerLinkProvider(f){return this._core.registerLinkProvider(f)}registerCharacterJoiner(f){return this._checkProposedApi(),this._core.registerCharacterJoiner(f)}deregisterCharacterJoiner(f){this._checkProposedApi(),this._core.deregisterCharacterJoiner(f)}registerMarker(f=0){return this._verifyIntegers(f),this._core.registerMarker(f)}registerDecoration(f){var d,h,_;return this._checkProposedApi(),this._verifyPositiveIntegers((d=f.x)!==null&&d!==void 0?d:0,(h=f.width)!==null&&h!==void 0?h:0,(_=f.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(f)}hasSelection(){return this._core.hasSelection()}select(f,d,h){this._verifyIntegers(f,d,h),this._core.select(f,d,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(f,d){this._verifyIntegers(f,d),this._core.selectLines(f,d)}dispose(){super.dispose()}scrollLines(f){this._verifyIntegers(f),this._core.scrollLines(f)}scrollPages(f){this._verifyIntegers(f),this._core.scrollPages(f)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(f){this._verifyIntegers(f),this._core.scrollToLine(f)}clear(){this._core.clear()}write(f,d){this._core.write(f,d)}writeln(f,d){this._core.write(f),this._core.write(`\r
|
|
27
|
-
`,d)}paste(f){this._core.paste(f)}refresh(f,d){this._verifyIntegers(f,d),this._core.refresh(f,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(f){this._addonManager.loadAddon(this,f)}static get strings(){return i}_verifyIntegers(...f){for(const d of f)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...f){for(const d of f)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=x})(),m})()))})(Ri)),Ri.exports}var Zm=Qm();var Jm=2,ep=1,tp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},i=v.top+v.bottom,o=v.right+v.left,l=n-i,u=p-o-s;return{cols:Math.max(Jm,Math.floor(u/e.css.cell.width)),rows:Math.max(ep,Math.floor(l/e.css.cell.height))}}};function sp(e={}){const{cwd:s,cols:r,rows:n,onOutput:p,onExit:m}=e,[v,i]=y.useState(null),[o,l]=y.useState(()=>ts.isConnected()),[u,c]=y.useState(!1),[g,b]=y.useState(!1),[S,x]=y.useState(!1),a=y.useRef({onOutput:p,onExit:m});a.current={onOutput:p,onExit:m};const f=y.useRef(null);f.current=v,y.useEffect(()=>{if(!v)return;const k=ts.getSocket(),j=()=>{l(!0),c(!1),i(null),x(!0)},C=()=>{l(!1),c(!1)},E=M=>{M.terminalId===v&&a.current.onOutput?.(M.data)},N=M=>{M.terminalId===v&&(c(!1),a.current.onExit?.(M.exitCode),i(null))},D=M=>{M.terminalId===v&&c(!0)},A=M=>{M.terminalId===v&&c(!1)};return k.on("connect",j),k.on("disconnect",C),k.on(ct.TERMINAL_STDOUT,E),k.on(ct.TERMINAL_EXIT,N),k.on(ct.TERMINAL_SUBSCRIBED,D),k.on(ct.TERMINAL_UNSUBSCRIBED,A),l(k.connected),k.connected&&k.emit(ws.SUBSCRIBE,{topic:"terminal",id:v},M=>{M.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",C),k.off(ct.TERMINAL_STDOUT,E),k.off(ct.TERMINAL_EXIT,N),k.off(ct.TERMINAL_SUBSCRIBED,D),k.off(ct.TERMINAL_UNSUBSCRIBED,A),k.emit(ws.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=y.useCallback(async()=>{const k=ts.getSocket();if(!k.connected)return null;b(!0);try{const j=await ve.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:n});return i(j.terminalId),x(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{b(!1)}},[s,r,n]),h=y.useCallback(async()=>{const k=f.current;if(k){try{await ve.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),c(!1)}},[]),_=y.useCallback(k=>{const j=f.current;if(!j)return;ts.getSocket().emit(ws.TERMINAL_INPUT,{terminalId:j,data:k})},[]),w=y.useCallback((k,j)=>{const C=f.current;if(!C)return;ts.getSocket().emit(ws.TERMINAL_RESIZE,{terminalId:C,cols:k,rows:j})},[]);return y.useEffect(()=>()=>{const k=f.current;k&&ve.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:o,isAttached:u,isCreating:g,needsRecreate:S,create:d,destroy:h,sendInput:_,resize:w}}const rp={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},ip=he.memo(function({cwd:s,isVisible:r=!0,onExit:n,onReady:p}){const m=y.useRef(null),v=y.useRef(null),i=y.useRef(null),o=y.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:g,sendInput:b,resize:S}=sp({cwd:s,onOutput:y.useCallback(x=>{v.current?.write(x)},[]),onExit:y.useCallback(x=>{v.current?.writeln(`\r
|
|
28
|
-
\x1B[90m[Process exited with code ${x}]\x1B[0m`),n?.(x)},[n])});return y.useEffect(()=>{if(!c)return;const x=v.current;x&&x.writeln(`\r
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),y.useLayoutEffect(()=>{if(!m.current)return;const x=new Zm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:rp,scrollback:5e3,convertEol:!0}),a=new tp;x.loadAddon(a),x.open(m.current);const f=(d=0)=>{if(!(d>=5))try{const _=m.current;if(!_||_.clientWidth===0||_.clientHeight===0){setTimeout(()=>f(d+1),50);return}a.fit(),S(x.cols,x.rows)}catch{setTimeout(()=>f(d+1),50)}};return f(0),setTimeout(()=>f(1),100),v.current=x,i.current=a,()=>{x.dispose(),v.current=null,i.current=null}},[S]),y.useEffect(()=>{o.current||(o.current=!0,g())},[g]),y.useEffect(()=>{const x=v.current;if(!x||!u)return;const a=x.onData(f=>{b(f)});return()=>a.dispose()},[b,u]),y.useEffect(()=>{u&&p?.({sendInput:b})},[u,b,p]),y.useEffect(()=>{if(!r)return;const x=i.current,a=v.current,f=m.current;if(!x||!a||!f)return;let d=!1,h;const _=w=>{d||w>=5||(h=requestAnimationFrame(()=>{if(!d)if(f.clientWidth>0&&f.clientHeight>0)try{x.fit(),S(a.cols,a.rows)}catch{}else setTimeout(()=>_(w+1),30)}))};return _(0),()=>{d=!0,h!=null&&cancelAnimationFrame(h)}},[r,S]),y.useEffect(()=>{if(!m.current)return;const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=i.current,f=v.current,d=m.current;a&&f&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),S(f.cols,f.rows))}catch{}})});return x.observe(m.current),()=>x.disconnect()},[S]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),np=he.memo(function({commands:s,onSelect:r}){const{t:n}=ue(),[p,m]=y.useState(!1),v=y.useRef(null),i=y.useRef(null);return y.useEffect(()=>{if(!p)return;const o=l=>{v.current&&!v.current.contains(l.target)&&i.current&&!i.current.contains(l.target)&&m(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:i,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Ka,{size:12}),t.jsx("span",{children:n("快捷命令")}),t.jsx(ht,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((o,l)=>t.jsxs("button",{onClick:()=>{r(o.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(Xt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:o.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:o.command})]})]},l))})})]})]})});let Ti=0;function Io(){return Ti+=1,{id:`shell-${Ti}`,order:Ti}}const op=he.memo(function({cwd:s,isVisible:r=!0,quickCommands:n=[]}){const{t:p}=ue(),[m,v]=y.useState(()=>[Io()]),[i,o]=y.useState(()=>m[0].id),l=y.useRef(new Map),u=y.useCallback(()=>{const x=Io();v(a=>[...a,x]),o(x.id)},[]),c=y.useCallback((x,a)=>{a.stopPropagation(),l.current.delete(x),v(f=>{const d=f.filter(h=>h.id!==x);return x===i&&d.length>0&&o(d[d.length-1].id),d})},[i]),g=y.useCallback(x=>{l.current.delete(x),v(a=>{const f=a.filter(d=>d.id!==x);return x===i&&f.length>0&&o(f[f.length-1].id),f})},[i]),b=y.useCallback((x,a)=>{l.current.set(x,a.sendInput)},[]),S=y.useCallback(x=>{const a=l.current.get(i);a&&a(x+"\r")},[i]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:m.map(x=>t.jsxs("button",{onClick:()=>o(x.id),className:G("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",x.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Ar,{size:11,className:"shrink-0"}),t.jsx("span",{children:p("Shell {count}",{count:x.order})}),m.length>1&&t.jsx("span",{onClick:a=>c(x.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Ht,{size:10})})]},x.id))}),t.jsx("button",{onClick:u,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:p("New Terminal"),children:t.jsx(Vt,{size:14})}),n.length>0&&t.jsx(np,{commands:n,onSelect:S})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ar,{size:28}),t.jsx("span",{className:"text-xs",children:p("No terminals open")}),t.jsx("button",{onClick:u,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:p("New Terminal")})]})}):m.map(x=>t.jsx("div",{className:"absolute inset-0",style:{display:x.id===i?"block":"none"},children:t.jsx(ip,{cwd:s,isVisible:r&&x.id===i,onExit:()=>g(x.id),onReady:a=>b(x.id,a)})},x.id))})]})});function Bo(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=Array(s);r<s;r++)n[r]=e[r];return n}function ap(e){if(Array.isArray(e))return e}function lp(e,s,r){return(s=pp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function cp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,p,m,v,i=[],o=!0,l=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(o=(n=m.call(r)).done)&&(i.push(n.value),i.length!==s);o=!0);}catch(u){l=!0,p=u}finally{try{if(!o&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw p}}return i}}function dp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
30
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,n)}return r}function zo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Fo(Object(r),!0).forEach(function(n){lp(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fo(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function up(e,s){if(e==null)return{};var r,n,p=hp(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(n=0;n<m.length;n++)r=m[n],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function hp(e,s){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(s.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function fp(e,s){return ap(e)||cp(e,s)||gp(e,s)||dp()}function mp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function pp(e){var s=mp(e,"string");return typeof s=="symbol"?s:s+""}function gp(e,s){if(e){if(typeof e=="string")return Bo(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bo(e,s):void 0}}function vp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Wo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,n)}return r}function Ho(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Wo(Object(r),!0).forEach(function(n){vp(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wo(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function xp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(n){return s.reduceRight(function(p,m){return m(p)},n)}}function Us(e){return function s(){for(var r=this,n=arguments.length,p=new Array(n),m=0;m<n;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),o=0;o<v;o++)i[o]=arguments[o];return s.apply(r,[].concat(p,i))}}}function Wr(e){return{}.toString.call(e).includes("Object")}function bp(e){return!Object.keys(e).length}function tr(e){return typeof e=="function"}function _p(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function yp(e,s){return Wr(s)||is("changeType"),Object.keys(s).some(function(r){return!_p(e,r)})&&is("changeField"),s}function Sp(e){tr(e)||is("selectorType")}function wp(e){tr(e)||Wr(e)||is("handlerType"),Wr(e)&&Object.values(e).some(function(s){return!tr(s)})&&is("handlersType")}function Cp(e){e||is("initialIsRequired"),Wr(e)||is("initialType"),bp(e)&&is("initialContent")}function kp(e,s){throw new Error(e[s]||e.default)}var Ep={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},is=Us(kp)(Ep),yr={changes:yp,selector:Sp,handler:wp,initial:Cp};function jp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};yr.initial(e),yr.handler(s);var r={current:e},n=Us(Tp)(r,s),p=Us(Rp)(r),m=Us(yr.changes)(e),v=Us(Np)(r);function i(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return yr.selector(l),l(r.current)}function o(l){xp(n,p,m,v)(l)}return[i,o]}function Np(e,s){return tr(s)?s(e.current):s}function Rp(e,s){return e.current=Ho(Ho({},e.current),s),s}function Tp(e,s,r){return tr(s)?s(e.current):Object.keys(r).forEach(function(n){var p;return(p=s[n])===null||p===void 0?void 0:p.call(s,e.current[n])}),r}var Ap={create:jp},Mp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Dp(e){return function s(){for(var r=this,n=arguments.length,p=new Array(n),m=0;m<n;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),o=0;o<v;o++)i[o]=arguments[o];return s.apply(r,[].concat(p,i))}}}function Lp(e){return{}.toString.call(e).includes("Object")}function Pp(e){return e||$o("configIsRequired"),Lp(e)||$o("configType"),e.urls?(Op(),{paths:{vs:e.urls.monacoBase}}):e}function Op(){console.warn(Rl.deprecation)}function Ip(e,s){throw new Error(e[s]||e.default)}var Rl={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
31
|
-
You are using deprecated way of configuration.
|
|
32
|
-
|
|
33
|
-
Instead of using
|
|
34
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
35
|
-
use
|
|
36
|
-
monaco.config({ paths: { vs: '...' } })
|
|
37
|
-
|
|
38
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},$o=Dp(Ip)(Rl),Bp={config:Pp},Fp=function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function Tl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Tl(e[r],s[r]))}),zo(zo({},e),s)}var zp={type:"cancelation",msg:"operation is manually canceled"};function Ai(e){var s=!1,r=new Promise(function(n,p){e.then(function(m){return s?p(zp):n(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var Wp=["monaco"],Hp=Ap.create({config:Mp,isInitialized:!1,resolve:null,reject:null,monaco:null}),Al=fp(Hp,2),cr=Al[0],ni=Al[1];function $p(e){var s=Bp.config(e),r=s.monaco,n=up(s,Wp);ni(function(p){return{config:Tl(p.config,n),monaco:r}})}function Up(){var e=cr(function(s){var r=s.monaco,n=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:n,resolve:p}});if(!e.isInitialized){if(ni({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ai(Mi);if(window.monaco&&window.monaco.editor)return Ml(window.monaco),e.resolve(window.monaco),Ai(Mi);Fp(qp,Vp)(Xp)}return Ai(Mi)}function qp(e){return document.body.appendChild(e)}function Kp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Vp(e){var s=cr(function(n){var p=n.config,m=n.reject;return{config:p,reject:m}}),r=Kp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Xp(){var e=cr(function(r){var n=r.config,p=r.resolve,m=r.reject;return{config:n,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var n=r.m||r;Ml(n),e.resolve(n)},function(r){e.reject(r)})}function Ml(e){cr().monaco||ni({monaco:e})}function Yp(){return cr(function(e){var s=e.monaco;return s})}var Mi=new Promise(function(e,s){return ni({resolve:e,reject:s})}),Dl={config:$p,init:Up,__getMonacoInstance:Yp},Gp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Di=Gp,Qp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Zp=Qp;function Jp({children:e}){return he.createElement("div",{style:Zp.container},e)}var eg=Jp,tg=eg;function sg({width:e,height:s,isEditorReady:r,loading:n,_ref:p,className:m,wrapperProps:v}){return he.createElement("section",{style:{...Di.wrapper,width:e,height:s},...v},!r&&he.createElement(tg,null,n),he.createElement("div",{ref:p,style:{...Di.fullWidth,...!r&&Di.hide},className:m}))}var rg=sg,Ll=y.memo(rg);function ig(e){y.useEffect(e,[])}var Pl=ig;function ng(e,s,r=!0){let n=y.useRef(!0);y.useEffect(n.current||!r?()=>{n.current=!1}:e,s)}var Ct=ng;function Xs(){}function ks(e,s,r,n){return og(e,n)||ag(e,s,r,n)}function og(e,s){return e.editor.getModel(Ol(e,s))}function ag(e,s,r,n){return e.editor.createModel(s,r,n?Ol(e,n):void 0)}function Ol(e,s){return e.Uri.parse(s)}function lg({original:e,modified:s,language:r,originalLanguage:n,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:o=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:b="100%",className:S,wrapperProps:x={},beforeMount:a=Xs,onMount:f=Xs}){let[d,h]=y.useState(!1),[_,w]=y.useState(!0),k=y.useRef(null),j=y.useRef(null),C=y.useRef(null),E=y.useRef(f),N=y.useRef(a),D=y.useRef(!1);Pl(()=>{let L=Dl.init();return L.then(F=>(j.current=F)&&w(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?I():L.cancel()}),Ct(()=>{if(k.current&&j.current){let L=k.current.getOriginalEditor(),F=ks(j.current,e||"",n||r||"text",m||"");F!==L.getModel()&&L.setModel(F)}},[m],d),Ct(()=>{if(k.current&&j.current){let L=k.current.getModifiedEditor(),F=ks(j.current,s||"",p||r||"text",v||"");F!==L.getModel()&&L.setModel(F)}},[v],d),Ct(()=>{let L=k.current.getModifiedEditor();L.getOption(j.current.editor.EditorOption.readOnly)?L.setValue(s||""):s!==L.getValue()&&(L.executeEdits("",[{range:L.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),L.pushUndoStop())},[s],d),Ct(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Ct(()=>{let{original:L,modified:F}=k.current.getModel();j.current.editor.setModelLanguage(L,n||r||"text"),j.current.editor.setModelLanguage(F,p||r||"text")},[r,n,p],d),Ct(()=>{j.current?.editor.setTheme(l)},[l],d),Ct(()=>{k.current?.updateOptions(c)},[c],d);let A=y.useCallback(()=>{if(!j.current)return;N.current(j.current);let L=ks(j.current,e||"",n||r||"text",m||""),F=ks(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:L,modified:F})},[r,s,p,e,n,m,v]),M=y.useCallback(()=>{!D.current&&C.current&&(k.current=j.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...c}),A(),j.current?.editor.setTheme(l),h(!0),D.current=!0)},[c,l,A]);y.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),y.useEffect(()=>{!_&&!d&&M()},[_,d,M]);function I(){let L=k.current?.getModel();i||L?.original?.dispose(),o||L?.modified?.dispose(),k.current?.dispose()}return he.createElement(Ll,{width:b,height:g,isEditorReady:d,loading:u,_ref:C,className:S,wrapperProps:x})}var cg=lg;y.memo(cg);function dg(e){let s=y.useRef();return y.useEffect(()=>{s.current=e},[e]),s.current}var ug=dg,Sr=new Map;function hg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:n,language:p,path:m,theme:v="light",line:i,loading:o="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:b="100%",height:S="100%",className:x,wrapperProps:a={},beforeMount:f=Xs,onMount:d=Xs,onChange:h,onValidate:_=Xs}){let[w,k]=y.useState(!1),[j,C]=y.useState(!0),E=y.useRef(null),N=y.useRef(null),D=y.useRef(null),A=y.useRef(d),M=y.useRef(f),I=y.useRef(),L=y.useRef(n),F=ug(m),H=y.useRef(!1),T=y.useRef(!1);Pl(()=>{let B=Dl.init();return B.then($=>(E.current=$)&&C(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>N.current?P():B.cancel()}),Ct(()=>{let B=ks(E.current,e||n||"",s||p||"",m||r||"");B!==N.current?.getModel()&&(c&&Sr.set(F,N.current?.saveViewState()),N.current?.setModel(B),c&&N.current?.restoreViewState(Sr.get(m)))},[m],w),Ct(()=>{N.current?.updateOptions(l)},[l],w),Ct(()=>{!N.current||n===void 0||(N.current.getOption(E.current.editor.EditorOption.readOnly)?N.current.setValue(n):n!==N.current.getValue()&&(T.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),N.current.pushUndoStop(),T.current=!1))},[n],w),Ct(()=>{let B=N.current?.getModel();B&&p&&E.current?.editor.setModelLanguage(B,p)},[p],w),Ct(()=>{i!==void 0&&N.current?.revealLine(i)},[i],w),Ct(()=>{E.current?.editor.setTheme(v)},[v],w);let O=y.useCallback(()=>{if(!(!D.current||!E.current)&&!H.current){M.current(E.current);let B=m||r,$=ks(E.current,n||e||"",s||p||"",B||"");N.current=E.current?.editor.create(D.current,{model:$,automaticLayout:!0,...l},u),c&&N.current.restoreViewState(Sr.get(B)),E.current.editor.setTheme(v),i!==void 0&&N.current.revealLine(i),k(!0),H.current=!0}},[e,s,r,n,p,m,l,u,c,v,i]);y.useEffect(()=>{w&&A.current(N.current,E.current)},[w]),y.useEffect(()=>{!j&&!w&&O()},[j,w,O]),L.current=n,y.useEffect(()=>{w&&h&&(I.current?.dispose(),I.current=N.current?.onDidChangeModelContent(B=>{T.current||h(N.current.getValue(),B)}))},[w,h]),y.useEffect(()=>{if(w){let B=E.current.editor.onDidChangeMarkers($=>{let X=N.current.getModel()?.uri;if(X&&$.find(U=>U.path===X.path)){let U=E.current.editor.getModelMarkers({resource:X});_?.(U)}});return()=>{B?.dispose()}}return()=>{}},[w,_]);function P(){I.current?.dispose(),g?c&&Sr.set(m,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return he.createElement(Ll,{width:b,height:S,isEditorReady:w,loading:o,_ref:D,className:x,wrapperProps:a})}var fg=hg,mg=y.memo(fg),pg=mg,Tt=function(e,s){return Number(e.toFixed(s))},gg=function(e,s){return typeof e=="number"?e:s},Je=function(e,s,r){r&&typeof r=="function"&&r(e,s)},vg=function(e){return-Math.cos(e*Math.PI)/2+.5},xg=function(e){return e},bg=function(e){return e*e},_g=function(e){return e*(2-e)},yg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Sg=function(e){return e*e*e},wg=function(e){return--e*e*e+1},Cg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},kg=function(e){return e*e*e*e},Eg=function(e){return 1- --e*e*e*e},jg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Ng=function(e){return e*e*e*e*e},Rg=function(e){return 1+--e*e*e*e*e},Tg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Il={easeOut:vg,linear:xg,easeInQuad:bg,easeOutQuad:_g,easeInOutQuad:yg,easeInCubic:Sg,easeOutCubic:wg,easeInOutCubic:Cg,easeInQuart:kg,easeOutQuart:Eg,easeInOutQuart:jg,easeInQuint:Ng,easeOutQuint:Rg,easeInOutQuint:Tg},Bl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Lt=function(e){e.mounted&&(Bl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Fl(e,s,r,n){if(e.mounted){var p=new Date().getTime(),m=1;Lt(e),e.animation=function(){if(!e.mounted)return Bl(e.animation);var v=new Date().getTime()-p,i=v/r,o=Il[s],l=o(i);v>=r?(n(m),e.animation=null):e.animation&&(n(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Ag(e){var s=e.scale,r=e.positionX,n=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(n))}function as(e,s,r,n){var p=Ag(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY,u=s.scale-i,c=s.positionX-o,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):Fl(e,n,r,function(b){var S=i+u*b,x=o+c*b,a=l+g*b;m(S,x,a)})}}function Mg(e,s,r){var n=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,i=m*r,o=v*r,l=n-i,u=p-o;return{wrapperWidth:n,wrapperHeight:p,newContentWidth:i,newDiffWidth:l,newContentHeight:o,newDiffHeight:u}}var Dg=function(e,s,r,n,p,m,v){var i=e>s?r*(v?1:.5):0,o=n>p?m*(v?1:.5):0,l=e-s-i,u=i,c=n-p-o,g=o;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Fn=function(e,s){var r=e.wrapperComponent,n=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!n)throw new Error("Components are not mounted");var m=Mg(r,n,s),v=m.wrapperWidth,i=m.wrapperHeight,o=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=Dg(v,o,l,i,u,c,!!p);return g},en=function(e,s,r,n){return n?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},ds=function(e,s){var r=Fn(e,s);return e.bounds=r,r};function dr(e,s,r,n,p,m,v){var i=r.minPositionX,o=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var b=en(e,i-c,l+c,n),S=en(s,o-g,u+g,n);return{x:b,y:S}}function oi(e,s,r,n,p,m){var v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY,u=n-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:l};var c=o-s*u,g=l-r*u,b=dr(c,g,p,m,0,0,null);return b}function ur(e,s,r,n,p){var m=p?n:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Uo=function(e,s){var r=e.setup.panning.excluded,n=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,i=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),o=n&&m&&i;if(!o)return!1;var l=ai(m,r);return!l},qo=function(e){var s=e.isInitialized,r=e.isPanning,n=e.setup,p=n.panning.disabled,m=s&&r&&!p;return!!m},Lg=function(e,s){var r=e.transformState,n=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-n,y:v-p}},Pg=function(e,s){var r=s.touches,n=e.transformState,p=n.positionX,m=n.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,o=r[0].clientY;e.startCoords={x:i-p,y:o-m}}};function Og(e){var s=e.transformState,r=s.positionX,n=s.positionY,p=s.scale,m=e.setup,v=m.disabled,i=m.limitToBounds,o=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,b=u.maxPositionY,S=u.minPositionY,x=r>c||r<g,a=n>b||n<S,f=r>c?l.offsetWidth:e.setup.minPositionX||0,d=n>b?l.offsetHeight:e.setup.minPositionY||0,h=oi(e,f,d,p,e.bounds,i||o),_=h.x,w=h.y;return{scale:p,positionX:x?_:r,positionY:a?w:n}}}function zl(e,s,r,n,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,o=e.transformState,l=o.scale,u=o.positionX,c=o.positionY;if(!(v===null||i===null||s===u&&r===c)){var g=dr(s,r,i,m,n,p,v),b=g.x,S=g.y;e.setTransformState(l,b,S)}}var Ig=function(e,s,r){var n=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,i=m.lockAxisY,o=p.positionX,l=p.positionY;if(!n)return{x:o,y:l};var u=s-n.x,c=r-n.y,g=v?o:u,b=i?l:c;return{x:g,y:b}},os=function(e,s){var r=e.setup,n=e.transformState,p=n.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},Bg=function(e){var s=e.mounted,r=e.setup,n=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,i=!v||m>1||!n||s;return!!i},Fg=function(e){var s=e.mounted,r=e.velocity,n=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,i=e.transformState.scale,o=v.disabled,l=!o||i>1||!m||s;return!(!l||!r||!n)};function zg(e,s){var r=e.setup.velocityAnimation,n=r.equalToMove,p=r.animationTime,m=r.sensitivity;return n?p*s*m:p}function Ko(e,s,r,n,p,m,v,i,o,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>o?o:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<i?i:u>m?m:u}}return n?s:en(e,m,v,p)}function Wg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Hg(e,s){var r=Bg(e);if(r){var n=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,i=m.velocityAnimation.equalToMove,o=Date.now();if(n&&p&&v){var l=Wg(v,i),u=s.x-n.x,c=s.y-n.y,g=u/l,b=c/l,S=o-p,x=u*u+c*c,a=Math.sqrt(x)/S;e.velocity={velocityX:g,velocityY:b,total:a}}e.lastMousePosition=s,e.velocityTime=o}}function $g(e){var s=e.velocity,r=e.bounds,n=e.setup,p=e.wrapperComponent,m=Fg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,i=s.velocityY,o=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,b=n.limitToBounds,S=n.alignmentAnimation,x=n.zoomAnimation,a=n.panning,f=a.lockAxisY,d=a.lockAxisX,h=x.animationType,_=S.sizeX,w=S.sizeY,k=S.velocityAlignmentTime,j=k,C=zg(e,o),E=Math.max(C,j),N=os(e,_),D=os(e,w),A=N*p.offsetWidth/100,M=D*p.offsetHeight/100,I=l+A,L=u-A,F=c+M,H=g-M,T=e.transformState,O=new Date().getTime();Fl(e,h,E,function(P){var B=e.transformState,$=B.scale,X=B.positionX,U=B.positionY,W=new Date().getTime()-O,q=W/j,R=Il[S.animationType],z=1-R(Math.min(1,q)),V=1-P,K=X+v*V,ee=U+i*V,Z=Ko(K,T.positionX,X,d,b,u,l,L,I,z),se=Ko(ee,T.positionY,U,f,b,g,c,H,F,z);(X!==K||U!==ee)&&e.setTransformState($,Z,se)})}}function Vo(e,s){var r=e.transformState.scale;Lt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Pg(e,s):Lg(e,s)}function zn(e,s){var r=e.transformState.scale,n=e.setup,p=n.minScale,m=n.alignmentAnimation,v=m.disabled,i=m.sizeX,o=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!i&&!o;if(!c){var g=Og(e);g&&as(e,g,s??l,u)}}function Xo(e,s,r){var n=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(n){var o=Ig(e,s,r),l=o.x,u=o.y,c=os(e,v),g=os(e,i);Hg(e,{x:l,y:u}),zl(e,l,u,c,g)}}function Ug(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,n=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=n?.getBoundingClientRect(),v=p?.getBoundingClientRect(),i=m?.width||0,o=m?.height||0,l=v?.width||0,u=v?.height||0,c=i<l||o<u,g=!s&&r&&r?.total>.1&&c;g?$g(e):zn(e)}}function Wn(e,s,r,n){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,o=ur(Tt(s,2),m,v,0,!1),l=ds(e,o),u=oi(e,r,n,o,l,i),c=u.x,g=u.y;return{scale:o,positionX:c,positionY:g}}function Wl(e,s,r){var n=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,i=m.limitToBounds,o=m.zoomAnimation,l=o.disabled,u=o.animationTime,c=o.animationType,g=l||n>=v;if((n>=1||i)&&zn(e),!(g||!p||!e.mounted)){var b=s||p.offsetWidth/2,S=r||p.offsetHeight/2,x=Wn(e,v,b,S);x&&as(e,x,u,c)}}var ns=function(){return ns=Object.assign||function(s){for(var r,n=1,p=arguments.length;n<p;n++){r=arguments[n];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},ns.apply(this,arguments)};function Yo(e,s,r){for(var n=0,p=s.length,m;n<p;n++)(m||!(n in s))&&(m||(m=Array.prototype.slice.call(s,0,n)),m[n]=s[n]);return e.concat(m||Array.prototype.slice.call(s))}var wr={scale:1,positionX:0,positionY:0},Hs={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},tn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Hl=function(e){var s,r,n,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:wr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:wr.scale,positionX:(n=e.initialPositionX)!==null&&n!==void 0?n:wr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:wr.positionY}},Go=function(e){var s=ns({},Hs);return Object.keys(e).forEach(function(r){var n=typeof e[r]<"u",p=typeof Hs[r]<"u";if(p&&n){var m=Object.prototype.toString.call(Hs[r]),v=m==="[object Object]",i=m==="[object Array]";v?s[r]=ns(ns({},Hs[r]),e[r]):i?s[r]=Yo(Yo([],Hs[r],!0),e[r]):s[r]=e[r]}}),s},$l=function(e,s,r){var n=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,i=m.minScale,o=m.zoomAnimation,l=m.smooth,u=o.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?n*Math.exp(s*r):n+s*r,g=ur(Tt(c,3),i,v,u,!1);return g};function Ul(e,s,r,n,p){var m=e.wrapperComponent,v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-o)/i,b=(c/2-l)/i,S=$l(e,s,r),x=Wn(e,S,g,b);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");as(e,x,n,p)}function ql(e,s,r,n){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Hl(e.props),o=e.transformState,l=o.scale,u=o.positionX,c=o.positionY;if(m){var g=Fn(e,i.scale),b=dr(i.positionX,i.positionY,g,v,0,0,m),S={scale:i.scale,positionX:b.x,positionY:b.y};l===i.scale&&u===i.positionX&&c===i.positionY||(n?.(),as(e,S,s,r))}}function qg(e,s,r,n){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),i=m.x*n.scale,o=m.y*n.scale;return{x:(p.x-v.x+i)/n.scale,y:(p.y-v.y+o)/n.scale}}function Kg(e,s,r){var n=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,i=v.limitToBounds,o=v.minScale,l=v.maxScale;if(!n||!p)return m;var u=n.getBoundingClientRect(),c=s.getBoundingClientRect(),g=qg(s,n,p,m),b=g.x,S=g.y,x=c.width/m.scale,a=c.height/m.scale,f=n.offsetWidth/x,d=n.offsetHeight/a,h=ur(r||Math.min(f,d),o,l,0,!1),_=(u.width-x*h)/2,w=(u.height-a*h)/2,k=(u.left-b)*h+_,j=(u.top-S)*h+w,C=Fn(e,h),E=dr(k,j,C,i,0,0,n),N=E.x,D=E.y;return{positionX:N,positionY:D,scale:h}}var Vg=function(e){return function(s,r,n){s===void 0&&(s=.5),r===void 0&&(r=300),n===void 0&&(n="easeOut"),Ul(e,1,s,r,n)}},Xg=function(e){return function(s,r,n){s===void 0&&(s=.5),r===void 0&&(r=300),n===void 0&&(n="easeOut"),Ul(e,-1,s,r,n)}},Yg=function(e){return function(s,r,n,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,i=v.positionX,o=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var b={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?o:r,scale:Number.isNaN(n)?l:n};as(e,b,p,m)}}},Gg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),ql(e,s,r)}},Qg=function(e){return function(s,r,n){r===void 0&&(r=200),n===void 0&&(n="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var i=Kl(s||p.scale,m,v);as(e,i,r,n)}}},Zg=function(e){return function(s,r,n,p){n===void 0&&(n=600),p===void 0&&(p="easeOut"),Lt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=Kg(e,v,r);as(e,i,n,p)}}},Hr=function(e){return{instance:e,zoomIn:Vg(e),zoomOut:Xg(e),setTransform:Yg(e),resetTransform:Gg(e),centerView:Qg(e),zoomToElement:Zg(e)}},sn=function(e){return{instance:e,state:e.transformState}},Xe=function(e){var s={};return Object.assign(s,sn(e)),Object.assign(s,Hr(e)),s},Li=!1;function Pi(){try{var e={get passive(){return Li=!0,!1}};return e}catch{return Li=!1,Li}}var Cr=".".concat(tn.wrapperClass),ai=function(e,s){return s.some(function(r){return e.matches("".concat(Cr," ").concat(r,", ").concat(Cr," .").concat(r,", ").concat(Cr," ").concat(r," *, ").concat(Cr," .").concat(r," *"))})},rn=function(e){e&&clearTimeout(e)},Jg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Kl=function(e,s,r){var n=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-n)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function e0(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var t0=function(e,s){var r=e.setup.wheel,n=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,o=e.isPanning,l=s.target,u=i&&!o&&!n&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=ai(l,v);return!c},s0=function(e){return e?e.deltaY<0?1:-1:0};function r0(e,s){var r=s0(e),n=gg(s,r);return n}function Vl(e,s,r){var n=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-n.left)/r,m=(e.clientY-n.top)/r;else{var v=e.touches[0];p=(v.clientX-n.left)/r,m=(v.clientY-n.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var i0=function(e,s,r,n,p){var m=e.transformState.scale,v=e.wrapperComponent,i=e.setup,o=i.maxScale,l=i.minScale,u=i.zoomAnimation,c=i.disablePadding,g=u.size,b=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var S=m+s*r,x=n?!1:!b,a=ur(Tt(S,3),l,o,g,x&&!c);return a},n0=function(e,s){var r=e.previousWheelEvent,n=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?n<m||n>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},o0=function(e,s){var r=e.setup.pinch,n=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,i=m&&!n&&v;if(!i)return!1;var o=ai(v,p);return!o},a0=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,n=e.pinchStartDistance,p=r&&!s&&n;return!!p},l0=function(e,s,r){var n=r.getBoundingClientRect(),p=e.touches,m=Tt(p[0].clientX-n.left,5),v=Tt(p[0].clientY-n.top,5),i=Tt(p[1].clientX-n.left,5),o=Tt(p[1].clientY-n.top,5);return{x:(m+i)/2/s,y:(v+o)/2/s}},Xl=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},c0=function(e,s){var r=e.pinchStartScale,n=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,i=p.zoomAnimation,o=p.disablePadding,l=i.size,u=i.disabled;if(!r||n===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/n,g=c*r;return ur(Tt(g,2),v,m,l,!u&&!o)},d0=160,u0=100,h0=function(e,s){var r=e.props,n=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Lt(e),Je(Xe(e),s,n),Je(Xe(e),s,p))},f0=function(e,s){var r=e.props,n=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,i=e.transformState,o=i.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,b=v.disablePadding,S=v.smooth,x=c.size,a=c.disabled,f=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var h=r0(s,null),_=S?d*Math.abs(s.deltaY):f,w=i0(e,h,_,!s.ctrlKey);if(o!==w){var k=ds(e,w),j=Vl(s,m,o),C=a||x===0||u||b,E=l&&C,N=oi(e,j.x,j.y,w,k,E),D=N.x,A=N.y;e.previousWheelEvent=s,e.setTransformState(w,D,A),Je(Xe(e),s,n),Je(Xe(e),s,p)}},m0=function(e,s){var r=e.props,n=r.onWheelStop,p=r.onZoomStop;rn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Wl(e,s.x,s.y),e.wheelAnimationTimer=null)},u0);var m=n0(e,s);m&&(rn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Je(Xe(e),s,n),Je(Xe(e),s,p))},d0))},Yl=function(e){for(var s=0,r=0,n=0;n<2;n+=1)s+=e.touches[n].clientX,r+=e.touches[n].clientY;var p=s/2,m=r/2;return{x:p,y:m}},p0=function(e,s){var r=Xl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var n=Yl(s);e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y,Lt(e)},g0=function(e,s){var r=e.contentComponent,n=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,i=v.limitToBounds,o=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(n===null||!r)){var b=l0(s,m,r);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var S=Xl(s),x=c0(e,S),a=Yl(s),f=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===m&&f===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var h=ds(e,x),_=c||g===0||o,w=i&&_,k=oi(e,b.x,b.y,x,h,w),j=k.x,C=k.y;e.pinchMidpoint=b,e.lastDistance=S;var E=u.sizeX,N=u.sizeY,D=os(e,E),A=os(e,N),M=j+f,I=C+d,L=dr(M,I,h,i,D,A,p),F=L.x,H=L.y;e.setTransformState(x,F,H)}}}},v0=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Wl(e,s?.x,s?.y)},Gl=function(e,s){var r=e.props.onZoomStop,n=e.setup.doubleClick.animationTime;rn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Je(Xe(e),s,r)},n)},x0=function(e,s){var r=e.props,n=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Je(Xe(e),s,n),ql(e,v,i,function(){return Je(Xe(e),s,p)}),Gl(e,s)};function b0(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function _0(e,s){var r=e.setup,n=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,i=e.props,o=i.onZoomStart,l=i.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,b=u.step,S=u.animationTime,x=u.animationType;if(!c&&!n){if(g==="reset")return x0(e,s);if(!m)return console.error("No ContentComponent found");var a=b0(g,e.transformState.scale),f=$l(e,a,b);if(v!==f){Je(Xe(e),s,o);var d=Vl(s,m,v),h=Wn(e,f,d.x,d.y);if(!h)return console.error("Error during zoom event. New transformation state was not calculated.");Je(Xe(e),s,l),as(e,h,S,x),Gl(e,s)}}}var y0=function(e,s){var r=e.isInitialized,n=e.setup,p=e.wrapperComponent,m=n.doubleClick,v=m.disabled,i=m.excluded,o=s.target,l=p?.contains(o),u=r&&o&&l&&!v;if(!u)return!1;var c=ai(o,i);return!c},S0=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(n){r.props=n,ds(r,r.transformState.scale),r.setup=Go(n)},this.initializeWindowEvents=function(){var n,p,m=Pi(),v=(n=r.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,i=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var n,p,m=Pi(),v=(n=r.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Lt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(n){var p=Pi();n.addEventListener("wheel",r.onWheelZoom,p),n.addEventListener("dblclick",r.onDoubleClick,p),n.addEventListener("touchstart",r.onTouchPanningStart,p),n.addEventListener("touchmove",r.onTouchPanning,p),n.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(n,p){var m=!1,v=r.setup.centerOnInit,i=function(o,l){for(var u=0,c=o;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(o){o(Xe(r))}),r.observer=new ResizeObserver(function(o){if(i(o,n)||i(o,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Lt(r),ds(r,r.transformState.scale),zn(r,0)}),r.observer.observe(n),r.observer.observe(p)},this.onWheelZoom=function(n){var p=r.setup.disabled;if(!p){var m=t0(r,n);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(h0(r,n),f0(r,n),m0(r,n))}}},this.onWheelPanning=function(n){var p=r.setup,m=p.disabled,v=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||i.disabled||!i.wheelPanning||n.ctrlKey)){n.preventDefault(),n.stopPropagation();var o=r.transformState,l=o.positionX,u=o.positionY,c=l-n.deltaX,g=u-n.deltaY,b=i.lockAxisX?l:c,S=i.lockAxisY?u:g,x=r.setup.alignmentAnimation,a=x.sizeX,f=x.sizeY,d=os(r,a),h=os(r,f);b===l&&S===u||zl(r,b,S,d,h)}},this.onPanningStart=function(n){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Uo(r,n);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(n.button===0&&!r.setup.panning.allowLeftClickPan||n.button===1&&!r.setup.panning.allowMiddleClickPan||n.button===2&&!r.setup.panning.allowRightClickPan||(n.preventDefault(),n.stopPropagation(),Lt(r),Vo(r,n),Je(Xe(r),n,m)))}}},this.onPanning=function(n){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=qo(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(n.preventDefault(),n.stopPropagation(),Xo(r,n.clientX,n.clientY),Je(Xe(r),n,m))}}},this.onPanningStop=function(n){var p=r.props.onPanningStop;r.isPanning&&(Ug(r),Je(Xe(r),n,p))},this.onPinchStart=function(n){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,i=m.onZoomStart;if(!p){var o=o0(r,n);o&&(p0(r,n),Lt(r),Je(Xe(r),n,v),Je(Xe(r),n,i))}},this.onPinch=function(n){var p=r.setup.disabled,m=r.props,v=m.onPinching,i=m.onZoom;if(!p){var o=a0(r);o&&(n.preventDefault(),n.stopPropagation(),g0(r,n),Je(Xe(r),n,v),Je(Xe(r),n,i))}},this.onPinchStop=function(n){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(v0(r),Je(Xe(r),n,m),Je(Xe(r),n,v))},this.onTouchPanningStart=function(n){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Uo(r,n);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&n.touches.length===1;if(!i){r.lastTouch=+new Date,Lt(r);var o=n.touches,l=o.length===1,u=o.length===2;l&&(Lt(r),Vo(r,n),Je(Xe(r),n,m)),u&&r.onPinchStart(n)}}}},this.onTouchPanning=function(n){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&n.touches.length===1){if(p)return;var v=qo(r);if(!v)return;n.preventDefault(),n.stopPropagation();var i=n.touches[0];Xo(r,i.clientX,i.clientY),Je(Xe(r),n,m)}else n.touches.length>1&&r.onPinch(n)},this.onTouchPanningStop=function(n){r.onPanningStop(n),r.onPinchStop(n)},this.onDoubleClick=function(n){var p=r.setup.disabled;if(!p){var m=y0(r,n);m&&_0(r,n)}},this.clearPanning=function(n){r.isPanning&&r.onPanningStop(n)},this.setKeyPressed=function(n){r.pressedKeys[n.key]=!0},this.setKeyUnPressed=function(n){r.pressedKeys[n.key]=!1},this.isPressingKeys=function(n){return n.length?!!n.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(n,p,m){var v=r.props.onTransformed;if(!Number.isNaN(n)&&!Number.isNaN(p)&&!Number.isNaN(m)){n!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=n),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Xe(r);r.onChangeCallbacks.forEach(function(o){return o(i)}),Je(i,{scale:n,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var n=Kl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(n.scale,n.positionX,n.positionY)}},this.handleTransformStyles=function(n,p,m){return r.props.customTransform?r.props.customTransform(n,p,m):Jg(n,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var n=r.transformState,p=n.scale,m=n.positionX,v=n.positionY,i=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Xe(r)},this.onChange=function(n){return r.onChangeCallbacks.has(n)||r.onChangeCallbacks.add(n),function(){r.onChangeCallbacks.delete(n)}},this.onInit=function(n){return r.onInitCallbacks.has(n)||r.onInitCallbacks.add(n),function(){r.onInitCallbacks.delete(n)}},this.init=function(n,p){r.cleanupWindowEvents(),r.wrapperComponent=n,r.contentComponent=p,ds(r,r.transformState.scale),r.handleInitializeWrapperEvents(n),r.handleInitialize(n,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Xe(r);Je(m,void 0,r.props.onInit)},this.props=s,this.setup=Go(this.props),this.transformState=Hl(this.props)}return e})(),li=he.createContext(null),w0=function(e,s){return typeof e=="function"?e(s):e},C0=he.forwardRef(function(e,s){var r=y.useRef(new S0(e)).current,n=w0(e.children,Hr(r));return y.useImperativeHandle(s,function(){return Hr(r)},[r]),y.useEffect(function(){r.update(e)},[r,e]),he.createElement(li.Provider,{value:r},n)});he.forwardRef(function(e,s){var r=y.useRef(null),n=y.useContext(li);return y.useEffect(function(){return n.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=n.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[n]),he.createElement("div",ns({},e,{ref:e0([r,s])}))});function k0(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&n.firstChild?n.insertBefore(p,n.firstChild):n.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var E0=`.transform-component-module_wrapper__SPB86 {
|
|
40
|
-
position: relative;
|
|
41
|
-
width: -moz-fit-content;
|
|
42
|
-
width: fit-content;
|
|
43
|
-
height: -moz-fit-content;
|
|
44
|
-
height: fit-content;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
47
|
-
-webkit-user-select: none; /* Safari */
|
|
48
|
-
-khtml-user-select: none; /* Konqueror HTML */
|
|
49
|
-
-moz-user-select: none; /* Firefox */
|
|
50
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
51
|
-
user-select: none;
|
|
52
|
-
margin: 0;
|
|
53
|
-
padding: 0;
|
|
54
|
-
transform: translate3d(0, 0, 0);
|
|
55
|
-
}
|
|
56
|
-
.transform-component-module_content__FBWxo {
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-wrap: wrap;
|
|
59
|
-
width: -moz-fit-content;
|
|
60
|
-
width: fit-content;
|
|
61
|
-
height: -moz-fit-content;
|
|
62
|
-
height: fit-content;
|
|
63
|
-
margin: 0;
|
|
64
|
-
padding: 0;
|
|
65
|
-
transform-origin: 0% 0%;
|
|
66
|
-
}
|
|
67
|
-
.transform-component-module_content__FBWxo img {
|
|
68
|
-
pointer-events: none;
|
|
69
|
-
}
|
|
70
|
-
`,Qo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};k0(E0);var j0=function(e){var s=e.children,r=e.wrapperClass,n=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,i=e.contentStyle,o=e.wrapperProps,l=o===void 0?{}:o,u=e.contentProps,c=u===void 0?{}:u,g=y.useContext(li),b=g.init,S=g.cleanupWindowEvents,x=y.useRef(null),a=y.useRef(null);return y.useEffect(function(){var f=x.current,d=a.current;return f!==null&&d!==null&&b&&b?.(f,d),function(){S?.()}},[]),he.createElement("div",ns({},l,{ref:x,className:"".concat(tn.wrapperClass," ").concat(Qo.wrapper," ").concat(n),style:v}),he.createElement("div",ns({},c,{ref:a,className:"".concat(tn.contentClass," ").concat(Qo.content," ").concat(m),style:i}),s))},Ql=function(){var e=y.useContext(li);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},N0=function(){var e=Ql();return Hr(e)};function R0(e){var s=Ql(),r=y.useState(e(sn(s))),n=r[0],p=r[1];return y.useEffect(function(){var m=!0,v=s.onChange(function(i){m&&p(e(sn(i.instance)))});return function(){v(),m=!1}},[e,s]),n}function T0(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 A0(e,s){return kt({queryKey:le.files.tree(e||"",s),queryFn:()=>ve.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function M0(e,s){return kt({queryKey:le.files.content(e||"",s||""),queryFn:()=>ve.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function D0(e){const s=at();return y.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function L0(){const e=at();return yt({mutationFn:s=>ve.post("/files/write",s),onSuccess:(s,r)=>{const n=le.files.content(r.workingDir,r.path),p=e.getQueryData(n);e.setQueryData(n,{content:r.content,language:p?.language||T0(r.path)})}})}function P0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function O0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const I0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function B0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&I0.has(s)?bn:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Dr:s==="json"?Xd:s==="md"||s==="mdx"||s==="txt"?vn:Sd}const Zo=({depth:e,active:s,onClick:r,leftIcon:n,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:G("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:n}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Zl=({workingDir:e,path:s,depth:r,expanded:n,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ue(),{data:o,isLoading:l,isError:u}=A0(e,s),c=y.useMemo(()=>o?.items??[],[o?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const f=P0(s,g.name),d=n.has(f);return t.jsxs("div",{children:[t.jsx(Zo,{depth:r,onClick:()=>p(f),rightIcon:d?t.jsx(ht,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(Yr,{size:14,className:"text-amber-500"}):t.jsx(za,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Zl,{workingDir:e,path:f,depth:r+1,expanded:n,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},f)}const b=O0(s,g.name),S=B0(g),x=v===b,a=S===bn;return t.jsx(Zo,{depth:r,active:x,onClick:()=>m(b),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?t.jsx(S,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},b)})})},F0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:n,onCollapse:p})=>{const{t:m}=ue(),[v,i]=y.useState(()=>new Set),o=D0(e),l=y.useCallback(u=>{i(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:G("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(ir,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(fu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Zl,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:n}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},z0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function W0(e){const s=e.split(".").pop()?.toLowerCase();return s?z0.has(s):!1}function H0(e,s){const r="/api",n=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${n.toString()}`}const $0=({filePath:e})=>{const{t:s}=ue(),{zoomIn:r,zoomOut:n,centerView:p}=N0(),m=R0(i=>i.state.scale),v=Math.round(m*100);return t.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:[t.jsx("button",{type:"button",onClick:()=>n(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Ou,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(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:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(Lu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(uu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},U0=({workingDir:e,filePath:s})=>{const{t:r}=ue(),[n,p]=y.useState(!1),m=H0(e,s);return n?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(C0,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx($0,{filePath:s}),t.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:t.jsx(j0,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function q0(e){const s=e.split("/");return s[s.length-1]||e}function K0(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 V0=({active:e,name:s,isDirty:r,onClick:n,onClose:p})=>{const{t:m}=ue();return t.jsxs("button",{type:"button",onClick:n,className:G("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:[t.jsx("span",{className:G("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Ht,{size:12})})]})},X0=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:n}=ue(),[p,m]=y.useState([]),[v,i]=y.useState(null),o=L0(),[l,u]=y.useState(280),[c,g]=y.useState(!1),[b,S]=y.useState(!1),x=y.useRef(280),a=y.useCallback(()=>{g(M=>(M?u(x.current):x.current=l,!M))},[l]),f=y.useCallback(M=>{M.preventDefault(),S(!0);const I=M.clientX,L=l,F=T=>{const O=T.clientX-I,P=Math.min(480,Math.max(160,L+O));u(P)},H=()=>{S(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H)},[l]);y.useEffect(()=>{m([]),i(null)},[e]);const d=y.useMemo(()=>p.find(M=>M.path===v)||null,[p,v]),{data:h,isFetching:_,isError:w,error:k}=M0(e,d?.isImage?null:v);y.useEffect(()=>{!v||!h||m(M=>M.map(I=>I.path!==v||I.isDirty||I.loaded?I:{...I,language:h.language||I.language,content:h.content,savedContent:h.content,isDirty:!1,loaded:!0}))},[v,h]);const j=y.useCallback(M=>{m(I=>{if(I.find(H=>H.path===M))return I;const F=W0(M);return[...I,{path:M,name:q0(M),language:K0(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(M)},[]),C=y.useCallback(M=>{m(I=>{const L=I.filter(F=>F.path!==M);return i(F=>F!==M?F:L.length?L[L.length-1].path:null),L})},[]),E=y.useCallback(M=>{m(I=>I.map(L=>{if(L.path!==v)return L;const F=M!==L.savedContent;return{...L,content:M,isDirty:F}}))},[v]),N=y.useCallback(async()=>{r||!e||!d||(await o.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(M=>M.map(I=>I.path===d.path?{...I,savedContent:I.content,isDirty:!1,loaded:!0}:I)))},[d,r,o,e]),D=y.useRef(()=>{});y.useEffect(()=>{D.current=()=>{N().catch(()=>{})}},[N]),y.useEffect(()=>{const M=I=>{r||(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"&&(I.preventDefault(),D.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const A=y.useCallback((M,I)=>{M.addCommand(I.KeyMod.CtrlCmd|I.KeyCode.KeyS,()=>{D.current()})},[]);return t.jsxs("div",{className:G("flex h-full overflow-hidden bg-white",s),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:c?36:l,transition:b?"none":"width 0.15s ease"},children:c?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:n("Expand file tree"),children:t.jsx(pu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(F0,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:f,className:G("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.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:[p.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:n("No open files")}):p.map(M=>t.jsx(V0,{active:M.path===v,name:M.name,isDirty:M.isDirty,onClick:()=>i(M.path),onClose:I=>{I.stopPropagation(),C(M.path)}},M.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:n("Read-only")}),o.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin"}),n("Saving")]}),d?.isDirty&&!o.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:n("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(U0,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(pg,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>E(M??""),onMount:A,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),_&&!d.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(ze,{size:14,className:"animate-spin"}),n("Loading file...")]})}),w&&t.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:[n("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:n("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:n("No workspace selected.")})})]})]})};function ci(e,s={}){return kt({queryKey:le.git.changes(e||""),queryFn:()=>ve.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Jl(e,s,r){return kt({queryKey:le.git.diff(e||"",s||"",r),queryFn:()=>ve.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Hn(e,s){return kt({queryKey:le.git.commitFiles(e||"",s||""),queryFn:()=>ve.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function $n(e,s,r){return kt({queryKey:le.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ve.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function ec({isOpen:e,onClose:s,branchName:r,targetBranch:n,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:o}=ue(),[l,u]=y.useState(""),[c,g]=y.useState(!1);y.useEffect(()=>{e&&(g(!1),u(p??""))},[e]),y.useEffect(()=>{c||!e||u(p??"")},[p,c,e]);const b=()=>{m||s()};return t.jsx(As,{isOpen:e,onClose:b,title:o("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:b,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:o("取消")}),t.jsx("button",{onClick:()=>i(l.trim()||void 0),disabled:m,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),o("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Mr,{size:14}),o("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Pd,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:n})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:o("提交消息")}),t.jsx("textarea",{value:l,onChange:S=>{g(!0),u(S.target.value)},placeholder:o("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:o("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:o("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function ys(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function tc(e){if(!(e instanceof ja)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Ys.REBASE&&s.conflictOp!==Ys.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(n=>typeof n=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:ys(s,"sourceBranch"),targetBranch:ys(s,"targetBranch"),sourceWorktreePath:ys(s,"sourceWorktreePath"),targetWorktreePath:ys(s,"targetWorktreePath"),sourceWorkspaceId:ys(s,"sourceWorkspaceId"),targetWorkspaceId:ys(s,"targetWorkspaceId")}}function Jo(e,s,r,n){const p=tc(e);if(p){r(p);return}n(e instanceof Error?e.message:s)}function sc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:n,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:i}){const{t:o}=ue(),{data:l,isLoading:u}=An(e),c=gl(),g=pl(),b=Mn(),[S,x]=y.useState(!1),[a,f]=y.useState(null);if(y.useEffect(()=>{S&&m?.()},[S,m]),u||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("正在检查工作区状态...")})]});const d=l.conflictedFiles.length>0,h=l.operation!=="idle",_=l.hasUncommittedChanges||l.untrackedCount>0,w=l.uncommittedCount+l.untrackedCount,k=!d&&!h&&!_,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!_&&!d,C=()=>{f(null),c.mutate(e,{onError:A=>{Jo(A,o("更新失败,请稍后重试"),M=>v(M),f)}})},E=()=>{f(null),x(!0)},N=A=>{f(null),g.mutate({id:e,commitMessage:A},{onSuccess:()=>x(!1),onError:M=>{Jo(M,o("提交失败,请稍后重试"),I=>{x(!1),v(I)},f)}})},D=()=>{g.isPending||(x(!1),f(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(au,{size:13}),t.jsx("span",{className:"text-xs",children:o("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),_&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Qd,{size:12,className:"shrink-0"}),t.jsx("span",{children:o("{count} 个本地改动未处理,需要先整理后再继续",{count:w})})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(sr,{size:13,className:"shrink-0"}),t.jsx("span",{children:o("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:o("处理冲突")}),t.jsx("button",{onClick:()=>b.mutate(e),disabled:b.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:b.isPending?o("正在撤销..."):o("撤销操作")})]})]}),h&&!d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?o("正在同步源分支更新..."):o("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>b.mutate(e),disabled:b.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(jd,{size:12}),b.isPending?o("正在撤销..."):o("撤销操作")]})]}),!d&&!h&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:o("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:C,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ir,{size:12}),c.isPending?o("正在同步..."):o("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:o("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!_?t.jsxs("button",{onClick:E,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Mr,{size:12}),o("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:o(_?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Mr,{size:12}),o("提交变更")]})]})]})]})}),t.jsx(ec,{isOpen:S,onClose:D,branchName:s,targetBranch:r,commitMessage:n,isPending:g.isPending,error:a,onConfirm:N})]})}const Oi=50,Ii=400,ea={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"},ta={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function rc(e){const s=e.split("/");return s[s.length-1]||e}function Y0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function G0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Nr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const nn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:G("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Q0=({line:e,lineNum:s})=>{let r="",n="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",n="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(n="text-muted-foreground/70"),t.jsxs("div",{className:G("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:G("pl-2 whitespace-pre",n),children:e})]})},ic=({diff:e})=>{const{t:s}=ue(),[r,n]=y.useState(!1),p=y.useMemo(()=>e.split(`
|
|
71
|
-
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Ii,v=m?p.slice(0,Ii):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((i,o)=>t.jsx(Q0,{line:i,lineNum:o+1},o)),m&&t.jsx("button",{type:"button",onClick:()=>n(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Ii})})]})},Z0=({workingDir:e,path:s,diffType:r,enabled:n})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=Jl(e,n?s:null,r);return!n||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(ic,{diff:m?.diff||""})},J0=({workingDir:e,hash:s,path:r,enabled:n})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=$n(e,n?s:null,n?r:null);return!n||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(ic,{diff:m?.diff||""})},Bi=({entry:e,source:s,workingDir:r,flash:n,registerNode:p})=>{const[m,v]=y.useState(!1),[i,o]=y.useState(!1),l=y.useRef(null),u=Nr(s,e.path);y.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),y.useEffect(()=>{const b=l.current;if(!b||i)return;const S=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(o(!0),S.disconnect())},{rootMargin:"300px 0px"});return S.observe(b),()=>S.disconnect()},[i]);const c=ea[e.status]||ea.M,g=Y0(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:G("rounded-md border border-border bg-background overflow-hidden transition-shadow",n&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(b=>!b),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(ht,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:G("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:rc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(nn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Z0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(J0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function ev(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const n=r.path.split("/");let p=s;for(let m=0;m<n.length-1;m++){const v=n[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return nc(s)}function nc(e){const s=new Map;for(const r of e.dirs.values()){let n=nc(r);for(;n.dirs.size===1&&n.files.length===0;){const p=[...n.dirs.values()][0];n={...p,name:`${n.name}/${p.name}`}}s.set(n.name,n)}return{...e,dirs:s}}const tv=({dir:e,depth:s,activeKey:r,onSelect:n})=>{const[p,m]=y.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(Yr,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(za,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(oc,{node:e,depth:s+1,activeKey:r,onSelect:n})]})},oc=({node:e,depth:s,activeKey:r,onSelect:n})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(tv,{dir:p,depth:s,activeKey:r,onSelect:n},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>n(p),className:G("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:G("w-1.5 h-1.5 rounded-full shrink-0",ta[p.status]||ta.M)}),t.jsx("span",{className:G("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:rc(p.path)})]},p.cardKey)})]}),sv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:n}=ue(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:o}=pn({queryKey:le.git.log(e),queryFn:({pageParam:u=0})=>ve.get("/git/log",{params:{workingDir:e,limit:String(Oi),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Oi?void 0:c.length*Oi}),l=p?.pages.flatMap(u=>u.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(ze,{size:11,className:"animate-spin"}),t.jsx("span",{children:n("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:n("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:G("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:G("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:G("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",G0(u.timestamp)]})]})]},u.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:o,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:11,className:"animate-spin"})," ",n("正在加载...")]}):n("加载更多提交")})]})},rv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:n,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:o})=>{const{t:l}=ue(),[u,c]=y.useState({kind:"overview"}),[g,b]=y.useState(""),[S,x]=y.useState(null),[a,f]=y.useState(null),{data:d,isLoading:h,isError:_}=ci(e),w=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=Hn(e,w),C=y.useRef(new Map),E=y.useRef(null),N=y.useRef(null),D=y.useCallback((U,W)=>{W?C.current.set(U,W):C.current.delete(U)},[]),{uncommitted:A,committed:M,commitFiles:I}=y.useMemo(()=>{const U=R=>!g.trim()||R.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const R={kind:"commit",hash:u.commit.hash},z=(k?.files||[]).filter(U).map(V=>({...V,cardKey:Nr(R,V.path)}));return{uncommitted:[],committed:[],commitFiles:z}}const W=(d?.uncommitted||[]).filter(U).map(R=>({...R,cardKey:Nr({kind:"working",diffType:"uncommitted"},R.path)})),q=(d?.committed||[]).filter(U).map(R=>({...R,cardKey:Nr({kind:"working",diffType:"committed"},R.path)}));return{uncommitted:W,committed:q,commitFiles:[]}},[u,d,k,g]),L=u.kind==="commit"?I:[...A,...M],F=y.useMemo(()=>ev(L),[L]),H=y.useMemo(()=>{let U=0,W=0;for(const q of L)U+=q.additions??0,W+=q.deletions??0;return{additions:U,deletions:W,files:L.length}},[L]),T=y.useCallback(()=>{const U=E.current;if(!U)return;const W=U.getBoundingClientRect().top;let q=null,R=Number.NEGATIVE_INFINITY;for(const[z,V]of C.current){const K=V.getBoundingClientRect().top-W;K<=48&&K>R&&(R=K,q=z)}if(!q){let z=null,V=Number.POSITIVE_INFINITY;for(const[K,ee]of C.current){const Z=ee.getBoundingClientRect().top-W;Z<V&&(V=Z,z=K)}q=z}x(q)},[]);y.useEffect(()=>{const U=E.current;if(!U)return;let W=0;const q=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(T)};return U.addEventListener("scroll",q,{passive:!0}),()=>{U.removeEventListener("scroll",q),cancelAnimationFrame(W)}},[T]);const O=y.useCallback(U=>{const W=C.current.get(U.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),x(U.cardKey),f(U.cardKey),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>f(null),1200))},[]),P=y.useCallback(U=>{c(W=>W.kind==="commit"&&W.commit.hash===U.hash?{kind:"overview"}:{kind:"commit",commit:U}),b(""),x(null),E.current?.scrollTo({top:0})},[]),B=y.useCallback(()=>{c({kind:"overview"}),b(""),x(null),E.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const $=m&&s&&r&&n,X=u.kind==="commit"?j:h;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&i&&o&&t.jsx(sc,{workspaceId:s,branchName:r,targetBranch:n,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:o}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:H.files})}),t.jsx(nn,{additions:H.additions,deletions:H.deletions}),r&&n&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Gs,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:n})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:B,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Gs,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(nn,{className:"ml-auto",additions:H.additions,deletions:H.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:X?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(U=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},U))}):_&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):L.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Dr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:I.map(U=>t.jsx(Bi,{entry:U,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[A.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:A.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:A.map(U=>t.jsx(Bi,{entry:U,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))})]}),M.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(U=>t.jsx(Bi,{entry:U,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===U.cardKey,registerNode:D},U.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(_n,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:U=>b(U.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:L.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(oc,{node:F,depth:0,activeKey:S,onSelect:O})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Ts,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(sv,{workingDir:e,selectedHash:w,onSelectCommit:P})})]})]})]})]})},Fi=50,sa={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 iv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function nv(e){const s=e.split("/");return s[s.length-1]||e}function ov(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const av=({line:e,lineNum:s})=>{let r="",n="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",n="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(n="text-muted-foreground/70"),t.jsxs("div",{className:G("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:G("pl-2 whitespace-pre",n),children:e})]})},lv=({workingDir:e,hash:s,filePath:r})=>{const{t:n}=ue(),{data:p,isLoading:m,isError:v}=$n(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:n("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:n("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:n("No diff content available.")});const o=i.split(`
|
|
72
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((l,u)=>t.jsx(av,{line:l,lineNum:u+1},u))})},cv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:n})=>{const{t:p}=ue(),{data:m,isLoading:v}=Hn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(ze,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(o=>{const l=sa[o.status]||sa.M,u=ov(o.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),n(o.path)},className:G("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:G("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:o.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:nv(o.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},o.path)})})},dv=({workingDir:e})=>{const{t:s}=ue(),{data:r,isLoading:n,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=pn({queryKey:le.git.log(e||""),queryFn:({pageParam:w=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(Fi),skip:String(w)}}),initialPageParam:0,getNextPageParam:(w,k)=>w.commits.length<Fi?void 0:k.length*Fi,enabled:!!e}),o=r?.pages.flatMap(w=>w.commits)||[],[l,u]=y.useState(null),[c,g]=y.useState(null),[b,S]=y.useState(280),[x,a]=y.useState(!1),f=y.useCallback(w=>{w.preventDefault(),a(!0);const k=w.clientX,j=b,C=N=>{const D=Math.min(480,Math.max(180,j+(N.clientX-k)));S(D)},E=()=>{a(!1),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",E)},[b]),d=w=>{l===w?(u(null),g(null)):(u(w),g(null))},h=y.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(n)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(o.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Ts,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const _=o.find(w=>w.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ts,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:o.length})]})}),t.jsxs("div",{ref:h,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[o.map(w=>{const k=l===w.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(w.hash),className:G("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:G("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:w.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:w.message}),t.jsx(Mt,{size:12,className:G("shrink-0 text-muted-foreground/70 transition-transform",k&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:w.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:iv(w.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[w.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:w.body}),t.jsx(cv,{workingDir:e,hash:w.hash,selectedPath:c,onSelectFile:g})]})]},w.hash)}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:G("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:c&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Dr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:c}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",_?.shortHash,")"]})]}),t.jsx(lv,{workingDir:e,hash:l,filePath:c})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Dr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function uv(e){return kt({queryKey:le.previews.status(e??""),queryFn:async()=>{const s=await ve.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function hv(e){const s=at();return yt({mutationFn:r=>ve.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:le.previews.status(e)}),s.invalidateQueries({queryKey:le.workspaces.all}))}})}function fv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function mv({workspaceId:e,readOnly:s}){const{t:r}=ue(),{data:n,isLoading:p,refetch:m,isFetching:v}=uv(e),i=hv(e),[o,l]=y.useState(""),[u,c]=y.useState(0);y.useEffect(()=>{l(n?.target??"")},[n?.target]);const g=y.useMemo(()=>!n?.ready||!n.viewUrl?null:`${n.viewUrl}?_=${u}`,[u,n?.ready,n?.viewUrl]),b=async()=>{if(e)try{await i.mutateAsync(o.trim()||null),c(x=>x+1),ut.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");ut.error(a)}},S=async()=>{await m(),c(x=>x+1)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:o,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),b())},disabled:s||i.isPending,placeholder:fv(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"}),t.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(ze,{className:"animate-spin"}):t.jsx(Cu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(ze,{className:"animate-spin"}):t.jsx(ir,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),n?.ready&&n.viewUrl&&t.jsx(Ie,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:n.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(gn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:p?r("Checking preview target..."):n?.ready?`${r("Proxying")} ${n.target}`:n?.configured?`${r("Preview target is not reachable")}${n.error?`: ${n.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:n?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function pv(e){switch(e){case Rt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Rt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Rt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Rt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ra(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function gv(e){return e.length<=34?e:`...${e.slice(-31)}`}function ac({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:n,disabled:p,className:m,buttonClassName:v}){const{t:i}=ue(),[o,l]=y.useState(!1),u=y.useRef(null),c=y.useMemo(()=>In(e,s),[e,s]),g=c.find(b=>b.workspace.id===r)??c[0];return y.useEffect(()=>{if(!o)return;const b=S=>{u.current&&!u.current.contains(S.target)&&l(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]),c.length<=1?null:t.jsxs("div",{ref:u,className:G("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(b=>!b),disabled:p,className:G("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:i("Workspace"),children:[t.jsx(Rs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ra(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:gv(hs(g.workspace))}),t.jsx(ht,{size:13,className:G("shrink-0 text-neutral-400 transition-transform",o&&"rotate-180")})]}),o&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(b=>{const S=b.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{n(b.workspace.id),l(!1)},className:G("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",S&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:S?t.jsx(bt,{size:13}):t.jsx(xn,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(b.displayName)}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ra(b.roleLabel)),children:i(b.roleLabel)}),t.jsx("span",{className:G("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",pv(b.workspace.status)),children:b.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:hs(b.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[b.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",b.ownerName]}),b.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",b.parentBranchName]}),t.jsx("span",{children:b.workspace.id.slice(0,8)})]})]})]},b.workspace.id)})})]})}const vv=[{key:"review",label:"Changes",icon:t.jsx(Ds,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ia,{size:14})}],xv=[{key:"history",label:"History",icon:t.jsx(Ts,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ia,{size:14})}],bv=({active:e,onClick:s,icon:r,label:n})=>t.jsxs("button",{type:"button",onClick:s,className:G("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",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:[r,t.jsx("span",{children:n})]}),_v=({active:e,onClick:s,icon:r,label:n})=>t.jsx("button",{type:"button",onClick:s,title:n,"aria-label":n,"aria-pressed":e,className:G("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),lc=he.memo(function({className:s,sessionId:r,workspaceId:n,workingDir:p,projectId:m,hideChanges:v,readOnly:i,repoDeleted:o,teamRun:l,teamStatus:u,gitProps:c,workspaces:g,selectedWorkspaceId:b,onSelectWorkspace:S,variant:x="tabs",expanded:a,onExpandedChange:f,minContentWidth:d=520,tabRef:h}){const{t:_}=ue(),w=cn(W=>W.setVisibleContext),k=x==="rail",[j,C]=y.useState(!1),E=k?a??j:!0,N=y.useCallback(W=>{a===void 0&&C(W),f?.(W)},[a,f]),D=y.useMemo(()=>{const W=v?xv:vv,q=i?W.filter(R=>R.key!=="terminal"):W;return l?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...q]:q},[v,i,l]),[A,M]=y.useState(v?"history":"review"),I=y.useCallback(W=>{M(W),k&&N(!0)},[k,N]);y.useImperativeHandle(h,()=>({setTab:W=>I(W)}),[I]);const{data:L}=wd(m??""),F=y.useMemo(()=>{if(!L?.quickCommands)return[];try{return JSON.parse(L.quickCommands)}catch{return[]}},[L?.quickCommands]),[H,T]=y.useState([]),O=y.useRef(void 0);y.useEffect(()=>{p&&p!==O.current&&(O.current=p,T(W=>W.includes(p)?W:[...W,p]))},[p]),y.useEffect(()=>{D.some(W=>W.key===A)||M(D[0]?.key??(v?"history":"review"))},[A,v,D]),y.useEffect(()=>{if(k&&!E)return;const W=A==="review"?"changes":A==="history"?"history":null;if(!n||!p||!W){w(null);return}return w({workspaceId:n,workingDir:p,tab:W}),()=>{w(null)}},[A,E,k,w,p,n]);const P=!!S&&In(g,l).length>1,B=D.find(W=>W.key===A)??D[0],$=B?_(B.label):"",X=i?t.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:_(o?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,U=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(ac,{workspaces:g,teamRun:l,selectedWorkspaceId:b,onSelectWorkspace:S,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[A==="team-status"&&l&&u,A==="editor"&&t.jsx(X0,{workingDir:p,readOnly:i}),H.map(W=>{const q=A==="terminal"&&p===W;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:q?"block":"none"},children:t.jsx(op,{cwd:W,isVisible:q,quickCommands:F})},W)}),A==="preview"&&t.jsx(mv,{workspaceId:n,readOnly:i}),A==="review"&&t.jsx(rv,{workingDir:p,workspaceId:n,branchName:c?.branchName,targetBranch:c?.targetBranch,commitMessage:c?.commitMessage,canRunGitOperations:c?.canRunGitOperations,onRefreshCommitMessage:c?.onRefreshCommitMessage,onConflict:c?.onConflict,onResolveConflicts:c?.onResolveConflicts}),A==="history"&&t.jsx(dv,{workingDir:p})]})]});return k?t.jsxs("div",{className:G("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:D.map(W=>t.jsx(_v,{active:E&&A===W.key,onClick:()=>I(W.key),icon:W.icon,label:_(W.label)},W.key))}),E&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:d},children:[X,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:B?.icon}),t.jsx("span",{className:"truncate",children:$})]}),t.jsx("button",{type:"button",onClick:()=>N(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:_("收起"),"aria-label":_("收起"),children:t.jsx(vu,{size:15})})]}),U]})]}):t.jsxs("div",{className:G("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&X,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:D.map(W=>t.jsx(bv,{active:A===W.key,onClick:()=>I(W.key),icon:W.icon,label:_(W.label)},W.key))}),U]})}),ia=1500,yv=3e3;function Sv(e){const[s,r]=y.useState(null),n=y.useRef(0),p=y.useRef(null),m=y.useRef(null);return y.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},i=ts.connect(),o=u=>{r(u),m.current=setTimeout(()=>r(null),yv)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,n.current===0&&(n.current=Date.now()),r(c);return}const g=n.current>0?Date.now()-n.current:0,b=ia-g;n.current===0?(n.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>o(c),ia)):b>0?(p.current=c,v(),m.current=setTimeout(()=>o(c),b)):o(c)};return i.on(ct.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(ct.WORKSPACE_SETUP_PROGRESS,l),v(),n.current=0,p.current=null}},[e]),s}function Un(){const e=at();return yt({mutationFn:s=>ve.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)}),e.invalidateQueries({queryKey:le.tasks.all})}})}function cc(){const e=at();return yt({mutationFn:s=>ve.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)})}})}function qn(){const e=at();return yt({mutationFn:({id:s,message:r,providerId:n})=>ve.post(`/sessions/${s}/message`,{message:r,providerId:n}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function dc(e,s){return y.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.tokenUsage&&typeof n.tokenUsage.totalTokens=="number"&&n.tokenUsage.totalTokens>0)return{totalTokens:n.tokenUsage.totalTokens,modelContextWindow:n.tokenUsage.modelContextWindow}}return s??null},[e,s])}function uc({isOpen:e,onClose:s,onStarted:r,taskId:n,taskTitle:p,taskDescription:m,taskPrompt:v}){const{t:i}=ue(),[o,l]=y.useState(""),[u,c]=y.useState(""),[g,b]=y.useState(lt.WORKTREE),[S,x]=y.useState("idle"),[a,f]=y.useState(null),d=at(),h=ml(n),_=Un(),{data:w,isLoading:k}=Ms();y.useEffect(()=>{if(!e||!w)return;const A=w.find(M=>M.availability.type!=="NOT_FOUND");A&&l(A.provider.id)},[e,w]),y.useEffect(()=>{if(e){const A=[p];m&&A.push(m),c(v?.trim()||A.join(`
|
|
73
|
-
|
|
74
|
-
`)),b(lt.WORKTREE),x("idle"),f(null)}},[e,p,m,v]);const j=S!=="idle",C=async()=>{if(!(!o||!u.trim())){f(null);try{x("creating-workspace");const A=await h.mutateAsync({workspaceKind:g});x("creating-session");const M=await ve.post(`/workspaces/${A.id}/sessions`,{providerId:o,prompt:u.trim()});x("starting-session"),await _.mutateAsync(M.id),await d.invalidateQueries({queryKey:le.workspaces.list(n)}),x("idle"),r?.(),s()}catch(A){x("idle"),f(A instanceof Error?A.message:i("启动失败,请重试"))}}},E={idle:i("启动"),"creating-workspace":i("创建工作空间..."),"creating-session":i("创建会话..."),"starting-session":i("启动 Agent...")},N=(w??[]).map(({provider:A,availability:M})=>{const I=M.type!=="NOT_FOUND";return{value:A.id,label:I?A.name:`${A.name}${i(" (不可用)")}`,disabled:!I}}),D=[{value:lt.WORKTREE,label:i("工作树模式")},{value:lt.MAIN_DIRECTORY,label:i("本地模式")}];return t.jsx(As,{isOpen:e,onClose:j?()=>{}:s,title:i("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Ie,{variant:"outline",onClick:s,disabled:j,children:i("取消")}),t.jsx(Ie,{onClick:C,disabled:j||!o||!u.trim(),children:E[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("Agent")}),t.jsx(cs,{value:o,onChange:l,options:N,placeholder:i(k?"加载中...":"选择 Agent"),disabled:j||k})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("模式")}),t.jsx(cs,{value:g,onChange:A=>b(A),options:D,disabled:j})]})]}),g===lt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("任务描述")}),t.jsx("textarea",{value:u,onChange:A=>c(A.target.value),rows:5,disabled:j,placeholder:i("描述你想让 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"})]}),a&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:a})]})})}function hc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function wv(e,s,r){const n=e?.providerId??r?.providerId??null,p=n?s?.find(i=>i.provider.id===n)?.provider:null,m=p?.name??n??e?.agentType??r?.agentType??null;if(!m)return null;const v=n&&p?.name&&n!==p.name?`${p.name} (${n})`:m;return{label:m,title:v}}function fc({session:e,providers:s,usage:r,compact:n=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:i}=ue(),o=wv(e,s,{providerId:p,agentType:m});return!o&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${n?"gap-1":"gap-2"}`,children:[o&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${n?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${o.title}`,children:[t.jsx(rr,{size:n?12:14,className:"shrink-0 text-neutral-400"}),t.jsx("span",{className:"min-w-0 truncate",children:qi(o.label,n?12:18)})]}),t.jsx(Pn,{usage:r,tooltipSide:v})]})}function na(e,s,r,n){if(r.filter(v=>v===n).length<=1)return e;const m=r.slice(0,s+1).filter(v=>v===n).length;return`${e} #${m}`}function Cv(e){return Object.values(e).filter(Boolean).length}function mc({mode:e,setMode:s,selectedTemplateId:r,setSelectedTemplateId:n,selectedMemberPresetIds:p,setSelectedMemberPresetIds:m,disabled:v=!1}){const{t:i}=ue(),{data:o}=Ms(),{data:l,isError:u,isFetching:c,isLoading:g,refetch:b}=Ea(),{data:S,isError:x,isFetching:a,isLoading:f,refetch:d}=pd(),h=y.useMemo(()=>new Map((o??[]).map(({provider:N,availability:D})=>[N.id,N.name+(D.type==="NOT_FOUND"?i(" (不可用)"):"")])),[o,i]),_=y.useMemo(()=>new Map((l??[]).map(N=>[N.id,N])),[l]),w=y.useMemo(()=>new Map((S??[]).map(N=>[N.id,N])),[S]),k=y.useMemo(()=>p.map(N=>_.get(N)).filter(N=>!!N),[_,p]);y.useEffect(()=>{l!==void 0&&m(N=>{const D=N.filter(A=>_.has(A));return D.length===N.length&&D.every((A,M)=>A===N[M])?N:D})},[l,_,m]),y.useEffect(()=>{S!==void 0&&n(N=>!N||w.has(N)?N:null)},[n,w,S]);const j=N=>{v||n(D=>D===N?null:N)},C=N=>{v||m(D=>[...D,N])},E=N=>{v||m(D=>D.filter((A,M)=>M!==N))};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 shrink-0",children:i("执行模式")}),t.jsxs("div",{className:"inline-flex rounded-md bg-white p-0.5 shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>!v&&s("AUTO"),disabled:v,className:G("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(Ka,{size:11}),i("自动模式")]}),t.jsxs("button",{type:"button",onClick:()=>!v&&s("CONFIRM"),disabled:v,className:G("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(qa,{size:11}),i("确认模式")]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("section",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium text-neutral-500 mb-1.5",children:i("团队模板")}),x?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:i("团队模板加载失败")}),t.jsx("button",{type:"button",onClick:()=>{d()},disabled:v||a,className:"ml-2 underline hover:no-underline",children:i("重试")})]}):f?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(ze,{size:12,className:"animate-spin"}),i("加载中...")]}):(S??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[i("当前没有团队模板"),t.jsx(to,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:i("去创建")})]}):t.jsx("div",{className:"space-y-1.5",children:(S??[]).map(N=>{const D=N.id===r,A=N.members?.length??0,M=N.members?.map(L=>L.memberPresetId)??[],I=N.members?.slice(0,3).map((L,F)=>na(L.memberPreset?.name??L.memberPresetId,F,M,L.memberPresetId)).join(", ");return t.jsx("button",{type:"button",onClick:()=>j(N.id),disabled:v,className:G("w-full rounded-lg px-3 py-2 text-left transition-all disabled:cursor-not-allowed disabled:opacity-60",D?"bg-blue-50 ring-1 ring-blue-200":"bg-white hover:bg-white/80"),children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:G("text-xs truncate",D?"font-medium text-blue-800":"text-neutral-800"),children:N.name}),t.jsxs("span",{className:"text-[10px] text-neutral-400 shrink-0",children:[A,i("人")]})]}),I&&t.jsx("div",{className:"mt-0.5 text-[10px] text-neutral-400 truncate",children:I})]}),D&&t.jsx(bt,{size:13,className:"shrink-0 text-blue-600"})]})},N.id)})})]}),t.jsxs("section",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:i("追加成员")}),k.length>0&&t.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-blue-600 text-[9px] font-medium text-white px-1",children:k.length})]}),k.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:k.map((N,D)=>{const A=na(N.name,D,p,N.id);return t.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded bg-blue-50 text-[10px] text-neutral-700",children:[t.jsx(At,{name:N.name,avatar:N.avatar,className:"h-3.5 w-3.5 text-[7px]"}),t.jsx("span",{className:"max-w-[80px] truncate",children:A}),t.jsx("button",{type:"button",onClick:()=>E(D),disabled:v,className:"p-0.5 text-neutral-400 hover:text-red-500 disabled:opacity-30 rounded",children:t.jsx(Ht,{size:9})})]},`${N.id}-${D}`)})}),u?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:i("成员预设加载失败")}),t.jsx("button",{type:"button",onClick:()=>{b()},disabled:v||c,className:"ml-2 underline hover:no-underline",children:i("重试")})]}):g?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(ze,{size:12,className:"animate-spin"}),i("加载中...")]}):(l??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[i("当前没有成员预设"),t.jsx(to,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:i("去创建")})]}):t.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:(l??[]).map(N=>{const D=p.filter(I=>I===N.id).length,A=h.get(N.providerId)??N.providerId,M=Cv(N.capabilities);return t.jsxs("button",{type:"button",onClick:()=>C(N.id),disabled:v,className:G("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left transition-all",v&&"cursor-not-allowed opacity-60","bg-white hover:bg-white/80"),children:[t.jsx(At,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs text-neutral-800 truncate",children:N.name}),t.jsxs("div",{className:"text-[10px] text-neutral-400 truncate",children:[A," · ",M,"/10"]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[D>0&&t.jsxs("span",{className:"text-[9px] text-blue-600 font-medium",children:["×",D]}),t.jsx(Vt,{size:12,className:"text-neutral-300"})]})]},N.id)})})]})]})]})}function kv({isOpen:e,onClose:s,taskId:r}){const{t:n}=ue(),[p,m]=y.useState("AUTO"),[v,i]=y.useState(null),[o,l]=y.useState([]),[u,c]=y.useState(null),g=Na();y.useEffect(()=>{e&&(m("AUTO"),i(null),l([]),c(null))},[e]);const b=g.isPending,S=!!v||o.length>0,x=async()=>{if(!b){if(!v&&o.length===0){c(n("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...o.length>0?{memberPresetIds:o}:{}}),s()}catch(f){if(f instanceof ja&&f.status===409){c(n("该任务已经存在 TeamRun。请刷新后再试。"));return}c(f instanceof Error?f.message:n("创建 TeamRun 失败"))}}},a=b||!S;return t.jsxs(As,{isOpen:e,onClose:b?()=>{}:s,title:n("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ie,{type:"button",variant:"outline",onClick:s,disabled:b,children:n("取消")}),t.jsx(Ie,{type:"button",onClick:x,disabled:a,children:n(b?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(mc,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:o,setSelectedMemberPresetIds:l,disabled:b}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function pc({providers:e,currentProviderId:s,agentType:r,onSelect:n}){const{t:p}=ue(),[m,v]=y.useState(!1),i=y.useRef(null),o=e.filter(u=>String(u.provider.agentType)===r),l=e.find(u=>u.provider.id===s);return y.useEffect(()=>{function u(c){i.current&&!i.current.contains(c.target)&&v(!1)}if(m)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[m]),o.length<=1?t.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[t.jsx(so,{size:14,className:"shrink-0"}),t.jsx("span",{children:l?.provider.name?qi(l.provider.name,12):r})]}):t.jsxs("div",{className:"relative",ref:i,children:[t.jsxs("button",{onClick:()=>v(!m),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${l?.provider.name??r} (click to change)`,children:[t.jsx(so,{size:14,className:"shrink-0"}),t.jsx("span",{children:l?.provider.name?qi(l.provider.name,12):r}),t.jsx(ht,{size:12,className:`shrink-0 transition-transform ${m?"rotate-180":""}`})]}),m&&t.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:[t.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:p("切换渠道")}),o.map(u=>t.jsxs("button",{onClick:()=>{n(u.provider.id),v(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${u.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate max-w-[120px]",children:u.provider.name}),u.provider.isDefault&&t.jsx("span",{className:"text-xs text-neutral-400",children:p("(默认)")})]}),u.provider.id===s&&t.jsx(bt,{size:14,className:"shrink-0"})]},u.provider.id))]})]})}function Ev({commands:e,selectedIndex:s,query:r,hasCatalog:n,title:p="Slash Commands",queryPrefix:m="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:o="Enter / Tab to insert",compact:l=!1,onSelect:u}){const c=l?"px-1.5 pb-1.5":"px-2 pb-2",g=l?"px-2 py-1.5":"px-2.5 py-2",b=l?"max-h-36":"max-h-48";return t.jsxs("div",{className:l?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${l?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:p}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:o})]}),e.length===0?t.jsx("div",{className:`${l?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:n?i??`No matches for ${m}${r}`:v}):t.jsx("div",{className:`${c} ${b} overflow-y-auto`,children:e.map((S,x)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(S),className:`w-full rounded-lg border text-left transition-colors ${x===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:S.command}),S.kind&&S.kind!=="builtin"?t.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]}),t.jsx("div",{className:`${l?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:S.description})]},S.command))})]})}const Jt=12,kr=8;function $r({open:e,anchorRef:s,commands:r,selectedIndex:n,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:o,emptyQueryMessage:l,insertionHint:u,compact:c=!1,onSelect:g}){const b=y.useRef(null),[S,x]=y.useState(null);return y.useLayoutEffect(()=>{if(!e){x(null);return}const a=s.current;if(!a)return;let f=0;const d=()=>{const w=s.current;if(!w)return;const k=w.getBoundingClientRect(),j=window.innerWidth,C=window.innerHeight,E=c?260:320,N=c?j-Jt*2:560,D=Math.min(Math.max(k.width,E),Math.max(E,N)),A=Math.min(Math.max(Jt,k.left),Math.max(Jt,j-Jt-D)),M=C-k.bottom-kr-Jt,I=k.top-kr-Jt,L=b.current?.offsetHeight??(c?220:280),F=c?240:320,H=M<180&&I>M,O=Math.max(120,Math.min(F,H?I:M)),P=H?Math.max(Jt,k.top-kr-Math.min(L,O)):Math.min(C-Jt-Math.min(L,O),k.bottom+kr);x({top:P,left:A,width:D,maxHeight:O})},h=()=>{cancelAnimationFrame(f),f=requestAnimationFrame(d)};h();const _=new ResizeObserver(h);return _.observe(a),b.current&&_.observe(b.current),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),window.visualViewport?.addEventListener("resize",h),window.visualViewport?.addEventListener("scroll",h),()=>{cancelAnimationFrame(f),_.disconnect(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),window.visualViewport?.removeEventListener("resize",h),window.visualViewport?.removeEventListener("scroll",h)}},[s,r.length,c,e,p,n]),!e||!S||typeof document>"u"?null:ss.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:b,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:S.top,left:S.left,width:S.width,maxHeight:S.maxHeight},children:t.jsx(Ev,{commands:r,selectedIndex:n,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:o,emptyQueryMessage:l,insertionHint:u,compact:c,onSelect:g})})}),document.body)}function jv({workspaceId:e,gitStatus:s,onResolve:r}){const{t:n}=ue(),p=Mn();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(sr,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",n("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",n("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:n("中止操作")}),t.jsx(Ie,{size:"sm",onClick:r,children:n("解决冲突")})]})]})}function gc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function vc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function Nv(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,n=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${n} 完成合并`]}function Rv(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function Tv(e,s,r,n,p){const m=gc(r),v=vc(p);return n===Ys.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...Nv(e,p)].join(`
|
|
77
|
-
`)}function Av(e){const s=e.conflictOp===Ys.REBASE?"Rebase":"Merge",r=gc(e.conflictedFiles),n=[...vc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...n,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Ys.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Rv(e)].join(`
|
|
78
|
-
`)}function Mv(e){if(e.teamRunId)return{type:"team_room",message:Av(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:Tv(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function xc({open:e,onOpenChange:s,workspaceId:r,conflictOp:n,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:i,worktreePath:o,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:S,sessions:x,currentSessionId:a,teamRunId:f}){const{t:d}=ue(),[h,_]=y.useState(""),w=qn(),k=dn(f??""),j=Tn(),C=!!f,E=a||h,N=C?k.isPending:w.isPending,D=()=>{const F=Mv({workspaceId:r,worktreePath:o,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:S,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:n,teamRunId:f,currentSessionId:a,selectedSessionId:h});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ut.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&w.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},A=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},M=n==="REBASE"?"Rebase":"Merge",I=!C&&!a&&x.length>0,L=C||!!E;return t.jsx(As,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ie,{variant:"outline",onClick:A,children:d("在 IDE 中打开")}),t.jsx(Ie,{onClick:D,disabled:!L||N,children:d(N?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(F=>t.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:F},F))})]}),C&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),I&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:h,onChange:F=>_(F.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:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),x.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!C&&!E&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Dv(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,n)=>({files:r.files+1,additions:r.additions+(n.additions??0),deletions:r.deletions+(n.deletions??0)}),{files:0,additions:0,deletions:0})}function oa(e,s,r,n){const p=tc(e);if(p){r(p);return}n(e instanceof Error?e.message:s)}function bc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:n,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:i,onOpenChanges:o,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ue(),b=gl(),S=pl(),x=Mn(),[a,f]=y.useState(!1),[d,h]=y.useState(null),_=y.useMemo(()=>Dv(p),[p]),w=_.additions+_.deletions,k=_.files>0&&w>0,j=(m?.conflictedFiles.length??0)>0,C=!!(m&&m.operation!=="idle"),E=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),N=(m?.uncommittedCount??0)+(m?.untrackedCount??0),D=(m?.behind??0)>0,A=(m?.ahead??0)>0,M=v||!m&&i,I=!!(i&&e&&m&&D&&!j&&!C&&!E),L=!!(i&&e&&m&&A&&!D&&!j&&!C&&!E);if(y.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const F=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):N>0?g("{count} 未提交",{count:N}):D?g("落后 {count}",{count:m?.behind??0}):g(A?"可合并":"已是最新"),H=g("{files} 个文件 · {lines} 行",{files:_.files,lines:w}),T=()=>{I&&(h(null),b.mutate(e,{onError:$=>{oa($,g("更新失败,请稍后重试"),X=>u(X),h)}}))},O=()=>{L&&(h(null),f(!0))},P=$=>{h(null),S.mutate({id:e,commitMessage:$},{onSuccess:()=>f(!1),onError:X=>{oa(X,g("提交失败,请稍后重试"),U=>{f(!1),u(U)},h)}})},B=()=>{S.isPending||(f(!1),h(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:G("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:o,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Ds,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[_.additions>0&&t.jsxs("span",{className:"text-success",children:["+",_.additions]}),_.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",_.deletions]})]}),j&&t.jsx(sr,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:F})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[C&&t.jsx("button",{type:"button",onClick:()=>x.mutate(e),disabled:x.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:x.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:T,disabled:!I||b.isPending||M,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(D?"同步更新":"已是最新"),children:[b.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(ir,{size:12}),t.jsx("span",{children:b.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!L||S.isPending||M,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:L?g("合并到 {target}",{target:r}):g("提交变更"),children:[S.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Mr,{size:12}),t.jsx("span",{children:S.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(ec,{isOpen:a,onClose:B,branchName:s,targetBranch:r,commitMessage:n,isPending:S.isPending,error:d,onConfirm:P})]})}function Lv({agentType:e,workingDir:s}){return kt({queryKey:le.system.slashCommandCatalog(e,s),queryFn:async()=>(await ve.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function Pv(e,s){const r=new Set,n=[];for(const p of[...e,...s]){const m=p.command.trim().toLowerCase();!m||r.has(m)||(r.add(m),n.push(p.kind?p:{...p,kind:"builtin"}))}return n}function di(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function Ov(e){return di(e.command)}function Iv(e,s){if(!s)return 1e3;const r=Ov(e),n=e.aliases?.map(di)??[],p=[r,...n];let m=0;for(const i of p)i===s?m=Math.max(m,500):i.startsWith(s)?m=Math.max(m,400-(i.length-s.length)):i.includes(s)&&(m=Math.max(m,250-i.indexOf(s)));return m>0?m:`${r} ${n.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function aa(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:di(s[2]),replaceStart:r}}function _c(e,s){const r=di(s);return r?e.map((n,p)=>({command:n,index:p,score:Iv(n,r)})).filter(n=>n.score>0).sort((n,p)=>p.score-n.score||n.index-p.index||n.command.command.localeCompare(p.command.command)).map(n=>n.command):e.slice()}const Bv=[{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"}],Fv=[{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"}],zv=[{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"}],Wv=[{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"}],Hv={[Wt.CODEX]:Bv,[Wt.CLAUDE_CODE]:Fv,[Wt.GEMINI_CLI]:zv,[Wt.CURSOR_AGENT]:Wv};function yc(e){return e.trim().toLowerCase().replace(/^\//,"")}function $v(e){return e?(Hv[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function Uv(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?yc(s[1]):null}function qv(e,s){return _c(e,yc(s))}function Kv(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Sc({agentType:e,workingDir:s,input:r,setInput:n,textareaRef:p,minHeight:m,maxHeight:v}){const[i,o]=y.useState(0),{data:l=[]}=Lv({agentType:e,workingDir:s}),u=y.useMemo(()=>Pv($v(e),l),[e,l]),c=y.useMemo(()=>Uv(r),[r]),g=y.useMemo(()=>c===null?[]:qv(u,c),[u,c]),b=y.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);y.useEffect(()=>{o(0)},[e,c]),y.useEffect(()=>{i<g.length||o(0)},[g.length,i]);const S=y.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;n(d),requestAnimationFrame(()=>{const h=p.current;h&&(b(),h.focus(),h.setSelectionRange(d.length,d.length))})},[r,b,n,p]),x=y.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),o(f=>(f+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),o(f=>(f-1+g.length)%g.length),!0):Kv(a)?(a.preventDefault(),S(g[i]??g[0]),!0):!1,[S,g,c,i]);return{allCommands:u,query:c,filteredCommands:g,selectedIndex:i,setSelectedIndex:o,applyCommand:S,handleKeyDown:x}}function Vv({agentType:e,workingDir:s}){return kt({queryKey:le.system.skillCatalog(e,s),queryFn:async()=>(await ve.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Wt.CODEX,staleTime:3e4})}function Xv(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function wc({agentType:e,workingDir:s,input:r,setInput:n,textareaRef:p,minHeight:m,maxHeight:v}){const[i,o]=y.useState(0),{data:l=[]}=Vv({agentType:e,workingDir:s}),c=y.useMemo(()=>e===Wt.CODEX?aa(r):null,[e,r])?.query??null,g=y.useMemo(()=>c===null?[]:_c(l,c),[c,l]),b=y.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);y.useEffect(()=>{o(0)},[e,c]),y.useEffect(()=>{i<g.length||o(0)},[g.length,i]);const S=y.useCallback(a=>{const f=aa(r);if(!f)return;const d=`${r.slice(0,f.replaceStart)}${a.command} `;n(d),requestAnimationFrame(()=>{const h=p.current;h&&(b(),h.focus(),h.setSelectionRange(d.length,d.length))})},[r,b,n,p]),x=y.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),o(f=>(f+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),o(f=>(f-1+g.length)%g.length),!0):Xv(a)?(a.preventDefault(),S(g[i]??g[0]),!0):!1,[S,g,c,i]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:o,applySkill:S,handleKeyDown:x}}const Yv="/api",Gv=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Yv}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ss=520,zi=48,Qv=4,Zv=420;function Jv(){const{t:e}=ue();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const la=[{status:ge.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Oa,{className:"w-3 h-3"})},{status:ge.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Pa,{className:"w-3 h-3"})},{status:ge.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(La,{className:"w-3 h-3"})},{status:ge.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Da,{className:"w-3 h-3"})},{status:ge.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Ma,{className:"w-3 h-3"})}];function ex({status:e,onChangeStatus:s}){const{t:r}=ue(),[n,p]=y.useState(!1),m=y.useRef(null);y.useEffect(()=>{if(!n)return;const i=o=>{m.current&&!m.current.contains(o.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n]);const v=la.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${n?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:la.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(o=>o.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function ca({state:e,onRetry:s}){const{t:r}=ue(),n=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:n}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Ie,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:n})]})}function tx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:n,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),[i,o]=y.useState(""),[l,u]=y.useState(!1),[c,g]=y.useState(!1),[b,S]=y.useState(!1),[x,a]=y.useState(!1),[f,d]=y.useState(!1),[h,_]=y.useState(!1),[w,k]=y.useState(null),j=y.useRef(null),[C,E]=y.useState(!1),[N,D]=y.useState(null),[A,M]=y.useState(void 0),[I,L]=y.useState(!1),F=y.useRef(null),H=y.useRef(null),T=y.useRef(null),O=y.useRef(null),{scrollRef:P,contentRef:B,isAtBottom:$,scrollToBottom:X}=Ln({resize:"smooth",initial:"instant"}),[U,W]=y.useState(!1),[q,R]=y.useState(Ss),[z,V]=y.useState(!1),K=y.useRef(0),ee=y.useRef(Ss),Z=y.useRef(null),{data:se,isLoading:xe}=Rn(e?.id??""),be=Sv(e?.id),{data:Be}=Ra(e?.id??""),{data:ce}=Ta(Be?.id??""),nt=dn(Be?.id??""),pe=Be??null,je=!!pe,Ye=Be===null,Ze=!!(e?.id&&Be===null),{data:Re,isLoading:re}=Aa(e?.id??"",Ze);y.useEffect(()=>{L(!1),D(null),M(void 0)},[e?.id]);const fe=y.useMemo(()=>Sl(se,pe,A),[A,pe,se]);y.useEffect(()=>{A&&!se?.some(J=>J.id===A)&&M(void 0)},[A,se]);const ke=y.useMemo(()=>se?.find(J=>J.id===fe),[fe,se]),Oe=ke?.status===Rt.ACTIVE?ke.id:void 0,De=wl(ke,pe);y.useEffect(()=>{if(!I||!se)return;se.some(de=>de.status==="ACTIVE"&&de.sessions&&de.sessions.length>0)&&L(!1)},[se,I]);const Fe=y.useMemo(()=>{if(I||!se)return null;const J=mt=>{const _i=mt.createdAt,zs=mt.endedAt??mt.startedAt??_i;if(!zs)return 0;const bs=Date.parse(zs);return Number.isNaN(bs)?0:bs},de=(mt,_i)=>{const zs=mt.filter(bs=>_i.includes(bs.status));return zs.length===0?null:zs.sort((bs,Gc)=>J(Gc)-J(bs))[0]??null},Qe=se.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),wt=de(Qe,[rt.RUNNING])??de(Qe,[rt.PENDING])??de(Qe,[rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(wt)return wt;const xt=se.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return de(xt,[rt.COMPLETED,rt.FAILED,rt.CANCELLED])},[se,I]),Ge=Fe?.id??"",Ne=je?N??"":Ge,we=y.useMemo(()=>{if(!N||!se)return null;for(const J of se){const de=J.sessions?.find(Qe=>Qe.id===N);if(de)return de}return null},[N,se]),Q=y.useMemo(()=>{if(!N||!pe?.invocations)return null;const J=pe.invocations.filter(de=>de.sessionId===N);return J.length===0?null:J.sort((de,Qe)=>{const wt=Date.parse(de.updatedAt??de.createdAt??""),xt=Date.parse(Qe.updatedAt??Qe.createdAt??"");return(Number.isNaN(xt)?0:xt)-(Number.isNaN(wt)?0:wt)})[0]??null},[N,pe?.invocations]),oe=y.useMemo(()=>!Q?.memberId||!pe?.members?null:pe.members.find(J=>J.id===Q.memberId)??null,[Q?.memberId,pe?.members]),ae=N?we:Fe??null,Y=ae?.status===rt.RUNNING||ae?.status===rt.PENDING,te=!!e?.projectArchivedAt,ne=!!e?.projectRepoDeletedAt,me=v(ne?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Te}=Ms(),[Ee,Ae]=y.useState(null);y.useEffect(()=>{Ae(Fe?.providerId??null)},[Fe?.providerId]);const ye=y.useMemo(()=>!Fe||!se?!1:!se.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Qe=>Qe.id===Fe.id)),[Fe,se]),Me=y.useMemo(()=>{if(!(!se||I)){if(ke)return rs(ke);for(const J of se)if(J.status==="ACTIVE"&&rs(J))return rs(J);return rs(se[0])}},[I,ke,se]),et=Sc({agentType:Fe?.agentType,workingDir:Me,input:i,setInput:o,textareaRef:T,minHeight:60,maxHeight:300}),Ve=wc({agentType:Fe?.agentType,workingDir:Me,input:i,setInput:o,textareaRef:T,minHeight:60,maxHeight:300}),it=cn(J=>J.setVisibleContext),Le=!!(De&&Oe&&Me&&!te),{data:Pe,isLoading:He}=An(Oe??"",{enabled:Le}),{data:St}=ci(Me,{enabled:Le});y.useEffect(()=>{if(!(U||!Le||!Oe||!Me))return it({workspaceId:Oe,workingDir:Me,tab:"changes"}),()=>{it(null)}},[U,Oe,it,Le,Me]);const gt=ke?.sessions??[],ft=hs(ke),Dt=ke?.commitMessage,Et=y.useMemo(()=>Cl(ke,se,e?.mainBranch??""),[ke,e?.mainBranch,se]),$e=y.useMemo(()=>Pe?.conflictOp&&Pe.conflictedFiles.length>0?{conflictOp:Pe.conflictOp,conflictedFiles:Pe.conflictedFiles}:w,[Pe?.conflictOp,Pe?.conflictedFiles,w]),Ot=$e?.targetWorkspaceId??Oe,It=$e?.targetWorktreePath??ke?.worktreePath,ms=$e?.sourceBranch??ft,ui=$e?.targetBranch??Et,tt=at(),ps=y.useCallback(async()=>e?.id?tt.fetchQuery({queryKey:le.tasks.body(e.id),queryFn:()=>ve.get(`/tasks/${e.id}/body`)}):null,[tt,e?.id]),Os=y.useCallback(()=>e?.id?tt.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,tt]);y.useEffect(()=>{if(!C)return;const J=de=>{H.current&&!H.current.contains(de.target)&&E(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[C]);const Is=qn(),Gt=Tn(),ls=gd(),hr=ml(e?.id??""),Bs=Un(),gs=bf(),$t=y.useMemo(()=>!se||se.some(de=>de.status==="ACTIVE")?null:se.find(de=>de.status==="HIBERNATED")??null,[se]),vs=y.useRef(null);y.useEffect(()=>{$t&&vs.current!==$t.id&&(gs.isPending||(vs.current=$t.id,gs.mutate($t.id,{onSettled:()=>{vs.current=null}})))},[$t,gs]);const hi=y.useCallback(async()=>{if(!e?.id)return;const J=Fe?.providerId??Te?.find(de=>de.availability.type!=="NOT_FOUND")?.provider.id;if(J){a(!1),d(!0);try{const Qe=(await ps())?.prompt??e.title;await ls.mutateAsync(e.id),L(!0);const wt=await hr.mutateAsync({}),xt=await ve.post(`/workspaces/${wt.id}/sessions`,{providerId:J,prompt:Qe});await Bs.mutateAsync(xt.id),await tt.invalidateQueries({queryKey:le.workspaces.list(e.id)})}catch(de){console.error("[retry] failed:",de),L(!1)}finally{d(!1)}}},[e?.id,e?.title,Fe?.providerId,Te,ps,ls,hr,Bs,tt]),Fs=y.useCallback(async()=>{e?.id&&(await ps(),u(!0))},[ps,e?.id]),fr=y.useCallback(()=>{ke?.id&&Gt.mutate({workspaceId:ke.id})},[Gt,ke?.id]),fi=y.useCallback(()=>{!e?.id||!s||(s(e.id),S(!1))},[e?.id,s]),mr=y.useCallback(J=>{D(J),requestAnimationFrame(()=>{X()})},[X]),pr=y.useCallback(()=>{D(null)},[]),xs=y.useCallback(J=>{k(J??null),_(!0)},[]),mi=y.useCallback(J=>nt.mutateAsync(J),[nt]),Qt=y.useCallback(()=>{tt.invalidateQueries({queryKey:vd.all})},[tt]),{isConnected:gr,isLoadingSnapshot:Zt,logs:ie,entries:Se,attach:Ue}=Ba({sessionId:Ne,sessionStatus:ae?.status,onExit:y.useCallback(()=>{tt.invalidateQueries({queryKey:["workspaces"]})},[tt])});y.useEffect(()=>{if(!e?.id)return;const J=ts.connect();J.emit(ws.SUBSCRIBE,{topic:"task",id:e.id});const de=xt=>{xt.taskId===e.id&&(tt.invalidateQueries({queryKey:["tasks"]}),Qt())},Qe=xt=>{xt.taskId===e.id&&(tt.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Qt())},wt=xt=>{xt.taskId===e.id&&(tt.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Qt())};return J.on(ct.TASK_UPDATED,de),J.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Qe),J.on(ct.WORKSPACE_HIBERNATED,wt),()=>{J.off(ct.TASK_UPDATED,de),J.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Qe),J.off(ct.WORKSPACE_HIBERNATED,wt),J.emit(ws.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,tt,Qt]),y.useEffect(()=>{if(!Ne)return;const J=ts.connect(),de=Qe=>{Qe.sessionId===Ne&&(tt.invalidateQueries({queryKey:["workspaces"]}),Qt())};return J.on(ct.SESSION_COMPLETED,de),()=>{J.off(ct.SESSION_COMPLETED,de)}},[Ne,tt,Qt]);const{todos:We}=Fa(Se),{files:jt,addFiles:vt,removeFile:qe,clear:Ut,buildMarkdownLinks:qt,hasFiles:Bt,isUploading:vr}=si(),zc=y.useMemo(()=>hc(ae),[ae?.tokenUsage]),Vn=dc(ie,zc);y.useEffect(()=>{Ne&&gr&&Ue()},[Ne,gr,Ue]);const Xn=y.useRef(e?.id);y.useEffect(()=>{if(Xn.current!==e?.id&&P.current){const J=P.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}Xn.current=e?.id},[e?.id,P]);const pi=cc(),gi=y.useRef(!1),Yn=y.useCallback(async()=>{if(!i.trim()&&!Bt||!Ne||gi.current||vr)return;gi.current=!0;const J=qt(),de=[i.trim(),J].filter(Boolean).join(`
|
|
79
|
-
|
|
80
|
-
`);o(""),Ut(),T.current&&(T.current.style.height="60px"),Is.mutate({id:Ne,message:de,providerId:Ee??void 0},{onSuccess:()=>{Ue()},onSettled:()=>{gi.current=!1}})},[i,Ne,Is,Ue,Bt,vr,qt,Ut,Ee]),Wc=y.useCallback(async()=>{Ne&&(await pi.mutateAsync(Ne),tt.invalidateQueries({queryKey:["workspaces"]}))},[Ne,pi,tt]),Hc=y.useCallback(J=>{const de=J.target.files;de&&de.length>0&&vt(Array.from(de)),J.target.value=""},[vt]),$c=y.useCallback(J=>{const de=J.clipboardData.items,Qe=[];for(const wt of de)if(wt.kind==="file"){const xt=wt.getAsFile();xt&&Qe.push(xt)}Qe.length>0&&(J.preventDefault(),vt(Qe))},[vt]),[Gn,vi]=y.useState(!1),Uc=y.useCallback(J=>{J.preventDefault(),vi(!0)},[]),qc=y.useCallback(J=>{J.preventDefault(),vi(!1)},[]),Kc=y.useCallback(J=>{J.preventDefault(),vi(!1);const de=J.dataTransfer.files;de.length>0&&vt(Array.from(de))},[vt]),Kt=y.useCallback(J=>{const de=Z.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Qe=de?Math.max(Ss,de-zi-Qv-Zv):Ss;return Math.max(Ss,Math.min(Math.round(J),Qe))},[]),xi=y.useCallback(J=>{const de=J.clientX-K.current;R(Kt(ee.current-de))},[Kt]),bi=y.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);y.useEffect(()=>{if(z)return document.addEventListener("mousemove",xi),document.addEventListener("mouseup",bi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",xi),document.removeEventListener("mouseup",bi),document.body.style.cursor="",document.body.style.userSelect=""}},[bi,xi,z]);const Vc=y.useCallback(J=>{J.preventDefault(),K.current=J.clientX,ee.current=q,V(!0)},[q]);y.useEffect(()=>{!U||z||R(J=>Kt(J))},[Kt,U,z]),y.useEffect(()=>{if(!U)return;const J=()=>{R(de=>Kt(de))};return window.addEventListener("resize",J),()=>window.removeEventListener("resize",J)},[Kt,U]);const Xc=y.useCallback(()=>{R(J=>Kt(J)),W(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[Kt]),Yc=y.useCallback(J=>{o(J.target.value);const de=J.target;de.style.height="auto";const Qe=de.scrollHeight;de.style.height=`${Math.max(60,Math.min(Qe,300))}px`},[]),Qn=Le&&Oe?t.jsx(bc,{workspaceId:Oe,branchName:ft,targetBranch:Et,commitMessage:Dt,changes:St,gitStatus:Pe,isGitStatusLoading:He,canRunGitOperations:De,onOpenChanges:Xc,onRefreshCommitMessage:Os,onConflict:xs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(ex,{status:e.status,onChangeStatus:!te&&n?J=>n(e.id,J):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:fr,disabled:!Me||te,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(rr,{size:16})}),(s||Ye)&&!te&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsx("button",{onClick:()=>E(J=>!J),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx($a,{size:16})}),C&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[Ye&&t.jsxs("button",{onClick:()=>{g(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Vt,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Nd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{S(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),De&&Oe&&Pe&&t.jsx(jv,{workspaceId:Oe,gitStatus:Pe,onResolve:()=>xs()}),t.jsxs("div",{ref:Z,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:je&&pe?N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(fc,{session:ae,providers:Te,usage:Vn,providerIdFallback:oe?.providerId,agentTypeFallback:ae?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ie,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:pr,children:[t.jsx(Gs,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:B,className:"w-full max-w-4xl mx-auto",children:Zt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):ie.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Y?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Rr,{logs:ie})})}),!$&&t.jsxs("button",{onClick:()=>X(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Qs,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),We.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Tr,{todos:We})})})]}):t.jsx(yl,{teamRun:pe,messages:ce??pe.messages??[],readOnly:te,readOnlyMessage:me,onSendMessage:mi,onViewInvocationSession:mr,changeSummaryBar:Qn,centered:!0}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:B,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(re||Re?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:re?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Re?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(un,{urlTransform:Gv,components:hn,children:Re.body})}):null}),be&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[be.status==="running"&&t.jsxs(t.Fragment,{children:[t.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:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:be.currentIndex,total:be.totalCommands,command:be.currentCommand})})]}),be.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),be.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:be.error})})]}),!te&&p&&(xe||Ge)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ca,{state:p,onRetry:p.status==="failed"?Fs:void 0})}):null,xe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):Ge?Zt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):ie.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Y?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Rr,{logs:ie}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Xt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(te?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:te?me:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!te&&p?t.jsx(ca,{state:p}):null,!te&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Ie,{onClick:Fs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),Ye&&t.jsxs(Ie,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(Vt,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>X(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Qs,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),We.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Tr,{todos:We})})}),te?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:me})})}):ye?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Ie,{size:"sm",onClick:Fs,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Uc,onDragLeave:qc,onDrop:Kc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Qn,t.jsxs("div",{ref:F,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Gn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(ri,{files:jt,onRemove:qe}),t.jsx("textarea",{ref:T,value:i,onChange:Yc,onPaste:$c,onKeyDown:J=>{Ve.handleKeyDown(J)||et.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),Yn())},rows:1,placeholder:v(Gn?"Drop files here...":Ge&&!Y?"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-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:O,type:"file",multiple:!0,className:"hidden",onChange:Hc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>O.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(Vr,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Fe&&Te&&t.jsx(pc,{providers:Te,currentProviderId:Ee,agentType:Fe.agentType,onSelect:Ae}),t.jsx(Pn,{usage:Vn}),Y&&!i.trim()&&!Bt?t.jsx("button",{onClick:Wc,disabled:pi.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ns,{size:14})}):t.jsx("button",{onClick:Yn,disabled:!i.trim()&&!Bt||vr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Bt)&&!vr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Xr,{size:18})})]})]})]})]}),t.jsx($r,{open:et.query!==null,anchorRef:F,commands:et.filteredCommands,selectedIndex:et.selectedIndex,query:et.query??"",hasCatalog:et.allCommands.length>0,onSelect:et.applyCommand}),t.jsx($r,{open:Ve.query!==null,anchorRef:F,commands:Ve.filteredSkills,selectedIndex:Ve.selectedIndex,query:Ve.query??"",hasCatalog:Ve.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ve.applySkill})]})]})}),U&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Vc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:U?zi+q:zi},children:t.jsx(lc,{sessionId:Ge||void 0,workspaceId:fe,workingDir:Me,projectId:e.projectId,readOnly:te,repoDeleted:ne,teamRun:pe,teamStatus:pe?t.jsx(jl,{teamRun:pe,workspaces:se,selectedWorkspaceId:fe,onSelectWorkspace:M,onViewInvocationSession:mr}):void 0,workspaces:se,selectedWorkspaceId:fe,onSelectWorkspace:M,variant:"rail",expanded:U,onExpandedChange:J=>{J&&R(de=>Kt(de)),W(J)},minContentWidth:Ss,tabRef:j,gitProps:De&&Oe?{branchName:ft,targetBranch:Et,commitMessage:Dt,canRunGitOperations:!0,onRefreshCommitMessage:Os,onConflict:xs,onResolveConflicts:()=>xs()}:void 0})})]}),!te&&t.jsx(uc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Re?.title??e.title,taskDescription:Re?.body??"",taskPrompt:Re?.prompt,onStarted:()=>m?.(e.id)}),Ye&&!te&&t.jsx(kv,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),De&&Ot&&$e&&t.jsx(xc,{open:h,onOpenChange:J=>{_(J),J||k(null)},workspaceId:Ot,conflictOp:$e.conflictOp,conflictedFiles:$e.conflictedFiles,sourceBranch:ms,targetBranch:ui,operation:Pe?.operation,worktreePath:It,mergeAborted:$e.mergeAborted,mergeStrategy:$e.mergeStrategy,sourceWorkspaceId:$e.sourceWorkspaceId,targetWorkspaceId:$e.targetWorkspaceId,sourceWorktreePath:$e.sourceWorktreePath,targetWorktreePath:$e.targetWorktreePath,sessions:gt,currentSessionId:je?void 0:Ge,teamRunId:pe?.id}),t.jsx(Kr,{isOpen:x,onClose:()=>a(!1),onConfirm:hi,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:f}),t.jsx(Dn,{isOpen:b,onClose:()=>S(!1),onConfirm:fi,taskId:e.id,taskTitle:e.title,workspaces:se,isLoading:r})]}):t.jsx(Jv,{})}function Kn(e){switch(e){case zt.TODO:return ge.Pending;case zt.IN_PROGRESS:return ge.Running;case zt.IN_REVIEW:return ge.Review;case zt.DONE:return ge.Done;case zt.CANCELLED:return ge.Cancelled}}function sx(e){switch(e){case ge.Pending:return zt.TODO;case ge.Running:return zt.IN_PROGRESS;case ge.Review:return zt.IN_REVIEW;case ge.Done:return zt.DONE;case ge.Cancelled:return zt.CANCELLED}}function rx(e){switch(e){case Wt.CLAUDE_CODE:return"Claude Code";case Wt.GEMINI_CLI:return"Gemini CLI";case Wt.CURSOR_AGENT:return"Cursor Agent";case Wt.CODEX:return"Codex"}}const Ur=["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 Cc(e,s){let r=0;for(let n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n)|0;return Math.abs(r)%s}function kc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Ec(e){return e?e.workspaceKind===lt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function ix(e){return{id:e.id,name:e.name,color:e.color||Ur[Cc(e.name,Ur.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function nx(e){const s=kc(e);if(!s)return{agent:"—",branch:"—"};const r=Ec(s),n=s.sessions;if(n&&n.length>0){const p=n[n.length-1];return{agent:rx(p.agentType),branch:r}}return{agent:"—",branch:r}}function ox(e){const{agent:s,branch:r}=nx(e.workspaces),n=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Kn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,projectArchivedAt:n?.archivedAt??null,projectRepoDeletedAt:n?.repoDeletedAt??null}}function ax(e,s,r){const n=kc(e.workspaces,r),p=Ec(n);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Ur[Cc(s.name,Ur.length)],title:e.titlePreview??e.title,status:Kn(e.status),branch:p,mainBranch:n?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const da={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 lx(e){const s=e.split("/");return s[s.length-1]||e}function cx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function dx({workingDir:e,filePath:s,type:r}){const{t:n}=ue(),{data:p,isLoading:m,isError:v}=Jl(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:n("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:n("No diff content available.")});const o=i.split(`
|
|
81
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:o.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:G("px-3 whitespace-pre",c,g),children:l},u)})})}function ux({entry:e,type:s,workingDir:r}){const[n,p]=y.useState(!1),m=da[e.status]||da.M,v=cx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:G("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",n&&"bg-neutral-50"),children:[t.jsx("span",{className:G("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:lx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:n?t.jsx(ht,{size:14}):t.jsx(Mt,{size:14})})]}),n&&t.jsx(dx,{workingDir:r,filePath:e.path,type:s})]})}function ua({title:e,entries:s,type:r,workingDir:n,defaultOpen:p}){const{t:m}=ue(),[v,i]=y.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(o=>!o),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(ht,{size:14}):t.jsx(Mt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(o=>t.jsx(ux,{entry:o,type:r,workingDir:n},`${r}:${o.path}`))})]})}function hx({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:n,isError:p}=ci(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(n)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ds,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(ua,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(ua,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Wi=50,ha={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 fx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function mx(e){const s=e.split("/");return s[s.length-1]||e}function px(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function gx({workingDir:e,hash:s,filePath:r}){const{t:n}=ue(),{data:p,isLoading:m,isError:v}=$n(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:n("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:n("No diff content available.")});const o=i.split(`
|
|
82
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:o.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:G("px-3 whitespace-pre",c,g),children:l},u)})})}function vx({entry:e,workingDir:s,hash:r}){const[n,p]=y.useState(!1),m=ha[e.status]||ha.M,v=px(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:G("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",n&&"bg-neutral-50"),children:[t.jsx("span",{className:G("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:mx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:n?t.jsx(ht,{size:14}):t.jsx(Mt,{size:14})})]}),n&&t.jsx(gx,{workingDir:s,hash:r,filePath:e.path})]})}function xx({commit:e,workingDir:s}){const{t:r}=ue(),[n,p]=y.useState(!1),{data:m,isLoading:v}=Hn(s,n?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(o=>!o),className:G("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",n&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:G("w-2.5 h-2.5 rounded-full shrink-0",n?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:fx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:n?t.jsx(ht,{size:14}):t.jsx(Mt,{size:14})})]}),n&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(o=>t.jsx(vx,{entry:o,workingDir:s,hash:e.hash},o.path))})]})]})}function bx({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:n,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=pn({queryKey:le.git.log(e||""),queryFn:({pageParam:l=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(Wi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Wi?void 0:u.length*Wi,enabled:!!e}),o=r?.pages.flatMap(l=>l.commits)||[];return e?n?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):o.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ts,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:o.map(l=>t.jsx(xx,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const _x="/api",yx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${_x}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Sx({status:e}){const s={[ge.Running]:"bg-blue-500",[ge.Review]:"bg-amber-500",[ge.Pending]:"bg-neutral-400",[ge.Done]:"bg-emerald-500",[ge.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const wx=[{key:"chat",label:"Chat",icon:mn},{key:"changes",label:"Changes",icon:Ds},{key:"history",label:"History",icon:Ts},{key:"workspace",label:"Workspace",icon:Yr}],Cx=[{key:"chat",label:"Team room",icon:mn},{key:"team-status",label:"Team Status",icon:us},{key:"changes",label:"Changes",icon:Ds},{key:"workspace",label:"Workspace",icon:Yr}];function fa({state:e,onRetry:s}){const{t:r}=ue(),n=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:n}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Ie,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:n})]})}function kx({task:e,onBack:s,onDeleteTask:r,isDeleting:n,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),i=cn(ie=>ie.setVisibleContext),[o,l]=y.useState("chat"),[u,c]=y.useState(""),[g,b]=y.useState(!1),[S,x]=y.useState(!1),[a,f]=y.useState(!1),[d,h]=y.useState(null),[_,w]=y.useState(void 0),k=y.useRef(null),j=y.useRef(null),C=y.useRef(null),E=y.useRef(null),{scrollRef:N,contentRef:D,isAtBottom:A,scrollToBottom:M}=Ln({resize:"smooth",initial:"instant"}),I=at();y.useEffect(()=>{if(!a)return;const ie=Se=>{j.current&&!j.current.contains(Se.target)&&f(!1)};return document.addEventListener("mousedown",ie),()=>document.removeEventListener("mousedown",ie)},[a]);const{data:L,isLoading:F}=Rn(e.id),{data:H}=Ra(e.id),{data:T}=Ta(H?.id??""),O=dn(H?.id??""),P=H??null,B=P?Cx:wx,$=H===null,{data:X,isLoading:U}=Aa(e.id,$),W=!!e.projectArchivedAt,q=!!e.projectRepoDeletedAt,R=v(q?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");y.useEffect(()=>{w(void 0),h(null)},[e.id]),y.useEffect(()=>{P&&o==="history"&&l("chat"),!P&&o==="team-status"&&l("chat")},[o,P]);const z=y.useMemo(()=>Sl(L,P,_),[_,P,L]);y.useEffect(()=>{_&&!L?.some(ie=>ie.id===_)&&w(void 0)},[_,L]);const V=y.useMemo(()=>L?.find(ie=>ie.id===z),[z,L]),K=y.useMemo(()=>{if(L){if(V)return rs(V);for(const ie of L)if(ie.status==="ACTIVE"&&rs(ie))return rs(ie);return rs(L[0])}},[V,L]),ee=V?.status===Rt.ACTIVE?V.id:void 0,Z=wl(V,P),se=V?.branchName??"",xe=V?.commitMessage,be=y.useMemo(()=>Cl(V,L,e?.mainBranch??""),[V,e?.mainBranch,L]),Be=!!(Z&&ee&&K&&!W),{data:ce,isLoading:nt}=An(ee??"",{enabled:Be}),{data:pe}=ci(K,{enabled:Be}),je=pe?.committed?.length,[Ye,Ze]=y.useState(!1),[Re,re]=y.useState(null);y.useEffect(()=>{const ie=o==="changes"||o==="chat"&&Be?"changes":o==="history"?"history":null;if(!ee||!K||!ie){i(null);return}return i({workspaceId:ee,workingDir:K,tab:ie}),()=>{i(null)}},[o,ee,i,Be,K]);const fe=y.useMemo(()=>ce?.conflictOp&&ce.conflictedFiles.length>0?{conflictOp:ce.conflictOp,conflictedFiles:ce.conflictedFiles}:Re,[ce?.conflictOp,ce?.conflictedFiles,Re]),ke=fe?.targetWorkspaceId??ee,Oe=fe?.targetWorktreePath??V?.worktreePath,De=fe?.sourceBranch??se,Fe=fe?.targetBranch??be,Ge=V?.sessions??[],Ne=y.useCallback(ie=>{re(ie??null),Ze(!0)},[]),we=y.useCallback(()=>e?.id?I.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,I]),Q=y.useCallback(async()=>I.fetchQuery({queryKey:le.tasks.body(e.id),queryFn:()=>ve.get(`/tasks/${e.id}/body`)}),[I,e.id]),oe=y.useMemo(()=>{if(!L)return null;const ie=L.filter(qe=>qe.status==="ACTIVE"&&Array.isArray(qe.sessions)).flatMap(qe=>qe.sessions??[]),Se=qe=>{const Ut=qe.createdAt,qt=qe.endedAt??qe.startedAt??Ut;if(!qt)return 0;const Bt=Date.parse(qt);return Number.isNaN(Bt)?0:Bt},Ue=qe=>{const Ut=ie.filter(qt=>qe.includes(qt.status));return Ut.length===0?null:Ut.sort((qt,Bt)=>Se(Bt)-Se(qt))[0]??null},We=Ue([rt.RUNNING])??Ue([rt.PENDING])??Ue([rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(We)return We;const vt=L.filter(qe=>(qe.status==="ABANDONED"||qe.status==="MERGED"||qe.status==="HIBERNATED")&&Array.isArray(qe.sessions)).flatMap(qe=>qe.sessions??[]).filter(qe=>[rt.COMPLETED,rt.FAILED,rt.CANCELLED].includes(qe.status));return vt.length===0?null:vt.sort((qe,Ut)=>Se(Ut)-Se(qe))[0]??null},[L]),ae=oe?.id??"",Y=P?d??"":ae,te=y.useMemo(()=>{if(!d||!L)return null;for(const ie of L){const Se=ie.sessions?.find(Ue=>Ue.id===d);if(Se)return Se}return null},[d,L]),ne=y.useMemo(()=>{if(!d||!P?.invocations)return null;const ie=P.invocations.filter(Se=>Se.sessionId===d);return ie.length===0?null:ie.sort((Se,Ue)=>{const We=Date.parse(Se.updatedAt??Se.createdAt??""),jt=Date.parse(Ue.updatedAt??Ue.createdAt??"");return(Number.isNaN(jt)?0:jt)-(Number.isNaN(We)?0:We)})[0]??null},[d,P?.invocations]),me=y.useMemo(()=>!ne?.memberId||!P?.members?null:P.members.find(ie=>ie.id===ne.memberId)??null,[ne?.memberId,P?.members]),Te=d?te:oe??null,Ee=Te?.status===rt.RUNNING||Te?.status===rt.PENDING,Ae=y.useMemo(()=>!oe||!L?!1:!L.some(Se=>Se.status==="ACTIVE"&&Se.sessions?.some(Ue=>Ue.id===oe.id)),[oe,L]),{data:ye}=Ms(),[Me,et]=y.useState(null),Ve=Me?.sessionId===ae?Me.providerId:oe?.providerId??null,it=y.useCallback(ie=>{et({sessionId:ae,providerId:ie})},[ae]),Le=Sc({agentType:oe?.agentType,workingDir:K,input:u,setInput:c,textareaRef:C,minHeight:40,maxHeight:140}),Pe=wc({agentType:oe?.agentType,workingDir:K,input:u,setInput:c,textareaRef:C,minHeight:40,maxHeight:140}),He=K&&V?V.id:void 0,St=qn(),gt=Tn(),ft=cc(),{isConnected:Dt,isLoadingSnapshot:Et,logs:$e,entries:Ot,attach:It}=Ba({sessionId:Y,sessionStatus:Te?.status,onExit:y.useCallback(()=>{I.invalidateQueries({queryKey:["workspaces"]})},[I])}),{todos:ms}=Fa(Ot),{files:ui,addFiles:tt,removeFile:ps,clear:Os,buildMarkdownLinks:Is,hasFiles:Gt,isUploading:ls}=si(),hr=y.useMemo(()=>hc(Te),[Te?.tokenUsage]),Bs=dc($e,hr);y.useEffect(()=>{Y&&Dt&&It()},[Y,Dt,It]);const gs=y.useRef(null);y.useEffect(()=>{if(gs.current!==e.id&&N.current){const ie=N.current;requestAnimationFrame(()=>{ie.scrollTop=ie.scrollHeight})}gs.current=e.id},[e.id,N]);const $t=y.useRef(!1),vs=y.useCallback(async()=>{if(!u.trim()&&!Gt||!ae||$t.current||ls)return;$t.current=!0;const ie=Is(),Se=[u.trim(),ie].filter(Boolean).join(`
|
|
83
|
-
|
|
84
|
-
`);c(""),Os(),C.current&&(C.current.style.height="40px"),St.mutate({id:ae,message:Se,providerId:Ve??void 0},{onSuccess:()=>It(),onSettled:()=>{$t.current=!1}})},[u,ae,St,It,Gt,ls,Is,Os,Ve]),hi=y.useCallback(async()=>{ae&&(await ft.mutateAsync(ae),I.invalidateQueries({queryKey:["workspaces"]}))},[ae,ft,I]),Fs=y.useCallback(ie=>O.mutateAsync(ie),[O]),fr=y.useCallback(ie=>{h(ie),l("chat"),requestAnimationFrame(()=>{M()})},[M]),fi=y.useCallback(()=>{h(null)},[]),mr=y.useCallback(()=>{l("changes")},[]),pr=Be&&ee?t.jsx(bc,{workspaceId:ee,branchName:se,targetBranch:be,commitMessage:xe,changes:pe,gitStatus:ce,isGitStatusLoading:nt,canRunGitOperations:Z,onOpenChanges:mr,onRefreshCommitMessage:we,onConflict:Ne,className:"mb-2"}):null,xs=y.useCallback(ie=>{const Se=ie.target.files;Se&&Se.length>0&&tt(Array.from(Se)),ie.target.value=""},[tt]),mi=y.useCallback(ie=>{const Se=ie.clipboardData.items,Ue=[];for(const We of Se)if(We.kind==="file"){const jt=We.getAsFile();jt&&Ue.push(jt)}Ue.length>0&&(ie.preventDefault(),tt(Ue))},[tt]),Qt=y.useCallback(ie=>{c(ie.target.value);const Se=ie.target;Se.style.height="auto",Se.style.height=`${Math.max(40,Math.min(Se.scrollHeight,140))}px`},[]),gr=y.useCallback(()=>{He&>.mutate({workspaceId:He})},[gt,He]),Zt=y.useRef(null);return y.useEffect(()=>{const ie=window.visualViewport;if(!ie)return;let Se=!1;const Ue=()=>{Zt.current&&(Zt.current.style.height=`${ie.height}px`,Zt.current.style.top=`${ie.offsetTop}px`)},We=()=>Ue(),jt=()=>{Se||Ue()},vt=()=>{Se=!0},qe=()=>{Se=!1,requestAnimationFrame(Ue)};return ie.addEventListener("resize",We),ie.addEventListener("scroll",jt),document.addEventListener("touchstart",vt,{passive:!0}),document.addEventListener("touchend",qe,{passive:!0}),document.addEventListener("touchcancel",qe,{passive:!0}),()=>{ie.removeEventListener("resize",We),ie.removeEventListener("scroll",jt),document.removeEventListener("touchstart",vt),document.removeEventListener("touchend",qe),document.removeEventListener("touchcancel",qe)}},[]),y.useEffect(()=>{const ie=Zt.current;if(!ie)return;const Se=Ue=>{let We=Ue.target;for(;We&&We!==ie;){if(We.tagName==="TEXTAREA"){if(We.scrollHeight>We.clientHeight)return;We=We.parentElement;continue}const vt=window.getComputedStyle(We).overflowY;if((vt==="auto"||vt==="scroll")&&We.scrollHeight>We.clientHeight)return;We=We.parentElement}Ue.preventDefault()};return ie.addEventListener("touchmove",Se,{passive:!1}),()=>ie.removeEventListener("touchmove",Se)},[]),t.jsxs("div",{ref:Zt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Gs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Sx,{status:e.status}),t.jsx("button",{onClick:gr,disabled:!He||W,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(rr,{size:16})}),r&&!W&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>f(ie=>!ie),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx($a,{size:16})}),a&&t.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:t.jsxs("button",{onClick:()=>{x(!0),f(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:B.map(({key:ie,label:Se,icon:Ue})=>t.jsxs("button",{onClick:()=>l(ie),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${o===ie?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ue,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(Se)})]},ie))})]}),o==="chat"&&(P?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(fc,{session:Te,providers:ye,usage:Bs,compact:!0,providerIdFallback:me?.providerId,agentTypeFallback:Te?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ie,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:fi,children:[t.jsx(Gs,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:N,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:D,children:Et?t.jsx(Hi,{label:v("Loading logs...")}):$e.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(Ee?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Rr,{logs:$e})})}),!A&&t.jsxs("button",{onClick:()=>M(),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":v("Scroll to bottom"),children:[t.jsx(Qs,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Tr,{todos:ms,compact:!0})})]}):t.jsx(yl,{teamRun:P,messages:T??P.messages??[],readOnly:W,readOnlyMessage:R,onSendMessage:Fs,onViewInvocationSession:fr,changeSummaryBar:pr,compactComposer:!0})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:N,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:D,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:U?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):X?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(un,{urlTransform:yx,components:hn,children:X.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!W&&p&&(F||ae)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(fa,{state:p,onRetry:p.status==="failed"?async()=>{await Q(),b(!0)}:void 0})}):null,F?t.jsx(Hi,{label:"Loading..."}):ae?Et?t.jsx(Hi,{label:"Loading logs..."}):$e.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:Ee?"Waiting for agent output...":"No logs recorded."}):t.jsx(Rr,{logs:$e}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Xt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:W?R:v("选择一个 Agent 来执行此任务")}),!W&&p?t.jsx(fa,{state:p}):null,!W&&t.jsxs(Ie,{onClick:async()=>{await Q(),b(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!A&&t.jsxs("button",{onClick:()=>M(),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:[t.jsx(Qs,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Tr,{todos:ms,compact:!0})}),W?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:R})}):Ae?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Ie,{size:"sm",onClick:async()=>{await Q(),b(!0)},children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):ae&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[pr,t.jsxs("div",{ref:k,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(ri,{files:ui,onRemove:ps}),t.jsx("textarea",{ref:C,value:u,onChange:Qt,onPaste:mi,onKeyDown:ie=>{Pe.handleKeyDown(ie)||Le.handleKeyDown(ie)||ie.key==="Enter"&&!ie.shiftKey&&!ie.repeat&&!ie.nativeEvent.isComposing&&ie.nativeEvent.keyCode!==229&&(ie.preventDefault(),vs())},rows:1,placeholder:Ee?"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}}),t.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:xs}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Vr,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[oe&&ye&&t.jsx(pc,{providers:ye,currentProviderId:Ve,agentType:oe.agentType,onSelect:it}),t.jsx(Pn,{usage:Bs}),Ee&&!u.trim()&&!Gt?t.jsx("button",{onClick:hi,disabled:ft.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ns,{size:12})}):t.jsx("button",{onClick:vs,disabled:!u.trim()&&!Gt||ls,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Gt)&&!ls?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Xr,{size:15})})]})]})]}),t.jsx($r,{open:Le.query!==null,anchorRef:k,commands:Le.filteredCommands,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allCommands.length>0,compact:!0,onSelect:Le.applyCommand}),t.jsx($r,{open:Pe.query!==null,anchorRef:k,commands:Pe.filteredSkills,selectedIndex:Pe.selectedIndex,query:Pe.query??"",hasCatalog:Pe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Pe.applySkill})]})]})),o==="team-status"&&P&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(jl,{teamRun:P,workspaces:L,selectedWorkspaceId:z,onSelectWorkspace:w,onViewInvocationSession:fr})}),o==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[L&&L.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(ac,{workspaces:L,teamRun:P,selectedWorkspaceId:z,onSelectWorkspace:w,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),Z&&ee&&t.jsx("div",{className:"shrink-0",children:t.jsx(sc,{workspaceId:ee,branchName:se,targetBranch:be,commitMessage:xe,committedFileCount:je,onRefreshCommitMessage:we,onConflict:Ne,onResolveConflicts:()=>Ne()})}),t.jsx(hx,{workingDir:K})]}),o==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(bx,{workingDir:K})}),o==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(lc,{sessionId:ae||void 0,workspaceId:z,workingDir:K,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:W,repoDeleted:q})}),!W&&t.jsx(uc,{isOpen:g,onClose:()=>b(!1),taskId:e.id,taskTitle:X?.title??e.title,taskDescription:X?.body??"",taskPrompt:X?.prompt,onStarted:()=>m?.(e.id)}),t.jsx(Dn,{isOpen:S,onClose:()=>x(!1),onConfirm:()=>{r?.(e.id),x(!1)},taskId:e.id,taskTitle:e.title,workspaces:L,isLoading:n}),Ye&&fe&&ke&&t.jsx(xc,{open:Ye,onOpenChange:ie=>{Ze(ie),ie||re(null)},workspaceId:ke,conflictOp:fe.conflictOp,conflictedFiles:fe.conflictedFiles,sourceBranch:De,targetBranch:Fe,operation:ce?.operation,worktreePath:Oe,mergeAborted:fe.mergeAborted,mergeStrategy:fe.mergeStrategy,sourceWorkspaceId:fe.sourceWorkspaceId,targetWorkspaceId:fe.targetWorkspaceId,sourceWorktreePath:fe.sourceWorktreePath,targetWorktreePath:fe.targetWorktreePath,sessions:Ge,currentSessionId:P?void 0:ae,teamRunId:P?.id})]})}function Hi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var Ex=Object.defineProperty,qr=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,Nc=Object.prototype.propertyIsEnumerable,ma=(e,s,r)=>s in e?Ex(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,on=(e,s)=>{for(var r in s||(s={}))jc.call(s,r)&&ma(e,r,s[r]);if(qr)for(var r of qr(s))Nc.call(s,r)&&ma(e,r,s[r]);return e},an=(e,s)=>{var r={};for(var n in e)jc.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&qr)for(var n of qr(e))s.indexOf(n)<0&&Nc.call(e,n)&&(r[n]=e[n]);return r};var fs;(e=>{const s=class Ce{constructor(o,l,u,c){if(this.version=o,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],o<Ce.MIN_VERSION||o>Ce.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=o*4+17;let g=[];for(let S=0;S<this.size;S++)g.push(!1);for(let S=0;S<this.size;S++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(u);if(this.drawCodewords(b),c==-1){let S=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<S&&(c=x,S=a),this.applyMask(x)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(o,l){const u=e.QrSegment.makeSegments(o);return Ce.encodeSegments(u,l)}static encodeBinary(o,l){const u=e.QrSegment.makeBytes(o);return Ce.encodeSegments([u],l)}static encodeSegments(o,l,u=1,c=40,g=-1,b=!0){if(!(Ce.MIN_VERSION<=u&&u<=c&&c<=Ce.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let S,x;for(S=u;;S++){const h=Ce.getNumDataCodewords(S,l)*8,_=v.getTotalBits(o,S);if(_<=h){x=_;break}if(S>=c)throw new RangeError("Data too long")}for(const h of[Ce.Ecc.MEDIUM,Ce.Ecc.QUARTILE,Ce.Ecc.HIGH])b&&x<=Ce.getNumDataCodewords(S,h)*8&&(l=h);let a=[];for(const h of o){r(h.mode.modeBits,4,a),r(h.numChars,h.mode.numCharCountBits(S),a);for(const _ of h.getData())a.push(_)}p(a.length==x);const f=Ce.getNumDataCodewords(S,l)*8;p(a.length<=f),r(0,Math.min(4,f-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let h=236;a.length<f;h^=253)r(h,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((h,_)=>d[_>>>3]|=h<<7-(_&7)),new Ce(S,l,d,g)}getModule(o,l){return 0<=o&&o<this.size&&0<=l&&l<this.size&&this.modules[l][o]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const o=this.getAlignmentPatternPositions(),l=o.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(o[u],o[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(o){const l=this.errorCorrectionLevel.formatBits<<3|o;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(c,g));this.setFunctionModule(8,7,n(c,6)),this.setFunctionModule(8,8,n(c,7)),this.setFunctionModule(7,8,n(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let o=this.version;for(let u=0;u<12;u++)o=o<<1^(o>>>11)*7973;const l=this.version<<12|o;p(l>>>18==0);for(let u=0;u<18;u++){const c=n(l,u),g=this.size-11+u%3,b=Math.floor(u/3);this.setFunctionModule(g,b,c),this.setFunctionModule(b,g,c)}}drawFinderPattern(o,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),b=o+c,S=l+u;0<=b&&b<this.size&&0<=S&&S<this.size&&this.setFunctionModule(b,S,g!=2&&g!=4)}}drawAlignmentPattern(o,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(o+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(o,l,u){this.modules[l][o]=u,this.isFunction[l][o]=!0}addEccAndInterleave(o){const l=this.version,u=this.errorCorrectionLevel;if(o.length!=Ce.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Ce.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Ce.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],b=Math.floor(Ce.getNumRawDataModules(l)/8),S=c-b%c,x=Math.floor(b/c);let a=[];const f=Ce.reedSolomonComputeDivisor(g);for(let h=0,_=0;h<c;h++){let w=o.slice(_,_+x-g+(h<S?0:1));_+=w.length;const k=Ce.reedSolomonComputeRemainder(w,f);h<S&&w.push(0),a.push(w.concat(k))}let d=[];for(let h=0;h<a[0].length;h++)a.forEach((_,w)=>{(h!=x-g||w>=S)&&d.push(_[h])});return p(d.length==b),d}drawCodewords(o){if(o.length!=Math.floor(Ce.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const b=u-g,x=(u+1&2)==0?this.size-1-c:c;!this.isFunction[x][b]&&l<o.length*8&&(this.modules[x][b]=n(o[l>>>3],7-(l&7)),l++)}}p(l==o.length*8)}applyMask(o){if(o<0||o>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(o){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let o=0;for(let g=0;g<this.size;g++){let b=!1,S=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==b?(S++,S==5?o+=Ce.PENALTY_N1:S>5&&o++):(this.finderPenaltyAddHistory(S,x),b||(o+=this.finderPenaltyCountPatterns(x)*Ce.PENALTY_N3),b=this.modules[g][a],S=1);o+=this.finderPenaltyTerminateAndCount(b,S,x)*Ce.PENALTY_N3}for(let g=0;g<this.size;g++){let b=!1,S=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==b?(S++,S==5?o+=Ce.PENALTY_N1:S>5&&o++):(this.finderPenaltyAddHistory(S,x),b||(o+=this.finderPenaltyCountPatterns(x)*Ce.PENALTY_N3),b=this.modules[a][g],S=1);o+=this.finderPenaltyTerminateAndCount(b,S,x)*Ce.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let b=0;b<this.size-1;b++){const S=this.modules[g][b];S==this.modules[g][b+1]&&S==this.modules[g+1][b]&&S==this.modules[g+1][b+1]&&(o+=Ce.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((b,S)=>b+(S?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),o+=c*Ce.PENALTY_N4,p(0<=o&&o<=2568888),o}getAlignmentPatternPositions(){if(this.version==1)return[];{const o=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(o*2-2))*2;let u=[6];for(let c=this.size-7;u.length<o;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(o){if(o<Ce.MIN_VERSION||o>Ce.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*o+128)*o+64;if(o>=2){const u=Math.floor(o/7)+2;l-=(25*u-10)*u-55,o>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(o,l){return Math.floor(Ce.getNumRawDataModules(o)/8)-Ce.ECC_CODEWORDS_PER_BLOCK[l.ordinal][o]*Ce.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][o]}static reedSolomonComputeDivisor(o){if(o<1||o>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<o-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<o;c++){for(let g=0;g<l.length;g++)l[g]=Ce.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Ce.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(o,l){let u=l.map(c=>0);for(const c of o){const g=c^u.shift();u.push(0),l.forEach((b,S)=>u[S]^=Ce.reedSolomonMultiply(b,g))}return u}static reedSolomonMultiply(o,l){if(o>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*o;return p(u>>>8==0),u}finderPenaltyCountPatterns(o){const l=o[1];p(l<=this.size*3);const u=l>0&&o[2]==l&&o[3]==l*3&&o[4]==l&&o[5]==l;return(u&&o[0]>=l*4&&o[6]>=l?1:0)+(u&&o[6]>=l*4&&o[0]>=l?1:0)}finderPenaltyTerminateAndCount(o,l,u){return o&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(o,l){l[0]==0&&(o+=this.size),l.pop(),l.unshift(o)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.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]],s.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=s;function r(i,o,l){if(o<0||o>31||i>>>o)throw new RangeError("Value out of range");for(let u=o-1;u>=0;u--)l.push(i>>>u&1)}function n(i,o){return(i>>>o&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class st{constructor(o,l,u){if(this.mode=o,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(o){let l=[];for(const u of o)r(u,8,l);return new st(st.Mode.BYTE,o.length,l)}static makeNumeric(o){if(!st.isNumeric(o))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<o.length;){const c=Math.min(o.length-u,3);r(parseInt(o.substring(u,u+c),10),c*3+1,l),u+=c}return new st(st.Mode.NUMERIC,o.length,l)}static makeAlphanumeric(o){if(!st.isAlphanumeric(o))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=o.length;u+=2){let c=st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u))*45;c+=st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u+1)),r(c,11,l)}return u<o.length&&r(st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u)),6,l),new st(st.Mode.ALPHANUMERIC,o.length,l)}static makeSegments(o){return o==""?[]:st.isNumeric(o)?[st.makeNumeric(o)]:st.isAlphanumeric(o)?[st.makeAlphanumeric(o)]:[st.makeBytes(st.toUtf8ByteArray(o))]}static makeEci(o){let l=[];if(o<0)throw new RangeError("ECI assignment value out of range");if(o<128)r(o,8,l);else if(o<16384)r(2,2,l),r(o,14,l);else if(o<1e6)r(6,3,l),r(o,21,l);else throw new RangeError("ECI assignment value out of range");return new st(st.Mode.ECI,0,l)}static isNumeric(o){return st.NUMERIC_REGEX.test(o)}static isAlphanumeric(o){return st.ALPHANUMERIC_REGEX.test(o)}getData(){return this.bitData.slice()}static getTotalBits(o,l){let u=0;for(const c of o){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(o){o=encodeURI(o);let l=[];for(let u=0;u<o.length;u++)o.charAt(u)!="%"?l.push(o.charCodeAt(u)):(l.push(parseInt(o.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(fs||(fs={}));var Es=fs;var jx={L:Es.QrCode.Ecc.LOW,M:Es.QrCode.Ecc.MEDIUM,Q:Es.QrCode.Ecc.QUARTILE,H:Es.QrCode.Ecc.HIGH},Rc=128,Tc="L",Ac="#FFFFFF",Mc="#000000",Dc=!1,Lc=1,Nx=4,Rx=0,Tx=.1;function Pc(e,s=0){const r=[];return e.forEach(function(n,p){let m=null;n.forEach(function(v,i){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===n.length-1){if(!v)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}v&&m===null&&(m=i)})}),r.join("")}function Oc(e,s){return e.slice().map((r,n)=>n<s.y||n>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Ax(e,s,r,n){if(n==null)return null;const p=e.length+r*2,m=Math.floor(s*Tx),v=p/s,i=(n.width||m)*v,o=(n.height||m)*v,l=n.x==null?e.length/2-i/2:n.x*v,u=n.y==null?e.length/2-o/2:n.y*v,c=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let S=Math.floor(l),x=Math.floor(u),a=Math.ceil(i+l-S),f=Math.ceil(o+u-x);g={x:S,y:x,w:a,h:f}}const b=n.crossOrigin;return{x:l,y:u,h:o,w:i,excavation:g,opacity:c,crossOrigin:b}}function Mx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Nx:Rx}function Ic({value:e,level:s,minVersion:r,includeMargin:n,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let o=he.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...Es.QrSegment.makeSegments(a)),x),[]);return Es.QrCode.encodeSegments(S,jx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=he.useMemo(()=>{let b=o.getModules();const S=Mx(n,p),x=b.length+S*2,a=Ax(b,v,S,m);return{cells:b,margin:S,numCells:x,calculatedImageSettings:a}},[o,v,m,n,p]);return{qrcode:o,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var Dx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Lx=he.forwardRef(function(s,r){const n=s,{value:p,size:m=Rc,level:v=Tc,bgColor:i=Ac,fgColor:o=Mc,includeMargin:l=Dc,minVersion:u=Lc,boostLevel:c,marginSize:g,imageSettings:b}=n,x=an(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,f=an(x,["style"]),d=b?.src,h=he.useRef(null),_=he.useRef(null),w=he.useCallback(I=>{h.current=I,typeof r=="function"?r(I):r&&(r.current=I)},[r]),[k,j]=he.useState(!1),{margin:C,cells:E,numCells:N,calculatedImageSettings:D}=Ic({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:b,size:m});he.useEffect(()=>{if(h.current!=null){const I=h.current,L=I.getContext("2d");if(!L)return;let F=E;const H=_.current,T=D!=null&&H!==null&&H.complete&&H.naturalHeight!==0&&H.naturalWidth!==0;T&&D.excavation!=null&&(F=Oc(E,D.excavation));const O=window.devicePixelRatio||1;I.height=I.width=m*O;const P=m/N*O;L.scale(P,P),L.fillStyle=i,L.fillRect(0,0,N,N),L.fillStyle=o,Dx?L.fill(new Path2D(Pc(F,C))):E.forEach(function(B,$){B.forEach(function(X,U){X&&L.fillRect(U+C,$+C,1,1)})}),D&&(L.globalAlpha=D.opacity),T&&L.drawImage(H,D.x+C,D.y+C,D.w,D.h)}}),he.useEffect(()=>{j(!1)},[d]);const A=on({height:m,width:m},a);let M=null;return d!=null&&(M=he.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:_,crossOrigin:D?.crossOrigin})),he.createElement(he.Fragment,null,he.createElement("canvas",on({style:A,height:m,width:m,ref:w,role:"img"},f)),M)});Lx.displayName="QRCodeCanvas";var Bc=he.forwardRef(function(s,r){const n=s,{value:p,size:m=Rc,level:v=Tc,bgColor:i=Ac,fgColor:o=Mc,includeMargin:l=Dc,minVersion:u=Lc,boostLevel:c,title:g,marginSize:b,imageSettings:S}=n,x=an(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:f,numCells:d,calculatedImageSettings:h}=Ic({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:b,imageSettings:S,size:m});let _=f,w=null;S!=null&&h!=null&&(h.excavation!=null&&(_=Oc(f,h.excavation)),w=he.createElement("image",{href:S.src,height:h.h,width:h.w,x:h.x+a,y:h.y+a,preserveAspectRatio:"none",opacity:h.opacity,crossOrigin:h.crossOrigin}));const k=Pc(_,a);return he.createElement("svg",on({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!g&&he.createElement("title",null,g),he.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),he.createElement("path",{fill:o,d:k,shapeRendering:"crispEdges"}),w)});Bc.displayName="QRCodeSVG";function Fc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Px(){return kt({queryKey:le.tunnel.status,queryFn:()=>ve.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ox(){const e=at();return yt({mutationFn:()=>ve.post("/tunnel/start",{port:Fc()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function Ix(){const e=at();return yt({mutationFn:()=>ve.post("/tunnel/regenerate",{port:Fc()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function Bx(){const e=at();return yt({mutationFn:()=>ve.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function Fx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function zx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function Wx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function pa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const n=Math.round(r/60);if(n<60)return`${n}m ago`;const p=Math.round(n/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function $s(e){const s=e?.trim();return s||null}function Hx(e){if(!e)return"";const s=[$s(e.lastLocalError),$s(e.lastRemoteError),$s(e.lastError)].filter(p=>p!==null),r=$s(e.lastProcessOutput),n=!!r&&(e.status==="error"||e.status==="exited"||!!$s(e.lastError));return r&&n&&s.push(r),s.join(`
|
|
85
|
-
`)}function ga(){const{t:e}=ue(),{data:s}=Px(),r=Ox(),n=Bx(),p=Ix(),[m,v]=y.useState(!1),[i,o]=y.useState(null),l=y.useRef(null),[u,c]=y.useState({top:0,right:0}),[g,b]=y.useState(!1),[S,x]=y.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",f=r.isPending||s?.status==="starting",d=p.isPending,h=s?.shareableUrl,_=s?.token,w=Fx(s),k=zx(s),j=Hx(s);y.useEffect(()=>{if(m&&l.current){const I=l.current.getBoundingClientRect();c({top:I.bottom+8,right:window.innerWidth-I.right})}},[m]);const C=y.useCallback(()=>{v(!0)},[a]),E=y.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),N=y.useCallback(()=>{h&&(navigator.clipboard.writeText(h),o("url"),setTimeout(()=>o(null),2e3))},[h]),D=y.useCallback(()=>{_&&(navigator.clipboard.writeText(_),o("token"),setTimeout(()=>o(null),2e3))},[_]),A=y.useCallback(()=>{n.mutate(),v(!1),b(!1),x(!1)},[n]),M=y.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{x(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:C,disabled:f,className:`p-1.5 rounded-md transition-colors ${w.button}`,title:e(w.label),children:f?t.jsx(ze,{size:16,className:"animate-spin"}):w.icon==="warn"?t.jsx(sr,{size:16}):t.jsx(co,{size:16})}),a&&!f&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${w.dot} rounded-full`}),m&&!a&&ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(co,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Ht,{size:14})})]}),t.jsxs("button",{onClick:E,disabled:f,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[f&&t.jsx(ze,{size:13,className:"animate-spin"}),e(f?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${w.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Wx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Ht,{size:14})})]}),_&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(qa,{size:12}),t.jsx("span",{children:e("Token protected")})]}),h&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Bc,{value:h,size:160})}),h||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:h??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:I=>I.target.select()}),t.jsx("button",{onClick:N,disabled:!h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(bt,{size:14,className:"text-emerald-500"}):t.jsx(oo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:pa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:pa(s?.lastHealthyAt)})]})]}),j&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:j}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),_&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>b(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:_}),t.jsx("button",{onClick:D,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(bt,{size:14,className:"text-emerald-500"}):t.jsx(oo,{size:14})})]})]}),S&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:M,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!S&&t.jsxs("button",{onClick:()=>x(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(ir,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:A,disabled:n.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:n.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function $i({isOpen:e,onClose:s}){const{t:r}=ue(),n=Cd(),[p,m]=y.useState(""),[v,i]=y.useState(""),[o,l]=y.useState(null),[u,c]=y.useState(!1),[g,b]=y.useState(!1),S=p.trim(),x=v.trim(),a=u||n.isPending,f=y.useMemo(()=>!!(S&&x&&!a),[S,x,a]),d=y.useCallback(()=>{m(""),i(""),l(null),b(!1)},[]),h=y.useCallback(()=>{a||(d(),s())},[a,s,d]);y.useEffect(()=>{e||d()},[e,d]);const _=y.useCallback(async j=>{try{await n.mutateAsync({name:S,repoPath:x,initEmptyRepo:j}),d(),s()}catch(C){const E=C instanceof Error?C.message:r("Failed to create project");l(E),ut.error(E)}},[n,s,d,r,S,x]),w=y.useCallback(async()=>{if(!(!S||!x||a)){l(null),c(!0);try{const j=await ve.get("/filesystem/validate",{params:{path:x}});if(j.valid){await _(!1);return}if(j.reason==="no_git"&&j.isEmpty){b(!0);return}if(j.reason==="no_git"){l(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}l(j.error??r("Selected path is not a valid directory"))}catch(j){l(j instanceof Error?j.message:r("Could not check repository path"))}finally{c(!1)}}},[_,a,r,S,x]),k=y.useCallback(()=>{b(!1),_(!0)},[_]);return t.jsxs(t.Fragment,{children:[t.jsx(As,{isOpen:e,onClose:h,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:h,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:w,disabled:!f,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${f?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):n.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:j=>m(j.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,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:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),t.jsx(kd,{value:v,onChange:i,validationMode:"directory"})]}),o&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:o})]})}),t.jsx(Kr,{isOpen:g,onClose:()=>{n.isPending||b(!1)},onConfirm:k,title:r("Initialize Git repository?"),description:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:n.isPending})]})}const $x="/assets/agent-tower-logo-COx9gy77.png";function va({className:e="h-7 w-7"}){return t.jsx("img",{src:$x,alt:"Agent Tower",className:`block shrink-0 object-contain ${e}`})}const Ux={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function xa({projects:e,providers:s,isProvidersLoading:r,onSubmit:n,defaultProjectId:p="",defaultProviderId:m="",onProjectChange:v,createStep:i}){const{t:o}=ue(),[l,u]=y.useState(""),[c,g]=y.useState(p),[b,S]=y.useState(m),[x,a]=y.useState("SOLO"),[f,d]=y.useState(lt.WORKTREE),[h,_]=y.useState("AUTO"),[w,k]=y.useState(null),[j,C]=y.useState([]),[E,N]=y.useState(!1),[D,A]=y.useState(!1),[M,I]=y.useState(!1),[L,F]=y.useState(!1),H=y.useRef(null),T=y.useRef(null),O=y.useRef(null),P=y.useRef(null),B=y.useRef(null),{files:$,addFiles:X,removeFile:U,clear:W,buildMarkdownLinks:q,isUploading:R}=si();y.useEffect(()=>{g(p),v?.(p)},[p,v]),y.useEffect(()=>{S(m)},[m]),y.useEffect(()=>{if(!D)return;const re=fe=>{H.current&&!H.current.contains(fe.target)&&A(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[D]),y.useEffect(()=>{if(!M)return;const re=fe=>{T.current&&!T.current.contains(fe.target)&&I(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[M]),y.useEffect(()=>{if(!L)return;const re=fe=>{O.current&&!O.current.contains(fe.target)&&F(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[L]);const z=y.useMemo(()=>e.find(re=>re.id===c),[e,c]),V=y.useMemo(()=>s.find(re=>re.id===b),[s,b]),K=f===lt.MAIN_DIRECTORY?o("本地模式"):o("工作树模式"),ee=i!=="idle",Z=!!w||j.length>0,se=!ee&&!R&&l.trim().length>0&&!!c&&(x==="TEAM"?Z:!!b),xe=y.useCallback(async()=>{if(!se)return;const re=q();try{await n({title:l.trim(),description:"",projectId:c,providerId:b,mode:x,workspaceMode:x==="SOLO"?f:lt.WORKTREE,teamRunMode:h,teamTemplateId:w,memberPresetIds:j,attachmentLinks:re}),u(""),W()}catch{}},[se,l,c,b,x,f,h,w,j,n,q,W]),be=y.useCallback(re=>{re.key==="Enter"&&!re.shiftKey&&!re.nativeEvent.isComposing&&re.nativeEvent.keyCode!==229&&(re.preventDefault(),xe())},[xe]),Be=y.useCallback(re=>{const fe=re.target.files;fe&&fe.length>0&&X(Array.from(fe)),re.target.value=""},[X]),ce=y.useCallback(re=>{g(re),v?.(re),A(!1)},[v]),nt=y.useCallback(re=>{const fe=re.clipboardData.items,ke=[];for(const Oe of fe)if(Oe.kind==="file"){const De=Oe.getAsFile();De&&ke.push(De)}ke.length>0&&(re.preventDefault(),X(ke))},[X]),[pe,je]=y.useState(!1),Ye=y.useCallback(re=>{re.preventDefault(),je(!0)},[]),Ze=y.useCallback(re=>{re.preventDefault(),je(!1)},[]),Re=y.useCallback(re=>{re.preventDefault(),je(!1);const fe=re.dataTransfer.files;fe.length>0&&X(Array.from(fe))},[X]);return t.jsxs("div",{className:"w-full",children:[t.jsxs("div",{className:G("relative bg-background rounded-xl border transition-colors duration-200","hover:border-ring/40 focus-within:border-ring/60",pe?"border-info bg-info/5":"border-border",ee&&"opacity-80"),onDragOver:Ye,onDragLeave:Ze,onDrop:Re,children:[$.length>0&&t.jsx("div",{className:"px-4 pt-3",children:t.jsx(ri,{files:$,onRemove:U})}),t.jsx("textarea",{ref:P,value:l,onChange:re=>u(re.target.value),onKeyDown:be,onPaste:nt,placeholder:o("Describe your task..."),disabled:ee,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-base text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"80px",maxHeight:"200px",fieldSizing:"content"}}),pe&&t.jsx("div",{className:"px-4 pb-2",children:t.jsx("div",{className:"flex items-center justify-center py-3 border-2 border-dashed border-border rounded-lg text-sm text-muted-foreground",children:o("Drop files here")})}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>B.current?.click(),disabled:ee||R,className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:o("Attach files"),children:t.jsx(Vr,{size:18})}),t.jsx("input",{ref:B,type:"file",multiple:!0,onChange:Be,className:"hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[R&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin"}),o("Uploading...")]}),ee&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin"}),o(Ux[i])]}),!ee&&!R&&x==="TEAM"&&!Z&&l.trim().length>0&&t.jsx("span",{className:"text-[11px] text-warning",children:o("请选择团队模板或追加成员")}),se&&t.jsxs("span",{className:"hidden sm:inline text-[11px] text-muted-foreground/60 select-none",children:["⏎ ",o("创建")]}),t.jsx("button",{type:"button",onClick:xe,disabled:!se,className:G("p-2 rounded-lg transition-all duration-200",se?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"),title:o("Create & Start"),children:t.jsx(Xr,{size:16})})]})]})]}),t.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5",children:[t.jsxs("div",{className:"relative",ref:H,children:[t.jsxs("button",{type:"button",onClick:()=>{ee||A(re=>!re)},disabled:ee,className:G("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",z?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx("span",{className:"size-2 rounded-full shrink-0",style:{backgroundColor:z?.color??"var(--muted-foreground)"}}),t.jsx("span",{className:"max-w-[120px] truncate",children:z?.name??o("Project")}),t.jsx(ht,{size:12,className:G("text-muted-foreground/70 transition-transform",D&&"rotate-180")})]}),D&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:e.map(re=>t.jsxs("button",{type:"button",onClick:()=>ce(re.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:re.color??"var(--muted-foreground)"}}),t.jsx("span",{className:G("truncate flex-1",re.id===c?"text-foreground font-medium":"text-muted-foreground"),children:re.name}),t.jsx(bt,{size:14,className:G("ml-2 shrink-0",re.id===c?"opacity-100":"opacity-0")})]},re.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:T,children:[t.jsxs("button",{type:"button",onClick:()=>{ee||I(re=>!re)},disabled:ee,className:G("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",V?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx(Fd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[120px] truncate",children:V?.name??o(r?"Loading...":"Agent")}),t.jsx(ht,{size:12,className:G("text-muted-foreground/70 transition-transform",M&&"rotate-180")})]}),M&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(re=>t.jsxs("button",{type:"button",disabled:!re.available,onClick:()=>{S(re.id),I(!1)},className:G("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",!re.available&&"opacity-40 cursor-not-allowed"),children:[t.jsx(bt,{size:14,className:G("mr-2 shrink-0",re.id===b?"opacity-100":"opacity-0")}),t.jsxs("span",{className:G("truncate",re.id===b?"text-foreground font-medium":"text-muted-foreground"),children:[re.name,re.available?"":o(" (unavailable)")]})]},re.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:O,children:[t.jsxs("button",{type:"button",onClick:()=>{ee||F(re=>!re)},disabled:ee,className:G("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","text-foreground/80"),children:[t.jsx(xn,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[96px] truncate",children:K}),t.jsx(ht,{size:12,className:G("text-muted-foreground/70 transition-transform",L&&"rotate-180")})]}),L&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-40 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 z-50",children:[t.jsxs("button",{type:"button",onClick:()=>{d(lt.WORKTREE),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(bt,{size:14,className:G("mr-2 shrink-0",f===lt.WORKTREE?"opacity-100":"opacity-0")}),t.jsx("span",{className:G("truncate",f===lt.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:o("工作树模式")})]}),t.jsxs("button",{type:"button",onClick:()=>{d(lt.MAIN_DIRECTORY),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(bt,{size:14,className:G("mr-2 shrink-0",f===lt.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),t.jsx("span",{className:G("truncate",f===lt.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:o("本地模式")})]})]})]}),t.jsxs("div",{className:"ml-auto inline-flex items-center rounded-lg border border-border/70 bg-muted/50 p-0.5",children:[t.jsx("button",{type:"button",onClick:()=>{ee||x==="SOLO"||(a("SOLO"),N(!1))},disabled:ee,className:G("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="SOLO"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:o("Switch to Solo Agent"),children:o("单人")}),t.jsx("button",{type:"button",onClick:()=>{ee||x==="TEAM"||(a("TEAM"),F(!1),d(lt.WORKTREE),N(!0))},disabled:ee,className:G("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="TEAM"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:o("Switch to TeamRun"),children:o("团队")})]})]}),x==="SOLO"&&f===lt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2",children:t.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-2.5 py-1.5 text-[11px] leading-relaxed text-warning",children:o("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),x==="TEAM"&&E&&t.jsxs("div",{className:"mt-2 rounded-xl bg-muted/50 px-4 pt-3 pb-4",children:[t.jsx("div",{className:"mb-2.5",children:t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:o("团队协作配置")})}),t.jsx(mc,{mode:h,setMode:_,selectedTemplateId:w,setSelectedTemplateId:k,selectedMemberPresetIds:j,setSelectedMemberPresetIds:C,disabled:ee})]})]})}const ba=t.jsx("span",{className:"font-semibold text-foreground tracking-tight text-base",children:"Agent Tower"});function _a({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:n,className:p}){const{t:m}=ue(),[v,i]=y.useState(!1),o=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:G("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Rs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(ht,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Rs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(bt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:o.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(bt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),n()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(Vt,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ya(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const qx=260,Kx=600,Sa=400,Vx=100,Er=1e3;function Xx(e,s){return e&&(e.data.findIndex(n=>n.id===s.id)>=0?{...e,data:e.data.map(n=>n.id===s.id?{...n,...s}:n)}:{...e,data:[s,...e.data],total:e.total+1})}function xb(){const{t:e,locale:s}=ue(),[r,n]=y.useState(null),[p,m]=y.useState(null),[v,i]=y.useState(Sa),[o,l]=y.useState(!1),[u,c]=y.useState("idle"),[g,b]=y.useState({}),S=y.useRef(!1),x=y.useRef(0),a=y.useRef(Sa),f=y.useRef(null),d=at(),{data:h,isLoading:_}=Ms(),{data:w,isLoading:k}=Ed({limit:Vx}),j=y.useMemo(()=>w?.data??[],[w?.data]),C=y.useMemo(()=>j.map(ix),[j]),E=p&&j.some(Y=>Y.id===p)?p:null,{data:N,isLoading:D}=xd(E??"",{limit:Er}),A=Md({queries:E?[]:j.map(Y=>({queryKey:le.tasks.list(Y.id,{limit:Er}),queryFn:()=>ve.get(`/projects/${Y.id}/tasks`,{params:{limit:String(Er)}})}))}),M=!E&&A.some(Y=>Y.isLoading),I=y.useMemo(()=>{if(E)return N?.data??[];const Y=[];for(const te of A)te.data?.data&&Y.push(...te.data.data);return Y},[E,N,A]),[L,F]=y.useState([]),H=y.useMemo(()=>{if(L.length===0)return I;const Y=new Set(I.map(te=>te.id));return[...L.filter(te=>!Y.has(te.id)),...I]},[I,L]),[T,O]=y.useState(null),P=y.useMemo(()=>r&&H.some(Y=>Y.id===r)?r:T&&r===T?T:null,[r,H,T]);y.useEffect(()=>{T&&H.some(Y=>Y.id===T)&&O(null)},[T,H]),y.useEffect(()=>{if(L.length===0)return;const Y=new Set(I.map(te=>te.id));L.some(te=>Y.has(te.id))&&F(te=>te.filter(ne=>!Y.has(ne.id)))},[I,L]);const B=y.useMemo(()=>{const Y=new Map;for(const te of H){const ne=te.createdAt?new Date(te.createdAt).getTime():0,me=Y.get(te.projectId)??0;ne>me&&Y.set(te.projectId,ne)}return[...j].sort((te,ne)=>{const me=Y.get(te.id)??(te.createdAt?new Date(te.createdAt).getTime():0);return(Y.get(ne.id)??(ne.createdAt?new Date(ne.createdAt).getTime():0))-me})},[j,H]),$=y.useMemo(()=>B.filter(Y=>!Y.archivedAt),[B]),X=y.useMemo(()=>{if(!h)return[];const Y=localStorage.getItem("providerUsageCount"),te=Y?JSON.parse(Y):{};return[...h].sort((ne,me)=>{const Te=ne.availability.type!=="NOT_FOUND",Ee=me.availability.type!=="NOT_FOUND";if(Te!==Ee)return Te?-1:1;const Ae=te[ne.provider.id]??0;return(te[me.provider.id]??0)-Ae})},[h]),U=y.useMemo(()=>H.map(ox),[H]),W=y.useMemo(()=>new Set,[]),q=y.useMemo(()=>{if(!P)return null;const Y=H.find(ne=>ne.id===P);if(!Y)return null;const te=j.find(ne=>ne.id===Y.projectId);if(!te){const ne=hs(Y.workspaces?.find(me=>me.status==="ACTIVE")??Y.workspaces?.[0]);return{id:Y.id,projectId:Y.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:Y.title,status:Kn(Y.status),branch:ne,mainBranch:"main",description:Y.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return ax(Y,te)},[P,H,j]),R=Na(),z=bd(),V=_d(),K=Un(),ee=y.useCallback(Y=>{F(te=>te.some(ne=>ne.id===Y.id)?te.map(ne=>ne.id===Y.id?{...ne,...Y}:ne):[Y,...te]),d.setQueryData(le.tasks.list(Y.projectId,{limit:Er}),te=>Xx(te,Y)),d.setQueryData(le.tasks.detail(Y.id),Y),O(Y.id),n(Y.id)},[d]),Z=y.useCallback((Y,te,ne)=>{const me=Y.id,Te=[Y.title,Y.description].filter(Boolean).join(`
|
|
86
|
-
|
|
87
|
-
`);b(Ee=>({...Ee,[me]:{status:"creating-workspace"}})),(async()=>{try{const Ee=await ve.post(`/tasks/${me}/workspaces`,{workspaceKind:ne});b(ye=>({...ye,[me]:{status:"creating-session"}}));const Ae=await ve.post(`/workspaces/${Ee.id}/sessions`,{providerId:te,prompt:Te});b(ye=>({...ye,[me]:{status:"starting-session"}})),await K.mutateAsync(Ae.id),await d.invalidateQueries({queryKey:le.workspaces.list(me)}),await d.invalidateQueries({queryKey:le.tasks.all}),b(ye=>{const{[me]:Me,...et}=ye;return et})}catch(Ee){const Ae=Ee instanceof Error?Ee.message:e("启动 Agent 失败");b(ye=>({...ye,[me]:{status:"failed",error:Ae}})),ut.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:le.workspaces.list(me)}),d.invalidateQueries({queryKey:le.tasks.all})}})()},[d,K,e]),se=y.useCallback(Y=>{b(te=>{const{[Y]:ne,...me}=te;return me}),d.invalidateQueries({queryKey:le.workspaces.list(Y)}),d.invalidateQueries({queryKey:le.tasks.all})},[d]),xe=y.useCallback(Y=>{z.mutate(Y,{onSuccess:()=>{P===Y&&n(null),b(te=>{const{[Y]:ne,...me}=te;return me}),F(te=>te.filter(ne=>ne.id!==Y)),d.invalidateQueries({queryKey:le.tasks.all})},onError:()=>{ut.error(e("删除任务失败"))}})},[z,P,d,e]),be=y.useCallback((Y,te)=>{V.mutate({id:Y,status:sx(te)},{onError:()=>{ut.error(e("状态变更失败,该操作不被允许"))}})},[V,e]),Be=y.useCallback(Y=>{Y.preventDefault(),S.current=!0,x.current=Y.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);y.useEffect(()=>{const Y=ne=>{if(!S.current)return;const me=ne.clientX-x.current,Te=Math.max(qx,Math.min(Kx,a.current+me));i(Te)},te=()=>{S.current&&(S.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",te),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",te)}},[]);const ce=y.useCallback(()=>{l(!0)},[]),nt=y.useCallback(()=>{if($.length===0){ut.error(e("没有可用项目,请先创建或恢复项目"));return}n(null)},[$,e]),pe=y.useCallback(()=>{l(!1)},[]),je=y.useCallback(async Y=>{const{title:te,description:ne,projectId:me,providerId:Te,mode:Ee,workspaceMode:Ae,teamRunMode:ye,teamTemplateId:Me,memberPresetIds:et,attachmentLinks:Ve}=Y,it=[ne,Ve].filter(Boolean).join(`
|
|
88
|
-
|
|
89
|
-
`);let Le=null;try{if(c("creating-task"),Le=await ve.post(`/projects/${me}/tasks`,{title:te,description:it||void 0}),localStorage.setItem("lastSelectedProjectId",me),Ee==="SOLO"&&Te){localStorage.setItem("lastSelectedProviderId",Te);const Pe=localStorage.getItem("providerUsageCount"),He=Pe?JSON.parse(Pe):{};He[Te]=(He[Te]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(He))}Ee==="TEAM"?(c("creating-teamrun"),await R.mutateAsync({taskId:Le.id,mode:ye,...Me?{teamTemplateId:Me}:{},...et.length>0?{memberPresetIds:et}:{}})):Te&&Z(Le,Te,Ae),E&&me!==E&&m(null),ee(Le),c("idle"),d.invalidateQueries({queryKey:le.tasks.all}),d.invalidateQueries({queryKey:le.projects.all})}catch(Pe){if(c("idle"),Le&&Ee==="TEAM"){try{await z.mutateAsync(Le.id)}catch{}throw ut.error(e("TeamRun 创建失败,请检查团队配置后重试")),Pe}else if(Le)E&&me!==E&&m(null),ee(Le),d.invalidateQueries({queryKey:le.tasks.all}),d.invalidateQueries({queryKey:le.projects.all});else throw ut.error(Pe instanceof Error?Pe.message:e("Failed to create task")),Pe}},[R,Z,z,d,e,E,ee]),Ye=k||D||M,Ze=y.useMemo(()=>$.map(Y=>({id:Y.id,name:Y.name,color:C.find(te=>te.id===Y.id)?.color})),[$,C]),Re=y.useMemo(()=>X.map(({provider:Y,availability:te})=>({id:Y.id,name:Y.name,available:te.type!=="NOT_FOUND"})),[X]),re=y.useMemo(()=>{if(E&&$.find(te=>te.id===E))return E;const Y=localStorage.getItem("lastSelectedProjectId");return Y&&$.find(te=>te.id===Y)?Y:$[0]?.id??""},[$,E]),[fe,ke]=y.useState(re);y.useEffect(()=>{ke(re)},[re]);const Oe=y.useMemo(()=>$.find(Y=>Y.id===fe)?.name??$.find(Y=>Y.id===re)?.name??e("Project"),[$,fe,re,e]),De=s==="zh-CN"?`你需要在 ${Oe} 中做点什么?`:`What do you need to do in ${Oe}?`,Fe=y.useMemo(()=>{const Y=localStorage.getItem("lastSelectedProviderId");return Y&&X.find(ne=>ne.provider.id===Y&&ne.availability.type!=="NOT_FOUND")?Y:X.find(ne=>ne.availability.type!=="NOT_FOUND")?.provider.id??""},[X]),Ge=fl(),[Ne,we]=y.useState(!1),Q=y.useMemo(()=>{if(typeof window>"u")return!1;const Y=new URLSearchParams(window.location.search);return Y.get("desktop")==="1"&&Y.get("desktopTitlebar")==="integrated"},[]),oe=y.useCallback(()=>{if($.length===0){ut.error(e("没有可用项目,请先创建或恢复项目"));return}we(!0)},[$,e]),ae=y.useCallback(async Y=>{await je(Y),we(!1)},[je]);return Ge?Ne?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>we(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-2xl tracking-tight leading-tight text-foreground mb-6 break-words",children:De}),t.jsx(xa,{projects:Ze,providers:Re,isProvidersLoading:_,onSubmit:ae,defaultProjectId:re,defaultProviderId:Fe,onProjectChange:ke,createStep:u})]})]}):P&&q?t.jsxs(t.Fragment,{children:[t.jsx(kx,{task:q,onBack:()=>n(null),onDeleteTask:q.projectArchivedAt?void 0:xe,isDeleting:z.isPending,autoStartState:g[q.id]??null,onAutoStartRecovered:se}),t.jsx($i,{isOpen:o,onClose:pe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(va,{}),ba,t.jsx(_a,{projects:C,filterProjectId:E,setFilterProjectId:m,onCreateProject:ce})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ga,{}),t.jsx("button",{onClick:()=>io.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(ro,{size:16})})]})]}),Ye&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ya,{})}):t.jsx(wo,{tasks:U,projects:C,selectedTaskId:null,onSelectTask:n,filterProjectId:E,setFilterProjectId:m,width:"100%",onCreateTask:oe,onCreateProject:ce,activeTaskIds:W,onTaskStatusChange:be})]}),t.jsx($i,{isOpen:o,onClose:pe})]}):t.jsxs("div",{ref:f,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:G("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",Q&&"app-region-drag"),children:[t.jsxs("div",{className:G("flex items-center gap-2 min-w-0",Q&&"pl-[72px]"),children:[t.jsx(va,{}),ba,t.jsx(_a,{projects:C,filterProjectId:E,setFilterProjectId:m,onCreateProject:ce,className:Q?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:G("flex items-center gap-1",Q&&"app-region-no-drag"),children:[t.jsx("div",{className:Q?"app-region-no-drag":void 0,children:t.jsx(ga,{})}),t.jsx("button",{onClick:()=>io.getState().openSettings(),className:G("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",Q&&"app-region-no-drag"),children:t.jsx(ro,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ye&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ya,{})}):t.jsx(wo,{tasks:U,projects:C,selectedTaskId:P,onSelectTask:n,filterProjectId:E,setFilterProjectId:m,width:v,onCreateTask:nt,onCreateProject:ce,isCreateActive:!P,activeTaskIds:W,onTaskStatusChange:be,onDeleteTask:xe}),t.jsx("div",{onMouseDown:Be,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:P&&q?t.jsx(tx,{task:q,onDeleteTask:q.projectArchivedAt?void 0:xe,isDeleting:z.isPending,onTaskStatusChange:q.projectArchivedAt?void 0:be,autoStartState:g[q.id]??null,onAutoStartRecovered:se}):P&&!q?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-3xl tracking-tight leading-tight text-foreground mb-8 break-words",children:De}),t.jsx(xa,{projects:Ze,providers:Re,isProvidersLoading:_,onSubmit:je,defaultProjectId:re,defaultProviderId:Fe,onProjectChange:ke,createStep:u})]})})})]}),t.jsx($i,{isOpen:o,onClose:pe})]})}export{xb as ProjectKanbanPage};
|