cogpit 2.7.4 → 3.0.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 +5524 -3838
- package/dist/web/assets/CommandPaletteHost-fa5vgo7-.js +1 -0
- package/dist/web/assets/ConfigBrowser-CXvr5BFb.js +1 -0
- package/dist/web/assets/HighlightedEditor-DWc-xoSc.js +2 -0
- package/dist/web/assets/{KeyboardShortcutsDialog-DQuepxQo.js → KeyboardShortcutsDialog-C1of2PBc.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B6rggNR6.js → MobileFileChanges-BAEIKapA.js} +1 -1
- package/dist/web/assets/PluginsDialog-BgnTB0-z.js +1 -0
- package/dist/web/assets/PreviewPanel-DgbgRibz.js +1 -0
- package/dist/web/assets/ProjectFilesPanel-BGpyS_aw.js +4 -0
- package/dist/web/assets/ProjectSwitcherModal-CEypvUNm.js +1 -0
- package/dist/web/assets/{TerminalOutput-CUmbXM9h.js → TerminalOutput-Dq6QP83Y.js} +13 -13
- package/dist/web/assets/ThemeSelectorModal-DeYABHF9.js +1 -0
- package/dist/web/assets/WorkflowsPanel-CNxUSC9Q.js +1 -0
- package/dist/web/assets/WorktreePanel-DJYEUobs.js +1 -0
- package/dist/web/assets/edition-ui-CFlDe2_U.js +2 -0
- package/dist/web/assets/index-Bm91RnFy.js +1 -0
- package/dist/web/assets/index-Ch-IpPaH.js +1 -0
- package/dist/web/assets/index-DVp2Xjmx.js +1 -0
- package/dist/web/assets/{index-BA1eUNuR.js → index-DYugSKH5.js} +4 -4
- package/dist/web/assets/index-DsnL-sXV.js +472 -0
- package/dist/web/assets/index-TCQKag8a.css +1 -0
- package/dist/web/assets/password-BV9mqUzz.js +1 -0
- package/dist/web/assets/{session-parser.worker-CnA52U1J.js → session-parser.worker-CXlsiJzz.js} +24 -24
- package/dist/web/assets/{vendor-ui-ZKZkD5k3.js → vendor-ui-Br3ZTAXZ.js} +237 -167
- package/dist/web/index.html +6 -6
- package/dist/web/theme-bootstrap.js +1 -25
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-ByD_7YRK.js +0 -1
- package/dist/web/assets/ConfigBrowser-vXK8JNMg.js +0 -1
- package/dist/web/assets/HighlightedEditor-BwET41dr.js +0 -2
- package/dist/web/assets/PluginsDialog-DTF9NnK7.js +0 -1
- package/dist/web/assets/PreviewPanel-BaXxki5D.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-CO6Znhgi.js +0 -4
- package/dist/web/assets/ProjectSwitcherModal-Chi-U3vv.js +0 -1
- package/dist/web/assets/TerminalOutput-6GBZ9nXN.css +0 -32
- package/dist/web/assets/ThemeSelectorModal-B2m42_1f.js +0 -1
- package/dist/web/assets/WorkflowsPanel-CiYzHaQg.js +0 -1
- package/dist/web/assets/WorktreePanel-CldMZY3n.js +0 -1
- package/dist/web/assets/index-C-0I_ZqI.js +0 -1
- package/dist/web/assets/index-C6wvrmo0.js +0 -221
- package/dist/web/assets/index-CYN2JttE.js +0 -1
- package/dist/web/assets/index-DYWsIgvZ.css +0 -1
- package/dist/web/assets/index-QH_v3Ygj.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{az as I,H as _,i as U,j as Y,k as q,T as $,h as B,D as J}from"./index-DsnL-sXV.js";import{I as Q,u as V}from"./vendor-ui-Br3ZTAXZ.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%"}],K="cogpit-chat-width",M="medium";function X(){try{const s=localStorage.getItem(K);if(W.some(e=>e.id===s))return s}catch{}return M}let R=typeof window>"u"?M:X();const H=new Set;function L(s){if(typeof document>"u")return;const e=W.find(t=>t.id===s)??W[1];document.documentElement.style.setProperty("--chat-width",e.css)}L(R);function Z(){return R}function ee(s){R=s;try{localStorage.setItem(K,s)}catch{}L(s),H.forEach(e=>e())}function te(s){return H.add(s),()=>H.delete(s)}function se(){const s=O.c(2),e=g.useSyncExternalStore(te,Z,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return M}function de(s){const e=O.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[x,z]=g.useState(0),[P,A]=se();let j,w;e[0]!==l||e[1]!==t?(j=()=>{if(t){const a=I.findIndex(D=>D.id===l);z(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,y;e[9]!==i||e[10]!==t?(S=()=>{t||i(null)},y=[t,i],e[9]=i,e[10]=t,e[11]=S,e[12]=y):(S=e[11],y=e[12]),g.useEffect(S,y);let C;e[13]!==r||e[14]!==k?(C=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=C):C=e[15];const F=C;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs(U,{className:"border-b p-4 pr-12",children:[n.jsxs(Y,{className:"flex items-center gap-2 text-sm",children:[n.jsx(V,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(q,{children:"Preview a color theme and set the chat width."})]}),e[18]=E):E=e[18];const G=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:()=>z(D),onFocus:()=>z(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),l===a.id&&n.jsx(Q,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=l,e[22]=F,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx($,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=v):v=e[27];let f;e[28]!==P?(f=[P],e[28]=P,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:[v,n.jsx($,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let p;e[35]!==m||e[36]!==h?(p=n.jsxs(B,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[E,m,h]}),e[35]=m,e[36]=h,e[37]=p):p=e[37];let T;return e[38]!==t||e[39]!==p||e[40]!==o?(T=n.jsx(J,{open:t,onOpenChange:o,children:p}),e[38]=t,e[39]=p,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{de as ThemeSelectorModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as G,j as s,r as T}from"./vendor-react-gGw_S5I_.js";import{J as le,aQ as Le,aR as mt,aG as ft,aC as xt,aS as Ve,Z as pe,aT as He,aU as Qe,af as je,$ as Se,a0 as Ce,B as ne,a2 as Te,U as Re,aO as Ee,aK as Fe,aL as De,l as Ue,aM as Be,A as Ze,aV as pt,p as Ge,aW as ht,aX as gt,aY as jt,L as ze,M as We,O as Ae,Q as Oe,aZ as bt,d as Nt,c as wt,S as yt,a as vt,a_ as kt,b as St,q as Ct,N as Tt,_ as Rt}from"./index-DsnL-sXV.js";import{M as It}from"./vendor-markdown-BE1gYnO9.js";import{_ as Xe,$ as et,a0 as tt,a1 as $t,a2 as Ie,R as _t,I as st,z as lt,a3 as qe,g as zt,a4 as Wt,a5 as At,B as Ot,a6 as Ye,a as Pt,W as Mt}from"./vendor-ui-Br3ZTAXZ.js";import"./vendor-shiki-DOn6sF-i.js";const Lt=new Set(["done","error","skipped"]);function Ke(l){return Lt.has(l)}function Et(l){return l!=="completed"&&l!=="failed"&&l!=="killed"}function nt(l){switch(l){case"completed":return{label:"Completed",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"failed":return{label:"Failed",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"killed":return{label:"Stopped",badge:"border-warning/30 bg-warning/10 text-warning",dot:"bg-warning"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Ft(l){switch(l){case"done":return{label:"Done",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"skipped":return{label:"Skipped",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};case"error":return{label:"Error",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"queued":return{label:"Queued",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Dt(l){const e=new Map;l.phases.forEach((a,n)=>{const o=n+1;e.set(o,{index:o,title:a.title,detail:a.detail,agents:[]})});const t=[];for(const a of l.agents){const n=e.get(a.phaseIndex);n?n.agents.push(a):t.push(a)}const r=[...e.values()];t.length>0&&r.push({index:r.length+1,title:t[0].phaseTitle||"Other",agents:t});for(const a of r)a.agents.sort((n,o)=>n.index-o.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function rt(l){const e=l.trim();if(!e.startsWith("{")&&!e.startsWith("["))return l;try{return JSON.parse(e)}catch{return l}}function qt(l){try{return JSON.parse(`"${l}"`)}catch{return l.replace(/\\n/g," ").replace(/\\"/g,'"')}}function Yt(l){const e=rt(l);if(e!==l)return $e(e);for(const t of at){const r=l.match(new RegExp(`"${t}"\\s*:\\s*"((?:\\\\.|[^"\\\\])*)"`));if(r!=null&&r[1])return qt(r[1])}return l.replace(/^[#>*\s-]+/,"").replace(/[`*_#]/g,"").split(/\n\s*\n|\n/)[0].trim()}function $e(l){if(typeof l=="string")return Yt(l);if(typeof l=="number"||typeof l=="boolean")return String(l);if(Array.isArray(l))return l.length>0?$e(l[0]):"";if(Le(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 Kt(l){const e={oneLineSell:"In one line",quickWins:"Quick wins",whatIsLost:"What is lost",whyItHurts:"Why it hurts",restingState:"Resting state",fatalFlaws:"Fatal flaws",bestIdeasRegardlessOfConcept:"Best ideas across concepts"};return e[l]?e[l]:l.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^./,t=>t.toUpperCase())}function it(l){const e=G.c(4),{children:t}=l;let r;e[0]!==t?(r=mt(t),e[0]=t,e[1]=r):r=e[1];const a=r;let n;return e[2]!==a?(n=s.jsx(It,{components:xt,remarkPlugins:ft,children:a}),e[2]=a,e[3]=n):n=e[3],n}function ot(l){const e=G.c(7),{value:t}=l;if(typeof t=="string"){let n;return e[0]!==t?(n=s.jsx(it,{children:t}),e[0]=t,e[1]=n):n=e[1],n}if(t===null){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground",children:"None"}),e[2]=n):n=e[2],n}if(typeof t=="boolean"){const n=t?"Yes":"No";let o;return e[3]!==n?(o=s.jsx("span",{children:n}),e[3]=n,e[4]=o):o=e[4],o}const r=String(t);let a;return e[5]!==r?(a=s.jsx("span",{children:r}),e[5]=r,e[6]=a):a=e[6],a}function Pe(l){const e=G.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Le(t)&&!Array.isArray(t)){let o;return e[0]!==t?(o=s.jsx(ot,{value:t}),e[0]=t,e[1]=o):o=e[1],o}if(a>5){let o;e[2]!==t?(o=Je(t),e[2]=t,e[3]=o):o=e[3];let i;return e[4]!==o?(i=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}if(Array.isArray(t)){if(t.length===0){let d;return e[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"}),e[6]=d):d=e[6],d}if(t.every(Qt)){let d;e[7]!==t?(d=t.map(Ht),e[7]=t,e[8]=d):d=e[8];let m;return e[9]!==d?(m=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=m):m=e[10],m}let i;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(m,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Pe,{value:m,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],i=t.map(d),e[11]=a,e[12]=t,e[13]=i}else i=e[13];let u;return e[16]!==i?(u=s.jsx("div",{className:"flex flex-col gap-3",children:i}),e[16]=i,e[17]=u):u=e[17],u}let n;if(e[18]!==a||e[19]!==t){const o=Object.entries(t),i=o.find(Vt),u=o.filter(d=>{const[m]=d;return m!==(i==null?void 0:i[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[i&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:i[1]}),u.map(d=>{const[m,c]=d;return c===void 0?null:Jt.has(m)&&typeof c=="string"?s.jsx("div",{className:"border-l-2 border-foreground/30 pl-4 text-sm font-medium leading-relaxed",children:s.jsx(it,{children:c})},m):s.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:Kt(m)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Pe,{value:c,depth:a+1})})]},m)})]}),e[18]=a,e[19]=t,e[20]=n}else n=e[20];return n}function Vt(l){const[e,t]=l;return Bt.has(e)&&typeof t=="string"&&t.trim().length>0}function Ht(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Qt(l){return!Le(l)&&!Array.isArray(l)}function Me(l){const e=G.c(19),{value:t,className:r}=l;let a;e[0]!==t?(a=typeof t=="string"?rt(t):t,e[0]=t,e[1]=a):a=e[1];const n=a;if(typeof n=="string"&&(n.trim().startsWith("{")||n.trim().startsWith("["))){let m;e[2]!==n?(m=$e(n),e[2]=n,e[3]=m):m=e[3];const c=m;let x;e[4]!==r?(x=le("flex flex-col gap-2",r),e[4]=r,e[5]=x):x=e[5];let f;e[6]!==c?(f=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx("p",{className:"text-xs text-muted-foreground",children:"Only a shortened preview was saved for this response."}),e[8]=h):h=e[8];let p;return e[9]!==x||e[10]!==f?(p=s.jsxs("div",{className:x,children:[f,h]}),e[9]=x,e[10]=f,e[11]=p):p=e[11],p}let i;e[12]!==r?(i=le("min-w-0 text-sm",r),e[12]=r,e[13]=i):i=e[13];let u;e[14]!==n?(u=s.jsx(Pe,{value:n}),e[14]=n,e[15]=u):u=e[15];let d;return e[16]!==i||e[17]!==u?(d=s.jsx("div",{className:i,children:u}),e[16]=i,e[17]=u,e[18]=d):d=e[18],d}function Zt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Gt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Xt(l){const e=G.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[o,i]=T.useState(!1),[u,d]=T.useState(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={status:"idle"},e[0]=m):m=e[0];const[c,x]=T.useState(m),[f,h]=Ve();let p,g,j,b,S,C,y,N,v,R,A,Y,I,W,w,k,$,_,O,P,z;if(e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){v=Ft(t.state);let Ne;e[29]!==t.state?(Ne=!Ke(t.state)&&t.state!=="queued",e[29]=t.state,e[30]=Ne):Ne=e[30],N=Ne;let we;e[31]!==t.resultPreview?(we=t.resultPreview?$e(t.resultPreview):"",e[31]=t.resultPreview,e[32]=we):we=e[32];const ye=we;let ve;e[33]!==t.agentId||e[34]!==r||e[35]!==n||e[36]!==a?(ve=async()=>{x({status:"loading"});try{const he=await Re(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){x({status:"unavailable"});return}const ut=await he.json();x({status:"loaded",value:ut.result})}catch{x({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],y=ve;let ke;e[38]!==t.state||e[39]!==y||e[40]!==c.status?(ke=he=>{i(he),he&&c.status==="idle"&&Ke(t.state)&&y()},e[38]=t.state,e[39]=y,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,C=c.status==="unavailable",S=Se,A=o,Y=ct,b=Ee,P="sm",R="motion-card motion-list-item gap-0 py-0",j=Fe,O="px-0 py-0",g=Ce,k="group flex w-full items-start gap-3 rounded-lg px-3.5 py-3 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",$=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",v.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Gt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(De,{className:"truncate capitalize",title:dt,children:ae}),e[44]=t.label,e[45]=ae,e[46]=re):re=e[46];let ie;e[47]!==t.attempt?(ie=t.attempt&&t.attempt>1&&s.jsxs(pe,{variant:"outline",className:"text-muted-foreground",children:["Attempt ",t.attempt]}),e[47]=t.attempt,e[48]=ie):ie=e[48];let oe;e[49]!==re||e[50]!==ie?(oe=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[re,ie]}),e[49]=re,e[50]=ie,e[51]=oe):oe=e[51];let ce;e[52]!==t.lastToolName||e[53]!==t.lastToolSummary||e[54]!==N||e[55]!==ye?(ce=ye?s.jsx("p",{className:"mt-1 line-clamp-2 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:ye}):N&&t.lastToolName?s.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:["Working in ",t.lastToolName,t.lastToolSummary?`: ${t.lastToolSummary}`:""]}):null,e[52]=t.lastToolName,e[53]=t.lastToolSummary,e[54]=N,e[55]=ye,e[56]=ce):ce=e[56];let de;e[57]!==t.model?(de=t.model&&s.jsx("span",{children:Zt(t.model)}),e[57]=t.model,e[58]=de):de=e[58];let ue;e[59]!==t.tokens?(ue=typeof t.tokens=="number"&&t.tokens>0&&s.jsxs(_e,{icon:Xe,children:[He(t.tokens)," tokens"]}),e[59]=t.tokens,e[60]=ue):ue=e[60];let me;e[61]!==t.toolCalls?(me=typeof t.toolCalls=="number"&&t.toolCalls>0&&s.jsxs(_e,{icon:et,children:[t.toolCalls," tools"]}),e[61]=t.toolCalls,e[62]=me):me=e[62];let fe;e[63]!==t.durationMs?(fe=typeof t.durationMs=="number"&&s.jsx(_e,{icon:tt,children:Qe(t.durationMs)}),e[63]=t.durationMs,e[64]=fe):fe=e[64];let xe;e[65]!==de||e[66]!==ue||e[67]!==me||e[68]!==fe?(xe=s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[de,ue,me,fe]}),e[65]=de,e[66]=ue,e[67]=me,e[68]=fe,e[69]=xe):xe=e[69],e[70]!==oe||e[71]!==ce||e[72]!==xe?(_=s.jsxs("div",{className:"min-w-0 flex-1",children:[oe,ce,xe]}),e[70]=oe,e[71]=ce,e[72]=xe,e[73]=_):_=e[73],w="flex shrink-0 items-center gap-2",p=pe,I="outline",W=le("hidden sm:inline-flex",v.badge),e[1]=t,e[2]=r,e[3]=o,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=g,e[10]=j,e[11]=b,e[12]=S,e[13]=C,e[14]=y,e[15]=N,e[16]=v,e[17]=R,e[18]=A,e[19]=Y,e[20]=I,e[21]=W,e[22]=w,e[23]=k,e[24]=$,e[25]=_,e[26]=O,e[27]=P,e[28]=z}else p=e[8],g=e[9],j=e[10],b=e[11],S=e[12],C=e[13],y=e[14],N=e[15],v=e[16],R=e[17],A=e[18],Y=e[19],I=e[20],W=e[21],w=e[22],k=e[23],$=e[24],_=e[25],O=e[26],P=e[27],z=e[28];let M;e[74]!==N?(M=N&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=N,e[75]=M):M=e[75];let X;e[76]!==p||e[77]!==v.label||e[78]!==M||e[79]!==I||e[80]!==W?(X=s.jsxs(p,{variant:I,className:W,children:[M,v.label]}),e[76]=p,e[77]=v.label,e[78]=M,e[79]=I,e[80]=W,e[81]=X):X=e[81];let K;e[82]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Ie,{className:"mt-0.5 size-4 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"}),e[82]=K):K=e[82];let L;e[83]!==X||e[84]!==w?(L=s.jsxs("div",{className:w,children:[X,K]}),e[83]=X,e[84]=w,e[85]=L):L=e[85];let E;e[86]!==g||e[87]!==L||e[88]!==k||e[89]!==$||e[90]!==_?(E=s.jsxs(g,{className:k,children:[$,_,L]}),e[86]=g,e[87]=L,e[88]=k,e[89]=$,e[90]=_,e[91]=E):E=e[91];let ee;e[92]!==j||e[93]!==E||e[94]!==O?(ee=s.jsx(j,{className:O,children:E}),e[92]=j,e[93]=E,e[94]=O,e[95]=ee):ee=e[95];let V;e[96]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Ue,{}),e[96]=V):V=e[96];let H;e[97]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:"Response"}),e[97]=H):H=e[97];const te=c.status==="loaded"?"Complete agent response":"Saved response preview";let F;e[98]!==te?(F=s.jsxs("div",{children:[H,s.jsx("p",{className:"text-xs text-muted-foreground",children:te})]}),e[98]=te,e[99]=F):F=e[99];let D;e[100]!==C||e[101]!==y?(D=C&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void y(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=C,e[101]=y,e[102]=D):D=e[102];let U;e[103]!==f||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})}),e[103]=f,e[104]=h,e[105]=z,e[106]=U):U=e[106];let B;e[107]!==D||e[108]!==U?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[D,U]}),e[107]=D,e[108]=U,e[109]=B):B=e[109];let J;e[110]!==F||e[111]!==B?(J=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[F,B]}),e[110]=F,e[111]=B,e[112]=J):J=e[112];let q;e[113]!==c.status||e[114]!==N||e[115]!==z?(q=c.status==="loading"?s.jsxs("div",{className:"flex items-center gap-2 py-5 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading the complete response…"]}):z!==void 0?s.jsx(Me,{value:z}):s.jsx("p",{className:"text-sm text-muted-foreground",children:N?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=N,e[115]=z,e[116]=q):q=e[116];let Q;e[117]!==t.promptPreview||e[118]!==u?(Q=t.promptPreview&&s.jsxs(Se,{open:u,onOpenChange:d,children:[s.jsxs(Ce,{render:s.jsx(ne,{variant:"ghost",size:"sm",className:"w-full justify-start"}),children:[s.jsx($t,{"data-icon":"inline-start"}),"Agent prompt",s.jsx(Ie,{"data-icon":"inline-end",className:le("ml-auto transition-transform",u&&"rotate-180")})]}),s.jsx(Te,{className:"pt-2",children:s.jsx("div",{className:"rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground",children:s.jsx(Me,{value:t.promptPreview})})})]}),e[117]=t.promptPreview,e[118]=u,e[119]=Q):Q=e[119];let Z;e[120]!==J||e[121]!==q||e[122]!==Q?(Z=s.jsxs(Te,{children:[V,s.jsxs(Be,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,Q]})]}),e[120]=J,e[121]=q,e[122]=Q,e[123]=Z):Z=e[123];let se;e[124]!==b||e[125]!==R||e[126]!==ee||e[127]!==Z||e[128]!==P?(se=s.jsxs(b,{size:P,className:R,children:[ee,Z]}),e[124]=b,e[125]=R,e[126]=ee,e[127]=Z,e[128]=P,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:Y,children:se}),e[130]=S,e[131]=A,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=G.c(5),{icon:t,children:r}=l;let a;e[0]!==t?(a=s.jsx(t,{className:"size-3"}),e[0]=t,e[1]=a):a=e[1];let n;return e[2]!==r||e[3]!==a?(n=s.jsxs("span",{className:"inline-flex items-center gap-1",children:[a,r]}),e[2]=r,e[3]=a,e[4]=n):n=e[4],n}function es(l){const e=G.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:o,onForceStop:i}=l;let u,d,m,c,x,f,h,p;if(e[0]!==o||e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==a||e[5]!==n){const C=nt(t.status);let y;e[14]!==t.status?(y=Et(t.status),e[14]=t.status,e[15]=y):y=e[15];const N=y,v=Dt(t),R=Ut(t.agentCounts),A=N&&t.controllable!==!1;x="flex flex-col gap-6 pb-6";const Y=N&&s.jsx("span",{className:le("size-1.5 rounded-full",C.dot)});let I;e[16]!==C||e[17]!==Y?(I=s.jsxs(pe,{variant:"outline",className:C.badge,children:[Y,C.label]}),e[16]=C,e[17]=Y,e[18]=I):I=e[18];let W;e[19]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=W):W=e[19];let w;e[20]!==I?(w=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[I,W]}),e[20]=I,e[21]=w):w=e[21];let k;e[22]!==t.workflowName?(k=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=k):k=e[23];let $;e[24]!==t.summary?($=t.summary&&s.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=$):$=e[25];let _;e[26]!==w||e[27]!==k||e[28]!==$?(_=s.jsxs("div",{className:"min-w-0",children:[w,k,$]}),e[26]=w,e[27]=k,e[28]=$,e[29]=_):_=e[29];let O;e[30]!==N||e[31]!==A||e[32]!==o||e[33]!==i||e[34]!==n?(O=N&&i&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:o?"destructive":"outline",size:"sm",disabled:!A||n,onClick:i,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),o?"Confirm stop":"Stop workflow"]}),!A&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=N,e[31]=A,e[32]=o,e[33]=i,e[34]=n,e[35]=O):O=e[35];let P;e[36]!==_||e[37]!==O?(P=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,O]}),e[36]=_,e[37]=O,e[38]=P):P=e[38];const z=`${t.agentCounts.done+t.agentCounts.error}/${t.agentCount}`;let M;e[39]!==z?(M=s.jsx(ge,{icon:Wt,value:z,label:"Agents finished"}),e[39]=z,e[40]=M):M=e[40];const X=String(t.phaseCount);let K;e[41]!==X?(K=s.jsx(ge,{icon:At,value:X,label:"Phases"}),e[41]=X,e[42]=K):K=e[42];let L;e[43]!==t.totalTokens?(L=He(t.totalTokens),e[43]=t.totalTokens,e[44]=L):L=e[44];let E;e[45]!==L?(E=s.jsx(ge,{icon:Xe,value:L,label:"Tokens"}),e[45]=L,e[46]=E):E=e[46];const ee=String(t.totalToolCalls);let V;e[47]!==ee?(V=s.jsx(ge,{icon:et,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=V):V=e[48];let H;e[49]!==t.durationMs?(H=typeof t.durationMs=="number"?Qe(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=H):H=e[50];let te;e[51]!==H?(te=s.jsx(ge,{icon:tt,value:H,label:"Duration",className:"col-span-2 sm:col-span-1"}),e[51]=H,e[52]=te):te=e[52];let F;e[53]!==M||e[54]!==K||e[55]!==E||e[56]!==V||e[57]!==te?(F=s.jsxs("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border sm:grid-cols-5",children:[M,K,E,V,te]}),e[53]=M,e[54]=K,e[55]=E,e[56]=V,e[57]=te,e[58]=F):F=e[58];let D;e[59]!==R?(D=Math.round(R*100),e[59]=R,e[60]=D):D=e[60];let U;e[61]!==D?(U=s.jsx(jt,{value:D,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=D,e[62]=U):U=e[62];let B;e[63]!==R?(B=Math.round(R*100),e[63]=R,e[64]=B):B=e[64];let J;e[65]!==B?(J=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[B,"%"]}),e[65]=B,e[66]=J):J=e[66];let q;e[67]!==U||e[68]!==J?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,J]}),e[67]=U,e[68]=J,e[69]=q):q=e[69],e[70]!==P||e[71]!==F||e[72]!==q?(f=s.jsxs("section",{className:"flex flex-col gap-4",children:[P,F,q]}),e[70]=P,e[71]=F,e[72]=q,e[73]=f):f=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Ze,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(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],m="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let Q;e[81]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=Q):Q=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-popover p-2 md:block","aria-label":"Workflow phases",children:[Q,s.jsx("div",{className:"flex flex-col gap-1",children:v.map(ts)})]}),u="flex min-w-0 flex-col gap-8";let Z;e[82]!==t.runId||e[83]!==r||e[84]!==a?(Z=se=>s.jsx(ss,{group:se,dirName:r,sessionId:a,runId:t.runId},`${se.index}-${se.title}`),e[82]=t.runId,e[83]=r,e[84]=a,e[85]=Z):Z=e[85],d=v.map(Z),e[0]=o,e[1]=t,e[2]=r,e[3]=i,e[4]=a,e[5]=n,e[6]=u,e[7]=d,e[8]=m,e[9]=c,e[10]=x,e[11]=f,e[12]=h,e[13]=p}else u=e[6],d=e[7],m=e[8],c=e[9],x=e[10],f=e[11],h=e[12],p=e[13];let g;e[86]!==u||e[87]!==d?(g=s.jsx("div",{className:u,children:d}),e[86]=u,e[87]=d,e[88]=g):g=e[88];let j;e[89]!==m||e[90]!==c||e[91]!==g?(j=s.jsxs("div",{className:m,children:[c,g]}),e[89]=m,e[90]=c,e[91]=g,e[92]=j):j=e[92];let b;e[93]!==t.script?(b=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=b):b=e[94];let S;return e[95]!==j||e[96]!==b||e[97]!==x||e[98]!==f||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:x,children:[f,h,p,j,b]}),e[95]=j,e[96]=b,e[97]=x,e[98]=f,e[99]=h,e[100]=p,e[101]=S):S=e[101],S}function ts(l){return s.jsxs(ne,{variant:"ghost",size:"sm",type:"button",onClick:()=>{var e;return(e=document.getElementById(`workflow-phase-${l.index}`))==null?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-xs font-medium text-foreground",children:l.index}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.title}),s.jsx("span",{className:"tabular-nums",children:l.agents.length})]},`${l.index}-${l.title}`)}function ge(l){const e=G.c(15),{icon:t,value:r,label:a,className:n}=l;let o;e[0]!==n?(o=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=o):o=e[1];let i;e[2]!==t?(i=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=i):i=e[3];let u;e[4]!==r?(u=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=u):u=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let m;e[8]!==u||e[9]!==d?(m=s.jsxs("div",{className:"min-w-0",children:[u,d]}),e[8]=u,e[9]=d,e[10]=m):m=e[10];let c;return e[11]!==o||e[12]!==i||e[13]!==m?(c=s.jsxs("div",{className:o,children:[i,m]}),e[11]=o,e[12]=i,e[13]=m,e[14]=c):c=e[14],c}function ss(l){const e=G.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let o;e[0]!==t.agents?(o=t.agents.filter(ls),e[0]=t.agents,e[1]=o):o=e[1];const i=o.length,u=`workflow-phase-${t.index}`;let d;e[2]!==t.index?(d=s.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary text-xs font-semibold text-primary-foreground",children:t.index}),e[2]=t.index,e[3]=d):d=e[3];let m;e[4]!==t.title?(m=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=m):m=e[5];let c;e[6]!==i||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[i,"/",t.agents.length," complete"]}),e[6]=i,e[7]=t.agents.length,e[8]=c):c=e[8];let x;e[9]!==m||e[10]!==c?(x=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[m,c]}),e[9]=m,e[10]=c,e[11]=x):x=e[11];let f;e[12]!==t.detail?(f=t.detail&&s.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.detail}),e[12]=t.detail,e[13]=f):f=e[13];let h;e[14]!==x||e[15]!==f?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[x,f]}),e[14]=x,e[15]=f,e[16]=h):h=e[16];let p;e[17]!==d||e[18]!==h?(p=s.jsxs("div",{className:"mb-3 flex items-start gap-3",children:[d,h]}),e[17]=d,e[18]=h,e[19]=p):p=e[19];let g;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(g=t.agents.length===0?s.jsx(ze,{className:"border py-6",children:s.jsxs(We,{children:[s.jsx(Ae,{children:"No agents yet"}),s.jsx(Oe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(b=>s.jsx(Xt,{agent:b,dirName:r,sessionId:a,runId:n},`${n}:${b.agentId||b.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=g):g=e[24];let j;return e[25]!==g||e[26]!==u||e[27]!==p?(j=s.jsxs("section",{id:u,className:"scroll-mt-4",children:[p,g]}),e[25]=g,e[26]=u,e[27]=p,e[28]=j):j=e[28],j}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=T.useState(!0),[o,i]=T.useState(),[u,d]=T.useState(!1),[m,c]=T.useState(!1),[x,f]=Ve(),h=l.endsWith("…"),p=o??l,g=T.useCallback(async()=>{d(!0),c(!1);try{const j=await Re(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!j.ok){c(!0);return}const b=await j.json();i(b.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Ee,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Fe,{className:"py-4",children:[s.jsxs(Ce,{className:"group flex min-w-0 items-center gap-3 text-left outline-none",children:[s.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:s.jsx(zt,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx(De,{children:"Workflow outcome"}),s.jsx(ht,{children:"The synthesized answer from this run"})]}),s.jsx(Ie,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"})]}),s.jsxs(gt,{className:"flex items-center gap-1",children:[h&&o===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:u,onClick:()=>void g(),children:[u&&s.jsx(je,{"data-icon":"inline-start"}),m?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>f(Je(p)),"aria-label":x?"Outcome copied":"Copy outcome",title:x?"Copied":"Copy outcome",children:x?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(Ue,{}),s.jsx(Be,{className:"py-5",children:s.jsx(Me,{value:p})})]})]})})}function as(l){const e=G.c(7),{script:t}=l,[r,a]=T.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Fe,{className:"px-0 py-0",children:s.jsxs(Ce,{className:"group flex w-full items-center gap-2 px-3 py-3 text-left text-sm font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/40 hover:text-foreground",children:[s.jsx(Ot,{className:"size-4"}),s.jsx(De,{children:"Orchestration script"}),s.jsx(Ie,{className:"ml-auto size-4 transition-transform group-data-panel-open:rotate-180"})]})}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ue,{}),e[1]=o):o=e[1];let i;e[2]!==t?(i=s.jsxs(Ee,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[o,s.jsx(Be,{className:"py-3",children:s.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs leading-relaxed text-muted-foreground",children:t})})]})]}),e[2]=t,e[3]=i):i=e[3];let u;return e[4]!==r||e[5]!==i?(u=s.jsx(Se,{open:r,onOpenChange:a,children:i}),e[4]=r,e[5]=i,e[6]=u):u=e[6],u}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,canStop:o,onRefetchList:i}){var W;const[u,d]=T.useState(null),[m,c]=T.useState(!1),[x,f]=T.useState(null),[h,p]=T.useState(!1),[g,j]=T.useState(!1),[b,S]=T.useState(!1),[C,y]=T.useState(null),N=T.useRef(0),v=m?null:u&&a.some(w=>w.runId===u)?u:((W=a[0])==null?void 0:W.runId)??null,R=T.useCallback(async()=>{const w=++N.current;if(!t||!r||!v){f(null);return}try{const k=await Re(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(v)}`);if(!k.ok){w===N.current&&f(null);return}const $=await k.json();w===N.current&&f($)}catch{w===N.current&&f(null)}finally{w===N.current&&p(!1)}},[t,r,v]);T.useEffect(()=>{if(!v){f(null);return}f(null),p(!0),S(!1),y(null),R()},[v,R]),bt(l?t:null,l?r:null,l?v:null,()=>{R(),i()});const A=T.useCallback(async()=>{if(!b){S(!0);return}if(!(!r||!v)){j(!0),y(null);try{const k=await(await Re("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:v})})).json().catch(()=>({}));k!=null&&k.success?y("Stop signal sent."):(k==null?void 0:k.controllable)===!1?y("This workflow runs in a session Cogpit doesn't control."):y("Couldn't stop. The session may have already exited."),R(),i()}catch{y("Stop request failed.")}finally{j(!1),S(!1)}}},[b,r,v,R,i]),Y=a.length>1,I=a.find(w=>w.runId===v);return s.jsx(Nt,{open:l,onOpenChange:e,children:s.jsxs(wt,{side:"right",className:"w-full data-[side=right]:max-w-[1120px]",children:[s.jsx(yt,{className:"min-h-14 justify-center border-b py-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 pr-9",children:[s.jsxs(vt,{className:"flex items-center gap-2",children:[s.jsx(Ye,{className:"size-4"}),"Workflows",a.length>0&&s.jsx(pe,{variant:"secondary",children:a.length}),n&&s.jsxs(pe,{variant:"outline",className:"border-info/30 text-info",children:[s.jsx(kt,{className:"size-1.5"}),"Live"]})]}),s.jsx(St,{className:"sr-only",children:"Inspect workflow runs, agent progress, and run controls for this session."}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Refresh workflows",title:"Refresh workflows",children:s.jsx(Pt,{"data-icon":"inline-start"})})]})}),s.jsx(Ct,{className:"h-[calc(100dvh-3.5rem)]",children:s.jsx("div",{className:"px-5 py-6 sm:px-6",children:a.length===0?s.jsx(ze,{className:"min-h-[60dvh]",children:s.jsxs(We,{children:[s.jsx(Tt,{variant:"icon",children:s.jsx(Ye,{})}),s.jsx(Ae,{children:"No workflows in this session"}),s.jsx(Oe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[Y&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[v&&x&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>c(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Mt,{"data-icon":"inline-start"}),"All runs"]}),(!v||!x)&&a.map(w=>s.jsx(rs,{workflow:w,active:w.runId===v,onClick:()=>{d(w.runId),c(!1)}},w.runId))]}),h&&!x?s.jsxs("div",{className:"flex min-h-[50dvh] items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading workflow…"]}):x?s.jsxs(s.Fragment,{children:[C&&s.jsx(Ze,{className:"mb-4",children:s.jsx(Ge,{children:C})}),s.jsx(es,{detail:x,dirName:t??"",sessionId:r??"",stopping:g,confirming:b,onForceStop:o?A:void 0})]}):I?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(We,{children:[s.jsx(Ae,{children:"Could not load this workflow"}),s.jsx(Oe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=G.c(45),{workflow:t,active:r,onClick:a}=l;let n,o,i,u,d,m,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){i=nt(t.status),o=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",m=a;const N=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==N?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",N),e[12]=N,e[13]=c):c=e[13],u=le("size-2 shrink-0 rounded-full",i.dot),e[0]=r,e[1]=a,e[2]=t.agentCounts.done,e[3]=t.agentCounts.error,e[4]=t.status,e[5]=n,e[6]=o,e[7]=i,e[8]=u,e[9]=d,e[10]=m,e[11]=c}else n=e[5],o=e[6],i=e[7],u=e[8],d=e[9],m=e[10],c=e[11];let x;e[14]!==u?(x=s.jsx("span",{className:u}),e[14]=u,e[15]=x):x=e[15];let f;e[16]!==t.workflowName?(f=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=f):f=e[17];let h;e[18]!==i.badge||e[19]!==i.label?(h=s.jsx(pe,{variant:"outline",className:i.badge,children:i.label}),e[18]=i.badge,e[19]=i.label,e[20]=h):h=e[20];let p;e[21]!==f||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[f,h]}),e[21]=f,e[22]=h,e[23]=p):p=e[23];let g;e[24]!==t.summary?(g=t.summary&&s.jsx("p",{className:"mt-1 line-clamp-1 text-xs text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=g):g=e[25];let j;e[26]!==o||e[27]!==t.agentCount?(j=s.jsxs("span",{children:[o,"/",t.agentCount," agents"]}),e[26]=o,e[27]=t.agentCount,e[28]=j):j=e[28];let b;e[29]!==t.startTime?(b=t.startTime>0&&s.jsx("span",{children:Rt(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=b):b=e[30];let S;e[31]!==j||e[32]!==b?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[j,b]}),e[31]=j,e[32]=b,e[33]=S):S=e[33];let C;e[34]!==S||e[35]!==p||e[36]!==g?(C=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,g,S]}),e[34]=S,e[35]=p,e[36]=g,e[37]=C):C=e[37];let y;return e[38]!==n||e[39]!==C||e[40]!==d||e[41]!==m||e[42]!==c||e[43]!==x?(y=s.jsxs(n,{variant:d,onClick:m,className:c,children:[x,C]}),e[38]=n,e[39]=C,e[40]=d,e[41]=m,e[42]=c,e[43]=x,e[44]=y):y=e[44],y}export{ms as WorkflowsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as h,j as e}from"./vendor-react-gGw_S5I_.js";import{Y,B as d,J as A,l as Z,L as K,M as V,N as _,O as ee,Q as se,Z as ne,_ as te,$ as ae,a0 as re,a1 as R,a2 as ie,a3 as S,a4 as z,a5 as E,a6 as oe,a7 as U,a8 as F,a9 as $,aa as T,ab as P,U as u,ac as c}from"./index-DsnL-sXV.js";import{G as O,g as le,a as ce,X as de,b as me,h as he,i as I,C as xe,F as ue}from"./vendor-ui-Br3ZTAXZ.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const pe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function ye({worktrees:v,loading:p,dirName:r,onRefetch:g,onOpenSession:M,onClose:J}){const l=Y("hostFiles"),[L,y]=h.useState(null),[B,b]=h.useState(null),[W,x]=h.useState(!1),[n,m]=h.useState(null),[a,j]=h.useState(null),C=async s=>{if(!(!l||!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)}}},G=s=>{if(!(!l||!r)){if(s.isDirty){m({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){m({worktree:s,reason:"unpushed"});return}C(s)}},H=()=>{if(!n)return;const{worktree:s,reason:t}=n;if(t==="dirty"&&s.commitsAhead>0){m({worktree:s,reason:"unpushed"});return}m(null),C(s)},q=async s=>{if(!(!l||!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 o=await t.json();o.url?window.open(o.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const o=await t.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${o.error||"Unknown error"}`)}}catch(t){c.error(`Error creating PR: ${t instanceof Error?t.message:"Unknown error"}`)}finally{b(null)}}},Q=async()=>{if(!(!l||!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(o=>o.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{x(!1)}}},X=async()=>{if(!l||!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-canvas",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsx(O,{"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"}),l&&e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:Q,disabled:W,"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(ce,{"data-icon":"inline-start",className:A(p&&"animate-spin")})}),e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:J,"aria-label":"Close worktrees",children:e.jsx(de,{"data-icon":"inline-start"})})]}),e.jsx(Z,{}),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(K,{className:"border-0 py-16",children:e.jsxs(V,{children:[e.jsx(_,{variant:"icon",children:e.jsx(O,{})}),e.jsx(ee,{children:"No worktrees"}),e.jsx(se,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var w,N,D;const t=((w=s.changedFiles)==null?void 0:w.reduce((i,k)=>i+k.additions,0))??0,o=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.deletions,0))??0,f=((D=s.changedFiles)==null?void 0:D.length)??0;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 transition-colors hover:bg-accent/40",children:[e.jsxs("div",{className:"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(ne,{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:()=>M(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(me,{"data-icon":"inline-start"})}),l&&e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:B===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:()=>G(s),disabled:L===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(I,{"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:te(s.createdAt)}),f>0&&e.jsxs(ae,{className:"mt-2",children:[e.jsxs(re,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(xe,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(ue,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[f," file",f!==1?"s":""," changed"]}),e.jsx(R,{add:t,del:o,className:"ml-1"})]}),e.jsx(ie,{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",pe[i.status]??"text-muted-foreground"),children:i.status}),e.jsx("span",{className:"truncate text-foreground/80",children:i.path}),e.jsx(R,{add:i.additions,del:i.deletions,className:"ml-auto text-muted-foreground"})]},i.path))})})]})]},s.name)})]})]}),e.jsx(S,{open:n!==null,onOpenChange:s=>{s||m(null)},children:e.jsxs(z,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(oe,{className:"bg-destructive/10 text-destructive",children:e.jsx(I,{})}),e.jsx(U,{children:(n==null?void 0:n.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(F,{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($,{children:[e.jsx(T,{size:"sm",children:"Cancel"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:H,children:(n==null?void 0:n.reason)==="dirty"&&n.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(S,{open:a!==null,onOpenChange:s=>{s||j(null)},children:e.jsxs(z,{children:[e.jsxs(E,{children:[e.jsx(U,{children:"Remove stale worktrees?"}),e.jsxs(F,{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($,{children:[e.jsx(T,{size:"sm",children:"Cancel"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{ye as WorktreePanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Cogpit Team UI - proprietary, not covered by the MIT license */
|
|
2
|
+
import{c as A,r as _,j as s}from"./vendor-react-gGw_S5I_.js";import{U as me,b5 as As,bX as re,c5 as ks,c6 as Ye,A as ee,aV as le,p as te,ac as he,B as F,a6 as Es,a7 as Ds,a8 as Ts,a5 as Ps,aa as Os,a9 as Us,ab as Rs,a4 as Ls,a3 as Is,bU as Ms,af as We,aX as Ct,Z as ne,aL as _e,aK as $e,aM as Ae,aO as ke,a$ as J,aH as Fs,C as X,c7 as _t,v as Gs,bR as zs,L as Ee,M as De,N as Ke,O as Te,Q as Pe,c8 as Bs,c9 as Hs,ca as Vs,cb as Ys,_ as Ws,cc as qe,cd as Je,ce as ae,cf as Q,cg as Xe,ch as Z,ci as Qe,G as Ze,aW as et,b4 as de,b0 as tt,n as Ks,I as qs,E as Js,m as Xs,h as $t,D as At,H as Oe,i as kt,j as Et,k as Dt,T as st,z as Tt,c3 as Qs,aI as Zs,aT as Pt,cj as Ot,ck as V,aq as Ue,cl as Se,cm as ve,cn as pt,J as se,co as q,cp as en,cq as tn,cr as sn,cs as xe,q as nn,ct as ln,y as Ut,cu as an,bZ as rn,cv as on,cw as cn,cx as dn,cy as un,ar as fn,R as nt,cz as mn,at as Rt,cA as Lt,aN as hn,be as It,bc as Mt,bd as Ft,bf as Gt,bg as zt,bh as Bt,Y as xn,cB as pn,cC as gn,cD as jn}from"./index-DsnL-sXV.js";import{J as Ht,aE as Vt,aF as lt,aG as at,aH as bn,ae as Yt,a2 as wn,a9 as yn,aa as Sn,aI as Nn,aJ as vn,aK as Cn,aL as _n,X as Wt,af as rt,aM as $n,aN as Kt,m as An,aO as qt,a5 as kn,aP as En,aQ as Dn,aR as Tn,aS as Pn}from"./vendor-ui-Br3ZTAXZ.js";import{P as ue}from"./password-BV9mqUzz.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function On(n,e){const t=await me(n,{signal:e});if(!t.ok)throw new Error(await As(t,`Request failed (${t.status})`));const l=await re(t);if(!l)throw new Error("The server returned an unexpected response");return l}function ce(n){const e=A.c(11);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={data:null,dataPath:null,error:null,loading:!0},e[0]=t):t=e[0];const[l,r]=_.useState(t),[a,i]=_.useState(0);let o;e[1]!==n?(o=()=>{const m=new AbortController;return r(Rn),On(n,m.signal).then(h=>{m.signal.aborted||r({data:h,dataPath:n,error:null,loading:!1})}).catch(h=>{if(m.signal.aborted)return;const x=h instanceof Error?h.message:"Request failed";r(p=>{const g=p.dataPath===n;return{data:g?p.data:null,dataPath:g?n:null,error:x,loading:!1}})}),()=>m.abort()},e[1]=n,e[2]=o):o=e[2];let c;e[3]!==a||e[4]!==n?(c=[n,a],e[3]=a,e[4]=n,e[5]=c):c=e[5],_.useEffect(o,c);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i(Un),e[6]=d):d=e[6];const u=d;let f;return e[7]!==l.data||e[8]!==l.error||e[9]!==l.loading?(f={data:l.data,error:l.error,loading:l.loading,refresh:u},e[7]=l.data,e[8]=l.error,e[9]=l.loading,e[10]=f):f=e[10],f}function Un(n){return n+1}function Rn(n){return{...n,loading:!0,error:null}}function Jt(n){const{from:e,to:t}=n;return ce(`/api/team/usage?from=${e}&to=${t}`)}function Ln(n){return n===null||!("role"in n)?!1:n.role==="admin"||n.role==="member"}const Xt=864e5,Me=90,gt=Me*Xt;function In({from:n,to:e},t){return e-n>gt?"too_long":e<t-gt?"too_old":null}const it={admin:"Admin",member:"Member"},Ce={text:"—",title:"Price unavailable"},Qt="No one can become an admin while the license keeps members out.";function Zt(n,e){return{from:e-n*Xt,to:e}}function es(n){return n.input+n.output+n.cacheRead+n.cacheWrite}const Fe="cogpit:lockout-return-to-people";function Mn(){try{sessionStorage.setItem(Fe,"1")}catch{return}window.history.replaceState(null,"",`${ks()}/`)}function Fn(){try{return sessionStorage.getItem(Fe)===null?!1:(sessionStorage.removeItem(Fe),!0)}catch{return!1}}function K(n){return new Date(n).toLocaleDateString(void 0,{dateStyle:"medium"})}function Ge(n){const e=new Date(n),t=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${l}`}function ts(n,e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(!t)return null;const[l,r,a]=[Number(t[1]),Number(t[2])-1,Number(t[3])],i=new Date(l,r,a);return i.getFullYear()!==l||i.getMonth()!==r||i.getDate()!==a?null:(i.setDate(i.getDate()+e),i.getTime())}function Gn(n){return ts(n,0)}function zn(n){const e=ts(n,1);return e===null?null:e-1}const Bn={"shares.local.json":" Every share link was reset and its guests signed out; share each session again.","sessions.json":" Everyone was signed out and must sign in again."};function Hn({store:n,detectedAt:e,kind:t}){if(t==="baseline")return`The audit log started on ${K(e)}; existing data was accepted as-is.`;const l=`detected ${K(e)}`;return(t==="unverifiable"?`${n} could not be checked against the audit log (${l}).`:`${n} was changed outside Cogpit (${l}).`)+(Bn[n]??"")}const Vn={expired:{cause:"The license has expired.",remedy:"install a new key"},over_seats:{cause:"More accounts are enabled than the license has seats.",remedy:"disable accounts or install a license with more seats"}};function Yn({state:n,reason:e,graceEndsAt:t}){if(n==="valid"||e===null)return null;const{cause:l,remedy:r}=Vn[e];return n==="locked"?`${l} Only admins can sign in until you ${r}.`:t===null?`${l} Members will be locked out unless you ${r}.`:`${l} Members can sign in until ${K(t)}; ${r} before then.`}function Wn(n){const e=[],{audit:t}=n;if(t.writable||e.push({id:"audit-writable",message:"The audit log cannot be written. Prompts and admin actions are not being recorded."}),t.missed>0){const r=t.missed===1?"1 audit event":`${t.missed} audit events`,a=t.since===null?"":` since ${K(t.since)}`;e.push({id:"audit-missed",message:`${r} could not be recorded${a}.`})}t.clockAhead&&e.push({id:"audit-clock",message:"The audit log is dated ahead of this server's clock, so new entries carry the log's time. Check the system clock."});for(const r of n.integrity)e.push({id:`integrity-${r.store}-${r.detectedAt}`,message:Hn(r),acceptance:r.kind==="baseline"?{store:r.store,subject:"the existing data",trust:"Cogpit will keep trusting the stores' current contents, and the audit log will record that you accepted them."}:{store:r.store,subject:r.store,trust:"Cogpit will trust the file's current contents from now on, and the audit log will record that you accepted them."}});for(const{store:r,since:a}of n.storeWrites)e.push({id:`store-write-${r}`,message:`${r} could not be saved since ${K(a)}. Changes made since then, revoked access included, apply until the server restarts, then are lost. Free disk space or fix the data directory's permissions.`});const l=Yn(n.license);return l&&e.push({id:"license",message:l}),e}const Kn="Every seat on the license is in use. Disable someone or install a license with more seats.";async function pe(n,e,t){let l;try{l=await Ye(n,t,{method:e})}catch{return{ok:!1,error:"Could not reach the server."}}const r=await re(l);if(l.ok&&r)return{ok:!0,value:r};const a=r;return(a==null?void 0:a.code)==="SEAT_LIMIT"?{ok:!1,error:Kn}:{ok:!1,error:typeof(a==null?void 0:a.error)=="string"&&a.error?a.error:`Request failed (${l.status})`}}function qn(n){return pe("/api/team/users","POST",n)}function ss(n,e){return pe(`/api/team/users/${encodeURIComponent(n)}`,"PATCH",e)}function Jn(n){return pe("/api/team/session-access/assign","POST",n)}function Xn(n){return pe("/api/team/license","POST",{key:n})}function Qn(n){return pe("/api/team/health/acknowledge","POST",{store:n})}function ge(){const[n,e]=_.useState(!1),[t,l]=_.useState(null);async function r(a){e(!0),l(null);try{const i=await a();return i.ok?i.value:(l(i.error),null)}finally{e(!1)}}return{busy:n,error:t,setError:l,run:r}}function Zn(n){const e=A.c(40),{acceptance:t,warning:l,onAccepted:r}=n,{store:a,subject:i,trust:o}=t,{busy:c,error:d,run:u}=ge(),[f,m]=_.useState(!1);let h;e[0]!==r||e[1]!==u||e[2]!==a||e[3]!==i?(h=async function(){m(!1),await u(()=>Qn(a))&&(he.success(`Accepted the current state of ${i}`),r())},e[0]=r,e[1]=u,e[2]=a,e[3]=i,e[4]=h):h=e[4];const x=h,p=`Accept the current state of ${i}`;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=()=>m(!0),e[5]=g):g=e[5];let j;e[6]!==c||e[7]!==p?(j=s.jsx(F,{variant:"outline",size:"xs",disabled:c,"aria-label":p,onClick:g,children:"Accept current state"}),e[6]=c,e[7]=p,e[8]=j):j=e[8];let b;e[9]!==d?(b=d&&s.jsx("span",{role:"alert",className:"text-destructive",children:d}),e[9]=d,e[10]=b):b=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Es,{className:"bg-warning/10 text-warning",children:s.jsx(Vt,{})}),e[11]=S):S=e[11];const w=`Accept the current state of ${i}?`;let y;e[12]!==w?(y=s.jsx(Ds,{children:w}),e[12]=w,e[13]=y):y=e[13];let N;e[14]!==l?(N=s.jsx("span",{children:l}),e[14]=l,e[15]=N):N=e[15];let v;e[16]!==o?(v=s.jsx("span",{children:o}),e[16]=o,e[17]=v):v=e[17];let C;e[18]!==N||e[19]!==v?(C=s.jsxs(Ts,{className:"flex flex-col gap-2",children:[N,v]}),e[18]=N,e[19]=v,e[20]=C):C=e[20];let $;e[21]!==C||e[22]!==y?($=s.jsxs(Ps,{children:[S,y,C]}),e[21]=C,e[22]=y,e[23]=$):$=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Os,{size:"sm",children:"Cancel"}),e[24]=k):k=e[24];let T;e[25]!==x?(T=()=>void x(),e[25]=x,e[26]=T):T=e[26];let U;e[27]!==c||e[28]!==T?(U=s.jsxs(Us,{children:[k,s.jsx(Rs,{size:"sm",disabled:c,onClick:T,children:"Accept current state"})]}),e[27]=c,e[28]=T,e[29]=U):U=e[29];let O;e[30]!==$||e[31]!==U?(O=s.jsxs(Ls,{children:[$,U]}),e[30]=$,e[31]=U,e[32]=O):O=e[32];let D;e[33]!==f||e[34]!==O?(D=s.jsx(Is,{open:f,onOpenChange:m,children:O}),e[33]=f,e[34]=O,e[35]=D):D=e[35];let E;return e[36]!==D||e[37]!==j||e[38]!==b?(E=s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[j,b,D]}),e[36]=D,e[37]=j,e[38]=b,e[39]=E):E=e[39],E}function el(n){const e=A.c(28),{health:t,onChanged:l}=n;let r,a,i,o,c,d,u,f,m;if(e[0]!==t||e[1]!==l){m=Symbol.for("react.early_return_sentinel");e:{const g=Wn(t);if(g.length===0){m=null;break e}a=ee,d="border-warning/30 bg-warning/10 text-warning",e[11]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ht,{}),f=s.jsx(le,{children:"This team server needs attention"}),e[11]=u,e[12]=f):(u=e[11],f=e[12]),r=te,c="text-warning/90",i="flex list-disc flex-col gap-1 pl-4";let j;e[13]!==l?(j=b=>s.jsxs("li",{children:[s.jsx("span",{className:"mr-2",children:b.message}),b.acceptance&&s.jsx(Zn,{acceptance:b.acceptance,warning:b.message,onAccepted:l})]},b.id),e[13]=l,e[14]=j):j=e[14],o=g.map(j)}e[0]=t,e[1]=l,e[2]=r,e[3]=a,e[4]=i,e[5]=o,e[6]=c,e[7]=d,e[8]=u,e[9]=f,e[10]=m}else r=e[2],a=e[3],i=e[4],o=e[5],c=e[6],d=e[7],u=e[8],f=e[9],m=e[10];if(m!==Symbol.for("react.early_return_sentinel"))return m;let h;e[15]!==i||e[16]!==o?(h=s.jsx("ul",{className:i,children:o}),e[15]=i,e[16]=o,e[17]=h):h=e[17];let x;e[18]!==r||e[19]!==c||e[20]!==h?(x=s.jsx(r,{className:c,children:h}),e[18]=r,e[19]=c,e[20]=h,e[21]=x):x=e[21];let p;return e[22]!==a||e[23]!==d||e[24]!==u||e[25]!==f||e[26]!==x?(p=s.jsxs(a,{className:d,children:[u,f,x]}),e[22]=a,e[23]=d,e[24]=u,e[25]=f,e[26]=x,e[27]=p):p=e[27],p}function fe(n){const e=A.c(11),{title:t,message:l,onRetry:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(lt,{}),e[0]=a):a=e[0];let i;e[1]!==t?(i=s.jsx(le,{children:t}),e[1]=t,e[2]=i):i=e[2];let o;e[3]!==l?(o=s.jsx(te,{children:l}),e[3]=l,e[4]=o):o=e[4];let c;e[5]!==r?(c=s.jsx(Ms,{children:s.jsx(F,{variant:"outline",size:"xs",onClick:r,children:"Retry"})}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==i||e[8]!==o||e[9]!==c?(d=s.jsxs(ee,{variant:"destructive",children:[a,i,o,c]}),e[7]=i,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function ot(n){const e=A.c(3),{label:t}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(We,{className:"size-4"}),e[0]=l):l=e[0];let r;return e[1]!==t?(r=s.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[l,t]}),e[1]=t,e[2]=r):r=e[2],r}const tl={valid:{label:"Active",variant:"secondary"},grace:{label:"Grace period",variant:"outline",className:"border-warning/30 bg-warning/10 text-warning"},locked:{label:"Members locked out",variant:"destructive"}};function sl(n){const e=A.c(20),{license:t}=n;let l;e[0]!==t.customer?(l=["Customer",t.customer],e[0]=t.customer,e[1]=l):l=e[1];const r=`${t.activeUsers} of ${t.seats} used`;let a;e[2]!==r?(a=["Seats",r],e[2]=r,e[3]=a):a=e[3];const i=t.reason==="expired"?"Expired":"Expires";let o;e[4]!==t.expiresAt?(o=K(t.expiresAt),e[4]=t.expiresAt,e[5]=o):o=e[5];let c;e[6]!==i||e[7]!==o?(c=[i,o],e[6]=i,e[7]=o,e[8]=c):c=e[8];let d;if(e[9]!==t.graceEndsAt||e[10]!==l||e[11]!==a||e[12]!==c){if(d=[l,a,c],t.graceEndsAt!==null){let f;e[14]!==t.graceEndsAt?(f=K(t.graceEndsAt),e[14]=t.graceEndsAt,e[15]=f):f=e[15];let m;e[16]!==f?(m=["Grace ends",f],e[16]=f,e[17]=m):m=e[17],d.push(m)}e[9]=t.graceEndsAt,e[10]=l,e[11]=a,e[12]=c,e[13]=d}else d=e[13];let u;return e[18]!==d?(u=s.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5",children:d.map(nl)}),e[18]=d,e[19]=u):u=e[19],u}function nl(n){const[e,t]=n;return s.jsxs("div",{className:"contents",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsx("dd",{className:"text-foreground tabular-nums",children:t})]},e)}function ll(n){const e=A.c(23),{onDone:t,onInstalled:l}=n,r=_.useId(),[a,i]=_.useState(""),{busy:o,error:c,setError:d,run:u}=ge();let f;e[0]!==a||e[1]!==t||e[2]!==l||e[3]!==u||e[4]!==d?(f=async function(){if(!a.trim()){d("Paste a license key.");return}await u(()=>Xn(a.trim()))&&(he.success("License installed"),l(),t())},e[0]=a,e[1]=t,e[2]=l,e[3]=u,e[4]=d,e[5]=f):f=e[5];const m=f;let h;e[6]!==m?(h=()=>void m(),e[6]=m,e[7]=h):h=e[7];const x=`${r}-key`;let p;e[8]!==x?(p=s.jsx(J,{htmlFor:x,children:"License key"}),e[8]=x,e[9]=p):p=e[9];const g=`${r}-key`;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=y=>i(y.target.value),e[10]=j):j=e[10];let b;e[11]!==a||e[12]!==g?(b=s.jsx(Fs,{id:g,value:a,onChange:j,placeholder:"Paste the key from your Cogpit Team license",rows:3,spellCheck:!1,autoFocus:!0,className:"font-mono text-xs break-all"}),e[11]=a,e[12]=g,e[13]=b):b=e[13];let S;e[14]!==p||e[15]!==b?(S=s.jsxs(X,{children:[p,b]}),e[14]=p,e[15]=b,e[16]=S):S=e[16];let w;return e[17]!==o||e[18]!==c||e[19]!==t||e[20]!==h||e[21]!==S?(w=s.jsx(_t,{error:c,busy:o,saveLabel:"Install",onCancel:t,onSave:h,className:"px-0 pb-0",children:S}),e[17]=o,e[18]=c,e[19]=t,e[20]=h,e[21]=S,e[22]=w):w=e[22],w}function al(n){const e=A.c(24),{license:t,onInstalled:l}=n,[r,a]=_.useState(!1),i=t.data,o=i?tl[i.state]:null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(_e,{children:"License"}),e[0]=c):c=e[0];let d;e[1]!==o?(d=o&&s.jsx(Ct,{children:s.jsx(ne,{variant:o.variant,className:o.className,children:o.label})}),e[1]=o,e[2]=d):d=e[2];let u;e[3]!==d?(u=s.jsxs($e,{children:[c,d]}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==t.error||e[6]!==t.refresh?(f=t.error&&s.jsx(fe,{title:"License status could not load",message:t.error,onRetry:t.refresh}),e[5]=t.error,e[6]=t.refresh,e[7]=f):f=e[7];let m;e[8]!==i?(m=i&&s.jsx(sl,{license:i}),e[8]=i,e[9]=m):m=e[9];let h;e[10]!==t.loading||e[11]!==i?(h=!i&&t.loading&&s.jsx(ot,{label:"Loading license…"}),e[10]=t.loading,e[11]=i,e[12]=h):h=e[12];let x;e[13]!==r||e[14]!==l?(x=r?s.jsx(ll,{onDone:()=>a(!1),onInstalled:l}):s.jsxs(F,{variant:"outline",size:"sm",className:"self-start",onClick:()=>a(!0),children:[s.jsx(at,{"data-icon":"inline-start"}),"Install license key"]}),e[13]=r,e[14]=l,e[15]=x):x=e[15];let p;e[16]!==f||e[17]!==m||e[18]!==h||e[19]!==x?(p=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[f,m,h,x]}),e[16]=f,e[17]=m,e[18]=h,e[19]=x,e[20]=p):p=e[20];let g;return e[21]!==u||e[22]!==p?(g=s.jsxs(ke,{children:[u,p]}),e[21]=u,e[22]=p,e[23]=g):g=e[23],g}function jt(n){return n===1?"1 session":`${n} sessions`}function rl(n){const e=A.c(54),{project:t,path:l,name:r,assignees:a,onAssigned:i}=n,o=_.useId(),{busy:c,error:d,run:u}=ge();let f;e[0]!==t.dirName?(f=Vs(Ys(t.dirName)),e[0]=t.dirName,e[1]=f):f=e[1];const m=f;let h;e[2]!==r||e[3]!==i||e[4]!==t.dirName||e[5]!==u?(h=async function(I){const G=await u(()=>Jn({userId:I.id,dirName:t.dirName}));G&&(he.success(`Assigned ${jt(G.assigned)} in ${r} to ${I.displayName}`),qe(),i())},e[2]=r,e[3]=i,e[4]=t.dirName,e[5]=u,e[6]=h):h=e[6];const x=h;let p;e[7]!==r||e[8]!==o?(p=s.jsx("span",{id:o,className:"truncate font-medium text-foreground",children:r}),e[7]=r,e[8]=o,e[9]=p):p=e[9];let g;e[10]!==m?(g=m&&s.jsx(ne,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:m}),e[10]=m,e[11]=g):g=e[11];let j;e[12]!==p||e[13]!==g?(j=s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[12]=p,e[13]=g,e[14]=j):j=e[14];let b;e[15]!==l?(b=s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:l}),e[15]=l,e[16]=b):b=e[16];let S;e[17]!==t.sessionCount?(S=jt(t.sessionCount),e[17]=t.sessionCount,e[18]=S):S=e[18];let w;e[19]!==t.lastActivityAt?(w=Ws(new Date(t.lastActivityAt).toISOString()),e[19]=t.lastActivityAt,e[20]=w):w=e[20];let y;e[21]!==S||e[22]!==w?(y=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," · last active ",w]}),e[21]=S,e[22]=w,e[23]=y):y=e[23];let N;e[24]!==j||e[25]!==b||e[26]!==y?(N=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[j,b,y]}),e[24]=j,e[25]=b,e[26]=y,e[27]=N):N=e[27];const v=c||a.length===0;let C;e[28]!==o||e[29]!==v?(C=s.jsx(F,{variant:"outline",size:"sm",disabled:v,"aria-describedby":o}),e[28]=o,e[29]=v,e[30]=C):C=e[30];let $;e[31]!==c?($=c&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[31]=c,e[32]=$):$=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(wn,{"data-icon":"inline-end"}),e[33]=k):k=e[33];let T;e[34]!==C||e[35]!==$?(T=s.jsxs(Je,{render:C,children:[$,"Assign to…",k]}),e[34]=C,e[35]=$,e[36]=T):T=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(ae,{children:"Owner for every unassigned session"}),e[37]=U):U=e[37];let O;if(e[38]!==x||e[39]!==a){let R;e[41]!==x?(R=I=>s.jsxs(Q,{onClick:()=>void x(I),children:[s.jsx("span",{className:"truncate",children:I.displayName}),s.jsxs("span",{className:"ml-auto truncate text-xs text-muted-foreground",children:["@",I.username]})]},I.id),e[41]=x,e[42]=R):R=e[42],O=a.map(R),e[38]=x,e[39]=a,e[40]=O}else O=e[40];let D;e[43]!==O?(D=s.jsx(Xe,{align:"end",className:"w-56",children:s.jsxs(Z,{children:[U,O]})}),e[43]=O,e[44]=D):D=e[44];let E;e[45]!==T||e[46]!==D?(E=s.jsxs(Qe,{children:[T,D]}),e[45]=T,e[46]=D,e[47]=E):E=e[47];let P;e[48]!==d?(P=d&&s.jsx(Ze,{className:"w-full",children:d}),e[48]=d,e[49]=P):P=e[49];let L;return e[50]!==N||e[51]!==E||e[52]!==P?(L=s.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 py-2.5",children:[N,E,P]}),e[50]=N,e[51]=E,e[52]=P,e[53]=L):L=e[53],L}function il(n){var j;const e=A.c(24),{users:t}=n,l=ce("/api/team/unassigned");let r;e[0]!==t?(r=t.filter(cl),e[0]=t,e[1]=r):r=e[1];const a=r,i=(j=l.data)==null?void 0:j.projects,o=Gs(!0);let c;e[2]!==o?(c=new Map(o.map(ol)),e[2]=o,e[3]=c):c=e[3];const d=c,{names:u}=zs();let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsxs($e,{children:[s.jsx(_e,{children:"Unassigned sessions"}),s.jsx(et,{children:"Only admins can see sessions without an owner. Assign each project to the person who works in it."})]}),e[4]=f):f=e[4];let m;e[5]!==l.error||e[6]!==l.refresh?(m=l.error&&s.jsx(fe,{title:"Unassigned sessions could not load",message:l.error,onRetry:l.refresh}),e[5]=l.error,e[6]=l.refresh,e[7]=m):m=e[7];let h;e[8]!==i?(h=i&&i.length===0&&s.jsx(Ee,{className:"py-6",children:s.jsxs(De,{children:[s.jsx(Ke,{variant:"icon",children:s.jsx(bn,{})}),s.jsx(Te,{children:"Every session has an owner."}),s.jsx(Pe,{children:"New sessions belong to whoever starts them."})]})}),e[8]=i,e[9]=h):h=e[9];let x;e[10]!==a||e[11]!==d||e[12]!==u||e[13]!==i||e[14]!==l.refresh?(x=i&&i.length>0&&s.jsx("ul",{className:"divide-y",children:i.map(b=>{const S=d.get(b.dirName)??Bs(b.dirName);return s.jsx(rl,{project:b,path:S,name:u[b.dirName]??Hs(S),assignees:a,onAssigned:l.refresh},b.dirName)})}),e[10]=a,e[11]=d,e[12]=u,e[13]=i,e[14]=l.refresh,e[15]=x):x=e[15];let p;e[16]!==i||e[17]!==l.loading?(p=!i&&l.loading&&s.jsx(ot,{label:"Loading unassigned sessions…"}),e[16]=i,e[17]=l.loading,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==h||e[21]!==x||e[22]!==p?(g=s.jsxs(ke,{children:[f,s.jsxs(Ae,{className:"flex flex-col gap-3",children:[m,h,x,p]})]}),e[19]=m,e[20]=h,e[21]=x,e[22]=p,e[23]=g):g=e[23],g}function ol(n){return[n.dirName,n.path]}function cl(n){return!n.disabled}function ns({username:n,displayName:e,password:t}){return{username:n.trim(),password:t,...e.trim()?{displayName:e.trim()}:{}}}function ls(n){const e=A.c(14),{id:t,value:l,onChange:r,autoComplete:a,autoFocus:i}=n;let o;e[0]!==t?(o=s.jsx(J,{htmlFor:t,children:"Username"}),e[0]=t,e[1]=o):o=e[1];let c;e[2]!==r?(c=m=>r(m.target.value),e[2]=r,e[3]=c):c=e[3];let d;e[4]!==a||e[5]!==i||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Username",autoComplete:a,autoFocus:i,spellCheck:!1}),e[4]=a,e[5]=i,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(tt,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."}),e[10]=u):u=e[10];let f;return e[11]!==o||e[12]!==d?(f=s.jsxs(X,{children:[o,d,u]}),e[11]=o,e[12]=d,e[13]=f):f=e[13],f}function as(n){const e=A.c(13),{id:t,value:l,onChange:r,autoComplete:a}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"}),e[0]=i):i=e[0];let o;e[1]!==t?(o=s.jsxs(J,{htmlFor:t,children:["Display name ",i]}),e[1]=t,e[2]=o):o=e[2];let c;e[3]!==r?(c=f=>r(f.target.value),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==a||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Display name (optional)",autoComplete:a}),e[5]=a,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;return e[10]!==o||e[11]!==d?(u=s.jsxs(X,{children:[o,d]}),e[10]=o,e[11]=d,e[12]=u):u=e[12],u}function ct(n){const e=A.c(28),{id:t,label:l,placeholder:r,value:a,onChange:i,visible:o,onVisibleChange:c,autoFocus:d}=n;let u;e[0]!==t||e[1]!==l?(u=s.jsx(J,{htmlFor:t,children:l}),e[0]=t,e[1]=l,e[2]=u):u=e[2];const f=o?"text":"password";let m;e[3]!==i?(m=y=>i(y.target.value),e[3]=i,e[4]=m):m=e[4];let h;e[5]!==d||e[6]!==t||e[7]!==r||e[8]!==f||e[9]!==m||e[10]!==a?(h=s.jsx(Ks,{id:t,type:f,value:a,onChange:m,placeholder:r,autoComplete:"new-password",autoFocus:d}),e[5]=d,e[6]=t,e[7]=r,e[8]=f,e[9]=m,e[10]=a,e[11]=h):h=e[11];let x;e[12]!==c||e[13]!==o?(x=()=>c(!o),e[12]=c,e[13]=o,e[14]=x):x=e[14];const p=o?"Hide password":"Show password";let g;e[15]!==o?(g=o?s.jsx(yn,{}):s.jsx(Sn,{}),e[15]=o,e[16]=g):g=e[16];let j;e[17]!==x||e[18]!==p||e[19]!==g?(j=s.jsx(qs,{align:"inline-end",children:s.jsx(Js,{size:"icon-xs",onClick:x,"aria-label":p,children:g})}),e[17]=x,e[18]=p,e[19]=g,e[20]=j):j=e[20];let b;e[21]!==h||e[22]!==j?(b=s.jsxs(Xs,{children:[h,j]}),e[21]=h,e[22]=j,e[23]=b):b=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(tt,{children:["Use at least ",ue," characters."]}),e[24]=S):S=e[24];let w;return e[25]!==u||e[26]!==b?(w=s.jsxs(X,{children:[u,b,S]}),e[25]=u,e[26]=b,e[27]=w):w=e[27],w}const dl=["member","admin"],ul=["member"];function fl(n){const e=A.c(10),{open:t,onOpenChange:l,onCreated:r,noNewAdmins:a}=n;let i;e[0]!==r||e[1]!==l?(i=()=>{l(!1),r()},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]!==a||e[4]!==i?(o=s.jsx($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:s.jsx(ml,{noNewAdmins:a,onCreated:i})}),e[3]=a,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==l||e[7]!==t||e[8]!==o?(c=s.jsx(At,{open:t,onOpenChange:l,children:o}),e[6]=l,e[7]=t,e[8]=o,e[9]=c):c=e[9],c}function ml(n){const e=A.c(59),{onCreated:t,noNewAdmins:l}=n,r=_.useId(),a=l?ul:dl,[i,o]=_.useState(""),[c,d]=_.useState(""),[u,f]=_.useState("member"),[m,h]=_.useState(""),[x,p]=_.useState(!1),{busy:g,error:j,run:b}=ge();let S;e[0]!==m||e[1]!==i?(S=!i.trim()||m.length<ue,e[0]=m,e[1]=i,e[2]=S):S=e[2];const w=S;let y;if(e[3]!==c||e[4]!==w||e[5]!==t||e[6]!==m||e[7]!==u||e[8]!==b||e[9]!==i){const Le=async function(Ie){if(Ie.preventDefault(),w)return;const xt=await b(()=>qn({...ns({username:i,displayName:c,password:m}),role:u}));xt&&(he.success(`Added ${xt.user.displayName}`),t())};y=oe=>void Le(oe),e[3]=c,e[4]=w,e[5]=t,e[6]=m,e[7]=u,e[8]=b,e[9]=i,e[10]=y}else y=e[10];let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsxs(kt,{children:[s.jsx(Et,{children:"Add user"}),s.jsx(Dt,{children:"They sign in with this username and password. Their prompts are recorded and visible to admins."})]}),e[11]=N):N=e[11];const v=`${r}-username`;let C;e[12]!==v||e[13]!==i?(C=s.jsx(ls,{id:v,value:i,onChange:o,autoComplete:"off",autoFocus:!0}),e[12]=v,e[13]=i,e[14]=C):C=e[14];const $=`${r}-display-name`;let k;e[15]!==c||e[16]!==$?(k=s.jsx(as,{id:$,value:c,onChange:d,autoComplete:"off"}),e[15]=c,e[16]=$,e[17]=k):k=e[17];const T=`${r}-role`;let U;e[18]!==T?(U=s.jsx(J,{id:T,children:"Role"}),e[18]=T,e[19]=U):U=e[19];let O;e[20]!==u?(O=[u],e[20]=u,e[21]=O):O=e[21];let D;e[22]!==a?(D=Le=>{const oe=a.find(Ie=>Ie===Le.at(-1));oe&&f(oe)},e[22]=a,e[23]=D):D=e[23];const E=`${r}-role`;let P;e[24]!==a?(P=a.map(hl),e[24]=a,e[25]=P):P=e[25];let L;e[26]!==O||e[27]!==D||e[28]!==E||e[29]!==P?(L=s.jsx(st,{value:O,onValueChange:D,variant:"outline",size:"sm",spacing:0,"aria-labelledby":E,children:P}),e[26]=O,e[27]=D,e[28]=E,e[29]=P,e[30]=L):L=e[30];let R;e[31]!==l?(R=l&&s.jsx(tt,{children:Qt}),e[31]=l,e[32]=R):R=e[32];let I;e[33]!==L||e[34]!==R||e[35]!==U?(I=s.jsxs(X,{children:[U,L,R]}),e[33]=L,e[34]=R,e[35]=U,e[36]=I):I=e[36];const G=`${r}-password`;let H;e[37]!==m||e[38]!==x||e[39]!==G?(H=s.jsx(ct,{id:G,label:"Password",placeholder:"Password",value:m,onChange:h,visible:x,onVisibleChange:p}),e[37]=m,e[38]=x,e[39]=G,e[40]=H):H=e[40];let z;e[41]!==I||e[42]!==H||e[43]!==C||e[44]!==k?(z=s.jsxs(Tt,{children:[C,k,I,H]}),e[41]=I,e[42]=H,e[43]=C,e[44]=k,e[45]=z):z=e[45];let B;e[46]!==j?(B=j&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{}),s.jsx(te,{children:j})]}),e[46]=j,e[47]=B):B=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Qs,{render:s.jsx(F,{type:"button",variant:"outline"}),children:"Cancel"}),e[48]=M):M=e[48];const ie=g||w;let Y;e[49]!==g?(Y=g&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[49]=g,e[50]=Y):Y=e[50];let W;e[51]!==ie||e[52]!==Y?(W=s.jsxs(Zs,{children:[M,s.jsxs(F,{type:"submit",disabled:ie,children:[Y,"Add user"]})]}),e[51]=ie,e[52]=Y,e[53]=W):W=e[53];let je;return e[54]!==z||e[55]!==y||e[56]!==B||e[57]!==W?(je=s.jsxs("form",{onSubmit:y,className:"flex flex-col gap-4",children:[N,z,B,W]}),e[54]=z,e[55]=y,e[56]=B,e[57]=W,e[58]=je):je=e[58],je}function hl(n){return s.jsx(Oe,{value:n,children:it[n]},n)}const dt={"7d":{label:"7 days",days:7},"30d":{label:"30 days",days:30}},rs="30d",xl={too_long:`Choose a range of ${Me} days or less.`,too_old:`Usage is kept for the last ${Me} days only.`};function pl(n){return n==="custom"||typeof n=="string"&&Object.hasOwn(dt,n)}function is(n,e){return Zt(dt[n].days,e)}function gl(n,e,t){const l=Gn(n),r=zn(e);if(l===null||r===null)return{ok:!1,error:"Enter a start and an end date."};if(l>t)return{ok:!1,error:"The range cannot start in the future."};const a={from:l,to:Math.min(r,t)};if(a.from>a.to)return{ok:!1,error:"The start date must be on or before the end date."};const i=In(a,t);return i?{ok:!1,error:xl[i]}:{ok:!0,range:a}}function jl({from:n,to:e}){return`${K(n)} – ${K(e)}`}function bl(n){const e=A.c(29),{range:t,onRangeChange:l}=n,r=_.useId(),[a,i]=_.useState(rs);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={from:"",to:""},e[0]=o):o=e[0];const[c,d]=_.useState(o),[u,f]=_.useState(null),[m]=_.useState(yl);let h;e[1]!==l||e[2]!==t?(h=function(k){i(k),f(null),k==="custom"?d({from:Ge(t.from),to:Ge(t.to)}):l(is(k,Date.now()))},e[1]=l,e[2]=t,e[3]=h):h=e[3];const x=h;let p;e[4]!==l?(p=function(k){d(k);const T=gl(k.from,k.to,Date.now());f(T.ok?null:T.error),T.ok&&l(T.range)},e[4]=l,e[5]=p):p=e[5];const g=p;let j;e[6]!==a?(j=[a],e[6]=a,e[7]=j):j=e[7];let b;e[8]!==a||e[9]!==x?(b=$=>{const k=$.at(-1);pl(k)&&k!==a&&x(k)},e[8]=a,e[9]=x,e[10]=b):b=e[10];let S,w;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=Object.entries(dt).map(wl),w=s.jsx(Oe,{value:"custom",children:"Custom"}),e[11]=S,e[12]=w):(S=e[11],w=e[12]);let y;e[13]!==j||e[14]!==b?(y=s.jsxs(st,{value:j,onValueChange:b,variant:"outline",size:"sm",spacing:0,"aria-label":"Usage range",children:[S,w]}),e[13]=j,e[14]=b,e[15]=y):y=e[15];let N;e[16]!==a||e[17]!==c||e[18]!==g||e[19]!==u||e[20]!==r||e[21]!==m?(N=a==="custom"&&s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[s.jsxs(X,{className:"w-40",children:[s.jsx(J,{htmlFor:`${r}-from`,children:"From"}),s.jsx(de,{id:`${r}-from`,type:"date",value:c.from,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,from:$.target.value})})]}),s.jsxs(X,{className:"w-40",children:[s.jsx(J,{htmlFor:`${r}-to`,children:"To"}),s.jsx(de,{id:`${r}-to`,type:"date",value:c.to,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,to:$.target.value})})]})]}),e[16]=a,e[17]=c,e[18]=g,e[19]=u,e[20]=r,e[21]=m,e[22]=N):N=e[22];let v;e[23]!==u?(v=u&&s.jsx(Ze,{children:u}),e[23]=u,e[24]=v):v=e[24];let C;return e[25]!==v||e[26]!==y||e[27]!==N?(C=s.jsxs("div",{className:"flex flex-col gap-2",children:[y,N,v]}),e[25]=v,e[26]=y,e[27]=N,e[28]=C):C=e[28],C}function wl(n){const[e,t]=n;return s.jsx(Oe,{value:e,children:t.label},e)}function yl(){return Ge(Date.now())}const be="text-right tabular-nums",we="—";function Sl(n){const e=A.c(3),{usd:t}=n;if(t===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx("span",{title:Ce.title,children:Ce.text}),e[0]=r):r=e[0],r}let l;return e[1]!==t?(l=t===0?"$0":Ot(t),e[1]=t,e[2]=l):l=e[2],l}function os(n){const e=A.c(17),{figures:t}=n,l=(t==null?void 0:t.sessions)??we;let r;e[0]!==l?(r=s.jsx(V,{className:be,children:l}),e[0]=l,e[1]=r):r=e[1];const a=(t==null?void 0:t.prompts)??we;let i;e[2]!==a?(i=s.jsx(V,{className:be,children:a}),e[2]=a,e[3]=i):i=e[3];let o;e[4]!==t?(o=t?Pt(es(t.tokens)):we,e[4]=t,e[5]=o):o=e[5];let c;e[6]!==o?(c=s.jsx(V,{className:be,children:o}),e[6]=o,e[7]=c):c=e[7];let d;e[8]!==t?(d=t?s.jsx(Sl,{usd:t.costUsd}):we,e[8]=t,e[9]=d):d=e[9];let u;e[10]!==d?(u=s.jsx(V,{className:be,children:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==r||e[13]!==i||e[14]!==c||e[15]!==u?(f=s.jsxs(s.Fragment,{children:[r,i,c,u]}),e[12]=r,e[13]=i,e[14]=c,e[15]=u,e[16]=f):f=e[16],f}const Nl=8,vl={tokens:{input:0,output:0,cacheRead:0,cacheWrite:0},costUsd:0,sessions:0,prompts:0};function Cl(n,e){return e?Ue()?"This hub signs in to the device as you, so the change signs the hub out there too. Afterwards, update the password this hub saved for the device in Devices.":"You are signed out everywhere, this browser included, and sign in again with the new password.":`${n.displayName} is signed out everywhere and signs in with the new password.`}function _l(n){const e=A.c(29),{user:t,isSelf:l,onDone:r}=n,a=_.useId(),[i,o]=_.useState(""),[c,d]=_.useState(!1),{busy:u,error:f,setError:m,run:h}=ge();let x;e[0]!==l||e[1]!==r||e[2]!==i||e[3]!==h||e[4]!==m||e[5]!==t?(x=async function(){if(i.length<ue){m(`Use at least ${ue} characters.`);return}await h(()=>ss(t.id,{password:i}))&&(he.success(l?"Password changed":`Password reset for ${t.displayName}`),r())},e[0]=l,e[1]=r,e[2]=i,e[3]=h,e[4]=m,e[5]=t,e[6]=x):x=e[6];const p=x,g=l?"Change password":"Reset password";let j;e[7]!==p?(j=()=>void p(),e[7]=p,e[8]=j):j=e[8];const b=`${a}-password`,S=l?"Your new password":`New password for ${t.displayName}`;let w;e[9]!==i||e[10]!==b||e[11]!==S||e[12]!==c?(w=s.jsx(ct,{id:b,label:S,placeholder:"New password",value:i,onChange:o,visible:c,onVisibleChange:d,autoFocus:!0}),e[9]=i,e[10]=b,e[11]=S,e[12]=c,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==t?(y=Cl(t,l),e[14]=l,e[15]=t,e[16]=y):y=e[16];let N;e[17]!==y?(N=s.jsx("p",{className:"text-xs text-muted-foreground",children:y}),e[17]=y,e[18]=N):N=e[18];let v;e[19]!==w||e[20]!==N?(v=s.jsxs("div",{className:"flex max-w-md flex-col gap-2",children:[w,N]}),e[19]=w,e[20]=N,e[21]=v):v=e[21];let C;return e[22]!==u||e[23]!==f||e[24]!==r||e[25]!==g||e[26]!==j||e[27]!==v?(C=s.jsx(_t,{error:f,busy:u,saveLabel:g,onCancel:r,onSave:j,className:"border-t-0 bg-muted/40",children:v}),e[22]=u,e[23]=f,e[24]=r,e[25]=g,e[26]=j,e[27]=v,e[28]=C):C=e[28],C}function $l(n){const e=A.c(33),{user:t,isSelf:l,noNewAdmins:r,onSelect:a}=n,i=r&&t.role==="member"&&!t.disabled,o=r&&t.role==="admin"&&t.disabled===!0;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ae,{className:"font-normal",children:Qt}),e[0]=c):c=e[0];const d=c,u=`Actions for ${t.displayName}`;let f;e[1]!==u?(f=s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":u}),e[1]=u,e[2]=f):f=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Cn,{}),e[3]=m):m=e[3];let h;e[4]!==f?(h=s.jsx(Je,{render:f,children:m}),e[4]=f,e[5]=h):h=e[5];const x=l||i||o?"w-56":"w-44";let p;e[6]!==a?(p=()=>a("password"),e[6]=a,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(at,{}),e[8]=g):g=e[8];const j=l?"Change password":"Reset password";let b;e[9]!==p||e[10]!==j?(b=s.jsxs(Q,{onClick:p,children:[g,j]}),e[9]=p,e[10]=j,e[11]=b):b=e[11];let S;e[12]!==l||e[13]!==a||e[14]!==i||e[15]!==t.role?(S=l?null:i?d:s.jsxs(Q,{onClick:()=>a("role"),children:[s.jsx(Vt,{}),t.role==="admin"?"Make member":"Make admin"]}),e[12]=l,e[13]=a,e[14]=i,e[15]=t.role,e[16]=S):S=e[16];let w;e[17]!==b||e[18]!==S?(w=s.jsxs(Z,{children:[b,S]}),e[17]=b,e[18]=S,e[19]=w):w=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Se,{}),e[20]=y):y=e[20];let N;e[21]!==o||e[22]!==l||e[23]!==a||e[24]!==t.disabled?(N=s.jsx(Z,{children:l?s.jsx(ae,{className:"font-normal",children:"Ask another admin to change your role or disable your account."}):o?d:t.disabled?s.jsxs(Q,{onClick:()=>a("status"),children:[s.jsx(Nn,{}),"Enable"]}):s.jsxs(Q,{variant:"destructive",onClick:()=>a("status"),children:[s.jsx(vn,{}),"Disable"]})}),e[21]=o,e[22]=l,e[23]=a,e[24]=t.disabled,e[25]=N):N=e[25];let v;e[26]!==w||e[27]!==N||e[28]!==x?(v=s.jsxs(Xe,{align:"end",className:x,children:[w,y,N]}),e[26]=w,e[27]=N,e[28]=x,e[29]=v):v=e[29];let C;return e[30]!==v||e[31]!==h?(C=s.jsxs(Qe,{children:[h,v]}),e[30]=v,e[31]=h,e[32]=C):C=e[32],C}function Al(n){const e=A.c(61),{user:t,usage:l,isSelf:r,noNewAdmins:a,onChanged:i}=n,[o,c]=_.useState(null),d=t.displayName;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=function(Y){Y||c(null)},e[0]=u):u=e[0];const f=u;let m;e[1]!==i||e[2]!==t.id?(m=async function(Y){const W=await ss(t.id,Y);return W.ok?(c(null),i(),null):W.error},e[1]=i,e[2]=t.id,e[3]=m):m=e[3];const h=m;let x;e[4]!==d?(x=s.jsx("span",{className:"truncate",children:d}),e[4]=d,e[5]=x):x=e[5];let p;e[6]!==r?(p=r&&s.jsx(ne,{variant:"outline",children:"You"}),e[6]=r,e[7]=p):p=e[7];let g;e[8]!==x||e[9]!==p?(g=s.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[x,p]}),e[8]=x,e[9]=p,e[10]=g):g=e[10];let j;e[11]!==t.username?(j=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[11]=t.username,e[12]=j):j=e[12];let b;e[13]!==g||e[14]!==j?(b=s.jsx(V,{children:s.jsxs("div",{className:"flex min-w-0 flex-col",children:[g,j]})}),e[13]=g,e[14]=j,e[15]=b):b=e[15];const S=t.role==="admin"?"secondary":"outline",w=it[t.role];let y;e[16]!==S||e[17]!==w?(y=s.jsx(V,{children:s.jsx(ne,{variant:S,children:w})}),e[16]=S,e[17]=w,e[18]=y):y=e[18];let N;e[19]!==t.disabled?(N=s.jsx(V,{children:t.disabled?s.jsx(ne,{variant:"destructive",children:"Disabled"}):s.jsx("span",{className:"text-muted-foreground",children:"Active"})}),e[19]=t.disabled,e[20]=N):N=e[20];let v;e[21]!==l?(v=s.jsx(os,{figures:l}),e[21]=l,e[22]=v):v=e[22];let C;e[23]!==r||e[24]!==a||e[25]!==t?(C=s.jsx(V,{className:"text-right",children:s.jsx($l,{user:t,isSelf:r,noNewAdmins:a,onSelect:c})}),e[23]=r,e[24]=a,e[25]=t,e[26]=C):C=e[26];let $;e[27]!==y||e[28]!==N||e[29]!==v||e[30]!==C||e[31]!==b?($=s.jsxs(ve,{children:[b,y,N,v,C]}),e[27]=y,e[28]=N,e[29]=v,e[30]=C,e[31]=b,e[32]=$):$=e[32];let k;e[33]!==o||e[34]!==r||e[35]!==t?(k=o==="password"&&s.jsx(ve,{className:"hover:bg-transparent",children:s.jsx(V,{colSpan:Nl,className:"p-0 whitespace-normal",children:s.jsx(_l,{user:t,isSelf:r,onDone:()=>c(null)})})}),e[33]=o,e[34]=r,e[35]=t,e[36]=k):k=e[36];const T=o==="role",U=t.role==="admin"?`Make ${d} a member?`:`Make ${d} an admin?`,O=t.role==="admin"?`${d} loses access to People, the license and other members' sessions, and is signed out.`:`${d} can manage people, the license and every session, and is signed out to pick up the new role.`,D=t.role==="admin"?"Make member":"Make admin";let E;e[37]!==h||e[38]!==t.role?(E=()=>h({role:t.role==="admin"?"member":"admin"}),e[37]=h,e[38]=t.role,e[39]=E):E=e[39];let P;e[40]!==T||e[41]!==U||e[42]!==O||e[43]!==D||e[44]!==E?(P=s.jsx(pt,{open:T,onOpenChange:f,title:U,description:O,confirmLabel:D,onConfirm:E}),e[40]=T,e[41]=U,e[42]=O,e[43]=D,e[44]=E,e[45]=P):P=e[45];const L=o==="status",R=t.disabled?`Enable ${d}?`:`Disable ${d}?`,I=t.disabled?`${d} can sign in again and takes a license seat.`:`${d} is signed out now and cannot sign in until enabled again. Their sessions stay on this server.`,G=t.disabled?"Enable user":"Disable user",H=!t.disabled;let z;e[46]!==h||e[47]!==t.disabled?(z=()=>h({disabled:!t.disabled}),e[46]=h,e[47]=t.disabled,e[48]=z):z=e[48];let B;e[49]!==L||e[50]!==R||e[51]!==I||e[52]!==G||e[53]!==H||e[54]!==z?(B=s.jsx(pt,{open:L,onOpenChange:f,title:R,description:I,confirmLabel:G,destructive:H,onConfirm:z}),e[49]=L,e[50]=R,e[51]=I,e[52]=G,e[53]=H,e[54]=z,e[55]=B):B=e[55];let M;return e[56]!==$||e[57]!==k||e[58]!==P||e[59]!==B?(M=s.jsxs(s.Fragment,{children:[$,k,P,B]}),e[56]=$,e[57]=k,e[58]=P,e[59]=B,e[60]=M):M=e[60],M}function kl(n){const e=A.c(33),{users:t,usage:l,usageLoading:r,currentUserId:a,noNewAdmins:i,onUserChanged:o}=n;let c;e[0]!==(l==null?void 0:l.rows)?(c=new Map(l==null?void 0:l.rows.map(El)),e[0]=l==null?void 0:l.rows,e[1]=c):c=e[1];const d=c,u=r&&"opacity-60";let f;e[2]!==u?(f=se("transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m,h,x,p,g,j,b;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(q,{children:"User"}),x=s.jsx(q,{children:"Role"}),p=s.jsx(q,{children:"Status"}),g=s.jsx(q,{className:"text-right",children:"Sessions"}),j=s.jsx(q,{className:"text-right",children:"Prompts"}),b=s.jsx(q,{className:"text-right",children:"Tokens"}),m=s.jsx(q,{className:"text-right",children:"Est. cost"}),e[4]=m,e[5]=h,e[6]=x,e[7]=p,e[8]=g,e[9]=j,e[10]=b):(m=e[4],h=e[5],x=e[6],p=e[7],g=e[8],j=e[9],b=e[10]);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(en,{children:s.jsxs(ve,{className:"hover:bg-transparent",children:[h,x,p,g,j,b,m,s.jsx(q,{children:s.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e[11]=S):S=e[11];let w;if(e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==d||e[17]!==t){let C;e[19]!==a||e[20]!==i||e[21]!==o||e[22]!==l||e[23]!==d?(C=$=>s.jsx(Al,{user:$,usage:l?d.get($.id)??vl:null,isSelf:$.id===a,noNewAdmins:i,onChanged:o},$.id),e[19]=a,e[20]=i,e[21]=o,e[22]=l,e[23]=d,e[24]=C):C=e[24],w=t.map(C),e[12]=a,e[13]=i,e[14]=o,e[15]=l,e[16]=d,e[17]=t,e[18]=w}else w=e[18];let y;e[25]!==l?(y=(l==null?void 0:l.unattributed)&&s.jsxs(ve,{className:"text-muted-foreground",children:[s.jsx(V,{children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"font-medium",children:"Unattributed"}),s.jsx("span",{className:"text-xs",children:"Not tied to a recorded prompt"})]})}),s.jsx(V,{}),s.jsx(V,{}),s.jsx(os,{figures:l.unattributed}),s.jsx(V,{})]}),e[25]=l,e[26]=y):y=e[26];let N;e[27]!==w||e[28]!==y?(N=s.jsxs(tn,{children:[w,y]}),e[27]=w,e[28]=y,e[29]=N):N=e[29];let v;return e[30]!==N||e[31]!==f?(v=s.jsxs(sn,{className:f,children:[S,N]}),e[30]=N,e[31]=f,e[32]=v):v=e[32],v}function El(n){return[n.user.id,n]}function Dl(n){const e=A.c(37),{users:t,onUsersChanged:l,noNewAdmins:r}=n,[a,i]=_.useState(Tl),o=Jt(a),[c,d]=_.useState(!1),{user:u}=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_e,{children:"Users"}),e[0]=f):f=e[0];let m;e[1]!==a?(m=jl(a),e[1]=a,e[2]=m):m=e[2];let h;e[3]!==m?(h=s.jsxs(et,{children:["Usage ",m,", estimated at API prices."]}),e[3]=m,e[4]=h):h=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Ct,{children:s.jsxs(F,{size:"sm",onClick:()=>d(!0),children:[s.jsx(_n,{"data-icon":"inline-start"}),"Add user"]})}),e[5]=x):x=e[5];let p;e[6]!==h?(p=s.jsxs($e,{children:[f,h,x]}),e[6]=h,e[7]=p):p=e[7];let g;e[8]!==a?(g=s.jsx(bl,{range:a,onRangeChange:i}),e[8]=a,e[9]=g):g=e[9];let j;e[10]!==t.error||e[11]!==t.refresh?(j=t.error&&s.jsx(fe,{title:"Users could not load",message:t.error,onRetry:t.refresh}),e[10]=t.error,e[11]=t.refresh,e[12]=j):j=e[12];let b;e[13]!==o.error||e[14]!==o.refresh?(b=o.error&&s.jsx(fe,{title:"Usage could not load",message:o.error,onRetry:o.refresh}),e[13]=o.error,e[14]=o.refresh,e[15]=b):b=e[15];let S;e[16]!==(u==null?void 0:u.id)||e[17]!==r||e[18]!==l||e[19]!==o.data||e[20]!==o.loading||e[21]!==t.data||e[22]!==t.loading?(S=t.data?s.jsx(kl,{users:t.data.users,usage:o.data,usageLoading:o.loading,currentUserId:(u==null?void 0:u.id)??null,noNewAdmins:r,onUserChanged:l}):t.loading&&s.jsx(ot,{label:"Loading users…"}),e[16]=u==null?void 0:u.id,e[17]=r,e[18]=l,e[19]=o.data,e[20]=o.loading,e[21]=t.data,e[22]=t.loading,e[23]=S):S=e[23];let w;e[24]!==g||e[25]!==j||e[26]!==b||e[27]!==S?(w=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[g,j,b,S]}),e[24]=g,e[25]=j,e[26]=b,e[27]=S,e[28]=w):w=e[28];let y;e[29]!==c||e[30]!==r||e[31]!==l?(y=s.jsx(fl,{open:c,onOpenChange:d,onCreated:l,noNewAdmins:r}),e[29]=c,e[30]=r,e[31]=l,e[32]=y):y=e[32];let N;return e[33]!==w||e[34]!==y||e[35]!==p?(N=s.jsxs(ke,{children:[p,w,y]}),e[33]=w,e[34]=y,e[35]=p,e[36]=N):N=e[36],N}function Tl(){return is(rs,Date.now())}function cs(n){var $,k,T,U;const e=A.c(35),{onClose:t,lockout:l}=n,r=ce("/api/team/users"),a=ce("/api/team/license"),i=ce("/api/team/health"),o=l==null?void 0:l.onRestored,c=($=a.data)==null?void 0:$.state;let d,u;e[0]!==c||e[1]!==o?(d=()=>{c&&c!=="locked"&&(o==null||o())},u=[c,o],e[0]=c,e[1]=o,e[2]=d,e[3]=u):(d=e[2],u=e[3]),_.useEffect(d,u);let f;e[4]!==i||e[5]!==a?(f=function(){a.refresh(),i.refresh()},e[4]=i,e[5]=a,e[6]=f):f=e[6];const m=f;let h;e[7]!==m||e[8]!==r?(h=function(){r.refresh(),m()},e[7]=m,e[8]=r,e[9]=h):h=e[9];const x=h;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"People"}),e[10]=p):p=e[10];let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Wt,{}),e[11]=g):g=e[11];let j;e[12]!==t?(j=s.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-3 border-b px-4 py-2",children:[p,s.jsx(F,{variant:"ghost",size:"icon-sm",className:"ml-auto","aria-label":"Close People",onClick:t,children:g})]}),e[12]=t,e[13]=j):j=e[13];let b;e[14]!==i.data||e[15]!==i.refresh?(b=i.data&&s.jsx(el,{health:i.data,onChanged:i.refresh}),e[14]=i.data,e[15]=i.refresh,e[16]=b):b=e[16];const S=c==="locked";let w;e[17]!==x||e[18]!==S||e[19]!==r?(w=s.jsx(Dl,{users:r,onUsersChanged:x,noNewAdmins:S}),e[17]=x,e[18]=S,e[19]=r,e[20]=w):w=e[20];let y;e[21]!==l||e[22]!==((k=r.data)==null?void 0:k.users)?(y=!l&&s.jsx(il,{users:((T=r.data)==null?void 0:T.users)??[]}),e[21]=l,e[22]=(U=r.data)==null?void 0:U.users,e[23]=y):y=e[23];let N;e[24]!==m||e[25]!==a?(N=s.jsx(al,{license:a,onInstalled:m}),e[24]=m,e[25]=a,e[26]=N):N=e[26];let v;e[27]!==w||e[28]!==y||e[29]!==N||e[30]!==b?(v=s.jsx(nn,{className:"min-h-0 flex-1",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 p-4",children:[b,w,y,N]})}),e[27]=w,e[28]=y,e[29]=N,e[30]=b,e[31]=v):v=e[31];let C;return e[32]!==v||e[33]!==j?(C=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,v]}),e[32]=v,e[33]=j,e[34]=C):C=e[34],C}const ds="people";function us(n){return n.edition==="team"&&n.user!==null&&n.can("manageUsers")}const Pl={id:ds,label:"People",icon:rt,keywords:"team users members accounts usage cost license unassigned sessions admin",isAvailable:us,openOnStart:Fn,locksSwipe:!0,Component:cs};function fs(n){const e=A.c(5),{className:t}=n;let l;e[0]!==t?(l=se("flex items-start gap-1.5 text-xs text-muted-foreground",t),e[0]=t,e[1]=l):l=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx($n,{"aria-hidden":"true",className:"mt-px size-3.5 shrink-0"}),e[2]=r):r=e[2];let a;return e[3]!==l?(a=s.jsxs("p",{className:l,children:[r,"Your prompts are recorded and visible to admins."]}),e[3]=l,e[4]=a):a=e[4],a}const ms=30;function Ol(n){const e=A.c(25),{onLogout:t,onOpenMainView:l,mobile:r,className:a}=n,i=r===void 0?!1:r,{user:o,hubUser:c}=xe();let d;e[0]!==o?(d=Ln(o)?o:null,e[0]=o,e[1]=d):d=e[1];const u=d,f=u??c;if(!f)return null;const m=i?"icon-lg":"icon-sm",h=`Account: ${f.displayName}`;let x;e[2]!==a?(x=se("rounded-full",a),e[2]=a,e[3]=x):x=e[3];let p;e[4]!==m||e[5]!==h||e[6]!==x?(p=s.jsx(F,{variant:"ghost",size:m,"aria-label":h,className:x}),e[4]=m,e[5]=h,e[6]=x,e[7]=p):p=e[7];let g;e[8]!==f?(g=Ml(f),e[8]=f,e[9]=g):g=e[9];let j;e[10]!==g?(j=s.jsx("span",{"aria-hidden":"true",className:"flex size-6 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-foreground",children:g}),e[10]=g,e[11]=j):j=e[11];let b;e[12]!==p||e[13]!==j?(b=s.jsx(Je,{render:p,children:j}),e[12]=p,e[13]=j,e[14]=b):b=e[14];let S;e[15]!==f||e[16]!==c||e[17]!==i||e[18]!==t||e[19]!==l||e[20]!==u?(S=s.jsx(Xe,{align:"end",sideOffset:6,className:"w-72",children:u?s.jsx(Ul,{user:u,hubUser:c,onLogout:t,onOpenMainView:l,mobile:i}):s.jsx(hs,{hubUser:f,onLogout:t,mobile:i})}),e[15]=f,e[16]=c,e[17]=i,e[18]=t,e[19]=l,e[20]=u,e[21]=S):S=e[21];let w;return e[22]!==S||e[23]!==b?(w=s.jsxs(Qe,{children:[b,S]}),e[22]=S,e[23]=b,e[24]=w):w=e[24],w}function Ul(n){const e=A.c(31),{user:t,hubUser:l,onLogout:r,onOpenMainView:a,mobile:i}=n,[o]=_.useState(Rl),c=Jt(o).data,d=ln();let u;e[0]!==d?(u=us(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=Ue(),e[2]=m):m=e[2];const h=m;let x;e[3]!==t.displayName?(x=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[3]=t.displayName,e[4]=x):x=e[4];const p=it[t.role];let g;e[5]!==p||e[6]!==t.username?(g=s.jsxs("span",{className:"truncate font-normal",children:["@",t.username," · ",p]}),e[5]=p,e[6]=t.username,e[7]=g):g=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=h&&s.jsx(Ll,{}),e[8]=j):j=e[8];let b;e[9]!==x||e[10]!==g?(b=s.jsx(Z,{children:s.jsxs(ae,{className:"flex flex-col gap-0.5",children:[x,g,j]})}),e[9]=x,e[10]=g,e[11]=b):b=e[11];let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Se,{}),e[12]=S):S=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsxs(ae,{children:["My usage · ",ms," days"]}),e[13]=w):w=e[13];let y;e[14]!==c||e[15]!==t.id?(y=s.jsxs(Z,{children:[w,s.jsx(Il,{usage:c,userId:t.id})]}),e[14]=c,e[15]=t.id,e[16]=y):y=e[16];let N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(fs,{className:"px-1.5 pt-1 pb-1.5"}),e[17]=N):N=e[17];let v;e[18]!==i||e[19]!==a||e[20]!==f?(v=f&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(Z,{children:s.jsxs(Q,{onClick:()=>a(ds),className:se(i&&"min-h-10"),children:[s.jsx(rt,{}),"People"]})})]}),e[18]=i,e[19]=a,e[20]=f,e[21]=v):v=e[21];let C;e[22]!==l||e[23]!==i||e[24]!==r?(C=l&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(hs,{hubUser:l,onLogout:r,mobile:i})]}),e[22]=l,e[23]=i,e[24]=r,e[25]=C):C=e[25];let $;return e[26]!==y||e[27]!==v||e[28]!==C||e[29]!==b?($=s.jsxs(s.Fragment,{children:[b,S,y,N,v,C]}),e[26]=y,e[27]=v,e[28]=C,e[29]=b,e[30]=$):$=e[30],$}function Rl(){return Zt(ms,Date.now())}function hs(n){const e=A.c(12),{hubUser:t,onLogout:l,mobile:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ue(),e[0]=a):a=e[0];const i=a;let o;e[1]!==t?(o=i&&s.jsxs(ae,{className:"font-normal",children:["Signed in to this hub as ",t.displayName]}),e[1]=t,e[2]=o):o=e[2];const c=r&&"min-h-10";let d;e[3]!==c?(d=se(c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Kt,{}),e[5]=u):u=e[5];let f;e[6]!==l||e[7]!==d?(f=s.jsxs(Q,{onClick:l,className:d,children:[u,i?"Log out of this hub":"Log out"]}),e[6]=l,e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==o||e[10]!==f?(m=s.jsxs(Z,{children:[o,f]}),e[9]=o,e[10]=f,e[11]=m):m=e[11],m}function Ll(){const n=A.c(2),{activeDevice:e,activeDeviceId:t}=Ut(),l=(e==null?void 0:e.name)??t;let r;return n[0]!==l?(r=s.jsxs("span",{className:"truncate font-normal",children:["On ",l]}),n[0]=l,n[1]=r):r=n[1],r}function Il(n){const e=A.c(6),{usage:t,userId:l}=n;if(!t){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx("p",{className:"px-1.5 pb-1 text-sm text-muted-foreground",children:"—"}),e[0]=a):a=e[0],a}let r;if(e[1]!==t.rows||e[2]!==l){let a;e[4]!==l?(a=c=>c.user.id===l,e[4]=l,e[5]=a):a=e[5];const i=t.rows.find(a),o=i?i.costUsd:0;r=s.jsxs("p",{className:"flex items-baseline justify-between gap-2 px-1.5 pb-1 text-sm tabular-nums",children:[s.jsxs("span",{children:[Pt(i?es(i.tokens):0)," tokens"]}),o===null?s.jsx("span",{className:"text-muted-foreground",title:Ce.title,children:Ce.text}):s.jsxs("span",{className:"text-muted-foreground",title:"Estimated cost",children:["≈ ",Ot(o)]})]}),e[1]=t.rows,e[2]=l,e[3]=r}else r=e[3];return r}function Ml(n){const e=n.displayName.trim().split(/\s+/).filter(Boolean);return(e.length>0?e.slice(0,2).map(l=>l[0]):[n.username[0]??"?"]).join("").toUpperCase()}const bt="Until then, members cannot sign in and admins can only manage the license and accounts.",Re={expired:{title:"Your Cogpit Team license has expired",deviceTitle:n=>`${n}’s Cogpit Team license has expired`,description:`Install a new key in People. ${bt}`},over_seats:{title:"More accounts are enabled than your license has seats",deviceTitle:n=>`${n} has more accounts enabled than its license has seats`,description:`Disable accounts or install a license with more seats in People. ${bt}`}};function Fl(n){return Object.hasOwn(Re,n)}const Gl=15e3;function zl(n){const e=A.c(3);let t,l;e[0]!==n?(t=()=>{const r=new AbortController,a=setInterval(()=>{me("/api/me",{signal:r.signal}).then(Hl).then(i=>{!i||i.gate||(clearInterval(a),n())}).catch(Bl)},Gl);return()=>{clearInterval(a),r.abort()}},l=[n],e[0]=n,e[1]=t,e[2]=l):(t=e[1],l=e[2]),_.useEffect(t,l)}function Bl(){}function Hl(n){return n.ok?re(n):null}function Vl(n){const e=A.c(6),{gate:t,onRestored:l,onLogout:r}=n;if(!Fl(t)){let i;return e[0]!==n?(i=s.jsx(an,{...n}),e[0]=n,e[1]=i):i=e[1],i}let a;return e[2]!==t||e[3]!==r||e[4]!==l?(a=s.jsx(Yl,{lapse:t,onRestored:l,onLogout:r}),e[2]=t,e[3]=r,e[4]=l,e[5]=a):a=e[5],a}function Yl(n){const e=A.c(17),{lapse:t,onRestored:l,onLogout:r}=n,[a,i]=_.useState(!1);let o;e[0]!==l||e[1]!==a?(o=()=>{a&&Mn(),l()},e[0]=l,e[1]=a,e[2]=o):o=e[2];const c=o;zl(c);let d;e[3]!==a||e[4]!==c?(d={open:a,setOpen:i,onRestored:c},e[3]=a,e[4]=c,e[5]=d):d=e[5];const u=d;if(Ue()){let p;return e[6]!==t||e[7]!==u?(p=s.jsx(Wl,{lapse:t,people:u}),e[6]=t,e[7]=u,e[8]=p):p=e[8],p}const f=Re[t];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Kt,{"data-icon":"inline-start"}),e[9]=m):m=e[9];let h;e[10]!==r?(h=s.jsxs(F,{variant:"outline",size:"sm",onClick:r,children:[m,"Sign out"]}),e[10]=r,e[11]=h):h=e[11];let x;return e[12]!==t||e[13]!==u||e[14]!==f.title||e[15]!==h?(x=s.jsx(xs,{title:f.title,lapse:t,people:u,children:h}),e[12]=t,e[13]=u,e[14]=f.title,e[15]=h,e[16]=x):x=e[16],x}function Wl(n){const e=A.c(9),{lapse:t,people:l}=n,{activeDevice:r,activeDeviceId:a}=Ut(),i=Re[t];let o;e[0]!==(r==null?void 0:r.name)||e[1]!==a||e[2]!==i?(o=i.deviceTitle((r==null?void 0:r.name)??a),e[0]=r==null?void 0:r.name,e[1]=a,e[2]=i,e[3]=o):o=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsxs(F,{variant:"outline",size:"sm",onClick:Kl,children:[s.jsx(An,{"data-icon":"inline-start"}),"Switch to this machine"]}),e[4]=c):c=e[4];let d;return e[5]!==t||e[6]!==l||e[7]!==o?(d=s.jsx(xs,{title:o,lapse:t,people:l,children:c}),e[5]=t,e[6]=l,e[7]=o,e[8]=d):d=e[8],d}function Kl(){return on(cn)}function xs(n){const e=A.c(26),{title:t,lapse:l,people:r,children:a}=n,{open:i,setOpen:o,onRestored:c}=r;if(i){let S;e[0]!==o?(S=()=>o(!1),e[0]=o,e[1]=S):S=e[1];let w;e[2]!==c?(w={onRestored:c},e[2]=c,e[3]=w):w=e[3];let y;return e[4]!==S||e[5]!==w?(y=s.jsx("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:s.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:s.jsx(cs,{onClose:S,lockout:w})})}),e[4]=S,e[5]=w,e[6]=y):y=e[6],y}let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Ke,{variant:"icon",children:s.jsx(at,{className:"text-destructive"})}),e[7]=d):d=e[7];let u;e[8]!==t?(u=s.jsx(Te,{children:t}),e[8]=t,e[9]=u):u=e[9];const f=Re[l];let m;e[10]!==f.description?(m=s.jsx(Pe,{children:f.description}),e[10]=f.description,e[11]=m):m=e[11];let h;e[12]!==u||e[13]!==m?(h=s.jsxs(De,{children:[d,u,m]}),e[12]=u,e[13]=m,e[14]=h):h=e[14];let x;e[15]!==o?(x=()=>o(!0),e[15]=o,e[16]=x):x=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(rt,{"data-icon":"inline-start"}),e[17]=p):p=e[17];let g;e[18]!==x?(g=s.jsxs(F,{size:"sm",onClick:x,children:[p,"Open People"]}),e[18]=x,e[19]=g):g=e[19];let j;e[20]!==a||e[21]!==g?(j=s.jsxs(rn,{className:"flex-row justify-center",children:[g,a]}),e[20]=a,e[21]=g,e[22]=j):j=e[22];let b;return e[23]!==j||e[24]!==h?(b=s.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:s.jsxs(Ee,{children:[h,j]})}),e[23]=j,e[24]=h,e[25]=b):b=e[25],b}const ps="cogpit-session-scope",ql=["all","mine","shared","unassigned"],gs=["all","mine","shared"],Jl=[...gs,"unassigned"],Xl={scope:null,options:[]},ze=new Set,Ql={all:"All",mine:"Mine",shared:"Shared",unassigned:"Unassigned"};function Zl(){try{const n=localStorage.getItem(nt(ps));return ql.find(e=>e===n)??"all"}catch{return"all"}}function js(n){try{localStorage.setItem(nt(ps),n)}catch{}for(const e of ze)e()}function bs(n){ze.add(n);const e=dn(n);return()=>{ze.delete(n),e()}}const wt=new Map;function Be(){if(un().edition!=="team")return Xl;const n=fn("viewAllSessions"),e=n?Jl:gs,t=Zl(),l=e.includes(t)?t:"all",r=`${n?"admin":"member"}:${l}`;let a=wt.get(r);return a||(a={scope:l,options:e},wt.set(r,a)),a}function ws(){return _.useSyncExternalStore(bs,Be,Be)}function ys(n){return n===null||n==="all"?null:n}const ea=Object.freeze({}),ta={mine:Object.freeze({scope:"mine"}),shared:Object.freeze({scope:"shared"}),unassigned:Object.freeze({scope:"unassigned"})};function yt(){return ys(Be().scope)}const sa={subscribe:bs,getKey:yt,getQuery(){const n=yt();return n===null?ea:ta[n]}},He=new Map;function Ss(){return nt("share-notices")}function Ns(n){for(const e of n.known)n.listed.add(e);mn(),qe()}function na(n){const e=Ss(),t=new Set(n.filter(a=>a.kind==="access").map(a=>a.id)),l=He.get(e),r={known:t,listed:(l==null?void 0:l.listed)??new Set};He.set(e,r),l&&[...t].some(a=>!l.known.has(a))&&Ns(r)}function la(){const n=He.get(Ss());n&&[...n.known].some(e=>!n.listed.has(e))&&Ns(n)}const aa={mine:{title:"You have no sessions here",description:"Sessions you start show up here."},shared:{title:"Nothing shared with you here",description:"Sessions teammates share with you show up here."},unassigned:{title:"Every session here has an owner",description:"New sessions belong to whoever starts them."}};function ra(n){const e=A.c(17),{className:t}=n,l=ws();let r;e[0]!==l.scope?(r=ys(l.scope),e[0]=l.scope,e[1]=r):r=e[1];const a=r;let i,o;if(e[2]!==a?(i=()=>{a==="shared"&&la()},o=[a],e[2]=a,e[3]=i,e[4]=o):(i=e[3],o=e[4]),_.useEffect(i,o),a===null)return null;const{title:c,description:d}=aa[a];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ke,{variant:"icon",children:s.jsx(qt,{})}),e[5]=u):u=e[5];let f;e[6]!==c?(f=s.jsx(Te,{children:c}),e[6]=c,e[7]=f):f=e[7];let m;e[8]!==d?(m=s.jsx(Pe,{children:d}),e[8]=d,e[9]=m):m=e[9];let h;e[10]!==f||e[11]!==m?(h=s.jsxs(De,{children:[u,f,m]}),e[10]=f,e[11]=m,e[12]=h):h=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(F,{variant:"outline",size:"sm",onClick:ia,children:[s.jsx(kn,{"data-icon":"inline-start"}),"Show all"]}),e[13]=x):x=e[13];let p;return e[14]!==t||e[15]!==h?(p=s.jsxs(Ee,{className:t,children:[h,x]}),e[14]=t,e[15]=h,e[16]=p):p=e[16],p}function ia(){return js("all")}function oa(n){return"owner"in n&&"inheritsFrom"in n}function ca({owner:n,inheritsFrom:e}){return n?{label:n.displayName,title:`Owned by ${n.displayName}`}:e?{label:"Unassigned parent",title:"Its parent session has no owner yet"}:{label:"Unassigned",title:"No owner yet"}}function da(n){const e=A.c(8),{access:t}=n;if(!t||t.mine||!oa(t))return null;let l;e[0]!==t?(l=ca(t),e[0]=t,e[1]=l):l=e[1];const{label:r,title:a}=l;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(En,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let o;e[3]!==r?(o=s.jsx("span",{className:"truncate",children:r}),e[3]=r,e[4]=o):o=e[4];let c;return e[5]!==o||e[6]!==a?(c=s.jsxs(ne,{variant:"outline","data-session-owner":!0,className:"max-w-36",title:a,children:[i,o]}),e[5]=o,e[6]=a,e[7]=c):c=e[7],c}function ua(){const n=A.c(11),{scope:e,options:t}=ws();if(e===null)return null;let l;n[0]!==e?(l=[e],n[0]=e,n[1]=l):l=n[1];let r;n[2]!==t||n[3]!==e?(r=o=>{const c=t.find(d=>d===o.at(-1));c&&c!==e&&js(c)},n[2]=t,n[3]=e,n[4]=r):r=n[4];let a;n[5]!==t?(a=t.map(fa),n[5]=t,n[6]=a):a=n[6];let i;return n[7]!==l||n[8]!==r||n[9]!==a?(i=s.jsx("div",{className:"shrink-0 border-b px-2.5 py-2",children:s.jsx(st,{value:l,onValueChange:r,variant:"outline",size:"sm",spacing:0,className:"w-full","aria-label":"Whose sessions to list",children:a})}),n[7]=l,n[8]=r,n[9]=a,n[10]=i):i=n[10],i}function fa(n){return s.jsx(Oe,{value:n,className:"min-w-fit flex-1 px-2 text-xs",children:Ql[n]},n)}const ma="Could not update access. Try again.",ha=["view","interact","own"];function ut(n){return`/api/team/session-access/${encodeURIComponent(n)}`}function vs(n,e){return`${ut(n)}/grants/${encodeURIComponent(e)}`}function Cs(n){const e=n;return ha.includes(e==null?void 0:e.level)&&Array.isArray(e==null?void 0:e.grants)}async function ft(n){try{return await n()}catch{return null}}async function mt(n){const e=await ft(n),t=await re(e);return e!=null&&e.ok&&Cs(t)?{ok:!0,detail:t}:{ok:!1,superseded:(e==null?void 0:e.status)===409&&(t==null?void 0:t.code)==="superseded",error:typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:ma}}async function Ve(n,e){const t=Rt(),l=await ft(()=>me(ut(n),{signal:e})),r=await re(l);return!(l!=null&&l.ok)||!Cs(r)?null:(Lt(n,r.level,t),r)}async function xa(n){const e=await re(await ft(()=>me("/api/team/directory",{signal:n}))),t=e==null?void 0:e.users;return Array.isArray(t)?t:null}function pa(n,e,t){return mt(()=>Ye(vs(n,e),{mode:t},{method:"PUT"}))}function ga(n,e){return mt(()=>me(vs(n,e),{method:"DELETE"}))}function ja(n,e){return mt(()=>Ye(`${ut(n)}/owner`,{userId:e},{method:"PUT"}))}function ba(n){const e=A.c(3),{sessionId:t}=n,[l,r]=_.useState(null);let a,i;e[0]!==t?(a=()=>{const c=new AbortController;return Ve(t,c.signal).then(d=>{!c.signal.aborted&&d&&r({sessionId:t,user:d.owner})}),()=>c.abort()},i=[t],e[0]=t,e[1]=a,e[2]=i):(a=e[1],i=e[2]),_.useEffect(a,i);const o=(l==null?void 0:l.sessionId)===t?l.user:null;return o?`Shared with you by ${o.displayName} · view only`:"View only"}const Ne="__cogpitBootstrapToken";function wa(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},l=e||(typeof t[Ne]=="string"?t[Ne]:"");return e&&window.history.replaceState({...t,[Ne]:e},"",`${window.location.pathname}${window.location.search}`),l}function St(){const n={...window.history.state||{}};delete n[Ne],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function ya({onAuthenticated:n,onSetupClosed:e}){const[t]=_.useState(wa),[l,r]=_.useState(""),[a,i]=_.useState(""),[o,c]=_.useState(""),[d,u]=_.useState(""),[f,m]=_.useState(!1),[h,x]=_.useState(null),[p,g]=_.useState(!1),j=d.length>0&&d!==o,b=!t||!l.trim()||o.length<ue||d!==o,S=_.useCallback(async w=>{if(w.preventDefault(),!b){g(!0),x(null);try{const y=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify(ns({username:l,displayName:a,password:o}))}),N=await y.json();if(y.ok){St(),c(""),u(""),r(""),i(""),await e(),n();return}if(y.status===410){St(),await e();return}x(N.error||"Could not create the admin account")}catch{x("Failed to connect to server")}finally{g(!1)}}},[t,a,b,n,e,o,l]);return s.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:s.jsx("form",{onSubmit:S,className:"w-full max-w-md",children:s.jsxs(ke,{children:[s.jsxs($e,{children:[s.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:s.jsx(Dn,{className:"size-4"})}),s.jsx(_e,{children:"Create the first admin"}),s.jsx(et,{children:"Set up the account that will manage this Cogpit team server."})]}),s.jsxs(Ae,{className:"flex flex-col gap-4",children:[!t&&s.jsxs(ee,{children:[s.jsx(Ht,{"aria-hidden":"true"}),s.jsx(le,{children:"Setup link required"}),s.jsx(te,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),s.jsxs(Tt,{children:[s.jsx(ls,{id:"bootstrap-username",value:l,onChange:r,autoComplete:"username",autoFocus:!0}),s.jsx(as,{id:"bootstrap-display-name",value:a,onChange:i,autoComplete:"name"}),s.jsx(ct,{id:"bootstrap-password",label:"Password",placeholder:"Password",value:o,onChange:c,visible:f,onVisibleChange:m}),s.jsxs(X,{"data-invalid":j,children:[s.jsx(J,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),s.jsx(de,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:w=>u(w.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":j}),j&&s.jsx(Ze,{children:"Passwords do not match"})]})]}),h&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{"aria-hidden":"true"}),s.jsx(le,{children:"Could not create the account"}),s.jsx(te,{children:h})]})]}),s.jsx(hn,{children:s.jsxs(F,{type:"submit",className:"w-full",disabled:p||b,children:[p&&s.jsx(We,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}const Nt=[{value:"view",label:"Can view"},{value:"interact",label:"Can interact"}];function ht(n){const e=A.c(10),{user:t,className:l}=n;let r;e[0]!==l?(r=se("flex min-w-0 items-baseline gap-1.5",l),e[0]=l,e[1]=r):r=e[1];let a;e[2]!==t.displayName?(a=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[2]=t.displayName,e[3]=a):a=e[3];let i;e[4]!==t.username?(i=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[4]=t.username,e[5]=i):i=e[5];let o;return e[6]!==r||e[7]!==a||e[8]!==i?(o=s.jsxs("span",{className:r,children:[a,i]}),e[6]=r,e[7]=a,e[8]=i,e[9]=o):o=e[9],o}function _s(n){const e=A.c(12),{label:t,value:l,onChange:r,size:a}=n;let i;e[0]!==r||e[1]!==l?(i=f=>{f&&f!==l&&r(f)},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Gt,{}),e[3]=o):o=e[3];let c;e[4]!==t||e[5]!==a?(c=s.jsx(zt,{size:a,"aria-label":t,className:"w-32 shrink-0",children:o}),e[4]=t,e[5]=a,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Mt,{children:s.jsx(Ft,{children:Nt.map(Sa)})}),e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==l?(u=s.jsxs(Bt,{items:Nt,value:l,onValueChange:i,children:[c,d]}),e[8]=i,e[9]=c,e[10]=l,e[11]=u):u=e[11],u}function Sa(n){return s.jsx(It,{value:n.value,children:n.label},n.value)}function $s(n){const e=A.c(24),{label:t,users:l,value:r,placeholder:a,onChange:i,triggerRef:o,className:c}=n;let d;e[0]!==l?(d=l.map(va),e[0]=l,e[1]=d):d=e[1];const u=d,f=l.length===0;let m;e[2]!==i||e[3]!==l||e[4]!==r?(m=b=>{const S=l.find(w=>w.id===b);S&&S.id!==r&&i(S)},e[2]=i,e[3]=l,e[4]=r,e[5]=m):m=e[5];let h;e[6]!==a?(h=s.jsx(Gt,{placeholder:a}),e[6]=a,e[7]=h):h=e[7];let x;e[8]!==c||e[9]!==t||e[10]!==h||e[11]!==o?(x=s.jsx(zt,{ref:o,"aria-label":t,className:c,children:h}),e[8]=c,e[9]=t,e[10]=h,e[11]=o,e[12]=x):x=e[12];let p;e[13]!==l?(p=l.map(Na),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==p?(g=s.jsx(Mt,{children:s.jsx(Ft,{children:p})}),e[15]=p,e[16]=g):g=e[16];let j;return e[17]!==u||e[18]!==f||e[19]!==m||e[20]!==x||e[21]!==g||e[22]!==r?(j=s.jsxs(Bt,{items:u,value:r,disabled:f,onValueChange:m,children:[x,g]}),e[17]=u,e[18]=f,e[19]=m,e[20]=x,e[21]=g,e[22]=r,e[23]=j):j=e[23],j}function Na(n){return s.jsx(It,{value:n.id,children:s.jsx(ht,{user:n})},n.id)}function va(n){return{value:n.id,label:n.displayName}}function Ca(n){const e=A.c(10),{grants:t,onModeChange:l,onRemove:r}=n;if(t.length===0){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ee,{className:"gap-1 border p-4",children:s.jsxs(De,{children:[s.jsx(Te,{children:"Not shared with anyone yet"}),s.jsx(Pe,{className:"text-xs",children:"Only the owner and admins can open this session."})]})}),e[0]=o):o=e[0],o}let a;if(e[1]!==t||e[2]!==l||e[3]!==r){let o;e[5]!==l||e[6]!==r?(o=c=>s.jsxs("li",{className:"flex items-center gap-1.5 py-1.5 pr-1.5 pl-3",children:[s.jsx(ht,{user:c.user,className:"flex-1"}),s.jsx(_s,{size:"sm",label:`Access for ${c.user.displayName}`,value:c.mode,onChange:d=>l(c.user,d)}),s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${c.user.displayName}`,onClick:()=>r(c.user),children:s.jsx(Wt,{"data-icon":"inline-start"})})]},c.user.id),e[5]=l,e[6]=r,e[7]=o):o=e[7],a=t.map(o),e[1]=t,e[2]=l,e[3]=r,e[4]=a}else a=e[4];let i;return e[8]!==a?(i=s.jsx("ul",{"aria-label":"People with access",className:"flex flex-col divide-y rounded-lg border bg-card",children:a}),e[8]=a,e[9]=i):i=e[9],i}const _a="Someone else changed access — refreshed.";function ye(n,e){return t=>{const l=t.grants.filter(a=>a.user.id!==n),r=e?[...l,e].sort((a,i)=>a.grantedAt-i.grantedAt):l;return{...t,grants:r}}}function vt(n){return e=>({...e,...n})}function $a(n){const e=A.c(31),{user:t}=xe(),[l,r]=_.useState(!0),[a,i]=_.useState(null),[o,c]=_.useState(null),[d,u]=_.useState(null),[f,m]=_.useState(0),h=_.useRef(0),x=_.useRef(null);let p;e[0]!==n?(p=()=>{const D=new AbortController;return Promise.all([Ve(n,D.signal),xa(D.signal)]).then(E=>{var R;const[P,L]=E;D.signal.aborted||(x.current=((R=P==null?void 0:P.owner)==null?void 0:R.id)??null,i(P),c(L),r(!1))}),()=>D.abort()},e[0]=n,e[1]=p):p=e[1];let g;e[2]!==f||e[3]!==n?(g=[n,f],e[2]=f,e[3]=n,e[4]=g):g=e[4],_.useEffect(p,g);let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=function(){r(!0),m(Aa)},e[5]=j):j=e[5];const b=j;let S;e[6]!==n?(S=async function(E,P,L){var z,B;const R=h.current=h.current+1,I=Rt();u(null),i(M=>M&&E(M));const G=await L();if(G.ok){R===h.current&&i(G.detail),Lt(n,G.detail.level,I);const M=((z=G.detail.owner)==null?void 0:z.id)??null;M!==x.current&&qe(),x.current=M;return}if(i(M=>M&&P(M)),!G.superseded){u({tone:"error",text:G.error});return}u({tone:"notice",text:_a});const H=await Ve(n);H&&(x.current=((B=H.owner)==null?void 0:B.id)??null,i(H))},e[6]=n,e[7]=S):S=e[7];const w=S;let y;e[8]!==(a==null?void 0:a.grants)?(y=function(E){return(a==null?void 0:a.grants.find(P=>P.user.id===E))??null},e[8]=a==null?void 0:a.grants,e[9]=y):y=e[9];const N=y;let v;e[10]!==N||e[11]!==w||e[12]!==n||e[13]!==(t==null?void 0:t.id)?(v=function(E,P){const L=N(E.id),R=L?{...L,mode:P}:{user:E,mode:P,grantedBy:(t==null?void 0:t.id)??"",grantedAt:Date.now()};w(ye(E.id,R),ye(E.id,L),()=>pa(n,E.id,P))},e[10]=N,e[11]=w,e[12]=n,e[13]=t==null?void 0:t.id,e[14]=v):v=e[14];const C=v;let $;e[15]!==N||e[16]!==w||e[17]!==n?($=function(E){w(ye(E.id,null),ye(E.id,N(E.id)),()=>ga(n,E.id))},e[15]=N,e[16]=w,e[17]=n,e[18]=$):$=e[18];const k=$;let T;e[19]!==a||e[20]!==w||e[21]!==n?(T=function(E){if(!a)return;const{inheritsFrom:P,canHoldGrants:L}=a;w(vt({owner:E,inheritsFrom:null,canHoldGrants:!0}),vt({owner:a.owner,inheritsFrom:P,canHoldGrants:L}),()=>ja(n,E.id))},e[19]=a,e[20]=w,e[21]=n,e[22]=T):T=e[22];const U=T;let O;return e[23]!==U||e[24]!==a||e[25]!==o||e[26]!==C||e[27]!==l||e[28]!==d||e[29]!==k?(O={loading:l,detail:a,directory:o,message:d,retry:b,grant:C,revoke:k,changeOwner:U},e[23]=U,e[24]=a,e[25]=o,e[26]=C,e[27]=l,e[28]=d,e[29]=k,e[30]=O):O=e[30],O}function Aa(n){return n+1}function ka(n){const e=A.c(10),{sessionId:t,open:l,onOpenChange:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsxs(kt,{children:[s.jsx(Et,{children:"Share with team"}),s.jsx(Dt,{children:"View: read the session. Interact: also send messages, stop, and answer prompts."})]}),e[0]=a):a=e[0];let i;e[1]!==r?(i=()=>r(!1),e[1]=r,e[2]=i):i=e[2];let o;e[3]!==t||e[4]!==i?(o=s.jsxs($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:[a,s.jsx(Da,{sessionId:t,onClose:i},t)]}),e[3]=t,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==r||e[7]!==l||e[8]!==o?(c=s.jsx(At,{open:l,onOpenChange:r,children:o}),e[6]=r,e[7]=l,e[8]=o,e[9]=c):c=e[9],c}function Ea(n,e){return e&&!n.some(t=>t.id===e.id)?[e,...n]:n}function Da(n){var L;const e=A.c(44),{sessionId:t,onClose:l}=n,{user:r}=xe(),a=xn("manageUsers"),{loading:i,detail:o,directory:c,message:d,retry:u,grant:f,revoke:m,changeOwner:h}=$a(t);if(i){let R;return e[0]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsxs("p",{className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[s.jsx(We,{className:"size-4"})," Loading…"]}),e[0]=R):R=e[0],R}if(!o){let R;return e[1]!==u?(R=s.jsx(fe,{title:"Couldn't load who has access",message:"The server did not answer. Try again in a moment.",onRetry:u}),e[1]=u,e[2]=R):R=e[2],R}const x=r==null?void 0:r.id,p=(L=o.owner)==null?void 0:L.id;let g;e[3]!==o.grants||e[4]!==x||e[5]!==p?(g=new Set([x,p,...o.grants.map(Ta)]),e[3]=o.grants,e[4]=x,e[5]=p,e[6]=g):g=e[6];const j=g;let b;e[7]!==c||e[8]!==j?(b=(c==null?void 0:c.filter(R=>!j.has(R.id)))??null,e[7]=c,e[8]=j,e[9]=b):b=e[9];const S=b,{inheritsFrom:w}=o,y=w?null:o.owner;let N;e[10]!==c||e[11]!==a||e[12]!==y?(N=a&&c?Ea(c,y):null,e[10]=c,e[11]=a,e[12]=y,e[13]=N):N=e[13];const v=N,C=w?o.owner?`Through parent: ${o.owner.displayName}`:"Unassigned parent":"Unassigned";let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx("span",{className:"text-sm text-muted-foreground",children:"Owner"}),e[14]=$):$=e[14];let k;e[15]!==h||e[16]!==y||e[17]!==v||e[18]!==C?(k=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[$,v?s.jsx($s,{label:"Change owner",users:v,value:(y==null?void 0:y.id)??null,placeholder:C,onChange:h,className:"min-w-44"}):y?s.jsx(ht,{user:y,className:"justify-end"}):s.jsx("span",{className:"text-sm text-muted-foreground",children:C})]}),e[15]=h,e[16]=y,e[17]=v,e[18]=C,e[19]=k):k=e[19];let T;e[20]!==w||e[21]!==v?(T=v&&w&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"An owner of its own makes this session independent: it stops sharing its parent session's access."}),e[20]=w,e[21]=v,e[22]=T):T=e[22];let U;e[23]!==k||e[24]!==T?(U=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[k,T]}),e[23]=k,e[24]=T,e[25]=U):U=e[25];let O;e[26]!==S||e[27]!==o.canHoldGrants||e[28]!==f||e[29]!==w||e[30]!==l?(O=o.canHoldGrants?s.jsx(Oa,{candidates:S,onAdd:f}):s.jsx(Pa,{inheritsFrom:w,onParentOpened:l}),e[26]=S,e[27]=o.canHoldGrants,e[28]=f,e[29]=w,e[30]=l,e[31]=O):O=e[31];let D;e[32]!==d?(D=d&&s.jsx(Ua,{message:d}),e[32]=d,e[33]=D):D=e[33];let E;e[34]!==o.canHoldGrants||e[35]!==o.grants||e[36]!==f||e[37]!==m?(E=o.canHoldGrants&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:"People with access"}),s.jsx(Ca,{grants:o.grants,onModeChange:f,onRemove:m})]}),e[34]=o.canHoldGrants,e[35]=o.grants,e[36]=f,e[37]=m,e[38]=E):E=e[38];let P;return e[39]!==O||e[40]!==D||e[41]!==E||e[42]!==U?(P=s.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[U,O,D,E]}),e[39]=O,e[40]=D,e[41]=E,e[42]=U,e[43]=P):P=e[43],P}function Ta(n){return n.user.id}function Pa(n){const e=A.c(14),{inheritsFrom:t,onParentOpened:l}=n,[r,a]=_.useState(!1);if(!t){let x;return e[0]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(ee,{role:"note",children:[s.jsx(Tn,{}),s.jsx(le,{children:"Assign an owner first"}),s.jsx(te,{children:"Only a session with an owner can be shared."})]}),e[0]=x):x=e[0],x}let i;e[1]!==l?(i=async function(p){a(!1),await pn(p)?l():a(!0)},e[1]=l,e[2]=i):i=e[2];const o=i;let c,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(Pn,{}),d=s.jsx(le,{children:"Shared through its parent session"}),e[3]=c,e[4]=d):(c=e[3],d=e[4]);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("span",{children:"Whoever can open the parent can open this one. Share the parent to change who."}),e[5]=u):u=e[5];let f;e[6]!==t||e[7]!==o?(f=s.jsx(F,{variant:"link",className:"h-auto p-0",onClick:()=>void o(t),children:"Open parent session"}),e[6]=t,e[7]=o,e[8]=f):f=e[8];let m;e[9]!==r?(m=r&&s.jsx("span",{role:"alert",className:"text-destructive",children:"Couldn't open the parent session."}),e[9]=r,e[10]=m):m=e[10];let h;return e[11]!==f||e[12]!==m?(h=s.jsxs(ee,{role:"note",children:[c,d,s.jsxs(te,{className:"flex flex-col items-start gap-1",children:[u,f,m]})]}),e[11]=f,e[12]=m,e[13]=h):h=e[13],h}function Oa(n){const e=A.c(22),{candidates:t,onAdd:l}=n,[r,a]=_.useState(null),[i,o]=_.useState("view"),c=_.useRef(null);let d;e[0]!==t?(d=t??[],e[0]=t,e[1]=d):d=e[1];const u=d;let f;e[2]!==u||e[3]!==r?(f=r&&u.some(N=>N.id===r.id)?r:null,e[2]=u,e[3]=r,e[4]=f):f=e[4];const m=f;let h;e[5]!==i||e[6]!==l||e[7]!==m?(h=function(v){var C;v.preventDefault(),m&&(l(m,i),a(null),(C=c.current)==null||C.focus())},e[5]=i,e[6]=l,e[7]=m,e[8]=h):h=e[8];const x=h,p=(m==null?void 0:m.id)??null,g=t===null?"Couldn't load teammates":u.length===0?"No one else to add":"Choose a teammate";let j;e[9]!==u||e[10]!==p||e[11]!==g?(j=s.jsx($s,{label:"Teammate",users:u,value:p,placeholder:g,onChange:a,triggerRef:c,className:"min-w-0 flex-1"}),e[9]=u,e[10]=p,e[11]=g,e[12]=j):j=e[12];let b;e[13]!==i?(b=s.jsx(_s,{label:"Access for new teammate",value:i,onChange:o}),e[13]=i,e[14]=b):b=e[14];const S=!m;let w;e[15]!==S?(w=s.jsx(F,{type:"submit",disabled:S,children:"Add"}),e[15]=S,e[16]=w):w=e[16];let y;return e[17]!==x||e[18]!==j||e[19]!==b||e[20]!==w?(y=s.jsxs("form",{onSubmit:x,className:"flex items-center gap-2",children:[j,b,w]}),e[17]=x,e[18]=j,e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function Ua(n){const e=A.c(6),{message:t}=n,l=t.tone==="error",r=l?"alert":"status",a=l?"text-destructive":"text-muted-foreground";let i;e[0]!==a?(i=se("text-xs",a),e[0]=a,e[1]=i):i=e[1];let o;return e[2]!==t.text||e[3]!==r||e[4]!==i?(o=s.jsx("p",{role:r,className:i,children:t.text}),e[2]=t.text,e[3]=r,e[4]=i,e[5]=o):o=e[5],o}function Ra(n){const e=A.c(4),{sessionId:t}=n,{edition:l}=xe(),{permissions:r}=gn(),[a,i]=_.useState(!1);if(l!=="team"||!r.canOwn)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(jn,{icon:qt,label:"Share with team…",size:"default",onClick:()=>i(!0)}),e[0]=o):o=e[0];let c;return e[1]!==a||e[2]!==t?(c=s.jsxs(s.Fragment,{children:[o,s.jsx(ka,{sessionId:t,open:a,onOpenChange:i})]}),e[1]=a,e[2]=t,e[3]=c):c=e[3],c}const La={SetupScreen:ya,LoginNotice:fs,GateScreen:Vl,AccountControl:Ol,SessionHeaderActions:Ra,SessionBadges:da,ReadOnlyNote:ba,mainViews:[Pl],sessionListFilter:{...sa,Control:ua,Empty:ra},onInboxRead:na},Ha={edition:"team",ui:La};export{Ha as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,c as ge,j as s}from"./vendor-react-gGw_S5I_.js";import{U as et,bW as tt,b5 as st,bX as mt,bY as Jt,J as _e,L as Xe,M as We,N as Je,O as Ve,Q as Me,bZ as qe,B as Q,af as it,ay as Ot,b4 as Ke,n as Vt,I as qt,E as Zt,m as Qt,bu as It,bv as Lt,bt as Bt,b_ as ct,Z as Ye,_ as es,b$ as ts,c0 as ss,c1 as ns,l as ht,c2 as ls,i as Ft,j as Pt,k as $t,a$ as xt,G as rs,C as pt,z as os,c3 as Mt,aI as zt,h as Ut,D as Kt,a3 as as,a4 as is,a5 as cs,a6 as us,a7 as ds,a8 as fs,a9 as ms,aa as hs,ab as xs,bT as gt,R as wt,c4 as ps}from"./index-DsnL-sXV.js";import{a4 as gs,J as ut,n as Yt,I as dt,z as ws,g as ft,ax as bs,X as Ze,O as Ht,ay as ys,az as js,b as Ss,aA as Gt,a2 as ks,aB as vs,P as Cs,aC as Ns,i as bt,aa as Es,aD as Ts}from"./vendor-ui-Br3ZTAXZ.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const $e="/api/browser",Ds=5e3,_s="all";function nt(n,e=""){return`${$e}/sessions/${encodeURIComponent(n)}${e}`}function lt(n){return{headers:{"content-type":"application/json"},body:JSON.stringify(n)}}function rt(n,e){return n instanceof Error&&n.message?n.message:e}function As(n){const[e,t]=o.useState(null),[l,r]=o.useState(null),a=o.useRef(!1),c=o.useRef(0),m=o.useRef(!1);o.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);const x=o.useCallback(async()=>{const u=++c.current;m.current=!0;try{const d=await et(tt($e)),g=d.ok?await d.json():null;if(!a.current||u!==c.current)return;g?(t(f=>JSON.stringify(f)===JSON.stringify(g)?f:g),r(null)):r(await st(d,`Could not read the browser list (${d.status})`))}catch(d){a.current&&u===c.current&&r(rt(d,"Could not read the browser list"))}finally{u===c.current&&(m.current=!1)}},[]);o.useEffect(()=>{if(!n)return;x();const u=setInterval(()=>{m.current||x()},Ds);return()=>clearInterval(u)},[n,x]);const h=o.useCallback(async(u,d,g)=>{let f;try{f=await et(tt(u),d)}catch(N){return{ok:!1,error:rt(N,g)}}if(!f.ok)return{ok:!1,error:await st(f,g)};const L=await mt(f);return x(),{ok:!0,data:L}},[x]),w=o.useCallback(async(u,d,g)=>{const f=await h(u,d,g);return f.ok?{ok:!0}:f},[h]),y=o.useCallback(async(u,d)=>{const g=await h(`${$e}/sessions`,{method:"POST",...lt({name:u,note:d})},`Could not create ${u}`);if(!g.ok)return g;const f=g.data;return(f==null?void 0:f.name)===u&&t(L=>L&&!L.sessions.some(N=>N.name===u)?{...L,sessions:[...L.sessions,f]}:L),{ok:!0}},[h]),D=o.useCallback(u=>w(nt(u),{method:"DELETE"},`Could not delete ${u}`),[w]),j=o.useCallback(u=>w(nt(u,"/stop"),{method:"POST"},`Could not stop ${u}`),[w]),p=o.useCallback((u,d)=>w(nt(u),{method:"PATCH",...lt({archived:d})},`Could not ${d?"archive":"restore"} ${u}`),[w]),_=o.useCallback(async()=>{const u="Could not read where the browser skill is installed";let d;try{d=await et(tt(`${$e}/skill`))}catch(f){return{ok:!1,error:rt(f,u)}}if(!d.ok)return{ok:!1,error:await st(d,u)};const g=await mt(d);return Array.isArray(g==null?void 0:g.targets)?{ok:!0,targets:g.targets}:{ok:!1,error:u}},[]),k=o.useCallback(async u=>{const d="Could not install the browser skill",g=await h(`${$e}/skill/install`,{method:"POST",...lt({target:u})},d);if(!g.ok)return g;const{paths:f}=g.data??{};return Array.isArray(f)&&f.every(L=>typeof L=="string")?{ok:!0,paths:f}:{ok:!1,error:d}},[h]);return{status:e,error:l,refresh:x,create:y,remove:D,stop:j,setArchived:p,readSkillTargets:_,installSkill:k}}const ot=4;new TextEncoder;const Rs=new TextDecoder;function Os(n){if(n.byteLength<ot)throw new Error("Frame truncated before header length");const e=new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0),t=ot+e;if(n.byteLength<t)throw new Error("Frame truncated inside header");return{header:Is(Rs.decode(n.subarray(ot,t))),jpeg:n.subarray(t)}}function Is(n){let e;try{e=JSON.parse(n)}catch{throw new Error("Frame header is not valid JSON")}if(typeof e!="object"||e===null)throw new Error("Frame header is not an object");const{deviceWidth:t,deviceHeight:l,pageScaleFactor:r,offsetTop:a,scrollOffsetX:c,scrollOffsetY:m,targetId:x,ts:h}=e;if(typeof t!="number"||typeof l!="number"||typeof r!="number"||typeof a!="number"||typeof c!="number"||typeof m!="number"||typeof x!="string"||typeof h!="number")throw new Error("Frame header is missing fields");return{deviceWidth:t,deviceHeight:l,pageScaleFactor:r,offsetTop:a,scrollOffsetX:c,scrollOffsetY:m,targetId:x,ts:h}}const yt=500,Ls=5e3,jt=[];function Bs(n){const e=window.location.protocol==="https:"?"wss:":"ws:",t=Jt();return`${e}//${window.location.host}${t}/__browser?session=${encodeURIComponent(n)}`}function Fs(n){try{return JSON.parse(n)}catch{return null}}function Ps(n,e){return n.state===e.state&&n.session===e.session&&n.message===e.message}function $s(n,e){return n.targetId===e.targetId&&n.url===e.url&&n.title===e.title&&n.canGoBack===e.canGoBack&&n.canGoForward===e.canGoForward}function Ms(n,e){return n.length===e.length&&n.every((t,l)=>t.targetId===e[l].targetId&&t.url===e[l].url&&t.title===e[l].title)}function at(n){n&&n.bitmap.close()}function zs(n,e){const t=ge.c(16),[l,r]=o.useState("idle"),[a,c]=o.useState(null),[m,x]=o.useState(null),[h,w]=o.useState(jt),[y,D]=o.useState(null),[j,p]=o.useState(null),[_,k]=o.useState(null),[u,d]=o.useState(null),g=o.useRef(null),f=o.useRef(null),L=o.useRef(null),N=o.useRef(e);let A,Y;t[0]!==e?(A=()=>{N.current=e},Y=[e],t[0]=e,t[1]=A,t[2]=Y):(A=t[1],Y=t[2]),o.useEffect(A,Y);let b,P;t[3]!==n?(b=()=>{if(c(null),x(null),w(jt),D(null),d(null),p(null),k(null),n===null){r("idle");return}const v=n,E={alive:!0,issued:0,applied:0};let C=yt;const U=function(B,O){if(!E.alive||O<=E.applied){at(B);return}E.applied=O,f.current=B,p(B),k(Date.now())},F=function(B){let O,q;try{const X=Os(new Uint8Array(B));O=X.header,q=new Blob([X.jpeg],{type:"image/jpeg"})}catch{return}const H=E.issued=E.issued+1;createImageBitmap(q).then(X=>U({bitmap:X,header:O},H),Us)},V=function(B){var q;const O=Fs(B);if(O)e:switch(O.type){case"status":{c(H=>H&&Ps(H,O)?H:O),d(null);break e}case"page":{x(H=>H&&$s(H,O)?H:O);break e}case"tabs":{w(H=>Ms(H,O.tabs)?H:O.tabs),D(O.followed);break e}case"error":{d(O.message);break e}case"clipboard":(q=N.current)==null||q.call(N,O.text)}};function K(){if(!E.alive)return;const R=g.current;if(R&&R.readyState!==WebSocket.CLOSED)return;r("connecting");const B=new WebSocket(Bs(v));B.binaryType="arraybuffer",g.current=B,B.onopen=()=>{if(!E.alive){B.close();return}C=yt,r("connected")},B.onmessage=O=>{E.alive&&(typeof O.data=="string"?V(O.data):O.data instanceof ArrayBuffer&&F(O.data))},B.onclose=()=>{if(!E.alive)return;g.current=null,r("disconnected");const O=C;C=Math.min(C*2,Ls),L.current=setTimeout(K,O)}}return K(),()=>{E.alive=!1,L.current&&(clearTimeout(L.current),L.current=null);const R=g.current;g.current=null,R&&(R.onclose=null,R.close()),at(f.current),f.current=null}},P=[n],t[3]=n,t[4]=b,t[5]=P):(b=t[4],P=t[5]),o.useEffect(b,P);let $;t[6]===Symbol.for("react.memo_cache_sentinel")?($=v=>{const E=g.current;E&&E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(v))},t[6]=$):$=t[6];const M=$;let z;return t[7]!==u||t[8]!==y||t[9]!==j||t[10]!==_||t[11]!==m||t[12]!==a||t[13]!==l||t[14]!==h?(z={status:l,state:a,page:m,tabs:h,followed:y,frame:j,lastFrameAt:_,error:u,send:M},t[7]=u,t[8]=y,t[9]=j,t[10]=_,t[11]=m,t[12]=a,t[13]=l,t[14]=h,t[15]=z):z=t[15],z}function Us(){}const Ks=6e3;function Ys(n){const e=ge.c(16),{activity:t}=n,[l,r]=o.useState(!0),a=t?`${t.toolCallId}:${t.done}`:null;let c,m;if(e[0]!==a?(c=()=>{if(a===null)return;r(!0);const k=setTimeout(()=>r(!1),Ks);return()=>clearTimeout(k)},m=[a],e[0]=a,e[1]=c,e[2]=m):(c=e[1],m=e[2]),o.useEffect(c,m),!t)return null;const x=l?"opacity-100":"opacity-0";let h;e[3]!==x?(h=_e("pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-2 pb-6 pt-8","bg-gradient-to-t from-transparent via-background/70 to-transparent","transition-opacity duration-700 motion-reduce:transition-none",x),e[3]=x,e[4]=h):h=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(gs,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),e[5]=w):w=e[5];let y;e[6]!==t.command?(y=s.jsx("code",{className:"min-w-0 truncate font-mono text-[11px]",children:t.command}),e[6]=t.command,e[7]=y):y=e[7];const D=t.done?"ran":"running";let j;e[8]!==D?(j=s.jsx("span",{className:"shrink-0 text-muted-foreground",children:D}),e[8]=D,e[9]=j):j=e[9];let p;e[10]!==y||e[11]!==j?(p=s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-full bg-popover px-3 py-1 text-xs shadow-xs",children:[w,y,j]}),e[10]=y,e[11]=j,e[12]=p):p=e[12];let _;return e[13]!==h||e[14]!==p?(_=s.jsx("div",{className:h,children:p}),e[13]=h,e[14]=p,e[15]=_):_=e[15],_}const St="npm i -g agent-browser && agent-browser install",Hs=1500;function Gs(n){const e=ge.c(20),{onOpenSkill:t}=n,[l,r]=o.useState(!1),a=o.useRef(null);let c,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>()=>{a.current&&clearTimeout(a.current)},m=[],e[0]=c,e[1]=m):(c=e[0],m=e[1]),o.useEffect(c,m);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=async function(){await Ot(St)&&(r(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>r(!1),Hs))},e[2]=x):x=e[2];const h=x;let w,y;e[3]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Je,{variant:"icon",children:s.jsx(Yt,{})}),y=s.jsx(Ve,{children:"Nothing to show yet"}),e[3]=w,e[4]=y):(w=e[3],y=e[4]);let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsxs(We,{children:[w,y,s.jsxs(Me,{children:["This panel streams a real browser the agent drives. That takes the"," ",s.jsx("code",{className:"font-mono",children:"agent-browser"})," command, which is not on this machine yet."]})]}),e[5]=D):D=e[5];let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:St}),e[6]=j):j=e[6];const p=l?"Copied":"Copy install command";let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_=()=>void h(),e[7]=_):_=e[7];let k;e[8]!==l?(k=l?s.jsx(dt,{"data-icon":"inline-start",className:"text-emerald-500"}):s.jsx(ws,{"data-icon":"inline-start"}),e[8]=l,e[9]=k):k=e[9];let u;e[10]!==k||e[11]!==p?(u=s.jsxs("div",{className:"flex w-full items-center gap-1.5 rounded-md border bg-muted/40 py-1 pl-2.5 pr-1 text-left",children:[j,s.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":p,onClick:_,children:k})]}),e[10]=k,e[11]=p,e[12]=u):u=e[12];let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(ft,{"data-icon":"inline-start"}),e[13]=d):d=e[13];let g;e[14]!==t?(g=s.jsxs(Q,{variant:"outline",size:"sm",onClick:t,children:[d,"Install the agent skill…"]}),e[14]=t,e[15]=g):g=e[15];let f;e[16]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Me,{className:"text-xs",children:"The skill teaches the agent when to use a named browser and how this panel follows along. Installing writes it into your home directory, so it is never done for you."}),e[16]=f):f=e[16];let L;return e[17]!==u||e[18]!==g?(L=s.jsxs(Xe,{className:"size-full",children:[D,s.jsxs(qe,{children:[u,g,f]})]}),e[17]=u,e[18]=g,e[19]=L):L=e[19],L}function Xs(n){const e=ge.c(14),{name:t,lastUrl:l,onOpen:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(Je,{variant:"icon",children:s.jsx(bs,{})}),e[0]=a):a=e[0];let c;e[1]!==t?(c=s.jsxs(Ve,{children:[t," isn’t running"]}),e[1]=t,e[2]=c):c=e[2];const m=r?"The agent opens it by itself the moment it browses. You can also open a page here and watch from the start.":"It shows up here as soon as the agent that uses it opens it again.";let x;e[3]!==m?(x=s.jsx(Me,{children:m}),e[3]=m,e[4]=x):x=e[4];let h;e[5]!==c||e[6]!==x?(h=s.jsxs(We,{children:[a,c,x]}),e[5]=c,e[6]=x,e[7]=h):h=e[7];let w;e[8]!==l||e[9]!==r?(w=r&&s.jsx(qe,{children:s.jsx(Xt,{lastUrl:l,onOpen:r})}),e[8]=l,e[9]=r,e[10]=w):w=e[10];let y;return e[11]!==h||e[12]!==w?(y=s.jsxs(Xe,{className:"size-full",children:[h,w]}),e[11]=h,e[12]=w,e[13]=y):y=e[13],y}function kt(n){const e=ge.c(5),{onOpen:t}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(We,{children:[s.jsx(Je,{variant:"icon",children:s.jsx(Yt,{})}),s.jsx(Ve,{children:"Your agents’ browsers show up here"}),s.jsx(Me,{children:"When an agent in one of your sessions opens a web page, you can watch it here and take over. Other sessions you can access show their browsers too."})]}),e[0]=l):l=e[0];let r;e[1]!==t?(r=t&&s.jsx(qe,{children:s.jsx(Xt,{lastUrl:null,onOpen:t})}),e[1]=t,e[2]=r):r=e[2];let a;return e[3]!==r?(a=s.jsxs(Xe,{className:"size-full",children:[l,r]}),e[3]=r,e[4]=a):a=e[4],a}function Xt(n){const e=ge.c(14),{lastUrl:t,onOpen:l}=n,[r,a]=o.useState(null),c=r??t??"";let m;e[0]!==l||e[1]!==c?(m=function(k){k.preventDefault();const u=c.trim();u&&l(u)},e[0]=l,e[1]=c,e[2]=m):m=e[2];const x=m;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=_=>a(_.target.value),e[3]=h):h=e[3];let w;e[4]!==c?(w=s.jsx(Ke,{"aria-label":"Page to open",className:"h-8 text-sm",placeholder:"example.com",spellCheck:!1,autoComplete:"off",value:c,onChange:h}),e[4]=c,e[5]=w):w=e[5];let y;e[6]!==c?(y=c.trim(),e[6]=c,e[7]=y):y=e[7];const D=!y;let j;e[8]!==D?(j=s.jsx(Q,{type:"submit",size:"sm",disabled:D,children:"Open"}),e[8]=D,e[9]=j):j=e[9];let p;return e[10]!==x||e[11]!==w||e[12]!==j?(p=s.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:x,children:[w,j]}),e[10]=x,e[11]=w,e[12]=j,e[13]=p):p=e[13],p}function Ws({message:n,onRetry:e}){const[t,l]=o.useState(!1);async function r(){l(!0);try{await e()}finally{l(!1)}}return s.jsxs(Xe,{className:"size-full",children:[s.jsxs(We,{children:[s.jsx(Je,{variant:"icon",children:s.jsx(ut,{})}),s.jsx(Ve,{children:"Could not load the browsers"}),s.jsx(Me,{children:n})]}),s.jsx(qe,{children:s.jsxs(Q,{variant:"outline",size:"sm",disabled:t,onClick:()=>void r(),children:[t&&s.jsx(it,{"data-icon":"inline-start"}),"Retry"]})})]})}function vt(n){if(n.url==="about:blank"&&(!n.title.trim()||n.title==="about:blank"))return"New tab";if(n.title.trim())return n.title.trim();try{return new URL(n.url).hostname||n.url}catch{return n.url}}const Js={live:{label:"LIVE",hint:"Streaming the page as it changes",tone:"text-emerald-600 dark:text-emerald-400",dot:"bg-emerald-500"},idle:{label:"IDLE",hint:"The page has not changed for a few seconds",tone:"text-muted-foreground",dot:"ring-1 ring-muted-foreground/50 ring-inset"},offline:{label:"OFFLINE",hint:"The connection dropped — this is the last frame that arrived",tone:"text-amber-600 dark:text-amber-400",dot:"bg-amber-500"}};function Vs(n){const e=ge.c(17),{status:t}=n,l=Js[t];let r;e[0]!==l.tone?(r=_e("ml-1 flex shrink-0 cursor-default items-center gap-1 text-[10px] font-medium tracking-wide",l.tone),e[0]=l.tone,e[1]=r):r=e[1];let a;e[2]!==r?(a=s.jsx("span",{className:r}),e[2]=r,e[3]=a):a=e[3];let c;e[4]!==l.dot?(c=_e("size-1.5 rounded-full",l.dot),e[4]=l.dot,e[5]=c):c=e[5];let m;e[6]!==c?(m=s.jsx("span",{"aria-hidden":"true",className:c}),e[6]=c,e[7]=m):m=e[7];let x;e[8]!==l.label||e[9]!==a||e[10]!==m?(x=s.jsxs(It,{render:a,children:[m,l.label]}),e[8]=l.label,e[9]=a,e[10]=m,e[11]=x):x=e[11];let h;e[12]!==l.hint?(h=s.jsx(Lt,{children:l.hint}),e[12]=l.hint,e[13]=h):h=e[13];let w;return e[14]!==x||e[15]!==h?(w=s.jsxs(Bt,{children:[x,h]}),e[14]=x,e[15]=h,e[16]=w):w=e[16],w}const qs=o.memo(function(e){const t=ge.c(52),{page:l,tabs:r,followed:a,status:c,readOnly:m,onNavigate:x,onBack:h,onForward:w,onReload:y,onFollow:D,onCloseTab:j}=e,p=m===void 0?!1:m,[_,k]=o.useState(null),u=(l==null?void 0:l.url)??"";let d;t[0]!==_||t[1]!==u||t[2]!==x||t[3]!==p?(d=function(ee){if(ee.preventDefault(),p)return;const Se=(_??u).trim();k(null),Se&&x(Se)},t[0]=_,t[1]=u,t[2]=x,t[3]=p,t[4]=d):d=t[4];const g=d;let f;t[5]===Symbol.for("react.memo_cache_sentinel")?(f=function(ee){ee.key==="Escape"&&(ee.preventDefault(),k(null),ee.currentTarget.blur())},t[5]=f):f=t[5];const L=f,N=p||!(l!=null&&l.canGoBack);let A;t[6]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(Ht,{"data-icon":"inline-start"}),t[6]=A):A=t[6];let Y;t[7]!==h||t[8]!==N?(Y=s.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"Back",disabled:N,onClick:h,children:A}),t[7]=h,t[8]=N,t[9]=Y):Y=t[9];const b=p||!(l!=null&&l.canGoForward);let P;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(ys,{"data-icon":"inline-start"}),t[10]=P):P=t[10];let $;t[11]!==w||t[12]!==b?($=s.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"Forward",disabled:b,onClick:w,children:P}),t[11]=w,t[12]=b,t[13]=$):$=t[13];const M=p||!l;let z;t[14]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(js,{"data-icon":"inline-start"}),t[14]=z):z=t[14];let v;t[15]!==y||t[16]!==M?(v=s.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"Reload",disabled:M,onClick:y,children:z}),t[15]=y,t[16]=M,t[17]=v):v=t[17];const E=_??u;let C;t[18]===Symbol.for("react.memo_cache_sentinel")?(C=J=>k(J.target.value),t[18]=C):C=t[18];let U;t[19]===Symbol.for("react.memo_cache_sentinel")?(U=()=>k(null),t[19]=U):U=t[19];let F;t[20]!==p||t[21]!==E?(F=s.jsx(Vt,{"aria-label":"Page URL",className:"text-xs",placeholder:"Enter a URL",spellCheck:!1,autoComplete:"off",readOnly:p,value:E,onChange:C,onFocus:Zs,onBlur:U,onKeyDown:L}),t[20]=p,t[21]=E,t[22]=F):F=t[22];const V=!u;let K;t[23]!==u?(K=()=>window.open(u,"_blank","noopener,noreferrer"),t[23]=u,t[24]=K):K=t[24];let R;t[25]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(Ss,{"data-icon":"inline-start"}),t[25]=R):R=t[25];let B;t[26]!==V||t[27]!==K?(B=s.jsx(qt,{align:"inline-end",children:s.jsx(Zt,{size:"icon-xs","aria-label":"Open in your browser",disabled:V,onClick:K,children:R})}),t[26]=V,t[27]=K,t[28]=B):B=t[28];let O;t[29]!==F||t[30]!==B?(O=s.jsxs(Qt,{className:"h-7",children:[F,B]}),t[29]=F,t[30]=B,t[31]=O):O=t[31];let q;t[32]!==g||t[33]!==O?(q=s.jsx("form",{className:"ml-1 min-w-0 flex-1",onSubmit:g,children:O}),t[32]=g,t[33]=O,t[34]=q):q=t[34];let H;t[35]!==c?(H=c&&s.jsx(Vs,{status:c}),t[35]=c,t[36]=H):H=t[36];let X;t[37]!==v||t[38]!==q||t[39]!==H||t[40]!==Y||t[41]!==$?(X=s.jsxs("div",{className:"flex items-center gap-0.5",children:[Y,$,v,q,H]}),t[37]=v,t[38]=q,t[39]=H,t[40]=Y,t[41]=$,t[42]=X):X=t[42];let ne;t[43]!==a||t[44]!==j||t[45]!==D||t[46]!==p||t[47]!==r?(ne=r.length>0&&s.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-0.5",children:r.map(J=>s.jsxs("div",{className:_e("flex max-w-48 shrink-0 items-center rounded-md",J.targetId===a&&"bg-secondary"),children:[s.jsx(Q,{size:"xs",variant:"ghost",className:_e("min-w-0 shrink",!p&&"rounded-r-none"),"aria-current":J.targetId===a?"page":void 0,title:J.title||J.url,onClick:()=>D(J.targetId),onMouseDown:Qs,onAuxClick:ee=>{ee.button!==1||p||(ee.preventDefault(),j(J.targetId))},children:s.jsx("span",{className:"truncate",children:vt(J)})}),!p&&s.jsx(Q,{size:"icon-xs",variant:"ghost",className:"rounded-l-none","aria-label":`Close tab: ${vt(J)}`,title:"Close tab",onClick:()=>j(J.targetId),children:s.jsx(Ze,{"data-icon":"inline-start"})})]},J.targetId))}),t[43]=a,t[44]=j,t[45]=D,t[46]=p,t[47]=r,t[48]=ne):ne=t[48];let le;return t[49]!==X||t[50]!==ne?(le=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-b px-2 py-1.5",children:[X,ne]}),t[49]=X,t[50]=ne,t[51]=le):le=t[51],le});function Zs(n){return n.target.select()}function Qs(n){n.button===1&&n.preventDefault()}function en(n){var e;return((e=n.find(t=>t.mine))==null?void 0:e.name)??ct}function He(n){return(n==null?void 0:n.control)??"own"}function tn(n){return He(n)!=="watch"}function Ge(n,e){return n!=null&&n.mine?"Your browser":n!=null&&n.account?`${n.account}'s browser`:e}function sn(n,e,t){if(n!==ct||t===null)return n;const l=e.find(r=>(r.mine||r.account)&&r.driverSessionId===t);return(l==null?void 0:l.name)??n}function nn(n){if(!n||!Number.isFinite(Date.parse(n)))return null;if(Date.now()-Date.parse(n)>=10080*60*1e3)return new Date(n).toLocaleDateString();const e=es(n);return e==="now"?"just now":`${e} ago`}function Wt(n){const e=ge.c(4),{running:t}=n,l=t?"bg-emerald-500":"ring-1 ring-muted-foreground/50 ring-inset";let r;e[0]!==l?(r=_e("size-2 shrink-0 rounded-full",l),e[0]=l,e[1]=r):r=e[1];let a;return e[2]!==r?(a=s.jsx("span",{"aria-hidden":!0,className:r}),e[2]=r,e[3]=a):a=e[3],a}function ln(n){const e=ge.c(89),{sessions:t,selected:l,home:r,currentSessionId:a,busy:c,onSelect:m,onSetArchived:x,children:h}=n,[w,y]=o.useState(!1),[D,j]=o.useState(""),[p,_]=o.useState(!1),k=o.useRef(null);let u,d,g,f,L,N,A,Y,b,P,$,M,z,v,E,C,U;if(e[0]!==c||e[1]!==a||e[2]!==r||e[3]!==m||e[4]!==x||e[5]!==w||e[6]!==D||e[7]!==l||e[8]!==t||e[9]!==p){let ne;e[27]!==l?(ne=I=>I.name===l,e[27]=l,e[28]=ne):ne=e[28];const le=t.find(ne),J=D.trim().toLowerCase();let ee;e[29]!==r||e[30]!==l?(ee=I=>!!I.archived&&!I.isDefault&&I.name!==r&&!I.running&&I.name!==l,e[29]=r,e[30]=l,e[31]=ee):ee=e[31];const Se=ee,ve=I=>`${I.name} ${Ge(I,I.name)} ${I.note??""}`.toLowerCase().includes(J);let ye;e[32]!==r?(ye=(I,S)=>+(S.name===r)-+(I.name===r)||Number(S.isDefault)-Number(I.isDefault)||Number(S.running)-Number(I.running),e[32]=r,e[33]=ye):ye=e[33];const Ne=t.filter(I=>!Se(I)&&ve(I)).sort(ye);g=t.filter(Se);const we=g.filter(ve);U=p&&!J?[]:Ne,C=p||J?we:[];let he;e[34]===Symbol.for("react.memo_cache_sentinel")?(he=function(){y(!1)},e[34]=he):he=e[34],f=he;const xe=async function(S){S.archived&&!(await x(S.name,!1)).ok||(m(S.name),f())},be=async function(S){var ue;(await x(S,!0)).ok&&((ue=k.current)==null||ue.focus())};d=ts,E=w,e[35]===Symbol.for("react.memo_cache_sentinel")?(N=I=>{y(I),I&&(j(""),_(!1))},e[35]=N):N=e[35];let re;e[36]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Q,{variant:"ghost",size:"xs","aria-label":"Switch browser",className:"max-w-40"}),e[36]=re):re=e[36];const pe=s.jsx(Wt,{running:(le==null?void 0:le.running)??!1}),Z=Ge(le,l);let oe;e[37]!==Z?(oe=s.jsx("span",{className:"truncate",children:Z}),e[37]=Z,e[38]=oe):oe=e[38];let fe;e[39]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(ks,{"data-icon":"inline-end",className:"opacity-60"}),e[39]=fe):fe=e[39],e[40]!==pe||e[41]!==oe?(A=s.jsxs(ss,{render:re,children:[pe,oe,fe]}),e[40]=pe,e[41]=oe,e[42]=A):A=e[42],u=ns,P="Browsers",$=k,M="flex max-h-[min(32rem,var(--available-height))] w-80 max-w-[calc(100vw-1rem)] flex-col overflow-hidden";const je=p&&!J?"Archived browsers":"Browsers";let ae;e[43]!==je?(ae=s.jsx("span",{className:"text-sm font-medium",children:je}),e[43]=je,e[44]=ae):ae=e[44];let me;e[45]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Close browser picker",onClick:f,children:s.jsx(Ze,{"data-icon":"inline-start"})}),e[45]=me):me=e[45];let te;e[46]!==ae?(te=s.jsxs("div",{className:"flex items-center justify-between pl-1",children:[ae,me]}),e[46]=ae,e[47]=te):te=e[47];let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=I=>j(I.target.value),e[48]=de):de=e[48];let ie;e[49]!==D?(ie=s.jsx(Ke,{ref:k,"aria-label":"Search browsers",placeholder:"Search browsers…",value:D,onChange:de}),e[49]=D,e[50]=ie):ie=e[50],e[51]!==te||e[52]!==ie?(z=s.jsxs("div",{className:"flex shrink-0 flex-col gap-2 p-2",children:[te,ie]}),e[51]=te,e[52]=ie,e[53]=z):z=e[53],e[54]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(ht,{}),e[54]=v):v=e[54],L="min-h-0 max-h-72 overflow-y-auto overscroll-contain p-1",Y="Browser list",b=[{label:"Recent browsers",sessions:U,archived:!1},{label:"Archived browsers",sessions:C,archived:!0}].filter(rn).map(I=>s.jsxs("div",{children:[I.archived&&!!J&&s.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Archived"}),s.jsx("ul",{"aria-label":I.label,children:I.sessions.map(S=>s.jsx(on,{session:S,archived:I.archived,home:r,selected:l,currentSessionId:a,busy:c,onPick:xe,onArchive:be},S.name))})]},I.label)),e[0]=c,e[1]=a,e[2]=r,e[3]=m,e[4]=x,e[5]=w,e[6]=D,e[7]=l,e[8]=t,e[9]=p,e[10]=u,e[11]=d,e[12]=g,e[13]=f,e[14]=L,e[15]=N,e[16]=A,e[17]=Y,e[18]=b,e[19]=P,e[20]=$,e[21]=M,e[22]=z,e[23]=v,e[24]=E,e[25]=C,e[26]=U}else u=e[10],d=e[11],g=e[12],f=e[13],L=e[14],N=e[15],A=e[16],Y=e[17],b=e[18],P=e[19],$=e[20],M=e[21],z=e[22],v=e[23],E=e[24],C=e[25],U=e[26];let F;e[55]!==C||e[56]!==U.length?(F=U.length===0&&C.length===0&&s.jsx("p",{role:"status",className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No browsers found."}),e[55]=C,e[56]=U.length,e[57]=F):F=e[57];let V;e[58]!==L||e[59]!==F||e[60]!==Y||e[61]!==b?(V=s.jsxs("div",{className:L,"aria-label":Y,children:[b,F]}),e[58]=L,e[59]=F,e[60]=Y,e[61]=b,e[62]=V):V=e[62];let K;e[63]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(ht,{}),e[63]=K):K=e[63];let R;e[64]!==g.length||e[65]!==p?(R=(g.length>0||p)&&s.jsxs(Q,{variant:"ghost",size:"sm",className:"w-full justify-start","aria-expanded":p,onClick:()=>{_(!p),j("")},children:[p?s.jsx(Ht,{"data-icon":"inline-start"}):s.jsx(Gt,{"data-icon":"inline-start"}),p?"Back to recent":"Archived",!p&&s.jsx(Ye,{variant:"secondary",children:g.length})]}),e[64]=g.length,e[65]=p,e[66]=R):R=e[66];let B;e[67]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("p",{className:"px-1 pb-1 text-xs text-muted-foreground",children:"Stopped browsers archive after 24h of inactivity. Saved logins are kept."}),e[67]=B):B=e[67];let O;e[68]!==h||e[69]!==f?(O=h(f),e[68]=h,e[69]=f,e[70]=O):O=e[70];let q;e[71]!==R||e[72]!==O?(q=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1 p-2",children:[R,B,O]}),e[71]=R,e[72]=O,e[73]=q):q=e[73];let H;e[74]!==u||e[75]!==V||e[76]!==q||e[77]!==P||e[78]!==$||e[79]!==M||e[80]!==z||e[81]!==v?(H=s.jsxs(u,{"aria-label":P,initialFocus:$,className:M,children:[z,v,V,K,q]}),e[74]=u,e[75]=V,e[76]=q,e[77]=P,e[78]=$,e[79]=M,e[80]=z,e[81]=v,e[82]=H):H=e[82];let X;return e[83]!==d||e[84]!==N||e[85]!==A||e[86]!==H||e[87]!==E?(X=s.jsxs(d,{open:E,onOpenChange:N,children:[A,H]}),e[83]=d,e[84]=N,e[85]=A,e[86]=H,e[87]=E,e[88]=X):X=e[88],X}function rn(n){return n.sessions.length>0}function on(n){const e=ge.c(53),{session:t,archived:l,home:r,selected:a,currentSessionId:c,busy:m,onPick:x,onArchive:h}=n;let w;e[0]!==t.lastUsedAt?(w=nn(t.lastUsedAt),e[0]=t.lastUsedAt,e[1]=w):w=e[1];const y=w;let D;e[2]!==t?(D=Ge(t,t.name),e[2]=t,e[3]=D):D=e[3];const j=D,p=t.running&&t.driverSessionId!==null&&t.driverSessionId!==c,_=t.isDefault?r===t.name?"Default":"Host default":null,k=`${l?"Restore and switch to":"Switch to"} ${j}`,u=t.name===a?"true":void 0;let d;e[4]!==x||e[5]!==t?(d=()=>void x(t),e[4]=x,e[5]=t,e[6]=d):d=e[6];let g;e[7]!==t.running?(g=s.jsx(Wt,{running:t.running}),e[7]=t.running,e[8]=g):g=e[8];let f;e[9]!==j?(f=s.jsx("span",{className:"truncate",children:j}),e[9]=j,e[10]=f):f=e[10];const L=t.running?"running":"stopped";let N;e[11]!==L?(N=s.jsx("span",{className:"sr-only",children:L}),e[11]=L,e[12]=N):N=e[12];let A;e[13]!==_?(A=_&&s.jsx(Ye,{variant:"secondary",children:_}),e[13]=_,e[14]=A):A=e[14];let Y;e[15]!==t?(Y=He(t)==="watch"&&s.jsx(Ye,{variant:"outline",children:"View only"}),e[15]=t,e[16]=Y):Y=e[16];let b;e[17]!==y?(b=y&&s.jsx("span",{className:"ml-auto shrink-0 text-xs font-normal text-muted-foreground",children:y}),e[17]=y,e[18]=b):b=e[18];let P;e[19]!==A||e[20]!==Y||e[21]!==b||e[22]!==f||e[23]!==N?(P=s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[f,N,A,Y,b]}),e[19]=A,e[20]=Y,e[21]=b,e[22]=f,e[23]=N,e[24]=P):P=e[24];let $;e[25]!==p?($=p&&s.jsx("span",{className:"max-w-full truncate text-xs font-normal text-muted-foreground",children:"driven by another session"}),e[25]=p,e[26]=$):$=e[26];let M;e[27]!==P||e[28]!==$?(M=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col items-start gap-0.5",children:[P,$]}),e[27]=P,e[28]=$,e[29]=M):M=e[29];let z;e[30]!==a||e[31]!==t.name?(z=t.name===a&&s.jsx(dt,{"data-icon":"inline-end"}),e[30]=a,e[31]=t.name,e[32]=z):z=e[32];let v;e[33]!==l?(v=l&&s.jsx(vs,{"data-icon":"inline-end"}),e[33]=l,e[34]=v):v=e[34];let E;e[35]!==m||e[36]!==M||e[37]!==z||e[38]!==v||e[39]!==k||e[40]!==u||e[41]!==d||e[42]!==g?(E=s.jsxs(Q,{variant:"ghost",className:"h-auto min-h-10 min-w-0 flex-1 justify-start px-2 py-2","aria-label":k,"aria-current":u,disabled:m,onClick:d,children:[g,M,z,v]}),e[35]=m,e[36]=M,e[37]=z,e[38]=v,e[39]=k,e[40]=u,e[41]=d,e[42]=g,e[43]=E):E=e[43];let C;e[44]!==l||e[45]!==m||e[46]!==r||e[47]!==h||e[48]!==t?(C=!l&&!t.isDefault&&t.name!==r&&!t.running&&He(t)==="own"&&s.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":`Archive ${t.name}`,title:`Archive ${t.name}`,disabled:m,onClick:()=>void h(t.name),children:s.jsx(Gt,{"data-icon":"inline-start"})}),e[44]=l,e[45]=m,e[46]=r,e[47]=h,e[48]=t,e[49]=C):C=e[49];let U;return e[50]!==E||e[51]!==C?(U=s.jsxs("li",{className:"group flex items-center gap-1 rounded-md",children:[E,C]}),e[50]=E,e[51]=C,e[52]=U):U=e[52],U}const an=/^[a-z0-9][a-z0-9_-]{0,39}$/,cn="Lowercase letters, numbers, - and _, starting with a letter or number (40 max).",un=o.memo(function(e){const t=ge.c(112),{sessions:l,selected:r,home:a,currentSessionId:c,followAgent:m,busy:x,onSelect:h,onToggleFollow:w,onOpenSkill:y,onCreate:D,onRemove:j,onStop:p,onSetArchived:_,onShowDefault:k,onClose:u}=e,d=x===void 0?!1:x,g=o.useId(),f=o.useId(),[L,N]=o.useState(!1),[A,Y]=o.useState(""),[b,P]=o.useState(""),[$,M]=o.useState(null),[z,v]=o.useState(!1),[E,C]=o.useState(null),U=r===a;let F,V;t[0]!==r||t[1]!==l?(F=l.find(se=>se.name===r)??null,V=He(F),t[0]=r,t[1]=l,t[2]=F,t[3]=V):(F=t[2],V=t[3]);const K=V;let R;if(t[4]!==a||t[5]!==l){let se;t[7]!==a?(se=Pe=>Pe.mine&&Pe.name===a,t[7]=a,t[8]=se):se=t[8],R=l.some(se),t[4]=a,t[5]=l,t[6]=R}else R=t[6];const B=R,O=!U&&!(F!=null&&F.isDefault)&&K!=="watch",q=!U&&!(F!=null&&F.isDefault)&&K==="own";let H,X;t[9]!==A?(X=A.trim(),H=X.length>0&&!an.test(X),t[9]=A,t[10]=H,t[11]=X):(H=t[10],X=t[11]);const ne=H,le=ne?cn:$,J=X.length>0&&!ne&&!z;let ee;t[12]===Symbol.for("react.memo_cache_sentinel")?(ee=function(){Y(""),P(""),M(null),v(!1),N(!0)},t[12]=ee):ee=t[12];const Se=ee;let ve;t[13]!==J||t[14]!==b||t[15]!==D||t[16]!==h||t[17]!==X?(ve=async function(){if(!J)return;v(!0);const Pe=await D(X,b.trim());if(v(!1),!Pe.ok){M(Pe.error);return}N(!1),h(X)},t[13]=J,t[14]=b,t[15]=D,t[16]=h,t[17]=X,t[18]=ve):ve=t[18];const ye=ve,Ne=!U&&"border-amber-500/40 bg-amber-500/10";let we;t[19]!==Ne?(we=_e("@container/browser-bar flex h-10 shrink-0 items-center gap-2 border-b px-2",Ne),t[19]=Ne,t[20]=we):we=t[20];let he;t[21]!==d||t[22]!==q||t[23]!==O||t[24]!==y||t[25]!==p||t[26]!==r||t[27]!==(F==null?void 0:F.running)?(he=se=>s.jsxs(s.Fragment,{children:[s.jsxs(Q,{variant:"outline",size:"sm",disabled:d,onClick:()=>{se(),Se()},children:[s.jsx(Cs,{"data-icon":"inline-start"}),"New browser…"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs(Q,{variant:"ghost",size:"xs",onClick:()=>{se(),y()},children:[s.jsx(ft,{"data-icon":"inline-start"}),"Agent skill…"]}),O&&s.jsxs(Q,{variant:"ghost",size:"xs",disabled:d||!(F!=null&&F.running),onClick:()=>{se(),p(r)},children:[s.jsx(Ns,{"data-icon":"inline-start"}),"Stop"]}),q&&s.jsxs(Q,{variant:"ghost",size:"xs",disabled:d,onClick:()=>{se(),C(r)},children:[s.jsx(bt,{"data-icon":"inline-start"}),"Delete…"]})]})]}),t[21]=d,t[22]=q,t[23]=O,t[24]=y,t[25]=p,t[26]=r,t[27]=F==null?void 0:F.running,t[28]=he):he=t[28];let xe;t[29]!==d||t[30]!==c||t[31]!==a||t[32]!==h||t[33]!==_||t[34]!==r||t[35]!==l||t[36]!==he?(xe=s.jsx(ln,{sessions:l,selected:r,home:a,currentSessionId:c,busy:d,onSelect:h,onSetArchived:_,children:he}),t[29]=d,t[30]=c,t[31]=a,t[32]=h,t[33]=_,t[34]=r,t[35]=l,t[36]=he,t[37]=xe):xe=t[37];let be;t[38]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx("span",{className:"flex-1"}),t[38]=be):be=t[38];let re;t[39]!==K?(re=K==="watch"&&s.jsxs(Ye,{variant:"outline",title:"Only someone who can interact with the session driving it can use it",children:[s.jsx(Es,{"data-icon":"inline-start"}),"View only"]}),t[39]=K,t[40]=re):re=t[40];let pe;t[41]!==B||t[42]!==U||t[43]!==k?(pe=!U&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{role:"status",className:"flex min-w-0 items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-300",children:[s.jsx(ut,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"sr-only @sm/browser-bar:not-sr-only @sm/browser-bar:whitespace-nowrap",children:B?"Not your browser":"Not the default browser"})]}),s.jsx(Q,{variant:"outline",size:"xs",onClick:k,children:B?"Show yours":"Show default"})]}),t[41]=B,t[42]=U,t[43]=k,t[44]=pe):pe=t[44];let Z;t[45]!==w?(Z=se=>w(se),t[45]=w,t[46]=Z):Z=t[46];let oe;t[47]!==m||t[48]!==Z?(oe=s.jsx(ls,{size:"sm","aria-label":"Follow agent",pressed:m,onPressedChange:Z,className:"text-muted-foreground data-pressed:text-foreground"}),t[47]=m,t[48]=Z,t[49]=oe):oe=t[49];let fe,je;t[50]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(Ts,{"data-icon":"inline-start"}),je=s.jsx("span",{className:"hidden @md/browser-bar:inline",children:"Follow"}),t[50]=fe,t[51]=je):(fe=t[50],je=t[51]);let ae;t[52]!==oe?(ae=s.jsxs(It,{render:oe,children:[fe,je]}),t[52]=oe,t[53]=ae):ae=t[53];let me;t[54]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Lt,{children:"Switch to whichever browser this session’s agent uses"}),t[54]=me):me=t[54];let te;t[55]!==ae?(te=s.jsxs(Bt,{children:[ae,me]}),t[55]=ae,t[56]=te):te=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(Ze,{"data-icon":"inline-start"}),t[57]=de):de=t[57];let ie;t[58]!==u?(ie=s.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"Close browser panel",onClick:u,children:de}),t[58]=u,t[59]=ie):ie=t[59];let I;t[60]!==ye?(I=se=>{se.preventDefault(),ye()},t[60]=ye,t[61]=I):I=t[61];let S;t[62]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(Ft,{children:[s.jsx(Pt,{children:"New browser"}),s.jsx($t,{children:"A named browser keeps its own cookies and logins, and stays out of the default one."})]}),t[62]=S):S=t[62];const ce=!!le;let ue;t[63]!==g?(ue=s.jsx(xt,{htmlFor:g,children:"Name"}),t[63]=g,t[64]=ue):ue=t[64];const Ae=!!le;let G;t[65]===Symbol.for("react.memo_cache_sentinel")?(G=se=>{Y(se.target.value),M(null)},t[65]=G):G=t[65];let i;t[66]!==g||t[67]!==A||t[68]!==Ae?(i=s.jsx(Ke,{id:g,autoFocus:!0,autoComplete:"off",spellCheck:!1,placeholder:"shop","aria-invalid":Ae,value:A,onChange:G}),t[66]=g,t[67]=A,t[68]=Ae,t[69]=i):i=t[69];let T;t[70]!==le?(T=s.jsx(rs,{children:le}),t[70]=le,t[71]=T):T=t[71];let W;t[72]!==ce||t[73]!==ue||t[74]!==i||t[75]!==T?(W=s.jsxs(pt,{"data-invalid":ce,children:[ue,i,T]}),t[72]=ce,t[73]=ue,t[74]=i,t[75]=T,t[76]=W):W=t[76];let ke;t[77]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"}),t[77]=ke):ke=t[77];let Ce;t[78]!==f?(Ce=s.jsxs(xt,{htmlFor:f,children:["Note ",ke]}),t[78]=f,t[79]=Ce):Ce=t[79];let De;t[80]===Symbol.for("react.memo_cache_sentinel")?(De=se=>P(se.target.value),t[80]=De):De=t[80];let Te;t[81]!==b||t[82]!==f?(Te=s.jsx(Ke,{id:f,autoComplete:"off",placeholder:"What this browser is signed in to",value:b,onChange:De}),t[81]=b,t[82]=f,t[83]=Te):Te=t[83];let Ee;t[84]!==Ce||t[85]!==Te?(Ee=s.jsxs(pt,{children:[Ce,Te]}),t[84]=Ce,t[85]=Te,t[86]=Ee):Ee=t[86];let Oe;t[87]!==W||t[88]!==Ee?(Oe=s.jsxs(os,{className:"gap-4",children:[W,Ee]}),t[87]=W,t[88]=Ee,t[89]=Oe):Oe=t[89];let ze;t[90]===Symbol.for("react.memo_cache_sentinel")?(ze=s.jsx(Mt,{render:s.jsx(Q,{type:"button",variant:"outline"}),children:"Cancel"}),t[90]=ze):ze=t[90];const Qe=!J;let Ie;t[91]!==Qe?(Ie=s.jsxs(zt,{children:[ze,s.jsx(Q,{type:"submit",disabled:Qe,children:"Create browser"})]}),t[91]=Qe,t[92]=Ie):Ie=t[92];let Le;t[93]!==I||t[94]!==Oe||t[95]!==Ie?(Le=s.jsx(Ut,{className:"sm:max-w-sm",children:s.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[S,Oe,Ie]})}),t[93]=I,t[94]=Oe,t[95]=Ie,t[96]=Le):Le=t[96];let Be;t[97]!==L||t[98]!==Le?(Be=s.jsx(Kt,{open:L,onOpenChange:N,children:Le}),t[97]=L,t[98]=Le,t[99]=Be):Be=t[99];let Fe;t[100]!==E||t[101]!==j?(Fe=E!==null&&s.jsx(as,{open:!0,onOpenChange:se=>{se||C(null)},children:s.jsxs(is,{size:"sm",children:[s.jsxs(cs,{children:[s.jsx(us,{className:"bg-destructive/10 text-destructive",children:s.jsx(bt,{})}),s.jsxs(ds,{children:["Delete ",E,"?"]}),s.jsx(fs,{children:"Its profile goes with it, so everything signed in there is signed out. Other browsers are untouched."})]}),s.jsxs(ms,{children:[s.jsx(hs,{size:"sm",children:"Cancel"}),s.jsx(xs,{variant:"destructive",size:"sm",onClick:()=>{j(E),C(null)},children:"Delete browser"})]})]})}),t[100]=E,t[101]=j,t[102]=Fe):Fe=t[102];let Ue;return t[103]!==xe||t[104]!==re||t[105]!==pe||t[106]!==te||t[107]!==ie||t[108]!==Be||t[109]!==Fe||t[110]!==we?(Ue=s.jsxs("div",{className:we,children:[xe,be,re,pe,te,ie,Be,Fe]}),t[103]=xe,t[104]=re,t[105]=pe,t[106]=te,t[107]=ie,t[108]=Be,t[109]=Fe,t[110]=we,t[111]=Ue):Ue=t[111],Ue});function dn(n){const e=ge.c(36),{open:t,onOpenChange:l,readTargets:r,install:a}=n,[c,m]=o.useState(null),[x,h]=o.useState(null),[w,y]=o.useState(null);let D;e[0]!==r?(D=async()=>{const C=await r();C.ok?(m(C.targets),h(null)):h(C.error)},e[0]=r,e[1]=D):D=e[1];const j=D;let p,_;e[2]!==j||e[3]!==t?(p=()=>{t&&(h(null),j())},_=[t,j],e[2]=j,e[3]=t,e[4]=p,e[5]=_):(p=e[4],_=e[5]),o.useEffect(p,_);let k;e[6]!==a||e[7]!==j?(k=async function(U){y(U);const F=await a(U);y(null),F.ok?await j():h(F.error)},e[6]=a,e[7]=j,e[8]=k):k=e[8];const u=k;let d;e[9]!==c?(d=(c==null?void 0:c.some(fn))??!1,e[9]=c,e[10]=d):d=e[10];const g=d;let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Pt,{children:"Agent skill"}),e[11]=f):f=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsxs(Ft,{children:[f,s.jsxs($t,{children:["The skill teaches an agent how Cogpit’s browsers work: when to use a named one, when to keep to a throwaway, and that this panel is watching. Install it for agents you run outside Cogpit — it writes a"," ",s.jsx("code",{className:"font-mono",children:"SKILL.md"})," into that CLI’s configuration directory in your home folder."]})]}),e[12]=L):L=e[12];let N;e[13]!==x?(N=x&&s.jsx("p",{role:"alert",className:"text-sm text-destructive",children:x}),e[13]=x,e[14]=N):N=e[14];let A;e[15]!==w||e[16]!==u||e[17]!==c?(A=c===null?s.jsxs("div",{role:"status",className:"flex items-center gap-2 py-4 text-sm text-muted-foreground",children:[s.jsx(it,{}),"Reading where it is installed…"]}):s.jsx("ul",{className:"flex flex-col gap-2",children:c.map(C=>s.jsxs("li",{className:"flex items-center gap-3 rounded-md border p-2.5",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:C.label}),s.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:C.configRoot}),C.automatic&&s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:"Already automatic in the sessions Cogpit starts"})]}),C.installed?s.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(dt,{"aria-hidden":!0,className:"size-3.5 text-emerald-500"}),"Installed"]}):s.jsx(Q,{size:"xs",variant:"outline","aria-label":`Install for ${C.label}`,disabled:w!==null,onClick:()=>void u(C.kind),children:"Install"})]},C.kind))}),e[15]=w,e[16]=u,e[17]=c,e[18]=A):A=e[18];const Y=!g||w!==null;let b;e[19]!==u?(b=()=>void u(_s),e[19]=u,e[20]=b):b=e[20];let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(ft,{"data-icon":"inline-start"}),e[21]=P):P=e[21];let $;e[22]!==Y||e[23]!==b?($=s.jsxs(Q,{variant:"outline",disabled:Y,onClick:b,children:[P,"Install for all"]}),e[22]=Y,e[23]=b,e[24]=$):$=e[24];let M;e[25]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Mt,{render:s.jsx(Q,{type:"button"}),children:"Done"}),e[25]=M):M=e[25];let z;e[26]!==$?(z=s.jsxs(zt,{children:[$,M]}),e[26]=$,e[27]=z):z=e[27];let v;e[28]!==z||e[29]!==N||e[30]!==A?(v=s.jsxs(Ut,{className:"sm:max-w-md",children:[L,N,A,z]}),e[28]=z,e[29]=N,e[30]=A,e[31]=v):v=e[31];let E;return e[32]!==l||e[33]!==t||e[34]!==v?(E=s.jsx(Kt,{open:t,onOpenChange:l,children:v}),e[32]=l,e[33]=t,e[34]=v,e[35]=E):E=e[35],E}function fn(n){return!n.installed}const mn={x:0,y:0,width:0,height:0,scale:0};function hn(n,e){if(n.width<=0||n.height<=0||e.width<=0||e.height<=0)return mn;const t=Math.min(1,n.width/e.width,n.height/e.height),l=e.width*t,r=e.height*t;return{x:Math.round((n.width-l)/2),y:Math.round((n.height-r)/2),width:l,height:r,scale:t}}function Ct(n,e,t,l,r={}){if(l.scale<=0||l.width<=0||l.height<=0)return null;const a=n-t.left-l.x,c=e-t.top-l.y;return!(a>=0&&c>=0&&a<=l.width&&c<=l.height)&&!r.clamp?null:{x:Nt(a/l.scale,l.width/l.scale),y:Nt(c/l.scale,l.height/l.scale)}}function Nt(n,e){return Math.min(Math.max(n,0),e)}const xn=1,pn=2,gn=4,wn=8;function Re(n){return(n.altKey?xn:0)|(n.ctrlKey?pn:0)|(n.metaKey?gn:0)|(n.shiftKey?wn:0)}const bn=["left","middle","right"];function Et(n){return bn[n]??"left"}const yn=150,Tt=2,jn=500,Dt=5,Sn=1,kn=2,vn=16,Cn="Keyboard captured · Esc to release",Nn=new Set(["F5","F11","F12"]),En=new Set(["i","j","c"]);function _t(n){return Nn.has(n.key)||n.metaKey?!0:n.ctrlKey&&n.shiftKey&&En.has(n.key.toLowerCase())}function Tn(n){if(!(n.ctrlKey||n.metaKey))return n.key.length===1?n.key:n.key==="Enter"?"\r":void 0}function At(n,e,t){return e===Sn?n*vn:e===kn?n*t:n}function Dn(n,e,t){try{n.drawImage(e,t.x,t.y,t.width,t.height)}catch{}}function _n(n){const e=ge.c(82),{frame:t,send:l,onSizeChange:r,readOnly:a,className:c}=n,m=a===void 0?!1:a,x=o.useRef(null),h=o.useRef(null),w=o.useRef(null),y=o.useRef(null),D=o.useRef(!1);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={count:0,at:0,x:0,y:0,button:-1},e[0]=j):j=e[0];const p=o.useRef(j);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_=new Map,e[1]=_):_=e[1];const k=o.useRef(_);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={width:0,height:0,dpr:1},e[2]=u):u=e[2];const[d,g]=o.useState(u),[f,L]=o.useState(!1),N=t?t.header.deviceWidth:0,A=t?t.header.deviceHeight:0;let Y;e[3]!==A||e[4]!==N||e[5]!==d?(Y=hn(d,{width:N,height:A}),e[3]=A,e[4]=N,e[5]=d,e[6]=Y):Y=e[6];const b=Y,P=o.useRef(r);let $,M;e[7]!==r?($=()=>{P.current=r},M=[r],e[7]=r,e[8]=$,e[9]=M):($=e[8],M=e[9]),o.useEffect($,M);let z,v;e[10]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{const G=x.current;if(!G)return;let i=null;const T=()=>{const ke=G.getBoundingClientRect(),Ce=Math.round(ke.width),De=Math.round(ke.height),Te=window.devicePixelRatio||1;g(Ee=>Ee.width===Ce&&Ee.height===De&&Ee.dpr===Te?Ee:{width:Ce,height:De,dpr:Te}),i&&clearTimeout(i),i=setTimeout(()=>{i=null,Ce>0&&De>0&&P.current(Ce,De,Te)},yn)};T();const W=new ResizeObserver(T);return W.observe(G),()=>{W.disconnect(),i&&clearTimeout(i)}},v=[],e[10]=z,e[11]=v):(z=e[10],v=e[11]),o.useEffect(z,v);let E,C;e[12]!==b||e[13]!==t||e[14]!==d?(E=()=>{const G=h.current,i=G==null?void 0:G.getContext("2d");if(!G||!i)return;const T=Math.round(d.width*d.dpr),W=Math.round(d.height*d.dpr);G.width!==T&&(G.width=T),G.height!==W&&(G.height=W),i.setTransform(d.dpr,0,0,d.dpr,0,0),i.clearRect(0,0,d.width,d.height),!(!t||b.width<=0||b.height<=0)&&Dn(i,t.bitmap,b)},C=[t,b,d],e[12]=b,e[13]=t,e[14]=d,e[15]=E,e[16]=C):(E=e[15],C=e[16]),o.useEffect(E,C);let U,F;e[17]!==t?(U=()=>()=>at(t),F=[t],e[17]=t,e[18]=U,e[19]=F):(U=e[18],F=e[19]),o.useEffect(U,F);let V;e[20]!==b?(V=function(i,T,W){const ke=h.current;return ke?Ct(i,T,ke.getBoundingClientRect(),b,{clamp:W}):null},e[20]=b,e[21]=V):V=e[21];const K=V;let R;e[22]!==l?(R=function(i,T,W,ke,Ce){l({type:"mouse",event:i,x:T.x,y:T.y,button:W,clickCount:ke,modifiers:Ce})},e[22]=l,e[23]=R):R=e[23];const B=R;let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=function(i){const T=p.current,W=Date.now(),ke=i.button===T.button&&W-T.at<jn&&Math.abs(i.clientX-T.x)<=Dt&&Math.abs(i.clientY-T.y)<=Dt;return p.current={count:ke?T.count+1:1,at:W,x:i.clientX,y:i.clientY,button:i.button},p.current.count},e[24]=O):O=e[24];const q=O;let H;e[25]!==K||e[26]!==B?(H=function(){const i=w.current;if(w.current=null,!i)return;const T=K(i.clientX,i.clientY,D.current);T&&B("move",T,"none",0,i.modifiers)},e[25]=K,e[26]=B,e[27]=H):H=e[27];const X=H;let ne;e[28]!==X?(ne=function(){y.current!==null&&(cancelAnimationFrame(y.current),y.current=null),X()},e[28]=X,e[29]=ne):ne=e[29];const le=ne;let J;e[30]!==K||e[31]!==B?(J=function(i){if(i.currentTarget.focus(),i.button===Tt)return;const T=K(i.clientX,i.clientY,!1);T&&(i.currentTarget.setPointerCapture(i.pointerId),D.current=!0,B("down",T,Et(i.button),q(i),Re(i)))},e[30]=K,e[31]=B,e[32]=J):J=e[32];const ee=J;let Se;e[33]!==X?(Se=function(i){w.current={clientX:i.clientX,clientY:i.clientY,modifiers:Re(i)},y.current===null&&(y.current=requestAnimationFrame(()=>{y.current=null,X()}))},e[33]=X,e[34]=Se):Se=e[34];const ve=Se;let ye;e[35]!==le||e[36]!==K||e[37]!==B?(ye=function(i){le();const T=D.current;if(D.current=!1,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId),i.button===Tt)return;const W=K(i.clientX,i.clientY,T);W&&B("up",W,Et(i.button),p.current.count,Re(i))},e[35]=le,e[36]=K,e[37]=B,e[38]=ye):ye=e[38];const Ne=ye;let we;e[39]!==K||e[40]!==B?(we=function(i){i.preventDefault();const T=K(i.clientX,i.clientY,!1);if(!T)return;const W=Re(i);B("down",T,"right",1,W),B("up",T,"right",1,W)},e[39]=K,e[40]=B,e[41]=we):we=e[41];const he=we;let xe;e[42]!==l?(xe=function(i){if(i.key==="Escape"){i.currentTarget.blur();return}_t(i)||i.preventDefault();const T={type:"key",event:"down",key:i.key,code:i.code,modifiers:Re(i)},W=Tn(i);W!==void 0&&(T.text=W),k.current.set(i.code,i.key),l(T)},e[42]=l,e[43]=xe):xe=e[43];const be=xe;let re;e[44]!==l?(re=function(i){i.key!=="Escape"&&(_t(i)||i.preventDefault(),k.current.delete(i.code),l({type:"key",event:"up",key:i.key,code:i.code,modifiers:Re(i)}))},e[44]=l,e[45]=re):re=e[45];const pe=re;let Z,oe;e[46]!==A||e[47]!==N||e[48]!==b||e[49]!==m||e[50]!==l?(Z=()=>{const G=h.current;if(!G||m)return;const i=T=>{T.preventDefault();const W=Ct(T.clientX,T.clientY,G.getBoundingClientRect(),b);W&&l({type:"wheel",x:W.x,y:W.y,deltaX:At(T.deltaX,T.deltaMode,N),deltaY:At(T.deltaY,T.deltaMode,A),modifiers:Re(T)})};return G.addEventListener("wheel",i,{passive:!1}),()=>G.removeEventListener("wheel",i)},oe=[l,b,N,A,m],e[46]=A,e[47]=N,e[48]=b,e[49]=m,e[50]=l,e[51]=Z,e[52]=oe):(Z=e[51],oe=e[52]),o.useEffect(Z,oe);let fe,je;e[53]!==f||e[54]!==l?(fe=()=>{if(!f)return;const G=i=>{var W;const T=(W=i.clipboardData)==null?void 0:W.getData("text/plain");T&&(i.preventDefault(),l({type:"paste",text:T}))};return document.addEventListener("paste",G),()=>document.removeEventListener("paste",G)},je=[f,l],e[53]=f,e[54]=l,e[55]=fe,e[56]=je):(fe=e[55],je=e[56]),o.useEffect(fe,je);let ae,me;e[57]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>()=>{y.current!==null&&cancelAnimationFrame(y.current)},me=[],e[57]=ae,e[58]=me):(ae=e[57],me=e[58]),o.useEffect(ae,me);let te;e[59]!==l?(te=()=>{for(const[G,i]of k.current)l({type:"key",event:"up",key:i,code:G,modifiers:0});k.current.clear()},e[59]=l,e[60]=te):te=e[60];const de=te;let ie,I;e[61]!==de?(ie=()=>de,I=[de],e[61]=de,e[62]=ie,e[63]=I):(ie=e[62],I=e[63]),o.useEffect(ie,I);let S;e[64]!==c?(S=_e("relative min-h-0 min-w-0 overflow-hidden bg-muted/30",c),e[64]=c,e[65]=S):S=e[65];let ce;e[66]!==f||e[67]!==he||e[68]!==be||e[69]!==pe||e[70]!==ee||e[71]!==ve||e[72]!==Ne||e[73]!==m||e[74]!==de?(ce=m?s.jsx("canvas",{ref:h,role:"img","aria-label":"Browser viewport, view only",className:"block size-full cursor-default touch-none select-none"}):s.jsx("canvas",{ref:h,role:"application","aria-label":"Browser viewport",tabIndex:0,className:_e("block size-full cursor-default touch-none select-none outline-none",f&&"ring-2 ring-ring ring-inset"),onFocus:()=>L(!0),onBlur:()=>{L(!1),de()},onPointerDown:ee,onPointerMove:ve,onPointerUp:Ne,onPointerCancel:Ne,onContextMenu:he,onKeyDown:be,onKeyUp:pe}),e[66]=f,e[67]=he,e[68]=be,e[69]=pe,e[70]=ee,e[71]=ve,e[72]=Ne,e[73]=m,e[74]=de,e[75]=ce):ce=e[75];let ue;e[76]!==f?(ue=f&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-2 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-popover px-2 py-0.5 text-[10px] text-muted-foreground shadow-xs",children:Cn})}),e[76]=f,e[77]=ue):ue=e[77];let Ae;return e[78]!==S||e[79]!==ce||e[80]!==ue?(Ae=s.jsxs("div",{ref:x,className:S,children:[ce,ue]}),e[78]=S,e[79]=ce,e[80]=ue,e[81]=Ae):Ae=e[81],Ae}const An="browser-panel-session",Rn="browser-panel-follow",On=1e4,Rt=3e3,In=[];function Yn({context:n,active:e,closePanel:t}){var ie,I;const[l,r]=gt(wt(An),ct),[a,c]=gt(wt(Rn),!0),[m,x]=o.useState(!1),[h,w]=o.useState(null),[y,D]=o.useState(null),[j,p]=o.useState(!1),_=o.useRef(0),{status:k,error:u,refresh:d,create:g,remove:f,stop:L,setArchived:N,readSkillTargets:A,installSkill:Y}=As(e),b=(k==null?void 0:k.sessions)??In,P=en(b),$=k!==null&&b.length>0,M=k===null||b.some(S=>S.name===l)?l:P,z=o.useCallback(S=>void Ot(S),[]),v=zs(e&&$?M:null,z),E=((ie=n.session)==null?void 0:ie.sessionId)??null,C=o.useMemo(()=>ps(n.session),[n.session]),U=sn((C==null?void 0:C.session)??null,b,E),F=b.some(S=>S.name===U&&!S.archived);o.useEffect(()=>{!a||U===null||U===M||!F||Date.now()-_.current<On||r(U)},[a,U,F,M,r]);const V=o.useCallback(S=>{_.current=Date.now(),r(S)},[r]),K=o.useCallback(async S=>{x(!0);try{const ce=await S();return w(ce.ok?null:ce.error),ce}finally{x(!1)}},[]),{send:R}=v,B=o.useCallback((S,ce,ue)=>{R({type:"viewport",width:S,height:ce,dpr:ue})},[R]),O=o.useCallback(S=>{S&&(_.current=0),c(S)},[c]),q=o.useCallback(()=>V(P),[V,P]),H=o.useCallback(()=>p(!0),[]),X=o.useCallback(S=>{V(P),K(()=>f(S))},[V,P,K,f]),ne=o.useCallback(S=>void K(()=>L(S)),[K,L]),le=o.useCallback(async(S,ce)=>{const ue=await K(()=>N(S,ce));return ue.ok&&ce&&S===M&&V(P),ue},[K,N,M,V,P]),J=o.useCallback(S=>R({type:"navigate",url:S}),[R]),ee=o.useCallback(()=>R({type:"back"}),[R]),Se=o.useCallback(()=>R({type:"forward"}),[R]),ve=o.useCallback(()=>R({type:"reload"}),[R]),ye=o.useCallback(S=>R({type:"follow",targetId:S}),[R]),Ne=o.useCallback(S=>R({type:"close-tab",targetId:S}),[R]),we=o.useCallback(S=>R({type:"launch",url:S}),[R]),he=Ln(v.lastFrameAt),xe=((I=v.state)==null?void 0:I.state)??null,be=(k==null?void 0:k.installed)===!1||xe==="not-installed",re=!be&&xe==="live",pe=!be&&xe==="stopped",Z=b.find(S=>S.name===M)??null,oe=Ge(Z,M),fe=tn(Z),je=(Z==null?void 0:Z.mine)===!0&&!Z.running&&Z.lastUsedAt===null,ae=re&&(v.status==="disconnected"||v.status==="connecting"),me=k===null&&u!==null,te=v.error??h??(me?null:u),de=te!==null&&te!==y?te:null;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(un,{sessions:b,selected:M,home:P,currentSessionId:E,followAgent:a,busy:m,onSelect:V,onToggleFollow:O,onOpenSkill:H,onCreate:g,onRemove:X,onStop:ne,onSetArchived:le,onShowDefault:q,onClose:t}),re&&s.jsx(qs,{page:v.page,tabs:v.tabs,followed:v.followed,status:ae?"offline":he,readOnly:!fe,onNavigate:J,onBack:ee,onForward:Se,onReload:ve,onFollow:ye,onCloseTab:Ne}),de&&s.jsx(Pn,{message:de,onDismiss:()=>{w(null),D(te)}}),s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[me&&s.jsx(Ws,{message:u,onRetry:d}),be&&s.jsx(Gs,{onOpenSkill:H}),!be&&k!==null&&!$&&s.jsx(kt,{}),pe&&(je?s.jsx(kt,{onOpen:we}):s.jsx(Xs,{name:oe,lastUrl:(Z==null?void 0:Z.lastUrl)??null,onOpen:fe?we:void 0})),re&&s.jsxs(s.Fragment,{children:[s.jsx(_n,{className:"flex-1",frame:v.frame,send:R,onSizeChange:B,readOnly:!fe}),ae&&s.jsx(Fn,{}),s.jsx(Ys,{activity:C&&U===M?C:null})]}),!be&&!me&&(k===null||$)&&!pe&&!re&&s.jsxs("div",{role:"status",className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(it,{}),"Connecting to ",oe,"…"]})]}),s.jsx(dn,{open:j,onOpenChange:p,readTargets:A,install:Y})]})}function Ln(n){const e=ge.c(5),[,t]=o.useState(0);let l;e[0]!==t||e[1]!==n?(l=()=>{if(n===null)return;const a=n+Rt-Date.now();if(a<=0)return;const c=setTimeout(()=>t(Bn),a);return()=>clearTimeout(c)},e[0]=t,e[1]=n,e[2]=l):l=e[2];let r;return e[3]!==n?(r=[n],e[3]=n,e[4]=r):r=e[4],o.useEffect(l,r),n===null?"idle":Date.now()-n<Rt?"live":"idle"}function Bn(n){return n+1}function Fn(){const n=ge.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex justify-center p-2",children:s.jsx("span",{role:"status",className:"rounded-full bg-popover px-2.5 py-0.5 text-[11px] text-muted-foreground shadow-xs",children:"Reconnecting…"})}),n[0]=e):e=n[0],e}function Pn(n){const e=ge.c(9),{message:t,onDismiss:l}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(ut,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),e[0]=r):r=e[0];let a;e[1]!==t?(a=s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),e[1]=t,e[2]=a):a=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(Ze,{"data-icon":"inline-start"}),e[3]=c):c=e[3];let m;e[4]!==l?(m=s.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Dismiss",onClick:l,children:c}),e[4]=l,e[5]=m):m=e[5];let x;return e[6]!==a||e[7]!==m?(x=s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-2 py-1 text-xs text-destructive",children:[r,a,m]}),e[6]=a,e[7]=m,e[8]=x):x=e[8],x}export{Yn as BrowserPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as M,a as He,c as B,j as s}from"./vendor-react-gGw_S5I_.js";import{ap as We,U as Je,bF as Xe,B as V,b4 as Ze,aV as qe,A as Ce,b8 as et,bG as Oe,H as Ee,T as Ve,Z as Ae,bH as tt,bv as st,bu as nt,bt as it,bI as lt,bJ as ot,bK as at,bL as rt,J as xe,bM as ct,bN as dt,_ as ut,a1 as ft,bO as mt,bP as xt,bQ as ht,bR as gt,bS as pt,R as bt,bT as jt,L as wt,M as Nt,N as vt,O as yt,Q as St,af as It,p as _t,bU as Tt,bV as qt,q as Ct}from"./index-DsnL-sXV.js";import{b as kt,am as At,as as Qe,C as De,at as _e,ai as Et,au as Rt,aa as Mt,L as Lt,av as Ft,aw as Ot,a as $t,J as Dt}from"./vendor-ui-Br3ZTAXZ.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const zt=4e3;function Vt(){const o=We(),[e,t]=M.useState([]),[n,i]=M.useState(!1),[a,r]=M.useState(null),c=M.useRef(!1),d=M.useRef(o.key);M.useEffect(()=>(c.current=!1,()=>{c.current=!0}),[]),M.useLayoutEffect(()=>{d.current=o.key},[o.key]);const f=M.useCallback(async()=>{const b=()=>c.current||d.current!==o.key;try{const x=await Je(Xe("/api/mission-control",o));if(b())return;if(!x.ok)throw new Error(`Mission Control request failed (${x.status})`);const g=await x.json();if(b())return;t(Array.isArray(g.summaries)?g.summaries:[]),r(null)}catch(x){if(b())return;r(x instanceof Error?x.message:"Failed to load Mission Control")}finally{b()||i(!1)}},[o]);M.useEffect(()=>{i(!0);const b=()=>{(typeof document>"u"||document.visibilityState==="visible")&&f()},x=()=>{document.visibilityState==="visible"&&f()};b();const g=setInterval(b,zt);return document.addEventListener("visibilitychange",x),()=>{clearInterval(g),document.removeEventListener("visibilitychange",x)}},[f]);const m=M.useMemo(()=>{const b=new Map;for(const x of e)b.set(x.sessionId,x);return b},[e]),y=M.useCallback(()=>{f()},[f]);return{summaries:m,loading:n,error:a,refresh:y}}const Re="data-view-transition-kind",Ut="(prefers-reduced-motion: reduce)";let me=null,ze=null;function Yt(o,e,t){t===null?o.removeAttribute(e):o.setAttribute(e,t)}function Pt(o,e){const t={root:o,kind:e,previousKind:o.getAttribute(Re)};return o.setAttribute(Re,e),ze=t,t}function Te(o){ze===o&&(o.root.getAttribute(Re)===o.kind&&Yt(o.root,Re,o.previousKind),ze=null)}function Bt(){const o=me;if(o){me=null;try{o.transition.skipTransition()}catch{Te(o.tag);return}Te(o.tag)}}function Qt(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(Ut).matches}catch{return!1}}function Gt(o,{kind:e}){Bt();const t=typeof document>"u"?null:document,n=t==null?void 0:t.startViewTransition;if(!t||!(typeof n=="function")||Qt())return o(),null;const a=Pt(t.documentElement,e);let r=!1,c=!1,d;const f=m=>{if(!r){r=!0;try{m?He.flushSync(o):o()}catch(y){throw c=!0,d=y,y}}};try{const m=n.call(t,()=>f(!0)),y={transition:m,tag:a};return me=y,m.ready.catch(()=>{}),m.updateCallbackDone.catch(()=>{}),m.finished.then(()=>{me===y&&(me=null),Te(a)},()=>{me===y&&(me=null),Te(a)}),m}catch{if(Te(a),c)throw d;return f(!1),null}}function Kt(o){const e={};for(const t of o)t.type==="boolean"?e[t.name]=t.defaultValue===!0:t.defaultValue!==void 0?e[t.name]=String(t.defaultValue):e[t.name]="";return e}function Ht(o,e){const t={};for(const n of o){const i=e[n.name];if(typeof i=="boolean"){t[n.name]=i;continue}i!==""&&(t[n.name]=n.type==="number"||n.type==="integer"?Number(i):i)}return t}function Wt(o,e){return o.every(t=>{if(!t.required)return!0;const n=e[t.name];return typeof n=="boolean"?!0:n===""?!1:t.type==="number"||t.type==="integer"?Number.isFinite(Number(n)):!0})}function Jt(o){const e=B.c(52),{request:t,responding:n,onAnswer:i}=o;let a;e[0]!==t.fields?(a=()=>Kt(t.fields),e[0]=t.fields,e[1]=a):a=e[1];const[r,c]=M.useState(a);let d;e[2]!==t.fields||e[3]!==r?(d=Wt(t.fields,r),e[2]=t.fields,e[3]=r,e[4]=d):d=e[4];const f=d,m=t.displayName||t.title||t.serverName;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=(j,v)=>{c(p=>({...p,[j]:v}))},e[5]=y):y=e[5];const b=y;let x;e[6]!==i||e[7]!==t.requestId?(x=()=>i==null?void 0:i(t.requestId,{action:"decline"}),e[6]=i,e[7]=t.requestId,e[8]=x):x=e[8];const g=x;if(t.mode==="url"&&t.url){const j=t.url;let v;e[9]!==t.message?(v=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[9]=t.message,e[10]=v):v=e[10];let p;e[11]!==j?(p=s.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:j,children:j}),e[11]=j,e[12]=p):p=e[12];let w;e[13]!==g||e[14]!==i||e[15]!==t.requestId||e[16]!==n||e[17]!==j?(w=i&&s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs(V,{size:"sm",disabled:n,onClick:()=>{window.open(j,"_blank","noopener,noreferrer"),i(t.requestId,{action:"accept"})},children:["Open link",s.jsx(kt,{"data-icon":"inline-end"})]}),s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[13]=g,e[14]=i,e[15]=t.requestId,e[16]=n,e[17]=j,e[18]=w):w=e[18];let _;return e[19]!==m||e[20]!==v||e[21]!==p||e[22]!==w?(_=s.jsxs(Ye,{server:m,children:[v,p,w]}),e[19]=m,e[20]=v,e[21]=p,e[22]=w,e[23]=_):_=e[23],_}let l;e[24]!==t.message?(l=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[24]=t.message,e[25]=l):l=e[25];let h;if(e[26]!==i||e[27]!==t.fields||e[28]!==t.requestId||e[29]!==n||e[30]!==r){let j;e[32]!==i||e[33]!==t.requestId||e[34]!==n||e[35]!==r?(j=v=>s.jsx(Xt,{id:`elicit-${t.requestId}-${v.name}`,field:v,value:r[v.name],disabled:n||!i,onChange:p=>b(v.name,p)},v.name),e[32]=i,e[33]=t.requestId,e[34]=n,e[35]=r,e[36]=j):j=e[36],h=t.fields.map(j),e[26]=i,e[27]=t.fields,e[28]=t.requestId,e[29]=n,e[30]=r,e[31]=h}else h=e[31];let u;e[37]!==h?(u=s.jsx("div",{className:"mt-3 flex flex-col gap-3",children:h}),e[37]=h,e[38]=u):u=e[38];let S;e[39]!==f||e[40]!==g||e[41]!==i||e[42]!==t.fields||e[43]!==t.requestId||e[44]!==n||e[45]!==r?(S=i&&s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsx(V,{size:"sm",disabled:n||!f,onClick:()=>i(t.requestId,{action:"accept",content:Ht(t.fields,r)}),children:"Send"}),s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[39]=f,e[40]=g,e[41]=i,e[42]=t.fields,e[43]=t.requestId,e[44]=n,e[45]=r,e[46]=S):S=e[46];let I;return e[47]!==m||e[48]!==l||e[49]!==u||e[50]!==S?(I=s.jsxs(Ye,{server:m,children:[l,u,S]}),e[47]=m,e[48]=l,e[49]=u,e[50]=S,e[51]=I):I=e[51],I}function Xt(o){const e=B.c(55),{id:t,field:n,value:i,disabled:a,onChange:r}=o;if(n.type==="boolean"){const g=i===!0;let l;e[0]!==r?(l=I=>r(I===!0),e[0]=r,e[1]=l):l=e[1];let h;e[2]!==a||e[3]!==t||e[4]!==g||e[5]!==l?(h=s.jsx(et,{id:t,checked:g,disabled:a,onCheckedChange:l}),e[2]=a,e[3]=t,e[4]=g,e[5]=l,e[6]=h):h=e[6];let u;e[7]!==n?(u=s.jsx($e,{field:n}),e[7]=n,e[8]=u):u=e[8];let S;return e[9]!==t||e[10]!==h||e[11]!==u?(S=s.jsxs(Oe,{htmlFor:t,className:"items-start gap-2 font-normal",children:[h,u]}),e[9]=t,e[10]=h,e[11]=u,e[12]=S):S=e[12],S}if(n.type==="enum"){let g;e[13]!==n?(g=s.jsx($e,{field:n}),e[13]=n,e[14]=g):g=e[14];let l;e[15]!==t||e[16]!==g?(l=s.jsx(Oe,{htmlFor:t,children:g}),e[15]=t,e[16]=g,e[17]=l):l=e[17];let h;e[18]!==i?(h=typeof i=="string"&&i?[i]:[],e[18]=i,e[19]=h):h=e[19];let u;e[20]!==r?(u=w=>{w[0]&&r(w[0])},e[20]=r,e[21]=u):u=e[21];const S=n.label;let I;e[22]!==n.options?(I=n.options??[],e[22]=n.options,e[23]=I):I=e[23];let j;if(e[24]!==a||e[25]!==I){let w;e[27]!==a?(w=_=>s.jsx(Ee,{value:_.value,disabled:a,className:"w-full justify-start px-3",children:_.label},_.value),e[27]=a,e[28]=w):w=e[28],j=I.map(w),e[24]=a,e[25]=I,e[26]=j}else j=e[26];let v;e[29]!==n.label||e[30]!==t||e[31]!==h||e[32]!==u||e[33]!==j?(v=s.jsx(Ve,{id:t,value:h,onValueChange:u,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":S,children:j}),e[29]=n.label,e[30]=t,e[31]=h,e[32]=u,e[33]=j,e[34]=v):v=e[34];let p;return e[35]!==l||e[36]!==v?(p=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,v]}),e[35]=l,e[36]=v,e[37]=p):p=e[37],p}let c;e[38]!==n?(c=s.jsx($e,{field:n}),e[38]=n,e[39]=c):c=e[39];let d;e[40]!==t||e[41]!==c?(d=s.jsx(Oe,{htmlFor:t,children:c}),e[40]=t,e[41]=c,e[42]=d):d=e[42];const f=n.type==="string"?"text":"number",m=typeof i=="string"?i:"";let y;e[43]!==r?(y=g=>r(g.target.value),e[43]=r,e[44]=y):y=e[44];let b;e[45]!==a||e[46]!==n.label||e[47]!==t||e[48]!==f||e[49]!==m||e[50]!==y?(b=s.jsx(Ze,{id:t,"aria-label":n.label,type:f,value:m,disabled:a,onChange:y}),e[45]=a,e[46]=n.label,e[47]=t,e[48]=f,e[49]=m,e[50]=y,e[51]=b):b=e[51];let x;return e[52]!==d||e[53]!==b?(x=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[d,b]}),e[52]=d,e[53]=b,e[54]=x):x=e[54],x}function $e(o){const e=B.c(8),{field:t}=o;let n;e[0]!==t.required?(n=t.required&&s.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=t.required,e[1]=n):n=e[1];let i;e[2]!==t.description?(i=t.description&&s.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:t.description}),e[2]=t.description,e[3]=i):i=e[3];let a;return e[4]!==t.label||e[5]!==n||e[6]!==i?(a=s.jsxs("span",{className:"min-w-0",children:[t.label,n,i]}),e[4]=t.label,e[5]=n,e[6]=i,e[7]=a):a=e[7],a}function Ye(o){const e=B.c(8),{server:t,children:n}=o;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(At,{className:"text-info"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=s.jsxs(qe,{children:[t," needs input"]}),e[1]=t,e[2]=a):a=e[2];let r;e[3]!==n?(r=s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=r):r=e[4];let c;return e[5]!==a||e[6]!==r?(c=s.jsxs(Ce,{className:"border-info/40 bg-info/5",children:[i,a,r]}),e[5]=a,e[6]=r,e[7]=c):c=e[7],c}const Zt=["allow","allow_always","deny"],es=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function ts(o,e){return(o.availableDecisions??Zt).includes(e)}function ss(o){const e=B.c(22),{request:t,queued:n,responding:i,onRespond:a}=o;let r;if(e[0]!==a||e[1]!==n||e[2]!==t||e[3]!==i){let c;e[5]!==t?(c=S=>ts(t,S.decision),e[5]=t,e[6]=c):c=e[6];const d=es.filter(c);t.defaultToNo&&d.sort(is);const f=d.some(ns);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Qe,{className:"text-warning"}),e[7]=m):m=e[7];const y=t.title||`Allow ${t.toolName}?`;let b;e[8]!==y?(b=s.jsx("span",{className:"min-w-0 flex-1 truncate",children:y}),e[8]=y,e[9]=b):b=e[9];let x;e[10]!==n?(x=n>0&&s.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",n]}),e[10]=n,e[11]=x):x=e[11];let g;e[12]!==b||e[13]!==x?(g=s.jsxs(qe,{className:"flex min-w-0 items-center gap-2",children:[b,x]}),e[12]=b,e[13]=x,e[14]=g):g=e[14];let l;e[15]!==t.toolName?(l=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=l):l=e[16];let h;e[17]!==t.summary?(h=t.summary&&s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=h):h=e[18];let u;e[19]!==l||e[20]!==h?(u=s.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[l,h]}),e[19]=l,e[20]=h,e[21]=u):u=e[21],r=s.jsxs(Ce,{className:"border-warning/40 bg-warning/5",children:[m,g,u,a&&(f?s.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:d.map(S=>{const{decision:I,label:j,variant:v}=S;return s.jsx(V,{autoFocus:t.defaultToNo&&I==="deny",size:"xs",variant:v,disabled:i,onClick:()=>a(t.requestId,I),children:j},`${t.requestId}:${I}`)})}):s.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=a,e[1]=n,e[2]=t,e[3]=i,e[4]=r}else r=e[4];return r}function ns(o){return o.decision!=="allow_always"}function is(o,e){return+(e.decision==="deny")-+(o.decision==="deny")}function ls(o){return o.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function os(o){const e=B.c(64),{request:t,responding:n,gone:i,onAnswer:a,onOpenSession:r}=o,c=t.questions,[d,f]=M.useState(0);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const y=M.useRef(m);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=new Set,e[1]=b):b=e[1];const[x,g]=M.useState(b);if(c.length===0)return null;if(ls(c)){let N;e[2]!==c[0].question?(N=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c[0].question}),e[2]=c[0].question,e[3]=N):N=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(De,{"data-icon":"inline-end"}),e[4]=E):E=e[4];let T;e[5]!==r?(T=s.jsxs(V,{variant:"outline",size:"sm",onClick:r,className:"mt-3",children:["Open full question",E]}),e[5]=r,e[6]=T):T=e[6];let z;return e[7]!==N||e[8]!==T?(z=s.jsxs(Pe,{children:[N,T]}),e[7]=N,e[8]=T,e[9]=z):z=e[9],z}const l=c[d],h=n||!a;let u;e[10]!==l.question||e[11]!==d||e[12]!==a||e[13]!==c.length||e[14]!==t.toolUseId?(u=function(E){const T={...y.current,[l.question]:E};if(d+1<c.length){y.current=T,g(new Set),f(d+1);return}a==null||a(t.toolUseId,T)},e[10]=l.question,e[11]=d,e[12]=a,e[13]=c.length,e[14]=t.toolUseId,e[15]=u):u=e[15];const S=u;let I;e[16]!==l.header?(I=l.header&&s.jsx(Ae,{variant:"outline",className:"border-info/40 text-info",children:l.header}),e[16]=l.header,e[17]=I):I=e[17];let j;e[18]!==d||e[19]!==c.length?(j=c.length>1&&s.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[d+1," of ",c.length]}),e[18]=d,e[19]=c.length,e[20]=j):j=e[20];let v;e[21]!==I||e[22]!==j?(v=s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[I,j]}),e[21]=I,e[22]=j,e[23]=v):v=e[23];let p;e[24]!==l.question?(p=s.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:l.question,children:l.question}),e[24]=l.question,e[25]=p):p=e[25];let w;e[26]!==x?(w=[...x],e[26]=x,e[27]=w):w=e[27];let _;e[28]!==S||e[29]!==l.multiSelect?(_=N=>{l.multiSelect?g(new Set(N)):N[0]&&S(N[0])},e[28]=S,e[29]=l.multiSelect,e[30]=_):_=e[30];const $=l.multiSelect,L=l.question;let C;if(e[31]!==l.options||e[32]!==h){let N;e[34]!==h?(N=E=>s.jsx(as,{option:E,disabled:h},E.label),e[34]=h,e[35]=N):N=e[35],C=l.options.map(N),e[31]=l.options,e[32]=h,e[33]=C}else C=e[33];let q;e[36]!==l.multiSelect||e[37]!==l.question||e[38]!==C||e[39]!==w||e[40]!==_?(q=s.jsx(Ve,{value:w,onValueChange:_,multiple:$,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":L,children:C}),e[36]=l.multiSelect,e[37]=l.question,e[38]=C,e[39]=w,e[40]=_,e[41]=q):q=e[41];let Q;e[42]!==S||e[43]!==l.multiSelect||e[44]!==d||e[45]!==a||e[46]!==c.length||e[47]!==n||e[48]!==x?(Q=l.multiSelect&&a&&s.jsx(V,{size:"sm",disabled:n||x.size===0,onClick:()=>S(tt(x)),children:d+1<c.length?"Next":"Send"}),e[42]=S,e[43]=l.multiSelect,e[44]=d,e[45]=a,e[46]=c.length,e[47]=n,e[48]=x,e[49]=Q):Q=e[49];let U;e[50]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(De,{"data-icon":"inline-end"}),e[50]=U):U=e[50];let A;e[51]!==r?(A=s.jsxs(V,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto text-muted-foreground",children:["Open session",U]}),e[51]=r,e[52]=A):A=e[52];let F;e[53]!==Q||e[54]!==A?(F=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[Q,A]}),e[53]=Q,e[54]=A,e[55]=F):F=e[55];let O;e[56]!==i?(O=i&&s.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=i,e[57]=O):O=e[57];let D;return e[58]!==q||e[59]!==F||e[60]!==O||e[61]!==v||e[62]!==p?(D=s.jsxs(Pe,{children:[v,p,q,F,O]}),e[58]=q,e[59]=F,e[60]=O,e[61]=v,e[62]=p,e[63]=D):D=e[63],D}function as(o){const e=B.c(17),{option:t,disabled:n}=o;let i;e[0]!==t.label?(i=s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];const a=i;if(!t.description){let m;return e[2]!==n||e[3]!==a||e[4]!==t.label?(m=s.jsx(Ee,{value:t.label,disabled:n,className:"w-full justify-start px-3",children:a}),e[2]=n,e[3]=a,e[4]=t.label,e[5]=m):m=e[5],m}let r;e[6]!==n||e[7]!==t.label?(r=s.jsx(Ee,{value:t.label,disabled:n,className:"w-full justify-start px-3"}),e[6]=n,e[7]=t.label,e[8]=r):r=e[8];let c;e[9]!==a||e[10]!==r?(c=s.jsx(nt,{render:r,children:a}),e[9]=a,e[10]=r,e[11]=c):c=e[11];let d;e[12]!==t.description?(d=s.jsx(st,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==d?(f=s.jsxs(it,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=f):f=e[16],f}function Pe(o){const e=B.c(4),{children:t}=o;let n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(_e,{className:"text-info"}),i=s.jsx(qe,{children:"Answer to continue"}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let a;return e[2]!==t?(a=s.jsxs(Ce,{className:"border-info/40 bg-info/5",children:[n,i,s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=a):a=e[3],a}function rs(o){const e=B.c(15),{request:t,responding:n,onChoose:i}=o;let a,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(Qe,{className:"text-warning"}),r=s.jsx(qe,{children:"Claude declined this request"}),e[0]=a,e[1]=r):(a=e[0],r=e[1]);let c;e[2]!==t.originalModel?(c=s.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[t.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=t.originalModel,e[3]=c):c=e[3];let d;e[4]!==t.guidanceText?(d=t.guidanceText&&s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:t.guidanceText}),e[4]=t.guidanceText,e[5]=d):d=e[5];let f;e[6]!==i||e[7]!==t.fallbackModel||e[8]!==t.requestId||e[9]!==n?(f=i&&s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.jsxs(V,{size:"sm",disabled:n,onClick:()=>i(t.requestId,"retry_fallback"),children:["Retry on ",t.fallbackModel]}),s.jsx(V,{variant:"outline",size:"sm",disabled:n,onClick:()=>i(t.requestId,"edit_prompt"),children:"Edit prompt"}),s.jsx(V,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:()=>i(t.requestId,"cancelled"),children:"Dismiss"})]}),e[6]=i,e[7]=t.fallbackModel,e[8]=t.requestId,e[9]=n,e[10]=f):f=e[10];let m;return e[11]!==c||e[12]!==d||e[13]!==f?(m=s.jsxs(Ce,{className:"border-warning/40 bg-warning/5",children:[a,r,s.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[c,d,f]})]}),e[11]=c,e[12]=d,e[13]=f,e[14]=m):m=e[14],m}function cs(o){return o==="awaiting_approval"||o==="awaiting_prompt"||o==="awaiting_question"||o==="awaiting_answer"}function Ge(o){return o.canAnswer&&cs(o.state)}function Me(o){return o==="done"||o==="failed"}const Be={awaiting_approval:0,awaiting_prompt:1,awaiting_question:2,awaiting_answer:3,running:4,failed:5,done:6};function ds(o,e,t,n,i,a){return t?"awaiting_approval":n?"awaiting_prompt":i?"awaiting_question":a||o.agentStatus==="deferred"||o.agentStatus==="idle"&&e?"awaiting_answer":o.agentTerminalReason?"failed":e&&o.agentStatus&&at.has(o.agentStatus)?"running":"done"}const us=6;function fs({sessions:o,procBySession:e,summaries:t,permissionsBySession:n,questionsBySession:i,elicitationsBySession:a,dialogsBySession:r,awaitingPlan:c,newlyCompleted:d,canAnswer:f=()=>!0,finishedLimit:m=us,now:y=Date.now()}){const b=[];for(const l of lt(o)){const h=n.get(l.sessionId)??[],u=i.get(l.sessionId)??[],S=a.get(l.sessionId)??[],I=r.get(l.sessionId)??[],j=c.has(l.sessionId),v=h.length+u.length+S.length+I.length+Number(j);l.teamName&&l.agentName&&v===0||b.push({session:l,state:ds(l,ot(l,e,y),h.length>0,S.length>0||I.length>0,u.length>0,j),summary:t.get(l.sessionId)??null,permissions:h,questions:u,elicitations:S,dialogs:I,canAnswer:f(l)})}const x=b.filter(l=>Me(l.state)),g=[...x.filter(l=>d.has(l.session.sessionId)),...x.filter(l=>!d.has(l.session.sessionId))].slice(0,m);return[...b.filter(l=>!Me(l.state)),...g].sort((l,h)=>Be[l.state]-Be[h.state])}function ms(o,e){switch(e){case"running":return o.filter(t=>t.state==="running");case"needs-you":return o.filter(Ge);case"finished":return o.filter(t=>Me(t.state));default:return o}}function xs(o){const e={total:o.length,running:0,needsYou:0,finished:0,failed:0};for(const t of o)t.state==="running"&&e.running++,Ge(t)&&e.needsYou++,Me(t.state)&&e.finished++,t.state==="failed"&&e.failed++;return e}function hs(o){return o>=90?"text-destructive":o>=70?"text-warning":"text-muted-foreground"}const gs={awaiting_approval:{label:"Waiting for approval",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:_e},awaiting_prompt:{label:"Waiting for your input",text:"text-info",shell:"border-info/40 bg-info/5",icon:_e},awaiting_question:{label:"Waiting for your answer",text:"text-info",shell:"border-info/40 bg-info/5",icon:_e},awaiting_answer:{label:"Waiting for your answer",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:_e},running:{label:"Running",text:"text-info",shell:"border-border",icon:null},done:{label:"Done",text:"text-success",shell:"border-border",icon:Rt},failed:{label:"Failed",text:"text-destructive",shell:"border-destructive/40",icon:Et}};function ps(o){const e=B.c(3),{icon:t}=o;if(!t){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"size-2 shrink-0 rounded-full bg-info"}),e[0]=i):i=e[0],i}let n;return e[1]!==t?(n=s.jsx(t,{className:"size-3.5 shrink-0"}),e[1]=t,e[2]=n):n=e[2],n}const bs=M.memo(function(e){const t=B.c(99),{card:n,customName:i,projectLabel:a,responding:r,goneQuestions:c,compact:d,onOpen:f,onRespond:m,onAnswerQuestion:y,onAnswerElicitation:b,onChooseDialog:x}=e,g=d===void 0?!1:d,{session:l,state:h,summary:u,permissions:S,questions:I,elicitations:j,dialogs:v,canAnswer:p}=n,w=gs[h],_=S[0],$=I[0],L=j[0],C=v[0],q=!!(_||$||L||C);let Q;t[0]!==i||t[1]!==l?(Q=rt(l,i),t[0]=i,t[1]=l,t[2]=Q):Q=t[2];const U=Q,A=g&&"gap-1.5 py-2";let F;t[3]!==w.shell||t[4]!==A?(F=xe("motion-card motion-list-item group flex min-w-0 flex-col gap-2 rounded-lg border bg-card p-3 text-left transition-colors hover:border-foreground/20",w.shell,A),t[3]=w.shell,t[4]=A,t[5]=F):F=t[5];const O=`Open session ${U}`;let D;t[6]!==a?(D=s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:a}),t[6]=a,t[7]=D):D=t[7];let N;t[8]!==l.access?(N=s.jsx(ct,{access:l.access}),t[8]=l.access,t[9]=N):N=t[9];let E;t[10]!==u?(E=(u==null?void 0:u.model)&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:dt(u.model)}),t[10]=u,t[11]=E):E=t[11];let T;t[12]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(De,{"data-icon":"inline-end",className:"shrink-0 text-transparent transition-colors group-hover:text-muted-foreground"}),t[12]=T):T=t[12];let z;t[13]!==D||t[14]!==N||t[15]!==E?(z=s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[D,N,E,T]}),t[13]=D,t[14]=N,t[15]=E,t[16]=z):z=t[16];const G=g?"truncate":"line-clamp-2";let oe;t[17]!==G?(oe=xe("text-sm font-medium leading-snug text-foreground",G),t[17]=G,t[18]=oe):oe=t[18];let K;t[19]!==oe||t[20]!==U?(K=s.jsx("span",{className:oe,children:U}),t[19]=oe,t[20]=U,t[21]=K):K=t[21];let ae;t[22]!==f||t[23]!==z||t[24]!==K||t[25]!==O?(ae=s.jsxs(V,{variant:"ghost",onClick:f,className:"-m-1 h-auto min-w-0 flex-col items-stretch justify-start gap-1 whitespace-normal p-1 text-left","aria-label":O,children:[z,K]}),t[22]=f,t[23]=z,t[24]=K,t[25]=O,t[26]=ae):ae=t[26];let re;t[27]!==w.text?(re=xe("flex items-center gap-1.5 text-xs font-medium",w.text),t[27]=w.text,t[28]=re):re=t[28];let ce;t[29]!==w.icon?(ce=s.jsx(ps,{icon:w.icon}),t[29]=w.icon,t[30]=ce):ce=t[30];let le;t[31]!==w.label?(le=s.jsx("span",{className:"truncate",children:w.label}),t[31]=w.label,t[32]=le):le=t[32];const ue=l.lastActivityAt||l.lastModified;let H;t[33]!==ue?(H=ut(ue),t[33]=ue,t[34]=H):H=t[34];let de;t[35]!==H?(de=s.jsx("span",{className:"ml-auto shrink-0 font-mono text-xs font-normal text-muted-foreground",children:H}),t[35]=H,t[36]=de):de=t[36];let W;t[37]!==re||t[38]!==ce||t[39]!==le||t[40]!==de?(W=s.jsxs("div",{className:re,children:[ce,le,de]}),t[37]=re,t[38]=ce,t[39]=le,t[40]=de,t[41]=W):W=t[41];let J;t[42]!==p||t[43]!==m||t[44]!==S.length||t[45]!==_||t[46]!==r||t[47]!==l.sessionId?(J=_&&s.jsx(ss,{request:_,queued:S.length-1,responding:r.has(_.requestId),onRespond:p?(Y,P)=>m(l.sessionId,Y,P):void 0}),t[42]=p,t[43]=m,t[44]=S.length,t[45]=_,t[46]=r,t[47]=l.sessionId,t[48]=J):J=t[48];let X;t[49]!==p||t[50]!==C||t[51]!==x||t[52]!==_||t[53]!==r||t[54]!==l.sessionId?(X=!_&&C&&s.jsx(rs,{request:C,responding:r.has(C.requestId),onChoose:p?(Y,P)=>x(l.sessionId,Y,P):void 0},C.requestId),t[49]=p,t[50]=C,t[51]=x,t[52]=_,t[53]=r,t[54]=l.sessionId,t[55]=X):X=t[55];let Z;t[56]!==p||t[57]!==C||t[58]!==L||t[59]!==b||t[60]!==_||t[61]!==r||t[62]!==l.sessionId?(Z=!_&&!C&&L&&s.jsx(Jt,{request:L,responding:r.has(L.requestId),onAnswer:p?(Y,P)=>b(l.sessionId,Y,P):void 0},L.requestId),t[56]=p,t[57]=C,t[58]=L,t[59]=b,t[60]=_,t[61]=r,t[62]=l.sessionId,t[63]=Z):Z=t[63];let ee;t[64]!==p||t[65]!==C||t[66]!==L||t[67]!==c||t[68]!==y||t[69]!==f||t[70]!==$||t[71]!==_||t[72]!==r||t[73]!==l.sessionId?(ee=!_&&!C&&!L&&$&&s.jsx(os,{request:$,responding:r.has($.toolUseId),gone:c.has($.toolUseId),onAnswer:p?(Y,P)=>y(l.sessionId,Y,P):void 0,onOpenSession:f},$.toolUseId),t[64]=p,t[65]=C,t[66]=L,t[67]=c,t[68]=y,t[69]=f,t[70]=$,t[71]=_,t[72]=r,t[73]=l.sessionId,t[74]=ee):ee=t[74];let te;t[75]!==q||t[76]!==p?(te=q&&!p&&s.jsxs("p",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-2 text-xs text-muted-foreground",children:[s.jsx(Mt,{"data-icon":"inline-start",className:"size-3.5 shrink-0"}),"View only · you can’t answer this"]}),t[75]=q,t[76]=p,t[77]=te):te=t[77];let se;t[78]!==q||t[79]!==u?(se=!q&&(u==null?void 0:u.currentTool)&&s.jsx(js,{tool:u.currentTool}),t[78]=q,t[79]=u,t[80]=se):se=t[80];let ne;t[81]!==q||t[82]!==g||t[83]!==u?(ne=!g&&!q&&(u==null?void 0:u.lastAssistantText)&&s.jsx("p",{className:"line-clamp-4 text-sm leading-relaxed text-muted-foreground",children:u.lastAssistantText}),t[81]=q,t[82]=g,t[83]=u,t[84]=ne):ne=t[84];let ie;t[85]!==u?(ie=u&&s.jsx(ws,{summary:u}),t[85]=u,t[86]=ie):ie=t[86];let fe;return t[87]!==ae||t[88]!==W||t[89]!==J||t[90]!==X||t[91]!==Z||t[92]!==ee||t[93]!==te||t[94]!==se||t[95]!==ne||t[96]!==ie||t[97]!==F?(fe=s.jsxs("div",{className:F,children:[ae,W,J,X,Z,ee,te,se,ne,ie]}),t[87]=ae,t[88]=W,t[89]=J,t[90]=X,t[91]=Z,t[92]=ee,t[93]=te,t[94]=se,t[95]=ne,t[96]=ie,t[97]=F,t[98]=fe):fe=t[98],fe});function js(o){const e=B.c(7),{tool:t}=o;let n;e[0]!==t.name?(n=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.name}),e[0]=t.name,e[1]=n):n=e[1];let i;e[2]!==t.summary?(i=s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/80",children:t.summary}),e[2]=t.summary,e[3]=i):i=e[3];let a;return e[4]!==n||e[5]!==i?(a=s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md bg-muted/50 px-2.5 py-2",children:[n,i]}),e[4]=n,e[5]=i,e[6]=a):a=e[6],a}function ws(o){const e=B.c(11),{summary:t}=o,n=t.filesTotal,i=t.context,a=n.count>0,r=i!==null&&i.used>0;if(!a&&!r)return null;let c;e[0]!==n.additions||e[1]!==n.count||e[2]!==n.deletions||e[3]!==a?(c=a&&s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"truncate",children:[n.count," file",n.count===1?"":"s"]}),s.jsx(ft,{add:n.additions,del:n.deletions})]}),e[0]=n.additions,e[1]=n.count,e[2]=n.deletions,e[3]=a,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==r?(d=r&&s.jsxs("span",{className:xe("ml-auto shrink-0",hs(i.percent)),children:["ctx ",i.percent,"%"]}),e[5]=i,e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==c||e[9]!==d?(f=s.jsxs("div",{className:"mt-auto flex items-center gap-2 border-t pt-2 font-mono text-xs text-muted-foreground",children:[c,d]}),e[8]=c,e[9]=d,e[10]=f):f=e[10],f}const Ns=8e3,vs=12,ys="Start Claude Code, Codex, or Copilot and every session shows up here",Ss=[{id:"all",label:"All"},{id:"running",label:"Running"},{id:"needs-you",label:"Needs you"},{id:"finished",label:"Finished"}],Is=[{id:"grid",label:"Grid layout",Icon:Lt},{id:"list",label:"List layout",Icon:Ft}];function As(o){const e=B.c(121),{onSelectSession:t}=o,{sessions:n,procBySession:i,newlyCompleted:a,refresh:r}=mt(),{summaries:c,loading:d,error:f,refresh:m}=Vt(),{permissionsBySession:y,questionsBySession:b,elicitationsBySession:x,dialogsBySession:g,awaitingPlan:l,responding:h,respond:u,answerQuestion:S,answerElicitation:I,answerDialog:j,refresh:v}=xt();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[0]=p):p=e[0];const[w,_]=M.useState(p),{names:$}=ht(),{names:L}=gt(),C=pt(),[q,Q]=M.useState("all");let U;e[1]===Symbol.for("react.memo_cache_sentinel")?(U=bt("mission-control-layout"),e[1]=U):U=e[1];const[A,F]=jt(U,"grid");let O;e[2]!==C?(O=R=>C(R.access).answer,e[2]=C,e[3]=O):O=e[3];let D;e[4]!==l||e[5]!==g||e[6]!==x||e[7]!==a||e[8]!==y||e[9]!==i||e[10]!==b||e[11]!==n||e[12]!==c||e[13]!==O?(D=fs({sessions:n,procBySession:i,summaries:c,permissionsBySession:y,questionsBySession:b,elicitationsBySession:x,dialogsBySession:g,awaitingPlan:l,newlyCompleted:a,canAnswer:O}),e[4]=l,e[5]=g,e[6]=x,e[7]=a,e[8]=y,e[9]=i,e[10]=b,e[11]=n,e[12]=c,e[13]=O,e[14]=D):D=e[14];const N=D;let E;e[15]!==N?(E=xs(N),e[15]=N,e[16]=E):E=e[16];const T=E;let z;e[17]!==N||e[18]!==q?(z=ms(N,q),e[17]=N,e[18]=q,e[19]=z):z=e[19];const G=z;let oe;e[20]!==v||e[21]!==r||e[22]!==m?(oe=()=>{r(),m(),v()},e[20]=v,e[21]=r,e[22]=m,e[23]=oe):oe=e[23];const K=oe;let ae,re;e[24]!==r?(ae=()=>{const R=setInterval(()=>{document.visibilityState==="visible"&&r()},Ns);return()=>clearInterval(R)},re=[r],e[24]=r,e[25]=ae,e[26]=re):(ae=e[25],re=e[26]),M.useEffect(ae,re);let ce;e[27]!==S?(ce=async(R,k,Fe)=>{(await S(R,k,Fe)).ok||_(Ke=>new Set(Ke).add(k))},e[27]=S,e[28]=ce):ce=e[28];const le=ce;let ue;e[29]!==N.length?(ue=function(k){N.length<=vs?Gt(k,{kind:"fade"}):M.startTransition(k)},e[29]=N.length,e[30]=ue):ue=e[30];const H=ue;let de;e[31]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"Mission Control"}),e[31]=de):de=e[31];let W;e[32]!==T.total?(W=s.jsx(Ae,{variant:"secondary",children:T.total}),e[32]=T.total,e[33]=W):W=e[33];let J;e[34]!==T.needsYou?(J=T.needsYou>0&&s.jsxs(Ae,{variant:"outline",className:"border-warning/40 text-warning",children:[T.needsYou," need you"]}),e[34]=T.needsYou,e[35]=J):J=e[35];let X;e[36]!==T.failed?(X=T.failed>0&&s.jsxs(Ae,{variant:"destructive",children:[T.failed," failed"]}),e[36]=T.failed,e[37]=X):X=e[37];let Z;e[38]!==W||e[39]!==J||e[40]!==X?(Z=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[de,W,J,X]}),e[38]=W,e[39]=J,e[40]=X,e[41]=Z):Z=e[41];let ee;e[42]!==q?(ee=[q],e[42]=q,e[43]=ee):ee=e[43];let te;e[44]!==q||e[45]!==H?(te=R=>{const k=R.at(-1);k&&k!==q&&H(()=>Q(k))},e[44]=q,e[45]=H,e[46]=te):te=e[46];let se;e[47]!==T.needsYou?(se=Ss.map(R=>s.jsxs(Ee,{value:R.id,"aria-label":`Show ${R.label.toLowerCase()} sessions`,children:[R.label,R.id==="needs-you"&&T.needsYou>0&&s.jsx("span",{className:"font-mono text-warning",children:T.needsYou})]},R.id)),e[47]=T.needsYou,e[48]=se):se=e[48];let ne;e[49]!==ee||e[50]!==te||e[51]!==se?(ne=s.jsx(Ve,{value:ee,onValueChange:te,variant:"outline",size:"sm",spacing:0,"aria-label":"Filter sessions",children:se}),e[49]=ee,e[50]=te,e[51]=se,e[52]=ne):ne=e[52];let ie;e[53]!==A||e[54]!==F||e[55]!==H?(ie=Is.map(R=>{const{id:k,label:Fe,Icon:Ue}=R;return s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":Fe,"aria-pressed":A===k,onClick:()=>{k!==A&&H(()=>F(k))},className:xe(A===k&&"bg-accent text-accent-foreground"),children:s.jsx(Ue,{"data-icon":"inline-start"})},k)}),e[53]=A,e[54]=F,e[55]=H,e[56]=ie):ie=e[56];const fe=d&&"animate-spin";let Y;e[57]!==fe?(Y=xe(fe),e[57]=fe,e[58]=Y):Y=e[58];let P;e[59]!==Y?(P=s.jsx($t,{"data-icon":"inline-start",className:Y}),e[59]=Y,e[60]=P):P=e[60];let he;e[61]!==K||e[62]!==P?(he=s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":"Refresh Mission Control",onClick:K,children:P}),e[61]=K,e[62]=P,e[63]=he):he=e[63];let ge;e[64]!==ie||e[65]!==he?(ge=s.jsxs("div",{className:"flex items-center gap-1",children:[ie,he]}),e[64]=ie,e[65]=he,e[66]=ge):ge=e[66];let pe;e[67]!==ne||e[68]!==ge?(pe=s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[ne,ge]}),e[67]=ne,e[68]=ge,e[69]=pe):pe=e[69];let be;e[70]!==Z||e[71]!==pe?(be=s.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-3 border-b px-4 py-2",children:[Z,pe]}),e[70]=Z,e[71]=pe,e[72]=be):be=e[72];let je;e[73]!==f||e[74]!==K?(je=f&&s.jsxs(Ce,{variant:"destructive",className:"mb-4",children:[s.jsx(Dt,{}),s.jsx(qe,{children:"Mission Control could not refresh"}),s.jsx(_t,{className:"truncate",children:f}),s.jsx(Tt,{children:s.jsx(V,{variant:"outline",size:"xs",onClick:K,children:"Retry"})})]}),e[73]=f,e[74]=K,e[75]=je):je=e[75];let we;e[76]!==N.length||e[77]!==q||e[78]!==d||e[79]!==G.length?(we=G.length===0&&!d&&s.jsx(wt,{className:"min-h-64",children:s.jsxs(Nt,{children:[s.jsx(vt,{variant:"icon",children:s.jsx(Ot,{})}),s.jsx(yt,{children:N.length===0?"No live sessions":`Nothing matches "${q}"`}),s.jsx(St,{children:N.length===0?ys:"Try a different filter."})]})}),e[76]=N.length,e[77]=q,e[78]=d,e[79]=G.length,e[80]=we):we=e[80];let Ne;e[81]!==N.length||e[82]!==d||e[83]!==G.length?(Ne=G.length===0&&d&&N.length===0&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[s.jsx(It,{}),"Loading sessions…"]}),e[81]=N.length,e[82]=d,e[83]=G.length,e[84]=Ne):Ne=e[84];const Le=A==="grid"&&"md:grid-cols-2 2xl:grid-cols-3";let ve;e[85]!==Le?(ve=xe("grid grid-cols-1 gap-3",Le),e[85]=Le,e[86]=ve):ve=e[86];let ye;if(e[87]!==j||e[88]!==I||e[89]!==w||e[90]!==le||e[91]!==A||e[92]!==t||e[93]!==L||e[94]!==u||e[95]!==h||e[96]!==$||e[97]!==G){let R;e[99]!==j||e[100]!==I||e[101]!==w||e[102]!==le||e[103]!==A||e[104]!==t||e[105]!==L||e[106]!==u||e[107]!==h||e[108]!==$?(R=k=>s.jsx(bs,{card:k,compact:A==="list",customName:$[k.session.sessionId],projectLabel:L[k.session.dirName]??qt(k.session),responding:h,goneQuestions:w,onOpen:()=>t(k.session.dirName,k.session.fileName),onRespond:u,onAnswerQuestion:le,onAnswerElicitation:I,onChooseDialog:j},k.session.sessionId),e[99]=j,e[100]=I,e[101]=w,e[102]=le,e[103]=A,e[104]=t,e[105]=L,e[106]=u,e[107]=h,e[108]=$,e[109]=R):R=e[109],ye=G.map(R),e[87]=j,e[88]=I,e[89]=w,e[90]=le,e[91]=A,e[92]=t,e[93]=L,e[94]=u,e[95]=h,e[96]=$,e[97]=G,e[98]=ye}else ye=e[98];let Se;e[110]!==ve||e[111]!==ye?(Se=s.jsx("div",{className:ve,children:ye}),e[110]=ve,e[111]=ye,e[112]=Se):Se=e[112];let Ie;e[113]!==je||e[114]!==we||e[115]!==Ne||e[116]!==Se?(Ie=s.jsx(Ct,{className:"flex-1",children:s.jsxs("div",{className:"p-4",children:[je,we,Ne,Se]})}),e[113]=je,e[114]=we,e[115]=Ne,e[116]=Se,e[117]=Ie):Ie=e[117];let ke;return e[118]!==be||e[119]!==Ie?(ke=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[be,Ie]}),e[118]=be,e[119]=Ie,e[120]=ke):ke=e[120],ke}export{As as MissionControl};
|