cogpit 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +276 -73
- package/dist/web/assets/{CommandPaletteHost-DJghey7B.js → CommandPaletteHost-D43icOGh.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-x0UdXG0K.js → ConfigBrowser-BailHbYr.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D0TDZx8S.js → HighlightedEditor-Kf1cQYyg.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-2606YXAx.js → KeyboardShortcutsDialog-CHb_hQuK.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B4dwGXMS.js → MobileFileChanges-C9Xk9gfg.js} +1 -1
- package/dist/web/assets/{PreviewPanel-CJdf-VLC.js → PreviewPanel-Djv1bZZJ.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-DuBqjGFA.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-D8boI2Qx.js → ProjectSwitcherModal-CxQ6p2B4.js} +1 -1
- package/dist/web/assets/{TerminalOutput-C-6RWc6C.js → TerminalOutput-Cm-dLkUR.js} +1 -1
- package/dist/web/assets/ThemeSelectorModal-CTuOdp5Q.js +1 -0
- package/dist/web/assets/WorkflowsPanel-P7HtcaDf.js +1 -0
- package/dist/web/assets/{WorktreePanel-D-BUTFL2.js → WorktreePanel-DcjYVMuA.js} +1 -1
- package/dist/web/assets/index-CEBq1nya.js +1 -0
- package/dist/web/assets/{index-ztb2qsgi.js → index-CVfvPIib.js} +4 -4
- package/dist/web/assets/index-CWj7TiFf.css +1 -0
- package/dist/web/assets/{index-BBKPLXTq.js → index-D2LNKOXE.js} +1 -1
- package/dist/web/assets/index-DFiPbdIb.js +153 -0
- package/dist/web/assets/session-parser.worker-SrNyVFwl.js +29 -0
- package/dist/web/assets/{vendor-ui-RwWl1mlR.js → vendor-ui-DUTyrBOX.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/ProjectFilesPanel-3GzuQyp3.js +0 -4
- package/dist/web/assets/ThemeSelectorModal-DZ9JuT6j.js +0 -1
- package/dist/web/assets/WorkflowsPanel-i3GanFyN.js +0 -1
- package/dist/web/assets/index-CMQcske6.js +0 -1
- package/dist/web/assets/index-C_0XOtqJ.css +0 -1
- package/dist/web/assets/index-D6p4gVB_.js +0 -154
- package/dist/web/assets/session-parser.worker-D3MwyNH5.js +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as F,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{b0 as je,b2 as be,_ as P,U as ye,V as W,aV as q,Y as Ce,Z as X,a_ as se,B as z,w as L,b3 as ke,b4 as ve,b5 as Ne,b6 as Se,b7 as we,b8 as De,b9 as V,ba as Te,bb as Z,bc as Ee,a2 as ee,a9 as ae,bd as Re,aa as le,ab as ie,ac as re,ad as oe,ae as ce,af as de,ag as ue,a3 as Ie,E as Oe,y as ze,z as Ae,G as Le,H as Be,ak as $e,m as Fe,I as te,n as Ge,W as Me,q as Pe,be as _e}from"./index-D6p4gVB_.js";import{ah as Ue,B as Ve,m as He,a1 as Ke,ai as Ye,aj as Je,ak as me,al as xe,am as Qe,an as We,k as H,X as K,P as qe,ao as fe,ap as Xe,o as Ze,_ as et,S as tt}from"./vendor-ui-RwWl1mlR.js";import{H as nt}from"./HighlightedEditor-D0TDZx8S.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const st={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},at={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},ne=["instructions","agents","skills","commands","settings"],lt={instructions:{label:"Instructions",icon:Ye,color:"text-muted-foreground"},agents:{label:"Agents",icon:Ke,color:"text-muted-foreground"},skills:{label:"Skills",icon:He,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ve,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ue,color:"text-muted-foreground"}};function Y(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Y(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function it(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Y(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function he(l){const e=F.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Je,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(me,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const rt=Object.fromEntries(je().map(l=>[l.kind,be(l.kind)]));function pe(l){const e=F.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Qe,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=rt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function ge(l){const e=F.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=P("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(We,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let g;return e[6]!==u||e[7]!==m||e[8]!==d?(g=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=g):g=e[9],g}function ot({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,g]=o.useState(!1),N=o.useRef(null),k=o.useId();o.useEffect(()=>{var h;(h=N.current)==null||h.focus()},[]);const S=m==="project"&&e?e:l,f=!!l&&!!e;async function w(){if(!(!r.trim()||!S)){g(!0);try{const h=await L("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:S,fileType:i,name:r.trim()})});if(h.ok){const p=await h.json();n(p.path,i,m)}}finally{g(!1)}}}return t.jsxs(ye,{className:"gap-3 px-3 py-2",children:[f&&t.jsxs(W,{children:[t.jsx(q,{children:"Scope"}),t.jsxs(Ce,{"aria-label":"File scope",value:[m],onValueChange:h=>{const p=h[0];(p==="global"||p==="project")&&c(p)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(X,{value:"global",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(X,{value:"project",className:"flex-1",children:[t.jsx(me,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(W,{children:[t.jsxs(q,{htmlFor:k,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(se,{id:k,ref:N,type:"text",value:r,onChange:h=>u(h.target.value),onKeyDown:h=>{h.key==="Enter"&&w(),h.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void w(),disabled:d||!r.trim()||!S,children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(K,{"data-icon":"inline-start"})})]})]})]})}function ct(l){const e=F.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:g,onRenameValueChange:N,onRenameSubmit:k,onRenameCancel:S,creatingInCategory:f,onCreated:w,onCancelCreate:h}=l,p=lt[i],j=p.icon;if(n.length===0&&!u)return null;let D;e[0]!==p.color?(D=P("size-3.5",p.color),e[0]=p.color,e[1]=D):D=e[1];let T;e[2]!==j||e[3]!==D?(T=t.jsx(j,{"data-icon":"inline-start",className:D}),e[2]=j,e[3]=D,e[4]=T):T=e[4];let y;e[5]!==p.label?(y=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:p.label}),e[5]=p.label,e[6]=y):y=e[6];let R;e[7]!==n.length?(R=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=R):R=e[8];let C;e[9]!==i||e[10]!==u?(C=u&&t.jsxs(ke,{children:[t.jsx(ve,{render:t.jsx(z,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(Ne,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=C):C=e[11];let v;e[12]!==T||e[13]!==y||e[14]!==R||e[15]!==C?(v=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[T,y,R,C]}),e[12]=T,e[13]=y,e[14]=R,e[15]=C,e[16]=v):v=e[16];let E;if(e[17]!==n||e[18]!==m||e[19]!==S||e[20]!==c||e[21]!==k||e[22]!==N||e[23]!==r||e[24]!==g||e[25]!==d||e[26]!==s){let $;e[28]!==m||e[29]!==S||e[30]!==c||e[31]!==k||e[32]!==N||e[33]!==r||e[34]!==g||e[35]!==d||e[36]!==s?($=b=>{const _=s===b.path;if(d===b.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(se,{value:g,onChange:A=>N(A.target.value),onKeyDown:A=>{A.key==="Enter"&&k(),A.key==="Escape"&&S()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:k,disabled:!g.trim(),children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:S,children:t.jsx(K,{"data-icon":"inline-start"})})]},b.path);const G=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:b.name}),t.jsx(ge,{linkTarget:b.linkTarget}),b.readOnly&&t.jsx(fe,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),b.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:b.description})]}),t.jsx(pe,{cli:b.cli}),t.jsx(he,{scope:b.scope,pluginName:b.pluginName})]}),M=P("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",_?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:M,onClick:()=>r(b),children:G},b.path):t.jsxs(Se,{children:[t.jsx(we,{render:t.jsx("button",{type:"button",className:M,onClick:()=>r(b)}),children:G}),t.jsx(De,{className:"min-w-36",children:b.readOnly?t.jsx(V,{children:t.jsx(Te,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(Z,{onClick:()=>c(b),children:"Rename"})}),t.jsx(Ee,{}),t.jsx(V,{children:t.jsx(Z,{variant:"destructive",onClick:()=>m(b),children:"Delete"})})]})})]},b.path)},e[28]=m,e[29]=S,e[30]=c,e[31]=k,e[32]=N,e[33]=r,e[34]=g,e[35]=d,e[36]=s,e[37]=$):$=e[37],E=n.map($),e[17]=n,e[18]=m,e[19]=S,e[20]=c,e[21]=k,e[22]=N,e[23]=r,e[24]=g,e[25]=d,e[26]=s,e[27]=E}else E=e[27];let I;e[38]!==f||e[39]!==n.length?(I=n.length===0&&!f&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=f,e[39]=n.length,e[40]=I):I=e[40];let O;e[41]!==f||e[42]!==h||e[43]!==w?(O=f&&t.jsx(ot,{globalDir:f.globalDir,projectDir:f.projectDir,fileType:f.fileType,onCreated:w,onCancel:h}),e[41]=f,e[42]=h,e[43]=w,e[44]=O):O=e[44];let B;return e[45]!==v||e[46]!==E||e[47]!==I||e[48]!==O?(B=t.jsxs("section",{children:[v,E,I,O]}),e[45]=v,e[46]=E,e[47]=I,e[48]=O,e[49]=B):B=e[49],B}function dt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,g]=o.useState(!1),[N,k]=o.useState(!1),[S,f]=o.useState(!1),[w,h]=o.useState(!1),p=n!==null&&n!==r,j=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),k(!1),f(!1),L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(C=>C.json()).then(C=>{s(C.content??""),u(C.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const D=o.useCallback(async()=>{if(!(!p||j)){g(!0);try{(await L("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),k(!0),setTimeout(()=>k(!1),2e3))}finally{g(!1)}}},[n,l.path,p,j]),T=o.useCallback(()=>{s(r)},[r]),y=o.useCallback(async()=>{if(!j){h(!0);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(f(!1),e())}catch{}finally{h(!1)}}},[l.path,j,e]);o.useEffect(()=>{function C(v){!j&&(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),D())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[D,j]);function R(){return N?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(ee,{variant:"outline",className:P("h-5 text-xs",st[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(he,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),j&&t.jsxs(ee,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),p&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(ge,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(nt,{value:n??"",onChange:s,readOnly:j,filePath:l.path}),!j&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(z,{size:"xs",onClick:D,disabled:!p||d,children:[t.jsx(H,{"data-icon":"inline-start"}),R()]}),t.jsxs(z,{variant:"outline",size:"xs",onClick:T,disabled:!p,children:[t.jsx(Xe,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(ae,{open:S,onOpenChange:f,children:[t.jsxs(Re,{render:t.jsx(z,{variant:"outline",size:"xs"}),children:[t.jsx(Ze,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",disabled:w,children:"Cancel"}),t.jsxs(ue,{variant:"destructive",size:"sm",disabled:w,onClick:()=>void y(),children:[w&&t.jsx(Ie,{"data-icon":"inline-start"}),w?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ut(){const l=F.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Oe,{className:"border-0",children:t.jsxs(ze,{children:[t.jsx(Ae,{variant:"icon",children:t.jsx(et,{})}),t.jsx(Le,{children:"Select a configuration file"}),t.jsx(Be,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function mt(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function xt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",mt(n)].some(r=>r.toLowerCase().includes(i)))}const yt=o.memo(function({projectPath:e,initialFilePath:i}){var A,Q;const n=$e("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[g,N]=o.useState(null),[k,S]=o.useState(""),[f,w]=o.useState(null),[h,p]=o.useState(""),[j,D]=o.useState(null),T=o.useRef(!1),y=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",x=await L(a);if(x.ok){const U=await x.json();r(U.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!i||u||T.current)return;const a=s.flatMap(x=>Y(x.items,x.scope,x.pluginName)).find(x=>x.path===i);a&&(d(a),T.current=!0)},[i,u,s]);const R=it(s),C=Object.fromEntries(ne.map(a=>[a,xt(R[a],k)])),v=(A=s.find(a=>a.scope==="global"))==null?void 0:A.baseDir,E=(Q=s.find(a=>a.scope==="project"))==null?void 0:Q.baseDir,I=o.useCallback(a=>{d(a),N(null)},[]),O=o.useCallback((a,x,U)=>{N(null),y(),d({path:a,name:a.split("/").pop()||"",fileType:x,readOnly:!1,scope:U,description:""})},[y]),B=o.useCallback(()=>{d(null),y()},[y]),$=o.useCallback(a=>{if(!n||!v&&!E)return;const x=at[a];x&&N({category:a,globalDir:v?`${v}/${x.subdir}`:null,projectDir:E?`${E}/${x.subdir}`:null,fileType:x.fileType})},[n,v,E]),b=o.useCallback(a=>{!n||a.readOnly||D(a)},[n]),_=o.useCallback(async()=>{if(!n||!j||j.readOnly)return;const a=j;D(null);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),y())}catch{}},[n,y,j,c]),J=o.useCallback(a=>{if(!n||a.readOnly)return;const x=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");w(a),p(x)},[n]),G=o.useCallback(async()=>{if(!(!n||!f||!h.trim()))try{const a=await L("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:f.path,newName:h.trim()})});if(a.ok){const x=await a.json();w(null),p(""),await y(),x.newPath&&d({...f,path:x.newPath,name:x.newPath.split("/").pop()||f.name})}}catch{}},[n,f,h,y]),M=o.useCallback(()=>{w(null),p("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-0 w-80 shrink-0 flex-col border-r bg-sidebar",children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Fe,{children:[t.jsx(te,{children:t.jsx(tt,{"data-icon":"inline-start"})}),t.jsx(Ge,{value:k,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),k&&t.jsx(te,{align:"inline-end",children:t.jsx(Me,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(K,{"data-icon":"inline-start"})})})]})}),t.jsx(Pe,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,x)=>t.jsx(_e,{className:"h-8 w-full"},x))}):ne.map(a=>{const x=a==="agents"||a==="skills"||a==="commands";return t.jsx(ct,{category:a,items:C[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:I,onNewFile:n&&x?()=>$(a):void 0,onDeleteItem:n?b:void 0,onRenameItem:n?J:void 0,renamingPath:(f==null?void 0:f.path)??null,renameValue:h,onRenameValueChange:p,onRenameSubmit:G,onRenameCancel:M,creatingInCategory:n&&(g==null?void 0:g.category)===a?g:null,onCreated:O,onCancelCreate:()=>N(null)},a)})})})]}),c?t.jsx(dt,{file:c,onDeleted:B,readOnly:!n}):t.jsx(ut,{}),t.jsx(ae,{open:j!==null,onOpenChange:a=>{a||D(null)},children:t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',j==null?void 0:j.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",children:"Cancel"}),t.jsx(ue,{variant:"destructive",size:"sm",onClick:()=>void _(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{yt as ConfigBrowser};
|
|
1
|
+
import{c as F,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{b1 as je,b3 as be,_ as P,U as ye,V as J,aW as q,Y as Ce,Z as X,a$ as se,B as z,w as L,b4 as ke,b5 as ve,b6 as Ne,b7 as Se,b8 as we,b9 as De,ba as V,bb as Te,bc as Z,bd as Ee,a4 as ee,a9 as ae,be as Re,aa as le,ab as ie,ad as re,ae as oe,af as ce,ag as de,ah as ue,al as Ie,E as Oe,y as ze,z as Ae,G as Le,H as $e,a3 as Be,m as Fe,I as te,n as Ge,W as Me,q as Pe,bf as Ue}from"./index-DFiPbdIb.js";import{ai as _e,y as Ve,h as He,a2 as Ke,aj as Qe,ak as We,al as me,am as xe,an as Ye,ao as Je,Q as H,X as K,P as qe,ap as fe,aq as Xe,j as Ze,$ as et,S as tt}from"./vendor-ui-DUTyrBOX.js";import{H as nt}from"./HighlightedEditor-Kf1cQYyg.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const st={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},at={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},ne=["instructions","agents","skills","commands","settings"],lt={instructions:{label:"Instructions",icon:Qe,color:"text-muted-foreground"},agents:{label:"Agents",icon:Ke,color:"text-muted-foreground"},skills:{label:"Skills",icon:He,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ve,color:"text-muted-foreground"},settings:{label:"Settings",icon:_e,color:"text-muted-foreground"}};function Q(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Q(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function it(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Q(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function he(l){const e=F.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(me,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const rt=Object.fromEntries(je().map(l=>[l.kind,be(l.kind)]));function pe(l){const e=F.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ye,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=rt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function ge(l){const e=F.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=P("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Je,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let g;return e[6]!==u||e[7]!==m||e[8]!==d?(g=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=g):g=e[9],g}function ot({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,g]=o.useState(!1),N=o.useRef(null),k=o.useId();o.useEffect(()=>{var h;(h=N.current)==null||h.focus()},[]);const S=m==="project"&&e?e:l,f=!!l&&!!e;async function w(){if(!(!r.trim()||!S)){g(!0);try{const h=await L("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:S,fileType:i,name:r.trim()})});if(h.ok){const p=await h.json();n(p.path,i,m)}}finally{g(!1)}}}return t.jsxs(ye,{className:"gap-3 px-3 py-2",children:[f&&t.jsxs(J,{children:[t.jsx(q,{children:"Scope"}),t.jsxs(Ce,{"aria-label":"File scope",value:[m],onValueChange:h=>{const p=h[0];(p==="global"||p==="project")&&c(p)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(X,{value:"global",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(X,{value:"project",className:"flex-1",children:[t.jsx(me,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(J,{children:[t.jsxs(q,{htmlFor:k,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(se,{id:k,ref:N,type:"text",value:r,onChange:h=>u(h.target.value),onKeyDown:h=>{h.key==="Enter"&&w(),h.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void w(),disabled:d||!r.trim()||!S,children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(K,{"data-icon":"inline-start"})})]})]})]})}function ct(l){const e=F.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:g,onRenameValueChange:N,onRenameSubmit:k,onRenameCancel:S,creatingInCategory:f,onCreated:w,onCancelCreate:h}=l,p=lt[i],j=p.icon;if(n.length===0&&!u)return null;let D;e[0]!==p.color?(D=P("size-3.5",p.color),e[0]=p.color,e[1]=D):D=e[1];let T;e[2]!==j||e[3]!==D?(T=t.jsx(j,{"data-icon":"inline-start",className:D}),e[2]=j,e[3]=D,e[4]=T):T=e[4];let y;e[5]!==p.label?(y=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:p.label}),e[5]=p.label,e[6]=y):y=e[6];let R;e[7]!==n.length?(R=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=R):R=e[8];let C;e[9]!==i||e[10]!==u?(C=u&&t.jsxs(ke,{children:[t.jsx(ve,{render:t.jsx(z,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(Ne,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=C):C=e[11];let v;e[12]!==T||e[13]!==y||e[14]!==R||e[15]!==C?(v=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[T,y,R,C]}),e[12]=T,e[13]=y,e[14]=R,e[15]=C,e[16]=v):v=e[16];let E;if(e[17]!==n||e[18]!==m||e[19]!==S||e[20]!==c||e[21]!==k||e[22]!==N||e[23]!==r||e[24]!==g||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==S||e[30]!==c||e[31]!==k||e[32]!==N||e[33]!==r||e[34]!==g||e[35]!==d||e[36]!==s?(B=b=>{const U=s===b.path;if(d===b.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(se,{value:g,onChange:A=>N(A.target.value),onKeyDown:A=>{A.key==="Enter"&&k(),A.key==="Escape"&&S()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:k,disabled:!g.trim(),children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:S,children:t.jsx(K,{"data-icon":"inline-start"})})]},b.path);const G=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:b.name}),t.jsx(ge,{linkTarget:b.linkTarget}),b.readOnly&&t.jsx(fe,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),b.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:b.description})]}),t.jsx(pe,{cli:b.cli}),t.jsx(he,{scope:b.scope,pluginName:b.pluginName})]}),M=P("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:M,onClick:()=>r(b),children:G},b.path):t.jsxs(Se,{children:[t.jsx(we,{render:t.jsx("button",{type:"button",className:M,onClick:()=>r(b)}),children:G}),t.jsx(De,{className:"min-w-36",children:b.readOnly?t.jsx(V,{children:t.jsx(Te,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(Z,{onClick:()=>c(b),children:"Rename"})}),t.jsx(Ee,{}),t.jsx(V,{children:t.jsx(Z,{variant:"destructive",onClick:()=>m(b),children:"Delete"})})]})})]},b.path)},e[28]=m,e[29]=S,e[30]=c,e[31]=k,e[32]=N,e[33]=r,e[34]=g,e[35]=d,e[36]=s,e[37]=B):B=e[37],E=n.map(B),e[17]=n,e[18]=m,e[19]=S,e[20]=c,e[21]=k,e[22]=N,e[23]=r,e[24]=g,e[25]=d,e[26]=s,e[27]=E}else E=e[27];let I;e[38]!==f||e[39]!==n.length?(I=n.length===0&&!f&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=f,e[39]=n.length,e[40]=I):I=e[40];let O;e[41]!==f||e[42]!==h||e[43]!==w?(O=f&&t.jsx(ot,{globalDir:f.globalDir,projectDir:f.projectDir,fileType:f.fileType,onCreated:w,onCancel:h}),e[41]=f,e[42]=h,e[43]=w,e[44]=O):O=e[44];let $;return e[45]!==v||e[46]!==E||e[47]!==I||e[48]!==O?($=t.jsxs("section",{children:[v,E,I,O]}),e[45]=v,e[46]=E,e[47]=I,e[48]=O,e[49]=$):$=e[49],$}function dt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,g]=o.useState(!1),[N,k]=o.useState(!1),[S,f]=o.useState(!1),[w,h]=o.useState(!1),p=n!==null&&n!==r,j=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),k(!1),f(!1),L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(C=>C.json()).then(C=>{s(C.content??""),u(C.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const D=o.useCallback(async()=>{if(!(!p||j)){g(!0);try{(await L("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),k(!0),setTimeout(()=>k(!1),2e3))}finally{g(!1)}}},[n,l.path,p,j]),T=o.useCallback(()=>{s(r)},[r]),y=o.useCallback(async()=>{if(!j){h(!0);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(f(!1),e())}catch{}finally{h(!1)}}},[l.path,j,e]);o.useEffect(()=>{function C(v){!j&&(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),D())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[D,j]);function R(){return N?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(ee,{variant:"outline",className:P("h-5 text-xs",st[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(he,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),j&&t.jsxs(ee,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),p&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(ge,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(nt,{value:n??"",onChange:s,readOnly:j,filePath:l.path}),!j&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(z,{size:"xs",onClick:D,disabled:!p||d,children:[t.jsx(H,{"data-icon":"inline-start"}),R()]}),t.jsxs(z,{variant:"outline",size:"xs",onClick:T,disabled:!p,children:[t.jsx(Xe,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(ae,{open:S,onOpenChange:f,children:[t.jsxs(Re,{render:t.jsx(z,{variant:"outline",size:"xs"}),children:[t.jsx(Ze,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",disabled:w,children:"Cancel"}),t.jsxs(ue,{variant:"destructive",size:"sm",disabled:w,onClick:()=>void y(),children:[w&&t.jsx(Ie,{"data-icon":"inline-start"}),w?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ut(){const l=F.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Oe,{className:"border-0",children:t.jsxs(ze,{children:[t.jsx(Ae,{variant:"icon",children:t.jsx(et,{})}),t.jsx(Le,{children:"Select a configuration file"}),t.jsx($e,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function mt(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function xt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",mt(n)].some(r=>r.toLowerCase().includes(i)))}const yt=o.memo(function({projectPath:e,initialFilePath:i}){var A,Y;const n=Be("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[g,N]=o.useState(null),[k,S]=o.useState(""),[f,w]=o.useState(null),[h,p]=o.useState(""),[j,D]=o.useState(null),T=o.useRef(!1),y=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",x=await L(a);if(x.ok){const _=await x.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!i||u||T.current)return;const a=s.flatMap(x=>Q(x.items,x.scope,x.pluginName)).find(x=>x.path===i);a&&(d(a),T.current=!0)},[i,u,s]);const R=it(s),C=Object.fromEntries(ne.map(a=>[a,xt(R[a],k)])),v=(A=s.find(a=>a.scope==="global"))==null?void 0:A.baseDir,E=(Y=s.find(a=>a.scope==="project"))==null?void 0:Y.baseDir,I=o.useCallback(a=>{d(a),N(null)},[]),O=o.useCallback((a,x,_)=>{N(null),y(),d({path:a,name:a.split("/").pop()||"",fileType:x,readOnly:!1,scope:_,description:""})},[y]),$=o.useCallback(()=>{d(null),y()},[y]),B=o.useCallback(a=>{if(!n||!v&&!E)return;const x=at[a];x&&N({category:a,globalDir:v?`${v}/${x.subdir}`:null,projectDir:E?`${E}/${x.subdir}`:null,fileType:x.fileType})},[n,v,E]),b=o.useCallback(a=>{!n||a.readOnly||D(a)},[n]),U=o.useCallback(async()=>{if(!n||!j||j.readOnly)return;const a=j;D(null);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),y())}catch{}},[n,y,j,c]),W=o.useCallback(a=>{if(!n||a.readOnly)return;const x=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");w(a),p(x)},[n]),G=o.useCallback(async()=>{if(!(!n||!f||!h.trim()))try{const a=await L("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:f.path,newName:h.trim()})});if(a.ok){const x=await a.json();w(null),p(""),await y(),x.newPath&&d({...f,path:x.newPath,name:x.newPath.split("/").pop()||f.name})}}catch{}},[n,f,h,y]),M=o.useCallback(()=>{w(null),p("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-0 w-80 shrink-0 flex-col border-r bg-sidebar",children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Fe,{children:[t.jsx(te,{children:t.jsx(tt,{"data-icon":"inline-start"})}),t.jsx(Ge,{value:k,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),k&&t.jsx(te,{align:"inline-end",children:t.jsx(Me,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(K,{"data-icon":"inline-start"})})})]})}),t.jsx(Pe,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,x)=>t.jsx(Ue,{className:"h-8 w-full"},x))}):ne.map(a=>{const x=a==="agents"||a==="skills"||a==="commands";return t.jsx(ct,{category:a,items:C[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:I,onNewFile:n&&x?()=>B(a):void 0,onDeleteItem:n?b:void 0,onRenameItem:n?W:void 0,renamingPath:(f==null?void 0:f.path)??null,renameValue:h,onRenameValueChange:p,onRenameSubmit:G,onRenameCancel:M,creatingInCategory:n&&(g==null?void 0:g.category)===a?g:null,onCreated:O,onCancelCreate:()=>N(null)},a)})})})]}),c?t.jsx(dt,{file:c,onDeleted:$,readOnly:!n}):t.jsx(ut,{}),t.jsx(ae,{open:j!==null,onOpenChange:a=>{a||D(null)},children:t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',j==null?void 0:j.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",children:"Cancel"}),t.jsx(ue,{variant:"destructive",size:"sm",onClick:()=>void U(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{yt as ConfigBrowser};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as z,r as _,j as f}from"./vendor-react-gGw_S5I_.js";import{
|
|
1
|
+
import{c as z,r as _,j as f}from"./vendor-react-gGw_S5I_.js";import{a0 as F,a1 as K,_ as A,a2 as O}from"./index-DFiPbdIb.js";const X=2e5;function Q(l){const e=z.c(35),{value:t,onChange:v,readOnly:u,filePath:y,ariaLabel:E,textareaRef:p,onKeyDown:L,onSelect:S}=l,h=F(),[d,I]=_.useState(null),m=_.useRef(null),x=_.useRef(null);let g;e[0]!==y?(g=K(y)??"markdown",e[0]=y,e[1]=g):g=e[1];const b=g,j=t.length>X;let k,R;e[2]!==h||e[3]!==b||e[4]!==j||e[5]!==t?(k=()=>{if(j){I(null);return}let r=!1;const M=setTimeout(()=>{O(t,b,h).then(P=>{r||I(P)})},80);return()=>{r=!0,clearTimeout(M)}},R=[t,b,h,j],e[2]=h,e[3]=b,e[4]=j,e[5]=t,e[6]=k,e[7]=R):(k=e[6],R=e[7]),_.useEffect(k,R);let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{m.current&&x.current&&(x.current.scrollTop=m.current.scrollTop,x.current.scrollLeft=m.current.scrollLeft)},e[8]=T):T=e[8];const G=T;let w;e[9]!==p?(w=r=>{m.current=r,p&&(p.current=r)},e[9]=p,e[10]=w):w=e[10];const C=w,N=u&&"opacity-70";let n;e[11]!==N?(n=A("absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",N),e[11]=N,e[12]=n):n=e[12];let s;e[13]!==d||e[14]!==t?(s=d?d.map($):f.jsx("code",{className:"text-foreground",children:t}),e[13]=d,e[14]=t,e[15]=s):s=e[15];let o;e[16]!==n||e[17]!==s?(o=f.jsx("pre",{ref:x,"aria-hidden":!0,className:n,children:s}),e[16]=n,e[17]=s,e[18]=o):o=e[18];let a;e[19]!==v?(a=r=>v(r.target.value),e[19]=v,e[20]=a):a=e[20];const D=u&&"cursor-default";let c;e[21]!==D?(c=A("absolute inset-0 w-full h-full resize-none bg-transparent font-mono text-[13px] leading-relaxed p-4 outline-none","text-transparent caret-foreground selection:bg-info/30","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",D),e[21]=D,e[22]=c):c=e[22];let i;e[23]!==E||e[24]!==C||e[25]!==L||e[26]!==S||e[27]!==u||e[28]!==a||e[29]!==c||e[30]!==t?(i=f.jsx("textarea",{ref:C,"aria-label":E,value:t,onChange:a,onScroll:G,onKeyDown:L,onSelect:S,readOnly:u,spellCheck:!1,className:c,placeholder:"Empty file"}),e[23]=E,e[24]=C,e[25]=L,e[26]=S,e[27]=u,e[28]=a,e[29]=c,e[30]=t,e[31]=i):i=e[31];let H;return e[32]!==i||e[33]!==o?(H=f.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[o,i]}),e[32]=i,e[33]=o,e[34]=H):H=e[34],H}function $(l,e){return f.jsxs("span",{children:[l.map(q),`
|
|
2
2
|
`]},e)}function q(l,e){return f.jsx("span",{style:{color:l.color},children:l.content},e)}export{Q as H};
|
package/dist/web/assets/{KeyboardShortcutsDialog-2606YXAx.js → KeyboardShortcutsDialog-CHb_hQuK.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-
|
|
1
|
+
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-DFiPbdIb.js";import{R as O,K as oe,S as ce}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function fe(e){const s=q.c(6),{open:f,onOpenChange:l}=e,x=f?"open":"closed";let a;s[0]!==x?(a=t.jsx(de,{},x),s[0]=x,s[1]=a):a=s[1];let r;return s[2]!==l||s[3]!==f||s[4]!==a?(r=t.jsx(F,{open:f,onOpenChange:l,children:a}),s[2]=l,s[3]=f,s[4]=a,s[5]=r):r=s[5],r}function de(){const e=q.c(45),[s,f]=k.useState(""),[l,x]=k.useState(null),[a,r]=k.useState(null),[B,G]=k.useState($);let E,I;e[0]!==l?(E=()=>{if(!l)return;const D=l,A=function(n){if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),x(null),r(null);return}if(ie.has(n.key))return;n.preventDefault(),n.stopPropagation();const c=le(n),p=ne(c,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),G($()),x(null),r(null)};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},I=[l],e[0]=l,e[1]=E,e[2]=I):(E=e[1],I=e[2]),k.useEffect(E,I);let g,j,d,y,b,N,S,w,m,u,h;if(e[3]!==B||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),A=D?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):T;j=H,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(M,{className:"p-4 pb-3",children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(J,{children:"Click a shortcut, then press a new key combination. Changes are saved on this device."})]}),u=t.jsx(V,{}),e[18]=m,e[19]=u):(m=e[18],u=e[19]);let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(W,{children:t.jsx(ce,{"data-icon":"inline-start","aria-hidden":"true"})}),e[20]=K):K=e[20];let n;e[21]===Symbol.for("react.memo_cache_sentinel")?(n=i=>f(i.target.value),e[21]=n):n=e[21];let c;e[22]!==s?(c=t.jsxs(X,{className:"flex-1",children:[K,t.jsx(Z,{"aria-label":"Search keyboard shortcuts",value:s,onChange:n,placeholder:"Search shortcuts…"})]}),e[22]=s,e[23]=c):c=e[23];let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs(P,{variant:"outline",size:"sm",onClick:()=>{ee(),G($()),r(null)},children:[t.jsx(O,{"data-icon":"inline-start"}),"Reset all"]}),e[24]=p):p=e[24],e[25]!==c?(h=t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[c,p]}),e[25]=c,e[26]=h):h=e[26],e[27]!==a?(d=a&&t.jsx(te,{variant:"destructive",className:"mx-3 mb-2 w-auto",children:t.jsxs(se,{children:[a," Press another shortcut or Esc to cancel."]})}),e[27]=a,e[28]=d):d=e[28],g=ae,N="h-[min(28rem,60vh)]",y="flex flex-col gap-4 px-3 pb-4",b=Q.map(i=>{const L=A.filter(o=>o.group===i);return L.length===0?null:t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:i}),L.map(o=>{const z=l===o.command;return t.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm",children:o.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.description})]}),t.jsx(P,{variant:z?"secondary":"outline",size:"sm",className:"min-w-28 font-mono text-xs",onClick:()=>{r(null),x(z?null:o.command)},"aria-label":`Change shortcut for ${o.label}`,children:z?"Press keys…":Y(B[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),G($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(O,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=B,e[4]=a,e[5]=s,e[6]=l,e[7]=g,e[8]=j,e[9]=d,e[10]=y,e[11]=b,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else g=e[7],j=e[8],d=e[9],y=e[10],b=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==y||e[30]!==b?(C=t.jsx("div",{className:y,children:b}),e[29]=y,e[30]=b,e[31]=C):C=e[31];let v;e[32]!==g||e[33]!==C||e[34]!==N?(v=t.jsx(g,{className:N,children:C}),e[32]=g,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==j||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(j,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=j,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{fe as KeyboardShortcutsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-
|
|
1
|
+
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-DFiPbdIb.js";import"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{E as MobileFileChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as t}from"./vendor-react-gGw_S5I_.js";import{T as ae,B as g,l as K,U as ie,V as oe,m as le,n as ce,I as de,W as G,X as ue,Y as he,Z as pe,_ as me,E as fe,y as xe,z as we,G as ve,H as ge,$ as be,w as je,Q as b}from"./index-
|
|
1
|
+
import{r as n,j as t}from"./vendor-react-gGw_S5I_.js";import{T as ae,B as g,l as K,U as ie,V as oe,m as le,n as ce,I as de,W as G,X as ue,Y as he,Z as pe,_ as me,E as fe,y as xe,z as we,G as ve,H as ge,$ as be,w as je,Q as b}from"./index-DFiPbdIb.js";import{E as H,X as ye,b as Se,c as Ie,d as Ne,M as ke,T as Ee,e as Me,f as Pe,Z as ze,g as Re}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const W=360,Te=560,B="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",k=.5,E=1.5,N=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:Ee},desktop:{label:"Desktop",width:1280,height:800,icon:ke}};function Ce(){try{const s=Number(localStorage.getItem(B));if(Number.isFinite(s)&&s>=W)return s}catch{}return Te}function De(){try{const s=localStorage.getItem(Y);if(s&&s in h)return s}catch{}return"responsive"}function We(){try{const s=localStorage.getItem(_);if(s===null)return 1;const i=Number(s);if(Number.isFinite(i))return Math.min(E,Math.max(k,i))}catch{}return 1}function X(s){return be(`cogpit-preview-url:${s}`)}function V(s){const i=s.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const a=new URL(j);return a.protocol!=="http:"&&a.protocol!=="https:"?null:a.href}catch{return null}}function A(s,i){return`http://${i||"localhost"}:${s}/`}function Le({cwd:s,onClose:i}){const[M,j]=n.useState([]),[a,P]=n.useState(""),[$,y]=n.useState(""),[z,R]=n.useState(null),[Q,q]=n.useState(0),[J,T]=n.useState(!1),[S,ee]=n.useState(Ce),[l,te]=n.useState(De),[o,p]=n.useState(We),c=n.useRef(null),O=n.useRef(null),C=n.useRef(null),{activeDevice:m}=ae(),I=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;n.useEffect(()=>{let e="";try{e=localStorage.getItem(X(s))??""}catch{}const r=e?V(e)??"":"";P(r),y(r),R(null)},[s,re]),n.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(s)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=A(L,I);P(v=>v||w),y(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[s,I]),n.useEffect(()=>{if(a)try{localStorage.setItem(X(s),a)}catch{}},[s,a]),n.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=n.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=n.useCallback(e=>{const r=V(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),y(r),T(!0)},[]),D=n.useCallback(()=>{a&&(T(!0),q(e=>e+1))},[a]);n.useEffect(()=>{function e(r){var d,u,x;if((d=O.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),D();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=C.current)==null||u.focus(),(x=C.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(E,Number((f+N).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(k,Number((f-N).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D]);const se=n.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:S,currentWidth:S},e.currentTarget.setPointerCapture(e.pointerId)},[S]),ne=n.useCallback(e=>{if(!c.current)return;const r=Math.max(W,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(W,d));c.current.currentWidth=u,ee(u)},[]),F=n.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(B,String(e))}catch{}},[]);return t.jsxs("aside",{ref:O,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-background",style:{width:S},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:se,onPointerMove:ne,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(ye,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U($)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:C,"aria-label":"Preview URL","aria-invalid":!!z,value:$,onChange:e=>y(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!a,onClick:D,"aria-label":"Refresh preview",children:t.jsx(Se,{"data-icon":"inline-start",className:J?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!a,onClick:()=>window.open(a,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ie,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ne,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(A(e,I)),"aria-label":`Open ${I}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=k,onClick:()=>p(e=>Math.max(k,Number((e-N).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=E,onClick:()=>p(e=>Math.min(E,Number((e+N).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:a?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:a,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>T(!1)},`${a}-${Q}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Le as PreviewPanel,V as normalizePreviewUrl};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as a,j as t,c as Pe}from"./vendor-react-gGw_S5I_.js";import{E as V,y as Y,z as Q,G as q,H as J,w as ie,_ as we,aw as ut,al as ge,B as P,ax as Mt,ay as It,az as zt,aA as $t,l as xe,a4 as le,m as At,I as Ut,n as Pt,Y as rt,Z as me,q as Ot,aB as Gt,aC as Ht,aD as Wt,D as Kt,h as Bt,i as Xt,j as Vt,k as Yt,aE as Qt,aF as qt,a9 as Jt,aa as Zt,ab as _t,ad as es,ae as ts,af as ss,ag as ns,ah as as,Q as ls}from"./index-DFiPbdIb.js";import{H as is}from"./HighlightedEditor-Kf1cQYyg.js";import{J as je,o as Ae,F as rs,N as os,C as cs,X as ds,G as fs,S as us,b as ot,O as ct,Q as hs,k as ze}from"./vendor-ui-DUTyrBOX.js";import{M as xs}from"./vendor-markdown-BE1gYnO9.js";import"./vendor-shiki-DOn6sF-i.js";const ms=12,ht="h-6 w-full justify-start gap-1 rounded-none px-2 text-left font-normal";function Ce(n,e){return{paddingLeft:8+n*ms+(e?0:16)}}function ps(n){const e=n;return typeof e=="object"&&e!==null&&typeof e.name=="string"&&(e.type==="file"||e.type==="directory")}function gs(n){const e=n==null?void 0:n.entries;return Array.isArray(e)?e.filter(ps):[]}async function dt(n,e,i){try{const o=await ie(`/api/project-files/tree?cwd=${encodeURIComponent(n)}&dir=${encodeURIComponent(e)}${i?"&refresh=1":""}`);if(!o.ok){const p=await o.json().catch(()=>null),u=p==null?void 0:p.error;throw new Error(typeof u=="string"?u:"Unable to list directory")}const c=await o.json();return{status:"ready",entries:gs(c),scanLimited:c.scanLimited===!0}}catch(o){return{status:"error",message:o instanceof Error?o.message:"Unable to list directory"}}}function js(n){const e=n.split("/");return e.slice(0,-1).map((i,o)=>e.slice(0,o+1).join("/"))}function ws({cwd:n,selectedPath:e,onSelect:i,fileStatus:o,reloadToken:c}){const[p,u]=a.useState(()=>new Map),[S,j]=a.useState(()=>new Set),w=a.useRef(new Set),D=a.useRef(n);D.current=n;const x=a.useCallback(async m=>{if(w.current.has(m))return;w.current.add(m),u(b=>new Map(b).set(m,{status:"loading"}));const y=await dt(n,m,!1);w.current.delete(m),D.current===n&&u(b=>new Map(b).set(m,y))},[n]),f=a.useRef(null);a.useEffect(()=>{const m=f.current===n;f.current=n,m||j(new Set),u(new Map([["",{status:"loading"}]]));let y=!1;return dt(n,"",m).then(b=>{y||u(new Map([["",b]]))}),()=>{y=!0}},[n,c]),a.useEffect(()=>{if(!e)return;const m=js(e);m.length!==0&&j(y=>{if(m.every(R=>y.has(R)))return y;const b=new Set(y);for(const R of m)b.add(R);return b})},[e]);const N=a.useCallback(m=>{j(y=>{const b=new Set(y);return b.has(m)?b.delete(m):b.add(m),b})},[]),g=p.get(""),E=ys(g);return t.jsxs("div",{"aria-label":"Project file tree",className:"flex flex-col py-1",children:[E?t.jsx(V,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(E.Icon,{})}),t.jsx(q,{children:E.title}),t.jsx(J,{children:E.description})]})}):t.jsx(xt,{directory:"",depth:0,state:g,directories:p,expanded:S,selectedPath:e,onSelect:i,onToggle:N,onLoad:x,fileStatus:o}),(g==null?void 0:g.status)==="ready"&&g.scanLimited&&t.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"This project is too large to scan completely."})]})}function ys(n){return(n==null?void 0:n.status)==="error"?{Icon:je,title:"Could not load files",description:n.message}:(n==null?void 0:n.status)==="ready"&&n.entries.length===0?{Icon:Ae,title:"No files",description:"This project has no files to show."}:null}function xt(n){const e=Pe.c(22),{directory:i,depth:o,state:c,onLoad:p,...u}=n;let S,j;if(e[0]!==i||e[1]!==p||e[2]!==c?(S=()=>{c===void 0&&i!==""&&p(i)},j=[i,p,c],e[0]=i,e[1]=p,e[2]=c,e[3]=S,e[4]=j):(S=e[3],j=e[4]),a.useEffect(S,j),!c||c.status==="loading"){let x;e[5]!==o?(x=Ce(o,!1),e[5]=o,e[6]=x):x=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(ge,{className:"size-3"}),e[7]=f):f=e[7];const N=i===""&&"Loading files…";let g;return e[8]!==x||e[9]!==N?(g=t.jsxs("div",{role:"status",className:"flex h-6 items-center gap-2 text-xs text-muted-foreground",style:x,children:[f,N]}),e[8]=x,e[9]=N,e[10]=g):g=e[10],g}if(c.status==="error"){let x;e[11]!==o?(x=Ce(o,!1),e[11]=o,e[12]=x):x=e[12];let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(je,{"aria-hidden":"true",className:"size-3 shrink-0"}),e[13]=f):f=e[13];let N;e[14]!==c.message?(N=t.jsx("span",{className:"truncate",children:c.message}),e[14]=c.message,e[15]=N):N=e[15];let g;return e[16]!==c.message||e[17]!==x||e[18]!==N?(g=t.jsxs("div",{role:"alert",className:"flex h-6 items-center gap-1.5 truncate text-xs text-destructive",style:x,title:c.message,children:[f,N]}),e[16]=c.message,e[17]=x,e[18]=N,e[19]=g):g=e[19],g}const w=c.entries.map(x=>{const f=i?`${i}/${x.name}`:x.name;return x.type==="directory"?t.jsx(vs,{path:f,name:x.name,depth:o,onLoad:p,...u},f):t.jsx(bs,{path:f,name:x.name,depth:o,selected:u.selectedPath===f,status:u.fileStatus(f),onSelect:u.onSelect},f)});let D;return e[20]!==w?(D=t.jsx(t.Fragment,{children:w}),e[20]=w,e[21]=D):D=e[21],D}function vs(n){const e=Pe.c(48);let i,o,c,p,u,S,j,w,D,x,f,N,g,E,m,y,b;e[0]!==n?({path:j,name:u,depth:p,...w}=n,S=w.expanded.has(j),i=S?rs:os,c=P,f="ghost",N="sm",g=S,E=ht,e[18]!==p?(m=Ce(p,!0),e[18]=p,e[19]=m):m=e[19],y=()=>w.onToggle(j),b=j,o=cs,D="true",x=we("size-3 shrink-0 text-muted-foreground transition-transform",S&&"rotate-90"),e[0]=n,e[1]=i,e[2]=o,e[3]=c,e[4]=p,e[5]=u,e[6]=S,e[7]=j,e[8]=w,e[9]=D,e[10]=x,e[11]=f,e[12]=N,e[13]=g,e[14]=E,e[15]=m,e[16]=y,e[17]=b):(i=e[1],o=e[2],c=e[3],p=e[4],u=e[5],S=e[6],j=e[7],w=e[8],D=e[9],x=e[10],f=e[11],N=e[12],g=e[13],E=e[14],m=e[15],y=e[16],b=e[17]);let R;e[20]!==o||e[21]!==D||e[22]!==x?(R=t.jsx(o,{"aria-hidden":D,className:x}),e[20]=o,e[21]=D,e[22]=x,e[23]=R):R=e[23];let F;e[24]!==i?(F=t.jsx(i,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[24]=i,e[25]=F):F=e[25];let T;e[26]!==u?(T=t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:u}),e[26]=u,e[27]=T):T=e[27];let L;e[28]!==c||e[29]!==R||e[30]!==F||e[31]!==T||e[32]!==f||e[33]!==N||e[34]!==g||e[35]!==E||e[36]!==m||e[37]!==y||e[38]!==b?(L=t.jsxs(c,{variant:f,size:N,"aria-expanded":g,className:E,style:m,onClick:y,title:b,children:[R,F,T]}),e[28]=c,e[29]=R,e[30]=F,e[31]=T,e[32]=f,e[33]=N,e[34]=g,e[35]=E,e[36]=m,e[37]=y,e[38]=b,e[39]=L):L=e[39];let M;e[40]!==p||e[41]!==S||e[42]!==j||e[43]!==w?(M=S&&t.jsx("div",{children:t.jsx(xt,{directory:j,depth:p+1,state:w.directories.get(j),...w})}),e[40]=p,e[41]=S,e[42]=j,e[43]=w,e[44]=M):M=e[44];let U;return e[45]!==L||e[46]!==M?(U=t.jsxs("div",{children:[L,M]}),e[45]=L,e[46]=M,e[47]=U):U=e[47],U}function bs(n){const e=Pe.c(28),{path:i,name:o,depth:c,selected:p,status:u,onSelect:S}=n,j=a.useRef(null);let w;e[0]!==i?(w=ut(i),e[0]=i,e[1]=w):w=e[1];const D=w;let x,f;e[2]!==p?(x=()=>{var M,U;p&&((U=(M=j.current)==null?void 0:M.scrollIntoView)==null||U.call(M,{block:"nearest"}))},f=[p],e[2]=p,e[3]=x,e[4]=f):(x=e[3],f=e[4]),a.useEffect(x,f);const N=p||void 0,g=p?"secondary":"ghost";let E;e[5]!==c?(E=Ce(c,!1),e[5]=c,e[6]=E):E=e[6];let m;e[7]!==S||e[8]!==i?(m=()=>S(i),e[7]=S,e[8]=i,e[9]=m):m=e[9];let y;e[10]!==D?(y=t.jsx(D,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[10]=D,e[11]=y):y=e[11];const b=u&&u.className;let R;e[12]!==b?(R=we("min-w-0 flex-1 truncate text-xs",b),e[12]=b,e[13]=R):R=e[13];let F;e[14]!==o||e[15]!==R?(F=t.jsx("span",{className:R,children:o}),e[14]=o,e[15]=R,e[16]=F):F=e[16];let T;e[17]!==u?(T=u&&t.jsx("span",{className:we("shrink-0 font-mono text-[10px]",u.className),title:u.label,children:u.code}),e[17]=u,e[18]=T):T=e[18];let L;return e[19]!==i||e[20]!==F||e[21]!==T||e[22]!==N||e[23]!==g||e[24]!==E||e[25]!==m||e[26]!==y?(L=t.jsxs(P,{ref:j,"aria-current":N,variant:g,size:"sm",className:ht,style:E,onClick:m,title:i,children:[y,F,T]}),e[19]=i,e[20]=F,e[21]=T,e[22]=N,e[23]=g,e[24]=E,e[25]=m,e[26]=y,e[27]=L):L=e[27],L}const Ue=520,Ns=760,mt="cogpit-project-files-width",Ss={"?":{label:"Untracked",className:"text-info"},A:{label:"Added",className:"text-success"},M:{label:"Modified",className:"text-warning"},D:{label:"Deleted",className:"text-destructive"},R:{label:"Renamed",className:"text-info"},C:{label:"Copied",className:"text-info"},U:{label:"Conflicted",className:"text-destructive"}};function $e(n){const e=n.workTreeStatus.trim()||n.indexStatus.trim();return Ss[e]??{label:"Changed",className:"text-muted-foreground"}}function Cs(n){return`${n.indexStatus}${n.workTreeStatus}`.trim()||"?"}const ks=new Set([".md",".mdx",".markdown"]);function ft(n){const e=n.lastIndexOf(".");return e!==-1&&ks.has(n.slice(e).toLowerCase())}function Es(n,e,i){if(!n||/^(?:[a-z]+:|\/|#)/i.test(n))return n;const o=i.includes("/")?i.slice(0,i.lastIndexOf("/")):"",c=[];for(const u of[...o.split("/"),...n.split("/")])u===".."?c.pop():u&&u!=="."&&c.push(u);const p=e.includes("\\")?"\\":"/";return[e.replace(/[\\/]+$/,""),...c].join(p)}function Ds(){try{const n=Number(localStorage.getItem(mt));if(Number.isFinite(n)&&n>=Ue)return n}catch{}return Ns}async function pe(n,e){try{const i=await n.json();if(i&&typeof i=="object"&&typeof i.error=="string")return i.error}catch{}return e}function Rs(n){return n<1024?`${n} B`:`${(n/1024).toFixed(n<10*1024?1:0)} KB`}function Fs(n,e){let i=0;for(let o=1;o<e;o+=1){const c=n.indexOf(`
|
|
2
|
+
`,i);if(c<0)return i;i=c+1}return i}function As({cwd:n,onClose:e,onAddToPrompt:i,openRequest:o,embedded:c=!1}){const p=a.useRef(null),u=a.useRef(null),S=a.useRef(null),j=a.useRef(null),[w,D]=a.useState(Ds),x=a.useRef(w),[f,N]=a.useState(""),[g,E]=a.useState([]),[m,y]=a.useState(!0),[b,R]=a.useState(null),[F,T]=a.useState(0),[L,M]=a.useState(!1),[U,pt]=a.useState(0),ke=a.useRef(!1),[r,Oe]=a.useState(null),[I,Z]=a.useState(""),[gt,re]=a.useState(""),[O,oe]=a.useState(null),[jt,Ge]=a.useState(0),[K,He]=a.useState(!1),[_,We]=a.useState(!1),[Ke,ee]=a.useState(null),[wt,te]=a.useState(!1),[z,Ee]=a.useState("all"),[v,Be]=a.useState(null),[Xe,Ve]=a.useState(!1),[yt,Ye]=a.useState(null),[C,ce]=a.useState("edit"),[k,ye]=a.useState(null),[de,Qe]=a.useState(!1),[qe,De]=a.useState(null),[fe,B]=a.useState(null),[G,ve]=a.useState(null),[be,Re]=a.useState(""),[W,ue]=a.useState(null),$=r!==null&&I!==gt,A=a.useMemo(()=>new Map(((v==null?void 0:v.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[v==null?void 0:v.files]),se=a.useCallback(async()=>{Ve(!0),Ye(null);try{const s=await ie(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const l=await s.json();Be(l),l.isRepository||Ee("all")}catch(s){Be(null),Ee("all"),Ye(s instanceof Error?s.message:"Unable to read git status")}finally{Ve(!1)}},[n]);a.useEffect(()=>{se()},[se]);const Fe=z==="all"&&f.trim()==="";a.useEffect(()=>{if(Fe)return;const s=new AbortController,l=window.setTimeout(async()=>{y(!0),R(null);const d=ke.current;ke.current=!1;try{const h=await ie(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(f)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!h.ok)throw new Error(await pe(h,"Unable to list project files"));const H=await h.json();if(s.signal.aborted)return;const lt=Mt(H),it=H.totalMatches;E(lt),T(typeof it=="number"?it:lt.length),M(H.scanLimited===!0)}catch(h){s.signal.aborted||(E([]),R(h instanceof Error?h.message:"Unable to list project files"))}finally{s.signal.aborted||y(!1)}},120);return()=>{window.clearTimeout(l),s.abort()}},[n,f,U,Fe]),a.useEffect(()=>{Oe(null),Z(""),re(""),oe(null),ee(null),B(null),ce("edit"),ye(null),De(null),ue(null)},[n]),a.useEffect(()=>{if(!$)return;const s=l=>l.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[$]);const vt=a.useCallback((s,l)=>{const d=u.current;if(!d)return;if(!l||l<1){d.focus();return}const h=Fs(s,l);d.blur(),d.setSelectionRange(h,h),d.focus()},[]);a.useEffect(()=>{const s=S.current;!s||!u.current||(S.current=null,vt(s.text,s.line))});const ne=a.useCallback(async(s,l)=>{He(!0),ee(null),te(!1),B(null);try{const d=await ie(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const h=await d.json();Z(h.content),re(h.content),oe(h.mtimeMs),Ge(h.size),S.current={text:h.content,line:l}}catch(d){Z(""),re(""),oe(null),ee(d instanceof Error?d.message:"Unable to open file")}finally{He(!1)}},[n]),ae=a.useCallback(async(s,l)=>{Qe(!0),De(null),ye(null);try{const d=l?`&originalPath=${encodeURIComponent(l)}`:"",h=await ie(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!h.ok)throw new Error(await pe(h,"Unable to diff file"));ye(await h.json())}catch(d){De(d instanceof Error?d.message:"Unable to diff file")}finally{Qe(!1)}},[n]),Ne=a.useCallback(({path:s,mode:l,line:d})=>{var h;if(Oe(s),l==="edit"){ce(ft(s)&&!d?"preview":"edit"),ne(s,d);return}ce(l),Z(""),re(""),oe(null),ee(null),te(!1),B(null),ae(s,(h=A.get(s))==null?void 0:h.originalPath)},[A,ae,ne]),Se=a.useCallback(s=>{if($){ue({type:"file",target:s});return}Ne(s)},[$,Ne]),Je=a.useCallback(s=>{if(s===r)return;const l=z==="changes"&&A.has(s)?"diff":"edit";Se({path:s,mode:l})},[A,z,Se,r]),Ze=a.useRef(0);a.useEffect(()=>{!o||o.token===Ze.current||(Ze.current=o.token,Se({path:o.file,mode:o.mode,line:o.line}))},[o,Se]);const bt=a.useCallback(()=>{var s;!r||C==="diff"||(ce("diff"),(k==null?void 0:k.path)!==r&&!de&&ae(r,(s=A.get(r))==null?void 0:s.originalPath))},[A,k==null?void 0:k.path,de,ae,r,C]),Nt=a.useCallback(s=>{!r||C===s||(ce(s),O===null&&!K&&ne(r))},[K,ne,O,r,C]),Te=a.useCallback(()=>{var s;if(r){if(C==="diff"){ae(r,(s=A.get(r))==null?void 0:s.originalPath);return}ne(r)}},[A,ae,ne,r,C]),St=a.useCallback(()=>{ke.current=!0,pt(s=>s+1),se(),C==="diff"&&Te()},[se,Te,C]),Le=a.useCallback(async()=>{if(!(!r||O===null||!$||_)){We(!0),ee(null),te(!1);try{const s=await ie("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,path:r,content:I,expectedMtimeMs:O})});if(!s.ok)throw new Error(await pe(s,"Unable to save file"));const l=await s.json();re(I),oe(l.mtimeMs),Ge(l.size),te(!0),ye(null),se()}catch(s){ee(s instanceof Error?s.message:"Unable to save file")}finally{We(!1)}}},[I,n,$,se,O,_,r]);a.useEffect(()=>{function s(l){var d;(d=p.current)!=null&&d.contains(document.activeElement)&&ls("projectFileSave",l)&&(l.preventDefault(),Le())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Le]);const Ct=a.useCallback(()=>{if($){ue({type:"close"});return}e()},[$,e]),kt=a.useCallback(()=>{if(!W)return;const s=W;if(ue(null),s.type==="file"){Ne(s.target);return}e()},[e,Ne,W]),Et=a.useCallback(s=>{if(s.key!=="Tab")return;s.preventDefault();const l=s.currentTarget,d=l.selectionStart,h=l.selectionEnd,H=`${I.slice(0,d)} ${I.slice(h)}`;Z(H),te(!1),B(null),requestAnimationFrame(()=>{l.selectionStart=d+2,l.selectionEnd=d+2})},[I]),Dt=a.useCallback(s=>{const l=s.currentTarget;if(l.selectionStart===l.selectionEnd){B(null);return}const d=I.slice(l.selectionStart,l.selectionEnd),h=I.slice(0,l.selectionStart).split(`
|
|
3
|
+
`).length,H=h+d.split(`
|
|
4
|
+
`).length-1;B({text:d,startLine:h,endLine:H})},[I]),Rt=a.useCallback(s=>{s.preventDefault(),j.current={startX:s.clientX,startWidth:w},s.currentTarget.setPointerCapture(s.pointerId)},[w]),Ft=a.useCallback(s=>{if(!j.current)return;const l=Math.max(Ue,window.innerWidth*.9),d=j.current.startWidth+(j.current.startX-s.clientX),h=Math.min(l,Math.max(Ue,d));x.current=h,D(h)},[]),_e=a.useCallback(()=>{if(j.current){j.current=null;try{localStorage.setItem(mt,String(x.current))}catch{}}},[]),Me=a.useMemo(()=>(r==null?void 0:r.split("/").at(-1))??null,[r]),he=r?A.get(r):void 0,et=r!==null&&ft(r),tt=a.useCallback(s=>{const l=A.get(s);return l?{code:Cs(l),...$e(l)}:null},[A]),Tt=a.useMemo(()=>({...It,img:s=>t.jsx(zt,{src:Es(s.src,n,r??""),alt:s.alt})}),[n,r]),Ie=a.useMemo(()=>k&&!k.binary&&!k.tooLarge?$t(k.original??"",k.current??""):null,[k]),X=a.useMemo(()=>{if(z==="all")return g;const s=f.trim().toLowerCase();return((v==null?void 0:v.files)??[]).map(l=>l.path).filter((l,d,h)=>h.indexOf(l)===d).filter(l=>!s||l.toLowerCase().includes(s)).sort((l,d)=>l.localeCompare(d))},[z,g,v==null?void 0:v.files,f]),st=a.useMemo(()=>r&&!X.includes(r)?[r,...X]:X,[X,r]),Lt=z==="changes"?Xe:m,nt=z==="changes"?yt:b,at=Xe;return t.jsxs("aside",{ref:p,"aria-label":"Project files",className:we("relative flex min-h-0 flex-col bg-background",c?"size-full":"view-transition-right-panel panel-enter-right shrink-0 border-l"),style:c?void 0:{width:w},children:[!c&&t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-accent",onPointerDown:Rt,onPointerMove:Ft,onPointerUp:_e,onPointerCancel:_e}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(Ae,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:Ct,"aria-label":"Close project files",children:t.jsx(ds,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(v==null?void 0:v.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(fs,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:v.branch??"Detached HEAD",children:v.branch??"detached HEAD"}),v.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",v.upstream]}),(v.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",v.ahead]}),(v.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",v.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[v.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:"flex w-56 shrink-0 flex-col",children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(At,{className:"min-w-0 flex-1",children:[t.jsx(Ut,{children:t.jsx(us,{"data-icon":"inline-start"})}),t.jsx(Pt,{"aria-label":"Search project files",value:f,onChange:s=>N(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(P,{variant:"ghost",size:"icon-sm",disabled:at,onClick:St,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(ot,{"data-icon":"inline-start",className:at?"animate-spin":void 0})})]}),(v==null?void 0:v.isRepository)&&t.jsxs(rt,{"aria-label":"File scope",value:[z],onValueChange:s=>{const l=s[0];(l==="all"||l==="changes")&&Ee(l)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(me,{value:"all",className:"flex-1",children:"All files"}),t.jsx(me,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Ot,{className:"min-h-0 flex-1",children:Fe?t.jsx(ws,{cwd:n,selectedPath:r,onSelect:Je,fileStatus:tt,reloadToken:U}):Lt?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(ge,{}),"Loading files…"]}):nt?t.jsx(V,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(je,{})}),t.jsx(q,{children:"Could not load files"}),t.jsx(J,{children:nt})]})}):st.length===0?t.jsx(V,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(Ae,{})}),t.jsx(q,{children:z==="changes"?"No working-tree changes":"No matching files"}),t.jsx(J,{children:z==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[st.map(s=>{const l=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",h=tt(s),H=ut(s);return t.jsxs(P,{variant:r===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>Je(s),title:s,children:[t.jsx(H,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:l}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),h&&t.jsx(le,{variant:"outline",className:we("font-mono",h.className),title:h.label,children:h.code})]},s)}),z==="all"&&(F>X.length||L)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[F>X.length&&`Showing ${X.length} of ${F} matches. Type to narrow the list. `,L&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical"}),t.jsx("section",{"aria-label":"File editor",className:"flex min-w-0 flex-1 flex-col",children:r?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:r,children:Me}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:r})]}),(he||C==="diff"||et)&&t.jsxs(rt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?bt():(s[0]==="edit"||s[0]==="preview")&&Nt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(he||C==="diff")&&t.jsx(me,{value:"diff",children:"Diff"}),et&&t.jsx(me,{value:"preview",children:"Preview"}),t.jsx(me,{value:"edit",children:"Edit"})]}),C==="diff"&&he&&t.jsx(le,{variant:"outline",className:$e(he).className,children:$e(he).label}),C==="diff"&&Ie&&t.jsx(Gt,{add:Ie.add,del:Ie.del}),C!=="diff"&&$&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!$&&wt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&O!==null&&t.jsx("span",{className:"text-xs text-muted-foreground",children:Rs(jt)}),i&&t.jsxs(P,{variant:"outline",size:"sm",disabled:C==="diff"?de||k===null:K||O===null,onClick:()=>{fe?(Re(""),ve(fe)):i({path:r})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(ct,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(P,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||_,onClick:Te,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(ot,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(P,{size:"sm",disabled:!$||K||_||O===null,onClick:()=>void Le(),children:[_?t.jsx(ge,{"data-icon":"inline-start"}):t.jsx(hs,{"data-icon":"inline-start"}),_?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Ke&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(je,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Ke})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ge,{}),"Loading diff…"]}):qe?t.jsx(V,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(je,{})}),t.jsx(q,{children:"Could not diff this file"}),t.jsx(J,{children:qe})]})}):k===null?null:k.binary||k.tooLarge?t.jsx(V,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:k.binary?"Binary file":"File is too large to diff"}),t.jsx(J,{children:k.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):k.original===k.current?t.jsx(V,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:"No content changes"}),t.jsx(J,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(Ht,{oldString:k.original??"",newString:k.current??"",filePath:r,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ge,{}),"Opening file…"]}),!K&&O!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${r}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(xs,{components:Tt,remarkPlugins:Wt,children:I})}):t.jsx(is,{textareaRef:u,ariaLabel:`Editing ${r}`,filePath:r,value:I,readOnly:!1,onChange:s=>{Z(s),te(!1),B(null)},onKeyDown:Et,onSelect:Dt}))]})]}):t.jsx(V,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:"Select a file"}),t.jsx(J,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx(Kt,{open:G!==null,onOpenChange:s=>{s||ve(null)},children:t.jsxs(Bt,{children:[t.jsxs(Xt,{children:[t.jsx(Vt,{children:"Comment on selected lines"}),t.jsxs(Yt,{children:["Add a review instruction for ",r," lines ",G==null?void 0:G.startLine,"-",G==null?void 0:G.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const l=be.trim();!r||!G||!l||!i||(i({path:r,...G,comment:l}),ve(null),Re(""))},children:[t.jsx(Qt,{autoFocus:!0,"aria-label":"Review comment",value:be,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var l;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&be.trim()&&(s.preventDefault(),(l=s.currentTarget.form)==null||l.requestSubmit())}}),t.jsxs(qt,{children:[t.jsx(P,{type:"button",variant:"outline",onClick:()=>ve(null),children:"Cancel"}),t.jsxs(P,{type:"submit",disabled:!be.trim(),children:[t.jsx(ct,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Jt,{open:W!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Zt,{size:"sm",children:[t.jsxs(_t,{children:[t.jsx(es,{children:"Discard unsaved changes?"}),t.jsx(ts,{children:(W==null?void 0:W.type)==="file"?`Your edits to ${Me??"this file"} will be lost when you open ${W.target.path}.`:`Your edits to ${Me??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(ss,{children:[t.jsx(ns,{size:"sm",children:"Keep editing"}),t.jsx(as,{variant:"destructive",size:"sm",onClick:kt,children:"Discard changes"})]})]})})]})}export{As as ProjectFilesPanel};
|
package/dist/web/assets/{ProjectSwitcherModal-D8boI2Qx.js → ProjectSwitcherModal-CxQ6p2B4.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as U,r as A,j as t}from"./vendor-react-gGw_S5I_.js";import{v as X,w as Y,i as Z,j as _,k as ee,C as te,x as se,E as ae,y as ne,z as ie,G as oe,H as le,J as q,L as re,M as J,N as de,O as ce,h as me,P as he,D as ue,Q as fe,R as xe}from"./index-
|
|
1
|
+
import{c as U,r as A,j as t}from"./vendor-react-gGw_S5I_.js";import{v as X,w as Y,i as Z,j as _,k as ee,C as te,x as se,E as ae,y as ne,z as ie,G as oe,H as le,J as q,L as re,M as J,N as de,O as ce,h as me,P as he,D as ue,Q as fe,R as xe}from"./index-DFiPbdIb.js";import{F as Q,a as pe}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function ve(v){const e=U.c(56),{open:l,onClose:n,onNewSession:c,onNewFolder:H,defaultAgentKind:O,currentProjectDirName:u,currentProjectCwd:m}=v;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[0]=S):S=e[0];const[o,K]=A.useState(S),[r,W]=A.useState("");let P,D;e[1]!==l?(P=()=>{l&&(W(""),Y("/api/projects").then(Ne).then(s=>K(s)).catch(()=>K([])))},D=[l],e[1]=l,e[2]=P,e[3]=D):(P=e[2],D=e[3]),A.useEffect(P,D);let E,F;e[4]!==m||e[5]!==u||e[6]!==n||e[7]!==c||e[8]!==l||e[9]!==o?(E=()=>{if(!l)return;const s=function(h){var y;if(fe("newSession",h)&&u){h.preventDefault();const V=m?xe(o,m,"claude")??((y=o.find(B=>B.path===m))==null?void 0:y.dirName)??u:u;c(V,m??void 0),n()}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},F=[l,o,u,m,c,n],e[4]=m,e[5]=u,e[6]=n,e[7]=c,e[8]=l,e[9]=o,e[10]=E,e[11]=F):(E=e[10],F=e[11]),A.useEffect(E,F);const{names:d}=X();let R;e:{if(!r){R=o;break e}let s;if(e[12]!==r||e[13]!==d||e[14]!==o){const a=r.toLowerCase();s=o.filter(h=>{var y;return h.path.toLowerCase().includes(a)||h.shortName.toLowerCase().includes(a)||h.dirName.toLowerCase().includes(a)||((y=d[h.dirName])==null?void 0:y.toLowerCase().includes(a))}),e[12]=r,e[13]=d,e[14]=o,e[15]=s}else s=e[15];R=s}const T=R;let i,f,b;e[16]!==r?(i=r.trim(),f=i.replace(/[\\/]+$/,"")||i,b=i.startsWith("/")||/^[a-z]:[\\/]/i.test(i)||i.startsWith("\\\\"),e[16]=r,e[17]=i,e[18]=f,e[19]=b):(i=e[17],f=e[18],b=e[19]);const G=b;let L;e[20]!==G||e[21]!==f||e[22]!==o?(L=G&&!o.some(s=>(s.path.replace(/[\\/]+$/,"")||s.path)===f),e[20]=G,e[21]=f,e[22]=o,e[23]=L):L=e[23];const I=L;let k;e[24]!==n||e[25]!==c?(k=s=>{c(s.dirName,s.path),n()},e[24]=n,e[25]=c,e[26]=k):k=e[26];const g=k;let x;e[27]!==n?(x=s=>{s||n()},e[27]=n,e[28]=x):x=e[28];let z;e[29]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsxs(Z,{className:"sr-only",children:[t.jsx(_,{children:"Start a session"}),t.jsx(ee,{children:"Choose a project or enter an absolute folder path."})]}),e[29]=z):z=e[29];let p;e[30]!==r?(p=t.jsx(te,{autoFocus:!0,placeholder:"Search projects or paste an absolute path...",value:r,onValueChange:W}),e[30]=r,e[31]=p):p=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(se,{className:"py-0",children:t.jsx(ae,{className:"border-0 py-8",children:t.jsxs(ne,{children:[t.jsx(ie,{variant:"icon",children:t.jsx(Q,{})}),t.jsx(oe,{children:"No projects found"}),t.jsx(le,{children:"Try another name or paste an absolute path."})]})})}),e[32]=M):M=e[32];let N;e[33]!==I||e[34]!==O||e[35]!==i||e[36]!==n||e[37]!==H?(N=I&&t.jsxs(q,{value:`folder:${i}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>{H(i),n()},children:[t.jsx(pe,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),t.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[i," · ",re(O)]})]})]}),e[33]=I,e[34]=O,e[35]=i,e[36]=n,e[37]=H,e[38]=N):N=e[38];let j;if(e[39]!==T||e[40]!==g||e[41]!==d){let s;e[43]!==g||e[44]!==d?(s=a=>t.jsxs(q,{value:`project:${a.dirName}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>g(a),children:[t.jsx(Q,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium",children:d[a.dirName]||J(a.path)}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[d[a.dirName]&&t.jsx("span",{className:"mr-1.5",children:J(a.path)}),a.sessionCount," session",a.sessionCount!==1?"s":"",a.lastModified&&t.jsxs(t.Fragment,{children:[" · ",new Date(a.lastModified).toLocaleDateString()]})]})]})]},a.dirName),e[43]=g,e[44]=d,e[45]=s):s=e[45],j=T.map(s),e[39]=T,e[40]=g,e[41]=d,e[42]=j}else j=e[42];let w;e[46]!==N||e[47]!==j?(w=t.jsxs(de,{className:"max-h-80 p-1",children:[M,t.jsxs(ce,{className:"p-0",children:[N,j]})]}),e[46]=N,e[47]=j,e[48]=w):w=e[48];let C;e[49]!==p||e[50]!==w?(C=t.jsxs(me,{className:"max-w-md gap-0 overflow-hidden p-0",children:[z,t.jsxs(he,{shouldFilter:!1,className:"rounded-none p-0",children:[p,w]})]}),e[49]=p,e[50]=w,e[51]=C):C=e[51];let $;return e[52]!==l||e[53]!==x||e[54]!==C?($=t.jsx(ue,{open:l,onOpenChange:x,children:C}),e[52]=l,e[53]=x,e[54]=C,e[55]=$):$=e[55],$}function Ne(v){return v.ok?v.json():[]}export{ve as ProjectSwitcherModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{
|
|
1
|
+
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{ao as jr,Q as as,B as Gr}from"./index-DFiPbdIb.js";import{a5 as Jr}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";/**
|
|
2
2
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{av as I,Z as $,i as L,j as U,k as Z,Y as H,h as q,D as B}from"./index-DFiPbdIb.js";import{I as J,u as Q}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const W=[{id:"narrow",name:"Narrow",css:"44rem"},{id:"medium",name:"Medium",css:"56rem"},{id:"wide",name:"Wide",css:"64rem"},{id:"full",name:"Full",css:"100%"}],Y="cogpit-chat-width",R="medium";function V(){try{const s=localStorage.getItem(Y);if(W.some(e=>e.id===s))return s}catch{}return R}let _=typeof window>"u"?R:V();const M=new Set;function K(s){if(typeof document>"u")return;const e=W.find(t=>t.id===s)??W[1];document.documentElement.style.setProperty("--chat-width",e.css)}K(_);function X(){return _}function ee(s){_=s;try{localStorage.setItem(Y,s)}catch{}K(s),M.forEach(e=>e())}function te(s){return M.add(s),()=>M.delete(s)}function se(){const s=O.c(2),e=g.useSyncExternalStore(te,X,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return R}function de(s){const e=O.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[x,P]=g.useState(0),[z,A]=se();let j,w;e[0]!==l||e[1]!==t?(j=()=>{if(t){const a=I.findIndex(D=>D.id===l);P(a>=0?a:0)}},w=[t,l],e[0]=l,e[1]=t,e[2]=j,e[3]=w):(j=e[2],w=e[3]),g.useEffect(j,w);let N,b;e[4]!==i||e[5]!==t||e[6]!==x?(N=()=>{t&&i(I[x].id)},b=[x,t,i],e[4]=i,e[5]=t,e[6]=x,e[7]=N,e[8]=b):(N=e[7],b=e[8]),g.useEffect(N,b);let S,v;e[9]!==i||e[10]!==t?(S=()=>{t||i(null)},v=[t,i],e[9]=i,e[10]=t,e[11]=S,e[12]=v):(S=e[11],v=e[12]),g.useEffect(S,v);let y;e[13]!==r||e[14]!==k?(y=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=y):y=e[15];const F=y;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs(L,{className:"border-b p-4 pr-12",children:[n.jsxs(U,{className:"flex items-center gap-2 text-sm",children:[n.jsx(Q,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(Z,{children:"Preview a color theme and set the chat width."})]}),e[18]=C):C=e[18];const G=I[x];let c;e[19]!==G.id?(c=[G.id],e[19]=G.id,e[20]=c):c=e[20];let d;e[21]!==l||e[22]!==F?(d=I.map((a,D)=>n.jsxs($,{value:a.id,className:"h-auto w-full justify-start gap-3 px-3 py-2.5 text-left text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>F(a),onMouseEnter:()=>P(D),onFocus:()=>P(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),l===a.id&&n.jsx(J,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=l,e[22]=F,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx(H,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=E):E=e[27];let f;e[28]!==z?(f=[z],e[28]=z,e[29]=f):f=e[29];let u;e[30]!==A?(u=W.map(a=>n.jsx($,{value:a.id,className:"flex-1 text-xs text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>A(a.id),children:a.name},a.id)),e[30]=A,e[31]=u):u=e[31];let h;e[32]!==f||e[33]!==u?(h=n.jsxs("div",{className:"border-t p-3",children:[E,n.jsx(H,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let p;e[35]!==m||e[36]!==h?(p=n.jsxs(q,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[C,m,h]}),e[35]=m,e[36]=h,e[37]=p):p=e[37];let T;return e[38]!==t||e[39]!==p||e[40]!==o?(T=n.jsx(B,{open:t,onOpenChange:o,children:p}),e[38]=t,e[39]=p,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{de as ThemeSelectorModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as X,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{_ as le,aN as mt,aD as ft,ay as xt,aO as Ye,a4 as pe,aP as Ke,al as je,a6 as Se,a7 as Ce,B as ne,a8 as Te,w as Ie,aL as Me,aH as Le,aI as Fe,l as De,aJ as Ue,A as Qe,aQ as pt,p as Ge,aR as ht,aS as gt,aT as jt,E as ze,y as Ae,G as We,H as Pe,aU as bt,d as Nt,c as wt,S as yt,a as vt,aV as kt,b as St,q as Ct,z as Tt,a5 as It}from"./index-DFiPbdIb.js";import{M as Rt}from"./vendor-markdown-BE1gYnO9.js";import{W as Xe,Y as Ze,_ as et,$ as $t,a0 as Re,R as _t,I as tt,z as st,a1 as qe,h as zt,a2 as At,a3 as Wt,B as Pt,a4 as He,b as Ot,V as Et}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";const Mt=new Set(["done","error","skipped"]);function Ve(l){return Mt.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 Ht(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 Ht(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=X.c(4),{children:t}=l;let r;e[0]!==t?(r=mt(t),e[0]=t,e[1]=r):r=e[1];const a=r;let n;return e[2]!==a?(n=s.jsx(Rt,{components:xt,remarkPlugins:ft,children:a}),e[2]=a,e[3]=n):n=e[3],n}function ot(l){const e=X.c(7),{value:t}=l;if(typeof t=="string"){let n;return e[0]!==t?(n=s.jsx(it,{children:t}),e[0]=t,e[1]=n):n=e[1],n}if(t===null){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground",children:"None"}),e[2]=n):n=e[2],n}if(typeof t=="boolean"){const n=t?"Yes":"No";let 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=X.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(Qt)){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(Yt),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 Yt(l){const[e,t]=l;return Bt.has(e)&&typeof t=="string"&&t.trim().length>0}function Kt(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Qt(l){return!Be(l)&&!Array.isArray(l)}function Ee(l){const e=X.c(19),{value:t,className:r}=l;let a;e[0]!==t?(a=typeof t=="string"?rt(t):t,e[0]=t,e[1]=a):a=e[1];const n=a;if(typeof n=="string"&&(n.trim().startsWith("{")||n.trim().startsWith("["))){let 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 Gt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Xt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Zt(l){const e=X.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]=Ye();let p,j,b,N,S,w,v,g,T,R,A,H,I,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 Ie(`/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,H=ct,N=Me,O="sm",R="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=Xt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(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:Gt(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:Xe,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:Ze,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,I="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]=R,e[18]=A,e[19]=H,e[20]=I,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],R=e[17],A=e[18],H=e[19],I=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 E;e[74]!==g?(E=g&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=g,e[75]=E):E=e[75];let Z;e[76]!==p||e[77]!==T.label||e[78]!==E||e[79]!==I||e[80]!==y?(Z=s.jsxs(p,{variant:I,className:y,children:[E,T.label]}),e[76]=p,e[77]=T.label,e[78]=E,e[79]=I,e[80]=y,e[81]=Z):Z=e[81];let V;e[82]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Re,{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 M;e[83]!==Z||e[84]!==k?(M=s.jsxs("div",{className:k,children:[Z,V]}),e[83]=Z,e[84]=k,e[85]=M):M=e[85];let L;e[86]!==j||e[87]!==M||e[88]!==$||e[89]!==W||e[90]!==_?(L=s.jsxs(j,{className:$,children:[W,_,M]}),e[86]=j,e[87]=M,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 Y;e[96]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(De,{}),e[96]=Y):Y=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(Ee,{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 Q;e[117]!==t.promptPreview||e[118]!==m?(Q=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(Re,{"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(Ee,{value:t.promptPreview})})})]}),e[117]=t.promptPreview,e[118]=m,e[119]=Q):Q=e[119];let G;e[120]!==J||e[121]!==q||e[122]!==Q?(G=s.jsxs(Te,{children:[Y,s.jsxs(Ue,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,Q]})]}),e[120]=J,e[121]=q,e[122]=Q,e[123]=G):G=e[123];let se;e[124]!==N||e[125]!==R||e[126]!==ee||e[127]!==G||e[128]!==O?(se=s.jsxs(N,{size:O,className:R,children:[ee,G]}),e[124]=N,e[125]=R,e[126]=ee,e[127]=G,e[128]=O,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==H||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:H,children:se}),e[130]=S,e[131]=A,e[132]=H,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=X.c(5),{icon:t,children:r}=l;let a;e[0]!==t?(a=s.jsx(t,{className:"size-3"}),e[0]=t,e[1]=a):a=e[1];let n;return e[2]!==r||e[3]!==a?(n=s.jsxs("span",{className:"inline-flex items-center gap-1",children:[a,r]}),e[2]=r,e[3]=a,e[4]=n):n=e[4],n}function es(l){const e=X.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming: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),R=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const H=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let I;e[16]!==w||e[17]!==H?(I=s.jsxs(pe,{variant:"outline",className:w.badge,children:[H,w.label]}),e[16]=w,e[17]=H,e[18]=I):I=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]!==I?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[I,y]}),e[20]=I,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 E;e[39]!==z?(E=s.jsx(ge,{icon:At,value:z,label:"Agents finished"}),e[39]=z,e[40]=E):E=e[40];const Z=String(t.phaseCount);let V;e[41]!==Z?(V=s.jsx(ge,{icon:Wt,value:Z,label:"Phases"}),e[41]=Z,e[42]=V):V=e[42];let M;e[43]!==t.totalTokens?(M=nt(t.totalTokens),e[43]=t.totalTokens,e[44]=M):M=e[44];let L;e[45]!==M?(L=s.jsx(ge,{icon:Xe,value:M,label:"Tokens"}),e[45]=M,e[46]=L):L=e[46];const ee=String(t.totalToolCalls);let Y;e[47]!==ee?(Y=s.jsx(ge,{icon:Ze,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=Y):Y=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]!==E||e[54]!==V||e[55]!==L||e[56]!==Y||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:[E,V,L,Y,te]}),e[53]=E,e[54]=V,e[55]=L,e[56]=Y,e[57]=te,e[58]=F):F=e[58];let D;e[59]!==R?(D=Math.round(R*100),e[59]=R,e[60]=D):D=e[60];let U;e[61]!==D?(U=s.jsx(jt,{value:D,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=D,e[62]=U):U=e[62];let B;e[63]!==R?(B=Math.round(R*100),e[63]=R,e[64]=B):B=e[64];let J;e[65]!==B?(J=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[B,"%"]}),e[65]=B,e[66]=J):J=e[66];let q;e[67]!==U||e[68]!==J?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,J]}),e[67]=U,e[68]=J,e[69]=q):q=e[69],e[70]!==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(Qe,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Ge,{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 Q;e[81]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=Q):Q=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-card p-2 md:block","aria-label":"Workflow phases",children:[Q,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="flex min-w-0 flex-col gap-8";let G;e[82]!==t.runId||e[83]!==r||e[84]!==a?(G=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]=G):G=e[85],d=T.map(G),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=X.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=X.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(Zt,{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]=Ye(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Ie(`/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(Me,{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(Re,{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(Ee,{value:p})})]})]})})}function as(l){const e=X.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(Re,{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(Me,{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 I;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:((I=a[0])==null?void 0:I.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Ie(`/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 R=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Ie("/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,H=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(He,{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(He,{})}),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(Et,{"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(Qe,{className:"mb-4",children:s.jsx(Ge,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:R})]}):H?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=X.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:It(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
|
|
1
|
+
import{r as m,j as e}from"./vendor-react-gGw_S5I_.js";import{a3 as K,B as d,_ as A,l as Q,E as V,y as Y,z as Z,G as _,H as ee,a4 as se,a5 as ne,a6 as te,a7 as ae,a8 as re,a9 as R,aa as z,ab as E,ac as ie,ad as S,ae as U,af as F,ag as T,ah as $,w as u,ai as c}from"./index-DFiPbdIb.js";import{G as P,h as le,b as oe,X as ce,c as de,i as he,j as O,C as me,k as xe}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ue={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function ve({worktrees:v,loading:p,dirName:r,onRefetch:g,onOpenSession:I,onClose:M}){const o=K("hostFiles"),[B,y]=m.useState(null),[G,b]=m.useState(null),[H,x]=m.useState(!1),[n,h]=m.useState(null),[a,j]=m.useState(null),C=async s=>{if(!(!o||!r)){y(s.name);try{await u(`/api/worktrees/${encodeURIComponent(r)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})}),g()}catch(t){c.error(`Failed to delete worktree: ${t instanceof Error?t.message:"Unknown error"}`)}finally{y(null)}}},J=s=>{if(!(!o||!r)){if(s.isDirty){h({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){h({worktree:s,reason:"unpushed"});return}C(s)}},W=()=>{if(!n)return;const{worktree:s,reason:t}=n;if(t==="dirty"&&s.commitsAhead>0){h({worktree:s,reason:"unpushed"});return}h(null),C(s)},L=async s=>{if(!(!o||!r)){b(s.name);try{const t=await u(`/api/worktrees/${encodeURIComponent(r)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(t.ok){const l=await t.json();l.url?window.open(l.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const l=await t.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${l.error||"Unknown error"}`)}}catch(t){c.error(`Error creating PR: ${t instanceof Error?t.message:"Unknown error"}`)}finally{b(null)}}},q=async()=>{if(!(!o||!r)){x(!0);try{const s=await u(`/api/worktrees/${encodeURIComponent(r)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:t}=await s.json();t.length===0?c.info("No stale worktrees found"):j(t.map(l=>l.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{x(!1)}}},X=async()=>{if(!o||!r||!a)return;const s=a;j(null),x(!0);try{await u(`/api/worktrees/${encodeURIComponent(r)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),g()}catch(t){c.error(`Cleanup failed: ${t instanceof Error?t.message:"Unknown error"}`)}finally{x(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{"aria-label":"Worktrees",className:"flex size-full min-h-0 flex-col bg-background",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsx(P,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Worktrees"}),e.jsx("div",{className:"flex-1"}),o&&e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:q,disabled:H,"aria-label":"Cleanup stale worktrees",children:e.jsx(le,{"data-icon":"inline-start"})}),e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:g,disabled:p,"aria-label":"Refresh worktrees",children:e.jsx(oe,{"data-icon":"inline-start",className:A(p&&"animate-spin")})}),e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:M,"aria-label":"Close worktrees",children:e.jsx(ce,{"data-icon":"inline-start"})})]}),e.jsx(Q,{}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!r&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),r&&v.length===0&&!p&&e.jsx(V,{className:"border-0 py-16",children:e.jsxs(Y,{children:[e.jsx(Z,{variant:"icon",children:e.jsx(P,{})}),e.jsx(_,{children:"No worktrees"}),e.jsx(ee,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var N,w,D;const t=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.additions,0))??0,l=((w=s.changedFiles)==null?void 0:w.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:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.isDirty&&e.jsx("span",{className:"flex size-2 shrink-0 rounded-full bg-warning",title:"Uncommitted changes"}),s.commitsAhead>0&&e.jsxs(se,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[s.linkedSessions.length>0&&e.jsx(d,{variant:"ghost",size:"icon-xs",onClick:()=>I(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(de,{"data-icon":"inline-start"})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"ghost",size:"icon-xs",onClick:()=>L(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(he,{"data-icon":"inline-start"})}),e.jsx(d,{variant:"ghost",size:"icon-xs",onClick:()=>J(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:"shrink-0 font-mono",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:ne(s.createdAt)}),f>0&&e.jsxs(te,{className:"mt-2",children:[e.jsxs(ae,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(me,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(xe,{"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:["+",t]})," ",e.jsxs("span",{className:"text-destructive",children:["-",l]})]})]}),e.jsx(re,{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:A("shrink-0 w-3 text-center",ue[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(R,{open:n!==null,onOpenChange:s=>{s||h(null)},children:e.jsxs(z,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(ie,{className:"bg-destructive/10 text-destructive",children:e.jsx(O,{})}),e.jsx(S,{children:(n==null?void 0:n.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(U,{children:[(n==null?void 0:n.reason)==="dirty"?`"${n.worktree.name}" has uncommitted changes.`:`"${n==null?void 0:n.worktree.name}" has ${n==null?void 0:n.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(F,{children:[e.jsx(T,{size:"sm",children:"Cancel"}),e.jsx($,{variant:"destructive",size:"sm",onClick:W,children:(n==null?void 0:n.reason)==="dirty"&&n.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(R,{open:a!==null,onOpenChange:s=>{s||j(null)},children:e.jsxs(z,{children:[e.jsxs(E,{children:[e.jsx(S,{children:"Remove stale worktrees?"}),e.jsxs(U,{children:[a==null?void 0:a.length," stale worktree",(a==null?void 0:a.length)===1?"":"s"," will be removed: ",a==null?void 0:a.join(", "),"."]})]}),e.jsxs(F,{children:[e.jsx(T,{size:"sm",children:"Cancel"}),e.jsx($,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{ve as WorktreePanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Y,j as t,r as v}from"./vendor-react-gGw_S5I_.js";import{_ as Ye,V as le,aW as Ee,aX as J,m as dt,n as ut,I as ft,W as Ct,X as _t,aY as At,B as ce,aZ as mt,w as Ie,a_ as ht,a6 as xt,a7 as pt,a8 as gt,a$ as nt,a4 as et,b0 as $t,ap as Et,aq as zt,b1 as jt,i as Tt,j as It,k as Dt,b2 as Pt,U as Lt,aF as Ft,h as Rt,D as Ut}from"./index-DFiPbdIb.js";import{a6 as Bt,a7 as Ot,a8 as Mt,a9 as Vt,e as Ht,T as Gt,M as Wt,aa as Xt,ab as qt,ac as Kt,a0 as bt,C as vt,ad as it,ae as Jt,F as Yt,x as Zt,af as Qt,B as es,ag as ts,ah as ss}from"./vendor-ui-DUTyrBOX.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function ns(s){const e=Y.c(11);let n,a,i;e[0]!==s?({className:n,size:i,...a}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=i):(n=e[1],a=e[2],i=e[3]);const r=i===void 0?"default":i;let l;e[4]!==n?(l=Ye("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",n),e[4]=n,e[5]=l):l=e[5];let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(Ot,{"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]=f):f=e[6];let c;return e[7]!==a||e[8]!==r||e[9]!==l?(c=t.jsx(Bt,{"data-slot":"switch","data-size":r,className:l,...a,children:f}),e[7]=a,e[8]=r,e[9]=l,e[10]=c):c=e[10],c}function as(s){const e=Y.c(3),{name:n}=s,a=n.toLowerCase();if(a.includes("iphone")||a.includes("android")){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ht,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=r):r=e[0],r}if(a.includes("ipad")||a.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(Wt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[2]=i):i=e[2],i}function at(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function is(s){const e=[`Shared ${at(s.createdAt)}`,s.lastAccessAt>0?`opened ${at(s.lastAccessAt)}`:"never opened"];return s.guests>0&&e.push(s.guests===1?"1 guest":`${s.guests} guests`),e.join(" · ")}function ls(){const s=Y.c(12),{shares:e,revoke:n,revokeAll:a}=At();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]!==a||s[2]!==e.length?(r=e.length>0&&t.jsx(ce,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",onClick:()=>void a(),children:"Revoke all"}),s[1]=a,s[2]=e.length,s[3]=r):r=s[3];let l;s[4]!==r?(l=t.jsxs("div",{className:"flex h-6 items-center justify-between",children:[i,r]}),s[4]=r,s[5]=l):l=s[5];let f;s[6]!==n||s[7]!==e?(f=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(o=>{const m=o.title||o.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:is(o)})]}),t.jsx(ce,{variant:"ghost",size:"xs","aria-label":`Revoke share of ${m}`,className:"text-destructive hover:text-destructive",onClick:()=>void n(o.sessionId),children:"Revoke"})]},o.sessionId)})}),s[6]=n,s[7]=e,s[8]=f):f=s[8];let c;return s[9]!==l||s[10]!==f?(c=t.jsxs("div",{className:"flex flex-col gap-2",children:[l,f]}),s[9]=l,s[10]=f,s[11]=c):c=s[11],c}function rs(s){const e=Y.c(30),{networkAccess:n,setNetworkAccess:a,networkPassword:i,setNetworkPassword:r,showNetworkPassword:l,setShowNetworkPassword:f,hasExistingPassword:c,initialNetworkAccess:o,connectedDevices:m,minPasswordLength:b}=s;let x;e[0]!==n?(x=n?t.jsx(Xt,{"data-icon":"inline-start",className:"size-4 text-success"}):t.jsx(qt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=n,e[1]=x):x=e[1];let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=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]=j):j=e[2];let y;e[3]!==x?(y=t.jsxs("div",{className:"flex items-center gap-2",children:[x,j]}),e[3]=x,e[4]=y):y=e[4];let C;e[5]!==a?(C=_=>a(_),e[5]=a,e[6]=C):C=e[6];let w;e[7]!==n||e[8]!==C?(w=t.jsx(ns,{"aria-label":"Network Access",checked:n,onCheckedChange:C}),e[7]=n,e[8]=C,e[9]=w):w=e[9];let N;e[10]!==y||e[11]!==w?(N=t.jsxs("div",{className:"flex items-center justify-between",children:[y,w]}),e[10]=y,e[11]=w,e[12]=N):N=e[12];let p;e[13]!==c||e[14]!==b||e[15]!==n||e[16]!==i||e[17]!==r||e[18]!==f||e[19]!==l?(p=n&&t.jsxs(le,{"data-invalid":i.length>0&&i.length<b,children:[t.jsx(Ee,{htmlFor:"network-password",children:"Password"}),t.jsx(J,{children:c&&i.length===0?"A password is already set. Leave blank to keep it.":`Use at least ${b} characters.`}),t.jsxs(dt,{children:[t.jsx(ut,{id:"network-password",type:l?"text":"password",value:i,onChange:_=>r(_.target.value),placeholder:c?"Enter new password to change":"Set a password for remote access"}),t.jsx(ft,{align:"inline-end",children:t.jsx(Ct,{size:"icon-xs","aria-label":l?"Hide password":"Show password",onClick:()=>f(!l),children:l?t.jsx(Mt,{"data-icon":"inline-start"}):t.jsx(Vt,{"data-icon":"inline-start"})})})]}),i.length>0&&i.length<b&&t.jsxs(_t,{children:["Password must be at least ",b," characters (",i.length,"/",b,")"]}),t.jsx(J,{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]=b,e[15]=n,e[16]=i,e[17]=r,e[18]=f,e[19]=l,e[20]=p):p=e[20];let u;e[21]!==m||e[22]!==o||e[23]!==n?(u=n&&o&&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(os)})]}),e[21]=m,e[22]=o,e[23]=n,e[24]=u):u=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(ls,{}),e[25]=S):S=e[25];let h;return e[26]!==N||e[27]!==p||e[28]!==u?(h=t.jsxs("div",{className:"flex flex-col gap-4 border-t pt-5",children:[N,p,u,S]}),e[26]=N,e[27]=p,e[28]=u,e[29]=h):h=e[29],h}function os(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(as,{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:at(s.lastActivity)})]})]},`${s.ip}-${e}`)}const cs=["auto","path","npm","bundled","custom"],tt={source:"auto"},ds=["path","npm","bundled"];function us(s){return cs.includes(s)}function fs(s){if(!s||typeof s!="object")return;const{source:e,path:n}=s;if(!(!us(e)||e==="auto"))return e==="custom"?typeof n=="string"&&n.trim()?{source:e,path:n.trim()}:void 0:{source:e}}const Te={auto:"Automatic",path:"Installed on PATH",npm:"Global npm install",bundled:"Bundled with Cogpit",custom:"Custom path"};function wt(s,e){return e?`v${e} · ${s}`:s}function ms(s,e){return s===null?"Checking installed binaries…":e?e.version===null?`${e.path} did not report a version — check the path.`:`Now running: ${wt(e.path,e.version)}`:"No launchable binary for the saved choice — sessions cannot start."}function hs(s){return s!==null&&s.version!==null}function xs(s){const e=Y.c(92),{kind:n,value:a,onChange:i,disabled:r,reportVersion:l}=s;let f;e[0]!==n?(f=mt(n),e[0]=n,e[1]=f):f=e[1];const{displayName:c}=f,[o,m]=v.useState(null),[b,x]=v.useState(!1),j=`agent-executable-${n}`;let y;e[2]!==n?(y=()=>{let I=!1;return Ie(`/api/agent-executable/${n}`).then(js).then(te=>{I||m(te)}).catch(gs),()=>{I=!0}},e[2]=n,e[3]=y):y=e[3];let C;e[4]!==n||e[5]!==l?(C=[n,l],e[4]=n,e[5]=l,e[6]=C):C=e[6],v.useEffect(y,C);let w,N,p,u,S,h,_,z,T,k,A,D,g;if(e[7]!==r||e[8]!==c||e[9]!==j||e[10]!==i||e[11]!==b||e[12]!==(o==null?void 0:o.active)||e[13]!==(o==null?void 0:o.candidates)||e[14]!==a.path||e[15]!==a.source){const I=new Map((o==null?void 0:o.candidates.map(ps))??[]);u=(o==null?void 0:o.active)??null;let te;e[29]!==r||e[30]!==j||e[31]!==i||e[32]!==a.path||e[33]!==a.source?(te=(L,B,ae,oe)=>{const lt=oe===void 0?!0:oe,K=`${j}-${L}`;return t.jsxs(le,{orientation:"horizontal",children:[t.jsx("input",{type:"radio",id:K,name:j,className:"mt-1 size-4 shrink-0 accent-primary",checked:a.source===L,disabled:r||!lt,onChange:()=>i(L==="custom"?{source:L,path:a.path??""}:{source:L})}),t.jsxs(ht,{children:[t.jsx(Ee,{htmlFor:K,children:B}),t.jsx(J,{className:"break-all",children:ae})]})]},L)},e[29]=r,e[30]=j,e[31]=i,e[32]=a.path,e[33]=a.source,e[34]=te):te=e[34],S=te;const se=L=>{const B=I.get(L);return S(L,Te[L],B?wt(B.path,B.version):"Not found on this machine.",B!==void 0||a.source===L)},ze=u?`${Te[a.source]} · v${u.version??"?"}`:Te[a.source];p=xt,D=b,g=x,h="flex flex-col gap-2";let X;e[35]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(ce,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 font-medium hover:bg-transparent"}),e[35]=X):X=e[35];let ne;e[36]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsx(Kt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[36]=ne):ne=e[36];let q;e[37]!==c?(q=t.jsxs("span",{className:"flex items-center gap-2",children:[ne,c," executable"]}),e[37]=c,e[38]=q):q=e[38];let F;e[39]!==ze?(F=t.jsx("span",{className:"truncate",children:ze}),e[39]=ze,e[40]=F):F=e[40];let R;e[41]!==b?(R=b?t.jsx(bt,{className:"size-4 shrink-0"}):t.jsx(vt,{className:"size-4 shrink-0"}),e[41]=b,e[42]=R):R=e[42];let U;e[43]!==F||e[44]!==R?(U=t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-normal text-muted-foreground",children:[F,R]}),e[43]=F,e[44]=R,e[45]=U):U=e[45],e[46]!==q||e[47]!==U?(_=t.jsxs(pt,{render:X,children:[q,U]}),e[46]=q,e[47]=U,e[48]=_):_=e[48],N=gt,w=le,e[49]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(J,{children:"Which binary new sessions run. Automatic uses your installed CLI unless it is older than the copy bundled with Cogpit."}),e[49]=A):A=e[49],z="flex flex-col gap-2 pl-1",e[50]!==S?(T=S("auto",Te.auto,"Recommended."),e[50]=S,e[51]=T):T=e[51],k=ds.map(se),e[7]=r,e[8]=c,e[9]=j,e[10]=i,e[11]=b,e[12]=o==null?void 0:o.active,e[13]=o==null?void 0:o.candidates,e[14]=a.path,e[15]=a.source,e[16]=w,e[17]=N,e[18]=p,e[19]=u,e[20]=S,e[21]=h,e[22]=_,e[23]=z,e[24]=T,e[25]=k,e[26]=A,e[27]=D,e[28]=g}else w=e[16],N=e[17],p=e[18],u=e[19],S=e[20],h=e[21],_=e[22],z=e[23],T=e[24],k=e[25],A=e[26],D=e[27],g=e[28];const P=`${c} executable path`,H=a.source==="custom"?a.path??"":"",re=r||a.source!=="custom";let Z;e[52]!==i?(Z=I=>i({source:"custom",path:I.target.value}),e[52]=i,e[53]=Z):Z=e[53];let $;e[54]!==P||e[55]!==H||e[56]!==re||e[57]!==Z?($=t.jsx(nt,{"aria-label":P,value:H,placeholder:"/path/to/binary",disabled:re,onChange:Z,className:"mt-1"}),e[54]=P,e[55]=H,e[56]=re,e[57]=Z,e[58]=$):$=e[58];let G;e[59]!==S||e[60]!==$?(G=S("custom",Te.custom,$),e[59]=S,e[60]=$,e[61]=G):G=e[61];let O;e[62]!==G||e[63]!==z||e[64]!==T||e[65]!==k?(O=t.jsxs("div",{className:z,children:[T,k,G]}),e[62]=G,e[63]=z,e[64]=T,e[65]=k,e[66]=O):O=e[66];let Q;e[67]!==u?(Q=hs(u)?"text-muted-foreground":"text-destructive",e[67]=u,e[68]=Q):Q=e[68];let E;e[69]!==Q?(E=Ye("text-xs",Q),e[69]=Q,e[70]=E):E=e[70];let W;e[71]!==u||e[72]!==o?(W=ms(o,u),e[71]=u,e[72]=o,e[73]=W):W=e[73];let M;e[74]!==E||e[75]!==W?(M=t.jsx("p",{className:E,"aria-live":"polite",children:W}),e[74]=E,e[75]=W,e[76]=M):M=e[76];let ee;e[77]!==w||e[78]!==O||e[79]!==M||e[80]!==A?(ee=t.jsxs(w,{children:[A,O,M]}),e[77]=w,e[78]=O,e[79]=M,e[80]=A,e[81]=ee):ee=e[81];let V;e[82]!==N||e[83]!==ee?(V=t.jsx(N,{children:ee}),e[82]=N,e[83]=ee,e[84]=V):V=e[84];let de;return e[85]!==p||e[86]!==h||e[87]!==_||e[88]!==V||e[89]!==D||e[90]!==g?(de=t.jsxs(p,{open:D,onOpenChange:g,className:h,children:[_,V]}),e[85]=p,e[86]=h,e[87]=_,e[88]=V,e[89]=D,e[90]=g,e[91]=de):de=e[91],de}function ps(s){return[s.source,s]}function gs(){}function js(s){return s.ok?s.json():null}function Nt(s){return s instanceof Error?s.message:String(s)}async function St(s){const e=await s.json().catch(()=>null);return typeof(e==null?void 0:e.error)=="string"?e.error:`Request failed (${s.status})`}async function rt(s){try{const e=await Ie(`/api/agent-accounts/${s}`);return e.status===404?{status:"missing"}:e.ok?await e.json():{status:"error",error:await St(e)}}catch(e){return{status:"error",error:Nt(e)}}}function bs(s){const[e,n]=v.useState(null),[a,i]=v.useState(null),[r,l]=v.useState(null);v.useEffect(()=>{let c=!1;return rt(s).then(o=>{c||n(o)}),()=>{c=!0}},[s]);const f=v.useCallback(async c=>{i(c),l(null);try{const o=await Ie(`/api/agent-accounts/${s}/switch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slot:c})});if(!o.ok){l({kind:"failed",error:await St(o)});return}l({kind:"switched",result:await o.json()}),n(await rt(s))}catch(o){l({kind:"failed",error:Nt(o)})}finally{i(null)}},[s]);return{report:e,switchingSlot:a,outcome:r,switchTo:f}}const vs={token_expired:"Token expired",relogin_required:"Login needed",no_credentials:"No credentials",keychain_unavailable:"Keychain locked",foreign_credential:"Credential mismatch",api_key:"API key",unavailable:"Usage unavailable"};function st(s){return s.alias??s.email}function ot(s){const e=Y.c(18),{label:n,window:a}=s;if(!a)return null;const i=a.pct>=80,r=a.resetsIn?`${n} window resets in ${a.resetsIn}`:void 0;let l;e[0]!==n?(l=t.jsx("span",{className:"w-5",children:n}),e[0]=n,e[1]=l):l=e[1];const f=i?"bg-destructive":"bg-primary";let c;e[2]!==f?(c=Ye("absolute inset-y-0 left-0 rounded-full",f),e[2]=f,e[3]=c):c=e[3];const o=`${a.pct}%`;let m;e[4]!==o?(m={width:o},e[4]=o,e[5]=m):m=e[5];let b;e[6]!==c||e[7]!==m?(b=t.jsx("span",{className:"relative h-1 w-16 overflow-hidden rounded-full bg-muted",children:t.jsx("span",{className:c,style:m})}),e[6]=c,e[7]=m,e[8]=b):b=e[8];let x;e[9]!==a.pct?(x=Math.round(a.pct),e[9]=a.pct,e[10]=x):x=e[10];let j;e[11]!==x?(j=t.jsxs("span",{className:"tabular-nums",children:[x,"%"]}),e[11]=x,e[12]=j):j=e[12];let y;return e[13]!==r||e[14]!==l||e[15]!==b||e[16]!==j?(y=t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",title:r,children:[l,b,j]}),e[13]=r,e[14]=l,e[15]=b,e[16]=j,e[17]=y):y=e[17],y}function ct(s){return/[.!?]$/.test(s)?s:`${s}.`}function ws(s,e){if(s.kind==="failed")return`Switch failed: ${s.error}`;const{result:n}=s,a=[ct(n.message)];return n.switched&&a.push(n.credentialStore==="keychain"?`Running ${e} sessions pick it up within about 30 seconds; restart one to apply it immediately.`:`New messages in ${e} use it from now on.`),[...a,...n.warnings.map(ct)].join(" ")}function Ns(s){const e=Y.c(41),{kind:n,disabled:a}=s;let i;e[0]!==n?(i=mt(n),e[0]=n,e[1]=i):i=e[1];const{displayName:r}=i,{report:l,switchingSlot:f,outcome:c,switchTo:o}=bs(n),[m,b]=v.useState(!1);if(l===null||l.status==="missing")return null;let x,j;if(e[2]!==l.accounts||e[3]!==l.status){x=l.status==="ok"?l.accounts:[];const g=x.find(Ss)??null;j=l.status==="error"?"Unavailable":g?`${st(g)} · ${x.length} account${x.length===1?"":"s"}`:`${x.length} account${x.length===1?"":"s"}`,e[2]=l.accounts,e[3]=l.status,e[4]=x,e[5]=j}else x=e[4],j=e[5];const y=j;let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(ce,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 font-medium hover:bg-transparent"}),e[6]=C):C=e[6];let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(Jt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[7]=w):w=e[7];let N;e[8]!==r?(N=t.jsxs("span",{className:"flex items-center gap-2",children:[w,r," accounts"]}),e[8]=r,e[9]=N):N=e[9];let p;e[10]!==y?(p=t.jsx("span",{className:"truncate",children:y}),e[10]=y,e[11]=p):p=e[11];let u;e[12]!==m?(u=m?t.jsx(bt,{className:"size-4 shrink-0"}):t.jsx(vt,{className:"size-4 shrink-0"}),e[12]=m,e[13]=u):u=e[13];let S;e[14]!==p||e[15]!==u?(S=t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-normal text-muted-foreground",children:[p,u]}),e[14]=p,e[15]=u,e[16]=S):S=e[16];let h;e[17]!==N||e[18]!==S?(h=t.jsxs(pt,{render:C,children:[N,S]}),e[17]=N,e[18]=S,e[19]=h):h=e[19];const _=l.status==="ok"&&`Logins managed by ${l.tool}${l.version?` ${l.version}`:""}. `;let z;e[20]!==r||e[21]!==_?(z=t.jsxs(J,{children:[_,"Switching changes which login ",r," sessions authenticate with."]}),e[20]=r,e[21]=_,e[22]=z):z=e[22];let T;e[23]!==x||e[24]!==a||e[25]!==l.error||e[26]!==l.status||e[27]!==o||e[28]!==f?(T=l.status==="error"?t.jsx("p",{className:"text-xs text-destructive",role:"alert",children:l.error}):t.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border",children:x.map(g=>{const P=f===g.slot,H=vs[g.usageStatus];return t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"w-5 shrink-0 text-xs tabular-nums text-muted-foreground",children:g.slot}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:st(g)}),g.alias&&t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:g.email}),g.active&&t.jsx(et,{children:"Active"}),g.disabled&&t.jsx(et,{variant:"outline",children:"Disabled"}),H&&t.jsx(et,{variant:"destructive",children:H})]}),g.organization&&t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:g.organization}),g.usage&&t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:[t.jsx(ot,{label:"5h",window:g.usage.fiveHour}),t.jsx(ot,{label:"7d",window:g.usage.sevenDay})]})]}),!a&&!g.active&&t.jsx(ce,{type:"button",size:"sm",variant:"outline",disabled:f!==null,onClick:()=>o(g.slot),"aria-label":`Switch to ${st(g)}`,children:P?t.jsxs(t.Fragment,{children:[t.jsx(it,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Switching…"]}):"Switch"})]},g.slot)})}),e[23]=x,e[24]=a,e[25]=l.error,e[26]=l.status,e[27]=o,e[28]=f,e[29]=T):T=e[29];let k;e[30]!==r||e[31]!==c?(k=c&&t.jsx("p",{className:Ye("text-xs",c.kind==="failed"?"text-destructive":"text-muted-foreground"),"aria-live":"polite",role:c.kind==="failed"?"alert":"status",children:ws(c,r)}),e[30]=r,e[31]=c,e[32]=k):k=e[32];let A;e[33]!==z||e[34]!==T||e[35]!==k?(A=t.jsx(gt,{children:t.jsxs(le,{children:[z,T,k]})}),e[33]=z,e[34]=T,e[35]=k,e[36]=A):A=e[36];let D;return e[37]!==m||e[38]!==A||e[39]!==h?(D=t.jsxs(xt,{open:m,onOpenChange:b,className:"flex flex-col gap-2",children:[h,A]}),e[37]=m,e[38]=A,e[39]=h,e[40]=D):D=e[40],D}function Ss(s){return s.active}const ys=jt().filter(s=>s.cli.bundledBySdk).map(s=>s.kind),ks=jt().filter(s=>s.capabilities.accountSwitching).map(s=>s.kind);function Cs(s,e){return s.source===e.source&&(s.source!=="custom"||s.path===e.path)}function _s(s){const e=Y.c(5),{status:n,error:a}=s;if(n==="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(it,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Checking path..."]}),e[0]=i):i=e[0],i}if(n==="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(ts,{"data-icon":"inline-start",className:"size-3.5"}),"Valid .claude directory found"]}),e[1]=i):i=e[1],i}if(n==="invalid"&&a){let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ss,{"data-icon":"inline-start",className:"size-3.5"}),e[2]=i):i=e[2];let r;return e[3]!==a?(r=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[i,a]}),e[3]=a,e[4]=r):r=e[4],r}return null}function Rs(s){const e=Y.c(110),{open:n,currentPath:a,onClose:i,onSaved:r}=s,[l,f]=v.useState(a),[c,o]=v.useState(!1),{status:m,error:b,debouncedValidate:x,reset:j,save:y}=$t();let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=Et(),e[0]=C):C=e[0];const w=C;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=zt("configWrite"),e[1]=N):N=e[1];const p=N,[u,S]=v.useState(!1),[h,_]=v.useState(""),[z,T]=v.useState(!1),[k,A]=v.useState(""),[D,g]=v.useState(""),[P,H]=v.useState(""),[re,Z]=v.useState(""),[$,G]=v.useState(!1),[O,Q]=v.useState(!1),[E,W]=v.useState(tt),[M,ee]=v.useState(0),[V,de]=v.useState(tt),[I,te]=v.useState(!1),[se,ze]=v.useState(!1);let X;e[2]===Symbol.for("react.memo_cache_sentinel")?(X=[],e[2]=X):X=e[2];const[ne,q]=v.useState(X);let F,R;e[3]!==a||e[4]!==n||e[5]!==j?(F=()=>{n&&(f(a),j(),Ie("/api/config").then(Ts).then(d=>{const ie=(d==null?void 0:d.networkAccess)||!1;S(ie),te(ie),ze(!!(d!=null&&d.networkPassword)),_("");const Xe=(d==null?void 0:d.terminalApp)||"";A(Xe),g(Xe);const qe=(d==null?void 0:d.editorApp)||"";H(qe),Z(qe);const Ke=(d==null?void 0:d.useBuiltInEditor)===!0;G(Ke),Q(Ke);const Je=fs(d==null?void 0:d.agentExecutable)??tt;W(Je),de(Je),ie&&(d!=null&&d.networkPassword)&&!w?Ie("/api/connected-devices").then(zs).then($e=>q(($e==null?void 0:$e.devices)||[])).catch(Es):q([])}).catch($s))},R=[n,a,j,w],e[3]=a,e[4]=n,e[5]=j,e[6]=F,e[7]=R):(F=e[6],R=e[7]),v.useEffect(F,R);let U;e[8]!==x?(U=d=>{const ie=d.target.value;f(ie),x(ie)},e[8]=x,e[9]=U):U=e[9];const L=U;let B;e[10]!==E||e[11]!==P||e[12]!==I||e[13]!==u||e[14]!==h||e[15]!==r||e[16]!==l||e[17]!==y||e[18]!==k||e[19]!==$?(B=async()=>{o(!0);const d=await y(l,{networkAccess:w?I:u,networkPassword:!w&&u&&h.length>0?h:void 0,terminalApp:k.trim()||void 0,editorApp:P.trim()||void 0,useBuiltInEditor:$,agentExecutable:E});d.success&&d.claudeDir&&(ee(As),r(d.claudeDir)),o(!1)},e[10]=E,e[11]=P,e[12]=I,e[13]=u,e[14]=h,e[15]=r,e[16]=l,e[17]=y,e[18]=k,e[19]=$,e[20]=B):B=e[20];const ae=B;let oe;e[21]!==E||e[22]!==P||e[23]!==se||e[24]!==V||e[25]!==re||e[26]!==I||e[27]!==D||e[28]!==O||e[29]!==u||e[30]!==h||e[31]!==m||e[32]!==k||e[33]!==$?(oe=function(){var $e;if(m==="validating"||m==="invalid")return!1;const ie=m==="valid",Xe=!w&&(u!==I||u&&h.length>0),qe=k!==D,Ke=P!==re||$!==O,Je=!Cs(E,V);if(!ie&&!Xe&&!qe&&!Ke&&!Je||E.source==="custom"&&!(($e=E.path)!=null&&$e.trim()))return!1;if(!w&&u){const yt=h.length>0&&h.length<16,kt=!se&&h.length===0;if(yt||kt)return!1}return!0},e[21]=E,e[22]=P,e[23]=se,e[24]=V,e[25]=re,e[26]=I,e[27]=D,e[28]=O,e[29]=u,e[30]=h,e[31]=m,e[32]=k,e[33]=$,e[34]=oe):oe=e[34];const K=oe();let ue;e[35]!==i?(ue=d=>{d||i()},e[35]=i,e[36]=ue):ue=e[36];let De;e[37]===Symbol.for("react.memo_cache_sentinel")?(De=t.jsxs(Tt,{children:[t.jsx(It,{className:"text-foreground",children:"Configuration"}),t.jsx(Dt,{className:"text-muted-foreground",children:"Manage local paths, preferred apps, and remote access."})]}),e[37]=De):De=e[37];let Pe,Le;e[38]===Symbol.for("react.memo_cache_sentinel")?(Pe=t.jsx(Ee,{htmlFor:"claude-directory",children:"Claude directory"}),Le=t.jsx(J,{children:"The directory containing your Claude configuration."}),e[38]=Pe,e[39]=Le):(Pe=e[38],Le=e[39]);let Fe;e[40]===Symbol.for("react.memo_cache_sentinel")?(Fe=t.jsx(ft,{children:t.jsx(Yt,{"data-icon":"inline-start"})}),e[40]=Fe):Fe=e[40];let fe;e[41]!==K||e[42]!==ae||e[43]!==c?(fe=d=>{d.key==="Enter"&&K&&!c&&ae()},e[41]=K,e[42]=ae,e[43]=c,e[44]=fe):fe=e[44];let me;e[45]!==L||e[46]!==l||e[47]!==fe?(me=t.jsxs(dt,{children:[Fe,t.jsx(ut,{id:"claude-directory",value:l,onChange:L,placeholder:"/Users/you/.claude",disabled:!p,onKeyDown:fe})]}),e[45]=L,e[46]=l,e[47]=fe,e[48]=me):me=e[48];let he;e[49]!==b||e[50]!==m?(he=t.jsx("div",{"aria-live":"polite",children:t.jsx(_s,{status:m,error:b})}),e[49]=b,e[50]=m,e[51]=he):he=e[51];let xe;e[52]!==me||e[53]!==he?(xe=t.jsxs(le,{children:[Pe,Le,me,he]}),e[52]=me,e[53]=he,e[54]=xe):xe=e[54];let Re,Ue;e[55]===Symbol.for("react.memo_cache_sentinel")?(Re=t.jsxs(Ee,{htmlFor:"terminal-application",children:[t.jsx(Zt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Terminal application"]}),Ue=t.jsx(J,{children:"Leave blank to use the system default for Ctrl+Cmd+T."}),e[55]=Re,e[56]=Ue):(Re=e[55],Ue=e[56]);let Be;e[57]===Symbol.for("react.memo_cache_sentinel")?(Be=d=>A(d.target.value),e[57]=Be):Be=e[57];let pe;e[58]!==k?(pe=t.jsxs(le,{children:[Re,Ue,t.jsx(nt,{id:"terminal-application",value:k,onChange:Be,placeholder:"Ghostty, iTerm, or /path/to/binary",disabled:!p})]}),e[58]=k,e[59]=pe):pe=e[59];let Oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Oe=d=>G(d===!0),e[60]=Oe):Oe=e[60];let ge;e[61]!==$?(ge=t.jsx(Pt,{id:"use-built-in-editor",checked:$,onCheckedChange:Oe,disabled:!p}),e[61]=$,e[62]=ge):ge=e[62];let Me;e[63]===Symbol.for("react.memo_cache_sentinel")?(Me=t.jsxs(ht,{children:[t.jsxs(Ee,{htmlFor:"use-built-in-editor",children:[t.jsx(Qt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Open files in Cogpit"]}),t.jsx(J,{children:"Files and diffs open in Cogpit’s file workspace instead of launching an external editor."})]}),e[63]=Me):Me=e[63];let je;e[64]!==ge?(je=t.jsxs(le,{orientation:"horizontal",children:[ge,Me]}),e[64]=ge,e[65]=je):je=e[65];let Ve;e[66]===Symbol.for("react.memo_cache_sentinel")?(Ve=t.jsxs(Ee,{htmlFor:"editor-application",children:[t.jsx(es,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Editor application"]}),e[66]=Ve):Ve=e[66];const Ze=$?"Not used while files open in Cogpit.":"Leave blank to use $VISUAL or automatic detection.";let be;e[67]!==Ze?(be=t.jsx(J,{children:Ze}),e[67]=Ze,e[68]=be):be=e[68];let He;e[69]===Symbol.for("react.memo_cache_sentinel")?(He=d=>H(d.target.value),e[69]=He):He=e[69];const Qe=!p||$;let ve;e[70]!==P||e[71]!==Qe?(ve=t.jsx(nt,{id:"editor-application",value:P,onChange:He,placeholder:"cursor, code, zed, or /path/to/binary",disabled:Qe}),e[70]=P,e[71]=Qe,e[72]=ve):ve=e[72];let we;e[73]!==be||e[74]!==ve?(we=t.jsxs(le,{children:[Ve,be,ve]}),e[73]=be,e[74]=ve,e[75]=we):we=e[75];let Ne;e[76]!==E||e[77]!==M?(Ne=ys.map(d=>t.jsx(xs,{kind:d,value:E,onChange:W,disabled:!p,reportVersion:M},d)),e[76]=E,e[77]=M,e[78]=Ne):Ne=e[78];let Ge;e[79]===Symbol.for("react.memo_cache_sentinel")?(Ge=ks.map(d=>t.jsx(Ns,{kind:d,disabled:!p},d)),e[79]=Ge):Ge=e[79];let Se;e[80]!==ne||e[81]!==se||e[82]!==I||e[83]!==u||e[84]!==h||e[85]!==z?(Se=!w&&p&&t.jsx(rs,{networkAccess:u,setNetworkAccess:S,networkPassword:h,setNetworkPassword:_,showNetworkPassword:z,setShowNetworkPassword:T,hasExistingPassword:se,initialNetworkAccess:I,connectedDevices:ne,minPasswordLength:16}),e[80]=ne,e[81]=se,e[82]=I,e[83]=u,e[84]=h,e[85]=z,e[86]=Se):Se=e[86];let ye;e[87]!==xe||e[88]!==pe||e[89]!==je||e[90]!==we||e[91]!==Ne||e[92]!==Se?(ye=t.jsxs(Lt,{children:[xe,pe,je,we,Ne,Ge,Se]}),e[87]=xe,e[88]=pe,e[89]=je,e[90]=we,e[91]=Ne,e[92]=Se,e[93]=ye):ye=e[93];let ke;e[94]!==i?(ke=t.jsx(ce,{variant:"outline",onClick:i,children:"Cancel"}),e[94]=i,e[95]=ke):ke=e[95];let Ce;e[96]!==K||e[97]!==ae||e[98]!==c?(Ce=p&&t.jsx(ce,{disabled:!K||c,onClick:ae,children:c?t.jsxs(t.Fragment,{children:[t.jsx(it,{"data-icon":"inline-start",className:"size-4 animate-spin"}),"Saving..."]}):"Save"}),e[96]=K,e[97]=ae,e[98]=c,e[99]=Ce):Ce=e[99];let _e;e[100]!==ke||e[101]!==Ce?(_e=t.jsxs(Ft,{children:[ke,Ce]}),e[100]=ke,e[101]=Ce,e[102]=_e):_e=e[102];let Ae;e[103]!==ye||e[104]!==_e?(Ae=t.jsxs(Rt,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg",children:[De,ye,_e]}),e[103]=ye,e[104]=_e,e[105]=Ae):Ae=e[105];let We;return e[106]!==n||e[107]!==Ae||e[108]!==ue?(We=t.jsx(Ut,{open:n,onOpenChange:ue,children:Ae}),e[106]=n,e[107]=Ae,e[108]=ue,e[109]=We):We=e[109],We}function As(s){return s+1}function $s(){}function Es(){}function zs(s){return s.json()}function Ts(s){return s.json()}export{Rs as ConfigDialog};
|