cogpit 3.5.1 → 3.5.3
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-runtime.js +39279 -35071
- package/dist/instance-worker.js +1206 -154
- package/dist/web/assets/AutomationsPanel-D7XmgTgZ.js +1 -0
- package/dist/web/assets/{CogpitBlock-ZgOubpsS.js → CogpitBlock-CiS2M1Q_.js} +16 -16
- package/dist/web/assets/CommandPaletteHost-Dj06VjlP.js +1 -0
- package/dist/web/assets/ConfigBrowser-DqQo1F4o.js +1 -0
- package/dist/web/assets/CrewPanel-DzLPmS6o.js +1 -0
- package/dist/web/assets/HighlightedEditor-DPrSCx1c.js +2 -0
- package/dist/web/assets/KeyboardShortcutsDialog-BdXPWBJw.js +1 -0
- package/dist/web/assets/MissionHome-CTcx5vR7.js +2 -0
- package/dist/web/assets/MobileFileChanges-Ngv9AlhR.js +1 -0
- package/dist/web/assets/PluginsDialog-CWRSNNll.js +1 -0
- package/dist/web/assets/PreviewPanel-CQcJIdef.js +1 -0
- package/dist/web/assets/ProjectFilesPanel-D5EKIBD7.js +4 -0
- package/dist/web/assets/ProjectSwitcherModal-BoSCOiv9.js +1 -0
- package/dist/web/assets/{TerminalOutput-DOX29EmA.js → TerminalOutput-DYZJD2WR.js} +3 -3
- package/dist/web/assets/ThemeSelectorModal-8sO11Ob-.js +1 -0
- package/dist/web/assets/WorkflowsPanel-qv6TkN7g.js +1 -0
- package/dist/web/assets/WorktreePanel-Dr82TWOP.js +1 -0
- package/dist/web/assets/{bash-Yzrsuije.js → bash-DgJyDXW6.js} +1 -1
- package/dist/web/assets/{c-BIGW1oBm.js → c-BG-tZi7o.js} +1 -1
- package/dist/web/assets/cpp-BzPMphJ4.js +1 -0
- package/dist/web/assets/{css-DPfMkruS.js → css-PZBBrkI0.js} +1 -1
- package/dist/web/assets/edition-ui-DQHX5fm4.js +2 -0
- package/dist/web/assets/github-dark-BQV5ugrc.js +1 -0
- package/dist/web/assets/github-light-Rcb2q3L5.js +1 -0
- package/dist/web/assets/{go-CxLEBnE3.js → go-BBr2UQCn.js} +1 -1
- package/dist/web/assets/{html-GMplVEZG.js → html-DOf0XnR2.js} +1 -1
- package/dist/web/assets/index-BGSPI7dK.js +1 -0
- package/dist/web/assets/index-BVmNox_3.js +504 -0
- package/dist/web/assets/index-CHtH7TlZ.js +2 -0
- package/dist/web/assets/index-DKDki7Rz.css +1 -0
- package/dist/web/assets/index-DU4gWgPu.js +3 -0
- package/dist/web/assets/{index-By5-_P50.js → index-zhwBlO_8.js} +4 -4
- package/dist/web/assets/{java-CylS5w8V.js → java-BTDmaRNO.js} +1 -1
- package/dist/web/assets/{javascript-wDzz0qaB.js → javascript-WyGyM1wV.js} +1 -1
- package/dist/web/assets/{json-Cp-IABpG.js → json-B8JryHcM.js} +1 -1
- package/dist/web/assets/{jsx-g9-lgVsj.js → jsx-8cLv2Six.js} +1 -1
- package/dist/web/assets/{kotlin-BdnUsdx6.js → kotlin-BQy537ds.js} +1 -1
- package/dist/web/assets/{markdown-Cvjx9yec.js → markdown-DX-TNHnc.js} +1 -1
- package/dist/web/assets/{php-aq0itWAE.js → php-47JHu45N.js} +1 -1
- package/dist/web/assets/{python-B6aJPvgy.js → python-B6Ihcp-E.js} +1 -1
- package/dist/web/assets/render.worker-DW0Lo4fc.js +154 -0
- package/dist/web/assets/ruby-BrGyNOch.js +1 -0
- package/dist/web/assets/{rust-B1yitclQ.js → rust-CxuBE0J8.js} +1 -1
- package/dist/web/assets/{scss-OYdSNvt2.js → scss-DxBkwadj.js} +1 -1
- package/dist/web/assets/session-parser.worker-DCsmYUeX.js +41 -0
- package/dist/web/assets/{sql-BLtJtn59.js → sql-BbONfI8K.js} +1 -1
- package/dist/web/assets/svelte-H3swLp47.js +1 -0
- package/dist/web/assets/{swift-D82vCrfD.js → swift-tEesUtni.js} +1 -1
- package/dist/web/assets/switch-gTnbAJaZ.js +1 -0
- package/dist/web/assets/{toml-vGWfd6FD.js → toml-Ms459DBw.js} +1 -1
- package/dist/web/assets/{tsx-COt5Ahok.js → tsx-D6116Ycy.js} +1 -1
- package/dist/web/assets/{typescript-BPQ3VLAy.js → typescript-BqvgUolh.js} +1 -1
- package/dist/web/assets/vendor-markdown-BEJ8yVzA.js +29 -0
- package/dist/web/assets/{vendor-ui-DQeMoSiV.js → vendor-ui-CKjyvB3_.js} +226 -191
- package/dist/web/assets/vue-CWSgrUPf.js +1 -0
- package/dist/web/assets/{xml-D2mA2LmW.js → xml-CdYS3kUe.js} +1 -1
- package/dist/web/assets/{yaml-Buea-lGh.js → yaml-Bopit2L3.js} +1 -1
- package/dist/web/index.html +4 -5
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-Djn2jqYR.js +0 -1
- package/dist/web/assets/ConfigBrowser-CRwh8BXq.js +0 -1
- package/dist/web/assets/CrewPanel-BxPl5D7h.js +0 -1
- package/dist/web/assets/HighlightedEditor-D9A-dW2Z.js +0 -2
- package/dist/web/assets/KeyboardShortcutsDialog-L7rRhApI.js +0 -1
- package/dist/web/assets/MissionHome-zp7VebSO.js +0 -2
- package/dist/web/assets/MobileFileChanges-O-SvMq9F.js +0 -1
- package/dist/web/assets/PluginsDialog-CBOyfoUX.js +0 -1
- package/dist/web/assets/PreviewPanel-_pKuUaps.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-BsbpTgWK.js +0 -4
- package/dist/web/assets/ProjectSwitcherModal-D4MzdPVH.js +0 -1
- package/dist/web/assets/ThemeSelectorModal-7CWXZB-z.js +0 -1
- package/dist/web/assets/WorkflowsPanel-aOz1o3kA.js +0 -1
- package/dist/web/assets/WorktreePanel-BFve9bpC.js +0 -1
- package/dist/web/assets/cpp-BRuaLJcg.js +0 -1
- package/dist/web/assets/edition-ui-CFxEM3WF.js +0 -2
- package/dist/web/assets/github-dark-DHJKELXO.js +0 -1
- package/dist/web/assets/github-light-DAi9KRSo.js +0 -1
- package/dist/web/assets/index-CPTFl4Qh.js +0 -498
- package/dist/web/assets/index-DjpYbGVZ.js +0 -2
- package/dist/web/assets/index-DmMg-zf3.js +0 -1
- package/dist/web/assets/index-hGMtuUNI.css +0 -1
- package/dist/web/assets/ruby-B0Tyh1qT.js +0 -1
- package/dist/web/assets/session-parser.worker-3tFlB6dy.js +0 -31
- package/dist/web/assets/svelte-DZMnMd3x.js +0 -1
- package/dist/web/assets/switch-DS7UyNS2.js +0 -1
- package/dist/web/assets/vendor-markdown-BE1gYnO9.js +0 -37
- package/dist/web/assets/vendor-shiki-DOn6sF-i.js +0 -144
- package/dist/web/assets/vue-DVfSmUF7.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as Y,r as W,j as t}from"./vendor-react-gGw_S5I_.js";import{b6 as Se,J as Z,b7 as Ce,b8 as ye,v as Ae,b9 as ve,ba as de,aK as De,B as H,bb as Pe,bc as _e,P as Ee,bd as Me,be as ue,b0 as fe,A as me,bf as Re,bg as oe,H as $e,T as ze,bh as Ke,bi as Oe,bj as Te,bk as Le,bl as Fe,bm as Be,bn as Qe,bo as Ue,bp as He,bq as Ve,br as Ye,$ as le,L as Ge,M as Xe,Q as Je,bs as We,Z as Ze,bt as pe,bu as es,bv as ss,bw as ts,bx as ns,by as is}from"./index-CPTFl4Qh.js";import{n as xe,aa as ls,b as rs,ab as os,ac as as,ad as cs,ae as ds,C as Ie,$ as us,af as fs,S as ms,X as xs}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const gs=6;function ps(c){const e=Y.c(72),{recent:s,start:n}=c,[l,r]=W.useState(null),[i,x]=W.useState(""),a=l??s[0]??null;let u,h,d,f,o,g,m,b,p,j,v,N,w;if(e[0]!==l||e[1]!==a||e[2]!==s||e[3]!==n||e[4]!==i){h=(l&&!s.some(A=>he(A,l))?[l,...s]:[...s]).slice(0,gs);let z;e[18]!==i?(z=i.trim(),e[18]=i,e[19]=z):z=e[19];const F=z;u=!!(a&&F);let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=(A,V)=>{r({dirName:A,cwd:V,name:V?ve(V):A})},e[20]=k):k=e[20],d=k;let T;e[21]!==n.defaultAgentKind?(T=A=>d(de(n.defaultAgentKind,A),A),e[21]=n.defaultAgentKind,e[22]=T):T=e[22],f=T;const G=a==null?void 0:a.cwd;let B;e[23]!==G||e[24]!==a?(B=a&&G?A=>r({...a,dirName:de(A,G)}):void 0,e[23]=G,e[24]=a,e[25]=B):B=e[25],m=B;let X;e[26]!==F||e[27]!==a||e[28]!==n?(X=A=>{A==null||A.preventDefault(),!(!a||!F)&&(n.onStart(a.dirName,a.cwd,F),x(""))},e[26]=F,e[27]=a,e[28]=n,e[29]=X):X=e[29],g=X;let J;e[30]!==g?(J=A=>{A.key==="Enter"&&!A.shiftKey&&!A.nativeEvent.isComposing&&(A.preventDefault(),g())},e[30]=g,e[31]=J):J=e[31],o=J,N="Start a session",w="flex min-w-0 flex-col gap-3",b="flex flex-wrap items-center gap-1.5",p="group",j="Projects",v=h.map(A=>{const V=a!==null&&he(A,a);return t.jsxs("button",{type:"button","aria-pressed":V,title:A.cwd??A.name,onClick:()=>r(A),className:Z("flex max-w-48 items-center gap-1.5 rounded-full border py-1 pl-1.5 pr-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",V?"border-foreground/80 bg-foreground text-background":"border-border/70 text-muted-foreground hover:border-foreground/40 hover:text-foreground"),children:[t.jsx(Se,{projectPath:A.cwd??null,fallback:t.jsx(xe,{className:"size-3.5","aria-hidden":"true"}),className:"size-4"}),t.jsx("span",{className:"truncate",children:A.name})]},A.cwd??A.dirName)}),e[0]=l,e[1]=a,e[2]=s,e[3]=n,e[4]=i,e[5]=u,e[6]=h,e[7]=d,e[8]=f,e[9]=o,e[10]=g,e[11]=m,e[12]=b,e[13]=p,e[14]=j,e[15]=v,e[16]=N,e[17]=w}else u=e[5],h=e[6],d=e[7],f=e[8],o=e[9],g=e[10],m=e[11],b=e[12],p=e[13],j=e[14],v=e[15],N=e[16],w=e[17];const I=h.length>0;let y;e[32]!==d||e[33]!==f||e[34]!==n.defaultAgentKind||e[35]!==I?(y=t.jsx(hs,{defaultAgentKind:n.defaultAgentKind,onChoose:d,onChooseFolder:f,anyListed:I}),e[32]=d,e[33]=f,e[34]=n.defaultAgentKind,e[35]=I,e[36]=y):y=e[36];let q;e[37]!==b||e[38]!==p||e[39]!==j||e[40]!==v||e[41]!==y?(q=t.jsxs("div",{className:b,role:p,"aria-label":j,children:[v,y]}),e[37]=b,e[38]=p,e[39]=j,e[40]=v,e[41]=y,e[42]=q):q=e[42];let D;e[43]!==l||e[44]!==a?(D=z=>{!l&&a&&r(a),x(z.target.value)},e[43]=l,e[44]=a,e[45]=D):D=e[45];const _=a?`Describe the task for ${a.name}`:"Pick a project, then describe the task";let S;e[46]!==o||e[47]!==D||e[48]!==_||e[49]!==i?(S=t.jsx(De,{"aria-label":"First message",value:i,onChange:D,onKeyDown:o,placeholder:_,rows:1,className:"max-h-48 min-h-9 flex-1 resize-none rounded-none border-0 bg-transparent px-0 py-2 shadow-none focus-visible:border-transparent focus-visible:ring-0"}),e[46]=o,e[47]=D,e[48]=_,e[49]=i,e[50]=S):S=e[50];let P;e[51]!==a||e[52]!==n.model||e[53]!==m?(P=a&&t.jsx(Ce,{isNewSession:!0,agentKind:ye(a.dirName),onAgentKindChange:m,selectedModel:n.model.selectedModel,onModelChange:n.model.onModelChange,selectedEffort:n.model.selectedEffort,onEffortChange:n.model.onEffortChange}),e[51]=a,e[52]=n.model,e[53]=m,e[54]=P):P=e[54];const $=!u;let M;e[55]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(ls,{"data-icon":"icon"}),e[55]=M):M=e[55];let E;e[56]!==$?(E=t.jsx(H,{type:"submit",size:"icon-xs",disabled:$,"aria-label":"Start session",title:"Start session (Enter)",children:M}),e[56]=$,e[57]=E):E=e[57];let C;e[58]!==P||e[59]!==E?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1 pb-0.5",children:[P,E]}),e[58]=P,e[59]=E,e[60]=C):C=e[60];let R;e[61]!==S||e[62]!==C?(R=t.jsxs("div",{className:"flex items-end gap-2 rounded-xl border bg-popover py-2 pl-4 pr-2 shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",children:[S,C]}),e[61]=S,e[62]=C,e[63]=R):R=e[63];let K;e[64]!==g||e[65]!==R?(K=t.jsx("form",{onSubmit:g,className:"min-w-0",children:R}),e[64]=g,e[65]=R,e[66]=K):K=e[66];let O;return e[67]!==K||e[68]!==N||e[69]!==w||e[70]!==q?(O=t.jsxs("section",{"aria-label":N,className:w,children:[q,K]}),e[67]=K,e[68]=N,e[69]=w,e[70]=q,e[71]=O):O=e[71],O}function he(c,e){return c.cwd&&e.cwd?c.cwd===e.cwd:c.dirName===e.dirName}function hs(c){const e=Y.c(19),{defaultAgentKind:s,onChoose:n,onChooseFolder:l,anyListed:r}=c,[i,x]=W.useState(!1),a=Ae(i),u=r?"ghost":"outline";let h;e[0]!==u?(h=t.jsx(H,{variant:u,size:"xs",className:"rounded-full text-muted-foreground"}),e[0]=u,e[1]=h):h=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(xe,{"data-icon":"inline-start"}),e[2]=d):d=e[2];const f=r?"Other project":"Choose a project";let o;e[3]!==h||e[4]!==f?(o=t.jsxs(Pe,{render:h,children:[d,f]}),e[3]=h,e[4]=f,e[5]=o):o=e[5];let g;e[6]!==n?(g=(j,v)=>{x(!1),n(j,v)},e[6]=n,e[7]=g):g=e[7];let m;e[8]!==l?(m=j=>{x(!1),l(j)},e[8]=l,e[9]=m):m=e[9];let b;e[10]!==s||e[11]!==a||e[12]!==g||e[13]!==m?(b=t.jsx(_e,{align:"start",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:t.jsx(Ee,{projects:a,defaultAgentKind:s,onNewSession:g,onNewFolder:m})}),e[10]=s,e[11]=a,e[12]=g,e[13]=m,e[14]=b):b=e[14];let p;return e[15]!==i||e[16]!==o||e[17]!==b?(p=t.jsxs(Me,{open:i,onOpenChange:x,children:[o,b]}),e[15]=i,e[16]=o,e[17]=b,e[18]=p):p=e[18],p}function bs(c){const e={};for(const s of c)s.type==="boolean"?e[s.name]=s.defaultValue===!0:s.defaultValue!==void 0?e[s.name]=String(s.defaultValue):e[s.name]="";return e}function js(c,e){const s={};for(const n of c){const l=e[n.name];if(typeof l=="boolean"){s[n.name]=l;continue}l!==""&&(s[n.name]=n.type==="number"||n.type==="integer"?Number(l):l)}return s}function ws(c,e){return c.every(s=>{if(!s.required)return!0;const n=e[s.name];return typeof n=="boolean"?!0:n===""?!1:s.type==="number"||s.type==="integer"?Number.isFinite(Number(n)):!0})}function Ns(c){const e=Y.c(52),{request:s,responding:n,onAnswer:l}=c;let r;e[0]!==s.fields?(r=()=>bs(s.fields),e[0]=s.fields,e[1]=r):r=e[1];const[i,x]=W.useState(r);let a;e[2]!==s.fields||e[3]!==i?(a=ws(s.fields,i),e[2]=s.fields,e[3]=i,e[4]=a):a=e[4];const u=a,h=s.displayName||s.title||s.serverName;let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=(N,w)=>{x(I=>({...I,[N]:w}))},e[5]=d):d=e[5];const f=d;let o;e[6]!==l||e[7]!==s.requestId?(o=()=>l==null?void 0:l(s.requestId,{action:"decline"}),e[6]=l,e[7]=s.requestId,e[8]=o):o=e[8];const g=o;if(s.mode==="url"&&s.url){const N=s.url;let w;e[9]!==s.message?(w=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[9]=s.message,e[10]=w):w=e[10];let I;e[11]!==N?(I=t.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:N,children:N}),e[11]=N,e[12]=I):I=e[12];let y;e[13]!==g||e[14]!==l||e[15]!==s.requestId||e[16]!==n||e[17]!==N?(y=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>{window.open(N,"_blank","noopener,noreferrer"),l(s.requestId,{action:"accept"})},children:["Open link",t.jsx(rs,{"data-icon":"inline-end"})]}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[13]=g,e[14]=l,e[15]=s.requestId,e[16]=n,e[17]=N,e[18]=y):y=e[18];let q;return e[19]!==h||e[20]!==w||e[21]!==I||e[22]!==y?(q=t.jsxs(be,{server:h,children:[w,I,y]}),e[19]=h,e[20]=w,e[21]=I,e[22]=y,e[23]=q):q=e[23],q}let m;e[24]!==s.message?(m=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[24]=s.message,e[25]=m):m=e[25];let b;if(e[26]!==l||e[27]!==s.fields||e[28]!==s.requestId||e[29]!==n||e[30]!==i){let N;e[32]!==l||e[33]!==s.requestId||e[34]!==n||e[35]!==i?(N=w=>t.jsx(ys,{id:`elicit-${s.requestId}-${w.name}`,field:w,value:i[w.name],disabled:n||!l,onChange:I=>f(w.name,I)},w.name),e[32]=l,e[33]=s.requestId,e[34]=n,e[35]=i,e[36]=N):N=e[36],b=s.fields.map(N),e[26]=l,e[27]=s.fields,e[28]=s.requestId,e[29]=n,e[30]=i,e[31]=b}else b=e[31];let p;e[37]!==b?(p=t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:b}),e[37]=b,e[38]=p):p=e[38];let j;e[39]!==u||e[40]!==g||e[41]!==l||e[42]!==s.fields||e[43]!==s.requestId||e[44]!==n||e[45]!==i?(j=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx(H,{size:"sm",disabled:n||!u,onClick:()=>l(s.requestId,{action:"accept",content:js(s.fields,i)}),children:"Send"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[39]=u,e[40]=g,e[41]=l,e[42]=s.fields,e[43]=s.requestId,e[44]=n,e[45]=i,e[46]=j):j=e[46];let v;return e[47]!==h||e[48]!==m||e[49]!==p||e[50]!==j?(v=t.jsxs(be,{server:h,children:[m,p,j]}),e[47]=h,e[48]=m,e[49]=p,e[50]=j,e[51]=v):v=e[51],v}function ys(c){const e=Y.c(55),{id:s,field:n,value:l,disabled:r,onChange:i}=c;if(n.type==="boolean"){const g=l===!0;let m;e[0]!==i?(m=v=>i(v===!0),e[0]=i,e[1]=m):m=e[1];let b;e[2]!==r||e[3]!==s||e[4]!==g||e[5]!==m?(b=t.jsx(Re,{id:s,checked:g,disabled:r,onCheckedChange:m}),e[2]=r,e[3]=s,e[4]=g,e[5]=m,e[6]=b):b=e[6];let p;e[7]!==n?(p=t.jsx(ae,{field:n}),e[7]=n,e[8]=p):p=e[8];let j;return e[9]!==s||e[10]!==b||e[11]!==p?(j=t.jsxs(oe,{htmlFor:s,className:"items-start gap-2 font-normal",children:[b,p]}),e[9]=s,e[10]=b,e[11]=p,e[12]=j):j=e[12],j}if(n.type==="enum"){let g;e[13]!==n?(g=t.jsx(ae,{field:n}),e[13]=n,e[14]=g):g=e[14];let m;e[15]!==s||e[16]!==g?(m=t.jsx(oe,{htmlFor:s,children:g}),e[15]=s,e[16]=g,e[17]=m):m=e[17];let b;e[18]!==l?(b=typeof l=="string"&&l?[l]:[],e[18]=l,e[19]=b):b=e[19];let p;e[20]!==i?(p=y=>{y[0]&&i(y[0])},e[20]=i,e[21]=p):p=e[21];const j=n.label;let v;e[22]!==n.options?(v=n.options??[],e[22]=n.options,e[23]=v):v=e[23];let N;if(e[24]!==r||e[25]!==v){let y;e[27]!==r?(y=q=>t.jsx($e,{value:q.value,disabled:r,className:"w-full justify-start px-3",children:q.label},q.value),e[27]=r,e[28]=y):y=e[28],N=v.map(y),e[24]=r,e[25]=v,e[26]=N}else N=e[26];let w;e[29]!==n.label||e[30]!==s||e[31]!==b||e[32]!==p||e[33]!==N?(w=t.jsx(ze,{id:s,value:b,onValueChange:p,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":j,children:N}),e[29]=n.label,e[30]=s,e[31]=b,e[32]=p,e[33]=N,e[34]=w):w=e[34];let I;return e[35]!==m||e[36]!==w?(I=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,w]}),e[35]=m,e[36]=w,e[37]=I):I=e[37],I}let x;e[38]!==n?(x=t.jsx(ae,{field:n}),e[38]=n,e[39]=x):x=e[39];let a;e[40]!==s||e[41]!==x?(a=t.jsx(oe,{htmlFor:s,children:x}),e[40]=s,e[41]=x,e[42]=a):a=e[42];const u=n.type==="string"?"text":"number",h=typeof l=="string"?l:"";let d;e[43]!==i?(d=g=>i(g.target.value),e[43]=i,e[44]=d):d=e[44];let f;e[45]!==r||e[46]!==n.label||e[47]!==s||e[48]!==u||e[49]!==h||e[50]!==d?(f=t.jsx(ue,{id:s,"aria-label":n.label,type:u,value:h,disabled:r,onChange:d}),e[45]=r,e[46]=n.label,e[47]=s,e[48]=u,e[49]=h,e[50]=d,e[51]=f):f=e[51];let o;return e[52]!==a||e[53]!==f?(o=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,f]}),e[52]=a,e[53]=f,e[54]=o):o=e[54],o}function ae(c){const e=Y.c(8),{field:s}=c;let n;e[0]!==s.required?(n=s.required&&t.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=s.required,e[1]=n):n=e[1];let l;e[2]!==s.description?(l=s.description&&t.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:s.description}),e[2]=s.description,e[3]=l):l=e[3];let r;return e[4]!==s.label||e[5]!==n||e[6]!==l?(r=t.jsxs("span",{className:"min-w-0",children:[s.label,n,l]}),e[4]=s.label,e[5]=n,e[6]=l,e[7]=r):r=e[7],r}function be(c){const e=Y.c(8),{server:s,children:n}=c;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(os,{className:"text-info"}),e[0]=l):l=e[0];let r;e[1]!==s?(r=t.jsxs(fe,{children:[s," needs input"]}),e[1]=s,e[2]=r):r=e[2];let i;e[3]!==n?(i=t.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=i):i=e[4];let x;return e[5]!==r||e[6]!==i?(x=t.jsxs(me,{className:"border-info/40 bg-info/5",children:[l,r,i]}),e[5]=r,e[6]=i,e[7]=x):x=e[7],x}function vs(c){const e=Y.c(15),{request:s,responding:n,onChoose:l}=c;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(as,{className:"text-warning"}),i=t.jsx(fe,{children:"The agent declined this request"}),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let x;e[2]!==s.originalModel?(x=t.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[s.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=s.originalModel,e[3]=x):x=e[3];let a;e[4]!==s.guidanceText?(a=s.guidanceText&&t.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:s.guidanceText}),e[4]=s.guidanceText,e[5]=a):a=e[5];let u;e[6]!==l||e[7]!==s.fallbackModel||e[8]!==s.requestId||e[9]!==n?(u=l&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>l(s.requestId,"retry_fallback"),children:["Retry on ",s.fallbackModel]}),t.jsx(H,{variant:"outline",size:"sm",disabled:n,onClick:()=>l(s.requestId,"edit_prompt"),children:"Edit prompt"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:()=>l(s.requestId,"cancelled"),children:"Dismiss"})]}),e[6]=l,e[7]=s.fallbackModel,e[8]=s.requestId,e[9]=n,e[10]=u):u=e[10];let h;return e[11]!==x||e[12]!==a||e[13]!==u?(h=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[r,i,t.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[x,a,u]})]}),e[11]=x,e[12]=a,e[13]=u,e[14]=h):h=e[14],h}function Is(c){const e=Y.c(64),{request:s,input:n,canAnswer:l,onOpen:r}=c;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[x,a]=W.useState(i),{sessionId:u}=s;switch(s.kind){case"permission":{const h=s.request;let d;e[1]!==n.responding||e[2]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[1]=n.responding,e[2]=s.request.requestId,e[3]=d):d=e[3];let f;e[4]!==l||e[5]!==n||e[6]!==u?(f=l?(g,m)=>void n.respond(u,g,m):void 0,e[4]=l,e[5]=n,e[6]=u,e[7]=f):f=e[7];let o;return e[8]!==s.request||e[9]!==d||e[10]!==f?(o=t.jsx(Oe,{request:h,queued:0,responding:d,onRespond:f}),e[8]=s.request,e[9]=d,e[10]=f,e[11]=o):o=e[11],o}case"question":{const h=s.request;let d;e[12]!==n.responding||e[13]!==s.request.toolUseId?(d=n.responding.has(s.request.toolUseId),e[12]=n.responding,e[13]=s.request.toolUseId,e[14]=d):d=e[14];let f;e[15]!==x||e[16]!==s.request.toolUseId?(f=x.has(s.request.toolUseId),e[15]=x,e[16]=s.request.toolUseId,e[17]=f):f=e[17];let o;e[18]!==l||e[19]!==n||e[20]!==u?(o=l?async(m,b)=>{(await n.answerQuestion(u,m,b)).gone&&a(j=>new Set(j).add(m))}:void 0,e[18]=l,e[19]=n,e[20]=u,e[21]=o):o=e[21];let g;return e[22]!==r||e[23]!==s.request||e[24]!==d||e[25]!==f||e[26]!==o?(g=t.jsx(Ke,{request:h,responding:d,gone:f,onAnswer:o,onOpenSession:r}),e[22]=r,e[23]=s.request,e[24]=d,e[25]=f,e[26]=o,e[27]=g):g=e[27],g}case"elicitation":{const h=s.request;let d;e[28]!==n.responding||e[29]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[28]=n.responding,e[29]=s.request.requestId,e[30]=d):d=e[30];let f;e[31]!==l||e[32]!==n||e[33]!==u?(f=l?(g,m)=>void n.answerElicitation(u,g,m):void 0,e[31]=l,e[32]=n,e[33]=u,e[34]=f):f=e[34];let o;return e[35]!==s.request||e[36]!==d||e[37]!==f?(o=t.jsx(Ns,{request:h,responding:d,onAnswer:f}),e[35]=s.request,e[36]=d,e[37]=f,e[38]=o):o=e[38],o}case"dialog":{const h=s.request;let d;e[39]!==n.responding||e[40]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[39]=n.responding,e[40]=s.request.requestId,e[41]=d):d=e[41];let f;e[42]!==l||e[43]!==n||e[44]!==u?(f=l?(g,m)=>void n.answerDialog(u,g,m):void 0,e[42]=l,e[43]=n,e[44]=u,e[45]=f):f=e[45];let o;return e[46]!==s.request||e[47]!==d||e[48]!==f?(o=t.jsx(vs,{request:h,responding:d,onChoose:f}),e[46]=s.request,e[47]=d,e[48]=f,e[49]=o):o=e[49],o}case"plan":case"deferred":{let h;e[50]!==s.kind?(h=s.kind==="plan"?t.jsx(cs,{className:"text-warning"}):t.jsx(ds,{className:"text-warning"}),e[50]=s.kind,e[51]=h):h=e[51];const d=s.kind==="plan"?"A plan is waiting for review":"A permission was deferred";let f;e[52]!==d?(f=t.jsx(fe,{children:d}),e[52]=d,e[53]=f):f=e[53];const o=s.kind==="plan"?"Review it in its session.":"Open the session and resume it to answer.";let g;e[54]!==o?(g=t.jsx("p",{className:"col-start-2 mt-1 text-sm text-muted-foreground",children:o}),e[54]=o,e[55]=g):g=e[55];let m;e[56]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ie,{"data-icon":"inline-end"}),e[56]=m):m=e[56];let b;e[57]!==r?(b=t.jsx("div",{className:"col-start-2 mt-2",children:t.jsxs(H,{size:"xs",onClick:r,children:["Open session",m]})}),e[57]=r,e[58]=b):b=e[58];let p;return e[59]!==h||e[60]!==f||e[61]!==g||e[62]!==b?(p=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[h,f,g,b]}),e[59]=h,e[60]=f,e[61]=g,e[62]=b,e[63]=p):p=e[63],p}}}function qs(c,e,s=()=>!0){const n=new Map(e.map(i=>[i.sessionId,i])),l=i=>{const x=n.get(i);return x?Be(x):Date.now()},r=[];for(const[i,x]of c.permissionsBySession)for(const a of x)r.push({kind:"permission",sessionId:i,since:a.timestamp,request:a});for(const[i,x]of c.questionsBySession)for(const a of x)r.push({kind:"question",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.elicitationsBySession)for(const a of x)r.push({kind:"elicitation",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.dialogsBySession)for(const a of x)r.push({kind:"dialog",sessionId:i,since:a.askedAt,request:a});for(const i of c.awaitingPlan)r.push({kind:"plan",sessionId:i,since:l(i)});for(const i of e)i.agentStatus==="deferred"&&!i.archived&&r.push({kind:"deferred",sessionId:i.sessionId,since:l(i.sessionId)});return r.filter(i=>s(i.sessionId)).sort((i,x)=>i.since-x.since)}function je(c){switch(c.kind){case"permission":return c.request.requestId;case"question":return c.request.toolUseId;case"elicitation":case"dialog":return c.request.requestId;default:return`${c.kind}:${c.sessionId}`}}const ks=7*864e5,we=3,Ss=30,Cs=50;function As(c,e){const s=c.filter(r=>!r.archived&&!(r.teamName&&r.agentName)),{topLevel:n,crewOf:l}=Te(s);return n.map(r=>{const i=l.get(r.sessionId)??[],x=i.length?Le(r,i):r.lastActivityAt||r.lastModified,a=[r,...i].flatMap(u=>(u.pullRequests??[]).map(h=>({pullRequest:h,by:u}))).sort((u,h)=>Date.parse(h.pullRequest.timestamp)-Date.parse(u.pullRequest.timestamp))[0];return{session:r,state:e(r).state,members:i,cells:i.map(u=>e(u).state),counts:i.length?Fe(i,e):null,activityAt:x,...a&&{landed:{number:a.pullRequest.number,title:a.pullRequest.title,url:a.pullRequest.url,by:a.by}}}}).sort((r,i)=>Date.parse(i.activityAt)-Date.parse(r.activityAt))}function Ds(c,e=Date.now()){const s=c.filter(n=>e-Date.parse(n.activityAt)<ks);return(s.length>=we?s:c.slice(0,we)).slice(0,Ss)}function Ps(c,e,s=6){const n=[],l=new Set;for(const r of c){const i=e(r.session);if(!(!i.cwd||l.has(i.cwd))&&(l.add(i.cwd),n.push(i),n.length===s))break}return n}function _s(c,e,s){const n=e.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:c.filter(l=>{const r=s(l).filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase();return n.every(i=>r.includes(i))}).slice(0,Cs)}const Es={working:"bg-success shadow-[0_0_0_1.5px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40"};function Ms(c,e){const s=c.cwd?is(c.cwd):null,n=(s==null?void 0:s.parentPath)??c.cwd,l=s?de(ye(c.dirName),s.parentPath):c.dirName;return{dirName:l,cwd:n,name:e[l]??(n?ve(n):c.projectShortName)}}function Rs(c){const e=c.target instanceof HTMLElement&&c.target.closest("input,textarea,select,[contenteditable=true]");return!c.metaKey&&!c.ctrlKey&&!c.altKey&&!e}function Gs(c){const e=Y.c(81),{onOpenSession:s,onBrowseProjects:n,start:l}=c,r=Qe(),i=Ue(),{names:x,rename:a}=He(),{names:u}=Ve(),h=Ye(),[d,f]=W.useState(""),o=W.useRef(null);let g;e[0]!==r.sessions?(g=r.sessions.filter(Ks),e[0]=r.sessions,e[1]=g):g=e[1];const m=g;let b;e[2]!==m?(b=new Map(m.map(zs)),e[2]=m,e[3]=b):b=e[3];const p=b;let j;e[4]!==i.awaitingDialog||e[5]!==i.awaitingElicitation?(j=new Set([...i.awaitingElicitation,...i.awaitingDialog]),e[4]=i.awaitingDialog,e[5]=i.awaitingElicitation,e[6]=j):j=e[6];let v;e[7]!==i.awaitingPermission||e[8]!==i.awaitingPlan||e[9]!==i.awaitingQuestion||e[10]!==j?(v={awaitingPermission:i.awaitingPermission,awaitingQuestion:i.awaitingQuestion,awaitingPrompt:j,awaitingPlan:i.awaitingPlan},e[7]=i.awaitingPermission,e[8]=i.awaitingPlan,e[9]=i.awaitingQuestion,e[10]=j,e[11]=v):v=e[11];const N=v;let w;e[12]!==r.procBySession||e[13]!==N?(w=Q=>es(Q,r.procBySession,N),e[12]=r.procBySession,e[13]=N,e[14]=w):w=e[14];const I=w;let y;e[15]!==p||e[16]!==h?(y=Q=>{const L=p.get(Q);return h(L==null?void 0:L.access).canInteract},e[15]=p,e[16]=h,e[17]=y):y=e[17];const q=y;let D;e[18]!==q||e[19]!==i||e[20]!==m?(D=qs(i,m,q),e[18]=q,e[19]=i,e[20]=m,e[21]=D):D=e[21];const _=D;let S;e[22]!==p||e[23]!==x?(S=Q=>ss(Q,p,x),e[22]=p,e[23]=x,e[24]=S):S=e[24];const P=S;let $;e[25]!==u?($=Q=>u[Q.dirName]??ts(Q),e[25]=u,e[26]=$):$=e[26];const M=$;let E,C,R;if(e[27]!==P||e[28]!==M||e[29]!==u||e[30]!==d||e[31]!==m||e[32]!==I){E=As(m,I),R=d.trim().length>0?_s(E,d,U=>{var ge;return[P(U.session.sessionId),M(U.session),U.session.gitBranch,U.session.cwd,U.session.lastUserMessage,U.session.firstUserMessage,(ge=U.landed)==null?void 0:ge.title,U.landed&&`#${U.landed.number}`,...U.members.map(ke=>P(ke.sessionId))]}):Ds(E);let L;e[36]!==u?(L=U=>Ms(U,u),e[36]=u,e[37]=L):L=e[37],C=Ps(E,L),e[27]=P,e[28]=M,e[29]=u,e[30]=d,e[31]=m,e[32]=I,e[33]=E,e[34]=C,e[35]=R}else E=e[33],C=e[34],R=e[35];const K=C;let O;e[38]!==p||e[39]!==s?(O=Q=>{const L=p.get(Q);L?s(L.dirName,L.fileName):ns(Q)},e[38]=p,e[39]=s,e[40]=O):O=e[40];const z=O;let F;e[41]!==r.processes?(F=r.processes.filter($s),e[41]=r.processes,e[42]=F):F=e[42];const k=F.length;let T,G;e[43]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const Q=L=>{var U;L.key==="/"&&Rs(L)&&(L.preventDefault(),(U=o.current)==null||U.focus())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},G=[],e[43]=T,e[44]=G):(T=e[43],G=e[44]),W.useEffect(T,G);let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Mission Control"}),e[45]=B):B=e[45];let X;e[46]!==k?(X=k>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[k," ",k===1?"agent":"agents"," running on this machine"]}),e[46]=k,e[47]=X):X=e[47];let J;e[48]!==X?(J=t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[B,X]}),e[48]=X,e[49]=J):J=e[49];let A;e[50]!==K||e[51]!==l?(A=l&&t.jsx(ps,{recent:K,start:l}),e[50]=K,e[51]=l,e[52]=A):A=e[52];let V;e[53]!==J||e[54]!==A?(V=t.jsxs("div",{className:"mx-auto flex w-full max-w-6xl shrink-0 flex-col gap-8 px-6 pt-16 lg:px-10",children:[J,A]}),e[53]=J,e[54]=A,e[55]=V):V=e[55];const re=_.length>0&&"lg:grid lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)]";let ee;e[56]!==re?(ee=Z("mx-auto flex w-full max-w-6xl flex-col gap-8 px-6 pb-10 pt-10 lg:h-full lg:px-10",re),e[56]=re,e[57]=ee):ee=e[57];let se;e[58]!==p||e[59]!==q||e[60]!==i||e[61]!==P||e[62]!==z||e[63]!==_?(se=_.length>0?t.jsx(Os,{queue:_,input:i,byId:p,nameOf:P,onOpen:z,canAnswer:q}):t.jsxs("p",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success/40","aria-hidden":"true"}),"Nothing is waiting on you."]}),e[58]=p,e[59]=q,e[60]=i,e[61]=P,e[62]=z,e[63]=_,e[64]=se):se=e[64];let te;e[65]!==P||e[66]!==n||e[67]!==z||e[68]!==M||e[69]!==d||e[70]!==a||e[71]!==E.length||e[72]!==R?(te=t.jsx(Ls,{sessions:R,total:E.length,query:d,onQueryChange:f,searchRef:o,nameOf:P,projectLabel:M,onOpen:z,onRename:a,onBrowseProjects:n}),e[65]=P,e[66]=n,e[67]=z,e[68]=M,e[69]=d,e[70]=a,e[71]=E.length,e[72]=R,e[73]=te):te=e[73];let ne;e[74]!==ee||e[75]!==se||e[76]!==te?(ne=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto lg:overflow-hidden",children:t.jsxs("div",{className:ee,children:[se,te]})}),e[74]=ee,e[75]=se,e[76]=te,e[77]=ne):ne=e[77];let ie;return e[78]!==V||e[79]!==ne?(ie=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[V,ne]}),e[78]=V,e[79]=ne,e[80]=ie):ie=e[80],ie}function $s(c){return c.sessionId}function zs(c){return[c.sessionId,c]}function Ks(c){return!c.archived}function qe(c){const e=Y.c(9),{title:s,count:n,children:l}=c;let r;e[0]!==s?(r=t.jsx("h2",{className:"text-sm font-medium",children:s}),e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=n!==void 0&&t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n}),e[2]=n,e[3]=i):i=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("span",{className:"flex-1"}),e[4]=x):x=e[4];let a;return e[5]!==l||e[6]!==r||e[7]!==i?(a=t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r,i,x,l]}),e[5]=l,e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function ce(c,e){const s=c==null?void 0:c.crew;return s?e(s.rootId)??s.rootTitle??null:null}const Ne={permission:"asked a permission",question:"asked a question",elicitation:"asked for input",dialog:"needs a choice",plan:"has a plan to review",deferred:"has a deferred permission"};function Os(c){const e=Y.c(71),{queue:s,input:n,byId:l,nameOf:r,onOpen:i,canAnswer:x}=c,[a,u]=W.useState(0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=new Set,e[0]=h):h=e[0];const d=W.useRef(h),f=Math.min(a,s.length-1),o=s[f];let g;if(e[1]!==l||e[2]!==r||e[3]!==o.sessionId){const k=l.get(o.sessionId);g=ce(k,r),e[1]=l,e[2]=r,e[3]=o.sessionId,e[4]=g}else g=e[4];const m=g;let b;e[5]!==f||e[6]!==x||e[7]!==n||e[8]!==i||e[9]!==s.length||e[10]!==o.kind||e[11]!==o.request||e[12]!==o.sessionId?(b=k=>{const T=k.target;if(!(T.closest("input,textarea,select,[contenteditable=true]")||k.metaKey||k.ctrlKey||k.altKey)&&((k.key==="j"||k.key==="n"||k.key==="ArrowDown")&&(k.preventDefault(),u(Math.min(s.length-1,f+1))),(k.key==="k"||k.key==="ArrowUp")&&(k.preventDefault(),u(Math.max(0,f-1))),k.key==="o"&&(k.preventDefault(),i(o.sessionId)),(k.key==="Enter"||k.key==="d")&&T===k.currentTarget&&x(o.sessionId))){if(o.kind!=="permission")return;const G=k.key==="d"||o.request.defaultToNo?"deny":"allow",B=o.request.requestId;if(o.request.availableDecisions&&!o.request.availableDecisions.includes(G)||(k.preventDefault(),d.current.has(B)||n.responding.has(B)))return;d.current.add(B),n.respond(o.sessionId,B,G).finally(()=>d.current.delete(B))}},e[5]=f,e[6]=x,e[7]=n,e[8]=i,e[9]=s.length,e[10]=o.kind,e[11]=o.request,e[12]=o.sessionId,e[13]=b):b=e[13];const p=b;let j;e[14]!==f||e[15]!==s.length?(j=s.length>1&&t.jsxs("span",{className:"flex items-center gap-1 text-xs tabular-nums text-muted-foreground",children:[f+1," of ",s.length,t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:f===0,onClick:()=>u(f-1),children:t.jsx(us,{"data-icon":"inline-start"})}),t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:f===s.length-1,onClick:()=>u(f+1),children:t.jsx(Ie,{"data-icon":"inline-start"})})]}),e[14]=f,e[15]=s.length,e[16]=j):j=e[16];let v;e[17]!==s.length||e[18]!==j?(v=t.jsx(qe,{title:"Needs you",count:s.length,children:j}),e[17]=s.length,e[18]=j,e[19]=v):v=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-warning","aria-hidden":"true"}),e[20]=N):N=e[20];let w;e[21]!==i||e[22]!==o.sessionId?(w=()=>i(o.sessionId),e[21]=i,e[22]=o.sessionId,e[23]=w):w=e[23];let I;e[24]!==r||e[25]!==o.sessionId?(I=r(o.sessionId)??"A session",e[24]=r,e[25]=o.sessionId,e[26]=I):I=e[26];let y;e[27]!==w||e[28]!==I?(y=t.jsx("button",{type:"button",onClick:w,className:"min-w-0 truncate rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[27]=w,e[28]=I,e[29]=y):y=e[29];let q;e[30]!==m?(q=m&&t.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:["· ",m]}),e[30]=m,e[31]=q):q=e[31];let D;e[32]!==o.since?(D=le(new Date(o.since).toISOString()),e[32]=o.since,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsxs("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-warning",children:["waiting ",D]}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==q||e[37]!==_||e[38]!==y?(S=t.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-[13px]",children:[N,y,q,_]}),e[36]=q,e[37]=_,e[38]=y,e[39]=S):S=e[39];const P=Ne[o.kind];let $;e[40]!==P?($=t.jsx("p",{className:"px-0.5 text-xs text-muted-foreground",children:P}),e[40]=P,e[41]=$):$=e[41];let M;e[42]!==o?(M=je(o),e[42]=o,e[43]=M):M=e[43];let E;e[44]!==x||e[45]!==o.sessionId?(E=x(o.sessionId),e[44]=x,e[45]=o.sessionId,e[46]=E):E=e[46];let C;e[47]!==i||e[48]!==o.sessionId?(C=()=>i(o.sessionId),e[47]=i,e[48]=o.sessionId,e[49]=C):C=e[49];let R;e[50]!==n||e[51]!==o||e[52]!==M||e[53]!==E||e[54]!==C?(R=t.jsx(Is,{request:o,input:n,canAnswer:E,onOpen:C},M),e[50]=n,e[51]=o,e[52]=M,e[53]=E,e[54]=C,e[55]=R):R=e[55];let K;e[56]!==S||e[57]!==$||e[58]!==R?(K=t.jsxs("div",{className:"flex flex-col gap-2",children:[S,$,R]}),e[56]=S,e[57]=$,e[58]=R,e[59]=K):K=e[59];let O;e[60]!==f||e[61]!==l||e[62]!==r||e[63]!==s?(O=s.length>1&&t.jsx("ol",{className:"mt-3 flex flex-col","aria-label":"Also waiting",children:s.map((k,T)=>T===f?null:t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>u(T),className:"grid w-full grid-cols-[18px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left text-[12.5px] outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:"text-right text-[11px] tabular-nums text-muted-foreground/80",children:T+1}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsxs("span",{className:"truncate font-medium",children:[r(k.sessionId)??"A session",ce(l.get(k.sessionId),r)&&t.jsxs("span",{className:"font-normal text-muted-foreground",children:[" · ",ce(l.get(k.sessionId),r)]})]}),t.jsx("span",{className:"truncate text-[11.5px] text-muted-foreground",children:Ne[k.kind]})]}),t.jsx("span",{className:"text-[11px] tabular-nums text-warning",children:le(new Date(k.since).toISOString())})]})},je(k)))}),e[60]=f,e[61]=l,e[62]=r,e[63]=s,e[64]=O):O=e[64];let z;e[65]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("p",{className:"mt-2 px-0.5 text-[11px] text-muted-foreground/80",children:"J / K move · Enter answers · D denies · O opens"}),e[65]=z):z=e[65];let F;return e[66]!==p||e[67]!==K||e[68]!==O||e[69]!==v?(F=t.jsxs("section",{"aria-label":"Needs you",tabIndex:0,onKeyDown:p,className:"min-w-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring lg:min-h-0 lg:overflow-y-auto",children:[v,K,O,z]}),e[66]=p,e[67]=K,e[68]=O,e[69]=v,e[70]=F):F=e[70],F}function Ts(c){var e,s;return c.state==="needs-you"||(((e=c.counts)==null?void 0:e.needsYou)??0)>0?pe.attention:c.state==="working"||(((s=c.counts)==null?void 0:s.working)??0)>0?pe.working:null}function Ls(c){const e=Y.c(39),{sessions:s,total:n,query:l,onQueryChange:r,searchRef:i,nameOf:x,projectLabel:a,onOpen:u,onRename:h,onBrowseProjects:d}=c;let f;e[0]!==l?(f=l.trim(),e[0]=l,e[1]=f):f=e[1];const o=f.length>0;let g;e[2]!==r||e[3]!==i?(g=()=>{var S;r(""),(S=i.current)==null||S.focus()},e[2]=r,e[3]=i,e[4]=g):g=e[4];const m=g,b=o?s.length:n;let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e[5]=p):p=e[5];let j;e[6]!==r?(j=S=>r(S.target.value),e[6]=r,e[7]=j):j=e[7];let v;e[8]!==m||e[9]!==i?(v=S=>{var P;S.key==="Escape"&&(S.preventDefault(),m(),(P=i.current)==null||P.blur())},e[8]=m,e[9]=i,e[10]=v):v=e[10];let N;e[11]!==l||e[12]!==i||e[13]!==j||e[14]!==v?(N=t.jsx(ue,{ref:i,type:"search","aria-label":"Search sessions",placeholder:"Search sessions",value:l,onChange:j,onKeyDown:v,className:"h-7 pl-8 pr-7 text-xs [&::-webkit-search-cancel-button]:hidden"}),e[11]=l,e[12]=i,e[13]=j,e[14]=v,e[15]=N):N=e[15];let w;e[16]!==m||e[17]!==o?(w=o?t.jsx("button",{type:"button","aria-label":"Clear search",onClick:m,className:"absolute right-1.5 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(xs,{className:"size-3"})}):t.jsx("kbd",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/70","aria-hidden":"true",children:"/"}),e[16]=m,e[17]=o,e[18]=w):w=e[18];let I;e[19]!==N||e[20]!==w?(I=t.jsxs("div",{className:"relative w-full max-w-64",children:[p,N,w]}),e[19]=N,e[20]=w,e[21]=I):I=e[21];let y;e[22]!==d?(y=d&&t.jsxs(H,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:d,children:[t.jsx(xe,{"data-icon":"inline-start"}),"All projects"]}),e[22]=d,e[23]=y):y=e[23];let q;e[24]!==y||e[25]!==b||e[26]!==I?(q=t.jsxs(qe,{title:"Your sessions",count:b,children:[I,y]}),e[24]=y,e[25]=b,e[26]=I,e[27]=q):q=e[27];let D;e[28]!==x||e[29]!==u||e[30]!==h||e[31]!==a||e[32]!==l||e[33]!==o||e[34]!==s?(D=s.length===0?t.jsx(Ge,{children:t.jsx(Xe,{children:t.jsx(Je,{children:o?`No session matches “${l.trim()}”.`:"Start a session and it shows up here, with every session it starts."})})}):t.jsx("ul",{className:"flex flex-col lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:s.map(S=>t.jsx(Fs,{entry:S,nameOf:x,projectLabel:a,onOpen:u,onRename:h},S.session.sessionId))}),e[28]=x,e[29]=u,e[30]=h,e[31]=a,e[32]=l,e[33]=o,e[34]=s,e[35]=D):D=e[35];let _;return e[36]!==q||e[37]!==D?(_=t.jsxs("section",{"aria-label":"Your sessions",className:"flex min-w-0 flex-col lg:min-h-0 lg:flex-1",children:[q,D]}),e[36]=q,e[37]=D,e[38]=_):_=e[38],_}function Fs(c){const e=Y.c(63),{entry:s,nameOf:n,projectLabel:l,onOpen:r,onRename:i}=c,[x,a]=W.useState(null),{session:u}=s;let h;e[0]!==n||e[1]!==u.sessionId?(h=n(u.sessionId)??"Untitled session",e[0]=n,e[1]=u.sessionId,e[2]=h):h=e[2];const d=h;let f;e[3]!==u?(f=We(u),e[3]=u,e[4]=f):f=e[4];const o=f;let g,m,b;if(e[5]!==x||e[6]!==s||e[7]!==n||e[8]!==r||e[9]!==i||e[10]!==o||e[11]!==l||e[12]!==u||e[13]!==d){const v=Ts(s);let N;e[17]!==x||e[18]!==i||e[19]!==o||e[20]!==u.sessionId||e[21]!==d?(N=()=>{if(x===null)return;const C=x.trim();a(null),C!==d&&i(u.sessionId,C===o?"":C)},e[17]=x,e[18]=i,e[19]=o,e[20]=u.sessionId,e[21]=d,e[22]=N):N=e[22];const w=N;let I;e[23]!==s.counts||e[24]!==u.isActive?(I=s.counts?t.jsxs(t.Fragment,{children:[s.counts.working>0&&t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.working})," working"]}),s.counts.needsYou>0&&t.jsxs("span",{className:"text-warning",children:[t.jsx("span",{className:"font-medium tabular-nums",children:s.counts.needsYou})," need you"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.size})," in crew"]})]}):u.isActive&&t.jsx("span",{children:"working"}),e[23]=s.counts,e[24]=u.isActive,e[25]=I):I=e[25];let y;e[26]!==I?(y=t.jsx("span",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:I}),e[26]=I,e[27]=y):y=e[27];let q;e[28]!==s.landed?(q=s.landed&&t.jsxs(Ze,{variant:"outline",className:"shrink-0",children:["#",s.landed.number]}),e[28]=s.landed,e[29]=q):q=e[29];let D;e[30]!==s.landed||e[31]!==n||e[32]!==u.lastUserMessage?(D=s.landed?`${s.landed.title??"Pull request"} · ${n(s.landed.by.sessionId)??""}`:u.lastUserMessage??"",e[30]=s.landed,e[31]=n,e[32]=u.lastUserMessage,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsx("span",{className:"truncate",children:D}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==_||e[37]!==q?(S=t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[q,_]}),e[36]=_,e[37]=q,e[38]=S):S=e[38];let P;e[39]!==s.activityAt||e[40]!==s.counts?(P=s.counts?`crew active ${le(s.activityAt)}`:le(s.activityAt),e[39]=s.activityAt,e[40]=s.counts,e[41]=P):P=e[41];let $;e[42]!==P?($=t.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:P}),e[42]=P,e[43]=$):$=e[43];let M;e[44]!==S||e[45]!==$||e[46]!==y?(M=t.jsxs(t.Fragment,{children:[y,S,$]}),e[44]=S,e[45]=$,e[46]=y,e[47]=M):M=e[47];const E=M;g="group/row relative border-t border-border/70 first:border-t-0",e[48]!==s.cells||e[49]!==s.members||e[50]!==n||e[51]!==r||e[52]!==d?(m=s.members.length>0&&t.jsx("div",{role:"group","aria-label":`${d} crew`,className:"flex flex-wrap gap-1 px-3 pt-3",children:s.members.map((C,R)=>t.jsx("button",{type:"button","aria-label":`Open ${n(C.sessionId)??"crew member"}`,title:`${n(C.sessionId)}: ${s.cells[R]}`,onClick:()=>r(C.sessionId),className:"flex size-5 items-center justify-center rounded-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx("span",{className:Z("size-2 rounded-[2px]",Es[s.cells[R]])})},C.sessionId))}),e[48]=s.cells,e[49]=s.members,e[50]=n,e[51]=r,e[52]=d,e[53]=m):m=e[53],b=x===null?t.jsxs("button",{type:"button",onClick:()=>r(u.sessionId),className:Z("grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]","outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[13.5px] font-medium",children:d}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(u)})]}),E]}):t.jsxs("div",{className:"grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx(ue,{autoFocus:!0,"aria-label":"Session name",value:x,placeholder:o,onChange:C=>a(C.target.value),onFocus:Bs,onBlur:w,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),w()),C.key==="Escape"&&(C.preventDefault(),a(null))},className:"h-7 max-w-md text-[13.5px] font-medium"}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(u)})]}),E]}),e[5]=x,e[6]=s,e[7]=n,e[8]=r,e[9]=i,e[10]=o,e[11]=l,e[12]=u,e[13]=d,e[14]=g,e[15]=m,e[16]=b}else g=e[14],m=e[15],b=e[16];let p;e[54]!==x||e[55]!==s.members.length||e[56]!==d?(p=x===null&&t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":`Rename ${d}`,title:"Rename",onClick:()=>a(d),className:Z("absolute right-2 text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",s.members.length>0?"top-[42px]":"top-2.5"),children:t.jsx(fs,{"data-icon":"icon"})}),e[54]=x,e[55]=s.members.length,e[56]=d,e[57]=p):p=e[57];let j;return e[58]!==g||e[59]!==m||e[60]!==b||e[61]!==p?(j=t.jsxs("li",{className:g,children:[m,b,p]}),e[58]=g,e[59]=m,e[60]=b,e[61]=p,e[62]=j):j=e[62],j}function Bs(c){return c.target.select()}export{Gs as MissionHome};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-CPTFl4Qh.js";import"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{E as MobileFileChanges};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as ue,r as y,j as t}from"./vendor-react-gGw_S5I_.js";import{C as Z,bf as $e,bF as Q,ce as Xe,bJ as De,cf as et,be as re,B as P,z as Ie,cg as tt,ch as st,ci as Be,cj as Me,ck as He,cl as Ge,cm as Ke,cn as Je,A as se,p as ne,co as nt,Z as Re,cp as We,cq as it,cr as Ye,a9 as lt,aa as at,ad as ot,a7 as rt,ac as ct,ab as dt,a6 as ut,a5 as ht,b0 as Ee,cs as mt,ct as ft,D as pt,h as xt,i as gt,j as jt,k as bt,cu as vt,bR as yt,bS as Ct,bT as Oe,bU as Fe,L as wt,M as St,N as Nt,O as kt,Q as $t}from"./index-CPTFl4Qh.js";import{a as Dt,aD as Rt}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Ze(i){const e=i.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Et(i,e){if(i.length===0&&e.length===0)return 0;if(i.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(i.length,e.length);s+=1){const l=i[s],o=e[s];if(l===void 0)return-1;if(o===void 0)return 1;const a=/^\d+$/.test(l),n=/^\d+$/.test(o);if(a&&n){if(Number(l)!==Number(o))return Number(l)<Number(o)?-1:1;continue}if(a!==n)return a?-1:1;if(l!==o)return l<o?-1:1}return 0}function It(i,e){const s=Ze(i),l=Ze(e);if(!s||!l)return null;for(let o=0;o<3;o+=1)if(s.parts[o]!==l.parts[o])return s.parts[o]<l.parts[o]?-1:1;return Et(s.prerelease,l.prerelease)}function qe(i){const e=ue.c(33),{value:s,onChange:l,projects:o,disabled:a}=i,n=a===void 0?!1:a,u=y.useId();let r;e[0]!==s.projectIds||e[1]!==s.type?(r=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=r):r=e[2];let v;e[3]!==r?(v=new Set(r),e[3]=r,e[4]=v):v=e[4];const f=v;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Xe,{children:"Available in"}),e[5]=g):g=e[5];const k=`${u}-all`,j=s.type==="all";let c;e[6]!==l?(c=m=>l(m?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=l,e[7]=c):c=e[7];let h;e[8]!==n||e[9]!==k||e[10]!==j||e[11]!==c?(h=t.jsx($e,{id:k,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=k,e[10]=j,e[11]=c,e[12]=h):h=e[12];const p=`${u}-all`;let b;e[13]!==p?(b=t.jsx(Q,{htmlFor:p,children:"All projects on this host, including new projects"}),e[13]=p,e[14]=b):b=e[14];let C;e[15]!==b||e[16]!==h?(C=t.jsxs(Z,{orientation:"horizontal",children:[h,b]}),e[15]=b,e[16]=h,e[17]=C):C=e[17];let S;e[18]!==n||e[19]!==u||e[20]!==l||e[21]!==o||e[22]!==f||e[23]!==s.projectIds||e[24]!==s.type?(S=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:o.map(m=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-${m.id}`,checked:f.has(m.id),disabled:n,onCheckedChange:N=>l({type:"projects",projectIds:N?[...s.projectIds,m.id]:s.projectIds.filter(I=>I!==m.id)})}),t.jsx(Q,{htmlFor:`${u}-${m.id}`,children:m.name})]},m.id))}),e[18]=n,e[19]=u,e[20]=l,e[21]=o,e[22]=f,e[23]=s.projectIds,e[24]=s.type,e[25]=S):S=e[25];const D=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let d;e[26]!==D?(d=t.jsx(De,{children:D}),e[26]=D,e[27]=d):d=e[27];let w;return e[28]!==n||e[29]!==C||e[30]!==S||e[31]!==d?(w=t.jsxs(et,{disabled:n,children:[g,C,S,d]}),e[28]=n,e[29]=C,e[30]=S,e[31]=d,e[32]=w):w=e[32],w}function Pt(i){const e=ue.c(69),{client:s,run:l,busy:o}=i,a=y.useId(),[n,u]=y.useState(""),[r,v]=y.useState(""),[f,g]=y.useState(null),[k,j]=y.useState(""),[c,h]=y.useState(!1);let p;e[0]!==s||e[1]!==k||e[2]!==r||e[3]!==n||e[4]!==f||e[5]!==l?(p=Y=>{Y.preventDefault(),l(async()=>{var de;if(!f||f.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((de=globalThis.crypto)!=null&&de.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const M=await f.arrayBuffer(),ce=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",M)),Tt).join("");if(ce!==k.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:r,root:new TextDecoder("utf-8",{fatal:!0}).decode(M),fingerprint:ce}),h(!1),u(""),v(""),j("")})},e[0]=s,e[1]=k,e[2]=r,e[3]=n,e[4]=f,e[5]=l,e[6]=p):p=e[6];const b=`${a}-name`;let C;e[7]!==b?(C=t.jsx(Q,{htmlFor:b,children:"Development publisher"}),e[7]=b,e[8]=C):C=e[8];const S=`${a}-name`;let D;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=Y=>u(Y.target.value),e[9]=D):D=e[9];let d;e[10]!==o||e[11]!==n||e[12]!==S?(d=t.jsx(re,{id:S,value:n,onChange:D,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:o}),e[10]=o,e[11]=n,e[12]=S,e[13]=d):d=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(De,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=w):w=e[14];let m;e[15]!==C||e[16]!==d?(m=t.jsxs(Z,{children:[C,d,w]}),e[15]=C,e[16]=d,e[17]=m):m=e[17];const N=`${a}-label`;let I;e[18]!==N?(I=t.jsx(Q,{htmlFor:N,children:"Display name"}),e[18]=N,e[19]=I):I=e[19];const $=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let R;e[21]!==o||e[22]!==r||e[23]!==$?(R=t.jsx(re,{id:$,value:r,onChange:O,maxLength:100,required:!0,disabled:o}),e[21]=o,e[22]=r,e[23]=$,e[24]=R):R=e[24];let U;e[25]!==I||e[26]!==R?(U=t.jsxs(Z,{children:[I,R]}),e[25]=I,e[26]=R,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(Q,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var M;g(((M=Y.target.files)==null?void 0:M[0])??null),h(!1)},e[30]=G):G=e[30];let T;e[31]!==o||e[32]!==ee?(T=t.jsx(re,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:o}),e[31]=o,e[32]=ee,e[33]=T):T=e[33];let K;e[34]!==z||e[35]!==T?(K=t.jsxs(Z,{children:[z,T]}),e[34]=z,e[35]=T,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(Q,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=Y=>{j(Y.target.value),h(!1)},e[39]=L):L=e[39];let q;e[40]!==o||e[41]!==k||e[42]!==J?(q=t.jsx(re,{id:J,value:k,onChange:L,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:o}),e[40]=o,e[41]=k,e[42]=J,e[43]=q):q=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(De,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=F):F=e[44];let V;e[45]!==_||e[46]!==q?(V=t.jsxs(Z,{children:[_,q,F]}),e[45]=_,e[46]=q,e[47]=V):V=e[47];const x=`${a}-trust`;let E;e[48]!==o||e[49]!==x||e[50]!==c?(E=t.jsx($e,{id:x,checked:c,onCheckedChange:h,disabled:o}),e[48]=o,e[49]=x,e[50]=c,e[51]=E):E=e[51];const W=`${a}-trust`;let B;e[52]!==W?(B=t.jsx(Q,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=B):B=e[53];let X;e[54]!==E||e[55]!==B?(X=t.jsxs(Z,{orientation:"horizontal",children:[E,B]}),e[54]=E,e[55]=B,e[56]=X):X=e[56];const ae=o||!c||!f;let ie;e[57]!==ae?(ie=t.jsx(P,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==V||e[62]!==X||e[63]!==ie||e[64]!==m?(le=t.jsxs(Ie,{children:[m,U,K,V,X,ie]}),e[59]=U,e[60]=K,e[61]=V,e[62]=X,e[63]=ie,e[64]=m,e[65]=le):le=e[65];let oe;return e[66]!==p||e[67]!==le?(oe=t.jsx("form",{onSubmit:p,children:le}),e[66]=p,e[67]=le,e[68]=oe):oe=e[68],oe}function Tt(i){return i.toString(16).padStart(2,"0")}const At={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Ot({client:i,preview:e,activation:s,key:l,onFrame:o,onComplete:a,onError:n}){const u=new AbortController;let r="loading",v,f=0;const g=()=>new Error("The installation check expired. Review the package again to retry.");function k(p){r==="canceled"||r==="finished"||(r="canceled",clearTimeout(v),u.abort(),o(null),n(p))}function j(){r==="canceled"||r==="finished"||(r="finished",clearTimeout(v),a())}async function c(p){if(r==="committing"){r="recovering",clearTimeout(v);try{const b=await i.transactionOutcome(e);if(r!=="recovering")return;b.status==="committed"?(await i.refresh(),r==="recovering"&&j()):k(p)}catch{r==="recovering"&&k(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function h(){if(r==="trial"){if(Date.now()>f){k(g());return}r="committing";try{await i.commit(e,u.signal),r==="committing"&&j()}catch(p){await c(p instanceof Error?p:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const p=await i.payload(e.transactionId,u.signal);if(u.signal.aborted||(e.manifest.entry||await st(p,e.digest),f=await i.beginTrial(e,u.signal),u.signal.aborted))return;const b=f-Date.now();if(b<=0){k(g());return}if(r="trial",v=setTimeout(()=>{r==="committing"?(u.abort(),c(g())):r==="trial"&&k(g())},b),!e.manifest.entry){await h();return}o({key:l,client:i,props:{payload:p,digest:e.digest,activationKey:l,context:At,active:!1,title:"Plugin installation check",execute:async(C,S)=>{if(u.signal.throwIfAborted(),S.throwIfAborted(),C.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{h()},onError:k}})}catch(p){k(p instanceof Error?p:new Error("Plugin trial failed"))}})(),()=>{r="canceled",clearTimeout(v),u.abort()}}function Ft(i){const e=ue.c(22),{client:s,preview:l,activation:o,onComplete:a,onError:n}=i,u=`${o}:trial:${l.transactionId}:${l.digest}:${l.registryRevision}`,[r,v]=y.useState(null);let f;e[0]!==a||e[1]!==n?(f={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=f):f=e[2];const g=y.useRef(f);let k;e[3]!==a||e[4]!==n?(k=()=>{g.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=k):k=e[5],y.useLayoutEffect(k);let j,c;e[6]!==o||e[7]!==s||e[8]!==u||e[9]!==l?(j=()=>Ot({client:s,preview:l,activation:o,key:u,onFrame:v,onComplete:()=>g.current.onComplete(),onError:C=>g.current.onError(C)}),c=[s,l,o,u],e[6]=o,e[7]=s,e[8]=u,e[9]=l,e[10]=j,e[11]=c):(j=e[10],c=e[11]),y.useLayoutEffect(j,c);let h;e[12]!==l.manifest.name?(h=t.jsxs("p",{children:["Checking that ",l.manifest.name," starts correctly…"]}),e[12]=l.manifest.name,e[13]=h):h=e[13];let p;e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==u?(p=o&&(r==null?void 0:r.key)===u&&r.client===s&&t.jsx(tt,{...r.props}),e[14]=o,e[15]=s,e[16]=r,e[17]=u,e[18]=p):p=e[18];let b;return e[19]!==h||e[20]!==p?(b=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[h,p]}),e[19]=h,e[20]=p,e[21]=b):b=e[21],b}function _t({connection:i,resourceId:e,target:s,client:l,disabled:o,save:a}){const n=y.useId(),u=i.definition.resources[e],r=nt(i.definition,e),v=!!u.options&&r.length===0,f=i.selected[e],[g,k]=y.useState(""),[j,c]=y.useState(null),[h,p]=y.useState(!1),[b,C]=y.useState(null),S=y.useRef(null);y.useEffect(()=>()=>{var $;return($=S.current)==null?void 0:$.abort()},[]);const D=r.find($=>!i.selected[$]),d=o||!!D||u.scope==="project"&&!s.projectId,w=y.useCallback(async()=>{var O;(O=S.current)==null||O.abort();const $=new AbortController;S.current=$,p(!0),C(null);try{const R=await l.connectionOptions(s,i.id,e,$.signal);if($.signal.aborted)return;c(R)}catch(R){$.signal.aborted||C(R instanceof Error?R.message:"Unable to load choices")}finally{$.signal.aborted||p(!1)}},[l,s,i.id,e]),m=j===null&&!h&&!b;y.useEffect(()=>{v&&m&&!d&&w()},[v,m,d,w]);const N=f&&!(j!=null&&j.some($=>$.id===f.id))?[f,...j??[]]:j??[],I=t.jsxs(Je,{items:N.map($=>({value:$.id,label:$.label})),value:(f==null?void 0:f.id)??null,disabled:d||h||!j,onValueChange:$=>{$&&$!==(f==null?void 0:f.id)&&a(i.id,"select",{resourceId:e,value:$})},children:[t.jsx(Ke,{id:`${n}-resource`,"aria-invalid":!!b,children:t.jsx(Ge,{placeholder:h?"Loading choices…":`Choose ${u.label}`})}),t.jsx(Be,{children:t.jsx(Me,{children:N.map($=>t.jsx(He,{value:$.id,children:$.label},$.id))})})]});return t.jsxs(Z,{"data-disabled":d,"data-invalid":!!b,children:[t.jsx(Q,{htmlFor:`${n}-resource`,children:u.label}),t.jsx(De,{children:u.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),f&&!v&&t.jsxs("p",{className:"text-sm",children:["Selected: ",f.label]}),D&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",i.definition.resources[D].label," first."]}),u.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),u.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[v?I:t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{w()},children:h?"Loading choices…":j?"Refresh choices":"Browse choices"}),!v&&j&&I,v&&b&&t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{w()},children:"Try again"}),(j==null?void 0:j.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),u.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:$=>{$.preventDefault(),a(i.id,"select",{resourceId:e,value:g.trim()})},children:[t.jsx(re,{id:u.options?`${n}-input`:`${n}-resource`,"aria-label":`${u.label} ${u.input.urls?"URL or ID":"ID"}`,value:g,onChange:$=>k($.target.value),maxLength:2048,disabled:d,autoComplete:"off",spellCheck:!1,placeholder:u.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(P,{type:"submit",size:"sm",variant:"outline",disabled:d||!g.trim(),children:"Validate and select"})]}),f&&t.jsxs(P,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:()=>{a(i.id,"select",{resourceId:e,value:null})},children:["Clear ",u.label]}),b&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:b})]})}function zt(i){const e=ue.c(45),{connection:s,target:l,client:o,disabled:a,save:n}=i,u=y.useId(),[r,v]=y.useState(""),[f,g]=y.useState(!1),k=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let h;e[2]!==c?(h=t.jsx(Re,{variant:"outline",children:c}),e[2]=c,e[3]=h):h=e[3];let p;e[4]!==j||e[5]!==h?(p=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,h]}),e[4]=j,e[5]=h,e[6]=p):p=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=b):b=e[7];let C;e[8]!==s.definition.operations?(C=new Set(Object.values(s.definition.operations).map(Lt)),e[8]=s.definition.operations,e[9]=C):C=e[9];let S;e[10]!==C?(S=[...C],e[10]=C,e[11]=S):S=e[11];const D=S.join(", ");let d;e[12]!==D?(d=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",D]}),e[12]=D,e[13]=d):d=e[13];let w;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==u||e[20]!==f||e[21]!==n?(w=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-replace`,checked:f,onCheckedChange:g,disabled:a}),t.jsx(Q,{htmlFor:`${u}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:f})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=u,e[20]=f,e[21]=n,e[22]=w):w=e[22];let m;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==u||e[29]!==n||e[30]!==r?(m=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:$=>{$.preventDefault();const O=r.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Ie,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(Q,{htmlFor:`${u}-secret`,children:s.definition.secret.label}),t.jsx(re,{id:`${u}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:r,onChange:$=>v($.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(P,{type:"submit",size:"sm",disabled:a||!r.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=u,e[29]=n,e[30]=r,e[31]=m):m=e[31];let N;e[32]!==o||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==l?(N=s.status!=="disconnected"&&t.jsx(Ie,{children:Object.keys(s.definition.resources).map($=>t.jsx(_t,{connection:s,resourceId:$,target:l,client:o,disabled:a,save:n},$))}),e[32]=o,e[33]=s,e[34]=a,e[35]=n,e[36]=l,e[37]=N):N=e[37];let I;return e[38]!==s.label||e[39]!==d||e[40]!==w||e[41]!==m||e[42]!==N||e[43]!==p?(I=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":k,children:[p,b,d,w,m,N]}),e[38]=s.label,e[39]=d,e[40]=w,e[41]=m,e[42]=N,e[43]=p,e[44]=I):I=e[44],I}function Lt(i){return i.origin}function Vt({client:i,target:e}){const[s,l]=y.useState(null),[o,a]=y.useState(null),[n,u]=y.useState(!1),r=y.useRef(null),v=y.useRef(!1),f=e.pluginId,g=e.projectId;y.useEffect(()=>{const j=new AbortController;return r.current=j,i.connections({pluginId:f,projectId:g},j.signal).then(c=>{j.signal.aborted||l(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),r.current=null}},[i,f,g]);async function k(j,c,h){if(!s||v.current||!r.current||r.current.signal.aborted)return;v.current=!0;const p=r.current.signal;u(!0),a(null);try{const b=await i.changeConnection(e,j,c,h,s.revision,p);p.aborted||l(b)}catch(b){p.aborted||a(b instanceof Error?b.message:"Connection change failed")}finally{v.current=!1,p.aborted||u(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[o&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:o})}),!s&&!o&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(zt,{connection:j,target:e,client:i,disabled:n,save:k},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function Ut(i){const e=ue.c(32),{client:s,status:l,pluginId:o,initialProjectId:a}=i,[n,u]=y.useState(a),r=y.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let f;e[1]!==l.projects?(f=[v,...l.projects.map(Bt)],e[1]=l.projects,e[2]=f):f=e[2];const g=f;let k;e[3]!==r?(k=t.jsx(Q,{htmlFor:r,children:"Project settings"}),e[3]=r,e[4]=k):k=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=I=>u(I||null),e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ge,{}),e[6]=h):h=e[6];let p;e[7]!==r?(p=t.jsx(Ke,{id:r,children:h}),e[7]=r,e[8]=p):p=e[8];let b;e[9]!==g?(b=t.jsx(Be,{children:t.jsx(Me,{children:g.map(qt)})}),e[9]=g,e[10]=b):b=e[10];let C;e[11]!==g||e[12]!==j||e[13]!==p||e[14]!==b?(C=t.jsxs(Je,{items:g,value:j,onValueChange:c,children:[p,b]}),e[11]=g,e[12]=j,e[13]=p,e[14]=b,e[15]=C):C=e[15];let S;e[16]!==l.host.name?(S=t.jsxs(De,{children:["Connection credentials belong to ",l.host.name,". Project resources stay within the project you choose."]}),e[16]=l.host.name,e[17]=S):S=e[17];let D;e[18]!==S||e[19]!==k||e[20]!==C?(D=t.jsxs(Z,{children:[k,C,S]}),e[18]=S,e[19]=k,e[20]=C,e[21]=D):D=e[21];const d=`${o}:${n??"host"}:${l.connectionRevision??0}`;let w;e[22]!==o||e[23]!==n?(w={pluginId:o,projectId:n},e[22]=o,e[23]=n,e[24]=w):w=e[24];let m;e[25]!==s||e[26]!==d||e[27]!==w?(m=t.jsx(Vt,{client:s,target:w},d),e[25]=s,e[26]=d,e[27]=w,e[28]=m):m=e[28];let N;return e[29]!==D||e[30]!==m?(N=t.jsxs("div",{className:"flex flex-col gap-4",children:[D,m]}),e[29]=D,e[30]=m,e[31]=N):N=e[31],N}function qt(i){return t.jsx(He,{value:i.value,children:i.label},i.value)}function Bt(i){return{value:i.id,label:i.name}}function Mt({client:i,pluginId:e,projectId:s,definition:l}){var D;const o=y.useId(),[a,n]=y.useState(null),[u,r]=y.useState({}),[v,f]=y.useState(null),[g,k]=y.useState(!1),[j,c]=y.useState(""),[h,p]=y.useState(0),b=y.useRef(null),C=l.scope==="project"&&!s;y.useEffect(()=>{var w;if((w=b.current)==null||w.abort(),b.current=null,k(!1),n(null),f(null),c(""),C)return;const d=new AbortController;return i.settings({pluginId:e,projectId:s},d.signal).then(m=>{d.signal.aborted||(n(m),r(We(l,m.values)))}).catch(m=>{d.signal.aborted||f(m instanceof Error?m.message:"Unable to load plugin settings")}),()=>{var m;d.abort(),(m=b.current)==null||m.abort()}},[i,e,s,l,C,h]);async function S(d){if(d.preventDefault(),!a||g)return;let w;try{w=We(l,u)}catch{f("Check the setting values and their limits.");return}k(!0),f(null),c("");const m=new AbortController;b.current=m;try{const N=await i.saveSettings({pluginId:e,projectId:s},w,a.revision,m.signal);m.signal.aborted||(n(N),r(N.values),c("Settings saved."))}catch(N){m.signal.aborted||f(N instanceof Error?N.message:"Unable to save plugin settings")}finally{b.current===m&&(b.current=null,m.signal.aborted||k(!1))}}return C?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a project to edit this plugin's settings."}):t.jsx("form",{onSubmit:d=>{S(d)},children:t.jsxs(Ie,{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:l.scope==="project"?"Settings for this project.":"Settings for your account on this host."}),a&&l.fields.map(d=>{const w=`${o}-${d.id}`,m=N=>{r(I=>({...I,[d.id]:N})),c("")};return t.jsxs(Z,{"data-disabled":g,children:[t.jsx(Q,{htmlFor:w,children:d.label}),d.description&&t.jsx(De,{children:d.description}),d.type==="boolean"?t.jsx($e,{id:w,checked:u[d.id]===!0,disabled:g,onCheckedChange:N=>m(N===!0)}):d.type==="select"?t.jsxs(Je,{value:String(u[d.id]),items:d.options,disabled:g,onValueChange:N=>{N!==null&&m(String(N))},children:[t.jsx(Ke,{id:w,children:t.jsx(Ge,{})}),t.jsx(Be,{children:t.jsx(Me,{children:d.options.map(N=>t.jsx(He,{value:N.value,children:N.label},N.value))})})]}):t.jsx(re,{id:w,disabled:g,type:d.type==="number"?"number":"text",value:String(u[d.id]??""),...d.type==="number"?{min:d.min,max:d.max,step:d.step??"any"}:{maxLength:d.maxLength},onChange:N=>m(d.type==="number"?N.target.value===""?"":Number(N.target.value):N.target.value)})]},d.id)}),!!((D=a==null?void 0:a.adjustedFields)!=null&&D.length)&&t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Some saved values no longer match this version. Defaults are shown for ",a.adjustedFields.join(", "),"; save to apply them."]}),!a&&!v&&t.jsx("p",{role:"status",children:"Loading settings…"}),v&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v}),j&&t.jsx("p",{role:"status",className:"text-sm",children:j}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(P,{type:"submit",disabled:!a||g,children:g?"Saving…":"Save settings"}),t.jsx(P,{type:"button",variant:"outline",disabled:g,onClick:()=>p(d=>d+1),children:"Reload settings"})]})]})})}function Ht(i){var ie;const e=ue.c(175),{plugin:s,status:l,client:o,busy:a,run:n,onPreview:u,onConnections:r,onUpdate:v}=i,f=y.useId(),[g,k]=y.useState(s.scope),[j,c]=y.useState(!1),[h,p]=y.useState(!1);let b,C,S,D,d,w,m,N,I,$,O,R;if(e[0]!==a||e[1]!==o||e[2]!==r||e[3]!==u||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==g||e[8]!==l.host.name||e[9]!==l.projects||e[10]!==l.runtime||e[11]!==l.store){const le=it(),oe=Ye(s.manifest,le,l.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==o||e[25]!==s.id||e[26]!==n||e[27]!==l.store?(Y=(A,Ae)=>n(()=>o.changeInstalled(s.id,A,Ae,l.store.revision)),e[24]=o,e[25]=s.id,e[26]=n,e[27]=l.store,e[28]=Y):Y=e[28];const M=Y,ce=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let de;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==l.store?(de=s.lastError&&((ie=l.store.availableSeeds)==null?void 0:ie.find(A=>A.manifest.id===s.id&&A.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=l.store,e[33]=de):de=e[33];const _e=de;$="flex flex-col gap-3 rounded-lg border p-4";let he;e[34]!==s.manifest.name?(he=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=he):he=e[35];let me;e[36]!==s.id||e[37]!==s.manifest.version?(me=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=me):me=e[38];let fe;e[39]!==he||e[40]!==me?(fe=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[he,me]}),e[39]=he,e[40]=me,e[41]=fe):fe=e[41];const ze=ce==="Enabled"?"secondary":"outline";let pe;e[42]!==ce||e[43]!==ze?(pe=t.jsx(Re,{variant:ze,children:ce}),e[42]=ce,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==fe||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[fe,pe]}),e[45]=fe,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(R=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=R):R=e[49],C=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(A=>t.jsxs("p",{children:[A.side==="client"?"This client":A.side==="host"?l.host.name:"This package",": ",A.name," requires ",A.required,"; available ",A.actual??"none","."]},`${A.side}:${A.code}:${A.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==M||e[51]!==s.enabled?(xe=()=>M("enabled",{enabled:!s.enabled}),e[50]=M,e[51]=s.enabled,e[52]=xe):xe=e[52];const Le=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Le?(ge=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Le}),e[53]=a,e[54]=xe,e[55]=Le,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==r||e[59]!==s.id||e[60]!==s.manifest.contributes||e[61]!==s.manifest.permissions.connections.length?(je=(s.manifest.permissions.connections.length>0||s.manifest.contributes.settings)&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>r(s.id),children:s.manifest.contributes.settings?"Settings":"Connections"}),e[57]=a,e[58]=r,e[59]=s.id,e[60]=s.manifest.contributes,e[61]=s.manifest.permissions.connections.length,e[62]=je):je=e[62];const Ve=a||s.pinned;let be;e[63]!==v||e[64]!==s?(be=()=>v(s),e[63]=v,e[64]=s,e[65]=be):be=e[65];let ve;e[66]!==Ve||e[67]!==be?(ve=t.jsx(P,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[66]=Ve,e[67]=be,e[68]=ve):ve=e[68];let ye;e[69]!==a||e[70]!==o||e[71]!==u||e[72]!==s.id||e[73]!==s.scope||e[74]!==_e||e[75]!==n?(ye=_e&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>u(await o.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[69]=a,e[70]=o,e[71]=u,e[72]=s.id,e[73]=s.scope,e[74]=_e,e[75]=n,e[76]=ye):ye=e[76];let Ce;e[77]!==M||e[78]!==s.pinned?(Ce=()=>M("pin",{pinned:!s.pinned}),e[77]=M,e[78]=s.pinned,e[79]=Ce):Ce=e[79];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[80]!==a||e[81]!==Ce||e[82]!==Ue?(we=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[80]=a,e[81]=Ce,e[82]=Ue,e[83]=we):we=e[83];let Pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{p(!1),c(!0)},e[84]=Pe):Pe=e[84];let Se;e[85]!==a?(Se=t.jsx(P,{size:"sm",variant:"ghost",disabled:a,onClick:Pe,children:"Uninstall"}),e[85]=a,e[86]=Se):Se=e[86],e[87]!==ge||e[88]!==je||e[89]!==ve||e[90]!==ye||e[91]!==we||e[92]!==Se?(S=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Se]}),e[87]=ge,e[88]=je,e[89]=ve,e[90]=ye,e[91]=we,e[92]=Se,e[93]=S):S=e[93],e[94]!==s.pinned?(D=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[94]=s.pinned,e[95]=D):D=e[95],N="text-sm",e[96]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[96]=I):I=e[96],b="flex flex-col gap-4 pt-4",e[97]!==a||e[98]!==g||e[99]!==l.projects?(d=t.jsx(qe,{value:g,onChange:k,projects:l.projects,disabled:a}),e[97]=a,e[98]=g,e[99]=l.projects,e[100]=d):d=e[100];let Ne;e[101]!==a||e[102]!==s.scope||e[103]!==g?(Ne=a||JSON.stringify(g)===JSON.stringify(s.scope),e[101]=a,e[102]=s.scope,e[103]=g,e[104]=Ne):Ne=e[104];let ke;e[105]!==M||e[106]!==g?(ke=()=>M("scope",{scope:g}),e[105]=M,e[106]=g,e[107]=ke):ke=e[107],e[108]!==l.host.name||e[109]!==Ne||e[110]!==ke?(w=t.jsxs(P,{size:"sm",variant:"outline",disabled:Ne,onClick:ke,children:["Save projects on ",l.host.name]}),e[108]=l.host.name,e[109]=Ne,e[110]=ke,e[111]=w):w=e[111];let Te;e[112]!==s.selectedDigest?(Te=A=>A.digest!==s.selectedDigest,e[112]=s.selectedDigest,e[113]=Te):Te=e[113],m=s.versions.filter(Te).map(A=>{const Ae=!A.unavailableReason&&Ye(A.manifest,le,l.runtime,{allowPrerelease:A.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(P,{size:"sm",variant:"outline",disabled:a||s.pinned||!Ae,onClick:()=>n(async()=>u({...await o.rollback(s.id,A.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",A.manifest.version]}),!Ae&&t.jsx("p",{className:"text-xs text-muted-foreground",children:A.unavailableReason??"This version is incompatible with the connected host or client."})]},A.digest)}),e[0]=a,e[1]=o,e[2]=r,e[3]=u,e[4]=v,e[5]=s,e[6]=n,e[7]=g,e[8]=l.host.name,e[9]=l.projects,e[10]=l.runtime,e[11]=l.store,e[12]=b,e[13]=C,e[14]=S,e[15]=D,e[16]=d,e[17]=w,e[18]=m,e[19]=N,e[20]=I,e[21]=$,e[22]=O,e[23]=R}else b=e[12],C=e[13],S=e[14],D=e[15],d=e[16],w=e[17],m=e[18],N=e[19],I=e[20],$=e[21],O=e[22],R=e[23];let U;e[114]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[114]=U):U=e[114];let H;e[115]!==b||e[116]!==d||e[117]!==w||e[118]!==m?(H=t.jsxs("div",{className:b,children:[d,w,m,U]}),e[115]=b,e[116]=d,e[117]=w,e[118]=m,e[119]=H):H=e[119];let z;e[120]!==H||e[121]!==N||e[122]!==I?(z=t.jsxs("details",{className:N,children:[I,H]}),e[120]=H,e[121]=N,e[122]=I,e[123]=z):z=e[123];let ee;e[124]!==s.manifest.name?(ee=t.jsxs(lt,{children:["Uninstall ",s.manifest.name,"?"]}),e[124]=s.manifest.name,e[125]=ee):ee=e[125];let G;e[126]!==l.host.name?(G=t.jsxs(at,{children:["This removes the plugin from ",l.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[126]=l.host.name,e[127]=G):G=e[127];let T;e[128]!==ee||e[129]!==G?(T=t.jsxs(rt,{children:[ee,G]}),e[128]=ee,e[129]=G,e[130]=T):T=e[130];const K=`${f}-delete`,te=a||l.connectionRevision===void 0;let _;e[131]!==h||e[132]!==K||e[133]!==te?(_=t.jsx($e,{id:K,checked:h,onCheckedChange:p,disabled:te}),e[131]=h,e[132]=K,e[133]=te,e[134]=_):_=e[134];const J=`${f}-delete`;let L;e[135]!==J?(L=t.jsx(Q,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[135]=J,e[136]=L):L=e[136];let q;e[137]!==_||e[138]!==L?(q=t.jsxs(Z,{orientation:"horizontal",children:[_,L]}),e[137]=_,e[138]=L,e[139]=q):q=e[139];let F;e[140]!==h?(F=h&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[140]=h,e[141]=F):F=e[141];let V;e[142]!==a?(V=t.jsx(ct,{disabled:a,children:"Cancel"}),e[142]=a,e[143]=V):V=e[143];let x;e[144]!==o||e[145]!==h||e[146]!==s.id||e[147]!==n||e[148]!==l.connectionRevision||e[149]!==l.store?(x=()=>{c(!1),n(()=>o.changeInstalled(s.id,"uninstall",h?{deleteData:!0,expectedConnectionRevision:l.connectionRevision}:{deleteData:!1},l.store.revision))},e[144]=o,e[145]=h,e[146]=s.id,e[147]=n,e[148]=l.connectionRevision,e[149]=l.store,e[150]=x):x=e[150];let E;e[151]!==a||e[152]!==l.host.name||e[153]!==x?(E=t.jsxs(ot,{variant:"destructive",disabled:a,onClick:x,children:["Uninstall from ",l.host.name]}),e[151]=a,e[152]=l.host.name,e[153]=x,e[154]=E):E=e[154];let W;e[155]!==V||e[156]!==E?(W=t.jsxs(dt,{children:[V,E]}),e[155]=V,e[156]=E,e[157]=W):W=e[157];let B;e[158]!==T||e[159]!==q||e[160]!==F||e[161]!==W?(B=t.jsxs(ut,{children:[T,q,F,W]}),e[158]=T,e[159]=q,e[160]=F,e[161]=W,e[162]=B):B=e[162];let X;e[163]!==j||e[164]!==B?(X=t.jsx(ht,{open:j,onOpenChange:c,children:B}),e[163]=j,e[164]=B,e[165]=X):X=e[165];let ae;return e[166]!==C||e[167]!==S||e[168]!==D||e[169]!==z||e[170]!==X||e[171]!==$||e[172]!==O||e[173]!==R?(ae=t.jsxs("article",{className:$,children:[O,R,C,S,D,z,X]}),e[166]=C,e[167]=S,e[168]=D,e[169]=z,e[170]=X,e[171]=$,e[172]=O,e[173]=R,e[174]=ae):ae=e[174],ae}const Gt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Kt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function Jt(i,e){return e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":`Read ${Gt[i]} ${Kt[e]} using this host's signed-in CLI`}function Qe(i){const e=i.permissions;return[...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(()=>"Append text to your draft message"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...i.contributes.settings?[`Add ${i.contributes.settings.fields.length} ${i.contributes.settings.scope} settings fields`]:[],...(i.contributes.skills??[]).map(s=>`Provide agent instructions: ${s.title}`),...(i.contributes.chatBlocks??[]).map(s=>`Render ${s.title} cards and read the text inside their declared chat blocks`),...(i.contributes.sessionActions??[]).map(s=>`Add a ${s.title} button that sends an agent request when clicked`),...e.connections.flatMap(s=>s.operations.map(l=>`Use connection ${s.id}: ${l}`)),...e.integrations.flatMap(s=>s.operations.map(l=>Jt(s.id,l)))]}function Wt(i){var j;const e=ue.c(32),{preview:s}=i;let l,o,a,n,u,r;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=Qe(s.manifest),h=s.previousManifest?Qe(s.previousManifest):null,p=h?c.filter(S=>!h.includes(S)):[],b=h?h.filter(S=>!c.includes(S)):[],C=s.previousConnectionDefinitions?s.connectionDefinitions.filter(S=>{var d;const D=(d=s.previousConnectionDefinitions)==null?void 0:d.find(w=>w.id===S.id);return!D||JSON.stringify(D)!==JSON.stringify(S)}):[];l="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(o=s.oldVersion&&t.jsxs(se,{children:[t.jsx(Ee,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=o):o=e[14],a=h&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),p.length===0&&b.length===0&&C.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),p.map(is),b.map(ns),C.map(ss)]}),n=s.oldVersion&&!h&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=u):u=e[15],r=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(ts)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=l,e[7]=o,e[8]=a,e[9]=n,e[10]=u,e[11]=r}else l=e[6],o=e[7],a=e[8],n=e[9],u=e[10],r=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Yt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let f;e[18]!==s.incompatibleClients?(f=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=f):f=e[19];let g;e[20]!==s.digest?(g=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=g):g=e[21];let k;return e[22]!==l||e[23]!==o||e[24]!==a||e[25]!==n||e[26]!==u||e[27]!==r||e[28]!==v||e[29]!==f||e[30]!==g?(k=t.jsxs("div",{className:l,children:[o,a,n,u,r,v,f,g]}),e[22]=l,e[23]=o,e[24]=a,e[25]=n,e[26]=u,e[27]=r,e[28]=v,e[29]=f,e[30]=g,e[31]=k):k=e[31],k}function Yt(i){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:i.label}),t.jsxs("p",{children:["Access to ",Object.values(i.resources).map(es).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(i.operations).map(Xt))].join(", ")]}),Object.entries(i.operations).filter(Qt).map(Zt)]},i.id)}function Zt(i){const[e,s]=i;return t.jsxs("p",{className:"text-muted-foreground",children:[s.method," ",e,s.method==="POST"?" — sends supplied data to this service":"",s.response?" · receives audio":""]},e)}function Qt(i){const[,e]=i;return e.audience==="panel"}function Xt(i){return i.origin}function es(i){return i.label}function ts(i){return t.jsx("li",{children:i},i)}function ss(i){return t.jsxs("p",{children:["Changed connection: ",i.label,". Review its destinations and access below."]},i.id)}function ns(i){return t.jsxs("p",{children:["Removed: ",i]},`remove:${i}`)}function is(i){return t.jsxs("p",{children:["Added: ",i]},`add:${i}`)}function ds({client:i,state:e,currentPath:s,onClose:l,initialPluginId:o}){var V;const a=y.useId(),n=e.status,u=mt(),r=(n==null?void 0:n.safeMode)||u,{project:v,resolving:f}=ft({client:i,status:n,activation:e.activation,projectPath:s}),[g,k]=y.useState(null),j=g??{type:"projects",projectIds:v?[v.id]:[]},[c,h]=y.useState(null),[p,b]=y.useState({activation:"",hostName:""}),[C,S]=y.useState(!1),[D,d]=y.useState(!1),[w,m]=y.useState(null),[N,I]=y.useState(null),[$,O]=y.useState("installed"),[R,U]=y.useState(null),[H,z]=y.useState(null),[ee,G]=y.useState(o),T=n==null?void 0:n.store.plugins.find(x=>x.id===ee),K=y.useRef(!1),te=!!(n!=null&&n.store.available)&&p.activation===e.activation;function _(x){b({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),h(x)}y.useEffect(()=>{!c||te&&!(r&&C)||(S(!1),h(null),m("The host connection or plugin execution state changed. Review the package again before installing."),i.cancel(c).catch(()=>{}))},[i,c,te,r,C]),y.useEffect(()=>()=>{c&&i.cancel(c).catch(()=>{})},[i,c]);async function J(x){if(!K.current){K.current=!0,d(!0),m(null),I(null);try{await x()}catch(E){m(E instanceof Error?E.message:"Plugin action failed")}finally{K.current=!1,d(!1)}}}function L(){const x=c;S(!1),h(null),x&&i.cancel(x).catch(()=>{})}async function q(){if(!H||!R&&!g&&f)return;const x=await i.stage(H,(R==null?void 0:R.scope)??j);if(R&&x.manifest.id!==R.id)throw await i.cancel(x),new Error(`Choose a package for ${R.manifest.name} (${R.id}).`);_(x)}const F=D||C||!(n!=null&&n.store.available);return t.jsx(pt,{open:!0,onOpenChange:x=>{!x&&!D&&!C&&(L(),l())},children:t.jsxs(xt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!D&&!C,children:[t.jsxs(gt,{children:[t.jsx(jt,{children:"Plugins"}),t.jsx(bt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||w||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:n!=null&&n.store.available&&!w&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:w??e.error??(n==null?void 0:n.store.error)})]}),N&&t.jsx(se,{children:t.jsx(ne,{children:N})}),r&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(P,{size:"sm",variant:"outline",disabled:D||C||(n==null?void 0:n.safeMode),onClick:()=>vt(!u),children:u?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(P,{variant:"outline",disabled:D,onClick:()=>{J(()=>i.refresh())},children:[t.jsx(Dt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&T&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h2",{className:"font-medium",children:T.manifest.name}),t.jsx(P,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),T.manifest.permissions.connections.length>0&&T.manifest.contributes.settings&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect the service first. Its settings below take effect once it is connected."}),T.manifest.permissions.connections.length>0&&t.jsx(Ut,{client:i,status:n,pluginId:T.id,initialProjectId:(v==null?void 0:v.id)??null},`${T.id}:${n.store.revision}`),T.manifest.contributes.settings&&t.jsx(Mt,{client:i,pluginId:T.id,projectId:(v==null?void 0:v.id)??null,definition:T.manifest.contributes.settings},`settings:${T.id}:${n.store.revision}`)]}),n&&!T&&!c&&t.jsxs(yt,{value:$,onValueChange:x=>{O(String(x)),U(null),z(null)},children:[t.jsxs(Ct,{className:"h-auto flex-wrap",children:[t.jsx(Oe,{value:"installed",children:"Installed"}),t.jsx(Oe,{value:"browse",children:"Browse"}),t.jsx(Oe,{value:"install",children:"Install from file"}),t.jsx(Oe,{value:"publishers",children:"Publishers"})]}),t.jsx(Fe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(x=>t.jsx(Ht,{plugin:x,status:n,client:i,busy:F,run:E=>{J(E)},onPreview:_,onConnections:G,onUpdate:E=>{U(E),z(null),O("install")}},`${x.id}:${n.store.revision}`)):t.jsx(wt,{children:t.jsxs(St,{children:[t.jsx(Nt,{variant:"icon",children:t.jsx(Rt,{})}),t.jsx(kt,{children:"No installed plugins"}),t.jsx($t,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Fe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(qe,{value:j,onChange:k,projects:n.projects,disabled:F}),(n.store.availableSeeds??[]).map(x=>{const E=n.store.plugins.find(B=>B.id===x.manifest.id),W=E&&It(x.manifest.version,E.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:x.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.manifest.version," · ",x.manifest.publisher]})]}),W?t.jsx(P,{size:"sm",disabled:F||E.pinned,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,E.scope)))},children:E.pinned?"Pinned to installed version":"Review update"}):E?t.jsx(Re,{variant:"outline",children:"Installed"}):t.jsx(P,{size:"sm",disabled:F||!g&&f,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,j)))},children:"Review installation"})]},x.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Fe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:x=>{x.preventDefault(),J(q)},children:t.jsxs(Ie,{children:[R&&t.jsxs("p",{className:"text-sm",children:["Update ",R.manifest.name," from ",R.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(Q,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(re,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:F,required:!0,onChange:x=>{var E;return z(((E=x.target.files)==null?void 0:E[0])??null)}})]}),!R&&t.jsx(qe,{value:j,onChange:k,projects:n.projects,disabled:F}),t.jsxs(P,{type:"submit",disabled:F||!H||!R&&!g&&f,children:["Review ",R?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Fe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(x=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[x.label," ",t.jsx(Re,{variant:"outline",children:x.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[x.id," · ",x.fingerprint]})]},x.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Pt,{client:i,busy:F,run:x=>{J(x)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",p.hostName]}),t.jsx(Re,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Wt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(x=>{var E;return((E=n==null?void 0:n.projects.find(W=>W.id===x))==null?void 0:E.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(x=>t.jsxs("li",{children:[x.side,": ",x.name," requires ",x.required,"; available ",x.actual??"none","."]},`${x.side}:${x.code}:${x.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(x=>x.name).join(", "),"."]})}),C&&te&&!r?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{client:i,preview:c,activation:e.activation,onComplete:()=>{S(!1),h(null),I(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${p.hostName}.`),O("installed"),U(null)},onError:x=>{m(x.message),L()}}),t.jsxs(P,{variant:"outline",onClick:L,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(P,{variant:"outline",disabled:D,onClick:L,children:"Cancel"}),t.jsxs(P,{disabled:F||!te||!c.compatibility.compatible||r,onClick:()=>{m(null),S(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",p.hostName]})]})]})]})]})})}export{ds as PluginsDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,j as t}from"./vendor-react-gGw_S5I_.js";import{y as ne,B as g,l as K,z as ie,C as oe,m as le,n as ce,I as de,E as G,G as ue,T as he,H as pe,J as me,L as fe,M as xe,N as we,O as ve,Q as ge,R as be,U as je,w as b}from"./index-CPTFl4Qh.js";import{E as H,X as ye,a as Se,b as Ne,c as Ie,M as Ee,T as ke,d as Me,e as Pe,Z as ze,f as Re}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const O=360,Ce=560,V="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",E=.5,k=1.5,I=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:ke},desktop:{label:"Desktop",width:1280,height:800,icon:Ee}};function Te(){try{const s=Number(localStorage.getItem(V));if(Number.isFinite(s)&&s>=O)return s}catch{}return Ce}function De(){try{const s=localStorage.getItem(Y);if(s&&s in h)return s}catch{}return"responsive"}function Oe(){try{const s=localStorage.getItem(_);if(s===null)return 1;const i=Number(s);if(Number.isFinite(i))return Math.min(k,Math.max(E,i))}catch{}return 1}function X(s){return be(`cogpit-preview-url:${s}`)}function A(s){const i=s.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const n=new URL(j);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}catch{return null}}function B(s,i){return`http://${i||"localhost"}:${s}/`}function Le({cwd:s,onClose:i}){const[M,j]=a.useState([]),[n,P]=a.useState(""),[W,y]=a.useState(""),[z,R]=a.useState(null),[J,Q]=a.useState(0),[q,C]=a.useState(!1),[S,ee]=a.useState(Te),[l,te]=a.useState(De),[o,p]=a.useState(Oe),c=a.useRef(null),$=a.useRef(null),T=a.useRef(null),{activeDevice:m}=ne(),N=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;a.useEffect(()=>{let e="";try{e=localStorage.getItem(X(s))??""}catch{}const r=e?A(e)??"":"";P(r),y(r),R(null)},[s,re]),a.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(s)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=B(L,N);P(v=>v||w),y(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[s,N]),a.useEffect(()=>{if(n)try{localStorage.setItem(X(s),n)}catch{}},[s,n]),a.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=a.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=a.useCallback(e=>{const r=A(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),y(r),C(!0)},[]),D=a.useCallback(()=>{n&&(C(!0),Q(e=>e+1))},[n]);a.useEffect(()=>{function e(r){var d,u,x;if((d=$.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),D();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=T.current)==null||u.focus(),(x=T.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(k,Number((f+I).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(E,Number((f-I).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D]);const se=a.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:S,currentWidth:S},e.currentTarget.setPointerCapture(e.pointerId)},[S]),ae=a.useCallback(e=>{if(!c.current)return;const r=Math.max(O,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(O,d));c.current.currentWidth=u,ee(u)},[]),F=a.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(V,String(e))}catch{}},[]);return t.jsxs("aside",{ref:$,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-canvas",style:{width:S},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:se,onPointerMove:ae,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(ye,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U(W)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:T,"aria-label":"Preview URL","aria-invalid":!!z,value:W,onChange:e=>y(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!n,onClick:D,"aria-label":"Refresh preview",children:t.jsx(Se,{"data-icon":"inline-start",className:q?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!n,onClick:()=>window.open(n,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ne,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(B(e,N)),"aria-label":`Open ${N}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=E,onClick:()=>p(e=>Math.max(E,Number((e-I).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=k,onClick:()=>p(e=>Math.min(k,Number((e+I).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:n?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:n,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>C(!1)},`${n}-${J}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Le as PreviewPanel,A as normalizePreviewUrl};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as l,j as t,c as Ae}from"./vendor-react-gGw_S5I_.js";import{L as Q,M as q,N as J,O as W,Q as X,U as ae,J as ie,aD as ot,ah as je,B as A,aE as Ct,aF as kt,aG as Et,aH as Rt,l as xe,Z as le,m as Dt,I as Ft,n as Lt,T as nt,H as he,q as Tt,a2 as Mt,aI as It,aJ as $t,D as zt,h as At,i as Ut,j as Ot,k as Pt,aK as Gt,aL as Bt,a5 as Kt,a6 as Ht,a7 as Vt,a9 as Qt,aa as qt,ab as Jt,ac as Wt,ad as Xt,w as Yt}from"./index-CPTFl4Qh.js";import{H as Zt}from"./HighlightedEditor-D9A-dW2Z.js";import{O as ge,q as ze,n as _t,Q as es,C as ts,X as ss,G as ns,S as ls,a as lt,U as as,V as at,W as is,F as Ie}from"./vendor-ui-DQeMoSiV.js";import{M as rs}from"./vendor-markdown-BE1gYnO9.js";import"./vendor-shiki-DOn6sF-i.js";const os=12,ct="h-6 w-full justify-start gap-1 rounded-none px-2 text-left font-normal";function Se(n,e){return{paddingLeft:8+n*os+(e?0:16)}}function cs(n){const e=n;return typeof e=="object"&&e!==null&&typeof e.name=="string"&&(e.type==="file"||e.type==="directory")}function ds(n){const e=n==null?void 0:n.entries;return Array.isArray(e)?e.filter(cs):[]}async function it(n,e,r){try{const o=await ae(`/api/project-files/tree?cwd=${encodeURIComponent(n)}&dir=${encodeURIComponent(e)}${r?"&refresh=1":""}`);if(!o.ok){const u=await o.json().catch(()=>null),f=u==null?void 0:u.error;throw new Error(typeof f=="string"?f:"Unable to list directory")}const c=await o.json();return{status:"ready",entries:ds(c),scanLimited:c.scanLimited===!0}}catch(o){return{status:"error",message:o instanceof Error?o.message:"Unable to list directory"}}}function fs(n){const e=n.split("/");return e.slice(0,-1).map((r,o)=>e.slice(0,o+1).join("/"))}function us({cwd:n,selectedPath:e,onSelect:r,fileStatus:o,reloadToken:c}){const[u,f]=l.useState(()=>new Map),[g,S]=l.useState(()=>new Set),b=l.useRef(new Set),R=l.useRef(n);R.current=n;const m=l.useCallback(async x=>{if(b.current.has(x))return;b.current.add(x),f(y=>new Map(y).set(x,{status:"loading"}));const w=await it(n,x,!1);b.current.delete(x),R.current===n&&f(y=>new Map(y).set(x,w))},[n]),h=l.useRef(null);l.useEffect(()=>{const x=h.current===n;h.current=n,x||S(new Set),f(new Map([["",{status:"loading"}]]));let w=!1;return it(n,"",x).then(y=>{w||f(new Map([["",y]]))}),()=>{w=!0}},[n,c]),l.useEffect(()=>{if(!e)return;const x=fs(e);x.length!==0&&S(w=>{if(x.every(D=>w.has(D)))return w;const y=new Set(w);for(const D of x)y.add(D);return y})},[e]);const N=l.useCallback(x=>{S(w=>{const y=new Set(w);return y.has(x)?y.delete(x):y.add(x),y})},[]),j=u.get(""),k=ms(j);return t.jsxs("div",{"aria-label":"Project file tree",className:"flex flex-col py-1",children:[k?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(k.Icon,{})}),t.jsx(W,{children:k.title}),t.jsx(X,{children:k.description})]})}):t.jsx(dt,{directory:"",depth:0,state:j,directories:u,expanded:g,selectedPath:e,onSelect:r,onToggle:N,onLoad:m,fileStatus:o}),(j==null?void 0:j.status)==="ready"&&j.scanLimited&&t.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"This project is too large to scan completely."})]})}function ms(n){return(n==null?void 0:n.status)==="error"?{Icon:ge,title:"Could not load files",description:n.message}:(n==null?void 0:n.status)==="ready"&&n.entries.length===0?{Icon:ze,title:"No files",description:"This project has no files to show."}:null}function dt(n){const e=Ae.c(22),{directory:r,depth:o,state:c,onLoad:u,...f}=n;let g,S;if(e[0]!==r||e[1]!==u||e[2]!==c?(g=()=>{c===void 0&&r!==""&&u(r)},S=[r,u,c],e[0]=r,e[1]=u,e[2]=c,e[3]=g,e[4]=S):(g=e[3],S=e[4]),l.useEffect(g,S),!c||c.status==="loading"){let m;e[5]!==o?(m=Se(o,!1),e[5]=o,e[6]=m):m=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(je,{className:"size-3"}),e[7]=h):h=e[7];const N=r===""&&"Loading files…";let j;return e[8]!==m||e[9]!==N?(j=t.jsxs("div",{role:"status",className:"flex h-6 items-center gap-2 text-xs text-muted-foreground",style:m,children:[h,N]}),e[8]=m,e[9]=N,e[10]=j):j=e[10],j}if(c.status==="error"){let m;e[11]!==o?(m=Se(o,!1),e[11]=o,e[12]=m):m=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ge,{"aria-hidden":"true",className:"size-3 shrink-0"}),e[13]=h):h=e[13];let N;e[14]!==c.message?(N=t.jsx("span",{className:"truncate",children:c.message}),e[14]=c.message,e[15]=N):N=e[15];let j;return e[16]!==c.message||e[17]!==m||e[18]!==N?(j=t.jsxs("div",{role:"alert",className:"flex h-6 items-center gap-1.5 truncate text-xs text-destructive",style:m,title:c.message,children:[h,N]}),e[16]=c.message,e[17]=m,e[18]=N,e[19]=j):j=e[19],j}const b=c.entries.map(m=>{const h=r?`${r}/${m.name}`:m.name;return m.type==="directory"?t.jsx(xs,{path:h,name:m.name,depth:o,onLoad:u,...f},h):t.jsx(hs,{path:h,name:m.name,depth:o,selected:f.selectedPath===h,status:f.fileStatus(h),onSelect:f.onSelect},h)});let R;return e[20]!==b?(R=t.jsx(t.Fragment,{children:b}),e[20]=b,e[21]=R):R=e[21],R}function xs(n){const e=Ae.c(48);let r,o,c,u,f,g,S,b,R,m,h,N,j,k,x,w,y;e[0]!==n?({path:S,name:f,depth:u,...b}=n,g=b.expanded.has(S),r=g?_t:es,c=A,h="ghost",N="sm",j=g,k=ct,e[18]!==u?(x=Se(u,!0),e[18]=u,e[19]=x):x=e[19],w=()=>b.onToggle(S),y=S,o=ts,R="true",m=ie("size-3 shrink-0 text-muted-foreground transition-transform",g&&"rotate-90"),e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=u,e[5]=f,e[6]=g,e[7]=S,e[8]=b,e[9]=R,e[10]=m,e[11]=h,e[12]=N,e[13]=j,e[14]=k,e[15]=x,e[16]=w,e[17]=y):(r=e[1],o=e[2],c=e[3],u=e[4],f=e[5],g=e[6],S=e[7],b=e[8],R=e[9],m=e[10],h=e[11],N=e[12],j=e[13],k=e[14],x=e[15],w=e[16],y=e[17]);let D;e[20]!==o||e[21]!==R||e[22]!==m?(D=t.jsx(o,{"aria-hidden":R,className:m}),e[20]=o,e[21]=R,e[22]=m,e[23]=D):D=e[23];let L;e[24]!==r?(L=t.jsx(r,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[24]=r,e[25]=L):L=e[25];let F;e[26]!==f?(F=t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:f}),e[26]=f,e[27]=F):F=e[27];let i;e[28]!==c||e[29]!==D||e[30]!==L||e[31]!==F||e[32]!==h||e[33]!==N||e[34]!==j||e[35]!==k||e[36]!==x||e[37]!==w||e[38]!==y?(i=t.jsxs(c,{variant:h,size:N,"aria-expanded":j,className:k,style:x,onClick:w,title:y,children:[D,L,F]}),e[28]=c,e[29]=D,e[30]=L,e[31]=F,e[32]=h,e[33]=N,e[34]=j,e[35]=k,e[36]=x,e[37]=w,e[38]=y,e[39]=i):i=e[39];let T;e[40]!==u||e[41]!==g||e[42]!==S||e[43]!==b?(T=g&&t.jsx("div",{children:t.jsx(dt,{directory:S,depth:u+1,state:b.directories.get(S),...b})}),e[40]=u,e[41]=g,e[42]=S,e[43]=b,e[44]=T):T=e[44];let U;return e[45]!==i||e[46]!==T?(U=t.jsxs("div",{children:[i,T]}),e[45]=i,e[46]=T,e[47]=U):U=e[47],U}function hs(n){const e=Ae.c(28),{path:r,name:o,depth:c,selected:u,status:f,onSelect:g}=n,S=l.useRef(null);let b;e[0]!==r?(b=ot(r),e[0]=r,e[1]=b):b=e[1];const R=b;let m,h;e[2]!==u?(m=()=>{var T,U;u&&((U=(T=S.current)==null?void 0:T.scrollIntoView)==null||U.call(T,{block:"nearest"}))},h=[u],e[2]=u,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);const N=u||void 0,j=u?"secondary":"ghost";let k;e[5]!==c?(k=Se(c,!1),e[5]=c,e[6]=k):k=e[6];let x;e[7]!==g||e[8]!==r?(x=()=>g(r),e[7]=g,e[8]=r,e[9]=x):x=e[9];let w;e[10]!==R?(w=t.jsx(R,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[10]=R,e[11]=w):w=e[11];const y=f&&f.className;let D;e[12]!==y?(D=ie("min-w-0 flex-1 truncate text-xs",y),e[12]=y,e[13]=D):D=e[13];let L;e[14]!==o||e[15]!==D?(L=t.jsx("span",{className:D,children:o}),e[14]=o,e[15]=D,e[16]=L):L=e[16];let F;e[17]!==f?(F=f&&t.jsx("span",{className:ie("shrink-0 font-mono text-[10px]",f.className),title:f.label,children:f.code}),e[17]=f,e[18]=F):F=e[18];let i;return e[19]!==r||e[20]!==L||e[21]!==F||e[22]!==N||e[23]!==j||e[24]!==k||e[25]!==x||e[26]!==w?(i=t.jsxs(A,{ref:S,"aria-current":N,variant:j,size:"sm",className:ct,style:k,onClick:x,title:r,children:[w,L,F]}),e[19]=r,e[20]=L,e[21]=F,e[22]=N,e[23]=j,e[24]=k,e[25]=x,e[26]=w,e[27]=i):i=e[27],i}const ps={"?":{label:"Untracked",className:"text-info"},A:{label:"Added",className:"text-success"},M:{label:"Modified",className:"text-warning"},D:{label:"Deleted",className:"text-destructive"},R:{label:"Renamed",className:"text-info"},C:{label:"Copied",className:"text-info"},U:{label:"Conflicted",className:"text-destructive"}};function $e(n){const e=n.workTreeStatus.trim()||n.indexStatus.trim();return ps[e]??{label:"Changed",className:"text-muted-foreground"}}function js(n){return`${n.indexStatus}${n.workTreeStatus}`.trim()||"?"}const gs=new Set([".md",".mdx",".markdown"]);function rt(n){const e=n.lastIndexOf(".");return e!==-1&&gs.has(n.slice(e).toLowerCase())}function ws(n,e,r){if(!n||/^(?:[a-z]+:|\/|#)/i.test(n))return n;const o=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",c=[];for(const f of[...o.split("/"),...n.split("/")])f===".."?c.pop():f&&f!=="."&&c.push(f);const u=e.includes("\\")?"\\":"/";return[e.replace(/[\\/]+$/,""),...c].join(u)}async function pe(n,e){try{const r=await n.json();if(r&&typeof r=="object"&&typeof r.error=="string")return r.error}catch{}return e}function vs(n){return n<1024?`${n} B`:`${(n/1024).toFixed(n<10*1024?1:0)} KB`}function ys(n,e){let r=0;for(let o=1;o<e;o+=1){const c=n.indexOf(`
|
|
2
|
-
`,r);if(c<0)return r;r=c+1}return r}function Rs({cwd:n,onClose:e,onAddToPrompt:r,openRequest:o}){const c=l.useRef(null),u=l.useRef(null),f=l.useRef(null),[g,S]=l.useState(""),[b,R]=l.useState([]),[m,h]=l.useState(!0),[N,j]=l.useState(null),[k,x]=l.useState(0),[w,y]=l.useState(!1),[D,L]=l.useState(0),F=l.useRef(!1),[i,T]=l.useState(null),[U,Ce]=l.useState(!0),[M,Y]=l.useState(""),[ft,re]=l.useState(""),[O,oe]=l.useState(null),[ut,Ue]=l.useState(0),[K,Oe]=l.useState(!1),[Z,Pe]=l.useState(!1),[Ge,_]=l.useState(null),[mt,ee]=l.useState(!1),[I,ke]=l.useState("all"),[v,Be]=l.useState(null),[Ke,He]=l.useState(!1),[xt,Ve]=l.useState(null),[C,ce]=l.useState("edit"),[E,we]=l.useState(null),[de,Qe]=l.useState(!1),[qe,Ee]=l.useState(null),[fe,H]=l.useState(null),[P,ve]=l.useState(null),[ye,Re]=l.useState(""),[B,ue]=l.useState(null),$=i!==null&&M!==ft,z=l.useMemo(()=>new Map(((v==null?void 0:v.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[v==null?void 0:v.files]),te=l.useCallback(async()=>{He(!0),Ve(null);try{const s=await ae(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const a=await s.json();Be(a),a.isRepository||ke("all")}catch(s){Be(null),ke("all"),Ve(s instanceof Error?s.message:"Unable to read git status")}finally{He(!1)}},[n]);l.useEffect(()=>{te()},[te]);const De=I==="all"&&g.trim()==="";l.useEffect(()=>{if(De)return;const s=new AbortController,a=window.setTimeout(async()=>{h(!0),j(null);const d=F.current;F.current=!1;try{const p=await ae(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(g)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!p.ok)throw new Error(await pe(p,"Unable to list project files"));const G=await p.json();if(s.signal.aborted)return;const tt=Ct(G),st=G.totalMatches;R(tt),x(typeof st=="number"?st:tt.length),y(G.scanLimited===!0)}catch(p){s.signal.aborted||(R([]),j(p instanceof Error?p.message:"Unable to list project files"))}finally{s.signal.aborted||h(!1)}},120);return()=>{window.clearTimeout(a),s.abort()}},[n,g,D,De]),l.useEffect(()=>{T(null),Y(""),re(""),oe(null),_(null),H(null),ce("edit"),we(null),Ee(null),ue(null)},[n]),l.useEffect(()=>{if(!$)return;const s=a=>a.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[$]);const ht=l.useCallback((s,a)=>{const d=u.current;if(!d)return;if(!a||a<1){d.focus();return}const p=ys(s,a);d.blur(),d.setSelectionRange(p,p),d.focus()},[]);l.useEffect(()=>{const s=f.current;!s||!u.current||(f.current=null,ht(s.text,s.line))});const se=l.useCallback(async(s,a)=>{Oe(!0),_(null),ee(!1),H(null);try{const d=await ae(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const p=await d.json();Y(p.content),re(p.content),oe(p.mtimeMs),Ue(p.size),f.current={text:p.content,line:a}}catch(d){Y(""),re(""),oe(null),_(d instanceof Error?d.message:"Unable to open file")}finally{Oe(!1)}},[n]),ne=l.useCallback(async(s,a)=>{Qe(!0),Ee(null),we(null);try{const d=a?`&originalPath=${encodeURIComponent(a)}`:"",p=await ae(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!p.ok)throw new Error(await pe(p,"Unable to diff file"));we(await p.json())}catch(d){Ee(d instanceof Error?d.message:"Unable to diff file")}finally{Qe(!1)}},[n]),be=l.useCallback(({path:s,mode:a,line:d})=>{var p;if(T(s),Ce(!1),a==="edit"){ce(rt(s)&&!d?"preview":"edit"),se(s,d);return}ce(a),Y(""),re(""),oe(null),_(null),ee(!1),H(null),ne(s,(p=z.get(s))==null?void 0:p.originalPath)},[z,ne,se]),Ne=l.useCallback(s=>{if($){ue({type:"file",target:s});return}be(s)},[$,be]),Je=l.useCallback(s=>{if(s===i){Ce(!1);return}const a=I==="changes"&&z.has(s)?"diff":"edit";Ne({path:s,mode:a})},[z,I,Ne,i]),We=l.useRef(0);l.useEffect(()=>{!o||o.token===We.current||(We.current=o.token,Ne({path:o.file,mode:o.mode,line:o.line}))},[o,Ne]);const pt=l.useCallback(()=>{var s;!i||C==="diff"||(ce("diff"),(E==null?void 0:E.path)!==i&&!de&&ne(i,(s=z.get(i))==null?void 0:s.originalPath))},[z,E==null?void 0:E.path,de,ne,i,C]),jt=l.useCallback(s=>{!i||C===s||(ce(s),O===null&&!K&&se(i))},[K,se,O,i,C]),Fe=l.useCallback(()=>{var s;if(i){if(C==="diff"){ne(i,(s=z.get(i))==null?void 0:s.originalPath);return}se(i)}},[z,ne,se,i,C]),gt=l.useCallback(()=>{F.current=!0,L(s=>s+1),te(),C==="diff"&&Fe()},[te,Fe,C]),Le=l.useCallback(async()=>{if(!(!i||O===null||!$||Z)){Pe(!0),_(null),ee(!1);try{const s=await ae("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,path:i,content:M,expectedMtimeMs:O})});if(!s.ok)throw new Error(await pe(s,"Unable to save file"));const a=await s.json();re(M),oe(a.mtimeMs),Ue(a.size),ee(!0),we(null),te()}catch(s){_(s instanceof Error?s.message:"Unable to save file")}finally{Pe(!1)}}},[M,n,$,te,O,Z,i]);l.useEffect(()=>{function s(a){var d;(d=c.current)!=null&&d.contains(document.activeElement)&&Yt("projectFileSave",a)&&(a.preventDefault(),Le())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Le]);const wt=l.useCallback(()=>{if($){ue({type:"close"});return}e()},[$,e]),vt=l.useCallback(()=>{if(!B)return;const s=B;if(ue(null),s.type==="file"){be(s.target);return}e()},[e,be,B]),yt=l.useCallback(s=>{if(s.key!=="Tab")return;s.preventDefault();const a=s.currentTarget,d=a.selectionStart,p=a.selectionEnd,G=`${M.slice(0,d)} ${M.slice(p)}`;Y(G),ee(!1),H(null),requestAnimationFrame(()=>{a.selectionStart=d+2,a.selectionEnd=d+2})},[M]),bt=l.useCallback(s=>{const a=s.currentTarget;if(a.selectionStart===a.selectionEnd){H(null);return}const d=M.slice(a.selectionStart,a.selectionEnd),p=M.slice(0,a.selectionStart).split(`
|
|
3
|
-
`).length,G=p+d.split(`
|
|
4
|
-
`).length-1;H({text:d,startLine:p,endLine:G})},[M]),Te=l.useMemo(()=>(i==null?void 0:i.split("/").at(-1))??null,[i]),me=i?z.get(i):void 0,Xe=i!==null&&rt(i),Ye=l.useCallback(s=>{const a=z.get(s);return a?{code:js(a),...$e(a)}:null},[z]),Nt=l.useMemo(()=>({...kt,img:s=>t.jsx(Et,{src:ws(s.src,n,i??""),alt:s.alt})}),[n,i]),Me=l.useMemo(()=>E&&!E.binary&&!E.tooLarge?Rt(E.original??"",E.current??""):null,[E]),V=l.useMemo(()=>{if(I==="all")return b;const s=g.trim().toLowerCase();return((v==null?void 0:v.files)??[]).map(a=>a.path).filter((a,d,p)=>p.indexOf(a)===d).filter(a=>!s||a.toLowerCase().includes(s)).sort((a,d)=>a.localeCompare(d))},[I,b,v==null?void 0:v.files,g]),Ze=l.useMemo(()=>i&&!V.includes(i)?[i,...V]:V,[V,i]),St=I==="changes"?Ke:m,_e=I==="changes"?xt:N,et=Ke;return t.jsxs("aside",{ref:c,"aria-label":"Project files",className:"relative flex size-full min-h-0 flex-col bg-canvas",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(ze,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(A,{variant:"ghost",size:"icon-sm",onClick:wt,"aria-label":"Close project files",children:t.jsx(ss,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(v==null?void 0:v.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(ns,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:v.branch??"Detached HEAD",children:v.branch??"detached HEAD"}),v.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",v.upstream]}),(v.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",v.ahead]}),(v.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",v.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[v.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:ie("min-h-0 shrink-0 flex-col md:flex md:w-56",i&&!U?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(Dt,{className:"min-w-0 flex-1",children:[t.jsx(Ft,{children:t.jsx(ls,{"data-icon":"inline-start"})}),t.jsx(Lt,{"aria-label":"Search project files",value:g,onChange:s=>S(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:et,onClick:gt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(lt,{"data-icon":"inline-start",className:et?"animate-spin":void 0})})]}),(v==null?void 0:v.isRepository)&&t.jsxs(nt,{"aria-label":"File scope",value:[I],onValueChange:s=>{const a=s[0];(a==="all"||a==="changes")&&ke(a)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(he,{value:"all",className:"flex-1",children:"All files"}),t.jsx(he,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Tt,{className:"min-h-0 flex-1",children:De?t.jsx(us,{cwd:n,selectedPath:i,onSelect:Je,fileStatus:Ye,reloadToken:D}):St?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading files…"]}):_e?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(W,{children:"Could not load files"}),t.jsx(X,{children:_e})]})}):Ze.length===0?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(W,{children:I==="changes"?"No working-tree changes":"No matching files"}),t.jsx(X,{children:I==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[Ze.map(s=>{const a=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",p=Ye(s),G=ot(s);return t.jsxs(A,{variant:i===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>Je(s),title:s,children:[t.jsx(G,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:a}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),p&&t.jsx(le,{variant:"outline",className:ie("font-mono",p.className),title:p.label,children:p.code})]},s)}),I==="all"&&(k>V.length||w)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[k>V.length&&`Showing ${V.length} of ${k} matches. Type to narrow the list. `,w&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical",className:"hidden md:block"}),t.jsx("section",{"aria-label":"File editor",className:ie("min-h-0 min-w-0 flex-1 flex-col md:flex",i&&!U?"flex":"hidden"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center gap-2 px-3 py-1 md:flex-nowrap",children:[t.jsx(A,{variant:"ghost",size:"icon-lg",className:"md:hidden",onClick:()=>Ce(!0),"aria-label":"Back to file browser",children:t.jsx(as,{"data-icon":"inline-start"})}),t.jsxs("div",{className:"min-w-0 flex-1 basis-[calc(100%-3.25rem)] md:basis-auto",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:i,children:Te}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:i})]}),(me||C==="diff"||Xe)&&t.jsxs(nt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?pt():(s[0]==="edit"||s[0]==="preview")&&jt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(me||C==="diff")&&t.jsx(he,{value:"diff",children:"Diff"}),Xe&&t.jsx(he,{value:"preview",children:"Preview"}),t.jsx(he,{value:"edit",children:"Edit"})]}),C==="diff"&&me&&t.jsx(le,{variant:"outline",className:$e(me).className,children:$e(me).label}),C==="diff"&&Me&&t.jsx(Mt,{add:Me.add,del:Me.del}),C!=="diff"&&$&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!$&&mt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&O!==null&&t.jsx("span",{className:"hidden text-xs text-muted-foreground md:inline",children:vs(ut)}),r&&t.jsxs(A,{variant:"outline",size:"sm",disabled:C==="diff"?de||E===null:K||O===null,onClick:()=>{fe?(Re(""),ve(fe)):r({path:i})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(at,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||Z,onClick:Fe,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(lt,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(A,{size:"sm",disabled:!$||K||Z||O===null,onClick:()=>void Le(),children:[Z?t.jsx(je,{"data-icon":"inline-start"}):t.jsx(is,{"data-icon":"inline-start"}),Z?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Ge&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(ge,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Ge})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading diff…"]}):qe?t.jsx(Q,{className:"rounded-none",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(W,{children:"Could not diff this file"}),t.jsx(X,{children:qe})]})}):E===null?null:E.binary||E.tooLarge?t.jsx(Q,{className:"rounded-none",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(W,{children:E.binary?"Binary file":"File is too large to diff"}),t.jsx(X,{children:E.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):E.original===E.current?t.jsx(Q,{className:"rounded-none",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(W,{children:"No content changes"}),t.jsx(X,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(It,{oldString:E.original??"",newString:E.current??"",filePath:i,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Opening file…"]}),!K&&O!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${i}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(rs,{components:Nt,remarkPlugins:$t,children:M})}):t.jsx(Zt,{textareaRef:u,ariaLabel:`Editing ${i}`,filePath:i,value:M,readOnly:!1,onChange:s=>{Y(s),ee(!1),H(null)},onKeyDown:yt,onSelect:bt}))]})]}):t.jsx(Q,{className:"rounded-none",children:t.jsxs(q,{children:[t.jsx(J,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(W,{children:"Select a file"}),t.jsx(X,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx(zt,{open:P!==null,onOpenChange:s=>{s||ve(null)},children:t.jsxs(At,{children:[t.jsxs(Ut,{children:[t.jsx(Ot,{children:"Comment on selected lines"}),t.jsxs(Pt,{children:["Add a review instruction for ",i," lines ",P==null?void 0:P.startLine,"-",P==null?void 0:P.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const a=ye.trim();!i||!P||!a||!r||(r({path:i,...P,comment:a}),ve(null),Re(""))},children:[t.jsx(Gt,{autoFocus:!0,"aria-label":"Review comment",value:ye,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var a;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&ye.trim()&&(s.preventDefault(),(a=s.currentTarget.form)==null||a.requestSubmit())}}),t.jsxs(Bt,{children:[t.jsx(A,{type:"button",variant:"outline",onClick:()=>ve(null),children:"Cancel"}),t.jsxs(A,{type:"submit",disabled:!ye.trim(),children:[t.jsx(at,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Kt,{open:B!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Ht,{size:"sm",children:[t.jsxs(Vt,{children:[t.jsx(Qt,{children:"Discard unsaved changes?"}),t.jsx(qt,{children:(B==null?void 0:B.type)==="file"?`Your edits to ${Te??"this file"} will be lost when you open ${B.target.path}.`:`Your edits to ${Te??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(Jt,{children:[t.jsx(Wt,{size:"sm",children:"Keep editing"}),t.jsx(Xt,{variant:"destructive",size:"sm",onClick:vt,children:"Discard changes"})]})]})})]})}export{Rs as ProjectFilesPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as E,r as y,j as m}from"./vendor-react-gGw_S5I_.js";import{v as b,i as L,j as k,k as F,h as K,P as R,D as _,w as A,x as H}from"./index-CPTFl4Qh.js";import"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function q(v){const e=E.c(28),{open:r,onClose:t,onNewSession:i,onNewFolder:j,defaultAgentKind:x,currentProjectDirName:a,currentProjectCwd:o,initialView:D}=v,s=b(r);let h,p;e[0]!==o||e[1]!==a||e[2]!==t||e[3]!==i||e[4]!==r||e[5]!==s?(h=()=>{if(!r)return;const n=function(g){var S;if(A("newSession",g)&&a){g.preventDefault();const P=o?H(s,o,"claude")??((S=s.find(C=>C.path===o))==null?void 0:S.dirName)??a:a;i(P,o??void 0),t()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},p=[r,s,a,o,i,t],e[0]=o,e[1]=a,e[2]=t,e[3]=i,e[4]=r,e[5]=s,e[6]=h,e[7]=p):(h=e[6],p=e[7]),y.useEffect(h,p);let l;e[8]!==t?(l=n=>{n||t()},e[8]=t,e[9]=l):l=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsxs(L,{className:"sr-only",children:[m.jsx(k,{children:"Start a session"}),m.jsx(F,{children:"Choose a project, enter an absolute folder path, or browse the folders."})]}),e[10]=w):w=e[10];let c;e[11]!==t||e[12]!==i?(c=(n,N)=>{i(n,N),t()},e[11]=t,e[12]=i,e[13]=c):c=e[13];let d;e[14]!==t||e[15]!==j?(d=n=>{j(n),t()},e[14]=t,e[15]=j,e[16]=d):d=e[16];let f;e[17]!==o||e[18]!==x||e[19]!==D||e[20]!==s||e[21]!==c||e[22]!==d?(f=m.jsxs(K,{className:"max-w-md gap-0 overflow-hidden p-0",children:[w,m.jsx(R,{projects:s,currentPath:o,onNewSession:c,onNewFolder:d,defaultAgentKind:x,initialView:D})]}),e[17]=o,e[18]=x,e[19]=D,e[20]=s,e[21]=c,e[22]=d,e[23]=f):f=e[23];let u;return e[24]!==r||e[25]!==l||e[26]!==f?(u=m.jsx(_,{open:r,onOpenChange:l,children:f}),e[24]=r,e[25]=l,e[26]=f,e[27]=u):u=e[27],u}export{q as ProjectSwitcherModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{aC as W,H as _,i as U,j as Y,k as q,T as $,h as B,D as J}from"./index-CPTFl4Qh.js";import{N as Q,w as V}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const I=[{id:"narrow",name:"Narrow",css:"44rem"},{id:"medium",name:"Medium",css:"56rem"},{id:"wide",name:"Wide",css:"64rem"},{id:"full",name:"Full",css:"100%"}],K="cogpit-chat-width",M="medium";function X(){try{const s=localStorage.getItem(K);if(I.some(e=>e.id===s))return s}catch{}return M}let R=typeof window>"u"?M:X();const H=new Set;function L(s){if(typeof document>"u")return;const e=I.find(t=>t.id===s)??I[1];document.documentElement.style.setProperty("--chat-width",e.css)}L(R);function Z(){return R}function ee(s){R=s;try{localStorage.setItem(K,s)}catch{}L(s),H.forEach(e=>e())}function te(s){return H.add(s),()=>H.delete(s)}function se(){const s=O.c(2),e=g.useSyncExternalStore(te,Z,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return M}function de(s){const e=O.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[x,P]=g.useState(0),[z,A]=se();let j,w;e[0]!==l||e[1]!==t?(j=()=>{if(t){const a=W.findIndex(D=>D.id===l);P(a>=0?a:0)}},w=[t,l],e[0]=l,e[1]=t,e[2]=j,e[3]=w):(j=e[2],w=e[3]),g.useEffect(j,w);let N,b;e[4]!==i||e[5]!==t||e[6]!==x?(N=()=>{t&&i(W[x].id)},b=[x,t,i],e[4]=i,e[5]=t,e[6]=x,e[7]=N,e[8]=b):(N=e[7],b=e[8]),g.useEffect(N,b);let C,S;e[9]!==i||e[10]!==t?(C=()=>{t||i(null)},S=[t,i],e[9]=i,e[10]=t,e[11]=C,e[12]=S):(C=e[11],S=e[12]),g.useEffect(C,S);let y;e[13]!==r||e[14]!==k?(y=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=y):y=e[15];const F=y;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs(U,{className:"border-b p-4 pr-12",children:[n.jsxs(Y,{className:"flex items-center gap-2 text-sm",children:[n.jsx(V,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(q,{children:"Preview a color theme and set the chat width."})]}),e[18]=E):E=e[18];const G=W[x];let c;e[19]!==G.id?(c=[G.id],e[19]=G.id,e[20]=c):c=e[20];let d;e[21]!==l||e[22]!==F?(d=W.map((a,D)=>n.jsxs(_,{value:a.id,className:"h-auto w-full justify-start gap-3 px-3 py-2.5 text-left text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>F(a),onMouseEnter:()=>P(D),onFocus:()=>P(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),l===a.id&&n.jsx(Q,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=l,e[22]=F,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx($,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=v):v=e[27];let f;e[28]!==z?(f=[z],e[28]=z,e[29]=f):f=e[29];let u;e[30]!==A?(u=I.map(a=>n.jsx(_,{value:a.id,className:"flex-1 text-xs text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>A(a.id),children:a.name},a.id)),e[30]=A,e[31]=u):u=e[31];let h;e[32]!==f||e[33]!==u?(h=n.jsxs("div",{className:"border-t p-3",children:[v,n.jsx($,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let p;e[35]!==m||e[36]!==h?(p=n.jsxs(B,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[E,m,h]}),e[35]=m,e[36]=h,e[37]=p):p=e[37];let T;return e[38]!==t||e[39]!==p||e[40]!==o?(T=n.jsx(J,{open:t,onOpenChange:o,children:p}),e[38]=t,e[39]=p,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{de as ThemeSelectorModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as X,j as s,r as T}from"./vendor-react-gGw_S5I_.js";import{J as le,aX as Ee,aY as mt,aJ as ft,aF as xt,aZ as He,Z as pe,a_ as Ke,a$ as Qe,ah as je,a0 as Se,a1 as Ce,B as ne,a4 as Te,U as Re,aV as Le,aR as Fe,aS as De,l as Ue,aT as Be,A as Ze,b0 as pt,p as Xe,b1 as ht,b2 as gt,b3 as jt,L as ze,M as Ae,O as We,Q as Oe,b4 as bt,d as Nt,c as wt,S as yt,a as vt,b5 as kt,b as St,q as Ct,N as Tt,$ as Rt}from"./index-CPTFl4Qh.js";import{M as It}from"./vendor-markdown-BE1gYnO9.js";import{a1 as Ge,a2 as et,a3 as tt,a4 as $t,a5 as Ie,R as _t,N as st,B as lt,a6 as qe,i as zt,a7 as At,a8 as Wt,I as Ot,a9 as Ye,a as Pt,$ as Mt}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";const Et=new Set(["done","error","skipped"]);function Ve(l){return Et.has(l)}function Lt(l){return l!=="completed"&&l!=="failed"&&l!=="killed"}function nt(l){switch(l){case"completed":return{label:"Completed",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"failed":return{label:"Failed",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"killed":return{label:"Stopped",badge:"border-warning/30 bg-warning/10 text-warning",dot:"bg-warning"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Ft(l){switch(l){case"done":return{label:"Done",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"skipped":return{label:"Skipped",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};case"error":return{label:"Error",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"queued":return{label:"Queued",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Dt(l){const e=new Map;l.phases.forEach((a,n)=>{const o=n+1;e.set(o,{index:o,title:a.title,detail:a.detail,agents:[]})});const t=[];for(const a of l.agents){const n=e.get(a.phaseIndex);n?n.agents.push(a):t.push(a)}const r=[...e.values()];t.length>0&&r.push({index:r.length+1,title:t[0].phaseTitle||"Other",agents:t});for(const a of r)a.agents.sort((n,o)=>n.index-o.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function rt(l){const e=l.trim();if(!e.startsWith("{")&&!e.startsWith("["))return l;try{return JSON.parse(e)}catch{return l}}function qt(l){try{return JSON.parse(`"${l}"`)}catch{return l.replace(/\\n/g," ").replace(/\\"/g,'"')}}function Yt(l){const e=rt(l);if(e!==l)return $e(e);for(const t of at){const r=l.match(new RegExp(`"${t}"\\s*:\\s*"((?:\\\\.|[^"\\\\])*)"`));if(r!=null&&r[1])return qt(r[1])}return l.replace(/^[#>*\s-]+/,"").replace(/[`*_#]/g,"").split(/\n\s*\n|\n/)[0].trim()}function $e(l){if(typeof l=="string")return Yt(l);if(typeof l=="number"||typeof l=="boolean")return String(l);if(Array.isArray(l))return l.length>0?$e(l[0]):"";if(Ee(l))for(const e of at){const t=l[e];if(typeof t=="string"&&t.trim())return t.trim()}return""}function Je(l){if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}function Vt(l){const e={oneLineSell:"In one line",quickWins:"Quick wins",whatIsLost:"What is lost",whyItHurts:"Why it hurts",restingState:"Resting state",fatalFlaws:"Fatal flaws",bestIdeasRegardlessOfConcept:"Best ideas across concepts"};return e[l]?e[l]:l.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^./,t=>t.toUpperCase())}function it(l){const e=X.c(4),{children:t}=l;let r;e[0]!==t?(r=mt(t),e[0]=t,e[1]=r):r=e[1];const a=r;let n;return e[2]!==a?(n=s.jsx(It,{components:xt,remarkPlugins:ft,children:a}),e[2]=a,e[3]=n):n=e[3],n}function ot(l){const e=X.c(7),{value:t}=l;if(typeof t=="string"){let n;return e[0]!==t?(n=s.jsx(it,{children:t}),e[0]=t,e[1]=n):n=e[1],n}if(t===null){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground",children:"None"}),e[2]=n):n=e[2],n}if(typeof t=="boolean"){const n=t?"Yes":"No";let o;return e[3]!==n?(o=s.jsx("span",{children:n}),e[3]=n,e[4]=o):o=e[4],o}const r=String(t);let a;return e[5]!==r?(a=s.jsx("span",{children:r}),e[5]=r,e[6]=a):a=e[6],a}function Pe(l){const e=X.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Ee(t)&&!Array.isArray(t)){let o;return e[0]!==t?(o=s.jsx(ot,{value:t}),e[0]=t,e[1]=o):o=e[1],o}if(a>5){let o;e[2]!==t?(o=Je(t),e[2]=t,e[3]=o):o=e[3];let i;return e[4]!==o?(i=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}if(Array.isArray(t)){if(t.length===0){let d;return e[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"}),e[6]=d):d=e[6],d}if(t.every(Qt)){let d;e[7]!==t?(d=t.map(Kt),e[7]=t,e[8]=d):d=e[8];let m;return e[9]!==d?(m=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=m):m=e[10],m}let i;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(m,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Pe,{value:m,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],i=t.map(d),e[11]=a,e[12]=t,e[13]=i}else i=e[13];let u;return e[16]!==i?(u=s.jsx("div",{className:"flex flex-col gap-3",children:i}),e[16]=i,e[17]=u):u=e[17],u}let n;if(e[18]!==a||e[19]!==t){const o=Object.entries(t),i=o.find(Ht),u=o.filter(d=>{const[m]=d;return m!==(i==null?void 0:i[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[i&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:i[1]}),u.map(d=>{const[m,c]=d;return c===void 0?null:Jt.has(m)&&typeof c=="string"?s.jsx("div",{className:"border-l-2 border-foreground/30 pl-4 text-sm font-medium leading-relaxed",children:s.jsx(it,{children:c})},m):s.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:Vt(m)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Pe,{value:c,depth:a+1})})]},m)})]}),e[18]=a,e[19]=t,e[20]=n}else n=e[20];return n}function Ht(l){const[e,t]=l;return Bt.has(e)&&typeof t=="string"&&t.trim().length>0}function Kt(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Qt(l){return!Ee(l)&&!Array.isArray(l)}function Me(l){const e=X.c(19),{value:t,className:r}=l;let a;e[0]!==t?(a=typeof t=="string"?rt(t):t,e[0]=t,e[1]=a):a=e[1];const n=a;if(typeof n=="string"&&(n.trim().startsWith("{")||n.trim().startsWith("["))){let m;e[2]!==n?(m=$e(n),e[2]=n,e[3]=m):m=e[3];const c=m;let x;e[4]!==r?(x=le("flex flex-col gap-2",r),e[4]=r,e[5]=x):x=e[5];let f;e[6]!==c?(f=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx("p",{className:"text-xs text-muted-foreground",children:"Only a shortened preview was saved for this response."}),e[8]=h):h=e[8];let p;return e[9]!==x||e[10]!==f?(p=s.jsxs("div",{className:x,children:[f,h]}),e[9]=x,e[10]=f,e[11]=p):p=e[11],p}let i;e[12]!==r?(i=le("min-w-0 text-sm",r),e[12]=r,e[13]=i):i=e[13];let u;e[14]!==n?(u=s.jsx(Pe,{value:n}),e[14]=n,e[15]=u):u=e[15];let d;return e[16]!==i||e[17]!==u?(d=s.jsx("div",{className:i,children:u}),e[16]=i,e[17]=u,e[18]=d):d=e[18],d}function Zt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Xt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Gt(l){const e=X.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[o,i]=T.useState(!1),[u,d]=T.useState(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={status:"idle"},e[0]=m):m=e[0];const[c,x]=T.useState(m),[f,h]=He();let p,g,j,b,S,C,y,N,v,R,W,Y,I,A,w,k,$,_,O,P,z;if(e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){v=Ft(t.state);let Ne;e[29]!==t.state?(Ne=!Ve(t.state)&&t.state!=="queued",e[29]=t.state,e[30]=Ne):Ne=e[30],N=Ne;let we;e[31]!==t.resultPreview?(we=t.resultPreview?$e(t.resultPreview):"",e[31]=t.resultPreview,e[32]=we):we=e[32];const ye=we;let ve;e[33]!==t.agentId||e[34]!==r||e[35]!==n||e[36]!==a?(ve=async()=>{x({status:"loading"});try{const he=await Re(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){x({status:"unavailable"});return}const ut=await he.json();x({status:"loaded",value:ut.result})}catch{x({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],y=ve;let ke;e[38]!==t.state||e[39]!==y||e[40]!==c.status?(ke=he=>{i(he),he&&c.status==="idle"&&Ve(t.state)&&y()},e[38]=t.state,e[39]=y,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,C=c.status==="unavailable",S=Se,W=o,Y=ct,b=Le,P="sm",R="motion-card motion-list-item gap-0 py-0",j=Fe,O="px-0 py-0",g=Ce,k="group flex w-full items-start gap-3 rounded-lg px-3.5 py-3 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",$=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",v.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Xt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(De,{className:"truncate capitalize",title:dt,children:ae}),e[44]=t.label,e[45]=ae,e[46]=re):re=e[46];let ie;e[47]!==t.attempt?(ie=t.attempt&&t.attempt>1&&s.jsxs(pe,{variant:"outline",className:"text-muted-foreground",children:["Attempt ",t.attempt]}),e[47]=t.attempt,e[48]=ie):ie=e[48];let oe;e[49]!==re||e[50]!==ie?(oe=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[re,ie]}),e[49]=re,e[50]=ie,e[51]=oe):oe=e[51];let ce;e[52]!==t.lastToolName||e[53]!==t.lastToolSummary||e[54]!==N||e[55]!==ye?(ce=ye?s.jsx("p",{className:"mt-1 line-clamp-2 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:ye}):N&&t.lastToolName?s.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:["Working in ",t.lastToolName,t.lastToolSummary?`: ${t.lastToolSummary}`:""]}):null,e[52]=t.lastToolName,e[53]=t.lastToolSummary,e[54]=N,e[55]=ye,e[56]=ce):ce=e[56];let de;e[57]!==t.model?(de=t.model&&s.jsx("span",{children:Zt(t.model)}),e[57]=t.model,e[58]=de):de=e[58];let ue;e[59]!==t.tokens?(ue=typeof t.tokens=="number"&&t.tokens>0&&s.jsxs(_e,{icon:Ge,children:[Ke(t.tokens)," tokens"]}),e[59]=t.tokens,e[60]=ue):ue=e[60];let me;e[61]!==t.toolCalls?(me=typeof t.toolCalls=="number"&&t.toolCalls>0&&s.jsxs(_e,{icon:et,children:[t.toolCalls," tools"]}),e[61]=t.toolCalls,e[62]=me):me=e[62];let fe;e[63]!==t.durationMs?(fe=typeof t.durationMs=="number"&&s.jsx(_e,{icon:tt,children:Qe(t.durationMs)}),e[63]=t.durationMs,e[64]=fe):fe=e[64];let xe;e[65]!==de||e[66]!==ue||e[67]!==me||e[68]!==fe?(xe=s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[de,ue,me,fe]}),e[65]=de,e[66]=ue,e[67]=me,e[68]=fe,e[69]=xe):xe=e[69],e[70]!==oe||e[71]!==ce||e[72]!==xe?(_=s.jsxs("div",{className:"min-w-0 flex-1",children:[oe,ce,xe]}),e[70]=oe,e[71]=ce,e[72]=xe,e[73]=_):_=e[73],w="flex shrink-0 items-center gap-2",p=pe,I="outline",A=le("hidden sm:inline-flex",v.badge),e[1]=t,e[2]=r,e[3]=o,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=g,e[10]=j,e[11]=b,e[12]=S,e[13]=C,e[14]=y,e[15]=N,e[16]=v,e[17]=R,e[18]=W,e[19]=Y,e[20]=I,e[21]=A,e[22]=w,e[23]=k,e[24]=$,e[25]=_,e[26]=O,e[27]=P,e[28]=z}else p=e[8],g=e[9],j=e[10],b=e[11],S=e[12],C=e[13],y=e[14],N=e[15],v=e[16],R=e[17],W=e[18],Y=e[19],I=e[20],A=e[21],w=e[22],k=e[23],$=e[24],_=e[25],O=e[26],P=e[27],z=e[28];let M;e[74]!==N?(M=N&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=N,e[75]=M):M=e[75];let G;e[76]!==p||e[77]!==v.label||e[78]!==M||e[79]!==I||e[80]!==A?(G=s.jsxs(p,{variant:I,className:A,children:[M,v.label]}),e[76]=p,e[77]=v.label,e[78]=M,e[79]=I,e[80]=A,e[81]=G):G=e[81];let V;e[82]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Ie,{className:"mt-0.5 size-4 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"}),e[82]=V):V=e[82];let E;e[83]!==G||e[84]!==w?(E=s.jsxs("div",{className:w,children:[G,V]}),e[83]=G,e[84]=w,e[85]=E):E=e[85];let L;e[86]!==g||e[87]!==E||e[88]!==k||e[89]!==$||e[90]!==_?(L=s.jsxs(g,{className:k,children:[$,_,E]}),e[86]=g,e[87]=E,e[88]=k,e[89]=$,e[90]=_,e[91]=L):L=e[91];let ee;e[92]!==j||e[93]!==L||e[94]!==O?(ee=s.jsx(j,{className:O,children:L}),e[92]=j,e[93]=L,e[94]=O,e[95]=ee):ee=e[95];let H;e[96]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Ue,{}),e[96]=H):H=e[96];let K;e[97]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:"Response"}),e[97]=K):K=e[97];const te=c.status==="loaded"?"Complete agent response":"Saved response preview";let F;e[98]!==te?(F=s.jsxs("div",{children:[K,s.jsx("p",{className:"text-xs text-muted-foreground",children:te})]}),e[98]=te,e[99]=F):F=e[99];let D;e[100]!==C||e[101]!==y?(D=C&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void y(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=C,e[101]=y,e[102]=D):D=e[102];let U;e[103]!==f||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})}),e[103]=f,e[104]=h,e[105]=z,e[106]=U):U=e[106];let B;e[107]!==D||e[108]!==U?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[D,U]}),e[107]=D,e[108]=U,e[109]=B):B=e[109];let J;e[110]!==F||e[111]!==B?(J=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[F,B]}),e[110]=F,e[111]=B,e[112]=J):J=e[112];let q;e[113]!==c.status||e[114]!==N||e[115]!==z?(q=c.status==="loading"?s.jsxs("div",{className:"flex items-center gap-2 py-5 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading the complete response…"]}):z!==void 0?s.jsx(Me,{value:z}):s.jsx("p",{className:"text-sm text-muted-foreground",children:N?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=N,e[115]=z,e[116]=q):q=e[116];let Q;e[117]!==t.promptPreview||e[118]!==u?(Q=t.promptPreview&&s.jsxs(Se,{open:u,onOpenChange:d,children:[s.jsxs(Ce,{render:s.jsx(ne,{variant:"ghost",size:"sm",className:"w-full justify-start"}),children:[s.jsx($t,{"data-icon":"inline-start"}),"Agent prompt",s.jsx(Ie,{"data-icon":"inline-end",className:le("ml-auto transition-transform",u&&"rotate-180")})]}),s.jsx(Te,{className:"pt-2",children:s.jsx("div",{className:"rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground",children:s.jsx(Me,{value:t.promptPreview})})})]}),e[117]=t.promptPreview,e[118]=u,e[119]=Q):Q=e[119];let Z;e[120]!==J||e[121]!==q||e[122]!==Q?(Z=s.jsxs(Te,{children:[H,s.jsxs(Be,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,Q]})]}),e[120]=J,e[121]=q,e[122]=Q,e[123]=Z):Z=e[123];let se;e[124]!==b||e[125]!==R||e[126]!==ee||e[127]!==Z||e[128]!==P?(se=s.jsxs(b,{size:P,className:R,children:[ee,Z]}),e[124]=b,e[125]=R,e[126]=ee,e[127]=Z,e[128]=P,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==W||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:W,onOpenChange:Y,children:se}),e[130]=S,e[131]=W,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=X.c(5),{icon:t,children:r}=l;let a;e[0]!==t?(a=s.jsx(t,{className:"size-3"}),e[0]=t,e[1]=a):a=e[1];let n;return e[2]!==r||e[3]!==a?(n=s.jsxs("span",{className:"inline-flex items-center gap-1",children:[a,r]}),e[2]=r,e[3]=a,e[4]=n):n=e[4],n}function es(l){const e=X.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:o,onForceStop:i}=l;let u,d,m,c,x,f,h,p;if(e[0]!==o||e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==a||e[5]!==n){const C=nt(t.status);let y;e[14]!==t.status?(y=Lt(t.status),e[14]=t.status,e[15]=y):y=e[15];const N=y,v=Dt(t),R=Ut(t.agentCounts),W=N&&t.controllable!==!1;x="flex flex-col gap-6 pb-6";const Y=N&&s.jsx("span",{className:le("size-1.5 rounded-full",C.dot)});let I;e[16]!==C||e[17]!==Y?(I=s.jsxs(pe,{variant:"outline",className:C.badge,children:[Y,C.label]}),e[16]=C,e[17]=Y,e[18]=I):I=e[18];let A;e[19]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=A):A=e[19];let w;e[20]!==I?(w=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[I,A]}),e[20]=I,e[21]=w):w=e[21];let k;e[22]!==t.workflowName?(k=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=k):k=e[23];let $;e[24]!==t.summary?($=t.summary&&s.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=$):$=e[25];let _;e[26]!==w||e[27]!==k||e[28]!==$?(_=s.jsxs("div",{className:"min-w-0",children:[w,k,$]}),e[26]=w,e[27]=k,e[28]=$,e[29]=_):_=e[29];let O;e[30]!==N||e[31]!==W||e[32]!==o||e[33]!==i||e[34]!==n?(O=N&&i&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:o?"destructive":"outline",size:"sm",disabled:!W||n,onClick:i,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),o?"Confirm stop":"Stop workflow"]}),!W&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=N,e[31]=W,e[32]=o,e[33]=i,e[34]=n,e[35]=O):O=e[35];let P;e[36]!==_||e[37]!==O?(P=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,O]}),e[36]=_,e[37]=O,e[38]=P):P=e[38];const z=`${t.agentCounts.done+t.agentCounts.error}/${t.agentCount}`;let M;e[39]!==z?(M=s.jsx(ge,{icon:At,value:z,label:"Agents finished"}),e[39]=z,e[40]=M):M=e[40];const G=String(t.phaseCount);let V;e[41]!==G?(V=s.jsx(ge,{icon:Wt,value:G,label:"Phases"}),e[41]=G,e[42]=V):V=e[42];let E;e[43]!==t.totalTokens?(E=Ke(t.totalTokens),e[43]=t.totalTokens,e[44]=E):E=e[44];let L;e[45]!==E?(L=s.jsx(ge,{icon:Ge,value:E,label:"Tokens"}),e[45]=E,e[46]=L):L=e[46];const ee=String(t.totalToolCalls);let H;e[47]!==ee?(H=s.jsx(ge,{icon:et,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=H):H=e[48];let K;e[49]!==t.durationMs?(K=typeof t.durationMs=="number"?Qe(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=K):K=e[50];let te;e[51]!==K?(te=s.jsx(ge,{icon:tt,value:K,label:"Duration",className:"col-span-2 sm:col-span-1"}),e[51]=K,e[52]=te):te=e[52];let F;e[53]!==M||e[54]!==V||e[55]!==L||e[56]!==H||e[57]!==te?(F=s.jsxs("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border sm:grid-cols-5",children:[M,V,L,H,te]}),e[53]=M,e[54]=V,e[55]=L,e[56]=H,e[57]=te,e[58]=F):F=e[58];let D;e[59]!==R?(D=Math.round(R*100),e[59]=R,e[60]=D):D=e[60];let U;e[61]!==D?(U=s.jsx(jt,{value:D,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=D,e[62]=U):U=e[62];let B;e[63]!==R?(B=Math.round(R*100),e[63]=R,e[64]=B):B=e[64];let J;e[65]!==B?(J=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[B,"%"]}),e[65]=B,e[66]=J):J=e[66];let q;e[67]!==U||e[68]!==J?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,J]}),e[67]=U,e[68]=J,e[69]=q):q=e[69],e[70]!==P||e[71]!==F||e[72]!==q?(f=s.jsxs("section",{className:"flex flex-col gap-4",children:[P,F,q]}),e[70]=P,e[71]=F,e[72]=q,e[73]=f):f=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Ze,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Xe,{children:s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs",children:t.error})})]}),e[74]=t.error,e[75]=h):h=e[75],e[76]!==t.resultPreview||e[77]!==t.runId||e[78]!==r||e[79]!==a?(p=t.resultPreview&&s.jsx(ns,{preview:t.resultPreview,dirName:r,sessionId:a,runId:t.runId}),e[76]=t.resultPreview,e[77]=t.runId,e[78]=r,e[79]=a,e[80]=p):p=e[80],m="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let Q;e[81]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=Q):Q=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-popover p-2 md:block","aria-label":"Workflow phases",children:[Q,s.jsx("div",{className:"flex flex-col gap-1",children:v.map(ts)})]}),u="flex min-w-0 flex-col gap-8";let Z;e[82]!==t.runId||e[83]!==r||e[84]!==a?(Z=se=>s.jsx(ss,{group:se,dirName:r,sessionId:a,runId:t.runId},`${se.index}-${se.title}`),e[82]=t.runId,e[83]=r,e[84]=a,e[85]=Z):Z=e[85],d=v.map(Z),e[0]=o,e[1]=t,e[2]=r,e[3]=i,e[4]=a,e[5]=n,e[6]=u,e[7]=d,e[8]=m,e[9]=c,e[10]=x,e[11]=f,e[12]=h,e[13]=p}else u=e[6],d=e[7],m=e[8],c=e[9],x=e[10],f=e[11],h=e[12],p=e[13];let g;e[86]!==u||e[87]!==d?(g=s.jsx("div",{className:u,children:d}),e[86]=u,e[87]=d,e[88]=g):g=e[88];let j;e[89]!==m||e[90]!==c||e[91]!==g?(j=s.jsxs("div",{className:m,children:[c,g]}),e[89]=m,e[90]=c,e[91]=g,e[92]=j):j=e[92];let b;e[93]!==t.script?(b=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=b):b=e[94];let S;return e[95]!==j||e[96]!==b||e[97]!==x||e[98]!==f||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:x,children:[f,h,p,j,b]}),e[95]=j,e[96]=b,e[97]=x,e[98]=f,e[99]=h,e[100]=p,e[101]=S):S=e[101],S}function ts(l){return s.jsxs(ne,{variant:"ghost",size:"sm",type:"button",onClick:()=>{var e;return(e=document.getElementById(`workflow-phase-${l.index}`))==null?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-xs font-medium text-foreground",children:l.index}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.title}),s.jsx("span",{className:"tabular-nums",children:l.agents.length})]},`${l.index}-${l.title}`)}function ge(l){const e=X.c(15),{icon:t,value:r,label:a,className:n}=l;let o;e[0]!==n?(o=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=o):o=e[1];let i;e[2]!==t?(i=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=i):i=e[3];let u;e[4]!==r?(u=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=u):u=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let m;e[8]!==u||e[9]!==d?(m=s.jsxs("div",{className:"min-w-0",children:[u,d]}),e[8]=u,e[9]=d,e[10]=m):m=e[10];let c;return e[11]!==o||e[12]!==i||e[13]!==m?(c=s.jsxs("div",{className:o,children:[i,m]}),e[11]=o,e[12]=i,e[13]=m,e[14]=c):c=e[14],c}function ss(l){const e=X.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let o;e[0]!==t.agents?(o=t.agents.filter(ls),e[0]=t.agents,e[1]=o):o=e[1];const i=o.length,u=`workflow-phase-${t.index}`;let d;e[2]!==t.index?(d=s.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary text-xs font-semibold text-primary-foreground",children:t.index}),e[2]=t.index,e[3]=d):d=e[3];let m;e[4]!==t.title?(m=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=m):m=e[5];let c;e[6]!==i||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[i,"/",t.agents.length," complete"]}),e[6]=i,e[7]=t.agents.length,e[8]=c):c=e[8];let x;e[9]!==m||e[10]!==c?(x=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[m,c]}),e[9]=m,e[10]=c,e[11]=x):x=e[11];let f;e[12]!==t.detail?(f=t.detail&&s.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.detail}),e[12]=t.detail,e[13]=f):f=e[13];let h;e[14]!==x||e[15]!==f?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[x,f]}),e[14]=x,e[15]=f,e[16]=h):h=e[16];let p;e[17]!==d||e[18]!==h?(p=s.jsxs("div",{className:"mb-3 flex items-start gap-3",children:[d,h]}),e[17]=d,e[18]=h,e[19]=p):p=e[19];let g;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(g=t.agents.length===0?s.jsx(ze,{className:"border py-6",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"No agents yet"}),s.jsx(Oe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(b=>s.jsx(Gt,{agent:b,dirName:r,sessionId:a,runId:n},`${n}:${b.agentId||b.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=g):g=e[24];let j;return e[25]!==g||e[26]!==u||e[27]!==p?(j=s.jsxs("section",{id:u,className:"scroll-mt-4",children:[p,g]}),e[25]=g,e[26]=u,e[27]=p,e[28]=j):j=e[28],j}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=T.useState(!0),[o,i]=T.useState(),[u,d]=T.useState(!1),[m,c]=T.useState(!1),[x,f]=He(),h=l.endsWith("…"),p=o??l,g=T.useCallback(async()=>{d(!0),c(!1);try{const j=await Re(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!j.ok){c(!0);return}const b=await j.json();i(b.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Le,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Fe,{className:"py-4",children:[s.jsxs(Ce,{className:"group flex min-w-0 items-center gap-3 text-left outline-none",children:[s.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:s.jsx(zt,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx(De,{children:"Workflow outcome"}),s.jsx(ht,{children:"The synthesized answer from this run"})]}),s.jsx(Ie,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"})]}),s.jsxs(gt,{className:"flex items-center gap-1",children:[h&&o===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:u,onClick:()=>void g(),children:[u&&s.jsx(je,{"data-icon":"inline-start"}),m?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>f(Je(p)),"aria-label":x?"Outcome copied":"Copy outcome",title:x?"Copied":"Copy outcome",children:x?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(Ue,{}),s.jsx(Be,{className:"py-5",children:s.jsx(Me,{value:p})})]})]})})}function as(l){const e=X.c(7),{script:t}=l,[r,a]=T.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Fe,{className:"px-0 py-0",children:s.jsxs(Ce,{className:"group flex w-full items-center gap-2 px-3 py-3 text-left text-sm font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/40 hover:text-foreground",children:[s.jsx(Ot,{className:"size-4"}),s.jsx(De,{children:"Orchestration script"}),s.jsx(Ie,{className:"ml-auto size-4 transition-transform group-data-panel-open:rotate-180"})]})}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ue,{}),e[1]=o):o=e[1];let i;e[2]!==t?(i=s.jsxs(Le,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[o,s.jsx(Be,{className:"py-3",children:s.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs leading-relaxed text-muted-foreground",children:t})})]})]}),e[2]=t,e[3]=i):i=e[3];let u;return e[4]!==r||e[5]!==i?(u=s.jsx(Se,{open:r,onOpenChange:a,children:i}),e[4]=r,e[5]=i,e[6]=u):u=e[6],u}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,canStop:o,onRefetchList:i}){var A;const[u,d]=T.useState(null),[m,c]=T.useState(!1),[x,f]=T.useState(null),[h,p]=T.useState(!1),[g,j]=T.useState(!1),[b,S]=T.useState(!1),[C,y]=T.useState(null),N=T.useRef(0),v=m?null:u&&a.some(w=>w.runId===u)?u:((A=a[0])==null?void 0:A.runId)??null,R=T.useCallback(async()=>{const w=++N.current;if(!t||!r||!v){f(null);return}try{const k=await Re(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(v)}`);if(!k.ok){w===N.current&&f(null);return}const $=await k.json();w===N.current&&f($)}catch{w===N.current&&f(null)}finally{w===N.current&&p(!1)}},[t,r,v]);T.useEffect(()=>{if(!v){f(null);return}f(null),p(!0),S(!1),y(null),R()},[v,R]),bt(l?t:null,l?r:null,l?v:null,()=>{R(),i()});const W=T.useCallback(async()=>{if(!b){S(!0);return}if(!(!r||!v)){j(!0),y(null);try{const k=await(await Re("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:v})})).json().catch(()=>({}));k!=null&&k.success?y("Stop signal sent."):(k==null?void 0:k.controllable)===!1?y("This workflow runs in a session Cogpit doesn't control."):y("Couldn't stop. The session may have already exited."),R(),i()}catch{y("Stop request failed.")}finally{j(!1),S(!1)}}},[b,r,v,R,i]),Y=a.length>1,I=a.find(w=>w.runId===v);return s.jsx(Nt,{open:l,onOpenChange:e,children:s.jsxs(wt,{side:"right",className:"w-full data-[side=right]:max-w-[1120px]",children:[s.jsx(yt,{className:"min-h-14 justify-center border-b py-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 pr-9",children:[s.jsxs(vt,{className:"flex items-center gap-2",children:[s.jsx(Ye,{className:"size-4"}),"Workflows",a.length>0&&s.jsx(pe,{variant:"secondary",children:a.length}),n&&s.jsxs(pe,{variant:"outline",className:"border-info/30 text-info",children:[s.jsx(kt,{className:"size-1.5"}),"Live"]})]}),s.jsx(St,{className:"sr-only",children:"Inspect workflow runs, agent progress, and run controls for this session."}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Refresh workflows",title:"Refresh workflows",children:s.jsx(Pt,{"data-icon":"inline-start"})})]})}),s.jsx(Ct,{className:"h-[calc(100dvh-3.5rem)]",children:s.jsx("div",{className:"px-5 py-6 sm:px-6",children:a.length===0?s.jsx(ze,{className:"min-h-[60dvh]",children:s.jsxs(Ae,{children:[s.jsx(Tt,{variant:"icon",children:s.jsx(Ye,{})}),s.jsx(We,{children:"No workflows in this session"}),s.jsx(Oe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[Y&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[v&&x&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>c(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Mt,{"data-icon":"inline-start"}),"All runs"]}),(!v||!x)&&a.map(w=>s.jsx(rs,{workflow:w,active:w.runId===v,onClick:()=>{d(w.runId),c(!1)}},w.runId))]}),h&&!x?s.jsxs("div",{className:"flex min-h-[50dvh] items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading workflow…"]}):x?s.jsxs(s.Fragment,{children:[C&&s.jsx(Ze,{className:"mb-4",children:s.jsx(Xe,{children:C})}),s.jsx(es,{detail:x,dirName:t??"",sessionId:r??"",stopping:g,confirming:b,onForceStop:o?W:void 0})]}):I?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Oe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=X.c(45),{workflow:t,active:r,onClick:a}=l;let n,o,i,u,d,m,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){i=nt(t.status),o=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",m=a;const N=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==N?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",N),e[12]=N,e[13]=c):c=e[13],u=le("size-2 shrink-0 rounded-full",i.dot),e[0]=r,e[1]=a,e[2]=t.agentCounts.done,e[3]=t.agentCounts.error,e[4]=t.status,e[5]=n,e[6]=o,e[7]=i,e[8]=u,e[9]=d,e[10]=m,e[11]=c}else n=e[5],o=e[6],i=e[7],u=e[8],d=e[9],m=e[10],c=e[11];let x;e[14]!==u?(x=s.jsx("span",{className:u}),e[14]=u,e[15]=x):x=e[15];let f;e[16]!==t.workflowName?(f=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=f):f=e[17];let h;e[18]!==i.badge||e[19]!==i.label?(h=s.jsx(pe,{variant:"outline",className:i.badge,children:i.label}),e[18]=i.badge,e[19]=i.label,e[20]=h):h=e[20];let p;e[21]!==f||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[f,h]}),e[21]=f,e[22]=h,e[23]=p):p=e[23];let g;e[24]!==t.summary?(g=t.summary&&s.jsx("p",{className:"mt-1 line-clamp-1 text-xs text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=g):g=e[25];let j;e[26]!==o||e[27]!==t.agentCount?(j=s.jsxs("span",{children:[o,"/",t.agentCount," agents"]}),e[26]=o,e[27]=t.agentCount,e[28]=j):j=e[28];let b;e[29]!==t.startTime?(b=t.startTime>0&&s.jsx("span",{children:Rt(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=b):b=e[30];let S;e[31]!==j||e[32]!==b?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[j,b]}),e[31]=j,e[32]=b,e[33]=S):S=e[33];let C;e[34]!==S||e[35]!==p||e[36]!==g?(C=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,g,S]}),e[34]=S,e[35]=p,e[36]=g,e[37]=C):C=e[37];let y;return e[38]!==n||e[39]!==C||e[40]!==d||e[41]!==m||e[42]!==c||e[43]!==x?(y=s.jsxs(n,{variant:d,onClick:m,className:c,children:[x,C]}),e[38]=n,e[39]=C,e[40]=d,e[41]=m,e[42]=c,e[43]=x,e[44]=y):y=e[44],y}export{ms as WorkflowsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as x,j as e}from"./vendor-react-gGw_S5I_.js";import{Y as K,B as h,J as E,l as V,L as _,M as ee,N as se,O as ae,Q as ne,Z as re,_ as C,$ as te,a0 as ie,a1 as oe,a2 as S,a3 as le,a4 as ce,a5 as U,a6 as F,a7 as T,a8 as de,a9 as $,aa as P,ab as O,ac as I,ad as M,U as p,ae as d}from"./index-CPTFl4Qh.js";import{G as b,i as he,a as me,X as xe,b as ue,j as pe,k as B,C as ge,F as je}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function y(l){return l.commitsAhead>0&&(!l.branch||C(l.name,l.branch))}const fe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function Ne({worktrees:l,loading:g,dirName:t,onRefetch:j,onOpenSession:J,onClose:L}){const c=K("hostFiles"),[W,N]=x.useState(null),[G,w]=x.useState(null),[H,u]=x.useState(!1),[n,m]=x.useState(null),[r,f]=x.useState(null),D=async s=>{if(!(!c||!t)){N(s.name);try{const a=await p(`/api/worktrees/${encodeURIComponent(t)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})});if(!a.ok){const{error:i}=await a.json().catch(()=>({error:void 0}));throw new Error(i??`HTTP ${a.status}`)}j()}catch(a){d.error(`Failed to delete worktree: ${a instanceof Error?a.message:"Unknown error"}`)}finally{N(null)}}},q=s=>{if(!(!c||!t)){if(s.isDirty){m({worktree:s,reason:"dirty"});return}if(y(s)){m({worktree:s,reason:"unpushed"});return}D(s)}},Q=()=>{if(!n)return;const{worktree:s,reason:a}=n;if(a==="dirty"&&y(s)){m({worktree:s,reason:"unpushed"});return}m(null),D(s)},X=async s=>{if(!(!c||!t)){w(s.name);try{const a=await p(`/api/worktrees/${encodeURIComponent(t)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(a.ok){const i=await a.json();i.url?window.open(i.url,"_blank","noopener,noreferrer"):d.warning("PR created but no URL was returned")}else{const i=await a.json().catch(()=>({error:"Unknown error"}));d.error(`Failed to create PR: ${i.error||"Unknown error"}`)}}catch(a){d.error(`Error creating PR: ${a instanceof Error?a.message:"Unknown error"}`)}finally{w(null)}}},Y=async()=>{if(!(!c||!t)){u(!0);try{const s=await p(`/api/worktrees/${encodeURIComponent(t)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:a}=await s.json();a.length===0?d.info("No stale worktrees found"):f(a.map(i=>i.name))}}catch(s){d.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{u(!1)}}},Z=async()=>{if(!c||!t||!r)return;const s=r;f(null),u(!0);try{await p(`/api/worktrees/${encodeURIComponent(t)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(a){d.error(`Cleanup failed: ${a instanceof Error?a.message:"Unknown error"}`)}finally{u(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{"aria-label":"Worktrees",className:"flex size-full min-h-0 flex-col bg-canvas",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsx(b,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Worktrees"}),e.jsx("div",{className:"flex-1"}),c&&e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:Y,disabled:H,"aria-label":"Cleanup stale worktrees",children:e.jsx(he,{"data-icon":"inline-start"})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:j,disabled:g,"aria-label":"Refresh worktrees",children:e.jsx(me,{"data-icon":"inline-start",className:E(g&&"animate-spin")})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:L,"aria-label":"Close worktrees",children:e.jsx(xe,{"data-icon":"inline-start"})})]}),e.jsx(V,{}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!t&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),t&&l.length===0&&!g&&e.jsx(_,{className:"border-0 py-16",children:e.jsxs(ee,{children:[e.jsx(se,{variant:"icon",children:e.jsx(b,{})}),e.jsx(ae,{children:"No worktrees"}),e.jsx(ne,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),l.map(s=>{var A,z,R;const a=((A=s.changedFiles)==null?void 0:A.reduce((o,v)=>o+v.additions,0))??0,i=((z=s.changedFiles)==null?void 0:z.reduce((o,v)=>o+v.deletions,0))??0,k=((R=s.changedFiles)==null?void 0:R.length)??0;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 transition-colors hover:bg-accent/40",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.isDirty&&e.jsx("span",{className:"flex size-2 shrink-0 rounded-full bg-warning",title:"Uncommitted changes"}),s.commitsAhead>0&&e.jsxs(re,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[s.linkedSessions.length>0&&e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>J(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(ue,{"data-icon":"inline-start"})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>X(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(pe,{"data-icon":"inline-start"})}),e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:W===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(B,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"shrink-0 font-mono",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),(s.createdAt||!C(s.name,s.branch))&&e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[!C(s.name,s.branch)&&e.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(b,{className:"size-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:s.branch||"detached"})]}),s.createdAt&&e.jsx("span",{className:"shrink-0",children:te(s.createdAt)})]}),k>0&&e.jsxs(ie,{className:"mt-2",children:[e.jsxs("div",{className:"relative flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsxs(oe,{className:"group flex items-center gap-1.5 after:absolute after:inset-0",children:[e.jsx(ge,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(je,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[k," file",k!==1?"s":""," changed"]})]}),e.jsx(S,{add:a,del:i,breakdown:le(s.changedFiles),className:"relative ml-1"})]}),e.jsx(ce,{children:e.jsx("div",{className:"mt-1.5 flex flex-col gap-px rounded-md bg-muted/40 p-1.5",children:s.changedFiles.map(o=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:E("shrink-0 w-3 text-center",fe[o.status]??"text-muted-foreground"),children:o.status}),e.jsx("span",{className:"truncate text-foreground/80",children:o.path}),e.jsx(S,{add:o.additions,del:o.deletions,className:"ml-auto text-muted-foreground"})]},o.path))})})]})]},s.name)})]})]}),e.jsx(U,{open:n!==null,onOpenChange:s=>{s||m(null)},children:e.jsxs(F,{size:"sm",children:[e.jsxs(T,{children:[e.jsx(de,{className:"bg-destructive/10 text-destructive",children:e.jsx(B,{})}),e.jsx($,{children:(n==null?void 0:n.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(P,{children:[(n==null?void 0:n.reason)==="dirty"?`"${n.worktree.name}" has uncommitted changes.`:`"${n==null?void 0:n.worktree.name}" has ${n==null?void 0:n.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(O,{children:[e.jsx(I,{size:"sm",children:"Cancel"}),e.jsx(M,{variant:"destructive",size:"sm",onClick:Q,children:(n==null?void 0:n.reason)==="dirty"&&y(n.worktree)?"Continue":"Delete worktree"})]})]})}),e.jsx(U,{open:r!==null,onOpenChange:s=>{s||f(null)},children:e.jsxs(F,{children:[e.jsxs(T,{children:[e.jsx($,{children:"Remove stale worktrees?"}),e.jsxs(P,{children:[r==null?void 0:r.length," stale worktree",(r==null?void 0:r.length)===1?"":"s"," will be removed: ",r==null?void 0:r.join(", "),"."]})]}),e.jsxs(O,{children:[e.jsx(I,{size:"sm",children:"Cancel"}),e.jsx(M,{variant:"destructive",size:"sm",onClick:()=>void Z(),children:"Remove worktrees"})]})]})})]})}export{Ne as WorktreePanel};
|