cogpit 2.1.2 → 2.1.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.
Files changed (19) hide show
  1. package/dist/cli.js +46 -1
  2. package/dist/web/assets/{CommandPaletteHost-Bq0_FFr0.js → CommandPaletteHost-1UPdv9Nv.js} +1 -1
  3. package/dist/web/assets/{ConfigBrowser-DmOlS3cU.js → ConfigBrowser-B5lZsJDw.js} +1 -1
  4. package/dist/web/assets/{HighlightedEditor-BYfv1SYX.js → HighlightedEditor-qhEWgnBF.js} +1 -1
  5. package/dist/web/assets/{KeyboardShortcutsDialog-YDYAOpa5.js → KeyboardShortcutsDialog-B9nMtf5U.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-Bb3zEFSH.js → MobileFileChanges-j9DCxvz6.js} +1 -1
  7. package/dist/web/assets/{PreviewPanel-B9CQNmuh.js → PreviewPanel-DZSVN3mt.js} +1 -1
  8. package/dist/web/assets/{ProjectFilesPanel-C3jKD37-.js → ProjectFilesPanel-DSvO4CrB.js} +1 -1
  9. package/dist/web/assets/{ProjectSwitcherModal-CxbGrX7A.js → ProjectSwitcherModal-o8NhzySH.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-LwRcBZWA.js → TerminalOutput-CcWkSv29.js} +1 -1
  11. package/dist/web/assets/{ThemeSelectorModal-BG_Jah0i.js → ThemeSelectorModal-CnbSCgJj.js} +1 -1
  12. package/dist/web/assets/{WorkflowsPanel-CiZjrfSd.js → WorkflowsPanel-CvBweQMf.js} +1 -1
  13. package/dist/web/assets/{WorktreePanel-gR-fCesa.js → WorktreePanel-DahbK2L0.js} +1 -1
  14. package/dist/web/assets/{index-C_pb6rZe.js → index-7UiltNKa.js} +1 -1
  15. package/dist/web/assets/{index-D-Mg0tNr.js → index-BESnPMZk.js} +68 -68
  16. package/dist/web/assets/{index-BaKcHvT2.js → index-DXTQExVH.js} +1 -1
  17. package/dist/web/assets/{index-EmT8Vg0x.js → index-_0HhakEy.js} +1 -1
  18. package/dist/web/index.html +1 -1
  19. package/package.json +1 -1
@@ -1 +1 @@
1
- import{c as G,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{U as le,aR as mt,aS as ft,aT as xt,aU as He,V as pe,aV as Ke,ai as je,X as Se,Y as Ce,B as ne,Z as Te,w as Re,aP as Ee,aL as Le,aM as Fe,l as De,aN as Ue,A as Xe,aW as pt,p as Ze,aX as ht,aY as gt,aZ as jt,E as ze,y as Ae,G as We,H as Pe,a_ as bt,d as Nt,c as wt,S as yt,a as vt,a$ as kt,b as St,q as Ct,z as Tt,W as Rt}from"./index-D-Mg0tNr.js";import{M as It}from"./vendor-markdown-BE1gYnO9.js";import{a5 as Ge,a6 as Qe,a7 as et,a8 as $t,a9 as Ie,R as _t,O as tt,D as st,aa as qe,b as zt,ab as At,ac as Wt,J as Pt,ad as Ye,c as Ot,a4 as Mt}from"./vendor-ui-Bg9q4lA4.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 lt(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 i=n+1;e.set(i,{index:i,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,i)=>n.index-i.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}function nt(l){return l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}k`:`${l}`}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function Be(l){return typeof l=="object"&&l!==null&&!Array.isArray(l)}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(Be(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=G.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=G.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 i;return e[3]!==n?(i=s.jsx("span",{children:n}),e[3]=n,e[4]=i):i=e[4],i}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 Oe(l){const e=G.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Be(t)&&!Array.isArray(t)){let i;return e[0]!==t?(i=s.jsx(ot,{value:t}),e[0]=t,e[1]=i):i=e[1],i}if(a>5){let i;e[2]!==t?(i=Je(t),e[2]=t,e[3]=i):i=e[3];let o;return e[4]!==i?(o=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=o):o=e[5],o}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(Xt)){let d;e[7]!==t?(d=t.map(Kt),e[7]=t,e[8]=d):d=e[8];let u;return e[9]!==d?(u=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=u):u=e[10],u}let o;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(u,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Oe,{value:u,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],o=t.map(d),e[11]=a,e[12]=t,e[13]=o}else o=e[13];let m;return e[16]!==o?(m=s.jsx("div",{className:"flex flex-col gap-3",children:o}),e[16]=o,e[17]=m):m=e[17],m}let n;if(e[18]!==a||e[19]!==t){const i=Object.entries(t),o=i.find(Ht),m=i.filter(d=>{const[u]=d;return u!==(o==null?void 0:o[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[o&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:o[1]}),m.map(d=>{const[u,c]=d;return c===void 0?null:Jt.has(u)&&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})},u):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(u)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Oe,{value:c,depth:a+1})})]},u)})]}),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 Xt(l){return!Be(l)&&!Array.isArray(l)}function Me(l){const e=G.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 u;e[2]!==n?(u=$e(n),e[2]=n,e[3]=u):u=e[3];const c=u;let f;e[4]!==r?(f=le("flex flex-col gap-2",r),e[4]=r,e[5]=f):f=e[5];let x;e[6]!==c?(x=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=x):x=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]!==f||e[10]!==x?(p=s.jsxs("div",{className:f,children:[x,h]}),e[9]=f,e[10]=x,e[11]=p):p=e[11],p}let o;e[12]!==r?(o=le("min-w-0 text-sm",r),e[12]=r,e[13]=o):o=e[13];let m;e[14]!==n?(m=s.jsx(Oe,{value:n}),e[14]=n,e[15]=m):m=e[15];let d;return e[16]!==o||e[17]!==m?(d=s.jsx("div",{className:o,children:m}),e[16]=o,e[17]=m,e[18]=d):d=e[18],d}function Zt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Gt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Qt(l){const e=G.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[i,o]=C.useState(!1),[m,d]=C.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},e[0]=u):u=e[0];const[c,f]=C.useState(u),[x,h]=He();let p,j,b,N,S,w,v,g,T,I,A,Y,R,y,k,$,W,_,P,O,z;if(e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){T=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],g=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()=>{f({status:"loading"});try{const he=await Re(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){f({status:"unavailable"});return}const ut=await he.json();f({status:"loaded",value:ut.result})}catch{f({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],v=ve;let ke;e[38]!==t.state||e[39]!==v||e[40]!==c.status?(ke=he=>{o(he),he&&c.status==="idle"&&Ve(t.state)&&v()},e[38]=t.state,e[39]=v,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,w=c.status==="unavailable",S=Se,A=i,Y=ct,N=Ee,O="sm",I="motion-card motion-list-item gap-0 py-0",b=Le,P="px-0 py-0",j=Ce,$="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",W=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",T.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Gt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(Fe,{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]!==g||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}):g&&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]=g,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:[nt(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:Qe,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:et,children:Ke(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],k="flex shrink-0 items-center gap-2",p=pe,R="outline",y=le("hidden sm:inline-flex",T.badge),e[1]=t,e[2]=r,e[3]=i,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=j,e[10]=b,e[11]=N,e[12]=S,e[13]=w,e[14]=v,e[15]=g,e[16]=T,e[17]=I,e[18]=A,e[19]=Y,e[20]=R,e[21]=y,e[22]=k,e[23]=$,e[24]=W,e[25]=_,e[26]=P,e[27]=O,e[28]=z}else p=e[8],j=e[9],b=e[10],N=e[11],S=e[12],w=e[13],v=e[14],g=e[15],T=e[16],I=e[17],A=e[18],Y=e[19],R=e[20],y=e[21],k=e[22],$=e[23],W=e[24],_=e[25],P=e[26],O=e[27],z=e[28];let M;e[74]!==g?(M=g&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=g,e[75]=M):M=e[75];let Q;e[76]!==p||e[77]!==T.label||e[78]!==M||e[79]!==R||e[80]!==y?(Q=s.jsxs(p,{variant:R,className:y,children:[M,T.label]}),e[76]=p,e[77]=T.label,e[78]=M,e[79]=R,e[80]=y,e[81]=Q):Q=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]!==Q||e[84]!==k?(E=s.jsxs("div",{className:k,children:[Q,V]}),e[83]=Q,e[84]=k,e[85]=E):E=e[85];let L;e[86]!==j||e[87]!==E||e[88]!==$||e[89]!==W||e[90]!==_?(L=s.jsxs(j,{className:$,children:[W,_,E]}),e[86]=j,e[87]=E,e[88]=$,e[89]=W,e[90]=_,e[91]=L):L=e[91];let ee;e[92]!==b||e[93]!==L||e[94]!==P?(ee=s.jsx(b,{className:P,children:L}),e[92]=b,e[93]=L,e[94]=P,e[95]=ee):ee=e[95];let H;e[96]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(De,{}),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]!==w||e[101]!==v?(D=w&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void v(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=w,e[101]=v,e[102]=D):D=e[102];let U;e[103]!==x||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":x?"Response copied":"Copy response",title:x?"Copied":"Copy response",children:x?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})}),e[103]=x,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]!==g||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:g?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=g,e[115]=z,e[116]=q):q=e[116];let X;e[117]!==t.promptPreview||e[118]!==m?(X=t.promptPreview&&s.jsxs(Se,{open:m,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",m&&"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]=m,e[119]=X):X=e[119];let Z;e[120]!==J||e[121]!==q||e[122]!==X?(Z=s.jsxs(Te,{children:[H,s.jsxs(Ue,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,X]})]}),e[120]=J,e[121]=q,e[122]=X,e[123]=Z):Z=e[123];let se;e[124]!==N||e[125]!==I||e[126]!==ee||e[127]!==Z||e[128]!==O?(se=s.jsxs(N,{size:O,className:I,children:[ee,Z]}),e[124]=N,e[125]=I,e[126]=ee,e[127]=Z,e[128]=O,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:Y,children:se}),e[130]=S,e[131]=A,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=G.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=G.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:i,onForceStop:o}=l;let m,d,u,c,f,x,h,p;if(e[0]!==i||e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==a||e[5]!==n){const w=lt(t.status);let v;e[14]!==t.status?(v=Lt(t.status),e[14]=t.status,e[15]=v):v=e[15];const g=v,T=Dt(t),I=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const Y=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let R;e[16]!==w||e[17]!==Y?(R=s.jsxs(pe,{variant:"outline",className:w.badge,children:[Y,w.label]}),e[16]=w,e[17]=Y,e[18]=R):R=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=y):y=e[19];let k;e[20]!==R?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[R,y]}),e[20]=R,e[21]=k):k=e[21];let $;e[22]!==t.workflowName?($=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=$):$=e[23];let W;e[24]!==t.summary?(W=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]=W):W=e[25];let _;e[26]!==k||e[27]!==$||e[28]!==W?(_=s.jsxs("div",{className:"min-w-0",children:[k,$,W]}),e[26]=k,e[27]=$,e[28]=W,e[29]=_):_=e[29];let P;e[30]!==g||e[31]!==A||e[32]!==i||e[33]!==o||e[34]!==n?(P=g&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:i?"destructive":"outline",size:"sm",disabled:!A||n,onClick:o,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),i?"Confirm stop":"Stop workflow"]}),!A&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=g,e[31]=A,e[32]=i,e[33]=o,e[34]=n,e[35]=P):P=e[35];let O;e[36]!==_||e[37]!==P?(O=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,P]}),e[36]=_,e[37]=P,e[38]=O):O=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 Q=String(t.phaseCount);let V;e[41]!==Q?(V=s.jsx(ge,{icon:Wt,value:Q,label:"Phases"}),e[41]=Q,e[42]=V):V=e[42];let E;e[43]!==t.totalTokens?(E=nt(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:Qe,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"?Ke(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=K):K=e[50];let te;e[51]!==K?(te=s.jsx(ge,{icon:et,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]!==I?(D=Math.round(I*100),e[59]=I,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]!==I?(B=Math.round(I*100),e[63]=I,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]!==O||e[71]!==F||e[72]!==q?(x=s.jsxs("section",{className:"flex flex-col gap-4",children:[O,F,q]}),e[70]=O,e[71]=F,e[72]=q,e[73]=x):x=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Xe,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Ze,{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],u="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let X;e[81]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=X):X=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-card p-2 md:block","aria-label":"Workflow phases",children:[X,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="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=T.map(Z),e[0]=i,e[1]=t,e[2]=r,e[3]=o,e[4]=a,e[5]=n,e[6]=m,e[7]=d,e[8]=u,e[9]=c,e[10]=f,e[11]=x,e[12]=h,e[13]=p}else m=e[6],d=e[7],u=e[8],c=e[9],f=e[10],x=e[11],h=e[12],p=e[13];let j;e[86]!==m||e[87]!==d?(j=s.jsx("div",{className:m,children:d}),e[86]=m,e[87]=d,e[88]=j):j=e[88];let b;e[89]!==u||e[90]!==c||e[91]!==j?(b=s.jsxs("div",{className:u,children:[c,j]}),e[89]=u,e[90]=c,e[91]=j,e[92]=b):b=e[92];let N;e[93]!==t.script?(N=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=N):N=e[94];let S;return e[95]!==b||e[96]!==N||e[97]!==f||e[98]!==x||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:f,children:[x,h,p,b,N]}),e[95]=b,e[96]=N,e[97]=f,e[98]=x,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=G.c(15),{icon:t,value:r,label:a,className:n}=l;let i;e[0]!==n?(i=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=o):o=e[3];let m;e[4]!==r?(m=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=m):m=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 u;e[8]!==m||e[9]!==d?(u=s.jsxs("div",{className:"min-w-0",children:[m,d]}),e[8]=m,e[9]=d,e[10]=u):u=e[10];let c;return e[11]!==i||e[12]!==o||e[13]!==u?(c=s.jsxs("div",{className:i,children:[o,u]}),e[11]=i,e[12]=o,e[13]=u,e[14]=c):c=e[14],c}function ss(l){const e=G.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let i;e[0]!==t.agents?(i=t.agents.filter(ls),e[0]=t.agents,e[1]=i):i=e[1];const o=i.length,m=`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 u;e[4]!==t.title?(u=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[o,"/",t.agents.length," complete"]}),e[6]=o,e[7]=t.agents.length,e[8]=c):c=e[8];let f;e[9]!==u||e[10]!==c?(f=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[u,c]}),e[9]=u,e[10]=c,e[11]=f):f=e[11];let x;e[12]!==t.detail?(x=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]=x):x=e[13];let h;e[14]!==f||e[15]!==x?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[f,x]}),e[14]=f,e[15]=x,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 j;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(j=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(Pe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(N=>s.jsx(Qt,{agent:N,dirName:r,sessionId:a,runId:n},`${n}:${N.agentId||N.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=j):j=e[24];let b;return e[25]!==j||e[26]!==m||e[27]!==p?(b=s.jsxs("section",{id:m,className:"scroll-mt-4",children:[p,j]}),e[25]=j,e[26]=m,e[27]=p,e[28]=b):b=e[28],b}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=C.useState(!0),[i,o]=C.useState(),[m,d]=C.useState(!1),[u,c]=C.useState(!1),[f,x]=He(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Re(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!b.ok){c(!0);return}const N=await b.json();o(N.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Ee,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Le,{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(Fe,{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&&i===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:m,onClick:()=>void j(),children:[m&&s.jsx(je,{"data-icon":"inline-start"}),u?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>x(Je(p)),"aria-label":f?"Outcome copied":"Copy outcome",title:f?"Copied":"Copy outcome",children:f?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(De,{}),s.jsx(Ue,{className:"py-5",children:s.jsx(Me,{value:p})})]})]})})}function as(l){const e=G.c(7),{script:t}=l,[r,a]=C.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Le,{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(Pt,{className:"size-4"}),s.jsx(Fe,{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 i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(De,{}),e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsxs(Ee,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[i,s.jsx(Ue,{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]=o):o=e[3];let m;return e[4]!==r||e[5]!==o?(m=s.jsx(Se,{open:r,onOpenChange:a,children:o}),e[4]=r,e[5]=o,e[6]=m):m=e[6],m}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,onRefetchList:i}){var R;const[o,m]=C.useState(null),[d,u]=C.useState(!1),[c,f]=C.useState(null),[x,h]=C.useState(!1),[p,j]=C.useState(!1),[b,N]=C.useState(!1),[S,w]=C.useState(null),v=C.useRef(0),g=d?null:o&&a.some(y=>y.runId===o)?o:((R=a[0])==null?void 0:R.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Re(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(g)}`);if(!k.ok){y===v.current&&f(null);return}const $=await k.json();y===v.current&&f($)}catch{y===v.current&&f(null)}finally{y===v.current&&h(!1)}},[t,r,g]);C.useEffect(()=>{if(!g){f(null);return}f(null),h(!0),N(!1),w(null),T()},[g,T]),bt(l?t:null,l?r:null,l?g:null,()=>{T(),i()});const I=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Re("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:g})})).json().catch(()=>({}));k!=null&&k.success?w("Stop signal sent."):(k==null?void 0:k.controllable)===!1?w("This workflow runs in a session Cogpit doesn't control."):w("Couldn't stop. The session may have already exited."),T(),i()}catch{w("Stop request failed.")}finally{j(!1),N(!1)}}},[b,r,g,T,i]),A=a.length>1,Y=a.find(y=>y.runId===g);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(Ot,{"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(Pe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[A&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[g&&c&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Mt,{"data-icon":"inline-start"}),"All runs"]}),(!g||!c)&&a.map(y=>s.jsx(rs,{workflow:y,active:y.runId===g,onClick:()=>{m(y.runId),u(!1)}},y.runId))]}),x&&!c?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…"]}):c?s.jsxs(s.Fragment,{children:[S&&s.jsx(Xe,{className:"mb-4",children:s.jsx(Ze,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:I})]}):Y?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Pe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=G.c(45),{workflow:t,active:r,onClick:a}=l;let n,i,o,m,d,u,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){o=lt(t.status),i=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",u=a;const g=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==g?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",g),e[12]=g,e[13]=c):c=e[13],m=le("size-2 shrink-0 rounded-full",o.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]=i,e[7]=o,e[8]=m,e[9]=d,e[10]=u,e[11]=c}else n=e[5],i=e[6],o=e[7],m=e[8],d=e[9],u=e[10],c=e[11];let f;e[14]!==m?(f=s.jsx("span",{className:m}),e[14]=m,e[15]=f):f=e[15];let x;e[16]!==t.workflowName?(x=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=x):x=e[17];let h;e[18]!==o.badge||e[19]!==o.label?(h=s.jsx(pe,{variant:"outline",className:o.badge,children:o.label}),e[18]=o.badge,e[19]=o.label,e[20]=h):h=e[20];let p;e[21]!==x||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,h]}),e[21]=x,e[22]=h,e[23]=p):p=e[23];let j;e[24]!==t.summary?(j=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]=j):j=e[25];let b;e[26]!==i||e[27]!==t.agentCount?(b=s.jsxs("span",{children:[i,"/",t.agentCount," agents"]}),e[26]=i,e[27]=t.agentCount,e[28]=b):b=e[28];let N;e[29]!==t.startTime?(N=t.startTime>0&&s.jsx("span",{children:Rt(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=N):N=e[30];let S;e[31]!==b||e[32]!==N?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b,N]}),e[31]=b,e[32]=N,e[33]=S):S=e[33];let w;e[34]!==S||e[35]!==p||e[36]!==j?(w=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,j,S]}),e[34]=S,e[35]=p,e[36]=j,e[37]=w):w=e[37];let v;return e[38]!==n||e[39]!==w||e[40]!==d||e[41]!==u||e[42]!==c||e[43]!==f?(v=s.jsxs(n,{variant:d,onClick:u,className:c,children:[f,w]}),e[38]=n,e[39]=w,e[40]=d,e[41]=u,e[42]=c,e[43]=f,e[44]=v):v=e[44],v}export{ms as WorkflowsPanel};
1
+ import{c as G,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{U as le,aR as mt,aS as ft,aT as xt,aU as He,V as pe,aV as Ke,ai as je,X as Se,Y as Ce,B as ne,Z as Te,w as Re,aP as Ee,aL as Le,aM as Fe,l as De,aN as Ue,A as Xe,aW as pt,p as Ze,aX as ht,aY as gt,aZ as jt,E as ze,y as Ae,G as We,H as Pe,a_ as bt,d as Nt,c as wt,S as yt,a as vt,a$ as kt,b as St,q as Ct,z as Tt,W as Rt}from"./index-BESnPMZk.js";import{M as It}from"./vendor-markdown-BE1gYnO9.js";import{a5 as Ge,a6 as Qe,a7 as et,a8 as $t,a9 as Ie,R as _t,O as tt,D as st,aa as qe,b as zt,ab as At,ac as Wt,J as Pt,ad as Ye,c as Ot,a4 as Mt}from"./vendor-ui-Bg9q4lA4.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 lt(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 i=n+1;e.set(i,{index:i,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,i)=>n.index-i.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}function nt(l){return l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}k`:`${l}`}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function Be(l){return typeof l=="object"&&l!==null&&!Array.isArray(l)}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(Be(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=G.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=G.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 i;return e[3]!==n?(i=s.jsx("span",{children:n}),e[3]=n,e[4]=i):i=e[4],i}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 Oe(l){const e=G.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Be(t)&&!Array.isArray(t)){let i;return e[0]!==t?(i=s.jsx(ot,{value:t}),e[0]=t,e[1]=i):i=e[1],i}if(a>5){let i;e[2]!==t?(i=Je(t),e[2]=t,e[3]=i):i=e[3];let o;return e[4]!==i?(o=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=o):o=e[5],o}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(Xt)){let d;e[7]!==t?(d=t.map(Kt),e[7]=t,e[8]=d):d=e[8];let u;return e[9]!==d?(u=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=u):u=e[10],u}let o;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(u,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Oe,{value:u,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],o=t.map(d),e[11]=a,e[12]=t,e[13]=o}else o=e[13];let m;return e[16]!==o?(m=s.jsx("div",{className:"flex flex-col gap-3",children:o}),e[16]=o,e[17]=m):m=e[17],m}let n;if(e[18]!==a||e[19]!==t){const i=Object.entries(t),o=i.find(Ht),m=i.filter(d=>{const[u]=d;return u!==(o==null?void 0:o[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[o&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:o[1]}),m.map(d=>{const[u,c]=d;return c===void 0?null:Jt.has(u)&&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})},u):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(u)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Oe,{value:c,depth:a+1})})]},u)})]}),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 Xt(l){return!Be(l)&&!Array.isArray(l)}function Me(l){const e=G.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 u;e[2]!==n?(u=$e(n),e[2]=n,e[3]=u):u=e[3];const c=u;let f;e[4]!==r?(f=le("flex flex-col gap-2",r),e[4]=r,e[5]=f):f=e[5];let x;e[6]!==c?(x=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=x):x=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]!==f||e[10]!==x?(p=s.jsxs("div",{className:f,children:[x,h]}),e[9]=f,e[10]=x,e[11]=p):p=e[11],p}let o;e[12]!==r?(o=le("min-w-0 text-sm",r),e[12]=r,e[13]=o):o=e[13];let m;e[14]!==n?(m=s.jsx(Oe,{value:n}),e[14]=n,e[15]=m):m=e[15];let d;return e[16]!==o||e[17]!==m?(d=s.jsx("div",{className:o,children:m}),e[16]=o,e[17]=m,e[18]=d):d=e[18],d}function Zt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Gt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Qt(l){const e=G.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[i,o]=C.useState(!1),[m,d]=C.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},e[0]=u):u=e[0];const[c,f]=C.useState(u),[x,h]=He();let p,j,b,N,S,w,v,g,T,I,A,Y,R,y,k,$,W,_,P,O,z;if(e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){T=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],g=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()=>{f({status:"loading"});try{const he=await Re(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){f({status:"unavailable"});return}const ut=await he.json();f({status:"loaded",value:ut.result})}catch{f({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],v=ve;let ke;e[38]!==t.state||e[39]!==v||e[40]!==c.status?(ke=he=>{o(he),he&&c.status==="idle"&&Ve(t.state)&&v()},e[38]=t.state,e[39]=v,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,w=c.status==="unavailable",S=Se,A=i,Y=ct,N=Ee,O="sm",I="motion-card motion-list-item gap-0 py-0",b=Le,P="px-0 py-0",j=Ce,$="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",W=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",T.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Gt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(Fe,{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]!==g||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}):g&&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]=g,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:[nt(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:Qe,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:et,children:Ke(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],k="flex shrink-0 items-center gap-2",p=pe,R="outline",y=le("hidden sm:inline-flex",T.badge),e[1]=t,e[2]=r,e[3]=i,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=j,e[10]=b,e[11]=N,e[12]=S,e[13]=w,e[14]=v,e[15]=g,e[16]=T,e[17]=I,e[18]=A,e[19]=Y,e[20]=R,e[21]=y,e[22]=k,e[23]=$,e[24]=W,e[25]=_,e[26]=P,e[27]=O,e[28]=z}else p=e[8],j=e[9],b=e[10],N=e[11],S=e[12],w=e[13],v=e[14],g=e[15],T=e[16],I=e[17],A=e[18],Y=e[19],R=e[20],y=e[21],k=e[22],$=e[23],W=e[24],_=e[25],P=e[26],O=e[27],z=e[28];let M;e[74]!==g?(M=g&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=g,e[75]=M):M=e[75];let Q;e[76]!==p||e[77]!==T.label||e[78]!==M||e[79]!==R||e[80]!==y?(Q=s.jsxs(p,{variant:R,className:y,children:[M,T.label]}),e[76]=p,e[77]=T.label,e[78]=M,e[79]=R,e[80]=y,e[81]=Q):Q=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]!==Q||e[84]!==k?(E=s.jsxs("div",{className:k,children:[Q,V]}),e[83]=Q,e[84]=k,e[85]=E):E=e[85];let L;e[86]!==j||e[87]!==E||e[88]!==$||e[89]!==W||e[90]!==_?(L=s.jsxs(j,{className:$,children:[W,_,E]}),e[86]=j,e[87]=E,e[88]=$,e[89]=W,e[90]=_,e[91]=L):L=e[91];let ee;e[92]!==b||e[93]!==L||e[94]!==P?(ee=s.jsx(b,{className:P,children:L}),e[92]=b,e[93]=L,e[94]=P,e[95]=ee):ee=e[95];let H;e[96]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(De,{}),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]!==w||e[101]!==v?(D=w&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void v(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=w,e[101]=v,e[102]=D):D=e[102];let U;e[103]!==x||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":x?"Response copied":"Copy response",title:x?"Copied":"Copy response",children:x?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})}),e[103]=x,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]!==g||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:g?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=g,e[115]=z,e[116]=q):q=e[116];let X;e[117]!==t.promptPreview||e[118]!==m?(X=t.promptPreview&&s.jsxs(Se,{open:m,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",m&&"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]=m,e[119]=X):X=e[119];let Z;e[120]!==J||e[121]!==q||e[122]!==X?(Z=s.jsxs(Te,{children:[H,s.jsxs(Ue,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,X]})]}),e[120]=J,e[121]=q,e[122]=X,e[123]=Z):Z=e[123];let se;e[124]!==N||e[125]!==I||e[126]!==ee||e[127]!==Z||e[128]!==O?(se=s.jsxs(N,{size:O,className:I,children:[ee,Z]}),e[124]=N,e[125]=I,e[126]=ee,e[127]=Z,e[128]=O,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:Y,children:se}),e[130]=S,e[131]=A,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=G.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=G.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:i,onForceStop:o}=l;let m,d,u,c,f,x,h,p;if(e[0]!==i||e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==a||e[5]!==n){const w=lt(t.status);let v;e[14]!==t.status?(v=Lt(t.status),e[14]=t.status,e[15]=v):v=e[15];const g=v,T=Dt(t),I=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const Y=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let R;e[16]!==w||e[17]!==Y?(R=s.jsxs(pe,{variant:"outline",className:w.badge,children:[Y,w.label]}),e[16]=w,e[17]=Y,e[18]=R):R=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=y):y=e[19];let k;e[20]!==R?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[R,y]}),e[20]=R,e[21]=k):k=e[21];let $;e[22]!==t.workflowName?($=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=$):$=e[23];let W;e[24]!==t.summary?(W=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]=W):W=e[25];let _;e[26]!==k||e[27]!==$||e[28]!==W?(_=s.jsxs("div",{className:"min-w-0",children:[k,$,W]}),e[26]=k,e[27]=$,e[28]=W,e[29]=_):_=e[29];let P;e[30]!==g||e[31]!==A||e[32]!==i||e[33]!==o||e[34]!==n?(P=g&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:i?"destructive":"outline",size:"sm",disabled:!A||n,onClick:o,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),i?"Confirm stop":"Stop workflow"]}),!A&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=g,e[31]=A,e[32]=i,e[33]=o,e[34]=n,e[35]=P):P=e[35];let O;e[36]!==_||e[37]!==P?(O=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,P]}),e[36]=_,e[37]=P,e[38]=O):O=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 Q=String(t.phaseCount);let V;e[41]!==Q?(V=s.jsx(ge,{icon:Wt,value:Q,label:"Phases"}),e[41]=Q,e[42]=V):V=e[42];let E;e[43]!==t.totalTokens?(E=nt(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:Qe,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"?Ke(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=K):K=e[50];let te;e[51]!==K?(te=s.jsx(ge,{icon:et,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]!==I?(D=Math.round(I*100),e[59]=I,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]!==I?(B=Math.round(I*100),e[63]=I,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]!==O||e[71]!==F||e[72]!==q?(x=s.jsxs("section",{className:"flex flex-col gap-4",children:[O,F,q]}),e[70]=O,e[71]=F,e[72]=q,e[73]=x):x=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Xe,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Ze,{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],u="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let X;e[81]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=X):X=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-card p-2 md:block","aria-label":"Workflow phases",children:[X,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="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=T.map(Z),e[0]=i,e[1]=t,e[2]=r,e[3]=o,e[4]=a,e[5]=n,e[6]=m,e[7]=d,e[8]=u,e[9]=c,e[10]=f,e[11]=x,e[12]=h,e[13]=p}else m=e[6],d=e[7],u=e[8],c=e[9],f=e[10],x=e[11],h=e[12],p=e[13];let j;e[86]!==m||e[87]!==d?(j=s.jsx("div",{className:m,children:d}),e[86]=m,e[87]=d,e[88]=j):j=e[88];let b;e[89]!==u||e[90]!==c||e[91]!==j?(b=s.jsxs("div",{className:u,children:[c,j]}),e[89]=u,e[90]=c,e[91]=j,e[92]=b):b=e[92];let N;e[93]!==t.script?(N=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=N):N=e[94];let S;return e[95]!==b||e[96]!==N||e[97]!==f||e[98]!==x||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:f,children:[x,h,p,b,N]}),e[95]=b,e[96]=N,e[97]=f,e[98]=x,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=G.c(15),{icon:t,value:r,label:a,className:n}=l;let i;e[0]!==n?(i=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=o):o=e[3];let m;e[4]!==r?(m=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=m):m=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 u;e[8]!==m||e[9]!==d?(u=s.jsxs("div",{className:"min-w-0",children:[m,d]}),e[8]=m,e[9]=d,e[10]=u):u=e[10];let c;return e[11]!==i||e[12]!==o||e[13]!==u?(c=s.jsxs("div",{className:i,children:[o,u]}),e[11]=i,e[12]=o,e[13]=u,e[14]=c):c=e[14],c}function ss(l){const e=G.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let i;e[0]!==t.agents?(i=t.agents.filter(ls),e[0]=t.agents,e[1]=i):i=e[1];const o=i.length,m=`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 u;e[4]!==t.title?(u=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[o,"/",t.agents.length," complete"]}),e[6]=o,e[7]=t.agents.length,e[8]=c):c=e[8];let f;e[9]!==u||e[10]!==c?(f=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[u,c]}),e[9]=u,e[10]=c,e[11]=f):f=e[11];let x;e[12]!==t.detail?(x=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]=x):x=e[13];let h;e[14]!==f||e[15]!==x?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[f,x]}),e[14]=f,e[15]=x,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 j;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(j=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(Pe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(N=>s.jsx(Qt,{agent:N,dirName:r,sessionId:a,runId:n},`${n}:${N.agentId||N.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=j):j=e[24];let b;return e[25]!==j||e[26]!==m||e[27]!==p?(b=s.jsxs("section",{id:m,className:"scroll-mt-4",children:[p,j]}),e[25]=j,e[26]=m,e[27]=p,e[28]=b):b=e[28],b}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=C.useState(!0),[i,o]=C.useState(),[m,d]=C.useState(!1),[u,c]=C.useState(!1),[f,x]=He(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Re(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!b.ok){c(!0);return}const N=await b.json();o(N.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Ee,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Le,{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(Fe,{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&&i===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:m,onClick:()=>void j(),children:[m&&s.jsx(je,{"data-icon":"inline-start"}),u?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>x(Je(p)),"aria-label":f?"Outcome copied":"Copy outcome",title:f?"Copied":"Copy outcome",children:f?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(De,{}),s.jsx(Ue,{className:"py-5",children:s.jsx(Me,{value:p})})]})]})})}function as(l){const e=G.c(7),{script:t}=l,[r,a]=C.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Le,{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(Pt,{className:"size-4"}),s.jsx(Fe,{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 i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(De,{}),e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsxs(Ee,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[i,s.jsx(Ue,{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]=o):o=e[3];let m;return e[4]!==r||e[5]!==o?(m=s.jsx(Se,{open:r,onOpenChange:a,children:o}),e[4]=r,e[5]=o,e[6]=m):m=e[6],m}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,onRefetchList:i}){var R;const[o,m]=C.useState(null),[d,u]=C.useState(!1),[c,f]=C.useState(null),[x,h]=C.useState(!1),[p,j]=C.useState(!1),[b,N]=C.useState(!1),[S,w]=C.useState(null),v=C.useRef(0),g=d?null:o&&a.some(y=>y.runId===o)?o:((R=a[0])==null?void 0:R.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Re(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(g)}`);if(!k.ok){y===v.current&&f(null);return}const $=await k.json();y===v.current&&f($)}catch{y===v.current&&f(null)}finally{y===v.current&&h(!1)}},[t,r,g]);C.useEffect(()=>{if(!g){f(null);return}f(null),h(!0),N(!1),w(null),T()},[g,T]),bt(l?t:null,l?r:null,l?g:null,()=>{T(),i()});const I=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Re("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:g})})).json().catch(()=>({}));k!=null&&k.success?w("Stop signal sent."):(k==null?void 0:k.controllable)===!1?w("This workflow runs in a session Cogpit doesn't control."):w("Couldn't stop. The session may have already exited."),T(),i()}catch{w("Stop request failed.")}finally{j(!1),N(!1)}}},[b,r,g,T,i]),A=a.length>1,Y=a.find(y=>y.runId===g);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(Ot,{"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(Pe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[A&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[g&&c&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Mt,{"data-icon":"inline-start"}),"All runs"]}),(!g||!c)&&a.map(y=>s.jsx(rs,{workflow:y,active:y.runId===g,onClick:()=>{m(y.runId),u(!1)}},y.runId))]}),x&&!c?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…"]}):c?s.jsxs(s.Fragment,{children:[S&&s.jsx(Xe,{className:"mb-4",children:s.jsx(Ze,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:I})]}):Y?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Pe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=G.c(45),{workflow:t,active:r,onClick:a}=l;let n,i,o,m,d,u,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){o=lt(t.status),i=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",u=a;const g=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==g?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",g),e[12]=g,e[13]=c):c=e[13],m=le("size-2 shrink-0 rounded-full",o.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]=i,e[7]=o,e[8]=m,e[9]=d,e[10]=u,e[11]=c}else n=e[5],i=e[6],o=e[7],m=e[8],d=e[9],u=e[10],c=e[11];let f;e[14]!==m?(f=s.jsx("span",{className:m}),e[14]=m,e[15]=f):f=e[15];let x;e[16]!==t.workflowName?(x=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=x):x=e[17];let h;e[18]!==o.badge||e[19]!==o.label?(h=s.jsx(pe,{variant:"outline",className:o.badge,children:o.label}),e[18]=o.badge,e[19]=o.label,e[20]=h):h=e[20];let p;e[21]!==x||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,h]}),e[21]=x,e[22]=h,e[23]=p):p=e[23];let j;e[24]!==t.summary?(j=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]=j):j=e[25];let b;e[26]!==i||e[27]!==t.agentCount?(b=s.jsxs("span",{children:[i,"/",t.agentCount," agents"]}),e[26]=i,e[27]=t.agentCount,e[28]=b):b=e[28];let N;e[29]!==t.startTime?(N=t.startTime>0&&s.jsx("span",{children:Rt(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=N):N=e[30];let S;e[31]!==b||e[32]!==N?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b,N]}),e[31]=b,e[32]=N,e[33]=S):S=e[33];let w;e[34]!==S||e[35]!==p||e[36]!==j?(w=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,j,S]}),e[34]=S,e[35]=p,e[36]=j,e[37]=w):w=e[37];let v;return e[38]!==n||e[39]!==w||e[40]!==d||e[41]!==u||e[42]!==c||e[43]!==f?(v=s.jsxs(n,{variant:d,onClick:u,className:c,children:[f,w]}),e[38]=n,e[39]=w,e[40]=d,e[41]=u,e[42]=c,e[43]=f,e[44]=v):v=e[44],v}export{ms as WorkflowsPanel};
@@ -1 +1 @@
1
- import{r as h,j as e}from"./vendor-react-gGw_S5I_.js";import{T as Y,d as Z,c as K,S as Q,a as _,B as x,U as S,b as ee,E as se,y as te,z as ne,G as re,H as ae,V as ie,W as le,X as oe,Y as ce,Z as de,_ as A,$ as R,a0 as E,a1 as he,a2 as T,a3 as U,a4 as z,a5 as $,a6 as F,w as u,a7 as c}from"./index-D-Mg0tNr.js";import{G as P,b as xe,c as me,E as ue,d as pe,T as O,C as je,e as ge}from"./vendor-ui-Bg9q4lA4.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const fe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function we({open:I,onOpenChange:H,worktrees:v,loading:p,dirName:a,onRefetch:j,onOpenSession:M}){const o=Y("hostFiles"),[B,y]=h.useState(null),[G,b]=h.useState(null),[J,m]=h.useState(!1),[t,d]=h.useState(null),[r,g]=h.useState(null),C=async s=>{if(!(!o||!a)){y(s.name);try{await u(`/api/worktrees/${encodeURIComponent(a)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})}),j()}catch(n){c.error(`Failed to delete worktree: ${n instanceof Error?n.message:"Unknown error"}`)}finally{y(null)}}},W=s=>{if(!(!o||!a)){if(s.isDirty){d({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}C(s)}},L=()=>{if(!t)return;const{worktree:s,reason:n}=t;if(n==="dirty"&&s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}d(null),C(s)},q=async s=>{if(!(!o||!a)){b(s.name);try{const n=await u(`/api/worktrees/${encodeURIComponent(a)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(n.ok){const l=await n.json();l.url?window.open(l.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const l=await n.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${l.error||"Unknown error"}`)}}catch(n){c.error(`Error creating PR: ${n instanceof Error?n.message:"Unknown error"}`)}finally{b(null)}}},V=async()=>{if(!(!o||!a)){m(!0);try{const s=await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:n}=await s.json();n.length===0?c.info("No stale worktrees found"):g(n.map(l=>l.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{m(!1)}}},X=async()=>{if(!o||!a||!r)return;const s=r;g(null),m(!0);try{await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(n){c.error(`Cleanup failed: ${n instanceof Error?n.message:"Unknown error"}`)}finally{m(!1)}};return e.jsxs(Z,{open:I,onOpenChange:H,children:[e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsxs("div",{className:"flex items-center justify-between pr-8",children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(P,{"data-icon":"inline-start",className:"size-4"}),"Worktrees"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:V,disabled:J,"aria-label":"Cleanup stale worktrees",children:e.jsx(xe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:j,disabled:p,"aria-label":"Refresh worktrees",children:e.jsx(me,{"data-icon":"inline-start",className:S(p&&"animate-spin")})})]})]}),e.jsx(ee,{children:"Review isolated branches and their file changes."})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!a&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),a&&v.length===0&&!p&&e.jsx(se,{className:"border-0 py-16",children:e.jsxs(te,{children:[e.jsx(ne,{variant:"icon",children:e.jsx(P,{})}),e.jsx(re,{children:"No worktrees"}),e.jsx(ae,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var w,N,D;const n=((w=s.changedFiles)==null?void 0:w.reduce((i,k)=>i+k.additions,0))??0,l=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.deletions,0))??0,f=((D=s.changedFiles)==null?void 0:D.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:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",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(ie,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[s.linkedSessions.length>0&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>M(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(ue,{"data-icon":"inline-start"})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(pe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>W(s),disabled:B===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(O,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono shrink-0",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),s.createdAt&&e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:le(s.createdAt)}),f>0&&e.jsxs(oe,{className:"mt-2",children:[e.jsxs(ce,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(je,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(ge,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[f," file",f!==1?"s":""," changed"]}),e.jsxs("span",{className:"ml-1",children:[e.jsxs("span",{className:"text-success",children:["+",n]})," ",e.jsxs("span",{className:"text-destructive",children:["-",l]})]})]}),e.jsx(de,{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(i=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:S("shrink-0 w-3 text-center",fe[i.status]??"text-muted-foreground"),children:i.status}),e.jsx("span",{className:"truncate text-foreground/80",children:i.path}),e.jsxs("span",{className:"ml-auto shrink-0 text-muted-foreground",children:[e.jsxs("span",{className:"text-success",children:["+",i.additions]})," ",e.jsxs("span",{className:"text-destructive",children:["-",i.deletions]})]})]},i.path))})})]})]},s.name)})]})]}),e.jsx(A,{open:t!==null,onOpenChange:s=>{s||d(null)},children:e.jsxs(R,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(he,{className:"bg-destructive/10 text-destructive",children:e.jsx(O,{})}),e.jsx(T,{children:(t==null?void 0:t.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(U,{children:[(t==null?void 0:t.reason)==="dirty"?`"${t.worktree.name}" has uncommitted changes.`:`"${t==null?void 0:t.worktree.name}" has ${t==null?void 0:t.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:L,children:(t==null?void 0:t.reason)==="dirty"&&t.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(A,{open:r!==null,onOpenChange:s=>{s||g(null)},children:e.jsxs(R,{children:[e.jsxs(E,{children:[e.jsx(T,{children:"Remove stale worktrees?"}),e.jsxs(U,{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(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{we as WorktreePanel};
1
+ import{r as h,j as e}from"./vendor-react-gGw_S5I_.js";import{T as Y,d as Z,c as K,S as Q,a as _,B as x,U as S,b as ee,E as se,y as te,z as ne,G as re,H as ae,V as ie,W as le,X as oe,Y as ce,Z as de,_ as A,$ as R,a0 as E,a1 as he,a2 as T,a3 as U,a4 as z,a5 as $,a6 as F,w as u,a7 as c}from"./index-BESnPMZk.js";import{G as P,b as xe,c as me,E as ue,d as pe,T as O,C as je,e as ge}from"./vendor-ui-Bg9q4lA4.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const fe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function we({open:I,onOpenChange:H,worktrees:v,loading:p,dirName:a,onRefetch:j,onOpenSession:M}){const o=Y("hostFiles"),[B,y]=h.useState(null),[G,b]=h.useState(null),[J,m]=h.useState(!1),[t,d]=h.useState(null),[r,g]=h.useState(null),C=async s=>{if(!(!o||!a)){y(s.name);try{await u(`/api/worktrees/${encodeURIComponent(a)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})}),j()}catch(n){c.error(`Failed to delete worktree: ${n instanceof Error?n.message:"Unknown error"}`)}finally{y(null)}}},W=s=>{if(!(!o||!a)){if(s.isDirty){d({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}C(s)}},L=()=>{if(!t)return;const{worktree:s,reason:n}=t;if(n==="dirty"&&s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}d(null),C(s)},q=async s=>{if(!(!o||!a)){b(s.name);try{const n=await u(`/api/worktrees/${encodeURIComponent(a)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(n.ok){const l=await n.json();l.url?window.open(l.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const l=await n.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${l.error||"Unknown error"}`)}}catch(n){c.error(`Error creating PR: ${n instanceof Error?n.message:"Unknown error"}`)}finally{b(null)}}},V=async()=>{if(!(!o||!a)){m(!0);try{const s=await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:n}=await s.json();n.length===0?c.info("No stale worktrees found"):g(n.map(l=>l.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{m(!1)}}},X=async()=>{if(!o||!a||!r)return;const s=r;g(null),m(!0);try{await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(n){c.error(`Cleanup failed: ${n instanceof Error?n.message:"Unknown error"}`)}finally{m(!1)}};return e.jsxs(Z,{open:I,onOpenChange:H,children:[e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsxs("div",{className:"flex items-center justify-between pr-8",children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(P,{"data-icon":"inline-start",className:"size-4"}),"Worktrees"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:V,disabled:J,"aria-label":"Cleanup stale worktrees",children:e.jsx(xe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:j,disabled:p,"aria-label":"Refresh worktrees",children:e.jsx(me,{"data-icon":"inline-start",className:S(p&&"animate-spin")})})]})]}),e.jsx(ee,{children:"Review isolated branches and their file changes."})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!a&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),a&&v.length===0&&!p&&e.jsx(se,{className:"border-0 py-16",children:e.jsxs(te,{children:[e.jsx(ne,{variant:"icon",children:e.jsx(P,{})}),e.jsx(re,{children:"No worktrees"}),e.jsx(ae,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var w,N,D;const n=((w=s.changedFiles)==null?void 0:w.reduce((i,k)=>i+k.additions,0))??0,l=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.deletions,0))??0,f=((D=s.changedFiles)==null?void 0:D.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:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",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(ie,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[s.linkedSessions.length>0&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>M(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(ue,{"data-icon":"inline-start"})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(pe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>W(s),disabled:B===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(O,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono shrink-0",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),s.createdAt&&e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:le(s.createdAt)}),f>0&&e.jsxs(oe,{className:"mt-2",children:[e.jsxs(ce,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(je,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(ge,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[f," file",f!==1?"s":""," changed"]}),e.jsxs("span",{className:"ml-1",children:[e.jsxs("span",{className:"text-success",children:["+",n]})," ",e.jsxs("span",{className:"text-destructive",children:["-",l]})]})]}),e.jsx(de,{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(i=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:S("shrink-0 w-3 text-center",fe[i.status]??"text-muted-foreground"),children:i.status}),e.jsx("span",{className:"truncate text-foreground/80",children:i.path}),e.jsxs("span",{className:"ml-auto shrink-0 text-muted-foreground",children:[e.jsxs("span",{className:"text-success",children:["+",i.additions]})," ",e.jsxs("span",{className:"text-destructive",children:["-",i.deletions]})]})]},i.path))})})]})]},s.name)})]})]}),e.jsx(A,{open:t!==null,onOpenChange:s=>{s||d(null)},children:e.jsxs(R,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(he,{className:"bg-destructive/10 text-destructive",children:e.jsx(O,{})}),e.jsx(T,{children:(t==null?void 0:t.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(U,{children:[(t==null?void 0:t.reason)==="dirty"?`"${t.worktree.name}" has uncommitted changes.`:`"${t==null?void 0:t.worktree.name}" has ${t==null?void 0:t.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:L,children:(t==null?void 0:t.reason)==="dirty"&&t.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(A,{open:r!==null,onOpenChange:s=>{s||g(null)},children:e.jsxs(R,{children:[e.jsxs(E,{children:[e.jsx(T,{children:"Remove stale worktrees?"}),e.jsxs(U,{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(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{we as WorktreePanel};
@@ -1 +1 @@
1
- import{c as Y,j as t,r as h}from"./vendor-react-gGw_S5I_.js";import{U as Ke,aa as ee,aD as te,aE as Q,m as Re,n as Ue,I as Ge,ab as Qe,ac as Ye,aF as Ze,B as be,aG as et,aw as tt,ax as st,w as Le,i as it,j as at,k as nt,aH as Be,aI as lt,aJ as rt,a9 as ot,an as ct,h as dt,D as ut}from"./index-D-Mg0tNr.js";import{Q as ft,U as mt,V as ht,W as xt,i as pt,h as gt,M as jt,Y as vt,_ as wt,F as bt,A as kt,$ as Nt,J as St,a0 as Me,a1 as yt,a2 as Ct}from"./vendor-ui-Bg9q4lA4.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function _t(s){const e=Y.c(11);let a,l,i;e[0]!==s?({className:a,size:i,...l}=s,e[0]=s,e[1]=a,e[2]=l,e[3]=i):(a=e[1],l=e[2],i=e[3]);const r=i===void 0?"default":i;let o;e[4]!==a?(o=Ke("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",a),e[4]=a,e[5]=o):o=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(mt,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"}),e[6]=u):u=e[6];let c;return e[7]!==l||e[8]!==r||e[9]!==o?(c=t.jsx(ft,{"data-slot":"switch","data-size":r,className:o,...l,children:u}),e[7]=l,e[8]=r,e[9]=o,e[10]=c):c=e[10],c}function At(s){const e=Y.c(3),{name:a}=s,l=a.toLowerCase();if(l.includes("iphone")||l.includes("android")){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(pt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=r):r=e[0],r}if(l.includes("ipad")||l.includes("tablet")){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(gt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[1]=r):r=e[1],r}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(jt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[2]=i):i=e[2],i}function Ee(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const a=Math.floor(e/60);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function zt(s){const e=[`Shared ${Ee(s.createdAt)}`,s.lastAccessAt>0?`opened ${Ee(s.lastAccessAt)}`:"never opened"];return s.guests>0&&e.push(s.guests===1?"1 guest":`${s.guests} guests`),e.join(" · ")}function It(){const s=Y.c(12),{shares:e,revoke:a,revokeAll:l}=Ze();let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Shared sessions"}),s[0]=i):i=s[0];let r;s[1]!==l||s[2]!==e.length?(r=e.length>0&&t.jsx(be,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",onClick:()=>void l(),children:"Revoke all"}),s[1]=l,s[2]=e.length,s[3]=r):r=s[3];let o;s[4]!==r?(o=t.jsxs("div",{className:"flex h-6 items-center justify-between",children:[i,r]}),s[4]=r,s[5]=o):o=s[5];let u;s[6]!==a||s[7]!==e?(u=e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No sessions are shared."}):t.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(g=>{const m=g.title||g.sessionId;return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm text-foreground",children:m}),t.jsx("p",{className:"text-xs text-muted-foreground",children:zt(g)})]}),t.jsx(be,{variant:"ghost",size:"xs","aria-label":`Revoke share of ${m}`,className:"text-destructive hover:text-destructive",onClick:()=>void a(g.sessionId),children:"Revoke"})]},g.sessionId)})}),s[6]=a,s[7]=e,s[8]=u):u=s[8];let c;return s[9]!==o||s[10]!==u?(c=t.jsxs("div",{className:"flex flex-col gap-2",children:[o,u]}),s[9]=o,s[10]=u,s[11]=c):c=s[11],c}function Pt(s){const e=Y.c(30),{networkAccess:a,setNetworkAccess:l,networkPassword:i,setNetworkPassword:r,showNetworkPassword:o,setShowNetworkPassword:u,hasExistingPassword:c,initialNetworkAccess:g,connectedDevices:m,minPasswordLength:j}=s;let k;e[0]!==a?(k=a?t.jsx(vt,{"data-icon":"inline-start",className:"size-4 text-success"}):t.jsx(wt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=a,e[1]=k):k=e[1];let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Network Access"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow other devices to connect"})]}),e[2]=S):S=e[2];let N;e[3]!==k?(N=t.jsxs("div",{className:"flex items-center gap-2",children:[k,S]}),e[3]=k,e[4]=N):N=e[4];let v;e[5]!==l?(v=I=>l(I),e[5]=l,e[6]=v):v=e[6];let x;e[7]!==a||e[8]!==v?(x=t.jsx(_t,{"aria-label":"Network Access",checked:a,onCheckedChange:v}),e[7]=a,e[8]=v,e[9]=x):x=e[9];let w;e[10]!==N||e[11]!==x?(w=t.jsxs("div",{className:"flex items-center justify-between",children:[N,x]}),e[10]=N,e[11]=x,e[12]=w):w=e[12];let p;e[13]!==c||e[14]!==j||e[15]!==a||e[16]!==i||e[17]!==r||e[18]!==u||e[19]!==o?(p=a&&t.jsxs(ee,{"data-invalid":i.length>0&&i.length<j,children:[t.jsx(te,{htmlFor:"network-password",children:"Password"}),t.jsx(Q,{children:c&&i.length===0?"A password is already set. Leave blank to keep it.":`Use at least ${j} characters.`}),t.jsxs(Re,{children:[t.jsx(Ue,{id:"network-password",type:o?"text":"password",value:i,onChange:I=>r(I.target.value),placeholder:c?"Enter new password to change":"Set a password for remote access"}),t.jsx(Ge,{align:"inline-end",children:t.jsx(Qe,{size:"icon-xs","aria-label":o?"Hide password":"Show password",onClick:()=>u(!o),children:o?t.jsx(ht,{"data-icon":"inline-start"}):t.jsx(xt,{"data-icon":"inline-start"})})})]}),i.length>0&&i.length<j&&t.jsxs(Ye,{children:["Password must be at least ",j," characters (",i.length,"/",j,")"]}),t.jsx(Q,{children:"Requires app restart. Remote browsers need an HTTPS reverse proxy; port 19384 remains available to Cogpit hubs and device clients."})]}),e[13]=c,e[14]=j,e[15]=a,e[16]=i,e[17]=r,e[18]=u,e[19]=o,e[20]=p):p=e[20];let d;e[21]!==m||e[22]!==g||e[23]!==a?(d=a&&g&&m.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected devices"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(Et)})]}),e[21]=m,e[22]=g,e[23]=a,e[24]=d):d=e[24];let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(It,{}),e[25]=z):z=e[25];let f;return e[26]!==w||e[27]!==p||e[28]!==d?(f=t.jsxs("div",{className:"flex flex-col gap-4 border-t pt-5",children:[w,p,d,z]}),e[26]=w,e[27]=p,e[28]=d,e[29]=f):f=e[29],f}function Et(s,e){return t.jsxs("div",{className:"flex items-center justify-between rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(At,{name:s.deviceName}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-foreground",children:s.deviceName}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s.ip})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ee(s.lastActivity)})]})]},`${s.ip}-${e}`)}function Dt(s){const e=Y.c(5),{status:a,error:l}=s;if(a==="validating"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Me,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Checking path..."]}),e[0]=i):i=e[0],i}if(a==="valid"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-success",children:[t.jsx(yt,{"data-icon":"inline-start",className:"size-3.5"}),"Valid .claude directory found"]}),e[1]=i):i=e[1],i}if(a==="invalid"&&l){let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ct,{"data-icon":"inline-start",className:"size-3.5"}),e[2]=i):i=e[2];let r;return e[3]!==l?(r=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[i,l]}),e[3]=l,e[4]=r):r=e[4],r}return null}function Ht(s){const e=Y.c(102),{open:a,currentPath:l,onClose:i,onSaved:r}=s,[o,u]=h.useState(l),[c,g]=h.useState(!1),{status:m,error:j,debouncedValidate:k,reset:S,save:N}=et();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=tt(),e[0]=v):v=e[0];const x=v;let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=st("configWrite"),e[1]=w):w=e[1];const p=w,[d,z]=h.useState(!1),[f,I]=h.useState(""),[ke,Ve]=h.useState(!1),[y,De]=h.useState(""),[Ne,He]=h.useState(""),[C,$e]=h.useState(""),[Se,Oe]=h.useState(""),[b,Fe]=h.useState(!1),[ye,We]=h.useState(!1),[_,qe]=h.useState(!1),[P,Je]=h.useState(!1);let se;e[2]===Symbol.for("react.memo_cache_sentinel")?(se=[],e[2]=se):se=e[2];const[Ce,Te]=h.useState(se);let ie,ae;e[3]!==l||e[4]!==a||e[5]!==S?(ie=()=>{a&&(u(l),S(),Le("/api/config").then(Lt).then(n=>{const A=(n==null?void 0:n.networkAccess)||!1;z(A),qe(A),Je(!!(n!=null&&n.networkPassword)),I("");const we=(n==null?void 0:n.terminalApp)||"";De(we),He(we);const Ie=(n==null?void 0:n.editorApp)||"";$e(Ie),Oe(Ie);const Pe=(n==null?void 0:n.useBuiltInEditor)===!0;Fe(Pe),We(Pe),A&&(n!=null&&n.networkPassword)&&!x?Le("/api/connected-devices").then(Tt).then(Z=>Te((Z==null?void 0:Z.devices)||[])).catch(Ft):Te([])}).catch($t))},ae=[a,l,S,x],e[3]=l,e[4]=a,e[5]=S,e[6]=ie,e[7]=ae):(ie=e[6],ae=e[7]),h.useEffect(ie,ae);let ne;e[8]!==k?(ne=n=>{const A=n.target.value;u(A),k(A)},e[8]=k,e[9]=ne):ne=e[9];const _e=ne;let le;e[10]!==C||e[11]!==_||e[12]!==d||e[13]!==f||e[14]!==r||e[15]!==o||e[16]!==N||e[17]!==y||e[18]!==b?(le=async()=>{g(!0);const n=await N(o,{networkAccess:x?_:d,networkPassword:!x&&d&&f.length>0?f:void 0,terminalApp:y.trim()||void 0,editorApp:C.trim()||void 0,useBuiltInEditor:b});n.success&&n.claudeDir&&r(n.claudeDir),g(!1)},e[10]=C,e[11]=_,e[12]=d,e[13]=f,e[14]=r,e[15]=o,e[16]=N,e[17]=y,e[18]=b,e[19]=le):le=e[19];const E=le;let re;e[20]!==C||e[21]!==P||e[22]!==Se||e[23]!==_||e[24]!==Ne||e[25]!==ye||e[26]!==d||e[27]!==f||e[28]!==m||e[29]!==y||e[30]!==b?(re=function(){if(m==="validating"||m==="invalid")return!1;const A=m==="valid",we=!x&&(d!==_||d&&f.length>0);if(!A&&!we&&!(y!==Ne)&&!(C!==Se||b!==ye))return!1;if(!x&&d){const Z=f.length>0&&f.length<16,Xe=!P&&f.length===0;if(Z||Xe)return!1}return!0},e[20]=C,e[21]=P,e[22]=Se,e[23]=_,e[24]=Ne,e[25]=ye,e[26]=d,e[27]=f,e[28]=m,e[29]=y,e[30]=b,e[31]=re):re=e[31];const D=re();let $;e[32]!==i?($=n=>{n||i()},e[32]=i,e[33]=$):$=e[33];let oe;e[34]===Symbol.for("react.memo_cache_sentinel")?(oe=t.jsxs(it,{children:[t.jsx(at,{className:"text-foreground",children:"Configuration"}),t.jsx(nt,{className:"text-muted-foreground",children:"Manage local paths, preferred apps, and remote access."})]}),e[34]=oe):oe=e[34];let ce,de;e[35]===Symbol.for("react.memo_cache_sentinel")?(ce=t.jsx(te,{htmlFor:"claude-directory",children:"Claude directory"}),de=t.jsx(Q,{children:"The directory containing your Claude configuration."}),e[35]=ce,e[36]=de):(ce=e[35],de=e[36]);let ue;e[37]===Symbol.for("react.memo_cache_sentinel")?(ue=t.jsx(Ge,{children:t.jsx(bt,{"data-icon":"inline-start"})}),e[37]=ue):ue=e[37];let F;e[38]!==D||e[39]!==E||e[40]!==c?(F=n=>{n.key==="Enter"&&D&&!c&&E()},e[38]=D,e[39]=E,e[40]=c,e[41]=F):F=e[41];let T;e[42]!==_e||e[43]!==o||e[44]!==F?(T=t.jsxs(Re,{children:[ue,t.jsx(Ue,{id:"claude-directory",value:o,onChange:_e,placeholder:"/Users/you/.claude",disabled:!p,onKeyDown:F})]}),e[42]=_e,e[43]=o,e[44]=F,e[45]=T):T=e[45];let L;e[46]!==j||e[47]!==m?(L=t.jsx("div",{"aria-live":"polite",children:t.jsx(Dt,{status:m,error:j})}),e[46]=j,e[47]=m,e[48]=L):L=e[48];let B;e[49]!==T||e[50]!==L?(B=t.jsxs(ee,{children:[ce,de,T,L]}),e[49]=T,e[50]=L,e[51]=B):B=e[51];let fe,me;e[52]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsxs(te,{htmlFor:"terminal-application",children:[t.jsx(kt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Terminal application"]}),me=t.jsx(Q,{children:"Leave blank to use the system default for Ctrl+Cmd+T."}),e[52]=fe,e[53]=me):(fe=e[52],me=e[53]);let he;e[54]===Symbol.for("react.memo_cache_sentinel")?(he=n=>De(n.target.value),e[54]=he):he=e[54];let R;e[55]!==y?(R=t.jsxs(ee,{children:[fe,me,t.jsx(Be,{id:"terminal-application",value:y,onChange:he,placeholder:"Ghostty, iTerm, or /path/to/binary",disabled:!p})]}),e[55]=y,e[56]=R):R=e[56];let xe;e[57]===Symbol.for("react.memo_cache_sentinel")?(xe=n=>Fe(n===!0),e[57]=xe):xe=e[57];let U;e[58]!==b?(U=t.jsx(lt,{id:"use-built-in-editor",checked:b,onCheckedChange:xe,disabled:!p}),e[58]=b,e[59]=U):U=e[59];let pe;e[60]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsxs(rt,{children:[t.jsxs(te,{htmlFor:"use-built-in-editor",children:[t.jsx(Nt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Open files in Cogpit"]}),t.jsx(Q,{children:"Files and diffs open in Cogpit’s file workspace instead of launching an external editor."})]}),e[60]=pe):pe=e[60];let G;e[61]!==U?(G=t.jsxs(ee,{orientation:"horizontal",children:[U,pe]}),e[61]=U,e[62]=G):G=e[62];let ge;e[63]===Symbol.for("react.memo_cache_sentinel")?(ge=t.jsxs(te,{htmlFor:"editor-application",children:[t.jsx(St,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Editor application"]}),e[63]=ge):ge=e[63];const Ae=b?"Not used while files open in Cogpit.":"Leave blank to use $VISUAL or automatic detection.";let M;e[64]!==Ae?(M=t.jsx(Q,{children:Ae}),e[64]=Ae,e[65]=M):M=e[65];let je;e[66]===Symbol.for("react.memo_cache_sentinel")?(je=n=>$e(n.target.value),e[66]=je):je=e[66];const ze=!p||b;let V;e[67]!==C||e[68]!==ze?(V=t.jsx(Be,{id:"editor-application",value:C,onChange:je,placeholder:"cursor, code, zed, or /path/to/binary",disabled:ze}),e[67]=C,e[68]=ze,e[69]=V):V=e[69];let H;e[70]!==M||e[71]!==V?(H=t.jsxs(ee,{children:[ge,M,V]}),e[70]=M,e[71]=V,e[72]=H):H=e[72];let O;e[73]!==Ce||e[74]!==P||e[75]!==_||e[76]!==d||e[77]!==f||e[78]!==ke?(O=!x&&p&&t.jsx(Pt,{networkAccess:d,setNetworkAccess:z,networkPassword:f,setNetworkPassword:I,showNetworkPassword:ke,setShowNetworkPassword:Ve,hasExistingPassword:P,initialNetworkAccess:_,connectedDevices:Ce,minPasswordLength:16}),e[73]=Ce,e[74]=P,e[75]=_,e[76]=d,e[77]=f,e[78]=ke,e[79]=O):O=e[79];let W;e[80]!==B||e[81]!==R||e[82]!==G||e[83]!==H||e[84]!==O?(W=t.jsxs(ot,{children:[B,R,G,H,O]}),e[80]=B,e[81]=R,e[82]=G,e[83]=H,e[84]=O,e[85]=W):W=e[85];let q;e[86]!==i?(q=t.jsx(be,{variant:"outline",onClick:i,children:"Cancel"}),e[86]=i,e[87]=q):q=e[87];let J;e[88]!==D||e[89]!==E||e[90]!==c?(J=p&&t.jsx(be,{disabled:!D||c,onClick:E,children:c?t.jsxs(t.Fragment,{children:[t.jsx(Me,{"data-icon":"inline-start",className:"size-4 animate-spin"}),"Saving..."]}):"Save"}),e[88]=D,e[89]=E,e[90]=c,e[91]=J):J=e[91];let X;e[92]!==q||e[93]!==J?(X=t.jsxs(ct,{children:[q,J]}),e[92]=q,e[93]=J,e[94]=X):X=e[94];let K;e[95]!==W||e[96]!==X?(K=t.jsxs(dt,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg",children:[oe,W,X]}),e[95]=W,e[96]=X,e[97]=K):K=e[97];let ve;return e[98]!==a||e[99]!==K||e[100]!==$?(ve=t.jsx(ut,{open:a,onOpenChange:$,children:K}),e[98]=a,e[99]=K,e[100]=$,e[101]=ve):ve=e[101],ve}function $t(){}function Ft(){}function Tt(s){return s.json()}function Lt(s){return s.json()}export{Ht as ConfigDialog};
1
+ import{c as Y,j as t,r as h}from"./vendor-react-gGw_S5I_.js";import{U as Ke,aa as ee,aD as te,aE as Q,m as Re,n as Ue,I as Ge,ab as Qe,ac as Ye,aF as Ze,B as be,aG as et,aw as tt,ax as st,w as Le,i as it,j as at,k as nt,aH as Be,aI as lt,aJ as rt,a9 as ot,an as ct,h as dt,D as ut}from"./index-BESnPMZk.js";import{Q as ft,U as mt,V as ht,W as xt,i as pt,h as gt,M as jt,Y as vt,_ as wt,F as bt,A as kt,$ as Nt,J as St,a0 as Me,a1 as yt,a2 as Ct}from"./vendor-ui-Bg9q4lA4.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function _t(s){const e=Y.c(11);let a,l,i;e[0]!==s?({className:a,size:i,...l}=s,e[0]=s,e[1]=a,e[2]=l,e[3]=i):(a=e[1],l=e[2],i=e[3]);const r=i===void 0?"default":i;let o;e[4]!==a?(o=Ke("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",a),e[4]=a,e[5]=o):o=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(mt,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"}),e[6]=u):u=e[6];let c;return e[7]!==l||e[8]!==r||e[9]!==o?(c=t.jsx(ft,{"data-slot":"switch","data-size":r,className:o,...l,children:u}),e[7]=l,e[8]=r,e[9]=o,e[10]=c):c=e[10],c}function At(s){const e=Y.c(3),{name:a}=s,l=a.toLowerCase();if(l.includes("iphone")||l.includes("android")){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(pt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=r):r=e[0],r}if(l.includes("ipad")||l.includes("tablet")){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(gt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[1]=r):r=e[1],r}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(jt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[2]=i):i=e[2],i}function Ee(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const a=Math.floor(e/60);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function zt(s){const e=[`Shared ${Ee(s.createdAt)}`,s.lastAccessAt>0?`opened ${Ee(s.lastAccessAt)}`:"never opened"];return s.guests>0&&e.push(s.guests===1?"1 guest":`${s.guests} guests`),e.join(" · ")}function It(){const s=Y.c(12),{shares:e,revoke:a,revokeAll:l}=Ze();let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Shared sessions"}),s[0]=i):i=s[0];let r;s[1]!==l||s[2]!==e.length?(r=e.length>0&&t.jsx(be,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",onClick:()=>void l(),children:"Revoke all"}),s[1]=l,s[2]=e.length,s[3]=r):r=s[3];let o;s[4]!==r?(o=t.jsxs("div",{className:"flex h-6 items-center justify-between",children:[i,r]}),s[4]=r,s[5]=o):o=s[5];let u;s[6]!==a||s[7]!==e?(u=e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No sessions are shared."}):t.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(g=>{const m=g.title||g.sessionId;return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm text-foreground",children:m}),t.jsx("p",{className:"text-xs text-muted-foreground",children:zt(g)})]}),t.jsx(be,{variant:"ghost",size:"xs","aria-label":`Revoke share of ${m}`,className:"text-destructive hover:text-destructive",onClick:()=>void a(g.sessionId),children:"Revoke"})]},g.sessionId)})}),s[6]=a,s[7]=e,s[8]=u):u=s[8];let c;return s[9]!==o||s[10]!==u?(c=t.jsxs("div",{className:"flex flex-col gap-2",children:[o,u]}),s[9]=o,s[10]=u,s[11]=c):c=s[11],c}function Pt(s){const e=Y.c(30),{networkAccess:a,setNetworkAccess:l,networkPassword:i,setNetworkPassword:r,showNetworkPassword:o,setShowNetworkPassword:u,hasExistingPassword:c,initialNetworkAccess:g,connectedDevices:m,minPasswordLength:j}=s;let k;e[0]!==a?(k=a?t.jsx(vt,{"data-icon":"inline-start",className:"size-4 text-success"}):t.jsx(wt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=a,e[1]=k):k=e[1];let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Network Access"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow other devices to connect"})]}),e[2]=S):S=e[2];let N;e[3]!==k?(N=t.jsxs("div",{className:"flex items-center gap-2",children:[k,S]}),e[3]=k,e[4]=N):N=e[4];let v;e[5]!==l?(v=I=>l(I),e[5]=l,e[6]=v):v=e[6];let x;e[7]!==a||e[8]!==v?(x=t.jsx(_t,{"aria-label":"Network Access",checked:a,onCheckedChange:v}),e[7]=a,e[8]=v,e[9]=x):x=e[9];let w;e[10]!==N||e[11]!==x?(w=t.jsxs("div",{className:"flex items-center justify-between",children:[N,x]}),e[10]=N,e[11]=x,e[12]=w):w=e[12];let p;e[13]!==c||e[14]!==j||e[15]!==a||e[16]!==i||e[17]!==r||e[18]!==u||e[19]!==o?(p=a&&t.jsxs(ee,{"data-invalid":i.length>0&&i.length<j,children:[t.jsx(te,{htmlFor:"network-password",children:"Password"}),t.jsx(Q,{children:c&&i.length===0?"A password is already set. Leave blank to keep it.":`Use at least ${j} characters.`}),t.jsxs(Re,{children:[t.jsx(Ue,{id:"network-password",type:o?"text":"password",value:i,onChange:I=>r(I.target.value),placeholder:c?"Enter new password to change":"Set a password for remote access"}),t.jsx(Ge,{align:"inline-end",children:t.jsx(Qe,{size:"icon-xs","aria-label":o?"Hide password":"Show password",onClick:()=>u(!o),children:o?t.jsx(ht,{"data-icon":"inline-start"}):t.jsx(xt,{"data-icon":"inline-start"})})})]}),i.length>0&&i.length<j&&t.jsxs(Ye,{children:["Password must be at least ",j," characters (",i.length,"/",j,")"]}),t.jsx(Q,{children:"Requires app restart. Remote browsers need an HTTPS reverse proxy; port 19384 remains available to Cogpit hubs and device clients."})]}),e[13]=c,e[14]=j,e[15]=a,e[16]=i,e[17]=r,e[18]=u,e[19]=o,e[20]=p):p=e[20];let d;e[21]!==m||e[22]!==g||e[23]!==a?(d=a&&g&&m.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected devices"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(Et)})]}),e[21]=m,e[22]=g,e[23]=a,e[24]=d):d=e[24];let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(It,{}),e[25]=z):z=e[25];let f;return e[26]!==w||e[27]!==p||e[28]!==d?(f=t.jsxs("div",{className:"flex flex-col gap-4 border-t pt-5",children:[w,p,d,z]}),e[26]=w,e[27]=p,e[28]=d,e[29]=f):f=e[29],f}function Et(s,e){return t.jsxs("div",{className:"flex items-center justify-between rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(At,{name:s.deviceName}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-foreground",children:s.deviceName}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s.ip})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ee(s.lastActivity)})]})]},`${s.ip}-${e}`)}function Dt(s){const e=Y.c(5),{status:a,error:l}=s;if(a==="validating"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Me,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Checking path..."]}),e[0]=i):i=e[0],i}if(a==="valid"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-success",children:[t.jsx(yt,{"data-icon":"inline-start",className:"size-3.5"}),"Valid .claude directory found"]}),e[1]=i):i=e[1],i}if(a==="invalid"&&l){let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ct,{"data-icon":"inline-start",className:"size-3.5"}),e[2]=i):i=e[2];let r;return e[3]!==l?(r=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[i,l]}),e[3]=l,e[4]=r):r=e[4],r}return null}function Ht(s){const e=Y.c(102),{open:a,currentPath:l,onClose:i,onSaved:r}=s,[o,u]=h.useState(l),[c,g]=h.useState(!1),{status:m,error:j,debouncedValidate:k,reset:S,save:N}=et();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=tt(),e[0]=v):v=e[0];const x=v;let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=st("configWrite"),e[1]=w):w=e[1];const p=w,[d,z]=h.useState(!1),[f,I]=h.useState(""),[ke,Ve]=h.useState(!1),[y,De]=h.useState(""),[Ne,He]=h.useState(""),[C,$e]=h.useState(""),[Se,Oe]=h.useState(""),[b,Fe]=h.useState(!1),[ye,We]=h.useState(!1),[_,qe]=h.useState(!1),[P,Je]=h.useState(!1);let se;e[2]===Symbol.for("react.memo_cache_sentinel")?(se=[],e[2]=se):se=e[2];const[Ce,Te]=h.useState(se);let ie,ae;e[3]!==l||e[4]!==a||e[5]!==S?(ie=()=>{a&&(u(l),S(),Le("/api/config").then(Lt).then(n=>{const A=(n==null?void 0:n.networkAccess)||!1;z(A),qe(A),Je(!!(n!=null&&n.networkPassword)),I("");const we=(n==null?void 0:n.terminalApp)||"";De(we),He(we);const Ie=(n==null?void 0:n.editorApp)||"";$e(Ie),Oe(Ie);const Pe=(n==null?void 0:n.useBuiltInEditor)===!0;Fe(Pe),We(Pe),A&&(n!=null&&n.networkPassword)&&!x?Le("/api/connected-devices").then(Tt).then(Z=>Te((Z==null?void 0:Z.devices)||[])).catch(Ft):Te([])}).catch($t))},ae=[a,l,S,x],e[3]=l,e[4]=a,e[5]=S,e[6]=ie,e[7]=ae):(ie=e[6],ae=e[7]),h.useEffect(ie,ae);let ne;e[8]!==k?(ne=n=>{const A=n.target.value;u(A),k(A)},e[8]=k,e[9]=ne):ne=e[9];const _e=ne;let le;e[10]!==C||e[11]!==_||e[12]!==d||e[13]!==f||e[14]!==r||e[15]!==o||e[16]!==N||e[17]!==y||e[18]!==b?(le=async()=>{g(!0);const n=await N(o,{networkAccess:x?_:d,networkPassword:!x&&d&&f.length>0?f:void 0,terminalApp:y.trim()||void 0,editorApp:C.trim()||void 0,useBuiltInEditor:b});n.success&&n.claudeDir&&r(n.claudeDir),g(!1)},e[10]=C,e[11]=_,e[12]=d,e[13]=f,e[14]=r,e[15]=o,e[16]=N,e[17]=y,e[18]=b,e[19]=le):le=e[19];const E=le;let re;e[20]!==C||e[21]!==P||e[22]!==Se||e[23]!==_||e[24]!==Ne||e[25]!==ye||e[26]!==d||e[27]!==f||e[28]!==m||e[29]!==y||e[30]!==b?(re=function(){if(m==="validating"||m==="invalid")return!1;const A=m==="valid",we=!x&&(d!==_||d&&f.length>0);if(!A&&!we&&!(y!==Ne)&&!(C!==Se||b!==ye))return!1;if(!x&&d){const Z=f.length>0&&f.length<16,Xe=!P&&f.length===0;if(Z||Xe)return!1}return!0},e[20]=C,e[21]=P,e[22]=Se,e[23]=_,e[24]=Ne,e[25]=ye,e[26]=d,e[27]=f,e[28]=m,e[29]=y,e[30]=b,e[31]=re):re=e[31];const D=re();let $;e[32]!==i?($=n=>{n||i()},e[32]=i,e[33]=$):$=e[33];let oe;e[34]===Symbol.for("react.memo_cache_sentinel")?(oe=t.jsxs(it,{children:[t.jsx(at,{className:"text-foreground",children:"Configuration"}),t.jsx(nt,{className:"text-muted-foreground",children:"Manage local paths, preferred apps, and remote access."})]}),e[34]=oe):oe=e[34];let ce,de;e[35]===Symbol.for("react.memo_cache_sentinel")?(ce=t.jsx(te,{htmlFor:"claude-directory",children:"Claude directory"}),de=t.jsx(Q,{children:"The directory containing your Claude configuration."}),e[35]=ce,e[36]=de):(ce=e[35],de=e[36]);let ue;e[37]===Symbol.for("react.memo_cache_sentinel")?(ue=t.jsx(Ge,{children:t.jsx(bt,{"data-icon":"inline-start"})}),e[37]=ue):ue=e[37];let F;e[38]!==D||e[39]!==E||e[40]!==c?(F=n=>{n.key==="Enter"&&D&&!c&&E()},e[38]=D,e[39]=E,e[40]=c,e[41]=F):F=e[41];let T;e[42]!==_e||e[43]!==o||e[44]!==F?(T=t.jsxs(Re,{children:[ue,t.jsx(Ue,{id:"claude-directory",value:o,onChange:_e,placeholder:"/Users/you/.claude",disabled:!p,onKeyDown:F})]}),e[42]=_e,e[43]=o,e[44]=F,e[45]=T):T=e[45];let L;e[46]!==j||e[47]!==m?(L=t.jsx("div",{"aria-live":"polite",children:t.jsx(Dt,{status:m,error:j})}),e[46]=j,e[47]=m,e[48]=L):L=e[48];let B;e[49]!==T||e[50]!==L?(B=t.jsxs(ee,{children:[ce,de,T,L]}),e[49]=T,e[50]=L,e[51]=B):B=e[51];let fe,me;e[52]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsxs(te,{htmlFor:"terminal-application",children:[t.jsx(kt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Terminal application"]}),me=t.jsx(Q,{children:"Leave blank to use the system default for Ctrl+Cmd+T."}),e[52]=fe,e[53]=me):(fe=e[52],me=e[53]);let he;e[54]===Symbol.for("react.memo_cache_sentinel")?(he=n=>De(n.target.value),e[54]=he):he=e[54];let R;e[55]!==y?(R=t.jsxs(ee,{children:[fe,me,t.jsx(Be,{id:"terminal-application",value:y,onChange:he,placeholder:"Ghostty, iTerm, or /path/to/binary",disabled:!p})]}),e[55]=y,e[56]=R):R=e[56];let xe;e[57]===Symbol.for("react.memo_cache_sentinel")?(xe=n=>Fe(n===!0),e[57]=xe):xe=e[57];let U;e[58]!==b?(U=t.jsx(lt,{id:"use-built-in-editor",checked:b,onCheckedChange:xe,disabled:!p}),e[58]=b,e[59]=U):U=e[59];let pe;e[60]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsxs(rt,{children:[t.jsxs(te,{htmlFor:"use-built-in-editor",children:[t.jsx(Nt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Open files in Cogpit"]}),t.jsx(Q,{children:"Files and diffs open in Cogpit’s file workspace instead of launching an external editor."})]}),e[60]=pe):pe=e[60];let G;e[61]!==U?(G=t.jsxs(ee,{orientation:"horizontal",children:[U,pe]}),e[61]=U,e[62]=G):G=e[62];let ge;e[63]===Symbol.for("react.memo_cache_sentinel")?(ge=t.jsxs(te,{htmlFor:"editor-application",children:[t.jsx(St,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Editor application"]}),e[63]=ge):ge=e[63];const Ae=b?"Not used while files open in Cogpit.":"Leave blank to use $VISUAL or automatic detection.";let M;e[64]!==Ae?(M=t.jsx(Q,{children:Ae}),e[64]=Ae,e[65]=M):M=e[65];let je;e[66]===Symbol.for("react.memo_cache_sentinel")?(je=n=>$e(n.target.value),e[66]=je):je=e[66];const ze=!p||b;let V;e[67]!==C||e[68]!==ze?(V=t.jsx(Be,{id:"editor-application",value:C,onChange:je,placeholder:"cursor, code, zed, or /path/to/binary",disabled:ze}),e[67]=C,e[68]=ze,e[69]=V):V=e[69];let H;e[70]!==M||e[71]!==V?(H=t.jsxs(ee,{children:[ge,M,V]}),e[70]=M,e[71]=V,e[72]=H):H=e[72];let O;e[73]!==Ce||e[74]!==P||e[75]!==_||e[76]!==d||e[77]!==f||e[78]!==ke?(O=!x&&p&&t.jsx(Pt,{networkAccess:d,setNetworkAccess:z,networkPassword:f,setNetworkPassword:I,showNetworkPassword:ke,setShowNetworkPassword:Ve,hasExistingPassword:P,initialNetworkAccess:_,connectedDevices:Ce,minPasswordLength:16}),e[73]=Ce,e[74]=P,e[75]=_,e[76]=d,e[77]=f,e[78]=ke,e[79]=O):O=e[79];let W;e[80]!==B||e[81]!==R||e[82]!==G||e[83]!==H||e[84]!==O?(W=t.jsxs(ot,{children:[B,R,G,H,O]}),e[80]=B,e[81]=R,e[82]=G,e[83]=H,e[84]=O,e[85]=W):W=e[85];let q;e[86]!==i?(q=t.jsx(be,{variant:"outline",onClick:i,children:"Cancel"}),e[86]=i,e[87]=q):q=e[87];let J;e[88]!==D||e[89]!==E||e[90]!==c?(J=p&&t.jsx(be,{disabled:!D||c,onClick:E,children:c?t.jsxs(t.Fragment,{children:[t.jsx(Me,{"data-icon":"inline-start",className:"size-4 animate-spin"}),"Saving..."]}):"Save"}),e[88]=D,e[89]=E,e[90]=c,e[91]=J):J=e[91];let X;e[92]!==q||e[93]!==J?(X=t.jsxs(ct,{children:[q,J]}),e[92]=q,e[93]=J,e[94]=X):X=e[94];let K;e[95]!==W||e[96]!==X?(K=t.jsxs(dt,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg",children:[oe,W,X]}),e[95]=W,e[96]=X,e[97]=K):K=e[97];let ve;return e[98]!==a||e[99]!==K||e[100]!==$?(ve=t.jsx(ut,{open:a,onOpenChange:$,children:K}),e[98]=a,e[99]=K,e[100]=$,e[101]=ve):ve=e[101],ve}function $t(){}function Ft(){}function Tt(s){return s.json()}function Lt(s){return s.json()}export{Ht as ConfigDialog};