@adhdev/daemon-standalone 0.5.47 → 0.5.49
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/package.json
CHANGED
|
@@ -169,7 +169,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
169
169
|
100% { transform: scale(0.5); opacity: 0; }
|
|
170
170
|
}
|
|
171
171
|
`})]})}function nM({screenshotUrl:e,mode:t="preview",zoom:r=100,interactive:n=!1,connectionState:i,onDismiss:s,onClickAt:o,onKeyDown:l,badge:a,emptyMessage:c,aspectRatio:d,className:h,style:f}){const p=y.useRef(null),m=y.useCallback(_=>{if(!n||!o||!p.current)return;const w=p.current,g=w.getBoundingClientRect(),v=(_.clientX-g.left)/g.width*w.naturalWidth,x=(_.clientY-g.top)/g.height*w.naturalHeight;o(v,x,w.naturalWidth,w.naturalHeight)},[n,o]);return t==="preview"?e?u.jsxs("div",{className:`relative rounded-xl overflow-hidden border border-border-subtle bg-bg-secondary ${h||""}`,style:{aspectRatio:d||"16/9",...f},children:[u.jsx("img",{ref:p,src:e,alt:"IDE Screenshot",className:"w-full h-full object-cover"}),s&&u.jsx("button",{onClick:s,className:"absolute top-2.5 right-2.5 bg-black/50 border-none text-white w-5 h-5 rounded-full text-[10px] z-10 cursor-pointer flex items-center justify-center",children:"✕"})]}):null:e?u.jsxs("div",{className:`${n?"screenshot-interactive":""} ${h||""} relative h-full flex items-center justify-center overflow-auto`,tabIndex:n?0:void 0,onKeyDown:n?l:void 0,style:f,children:[u.jsx("img",{ref:p,src:e,alt:"IDE Screenshot",onClick:n?m:void 0,className:"max-w-full max-h-full object-contain",style:{...n?{cursor:"crosshair"}:{},...r!==100?{transform:`scale(${r/100})`,transformOrigin:"center center"}:{}}}),a&&u.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/70 text-white px-3.5 py-1.5 rounded-[20px] text-xs font-semibold backdrop-blur-sm",children:a})]}):u.jsxs("div",{className:`flex items-center justify-center flex-col gap-2 h-full text-text-muted ${h||""}`,style:f,children:[u.jsx("p",{className:"text-base",children:c||"🖥 Waiting for screenshot stream..."}),i&&u.jsxs("p",{className:"text-[13px] mt-2 opacity-50",children:["P2P: ",i]})]})}function w1({activeConv:e,onModalButton:t}){const[r,n]=y.useState(null);if(y.useEffect(()=>{n(null)},[e.modalMessage,e.status]),e.status!=="waiting_approval"||!e.modalButtons)return null;const i=o=>{r||(n(o),t(o))},s=o=>o.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return u.jsxs("div",{className:"bg-gradient-to-br from-amber-600 to-amber-700 text-white py-2.5 px-4 shrink-0 z-[5]",children:[e.modalMessage&&u.jsx("div",{className:"text-[11px] opacity-85 mb-1.5 whitespace-nowrap overflow-hidden text-ellipsis max-w-full",children:e.modalMessage.replace(/[\n\r]+/g," ").slice(0,120)}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"font-black text-xs flex items-center gap-2",children:[u.jsx(Ny,{size:14})," ",r?"PROCESSING...":"ACTION REQUIRED"]}),u.jsx("div",{className:"flex gap-2 flex-wrap",children:e.modalButtons.map((o,l)=>{const a=s(o).toLowerCase(),c=/^(run|approve|accept|yes|allow|always)/.test(a),d=/^(reject|deny|delete|remove|abort)/.test(a),h=r===o,f=r!==null;return u.jsx("button",{onClick:()=>i(o),disabled:f,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${c?"bg-white text-amber-700 font-extrabold":d?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${f&&!h?"opacity-40":"opacity-100"} ${f?"cursor-not-allowed":"cursor-pointer"}`,children:h?"⏳ ...":s(o)},l)})})]})]})}const Er=new Map;function iM({ideId:e,ideType:t,agentType:r,agentName:n,serverModel:i,serverMode:s,acpConfigOptions:o,acpModes:l}){var q;const{sendCommand:a}=ci(),c=!!(o||l),d=`${e}:${r}`,h=Er.get(d),[f,p]=y.useState(!1),[m,_]=y.useState(!1),[w,g]=y.useState((h==null?void 0:h.models)||[]),[v,x]=y.useState((h==null?void 0:h.modes)||[]),S=j=>j?typeof j=="string"?j:typeof j=="object"?j.name||j.id||JSON.stringify(j):String(j):"",[M,C]=y.useState(S(i)),[T,k]=y.useState(S(s)),[A,E]=y.useState(!1),[B,R]=y.useState(!1),L=y.useRef(0),P=j=>j.map(F=>typeof F=="string"?F:(F==null?void 0:F.name)||(F==null?void 0:F.id)||String(F));y.useEffect(()=>{if(o){const j=o.find(F=>F.category==="model");if(j){const F=P(j.options.map(he=>he.value));g(F),j.currentValue&&C(S(j.currentValue));const Y=Er.get(d)||{models:[],modes:[]};Er.set(d,{...Y,models:F})}}if(l&&l.length>0){const j=P(l.map(Y=>Y.id));x(j);const F=Er.get(d)||{models:[],modes:[]};Er.set(d,{...F,modes:j})}else if(o){const j=o.find(F=>F.category!=="model");if(j){const F=P(j.options.map(he=>he.value));x(F),j.currentValue&&k(S(j.currentValue));const Y=Er.get(d)||{models:[],modes:[]};Er.set(d,{...Y,modes:F})}}},[o,l,d]),y.useEffect(()=>{p(!1),_(!1),C(S(i)),k(S(s));const j=Er.get(d);j?(g(j.models),x(j.modes)):(g([]),x([]))},[e,r]),y.useEffect(()=>{i&&Date.now()>L.current&&C(S(i))},[i]),y.useEffect(()=>{s&&Date.now()>L.current&&k(S(s))},[s]);const O=y.useCallback(async(j,F={})=>{const Y={...F},he=e.split(":");return he.length>=3&&(he[1]==="ide"||he[1]==="cli"||he[1]==="acp")&&(Y._targetInstance=he.slice(2).join(":"),Y._targetType=he[1]),await a(e,j,Y)},[e]),z=async()=>{var j,F;if(w.length>0){p(!f);return}if(c){p(!0);return}E(!0);try{const Y=await O("list_extension_models",{agentType:r,ideType:t}),he=(Y==null?void 0:Y.models)||((j=Y==null?void 0:Y.result)==null?void 0:j.models)||[],me=P(he);g(me),Y!=null&&Y.current&&C(S(Y.current)),(F=Y==null?void 0:Y.result)!=null&&F.current&&C(S(Y.result.current));const Ce=Er.get(d)||{models:[],modes:[]};Er.set(d,{...Ce,models:me}),p(!0)}catch{}finally{E(!1)}},V=async()=>{var j,F;if(v.length>0){_(!m);return}if(c){_(!0);return}R(!0);try{const Y=await O("list_extension_modes",{agentType:r,ideType:t}),he=(Y==null?void 0:Y.modes)||((j=Y==null?void 0:Y.result)==null?void 0:j.modes)||[],me=P(he);x(me),Y!=null&&Y.current&&k(S(Y.current)),(F=Y==null?void 0:Y.result)!=null&&F.current&&k(S(Y.result.current));const Ce=Er.get(d)||{models:[],modes:[]};Er.set(d,{...Ce,modes:me}),_(!0)}catch{}finally{R(!1)}},D=async j=>{p(!1),C(j),L.current=Date.now()+5e3;try{c?await O("change_model",{agentType:r,ideType:t,model:j}):await O("set_extension_model",{agentType:r,ideType:t,model:j})}catch{}},$=c&&!(l&&l.length>0)&&(o==null?void 0:o.some(j=>j.category!=="model")),b=$?(q=o==null?void 0:o.find(j=>j.category!=="model"))==null?void 0:q.configId:void 0,J=async j=>{_(!1),k(j),L.current=Date.now()+5e3;try{c&&$&&b?await O("set_thought_level",{agentType:r,ideType:t,configId:b,value:j}):c?await O("set_mode",{agentType:r,ideType:t,mode:j}):await O("set_extension_mode",{agentType:r,ideType:t,mode:j})}catch{}},N={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[r]||"#94a3b8";return u.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 flex-wrap text-[10px] border-t border-border-subtle bg-[var(--surface-primary)]",children:[u.jsx("span",{className:"text-[9px] font-bold tracking-wide uppercase opacity-70",style:{color:N},children:n}),u.jsx("span",{className:"text-border-subtle text-[10px]",children:"│"}),u.jsxs("div",{className:"relative",children:[u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:f?`${N}55`:"transparent",border:"1px solid",color:M?"var(--text-primary)":"var(--text-muted)"},onClick:z,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),A?"...":M||"Model",u.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),f&&w.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>p(!1)}),u.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[u.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:"SELECT MODEL"}),w.map(j=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:j===M?`${N}18`:"transparent",color:j===M?N:"var(--text-secondary)",fontWeight:j===M?600:400,borderLeft:j===M?`2px solid ${N}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${N}12`},onMouseLeave:F=>{F.currentTarget.style.background=j===M?`${N}18`:"transparent"},onClick:()=>D(j),children:j},j))]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:m?`${N}55`:"transparent",border:"1px solid",color:T?"var(--text-primary)":"var(--text-muted)"},onClick:V,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:$?"🧠":"⚡"}),B?"...":T||($?"Thinking":"Mode"),u.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),m&&v.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>_(!1)}),u.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[u.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:$?"SELECT THINKING LEVEL":"SELECT MODE"}),v.map(j=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:j===T?`${N}18`:"transparent",color:j===T?N:"var(--text-secondary)",fontWeight:j===T?600:400,borderLeft:j===T?`2px solid ${N}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${N}12`},onMouseLeave:F=>{F.currentTarget.style.background=j===T?`${N}18`:"transparent"},onClick:()=>J(j),children:j},j))]})]})]})]})}const ii=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),ln=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function S1({activeConv:e,ides:t,agentInput:r,setAgentInput:n,handleSendChat:i,handleFocusAgent:s,isFocusingAgent:o,messageReceivedAt:l,actionLogs:a,userName:c}){const d=y.useRef(null),{sendCommand:h}=ci(),[f,p]=y.useState([]),[m,_]=y.useState(0),[w,g]=y.useState(!0),[v,x]=y.useState(!1),S=y.useRef("");e.tabKey!==S.current&&(S.current=e.tabKey,p([]),_(0),g(!0));const M=y.useCallback(async()=>{var k,A,E,B,R,L;if(!(v||!w)){x(!0);try{const P=t.find(b=>b.id===e.ideId),O=(P==null?void 0:P.daemonId)||((k=e.ideId)==null?void 0:k.split(":")[0])||"";if(!O){g(!1);return}const z=e.ideType||e.agentType||"",V=(e.ideId||"").split(":"),D=V.length>=3?V.slice(2).join(":"):void 0;console.log("[ChatPane] requestChatHistory:",{daemonId:O,agentType:z,instanceId:D,offset:m});const $=await h(O,"chat_history",{agentType:z,offset:m,limit:30,instanceId:D});console.log("[ChatPane] got result:",{count:((A=$.messages)==null?void 0:A.length)||0,hasMore:$.hasMore}),((E=$.messages)==null?void 0:E.length)>0&&(p(b=>[...$.messages,...b]),_(b=>b+$.messages.length)),g($.hasMore)}catch(P){console.warn("[ChatPane] Failed to load history:",P),!((B=P==null?void 0:P.message)!=null&&B.includes("P2P not available"))&&!((R=P==null?void 0:P.message)!=null&&R.includes("channel not open"))&&!((L=P==null?void 0:P.message)!=null&&L.includes("P2P not connected"))&&g(!1)}finally{x(!1)}}},[v,w,m,t,e]),C=y.useRef(0);y.useEffect(()=>{if(e.messages.length<10&&w&&!v&&f.length===0){const k=C.current;if(k>8)return;const E=setTimeout(()=>{C.current=k+1,M()},k===0?500:3e3);return()=>clearTimeout(E)}else f.length>0&&(C.current=0)},[e.tabKey,e.messages.length,w,v,f.length,M]);const T=(()=>{const k=e.messages.map((B,R)=>{const L=`${e.ideId}-${B.id??`i-${R}`}`;return{...B,receivedAt:B.receivedAt||l[L]||0}});if(f.length===0)return k;const A=new Set(k.map(B=>`${B.role}:${(B.content||"").slice(0,100)}`));return[...f.filter(B=>!A.has(`${B.role}:${(B.content||"").slice(0,100)}`)),...k]})();return u.jsxs(u.Fragment,{children:[u.jsx(BP,{messages:T,actionLogs:a.filter(k=>k.ideId===e.tabKey).sort((k,A)=>k.timestamp-A.timestamp),agentName:e.agentName||e.displayPrimary||"Agent",userName:c,isCliMode:ii(e)||ln(e),isWorking:e.status==="working",contextKey:e.tabKey,onLoadMore:M,isLoadingMore:v,hasMoreHistory:w,emptyState:e.messages.length===0?e.status==="not_monitored"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-3xl opacity-60",children:u.jsx(Ty,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Switching...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Wa,{size:14})," Open ",e.displayPrimary," Panel"]})}),u.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]}):e.status==="panel_hidden"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-3xl opacity-60",children:u.jsx(TP,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Panel is not visible in IDE"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Opening...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Wa,{size:14})," Open ",e.displayPrimary," Panel"]})}),u.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent sidebar in your IDE to start viewing messages"})]}):void 0:void 0}),!ii(e)&&(()=>{var A,E,B,R;const k=t.find(L=>L.id===e.ideId);return u.jsx(iM,{ideId:e.ideId,ideType:e.ideType,agentType:e.streamSource==="agent-stream"?e.agentType:((E=(A=k==null?void 0:k.agents)==null?void 0:A[0])==null?void 0:E.type)||e.ideType,agentName:e.streamSource==="agent-stream"?e.agentName:((R=(B=k==null?void 0:k.agents)==null?void 0:B[0])==null?void 0:R.name)||e.agentName,serverModel:(k==null?void 0:k.currentModel)||void 0,serverMode:(k==null?void 0:k.currentPlan)||void 0,acpConfigOptions:ln(e)?k==null?void 0:k.acpConfigOptions:void 0,acpModes:ln(e)?k==null?void 0:k.acpModes:void 0})})(),u.jsx("div",{className:"dashboard-input-area px-3 py-2.5 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:u.jsxs("div",{className:"flex gap-2.5 items-center",children:[u.jsx("div",{className:"flex-1 relative",children:u.jsx("input",{ref:d,type:"text",placeholder:`Send message to ${e.displayPrimary}...`,value:r,onChange:k=>n(k.target.value),onPaste:k=>{const A=k.clipboardData.getData("text");A&&n(E=>E+A),k.preventDefault()},onKeyDown:k=>{if(k.key==="Enter"){if(k.nativeEvent.isComposing){k.preventDefault();return}k.preventDefault(),i()}},onBlur:k=>{if(window.innerWidth<768){const A=k.relatedTarget;if((A==null?void 0:A.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary border border-border-subtle text-sm text-text-primary"})}),u.jsx("button",{onClick:i,disabled:!r.trim(),className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${r.trim()?"bg-accent cursor-pointer":"bg-bg-secondary cursor-default"}`,children:u.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:r.trim()?"text-white":"text-text-muted",children:u.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}const Lu=new Set,k1={emit(e,t){for(const r of Lu)r(e,t)},on(e){return Lu.add(e),()=>{Lu.delete(e)}}};function sM({activeConv:e,ptyBuffers:t,terminalRef:r,agentInput:n,setAgentInput:i,handleSendChat:s,handleModalButton:o}){var p;const l=y.useRef(null),{sendCommand:a,sendData:c}=ci(),d=(p=e.ideId)!=null&&p.includes(":cli:")?e.ideId.split(":cli:")[1]:"",h=e.tabKey,f=e.ideType||e.agentType||"";return y.useEffect(()=>{const m=t.current.get(h);if(m&&m.length>0){const _=setTimeout(()=>{var w;for(const g of m)(w=r.current)==null||w.write(g);requestAnimationFrame(()=>{var g;(g=r.current)==null||g.bumpResize()})},100);return()=>clearTimeout(_)}},[h]),y.useEffect(()=>{const m=k1.on((_,w)=>{var v;if(!w)return;(_===d||_===f)&&((v=r.current)==null||v.write(w))});return()=>{m()}},[d,f]),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--surface-primary)] border-b border-border-subtle shrink-0",children:[u.jsx("div",{className:"flex gap-1",children:u.jsx("div",{className:"px-3 py-1 rounded-md text-[11px] font-semibold bg-accent text-white",children:"⬛ Terminal"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"text-[10px] text-text-muted",children:[e.agentName," — Terminal"]}),u.jsx("button",{onClick:()=>{if(!r.current||!e)return;const m=t.current.get(e.tabKey);if(m&&m.length>0)for(const _ of m)r.current.write(_);requestAnimationFrame(()=>{requestAnimationFrame(()=>{var _;(_=r.current)==null||_.bumpResize()})})},title:"Refresh terminal (replay buffer + TUI redraw)",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-bg-secondary text-text-secondary border border-border-subtle cursor-pointer leading-none",children:"↺"}),u.jsx("button",{onClick:async()=>{var w;const m=(w=e.ideId)!=null&&w.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";if(!window.confirm(`Stop ${m}?
|
|
172
|
-
This will terminate the CLI process.`))return;const _=e.ideId||e.daemonId||"";try{await a(_,"stop_cli",{cliType:m})}catch(g){console.error("Stop CLI failed:",g)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),u.jsx(w1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(b1,{ref:r,onInput:m=>{var g;const _=e.ideId||e.daemonId||"",w=(g=e.ideId)!=null&&g.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(_,{type:"pty_input",cliType:w,data:m})||a(_,"pty_input",{cliType:w,data:m}).catch(console.error)},onResize:(m,_)=>{var v;const w=e.ideId||e.daemonId||"",g=(v=e.ideId)!=null&&v.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(w,{type:"pty_resize",cliType:g,cols:m,rows:_})||a(w,"pty_resize",{cliType:g,cols:m,rows:_,force:!0}).catch(()=>{})}},e.tabKey)}),u.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:u.jsxs("div",{className:"flex gap-2.5 items-center",children:[u.jsx("div",{className:"flex-1 relative",children:u.jsx("input",{ref:l,type:"text",placeholder:`Send message to ${e.displayPrimary}...`,value:n,onChange:m=>i(m.target.value),onPaste:m=>{const _=m.clipboardData.getData("text");_&&i(w=>w+_),m.preventDefault()},onKeyDown:m=>{if(m.key==="Enter"){if(m.nativeEvent.isComposing){m.preventDefault();return}m.preventDefault(),s()}},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary border border-border-subtle text-[13px] text-text-primary"})}),u.jsx("button",{onClick:s,disabled:!n.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${n.trim()?"bg-accent cursor-pointer":"bg-bg-secondary cursor-default"}`,children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:n.trim()?"text-white":"text-text-muted",children:u.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function oM({wsStatus:e,showReconnected:t,loginUrl:r}){const n=e==="disconnected"||e==="reconnecting"||e==="offline"||e==="auth_failed",i=e==="auth_failed"?"red":e==="offline"?"orange":"violet",s={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},o={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},l={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return u.jsxs(u.Fragment,{children:[n&&u.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:s[i],borderBottom:o[i],color:l[i]},children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:e==="auth_failed"?.6:1,animation:e==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:e==="auth_failed"?"grayscale(1)":void 0}}),e==="offline"&&"Network offline — waiting for connection...",e==="disconnected"&&"Reconnecting to server...",e==="reconnecting"&&"Reconnecting to server...",e==="auth_failed"&&(r?u.jsxs(u.Fragment,{children:["Session expired."," ",u.jsx("a",{href:r,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),t&&e==="connected"&&u.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let lM=Ho;function Cc(){return lM()}class aM{constructor(){As(this,"listeners",new Map)}send(t){}isConnected(){return!1}on(t,r){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r),()=>{var n;(n=this.listeners.get(t))==null||n.delete(r)}}emit(t,...r){var n;(n=this.listeners.get(t))==null||n.forEach(i=>i(...r))}}let cM=new aM;class uM{constructor(){As(this,"ptyCallbacks",new Set)}sendPtyInput(t,r,n){return!1}sendPtyResize(t,r,n,i){return!1}async requestChatHistory(t,r,n,i,s){return{messages:[],hasMore:!1}}retryConnection(t){}getState(t){return"disconnected"}sendData(t,r){return!1}get(t){}onScreenshot(t,r){return()=>{}}onStatusEvent(t){return()=>{}}onPtyOutput(t){return this.ptyCallbacks.add(t),()=>{this.ptyCallbacks.delete(t)}}emitPtyOutput(t,r){this.ptyCallbacks.forEach(n=>n(t,r))}}let vr=new uM,y_=vr;const Mu=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),Ru=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function hM({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=En(),o=Cc(),l=o.p2pStates||{},a=o.ides||[],c=n?"#22c55e":r==="connected"?"#eab308":"#ef4444",d=n?"0 0 4px #22c55e80":r==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",h=a.filter(g=>g.type==="adhdev-daemon"),f=Object.values(l),p=f.filter(g=>g==="connected").length,m=f.filter(g=>g==="connecting"||g==="new"||g==="checking").length,w=r!=="connected"||h.length===0?null:m>0&&p===0?"P2P connecting...":p>0&&t===0?"Waiting for IDE...":null;return u.jsxs("div",{className:"dashboard-header",children:[u.jsx("div",{className:"flex items-center gap-3",children:u.jsxs("div",{className:"leading-tight",children:[u.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[u.jsx(Fa,{size:18}),u.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),u.jsx("span",{className:"header-title-mobile",children:(e==null?void 0:e.displayPrimary)||"Dashboard"}),u.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:u.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:c,boxShadow:d}})})]}),u.jsxs("div",{className:"header-subtitle text-[11px] items-center gap-1",children:[t," agent",t!==1?"s":""," active",u.jsx("span",{title:n?"Connected":r==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:c,boxShadow:d}}),w&&u.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",w]})]})]})}),u.jsxs("div",{className:"flex gap-2 items-center",children:[e&&!Mu(e)&&!Ru(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm border-none px-2.5 py-1.5 flex items-center gap-1 text-xs",title:"IDE View",children:[u.jsx(Py,{size:14})," IDE"]}),e&&!Mu(e)&&!Ru(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5 flex items-center gap-1",title:"Chat History",children:u.jsx(CP,{size:16})}),e&&!Mu(e)&&!Ru(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5",title:"Remote Control",children:u.jsx(ll,{size:16})})]})]})}function Rr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function dM(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const r=Math.floor(t/60),n=t%60;if(r<24)return n>0?`${r}h ${n}m`:`${r}h`;const i=Math.floor(r/24),s=r%24;return`${i}d ${s}h`}function b_(e){return e<1024*1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function w_(e){return(e.id||"").includes(":cli:")}function S_(e){return(e.id||"").includes(":acp:")}function Pd(e,t){return Rr(e)}function fM(e){if(!Array.isArray(e)||e.length<=1)return e;const t=new Map,r=["generating","streaming","active","connected","idle","panel_hidden"];for(const n of e){const i=(n.name||n.id||"").toLowerCase().replace(/\s+/g,"-"),s=t.get(i);if(!s){t.set(i,n);continue}const o=r.indexOf(s.status||"idle"),l=r.indexOf(n.status||"idle");l>=0&&(o<0||l<o)&&t.set(i,n)}return Array.from(t.values())}function pM({activeConv:e,ides:t,isCreatingChat:r,isRefreshingHistory:n,onClose:i,onNewChat:s,onSwitchSession:o,onRefreshHistory:l}){var h;const a=t.find(f=>f.id===e.ideId),c=(a==null?void 0:a.chats)||[],d=(h=a==null?void 0:a.activeChat)==null?void 0:h.id;return u.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[u.jsx("div",{onClick:i,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),u.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[u.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),u.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[e.displayPrimary," — ",Rr(e.ideType)]})]}),u.jsx("button",{onClick:i,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[u.jsx("button",{onClick:s,disabled:r,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:r?"⌛ Creating...":"+ Start New Chat Session"}),c.map(f=>u.jsxs("div",{onClick:()=>{o(e.ideId,f.id),i()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${d===f.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[u.jsx("div",{className:`font-bold text-sm mb-1 ${d===f.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:f.title||"Untitled Session"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[f.id.substring(0,12),"..."]}),d===f.id&&u.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},f.id)),c.length===0&&u.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[u.jsx("div",{className:"text-3xl mb-3 opacity-60",children:u.jsx(RP,{size:32})}),u.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),u.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:u.jsx("button",{onClick:l,disabled:n,className:"btn btn-secondary btn-sm rounded-[10px]",children:n?"⌛ Refreshing...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(NP,{size:13})," Refresh History"]})})})]})]})}const k_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function mM({toasts:e,onDismiss:t,onClickToast:r}){return u.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:e.map(n=>u.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px]",style:{background:k_[n.type]||k_.info},onClick:()=>{var i;(i=n.actions)!=null&&i.length||(r&&r(n),t(n.id))},children:[u.jsx("div",{children:n.message}),n.actions&&n.actions.length>0&&u.jsx("div",{className:"flex gap-2 mt-2",children:n.actions.map((i,s)=>u.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${i.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":i.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:o=>{o.stopPropagation(),i.onClick(),t(n.id)},children:i.label},s))})]},n.id))})}const gM=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function _M(e){return e.workspace||"Workspace"}function vM(e,t,r,n){var s;const i={};if(r)for(const o of r){const l=o;if(l.type==="adhdev-daemon"||l.daemonMode){const a=l.machine||{},c=l.machineNickname,d=a.hostname||((s=l.system)==null?void 0:s.hostname)||"",h=c||(d&&d!=="Unknown"?d.replace(/\.local$/,""):null)||`Machine ${(l.id||"").substring(0,6)}`;i[l.id]=h}}return e.flatMap(o=>{var w,g,v,x,S;const l=[],a=o.daemonId&&i[o.daemonId]||void 0,c=o.daemonId||((w=o.id)==null?void 0:w.split(":")[0])||o.id,d=n?n[c]||"new":void 0,h=_M(o),f=Rr(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(M=>({...M,activeModal:M.activeModal??void 0})):[],_=gM(o);if(_){const M=Pd(o.type),C=(g=o.agents)==null?void 0:g[0],T=(v=o.activeChat)==null?void 0:v.activeModal,k=T&&Array.isArray(T.buttons)&&T.buttons.length>0,A=(x=o.activeChat)==null?void 0:x.status,E=A==="generating"||A==="loading"||A&&A.toLowerCase()==="thinking",R=k||A==="waiting_approval"?"waiting_approval":E?"working":(C==null?void 0:C.status)||"idle",L=o.activeChat||{title:"",messages:[]};let P=L.title&&String(L.title).trim()?String(L.title).trim():"";const O=(S=o.activeChat)==null?void 0:S.id,z=o.chats;if(O&&Array.isArray(z)&&z.length>0){const J=z.find(re=>re.id===O||re.id&&String(re.id)===String(O));J!=null&&J.title&&String(J.title).trim()&&(P=String(J.title).trim())}const V=L.messages||[],D=t[o.id]||[],$=new Map;V.filter(J=>J.role==="user").forEach(J=>{$.set(J.content,($.get(J.content)||0)+1)});const b=D.filter(J=>{const re=$.get(J.content)||0;return re>0?($.set(J.content,re-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:M,agentType:ii(o)||ln(o)?o.type:(C==null?void 0:C.type)||"ide-native",status:R,title:P,messages:[...V,...b],ideType:o.type,workspaceName:h,displayPrimary:P||h,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:k?T.buttons:void 0,modalMessage:k?T.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(ii(o)||ln(o)))return l;for(const M of m){const C=M.activeModal&&Array.isArray(M.activeModal.buttons)&&M.activeModal.buttons.length>0,T=C?"waiting_approval":M.status==="streaming"?"working":M.status,k=`${o.id}:${M.agentType}`,A=M.messages||[],E=t[k]||[],B=new Map;A.filter(L=>L.role==="user").forEach(L=>{B.set(L.content,(B.get(L.content)||0)+1)});const R=E.filter(L=>{const P=B.get(L.content)||0;return P>0?(B.set(L.content,P-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:M.agentName,agentType:M.agentType,status:T,title:"",messages:[...A,...R],ideType:o.type,workspaceName:h,displayPrimary:h,displaySecondary:`${f}·${M.agentName}`,cdpConnected:o.cdpConnected,modalButtons:C?M.activeModal.buttons:void 0,modalMessage:C?M.activeModal.message:void 0,streamSource:"agent-stream",tabKey:k,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Pd(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:h,displayPrimary:h,displaySecondary:f,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:d}),l})}function xM(e,t){var l,a,c,d;const r=[],{daemonId:n,existingDaemon:i,timestamp:s}=t,o=s||e.timestamp||Date.now();r.push({...i||{},id:n,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...e.version&&{version:e.version},...e.machine&&{machine:e.machine,platform:e.machine.platform},...e.instanceId&&{instanceId:e.instanceId},...e.machineNickname!==void 0&&{machineNickname:e.machineNickname},...e.p2p&&{p2p:e.p2p},..."system"in e&&{system:e.system},..."hostname"in e&&{hostname:e.hostname},...e.workspaces&&{workspaces:e.workspaces},...e.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:e.defaultWorkspaceId},...e.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:e.defaultWorkspacePath},...e.workspaceActivity&&{workspaceActivity:e.workspaceActivity},...e.detectedIdes&&{detectedIdes:e.detectedIdes},..."availableProviders"in e&&{availableProviders:e.availableProviders},cdpConnected:e.managedIdes.some(h=>h.cdpConnected),managedIdeIds:e.managedIdes.map(h=>`${n}:ide:${h.instanceId}`),managedCliIds:e.managedClis.map(h=>h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`),managedAcpIds:e.managedAcps.map(h=>h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`)});for(const h of e.managedIdes)r.push({id:`${n}:ide:${h.instanceId}`,type:h.ideType,ideType:h.ideType,version:h.ideVersion,status:h.cdpConnected?"online":"detected",daemonId:n,instanceId:h.instanceId,workspace:h.workspace,terminals:h.terminals,agents:h.aiAgents,activeChat:h.activeChat,chats:h.chats,agentStreams:h.agentStreams,cdpConnected:h.cdpConnected,currentModel:h.currentModel,currentPlan:h.currentPlan,currentAutoApprove:h.currentAutoApprove,timestamp:o});for(const h of e.managedClis){const f=h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`;r.push({id:f,type:h.cliType,ideType:h.cliType,agentType:h.cliType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.cliName,mode:h.mode||"terminal",workspace:h.workspace,activeChat:h.activeChat,agentStreams:[{agentType:h.cliType,agentName:h.cliName,extensionId:"cli-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((l=h.activeChat)==null?void 0:l.messages)||[],inputContent:"",activeModal:(a=h.activeChat)==null?void 0:a.activeModal}],timestamp:o,_isCli:!0})}for(const h of e.managedAcps){const f=h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`;r.push({id:f,type:h.acpType,ideType:h.acpType,agentType:h.acpType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.acpName,mode:"chat",workspace:h.workspace,activeChat:h.activeChat,currentModel:h.currentModel,currentPlan:h.currentPlan,acpConfigOptions:h.acpConfigOptions,acpModes:h.acpModes,agentStreams:[{agentType:h.acpType,agentName:h.acpName,extensionId:"acp-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((c=h.activeChat)==null?void 0:c.messages)||[],inputContent:"",activeModal:(d=h.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isAcp:!0})}return r}function C1(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=C1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function yM(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=C1(e))&&(n&&(n+=" "),n+=t);return n}const bM=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},wM=(e,t)=>({classGroupId:e,validator:t}),E1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Xa="-",C_=[],SM="arbitrary..",kM=e=>{const t=EM(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return CM(o);const l=o.split(Xa),a=l[0]===""&&l.length>1?1:0;return N1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?bM(c,a):a:c||C_}return r[o]||C_}}},N1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=N1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(Xa):e.slice(t).join(Xa),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},CM=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?SM+n:void 0})(),EM=e=>{const{theme:t,classGroups:r}=e;return NM(r,t)},NM=(e,t)=>{const r=E1();for(const n in e){const i=e[n];ip(i,r,n,t)}return r},ip=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];TM(o,t,r,n)}},TM=(e,t,r,n)=>{if(typeof e=="string"){PM(e,t,r);return}if(typeof e=="function"){LM(e,t,r,n);return}MM(e,t,r,n)},PM=(e,t,r)=>{const n=e===""?t:T1(t,e);n.classGroupId=r},LM=(e,t,r,n)=>{if(RM(e)){ip(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(wM(r,e))},MM=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];ip(a,T1(t,l),r,n)}},T1=(e,t)=>{let r=e;const n=t.split(Xa),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=E1(),r.nextPart.set(o,l)),r=l}return r},RM=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,IM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},Ld="!",E_=":",DM=[],N_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),jM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const s=[];let o=0,l=0,a=0,c;const d=i.length;for(let _=0;_<d;_++){const w=i[_];if(o===0&&l===0){if(w===E_){s.push(i.slice(a,_)),a=_+1;continue}if(w==="/"){c=_;continue}}w==="["?o++:w==="]"?o--:w==="("?l++:w===")"&&l--}const h=s.length===0?i:i.slice(a);let f=h,p=!1;h.endsWith(Ld)?(f=h.slice(0,-1),p=!0):h.startsWith(Ld)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return N_(s,p,f,m)};if(t){const i=t+E_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):N_(DM,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},AM=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],l=o[0]==="[",a=t.has(o);l||a?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},BM=e=>({cache:IM(e.cacheSize),parseClassName:jM(e),sortModifiers:AM(e),...kM(e)}),OM=/\s+/,zM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(OM);let a="";for(let c=l.length-1;c>=0;c-=1){const d=l[c],{isExternal:h,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:_}=r(d);if(h){a=d+(a.length>0?" "+a:a);continue}let w=!!_,g=n(w?m.substring(0,_):m);if(!g){if(!w){a=d+(a.length>0?" "+a:a);continue}if(g=n(m),!g){a=d+(a.length>0?" "+a:a);continue}w=!1}const v=f.length===0?"":f.length===1?f[0]:s(f).join(":"),x=p?v+Ld:v,S=x+g;if(o.indexOf(S)>-1)continue;o.push(S);const M=i(g,w);for(let C=0;C<M.length;++C){const T=M[C];o.push(x+T)}a=d+(a.length>0?" "+a:a)}return a},$M=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=P1(r))&&(i&&(i+=" "),i+=n);return i},P1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=P1(e[n]))&&(r&&(r+=" "),r+=t);return r},FM=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=BM(c),n=r.cache.get,i=r.cache.set,s=l,l(a)},l=a=>{const c=n(a);if(c)return c;const d=zM(a,r);return i(a,d),d};return s=o,(...a)=>s($M(...a))},WM=[],Et=e=>{const t=r=>r[e]||WM;return t.isThemeGetter=!0,t},L1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,M1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,HM=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,UM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,VM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,An=e=>HM.test(e),De=e=>!!e&&!Number.isNaN(Number(e)),Bn=e=>!!e&&Number.isInteger(Number(e)),Iu=e=>e.endsWith("%")&&De(e.slice(0,-1)),hn=e=>UM.test(e),R1=()=>!0,XM=e=>VM.test(e)&&!KM.test(e),sp=()=>!1,GM=e=>qM.test(e),QM=e=>YM.test(e),JM=e=>!fe(e)&&!pe(e),ZM=e=>hi(e,j1,sp),fe=e=>L1.test(e),pi=e=>hi(e,A1,XM),T_=e=>hi(e,lR,De),eR=e=>hi(e,O1,R1),tR=e=>hi(e,B1,sp),P_=e=>hi(e,I1,sp),rR=e=>hi(e,D1,QM),$l=e=>hi(e,z1,GM),pe=e=>M1.test(e),Zs=e=>Hi(e,A1),nR=e=>Hi(e,B1),L_=e=>Hi(e,I1),iR=e=>Hi(e,j1),sR=e=>Hi(e,D1),Fl=e=>Hi(e,z1,!0),oR=e=>Hi(e,O1,!0),hi=(e,t,r)=>{const n=L1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Hi=(e,t,r=!1)=>{const n=M1.exec(e);return n?n[1]?t(n[1]):r:!1},I1=e=>e==="position"||e==="percentage",D1=e=>e==="image"||e==="url",j1=e=>e==="length"||e==="size"||e==="bg-size",A1=e=>e==="length",lR=e=>e==="number",B1=e=>e==="family-name",O1=e=>e==="number"||e==="weight",z1=e=>e==="shadow",aR=()=>{const e=Et("color"),t=Et("font"),r=Et("text"),n=Et("font-weight"),i=Et("tracking"),s=Et("leading"),o=Et("breakpoint"),l=Et("container"),a=Et("spacing"),c=Et("radius"),d=Et("shadow"),h=Et("inset-shadow"),f=Et("text-shadow"),p=Et("drop-shadow"),m=Et("blur"),_=Et("perspective"),w=Et("aspect"),g=Et("ease"),v=Et("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...S(),pe,fe],C=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],k=()=>[pe,fe,a],A=()=>[An,"full","auto",...k()],E=()=>[Bn,"none","subgrid",pe,fe],B=()=>["auto",{span:["full",Bn,pe,fe]},Bn,pe,fe],R=()=>[Bn,"auto",pe,fe],L=()=>["auto","min","max","fr",pe,fe],P=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...k()],V=()=>[An,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],D=()=>[An,"screen","full","dvw","lvw","svw","min","max","fit",...k()],$=()=>[An,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],b=()=>[e,pe,fe],J=()=>[...S(),L_,P_,{position:[pe,fe]}],re=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",iR,ZM,{size:[pe,fe]}],q=()=>[Iu,Zs,pi],j=()=>["","none","full",c,pe,fe],F=()=>["",De,Zs,pi],Y=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[De,Iu,L_,P_],Ce=()=>["","none",m,pe,fe],ke=()=>["none",De,pe,fe],Ke=()=>["none",De,pe,fe],ue=()=>[De,pe,fe],ve=()=>[An,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hn],breakpoint:[hn],color:[R1],container:[hn],"drop-shadow":[hn],ease:["in","out","in-out"],font:[JM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hn],shadow:[hn],spacing:["px",De],text:[hn],"text-shadow":[hn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",An,fe,pe,w]}],container:["container"],columns:[{columns:[De,fe,pe,l]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:M()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Bn,"auto",pe,fe]}],basis:[{basis:[An,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,An,"auto","initial","none",fe]}],grow:[{grow:["",De,pe,fe]}],shrink:[{shrink:["",De,pe,fe]}],order:[{order:[Bn,"first","last","none",pe,fe]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...P(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...P()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":P()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],"inline-size":[{inline:["auto",...D()]}],"min-inline-size":[{"min-inline":["auto",...D()]}],"max-inline-size":[{"max-inline":["none",...D()]}],"block-size":[{block:["auto",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],w:[{w:[l,"screen",...V()]}],"min-w":[{"min-w":[l,"screen","none",...V()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",r,Zs,pi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,oR,eR]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Iu,fe]}],"font-family":[{font:[nR,tR,t]}],"font-features":[{"font-features":[fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,pe,fe]}],"line-clamp":[{"line-clamp":[De,"none",pe,T_]}],leading:[{leading:[s,...k()]}],"list-image":[{"list-image":["none",pe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:b()}],"text-color":[{text:b()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",pe,pi]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[De,"auto",pe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bn,pe,fe],radial:["",pe,fe],conic:[Bn,pe,fe]},sR,rR]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:q()}],"gradient-via-pos":[{via:q()}],"gradient-to-pos":[{to:q()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:j()}],"rounded-s":[{"rounded-s":j()}],"rounded-e":[{"rounded-e":j()}],"rounded-t":[{"rounded-t":j()}],"rounded-r":[{"rounded-r":j()}],"rounded-b":[{"rounded-b":j()}],"rounded-l":[{"rounded-l":j()}],"rounded-ss":[{"rounded-ss":j()}],"rounded-se":[{"rounded-se":j()}],"rounded-ee":[{"rounded-ee":j()}],"rounded-es":[{"rounded-es":j()}],"rounded-tl":[{"rounded-tl":j()}],"rounded-tr":[{"rounded-tr":j()}],"rounded-br":[{"rounded-br":j()}],"rounded-bl":[{"rounded-bl":j()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Y(),"hidden","none"]}],"divide-style":[{divide:[...Y(),"hidden","none"]}],"border-color":[{border:b()}],"border-color-x":[{"border-x":b()}],"border-color-y":[{"border-y":b()}],"border-color-s":[{"border-s":b()}],"border-color-e":[{"border-e":b()}],"border-color-bs":[{"border-bs":b()}],"border-color-be":[{"border-be":b()}],"border-color-t":[{"border-t":b()}],"border-color-r":[{"border-r":b()}],"border-color-b":[{"border-b":b()}],"border-color-l":[{"border-l":b()}],"divide-color":[{divide:b()}],"outline-style":[{outline:[...Y(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,pe,fe]}],"outline-w":[{outline:["",De,Zs,pi]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,Fl,$l]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,Fl,$l]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[De,pi]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,Fl,$l]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[De,pe,fe]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[pe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,fe]}],filter:[{filter:["","none",pe,fe]}],blur:[{blur:Ce()}],brightness:[{brightness:[De,pe,fe]}],contrast:[{contrast:[De,pe,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,Fl,$l]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",De,pe,fe]}],"hue-rotate":[{"hue-rotate":[De,pe,fe]}],invert:[{invert:["",De,pe,fe]}],saturate:[{saturate:[De,pe,fe]}],sepia:[{sepia:["",De,pe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,fe]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[De,pe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[De,pe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,pe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,pe,fe]}],"backdrop-invert":[{"backdrop-invert":["",De,pe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[De,pe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[De,pe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",De,pe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",pe,fe]}],ease:[{ease:["linear","initial",g,pe,fe]}],delay:[{delay:[De,pe,fe]}],animate:[{animate:["none",v,pe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,pe,fe]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:ke()}],"rotate-x":[{"rotate-x":ke()}],"rotate-y":[{"rotate-y":ke()}],"rotate-z":[{"rotate-z":ke()}],scale:[{scale:Ke()}],"scale-x":[{"scale-x":Ke()}],"scale-y":[{"scale-y":Ke()}],"scale-z":[{"scale-z":Ke()}],"scale-3d":["scale-3d"],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[pe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],accent:[{accent:b()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:b()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,fe]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[De,Zs,pi,T_]}],stroke:[{stroke:["none",...b()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},cR=FM(aR);function Xo(...e){return cR(yM(e))}function uR({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Xo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Yi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Xo("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",n&&"border-l-[3px]",i),style:n?{borderLeftColor:n}:void 0,children:[(e||r)&&u.jsxs("div",{className:"mb-4",children:[e&&u.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[t&&u.jsx("span",{className:"mr-1.5",children:t}),e]}),r&&u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),s]})}function hR({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Xo("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[u.jsx("div",{className:"text-5xl mb-4 opacity-50",children:e}),u.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:t}),u.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:r}),n]})}const dR={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},fR={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function pR({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Xo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",dR[e],r),children:[u.jsx("span",{className:Xo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",fR[e])}),n]})}function mR(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function M_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function Du(e){return e==="system"?mR():e}function gR(){const[e,t]=y.useState(M_),[r,n]=y.useState(()=>Du(M_()));y.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),y.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),l=a=>{e==="system"&&n(a.matches?"light":"dark")};return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[e]);const i=y.useCallback(o=>{t(o),n(Du(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=y.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(Du(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}const R_={dark:"Dark",light:"Light",system:"System"};function _R({collapsed:e}){const{preference:t,cycleTheme:r}=gR(),n=t==="dark"?u.jsx(DP,{size:16}):t==="light"?u.jsx(IP,{size:16}):u.jsx(jP,{size:16});return u.jsxs("div",{className:`nav-item cursor-pointer ${e?"justify-center py-2.5 px-0":""}`,onClick:r,title:`Theme: ${R_[t]} (click to cycle)`,children:[u.jsx("span",{className:"nav-icon",children:n}),!e&&u.jsx("span",{className:"text-xs",children:R_[t]})]})}function Gi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}const $1="adhdev_notification_prefs",I_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function vR(){try{const e=localStorage.getItem($1);if(e){const t=JSON.parse(e);return{...I_,...t}}}catch{}return{...I_}}function xR(e){try{localStorage.setItem($1,JSON.stringify(e))}catch{}}let gn=vR(),ua=[];function yR(){ua.forEach(e=>e())}function bR(e){gn={...gn,...e},xR(gn),yR()}function wR(){const[,e]=y.useState(0);y.useEffect(()=>{const r=()=>e(n=>n+1);return ua.push(r),()=>{ua=ua.filter(n=>n!==r)}},[]);const t=y.useCallback(r=>{bR(r)},[]);return[{...gn},t]}function ju(e){if(!gn.globalEnabled)return!1;switch(e){case"disconnect":return gn.disconnectAlert;case"completion":return gn.completionAlert;case"approval":return gn.approvalAlert;case"browser":return gn.browserNotifications;default:return!0}}function SR({onPrefChange:e}){const[t,r]=wR(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Gi,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:t.globalEnabled,onChange:i=>n("globalEnabled",i)}),t.globalEnabled&&u.jsx("div",{className:"border-t border-border-subtle my-0.5"}),t.globalEnabled&&u.jsx(Gi,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:t.browserNotifications,onChange:i=>n("browserNotifications",i)}),t.globalEnabled&&t.browserNotifications&&u.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[u.jsx(Gi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Gi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Gi,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:t.disconnectAlert,onChange:i=>n("disconnectAlert",i)})]}),!t.globalEnabled&&u.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function kR({ides:e,emptyMessage:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){const s=e.filter(o=>o.type==="adhdev-daemon");return s.length===0?u.jsx(hR,{icon:"🔌",title:"No machines connected",description:t||"Run 'adhdev daemon' on your machine to connect."}):u.jsx("div",{className:"flex flex-col gap-2",children:s.map(o=>u.jsx(NR,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function D_({title:e,message:t,confirmLabel:r,confirmColor:n,onConfirm:i,onCancel:s}){const o=n==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return t0.createPortal(u.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:s,children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[u.jsx("div",{className:"font-semibold text-sm mb-3",children:e}),u.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:t}),u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),u.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:r})]})]})}),document.body)}const CR={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function ER(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return CR[t]||{icon:"📝",name:e}}function NR({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var O,z,V,D;const[s,o]=y.useState("idle"),[l,a]=y.useState(""),[c,d]=y.useState(null),[h,f]=y.useState("idle"),[p,m]=y.useState(""),_=e,w=_.version||_.daemonVersion||null,g=((O=_.machine)==null?void 0:O.hostname)||((z=_.system)==null?void 0:z.hostname)||"",v=((V=_.machine)==null?void 0:V.platform)||((D=_.system)==null?void 0:D.platform)||"",x=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",M=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),C=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),T=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),k=_.p2p,A=async()=>{var $,b,J;if(r){o("upgrading"),a("Installing latest version...");try{const re=await r(e.id,"daemon_upgrade",{});($=re==null?void 0:re.result)!=null&&$.upgraded||(b=re==null?void 0:re.result)!=null&&b.success?(o("done"),a(`Upgraded to v${re.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((J=re==null?void 0:re.result)==null?void 0:J.error)||"Upgrade failed"))}catch(re){o("error"),a((re==null?void 0:re.message)||"Connection lost during upgrade")}}},E=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},B=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},R="0.5.47",L=!w||w!==R,P=M.length+C.length+T.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:x}),u.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[u.jsxs("span",{children:[e.id.substring(0,12),"…"]}),w&&u.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${L?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!L&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&L&&u.jsx("button",{onClick:A,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${R}`,children:s==="upgrading"?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):s==="done"?"✓ Updated":`↑ Update${` to v${R}`}`}),n&&u.jsx("button",{onClick:()=>d("disconnect"),disabled:h==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&u.jsx("button",{onClick:()=>d("revoke"),disabled:h==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Revoke token (requires re-setup)",children:"Revoke"}),u.jsx(pR,{status:e.status==="online"?"online":"error"})]})]}),u.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[k&&u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${k.state==="connected"?"bg-green-400":k.state==="connecting"||k.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",k.state==="connected"?"connected":k.state==="connecting"||k.state==="new"?"connecting...":k.state||"off"]}),k.peers!==void 0&&k.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",k.peers," peer",k.peers!==1?"s":"",")"]})]}),k&&P>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),P>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[M.map($=>{const b=ER($.type),J=$.cdpConnected;return u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:b.icon}),u.jsx("span",{children:b.name}),J!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${J?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:J?"CDP connected":"CDP connecting..."})]},$.id)}),C.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),T.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(D_,{title:"🔌 Disconnect Machine",message:`Disconnect "${x}" from ADHDev?
|
|
172
|
+
This will terminate the CLI process.`))return;const _=e.ideId||e.daemonId||"";try{await a(_,"stop_cli",{cliType:m})}catch(g){console.error("Stop CLI failed:",g)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),u.jsx(w1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(b1,{ref:r,onInput:m=>{var g;const _=e.ideId||e.daemonId||"",w=(g=e.ideId)!=null&&g.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(_,{type:"pty_input",cliType:w,data:m})||a(_,"pty_input",{cliType:w,data:m}).catch(console.error)},onResize:(m,_)=>{var v;const w=e.ideId||e.daemonId||"",g=(v=e.ideId)!=null&&v.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(w,{type:"pty_resize",cliType:g,cols:m,rows:_})||a(w,"pty_resize",{cliType:g,cols:m,rows:_,force:!0}).catch(()=>{})}},e.tabKey)}),u.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:u.jsxs("div",{className:"flex gap-2.5 items-center",children:[u.jsx("div",{className:"flex-1 relative",children:u.jsx("input",{ref:l,type:"text",placeholder:`Send message to ${e.displayPrimary}...`,value:n,onChange:m=>i(m.target.value),onPaste:m=>{const _=m.clipboardData.getData("text");_&&i(w=>w+_),m.preventDefault()},onKeyDown:m=>{if(m.key==="Enter"){if(m.nativeEvent.isComposing){m.preventDefault();return}m.preventDefault(),s()}},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary border border-border-subtle text-[13px] text-text-primary"})}),u.jsx("button",{onClick:s,disabled:!n.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${n.trim()?"bg-accent cursor-pointer":"bg-bg-secondary cursor-default"}`,children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:n.trim()?"text-white":"text-text-muted",children:u.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function oM({wsStatus:e,showReconnected:t,loginUrl:r}){const n=e==="disconnected"||e==="reconnecting"||e==="offline"||e==="auth_failed",i=e==="auth_failed"?"red":e==="offline"?"orange":"violet",s={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},o={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},l={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return u.jsxs(u.Fragment,{children:[n&&u.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:s[i],borderBottom:o[i],color:l[i]},children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:e==="auth_failed"?.6:1,animation:e==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:e==="auth_failed"?"grayscale(1)":void 0}}),e==="offline"&&"Network offline — waiting for connection...",e==="disconnected"&&"Reconnecting to server...",e==="reconnecting"&&"Reconnecting to server...",e==="auth_failed"&&(r?u.jsxs(u.Fragment,{children:["Session expired."," ",u.jsx("a",{href:r,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),t&&e==="connected"&&u.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let lM=Ho;function Cc(){return lM()}class aM{constructor(){As(this,"listeners",new Map)}send(t){}isConnected(){return!1}on(t,r){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r),()=>{var n;(n=this.listeners.get(t))==null||n.delete(r)}}emit(t,...r){var n;(n=this.listeners.get(t))==null||n.forEach(i=>i(...r))}}let cM=new aM;class uM{constructor(){As(this,"ptyCallbacks",new Set)}sendPtyInput(t,r,n){return!1}sendPtyResize(t,r,n,i){return!1}async requestChatHistory(t,r,n,i,s){return{messages:[],hasMore:!1}}retryConnection(t){}getState(t){return"disconnected"}sendData(t,r){return!1}get(t){}onScreenshot(t,r){return()=>{}}onStatusEvent(t){return()=>{}}onPtyOutput(t){return this.ptyCallbacks.add(t),()=>{this.ptyCallbacks.delete(t)}}emitPtyOutput(t,r){this.ptyCallbacks.forEach(n=>n(t,r))}}let vr=new uM,y_=vr;const Mu=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),Ru=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function hM({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=En(),o=Cc(),l=o.p2pStates||{},a=o.ides||[],c=n?"#22c55e":r==="connected"?"#eab308":"#ef4444",d=n?"0 0 4px #22c55e80":r==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",h=a.filter(g=>g.type==="adhdev-daemon"),f=Object.values(l),p=f.filter(g=>g==="connected").length,m=f.filter(g=>g==="connecting"||g==="new"||g==="checking").length,w=r!=="connected"||h.length===0?null:m>0&&p===0?"P2P connecting...":p>0&&t===0?"Waiting for IDE...":null;return u.jsxs("div",{className:"dashboard-header",children:[u.jsx("div",{className:"flex items-center gap-3",children:u.jsxs("div",{className:"leading-tight",children:[u.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[u.jsx(Fa,{size:18}),u.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),u.jsx("span",{className:"header-title-mobile",children:(e==null?void 0:e.displayPrimary)||"Dashboard"}),u.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:u.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:c,boxShadow:d}})})]}),u.jsxs("div",{className:"header-subtitle text-[11px] items-center gap-1",children:[t," agent",t!==1?"s":""," active",u.jsx("span",{title:n?"Connected":r==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:c,boxShadow:d}}),w&&u.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",w]})]})]})}),u.jsxs("div",{className:"flex gap-2 items-center",children:[e&&!Mu(e)&&!Ru(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm border-none px-2.5 py-1.5 flex items-center gap-1 text-xs",title:"IDE View",children:[u.jsx(Py,{size:14})," IDE"]}),e&&!Mu(e)&&!Ru(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5 flex items-center gap-1",title:"Chat History",children:u.jsx(CP,{size:16})}),e&&!Mu(e)&&!Ru(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5",title:"Remote Control",children:u.jsx(ll,{size:16})})]})]})}function Rr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function dM(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const r=Math.floor(t/60),n=t%60;if(r<24)return n>0?`${r}h ${n}m`:`${r}h`;const i=Math.floor(r/24),s=r%24;return`${i}d ${s}h`}function b_(e){return e<1024*1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function w_(e){return(e.id||"").includes(":cli:")}function S_(e){return(e.id||"").includes(":acp:")}function Pd(e,t){return Rr(e)}function fM(e){if(!Array.isArray(e)||e.length<=1)return e;const t=new Map,r=["generating","streaming","active","connected","idle","panel_hidden"];for(const n of e){const i=(n.name||n.id||"").toLowerCase().replace(/\s+/g,"-"),s=t.get(i);if(!s){t.set(i,n);continue}const o=r.indexOf(s.status||"idle"),l=r.indexOf(n.status||"idle");l>=0&&(o<0||l<o)&&t.set(i,n)}return Array.from(t.values())}function pM({activeConv:e,ides:t,isCreatingChat:r,isRefreshingHistory:n,onClose:i,onNewChat:s,onSwitchSession:o,onRefreshHistory:l}){var h;const a=t.find(f=>f.id===e.ideId),c=(a==null?void 0:a.chats)||[],d=(h=a==null?void 0:a.activeChat)==null?void 0:h.id;return u.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[u.jsx("div",{onClick:i,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),u.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[u.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),u.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[e.displayPrimary," — ",Rr(e.ideType)]})]}),u.jsx("button",{onClick:i,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[u.jsx("button",{onClick:s,disabled:r,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:r?"⌛ Creating...":"+ Start New Chat Session"}),c.map(f=>u.jsxs("div",{onClick:()=>{o(e.ideId,f.id),i()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${d===f.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[u.jsx("div",{className:`font-bold text-sm mb-1 ${d===f.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:f.title||"Untitled Session"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[f.id.substring(0,12),"..."]}),d===f.id&&u.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},f.id)),c.length===0&&u.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[u.jsx("div",{className:"text-3xl mb-3 opacity-60",children:u.jsx(RP,{size:32})}),u.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),u.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:u.jsx("button",{onClick:l,disabled:n,className:"btn btn-secondary btn-sm rounded-[10px]",children:n?"⌛ Refreshing...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(NP,{size:13})," Refresh History"]})})})]})]})}const k_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function mM({toasts:e,onDismiss:t,onClickToast:r}){return u.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:e.map(n=>u.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px]",style:{background:k_[n.type]||k_.info},onClick:()=>{var i;(i=n.actions)!=null&&i.length||(r&&r(n),t(n.id))},children:[u.jsx("div",{children:n.message}),n.actions&&n.actions.length>0&&u.jsx("div",{className:"flex gap-2 mt-2",children:n.actions.map((i,s)=>u.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${i.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":i.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:o=>{o.stopPropagation(),i.onClick(),t(n.id)},children:i.label},s))})]},n.id))})}const gM=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function _M(e){return e.workspace||"Workspace"}function vM(e,t,r,n){var s;const i={};if(r)for(const o of r){const l=o;if(l.type==="adhdev-daemon"||l.daemonMode){const a=l.machine||{},c=l.machineNickname,d=a.hostname||((s=l.system)==null?void 0:s.hostname)||"",h=c||(d&&d!=="Unknown"?d.replace(/\.local$/,""):null)||`Machine ${(l.id||"").substring(0,6)}`;i[l.id]=h}}return e.flatMap(o=>{var w,g,v,x,S;const l=[],a=o.daemonId&&i[o.daemonId]||void 0,c=o.daemonId||((w=o.id)==null?void 0:w.split(":")[0])||o.id,d=n?n[c]||"new":void 0,h=_M(o),f=Rr(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(M=>({...M,activeModal:M.activeModal??void 0})):[],_=gM(o);if(_){const M=Pd(o.type),C=(g=o.agents)==null?void 0:g[0],T=(v=o.activeChat)==null?void 0:v.activeModal,k=T&&Array.isArray(T.buttons)&&T.buttons.length>0,A=(x=o.activeChat)==null?void 0:x.status,E=A==="generating"||A==="loading"||A&&A.toLowerCase()==="thinking",R=k||A==="waiting_approval"?"waiting_approval":E?"working":(C==null?void 0:C.status)||"idle",L=o.activeChat||{title:"",messages:[]};let P=L.title&&String(L.title).trim()?String(L.title).trim():"";const O=(S=o.activeChat)==null?void 0:S.id,z=o.chats;if(O&&Array.isArray(z)&&z.length>0){const J=z.find(re=>re.id===O||re.id&&String(re.id)===String(O));J!=null&&J.title&&String(J.title).trim()&&(P=String(J.title).trim())}const V=L.messages||[],D=t[o.id]||[],$=new Map;V.filter(J=>J.role==="user").forEach(J=>{$.set(J.content,($.get(J.content)||0)+1)});const b=D.filter(J=>{const re=$.get(J.content)||0;return re>0?($.set(J.content,re-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:M,agentType:ii(o)||ln(o)?o.type:(C==null?void 0:C.type)||"ide-native",status:R,title:P,messages:[...V,...b],ideType:o.type,workspaceName:h,displayPrimary:P||h,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:k?T.buttons:void 0,modalMessage:k?T.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(ii(o)||ln(o)))return l;for(const M of m){const C=M.activeModal&&Array.isArray(M.activeModal.buttons)&&M.activeModal.buttons.length>0,T=C?"waiting_approval":M.status==="streaming"?"working":M.status,k=`${o.id}:${M.agentType}`,A=M.messages||[],E=t[k]||[],B=new Map;A.filter(L=>L.role==="user").forEach(L=>{B.set(L.content,(B.get(L.content)||0)+1)});const R=E.filter(L=>{const P=B.get(L.content)||0;return P>0?(B.set(L.content,P-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:M.agentName,agentType:M.agentType,status:T,title:"",messages:[...A,...R],ideType:o.type,workspaceName:h,displayPrimary:h,displaySecondary:`${f}·${M.agentName}`,cdpConnected:o.cdpConnected,modalButtons:C?M.activeModal.buttons:void 0,modalMessage:C?M.activeModal.message:void 0,streamSource:"agent-stream",tabKey:k,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Pd(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:h,displayPrimary:h,displaySecondary:f,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:d}),l})}function xM(e,t){var l,a,c,d;const r=[],{daemonId:n,existingDaemon:i,timestamp:s}=t,o=s||e.timestamp||Date.now();r.push({...i||{},id:n,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...e.version&&{version:e.version},...e.machine&&{machine:e.machine,platform:e.machine.platform},...e.instanceId&&{instanceId:e.instanceId},...e.machineNickname!==void 0&&{machineNickname:e.machineNickname},...e.p2p&&{p2p:e.p2p},..."system"in e&&{system:e.system},..."hostname"in e&&{hostname:e.hostname},...e.workspaces&&{workspaces:e.workspaces},...e.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:e.defaultWorkspaceId},...e.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:e.defaultWorkspacePath},...e.workspaceActivity&&{workspaceActivity:e.workspaceActivity},...e.detectedIdes&&{detectedIdes:e.detectedIdes},..."availableProviders"in e&&{availableProviders:e.availableProviders},cdpConnected:e.managedIdes.some(h=>h.cdpConnected),managedIdeIds:e.managedIdes.map(h=>`${n}:ide:${h.instanceId}`),managedCliIds:e.managedClis.map(h=>h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`),managedAcpIds:e.managedAcps.map(h=>h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`)});for(const h of e.managedIdes)r.push({id:`${n}:ide:${h.instanceId}`,type:h.ideType,ideType:h.ideType,version:h.ideVersion,status:h.cdpConnected?"online":"detected",daemonId:n,instanceId:h.instanceId,workspace:h.workspace,terminals:h.terminals,agents:h.aiAgents,activeChat:h.activeChat,chats:h.chats,agentStreams:h.agentStreams,cdpConnected:h.cdpConnected,currentModel:h.currentModel,currentPlan:h.currentPlan,currentAutoApprove:h.currentAutoApprove,timestamp:o});for(const h of e.managedClis){const f=h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`;r.push({id:f,type:h.cliType,ideType:h.cliType,agentType:h.cliType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.cliName,mode:h.mode||"terminal",workspace:h.workspace,activeChat:h.activeChat,agentStreams:[{agentType:h.cliType,agentName:h.cliName,extensionId:"cli-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((l=h.activeChat)==null?void 0:l.messages)||[],inputContent:"",activeModal:(a=h.activeChat)==null?void 0:a.activeModal}],timestamp:o,_isCli:!0})}for(const h of e.managedAcps){const f=h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`;r.push({id:f,type:h.acpType,ideType:h.acpType,agentType:h.acpType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.acpName,mode:"chat",workspace:h.workspace,activeChat:h.activeChat,currentModel:h.currentModel,currentPlan:h.currentPlan,acpConfigOptions:h.acpConfigOptions,acpModes:h.acpModes,agentStreams:[{agentType:h.acpType,agentName:h.acpName,extensionId:"acp-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((c=h.activeChat)==null?void 0:c.messages)||[],inputContent:"",activeModal:(d=h.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isAcp:!0})}return r}function C1(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=C1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function yM(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=C1(e))&&(n&&(n+=" "),n+=t);return n}const bM=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},wM=(e,t)=>({classGroupId:e,validator:t}),E1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Xa="-",C_=[],SM="arbitrary..",kM=e=>{const t=EM(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return CM(o);const l=o.split(Xa),a=l[0]===""&&l.length>1?1:0;return N1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?bM(c,a):a:c||C_}return r[o]||C_}}},N1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=N1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(Xa):e.slice(t).join(Xa),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},CM=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?SM+n:void 0})(),EM=e=>{const{theme:t,classGroups:r}=e;return NM(r,t)},NM=(e,t)=>{const r=E1();for(const n in e){const i=e[n];ip(i,r,n,t)}return r},ip=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];TM(o,t,r,n)}},TM=(e,t,r,n)=>{if(typeof e=="string"){PM(e,t,r);return}if(typeof e=="function"){LM(e,t,r,n);return}MM(e,t,r,n)},PM=(e,t,r)=>{const n=e===""?t:T1(t,e);n.classGroupId=r},LM=(e,t,r,n)=>{if(RM(e)){ip(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(wM(r,e))},MM=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];ip(a,T1(t,l),r,n)}},T1=(e,t)=>{let r=e;const n=t.split(Xa),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=E1(),r.nextPart.set(o,l)),r=l}return r},RM=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,IM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},Ld="!",E_=":",DM=[],N_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),jM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const s=[];let o=0,l=0,a=0,c;const d=i.length;for(let _=0;_<d;_++){const w=i[_];if(o===0&&l===0){if(w===E_){s.push(i.slice(a,_)),a=_+1;continue}if(w==="/"){c=_;continue}}w==="["?o++:w==="]"?o--:w==="("?l++:w===")"&&l--}const h=s.length===0?i:i.slice(a);let f=h,p=!1;h.endsWith(Ld)?(f=h.slice(0,-1),p=!0):h.startsWith(Ld)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return N_(s,p,f,m)};if(t){const i=t+E_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):N_(DM,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},AM=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],l=o[0]==="[",a=t.has(o);l||a?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},BM=e=>({cache:IM(e.cacheSize),parseClassName:jM(e),sortModifiers:AM(e),...kM(e)}),OM=/\s+/,zM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(OM);let a="";for(let c=l.length-1;c>=0;c-=1){const d=l[c],{isExternal:h,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:_}=r(d);if(h){a=d+(a.length>0?" "+a:a);continue}let w=!!_,g=n(w?m.substring(0,_):m);if(!g){if(!w){a=d+(a.length>0?" "+a:a);continue}if(g=n(m),!g){a=d+(a.length>0?" "+a:a);continue}w=!1}const v=f.length===0?"":f.length===1?f[0]:s(f).join(":"),x=p?v+Ld:v,S=x+g;if(o.indexOf(S)>-1)continue;o.push(S);const M=i(g,w);for(let C=0;C<M.length;++C){const T=M[C];o.push(x+T)}a=d+(a.length>0?" "+a:a)}return a},$M=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=P1(r))&&(i&&(i+=" "),i+=n);return i},P1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=P1(e[n]))&&(r&&(r+=" "),r+=t);return r},FM=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=BM(c),n=r.cache.get,i=r.cache.set,s=l,l(a)},l=a=>{const c=n(a);if(c)return c;const d=zM(a,r);return i(a,d),d};return s=o,(...a)=>s($M(...a))},WM=[],Et=e=>{const t=r=>r[e]||WM;return t.isThemeGetter=!0,t},L1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,M1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,HM=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,UM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,VM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,qM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,An=e=>HM.test(e),De=e=>!!e&&!Number.isNaN(Number(e)),Bn=e=>!!e&&Number.isInteger(Number(e)),Iu=e=>e.endsWith("%")&&De(e.slice(0,-1)),hn=e=>UM.test(e),R1=()=>!0,XM=e=>VM.test(e)&&!KM.test(e),sp=()=>!1,GM=e=>qM.test(e),QM=e=>YM.test(e),JM=e=>!fe(e)&&!pe(e),ZM=e=>hi(e,j1,sp),fe=e=>L1.test(e),pi=e=>hi(e,A1,XM),T_=e=>hi(e,lR,De),eR=e=>hi(e,O1,R1),tR=e=>hi(e,B1,sp),P_=e=>hi(e,I1,sp),rR=e=>hi(e,D1,QM),$l=e=>hi(e,z1,GM),pe=e=>M1.test(e),Zs=e=>Hi(e,A1),nR=e=>Hi(e,B1),L_=e=>Hi(e,I1),iR=e=>Hi(e,j1),sR=e=>Hi(e,D1),Fl=e=>Hi(e,z1,!0),oR=e=>Hi(e,O1,!0),hi=(e,t,r)=>{const n=L1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Hi=(e,t,r=!1)=>{const n=M1.exec(e);return n?n[1]?t(n[1]):r:!1},I1=e=>e==="position"||e==="percentage",D1=e=>e==="image"||e==="url",j1=e=>e==="length"||e==="size"||e==="bg-size",A1=e=>e==="length",lR=e=>e==="number",B1=e=>e==="family-name",O1=e=>e==="number"||e==="weight",z1=e=>e==="shadow",aR=()=>{const e=Et("color"),t=Et("font"),r=Et("text"),n=Et("font-weight"),i=Et("tracking"),s=Et("leading"),o=Et("breakpoint"),l=Et("container"),a=Et("spacing"),c=Et("radius"),d=Et("shadow"),h=Et("inset-shadow"),f=Et("text-shadow"),p=Et("drop-shadow"),m=Et("blur"),_=Et("perspective"),w=Et("aspect"),g=Et("ease"),v=Et("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...S(),pe,fe],C=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],k=()=>[pe,fe,a],A=()=>[An,"full","auto",...k()],E=()=>[Bn,"none","subgrid",pe,fe],B=()=>["auto",{span:["full",Bn,pe,fe]},Bn,pe,fe],R=()=>[Bn,"auto",pe,fe],L=()=>["auto","min","max","fr",pe,fe],P=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...k()],V=()=>[An,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],D=()=>[An,"screen","full","dvw","lvw","svw","min","max","fit",...k()],$=()=>[An,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],b=()=>[e,pe,fe],J=()=>[...S(),L_,P_,{position:[pe,fe]}],re=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",iR,ZM,{size:[pe,fe]}],q=()=>[Iu,Zs,pi],j=()=>["","none","full",c,pe,fe],F=()=>["",De,Zs,pi],Y=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[De,Iu,L_,P_],Ce=()=>["","none",m,pe,fe],ke=()=>["none",De,pe,fe],Ke=()=>["none",De,pe,fe],ue=()=>[De,pe,fe],ve=()=>[An,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hn],breakpoint:[hn],color:[R1],container:[hn],"drop-shadow":[hn],ease:["in","out","in-out"],font:[JM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hn],shadow:[hn],spacing:["px",De],text:[hn],"text-shadow":[hn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",An,fe,pe,w]}],container:["container"],columns:[{columns:[De,fe,pe,l]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:M()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Bn,"auto",pe,fe]}],basis:[{basis:[An,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,An,"auto","initial","none",fe]}],grow:[{grow:["",De,pe,fe]}],shrink:[{shrink:["",De,pe,fe]}],order:[{order:[Bn,"first","last","none",pe,fe]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...P(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...P()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":P()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],"inline-size":[{inline:["auto",...D()]}],"min-inline-size":[{"min-inline":["auto",...D()]}],"max-inline-size":[{"max-inline":["none",...D()]}],"block-size":[{block:["auto",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],w:[{w:[l,"screen",...V()]}],"min-w":[{"min-w":[l,"screen","none",...V()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",r,Zs,pi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,oR,eR]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Iu,fe]}],"font-family":[{font:[nR,tR,t]}],"font-features":[{"font-features":[fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,pe,fe]}],"line-clamp":[{"line-clamp":[De,"none",pe,T_]}],leading:[{leading:[s,...k()]}],"list-image":[{"list-image":["none",pe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:b()}],"text-color":[{text:b()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",pe,pi]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[De,"auto",pe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bn,pe,fe],radial:["",pe,fe],conic:[Bn,pe,fe]},sR,rR]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:q()}],"gradient-via-pos":[{via:q()}],"gradient-to-pos":[{to:q()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:j()}],"rounded-s":[{"rounded-s":j()}],"rounded-e":[{"rounded-e":j()}],"rounded-t":[{"rounded-t":j()}],"rounded-r":[{"rounded-r":j()}],"rounded-b":[{"rounded-b":j()}],"rounded-l":[{"rounded-l":j()}],"rounded-ss":[{"rounded-ss":j()}],"rounded-se":[{"rounded-se":j()}],"rounded-ee":[{"rounded-ee":j()}],"rounded-es":[{"rounded-es":j()}],"rounded-tl":[{"rounded-tl":j()}],"rounded-tr":[{"rounded-tr":j()}],"rounded-br":[{"rounded-br":j()}],"rounded-bl":[{"rounded-bl":j()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Y(),"hidden","none"]}],"divide-style":[{divide:[...Y(),"hidden","none"]}],"border-color":[{border:b()}],"border-color-x":[{"border-x":b()}],"border-color-y":[{"border-y":b()}],"border-color-s":[{"border-s":b()}],"border-color-e":[{"border-e":b()}],"border-color-bs":[{"border-bs":b()}],"border-color-be":[{"border-be":b()}],"border-color-t":[{"border-t":b()}],"border-color-r":[{"border-r":b()}],"border-color-b":[{"border-b":b()}],"border-color-l":[{"border-l":b()}],"divide-color":[{divide:b()}],"outline-style":[{outline:[...Y(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,pe,fe]}],"outline-w":[{outline:["",De,Zs,pi]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,Fl,$l]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,Fl,$l]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[De,pi]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,Fl,$l]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[De,pe,fe]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[pe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,fe]}],filter:[{filter:["","none",pe,fe]}],blur:[{blur:Ce()}],brightness:[{brightness:[De,pe,fe]}],contrast:[{contrast:[De,pe,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,Fl,$l]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",De,pe,fe]}],"hue-rotate":[{"hue-rotate":[De,pe,fe]}],invert:[{invert:["",De,pe,fe]}],saturate:[{saturate:[De,pe,fe]}],sepia:[{sepia:["",De,pe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,fe]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[De,pe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[De,pe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,pe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,pe,fe]}],"backdrop-invert":[{"backdrop-invert":["",De,pe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[De,pe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[De,pe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",De,pe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",pe,fe]}],ease:[{ease:["linear","initial",g,pe,fe]}],delay:[{delay:[De,pe,fe]}],animate:[{animate:["none",v,pe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,pe,fe]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:ke()}],"rotate-x":[{"rotate-x":ke()}],"rotate-y":[{"rotate-y":ke()}],"rotate-z":[{"rotate-z":ke()}],scale:[{scale:Ke()}],"scale-x":[{"scale-x":Ke()}],"scale-y":[{"scale-y":Ke()}],"scale-z":[{"scale-z":Ke()}],"scale-3d":["scale-3d"],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[pe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],accent:[{accent:b()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:b()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,fe]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[De,Zs,pi,T_]}],stroke:[{stroke:["none",...b()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},cR=FM(aR);function Xo(...e){return cR(yM(e))}function uR({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Xo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Yi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Xo("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",n&&"border-l-[3px]",i),style:n?{borderLeftColor:n}:void 0,children:[(e||r)&&u.jsxs("div",{className:"mb-4",children:[e&&u.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[t&&u.jsx("span",{className:"mr-1.5",children:t}),e]}),r&&u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),s]})}function hR({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Xo("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[u.jsx("div",{className:"text-5xl mb-4 opacity-50",children:e}),u.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:t}),u.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:r}),n]})}const dR={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},fR={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function pR({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Xo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",dR[e],r),children:[u.jsx("span",{className:Xo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",fR[e])}),n]})}function mR(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function M_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function Du(e){return e==="system"?mR():e}function gR(){const[e,t]=y.useState(M_),[r,n]=y.useState(()=>Du(M_()));y.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),y.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),l=a=>{e==="system"&&n(a.matches?"light":"dark")};return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[e]);const i=y.useCallback(o=>{t(o),n(Du(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=y.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(Du(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}const R_={dark:"Dark",light:"Light",system:"System"};function _R({collapsed:e}){const{preference:t,cycleTheme:r}=gR(),n=t==="dark"?u.jsx(DP,{size:16}):t==="light"?u.jsx(IP,{size:16}):u.jsx(jP,{size:16});return u.jsxs("div",{className:`nav-item cursor-pointer ${e?"justify-center py-2.5 px-0":""}`,onClick:r,title:`Theme: ${R_[t]} (click to cycle)`,children:[u.jsx("span",{className:"nav-icon",children:n}),!e&&u.jsx("span",{className:"text-xs",children:R_[t]})]})}function Gi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}const $1="adhdev_notification_prefs",I_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function vR(){try{const e=localStorage.getItem($1);if(e){const t=JSON.parse(e);return{...I_,...t}}}catch{}return{...I_}}function xR(e){try{localStorage.setItem($1,JSON.stringify(e))}catch{}}let gn=vR(),ua=[];function yR(){ua.forEach(e=>e())}function bR(e){gn={...gn,...e},xR(gn),yR()}function wR(){const[,e]=y.useState(0);y.useEffect(()=>{const r=()=>e(n=>n+1);return ua.push(r),()=>{ua=ua.filter(n=>n!==r)}},[]);const t=y.useCallback(r=>{bR(r)},[]);return[{...gn},t]}function ju(e){if(!gn.globalEnabled)return!1;switch(e){case"disconnect":return gn.disconnectAlert;case"completion":return gn.completionAlert;case"approval":return gn.approvalAlert;case"browser":return gn.browserNotifications;default:return!0}}function SR({onPrefChange:e}){const[t,r]=wR(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Gi,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:t.globalEnabled,onChange:i=>n("globalEnabled",i)}),t.globalEnabled&&u.jsx("div",{className:"border-t border-border-subtle my-0.5"}),t.globalEnabled&&u.jsx(Gi,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:t.browserNotifications,onChange:i=>n("browserNotifications",i)}),t.globalEnabled&&t.browserNotifications&&u.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[u.jsx(Gi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Gi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Gi,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:t.disconnectAlert,onChange:i=>n("disconnectAlert",i)})]}),!t.globalEnabled&&u.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function kR({ides:e,emptyMessage:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){const s=e.filter(o=>o.type==="adhdev-daemon");return s.length===0?u.jsx(hR,{icon:"🔌",title:"No machines connected",description:t||"Run 'adhdev daemon' on your machine to connect."}):u.jsx("div",{className:"flex flex-col gap-2",children:s.map(o=>u.jsx(NR,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function D_({title:e,message:t,confirmLabel:r,confirmColor:n,onConfirm:i,onCancel:s}){const o=n==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return t0.createPortal(u.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:s,children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[u.jsx("div",{className:"font-semibold text-sm mb-3",children:e}),u.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:t}),u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),u.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:r})]})]})}),document.body)}const CR={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function ER(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return CR[t]||{icon:"📝",name:e}}function NR({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var O,z,V,D;const[s,o]=y.useState("idle"),[l,a]=y.useState(""),[c,d]=y.useState(null),[h,f]=y.useState("idle"),[p,m]=y.useState(""),_=e,w=_.version||_.daemonVersion||null,g=((O=_.machine)==null?void 0:O.hostname)||((z=_.system)==null?void 0:z.hostname)||"",v=((V=_.machine)==null?void 0:V.platform)||((D=_.system)==null?void 0:D.platform)||"",x=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",M=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),C=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),T=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),k=_.p2p,A=async()=>{var $,b,J;if(r){o("upgrading"),a("Installing latest version...");try{const re=await r(e.id,"daemon_upgrade",{});($=re==null?void 0:re.result)!=null&&$.upgraded||(b=re==null?void 0:re.result)!=null&&b.success?(o("done"),a(`Upgraded to v${re.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((J=re==null?void 0:re.result)==null?void 0:J.error)||"Upgrade failed"))}catch(re){o("error"),a((re==null?void 0:re.message)||"Connection lost during upgrade")}}},E=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},B=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},R="0.5.49",L=!w||w!==R,P=M.length+C.length+T.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:x}),u.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[u.jsxs("span",{children:[e.id.substring(0,12),"…"]}),w&&u.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${L?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!L&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&L&&u.jsx("button",{onClick:A,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${R}`,children:s==="upgrading"?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):s==="done"?"✓ Updated":`↑ Update${` to v${R}`}`}),n&&u.jsx("button",{onClick:()=>d("disconnect"),disabled:h==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&u.jsx("button",{onClick:()=>d("revoke"),disabled:h==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Revoke token (requires re-setup)",children:"Revoke"}),u.jsx(pR,{status:e.status==="online"?"online":"error"})]})]}),u.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[k&&u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${k.state==="connected"?"bg-green-400":k.state==="connecting"||k.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",k.state==="connected"?"connected":k.state==="connecting"||k.state==="new"?"connecting...":k.state||"off"]}),k.peers!==void 0&&k.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",k.peers," peer",k.peers!==1?"s":"",")"]})]}),k&&P>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),P>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[M.map($=>{const b=ER($.type),J=$.cdpConnected;return u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:b.icon}),u.jsx("span",{children:b.name}),J!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${J?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:J?"CDP connected":"CDP connecting..."})]},$.id)}),C.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),T.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(D_,{title:"🔌 Disconnect Machine",message:`Disconnect "${x}" from ADHDev?
|
|
173
173
|
|
|
174
174
|
This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
|
|
175
175
|
|
|
@@ -196,4 +196,4 @@ ${Ee}`,_localId:`sys_approval_${Date.now()}`};F(Xe=>{for(const Ge of Object.keys
|
|
|
196
196
|
}
|
|
197
197
|
`})]})}function FR(e){return e.split(":")[0]||""}function WR({renderHeaderActions:e}={}){var Ke,ue,ve;const{id:t}=d0(),r=En(),n=Cc(),i=n.ides||[],s=n.connectionStates||{},{sendCommand:o}=ci(),l=y.useMemo(()=>FR(t||""),[t]),a=y.useMemo(()=>i.find(Q=>Q.id===t),[i,t]),c=(a==null?void 0:a.type)||void 0,d=c?c.charAt(0).toUpperCase()+c.slice(1):"IDE",h=(a==null?void 0:a.activeChat)||null,f=(a==null?void 0:a.agentStreams)||[],p=n.isConnected??!0,m=s[l]||(p?"connected":"new"),_=y.useMemo(()=>i.find(Q=>Q.id===l||Q.daemonId===l),[i,l]),w=(_==null?void 0:_.machineNickname)||((Ke=_==null?void 0:_.machine)==null?void 0:Ke.hostname)||"",g=(a==null?void 0:a.workspace)||"",[v]=g0(),x=typeof window<"u"&&window.innerWidth<=768,S=v.get("view")||(x?"chat":"split"),[M,C]=y.useState(S),[T,k]=y.useState("native"),[A,E]=y.useState(""),[B,R]=y.useState(!1),[L,P]=y.useState(null),[O,z]=y.useState(null),[V,D]=y.useState([]),$=h==null?void 0:h.status,b=(((ve=(ue=h==null?void 0:h.activeModal)==null?void 0:ue.buttons)==null?void 0:ve.length)??0)>0,J=$==="generating"||$==="loading"||$&&$.toLowerCase()==="thinking",N=b||$==="waiting_approval"?"waiting_approval":J?"working":$||"idle",q=y.useMemo(()=>{var Q,ge;return{ideId:t||"",daemonId:l,agentName:Pd(c||""),agentType:c||"",status:N,title:(h==null?void 0:h.title)||"",messages:(h==null?void 0:h.messages)||[],ideType:c||"",workspaceName:(a==null?void 0:a.workspaceName)||"",displayPrimary:d,displaySecondary:(a==null?void 0:a.workspaceName)||"",cdpConnected:!0,modalButtons:(Q=h==null?void 0:h.activeModal)==null?void 0:Q.buttons,modalMessage:(ge=h==null?void 0:h.activeModal)==null?void 0:ge.message,streamSource:"native",tabKey:`ide-${t}`}},[t,l,c,h,a,d,N]),j=y.useMemo(()=>f.map(Q=>{var _e,Te;const ge=Q.activeModal?"waiting_approval":Q.status==="streaming"?"working":Q.status||"idle";return{ideId:t||"",daemonId:l,agentName:Q.agentName,agentType:Q.agentType,status:ge,title:"",messages:Q.messages.map((Z,xe)=>({role:Z.role,content:Z.content,kind:Z.kind,id:`${Q.agentType}-${xe}`,receivedAt:Z.timestamp})),ideType:Q.agentType,workspaceName:"",displayPrimary:Q.agentName,displaySecondary:"",cdpConnected:!0,modalButtons:(_e=Q.activeModal)==null?void 0:_e.buttons,modalMessage:(Te=Q.activeModal)==null?void 0:Te.message,streamSource:"agent-stream",tabKey:`agent-stream-${Q.agentType}`}}),[f,t,l]),F=y.useMemo(()=>T==="native"?q:j.find(Q=>Q.agentType===T)||q,[T,q,j]);y.useEffect(()=>l?vr.onScreenshot("ide-page",(ge,_e)=>{if(ge!==l)return;const Te=new FileReader;Te.onload=()=>P(Te.result),Te.readAsDataURL(_e)}):void 0,[l]),y.useEffect(()=>l?vr.onStatusEvent((ge,_e)=>{if(ge!==l)return;let Te="",Z="info";if(_e.event==="agent:generating_completed"?(Te=`✅ Task completed${_e.duration?` (${_e.duration}s)`:""}`,Z="success"):(_e.event==="agent:waiting_approval"||_e.event==="agent:approval_requested")&&(Te="⚡ Approval needed",Z="warning"),Te){const xe=Date.now();D(We=>[...We.slice(-4),{id:xe,message:Te,type:Z}]),setTimeout(()=>D(We=>We.filter(Pe=>Pe.id!==xe)),Z==="warning"?1e4:5e3)}}):void 0,[l]);const Y=y.useMemo(()=>{if(!t)return c;const Q=t.split(":");return Q.length>=3&&Q[1]==="ide"?Q.slice(2).join(":"):c},[t,c]);y.useEffect(()=>{const Q=l?vr.get(l):null;!Q||!(m==="connected")||(M!=="chat"&&Y?Q.startScreenshots(Y):Q.stopScreenshots(Y))},[M,m,Y,l]);const he=y.useCallback(async(Q,ge={})=>{if(!t)throw new Error("No IDE ID");const _e={...ge};if(!_e._targetInstance&&t){const Z=t.split(":");Z.length>=3&&(Z[1]==="ide"||Z[1]==="cli")&&(_e._targetInstance=Z.slice(2).join(":"),_e._targetType=Z[1])}const Te=l?vr.get(l):null;return Te!=null&&Te.hasCommandChannel?await Te.sendCommand(Q,_e):Te&&Te.connectionState!=="failed"&&Te.connectionState!=="closed"&&await new Promise(xe=>{const Fe=Date.now(),We=()=>{if(Te.hasCommandChannel)return xe(!0);if(Date.now()-Fe>3e3)return xe(!1);setTimeout(We,200)};We()})&&Te.hasCommandChannel?await Te.sendCommand(Q,_e):await o(t,Q,_e)},[t,l]),me=async()=>{const Q=A.trim();if(!(!Q||!t||B)){E(""),R(!0);try{await he("send_chat",{message:Q,text:Q,waitForResponse:!0,...T!=="native"&&{agentType:T}})}catch(ge){console.error("[IDE] Send failed:",ge)}finally{R(!1)}}},Ce=async Q=>{if(t)try{const ge=await o(t,"screenshot",{width:Q?Math.min(Q,1280):1280});ge!=null&&ge.success&&(ge!=null&&ge.base64)&&z(`data:image/jpeg;base64,${ge.base64}`)}catch(ge){console.error("[IDE] Screenshot failed:",ge)}},ke=f.length>0;return t?u.jsxs("div",{className:"ide-page",children:[u.jsxs("header",{className:"ide-header",children:[u.jsxs("div",{className:"ide-header-left",children:[u.jsxs("div",{className:"ide-title",children:[u.jsx(Fa,{size:16}),u.jsx("span",{className:"ide-name",children:d}),u.jsx("span",{className:"ide-name-mobile",children:"IDE"}),g&&u.jsx("span",{className:"ide-workspace",children:g}),u.jsx("span",{className:"ide-badge",children:"REMOTE"})]}),u.jsxs("div",{className:"ide-status-pill",children:[u.jsx("span",{className:`ide-dot ${m==="connected"?"online":"connecting"}`}),u.jsx("span",{className:"ide-status-text",children:m==="connected"?"Connected":m==="connecting"?"Connecting":"WS"})]}),w&&u.jsx("span",{className:"ide-machine-label",children:w})]}),u.jsxs("div",{className:"ide-header-right",children:[["chat","split","remote"].map(Q=>u.jsx("button",{className:"btn btn-secondary btn-sm",style:{border:M===Q?"1px solid var(--accent-primary)":"none",background:M===Q?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:M===Q?"var(--accent-primary)":void 0},onClick:()=>C(Q),children:Q==="chat"?u.jsx(Fa,{size:14}):Q==="split"?"⊞":u.jsx(ll,{size:14})},Q)),e&&e({daemonId:l,ideInstanceId:t||""}),u.jsxs("button",{className:"btn btn-primary btn-sm border-none px-3 py-1.5 text-xs flex items-center justify-center shrink-0",onClick:()=>r(-1),children:["←",u.jsx("span",{className:"hidden md:inline ml-1",children:"Back"})]})]})]}),u.jsxs("div",{className:"ide-content",children:[u.jsxs("div",{className:`ide-chat-panel ${M==="chat"?"full":""} ${M==="remote"?"hidden":""}`,children:[ke&&u.jsxs("div",{className:"ide-chat-tabs",children:[u.jsx("button",{className:`ide-chat-tab ${T==="native"?"active":""}`,onClick:()=>k("native"),children:d}),f.map(Q=>{const ge=T===Q.agentType,_e=Q.status==="waiting_approval"||!!Q.activeModal,Te=Q.status==="streaming";return u.jsxs("button",{className:`ide-chat-tab ${ge?"active":""}`,onClick:()=>k(Q.agentType),children:[u.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",marginRight:5,background:_e?"#f59e0b":Te?"var(--accent-primary)":"#64748b",boxShadow:Te?"0 0 6px var(--accent-primary)":"none"}}),Q.agentName,_e&&u.jsx("span",{className:"ide-ext-badge",style:{background:"#f59e0b22",color:"#f59e0b",marginLeft:4},children:"!"})]},Q.agentType)})]}),u.jsx(S1,{activeConv:F,ides:i,agentInput:A,setAgentInput:E,handleSendChat:me,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[],userName:n.userName})]}),u.jsx("div",{className:`ide-remote-panel ${M==="remote"?"full":""} ${M==="chat"?"hidden":""}`,children:u.jsx(rM,{screenshot:O,isCapturing:!1,onRefresh:Ce,addLog:()=>{},connState:m,connScreenshot:L,onAction:async(Q,ge)=>{const _e=l?vr.get(l):null;if(!_e||m!=="connected")return console.warn("[RemoteInput] P2P not connected"),{success:!1,error:"P2P not connected"};const Te=(a==null?void 0:a.instanceId)||Y;return await _e.sendInput(Q,ge,Te)}})})]}),V.length>0&&u.jsx("div",{className:"ide-toasts",children:V.map(Q=>u.jsx("div",{className:`ide-toast ${Q.type}`,onClick:()=>D(ge=>ge.filter(_e=>_e.id!==Q.id)),children:Q.message},Q.id))})]}):u.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function HR({machineId:e,sendDaemonCommand:t,logsEndRef:r}){const[n,i]=y.useState([]),[s,o]=y.useState(null),[l,a]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,m]=y.useState([]),[_,w]=y.useState([]),[g,v]=y.useState(null),[x,S]=y.useState(!1),[M,C]=y.useState(""),T=y.useRef(null),k=y.useCallback(q=>{T.current=q},[]),A=y.useCallback((q,j)=>{i(F=>[...F.slice(-100),{timestamp:Date.now(),level:q,message:j}]),setTimeout(()=>{var F;return(F=r.current)==null?void 0:F.scrollIntoView({behavior:"smooth"})},100)},[r]),E=y.useCallback(async q=>{if(!(!e||s)){o(q),A("info",`Launching ${Rr(q)}...`);try{const j=await t(e,"launch_ide",{ideType:q,enableCdp:!0});A(j!=null&&j.success?"info":"error",j!=null&&j.success?`${Rr(q)} launched`:`Failed: ${j==null?void 0:j.error}`)}catch(j){A("error",`Launch error: ${j.message}`)}finally{o(null)}}},[e,s,A,t]),B=y.useCallback(async q=>{if(!e)return;const{cliType:j,dir:F,workspaceId:Y,useDefaultWorkspace:he,useHome:me,argsStr:Ce,model:ke}=q;if(!j){A("warn","Select a CLI or ACP provider first");return}const Ke=Ce?Ce.split(/\s+/).filter(Boolean):void 0,ue=(F==null?void 0:F.trim())||(Y?"(saved id)":he?"(default workspace)":me?"(home)":"");A("info",`Launching ${j}${ue?` in ${ue}`:""}${ke?` (model: ${ke})`:""}...`);try{const ve={cliType:j,cliArgs:Ke,initialModel:ke||void 0};F!=null&&F.trim()?ve.dir=F.trim():Y?ve.workspaceId=Y:he?ve.useDefaultWorkspace=!0:me&&(ve.useHome=!0);const Q=await t(e,"launch_cli",ve),ge=(Q==null?void 0:Q.result)||Q;Q!=null&&Q.success?(A("info",`${j} launched`),(ge==null?void 0:ge.launchSource)==="home"?A("info","📂 Running in home directory (explicit choice)"):(ge==null?void 0:ge.launchSource)==="defaultWorkspace"&&A("info","📂 Using default workspace (explicit choice)")):(A("error",`Failed: ${(Q==null?void 0:Q.error)||(ge==null?void 0:ge.error)}`),(Q==null?void 0:Q.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&v({cliType:j,argsStr:Ce,model:ke}))}catch(ve){A("error",`Launch error: ${ve.message}`)}},[e,A,t]),R=y.useCallback((q,j,F,Y)=>{if(e){if(!q){A("warn","Select a provider");return}if(!j.trim()){v({cliType:q,argsStr:F,model:Y});return}B({cliType:q,dir:j,argsStr:F,model:Y})}},[e,A,B]),L=y.useCallback(async(q,j,F)=>{if(e&&window.confirm(`Stop ${q}?
|
|
198
198
|
This will terminate the process.`))try{const Y=await t(e,"stop_cli",{cliType:q,dir:j,_targetInstance:F});Y!=null&&Y.success?A("info",`${q} stopped`):A("error",`Stop failed: ${(Y==null?void 0:Y.error)||"Unknown error"}`)}catch(Y){A("error",`Stop failed: ${Y.message}`)}},[e,A,t]),P=y.useCallback(async q=>{try{await t(q.daemonId,"restart_ide",{ideType:q.type}),A("info",`${Rr(q.type)} restart initiated`)}catch(j){A("error",`Restart failed: ${j.message}`)}},[A,t]),O=y.useCallback(async q=>{if(window.confirm(`Stop ${Rr(q.type)}?
|
|
199
|
-
This will disconnect CDP and optionally kill the process.`))try{const j=await t(q.daemonId,"stop_ide",{ideType:q.type,killProcess:!0});j!=null&&j.success?A("info",`${Rr(q.type)} stopped`):A("error",`Stop failed: ${(j==null?void 0:j.error)||"Unknown error"}`)}catch(j){A("error",`Stop failed: ${j.message}`)}},[A,t]),z=y.useCallback(async()=>{if(e)try{const q=await t(e,"detect_ides",{});A("info",`Found ${((q==null?void 0:q.result)||[]).length} IDE(s)`)}catch(q){A("error",`Detection failed: ${q.message}`)}},[e,A,t]),V=y.useCallback(async()=>{if(e){a(!0);try{const q=await t(e,"get_recent_workspaces",{});q!=null&&q.success&&Array.isArray(q==null?void 0:q.result)&&w(q.result)}catch(q){A("error",`Failed: ${q.message}`)}finally{a(!1)}}},[e,A,t]),D=y.useCallback(async q=>{if(!(!e||!q.trim())){d(!0);try{const j=await t(e,"workspace_add",{path:q.trim()});j!=null&&j.success?A("info",`Workspace added: ${q.trim()}`):A("error",(j==null?void 0:j.error)||"workspace_add failed")}catch(j){A("error",j.message)}finally{d(!1)}return!0}},[e,A,t]),$=y.useCallback(async q=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const j=await t(e,"workspace_remove",{id:q});j!=null&&j.success?A("info","Workspace removed"):A("error",(j==null?void 0:j.error)||"workspace_remove failed")}catch(j){A("error",j.message)}finally{d(!1)}}},[e,A,t]),b=y.useCallback(async q=>{var j;if(e){d(!0);try{const F=await t(e,"workspace_set_default",q===null?{clear:!0}:{id:q});if(F!=null&&F.success){A("info",q?"Default workspace updated":"Default workspace cleared");const Y=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";Y&&((j=T.current)==null||j.call(T,Y))}else A("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){A("error",F.message)}finally{d(!1)}}},[e,A,t]),J=y.useCallback(async q=>{var F;if(!e||!q.trim())return;const j=q.trim();d(!0);try{const Y=await t(e,"workspace_set_default",{path:j});Y!=null&&Y.success?(A("info","Default workspace set from history"),(F=T.current)==null||F.call(T,j)):A("error",(Y==null?void 0:Y.error)||"Could not set default (path missing on disk?)")}catch(Y){A("error",Y.message)}finally{d(!1)}},[e,A,t]),re=y.useCallback(async()=>{var q;if(e){f(!0);try{const j=await t(e,"get_cli_history",{}),F=(j==null?void 0:j.history)??((q=j==null?void 0:j.result)==null?void 0:q.history);j!=null&&j.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),N=y.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:M}),A("info",`Nickname set to "${M||"(cleared)"}"`),S(!1)}catch(q){A("error",`Failed: ${q.message}`)}},[e,M,A,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:x,setEditingNickname:S,nicknameInput:M,setNicknameInput:C,addLog:A,handleLaunchIde:E,runLaunchCliCore:B,handleLaunchCli:R,handleStopCli:L,handleRestartIde:P,handleStopIde:O,handleDetectIdes:z,handleLoadRecentWorkspaces:V,handleWorkspaceAdd:D,handleWorkspaceRemove:$,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:J,loadCliHistory:re,handleSaveNickname:N,setOnDefaultWorkspaceChanged:k}}function UR(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function VR({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=En(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:w}=o,[g,v]=y.useState("");y.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),y.useEffect(()=>{d()},[d]);const x=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-x)/e.totalMem*100))):0,M=e.loadavg[0]||0,C=T=>{const k=i.find(A=>A.type===T);(k==null?void 0:k.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(zl,{icon:u.jsx(Sg,{size:16}),label:"Uptime",value:dM(e.uptime)}),u.jsx(zl,{icon:u.jsx(ll,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(zl,{icon:u.jsx(Py,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(zl,{icon:u.jsx(Ly,{size:16}),label:"ACPs",value:`${n.length}`})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),u.jsxs("div",{className:"flex gap-6",children:[u.jsx(x_,{value:Math.min(Math.round(M/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${M.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(x_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${b_(e.totalMem-x)} / ${b_(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`})]})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(Wa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:T=>void m(T.target.value===""?null:T.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(T=>u.jsx("option",{value:T.id,children:T.label||T.path},T.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:T=>v(T.target.value),onKeyDown:T=>T.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(T=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:T.path,children:T.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(T.id),children:"Remove"})]},T.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(Sg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((T,k)=>{const A=T.label||`${T.cliType} · ${(T.dir||"").split("/").filter(Boolean).pop()||T.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:T.dir,children:[s(T.cliType)," ",A]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:T.dir,children:T.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:T.cliType,dir:T.dir,argsStr:(T.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>C(T.cliType),children:"Open tab…"})]})]},`${T.cliType}-${T.dir}-${T.timestamp}-${k}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(T=>{const k=T.path.split("/").filter(Boolean).pop()||T.path,A=T.kind==="ide"?"IDE":T.kind==="cli"?"CLI":T.kind==="acp"?"ACP":T.kind==="default"||T.kind==="active"?"●":"",E=(T.kind==="cli"||T.kind==="acp")&&!!T.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:T.path,children:k}),A&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:A}),T.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:T.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:UR(T.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[E&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:T.agentType,dir:T.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(T.path),children:"Set default"})]})]},`${T.path}-${T.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(T=>{var A;const k=(T.agentStreams||[]).some(E=>E.status==="generating"||E.status==="streaming")||((A=T.activeChat)==null?void 0:A.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${T.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${k?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(T.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Rr(T.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:T.workspace||""}),k&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${k?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:k?"#fb923c":"#22c55e",boxShadow:k?"0 0 8px rgba(249,115,22,0.4)":"none",animation:k?"pulse-dot 1.5s infinite":"none"}})]},T.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(T=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(T.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:T.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:T.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:T.status==="stopped"?"#ef4444":"#22c55e"}})]},T.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(T=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${T.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(T.type)}),T.name||T.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:T.running?"#22c55e":"#475569"}})]},T.type))})]})]})}function KR({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=En(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=y.useState({}),[m,_]=y.useState(null),w=e.detectedIdes||[];return y.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),x=(v==null?void 0:v.result)||v;x!=null&&x.success&&(x!=null&&x.ides)&&p(x.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Rr(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ll,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const x=`${g.type}.${v.type}`;_(x);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(M=>M.type===v.type?{...M,enabled:!M.enabled}:M)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",w.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.map(g=>{const v=g.running||r.some(x=>(x.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Rr(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),w.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(EP,{size:12})," Scan"]})]})]})]})}function j_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=En(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,w=e==="cli",g=w?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=w?"CLI":"ACP Agent",x=r.filter(L=>L.category===e),[S,M]=y.useState(""),[C,T]=y.useState(""),[k,A]=y.useState(""),[E,B]=y.useState("");y.useEffect(()=>{!S&&x.length>0&&M(x[0].type)},[S,x.length]),y.useEffect(()=>{t.defaultWorkspacePath&&!C&&T(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const R=L=>w?L.cliName:L.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:L=>M(L.target.value),className:"machine-input",children:x.length>0?x.map(L=>u.jsxs("option",{value:L.type,children:[L.icon," ",L.displayName]},L.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:C,onChange:L=>T(L.target.value),className:"machine-input flex-1 min-w-[200px]"}),!w&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:E,onChange:L=>B(L.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:k,onChange:L=>A(L.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,C,k||void 0,w?void 0:E||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:k||void 0,model:w?void 0:E||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:k||void 0,model:w?void 0:E||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",w?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(L=>{const P=w?null:L;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(L.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:R(L)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:L.workspace}),(P==null?void 0:P.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",P.currentModel]}),(P==null?void 0:P.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",P.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${L.status==="stopped"?"bg-red-500/[0.08] text-red-500":L.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:L.status}),!w&&u.jsx("button",{onClick:()=>o(`/ide/${L.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Fa,{size:14})}),L.status==="stopped"?u.jsx("button",{onClick:()=>l(L.type,L.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(L.type,L.workspace,L.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},L.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const L=new Set(x.map(O=>O.type)),P=p.filter(O=>L.has(O.cliType));return P.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:P.map((O,z)=>{var V,D;return u.jsxs("div",{onClick:()=>{M(O.cliType),T(O.dir),A((O.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-[background] duration-150",onMouseEnter:$=>$.currentTarget.style.background="var(--bg-glass-hover)",onMouseLeave:$=>$.currentTarget.style.background="var(--bg-glass)",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(O.cliType)}),u.jsx("span",{children:((V=O.dir)==null?void 0:V.split("/").filter(Boolean).pop())||"root"}),((D=O.cliArgs)==null?void 0:D.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:O.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:O.timestamp?new Date(O.timestamp).toLocaleDateString():""})]},z)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",w?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((L,P)=>u.jsx("button",{onClick:()=>T(L),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:L,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Wa,{size:12})," ",L.split("/").filter(Boolean).pop()||L]})},P))})]})]})}function qR({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=y.useState([]),[s,o]=y.useState(!1),[l,a]=y.useState(null),[c,d]=y.useState("all"),h=y.useCallback(async()=>{var p;if(e){o(!0);try{const m=await r(e,"get_provider_settings",{}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&(_!=null&&_.settings)){const w=[];for(const[g,v]of Object.entries(_.settings)){const x=t.find(S=>S.type===g);w.push({type:g,displayName:(x==null?void 0:x.displayName)||g,icon:(x==null?void 0:x.icon)||"",category:(x==null?void 0:x.category)||"unknown",schema:v,values:((p=_.values)==null?void 0:p[g])||{}})}w.sort((g,v)=>g.category.localeCompare(v.category)||g.displayName.localeCompare(v.displayName)),i(w)}}catch{}o(!1)}},[e,t,r]);y.useEffect(()=>{n.length===0&&h()},[]);const f=async(p,m,_)=>{a(`${p}.${m}`),i(w=>w.map(g=>g.type===p?{...g,values:{...g.values,[m]:_}}:g));try{const w=await r(e,"set_provider_setting",{providerType:p,key:m,value:_});w!=null&&w.success||h()}catch{h()}a(null)};return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-4",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(p=>u.jsx("button",{onClick:()=>d(p),className:`machine-btn text-[10px] px-2 py-0.5 ${c===p?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:p.toUpperCase()},p))]}),u.jsx("button",{onClick:h,disabled:s,className:"machine-btn",children:s?"⏳ Loading...":"↻ Refresh"})]}),c!=="all"&&n.filter(p=>p.category===c).length>1&&(()=>{const p=n.filter(g=>g.category===c),m=new Map;for(const g of p)for(const v of g.schema){if(v.type!=="boolean")continue;const x=m.get(v.key),S=!!(g.values[v.key]??v.default);x?(x.onCount+=S?1:0,x.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const w=async(g,v)=>{for(const x of p)await f(x.type,g,v)};return u.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[u.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",c.toUpperCase()," providers (",p.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([g,v])=>{const x=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void w(g,!0),disabled:x,className:`machine-btn text-[9px] px-1.5 py-px ${x?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void w(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const w=parseInt(_.target.value)||0;m.min!==void 0&&w<m.min||m.max!==void 0&&w>m.max||f(p.type,m.key,w)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function YR({machineId:e,sendDaemonCommand:t}){const[r,n]=y.useState([]),[i,s]=y.useState(0),[o,l]=y.useState(!0),[a,c]=y.useState("debug"),d=y.useRef(null),h=y.useRef(!1);return y.useEffect(()=>{if(!e||!o)return;const f=async()=>{try{const m=await t(e,"get_logs",{count:200,minLevel:a,since:i}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&Array.isArray(_==null?void 0:_.logs)&&_.logs.length>0){n(g=>[...g,..._.logs.map(x=>({timestamp:x.ts,level:x.level,message:`[${x.category}] ${x.message}`}))].slice(-300));const w=Math.max(..._.logs.map(g=>g.ts));s(w)}}catch{}};f();const p=setInterval(f,3e3);return()=>clearInterval(p)},[e,o,i,a,t]),y.useEffect(()=>{if(o&&r.length>0){const f=h.current?"smooth":"instant";setTimeout(()=>{var p;(p=d.current)==null||p.scrollIntoView({behavior:f}),h.current=!0},50)}},[r.length,o]),u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(f=>u.jsx("button",{onClick:()=>{c(f),n([]),s(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${a===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsxs("span",{className:"text-[10px] text-text-muted",children:[r.length," entries"]}),u.jsx("button",{onClick:()=>l(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),u.jsx("button",{onClick:()=>{n([]),s(0)},className:"machine-btn",children:"Clear"})]})]}),u.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[r.length===0&&u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),r.map((f,p)=>u.jsxs("div",{className:"flex gap-2 py-px",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#64748b":"#94a3b8"},children:[u.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(f.timestamp).toLocaleTimeString()}),u.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#475569":"#8b5cf6"},children:f.level==="error"?"ERR":f.level==="warn"?"WRN":f.level==="debug"?"DBG":"INF"}),u.jsx("span",{children:f.message})]},p)),u.jsx("div",{ref:d})]})]})}function XR({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/[0.08] transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function GR(){var S,M,C,T,k,A,E,B,R,L;const{id:e}=d0(),t=En(),{sendCommand:r}=ci(),n=Cc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=y.useState("overview"),a=y.useRef(null),c=HR({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(P=>P.id===e&&P.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(P=>({type:P.type,displayName:P.displayName,icon:P.icon,category:P.category})),f={};for(const P of h)f[P.type]=P.icon;const p=P=>f[P]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((M=d.machine)==null?void 0:M.platform)||"unknown",arch:((C=d.machine)==null?void 0:C.arch)||"",cpus:((T=d.machine)==null?void 0:T.cpus)||0,totalMem:((k=d.machine)==null?void 0:k.totalMem)||0,freeMem:((A=d.machine)==null?void 0:A.freeMem)||0,availableMem:(E=d.machine)==null?void 0:E.availableMem,loadavg:((B=d.machine)==null?void 0:B.loadavg)||[],uptime:((R=d.machine)==null?void 0:R.uptime)||0,release:((L=d.machine)==null?void 0:L.release)||"",cdpConnected:!!(d.ides||[]).some(P=>P.cdpConnected),machineNickname:d.machineNickname||null,p2p:d.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:d.detectedIdes||[],managedIdeIds:d.managedIdeIds||[],managedCliIds:d.managedCliIds||[],workspaces:d.workspaces||[],defaultWorkspaceId:d.defaultWorkspaceId??d.activeWorkspaceId??null,defaultWorkspacePath:d.defaultWorkspacePath??d.activeWorkspacePath??null,workspaceActivity:d.workspaceActivity||[]}:null,_=i.filter(P=>P.daemonId===e&&!P.daemonMode).filter(P=>!w_(P)&&!S_(P)).map(P=>({id:P.id,type:P.type,version:P.version||"",instanceId:P.instanceId||"",status:P.status,workspace:P.workspace||null,terminals:P.terminals||0,aiAgents:fM(P.aiAgents||P.agents||[]),activeChat:P.activeChat||null,chats:P.chats||[],agentStreams:P.agentStreams||[],cdpConnected:P.cdpConnected||!1,daemonId:e})),w=i.filter(P=>P.daemonId===e&&w_(P)).map(P=>({id:P.id,type:P.type,cliName:P.cliName||P.type,status:P.status,workspace:P.workspace||"",activeChat:P.activeChat||null,daemonId:e})),g=i.filter(P=>P.daemonId===e&&S_(P)).map(P=>({id:P.id,type:P.type,acpName:P.cliName||P.type,status:P.status,workspace:P.workspace||"",activeChat:P.activeChat||null,currentModel:P.currentModel,currentPlan:P.currentPlan,daemonId:e}));if(!m)return s?u.jsxs("div",{className:"p-10 text-center text-text-muted",children:[u.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),u.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):u.jsx("div",{className:"p-10 text-center text-text-muted",children:u.jsx("p",{children:"⏳ Loading machine..."})});const v=m.machineNickname||m.hostname,x=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(PP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ll,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ty,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ly,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ey,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(SP,{size:14})," Logs"]})}];return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[u.jsx("div",{className:"flex items-center justify-between w-full",children:u.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[c.editingNickname?u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsx("input",{autoFocus:!0,value:c.nicknameInput,onChange:P=>c.setNicknameInput(P.target.value),onKeyDown:P=>{P.key==="Enter"&&c.handleSaveNickname(),P.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:x.map(P=>u.jsxs("button",{onClick:()=>l(P.id),className:`machine-tab shrink-0${o===P.id?" active":""}`,children:[P.label,P.count!==void 0&&u.jsx("span",{className:"tab-count",children:P.count})]},P.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(VR,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:P=>l(P)}),o==="ides"&&u.jsx(KR,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(j_,{category:"cli",machine:m,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(j_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(qR,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(YR,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(XR,{machine:m,launchPick:c.launchPick,actions:c})]})}function QR(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,n=new URLSearchParams(window.location.search).get("token");return n?`${t}?token=${encodeURIComponent(n)}`:t}const A_=QR(),B_=3e3,JR=3e4;let mn=null,ZR=0;const Ga=new Map,Md=new Set;let gi=null;async function ha(e,t,r){const n=mn;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++ZR}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{Ga.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);Ga.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),n.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:r||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:r||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class eI{constructor(t){As(this,"daemonId");As(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN}get connectionState(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return ha(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return ha(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,gi&&(clearInterval(gi),gi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await ha(n,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const s=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());Md.forEach(o=>o(this.daemonId,s))}}catch{}};r(),gi=setInterval(r,2e3)}stopScreenshots(t){gi&&(clearInterval(gi),gi=null)}}let _i=null;function tI(e){(!_i||_i.daemonId!==e)&&(_i=new eI(e));const t=vr._originalGet||vr.get.bind(vr);vr._originalGet=t,vr.get=r=>r===e||r.startsWith("standalone")?_i:t(r),vr.getState=r=>(r===e||r.startsWith("standalone"))&&(_i==null?void 0:_i.connectionState)||"disconnected",vr.onScreenshot=(r,n)=>(Md.add(n),()=>{Md.delete(n)})}function rI({children:e}){const t=y.useRef(Cm()),r=Cm();t.current=r;const{setUserName:n}=Ho(),i=y.useRef(n);i.current=n;const[,s]=y.useState("disconnected"),o=y.useRef(null),l=y.useRef(),a=y.useRef(B_),c=y.useRef(!0);return y.useEffect(()=>{c.current=!0;function d(){var p,m;if(!c.current||((p=o.current)==null?void 0:p.readyState)===WebSocket.OPEN||((m=o.current)==null?void 0:m.readyState)===WebSocket.CONNECTING)return;s("connecting"),console.log(`[Standalone WS] Connecting to ${A_}...`);let f;try{f=new WebSocket(A_)}catch(_){console.error("[Standalone WS] Failed to create WebSocket:",_),h();return}o.current=f,f.onopen=()=>{if(!c.current){f.close();return}s("connected"),a.current=B_,console.log("[Standalone WS] Connected")},mn=f,f.onmessage=_=>{var w;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=Ga.get(g.requestId);v&&(Ga.delete(g.requestId),g.type==="error"?v.reject(new Error(((w=g.data)==null?void 0:w.message)||"Command failed")):v.resolve(g.data));return}if(g.type==="status"||g.type==="initial_state"){const v=g.data;if(!v)return;const{injectEntries:x,markLoaded:S}=t.current,M=v.id||"standalone";tI(M);const C=xM(v,{daemonId:M});C.length>0&&x(C),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,JR),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,mn=null)}},[]),u.jsx(u.Fragment,{children:e})}function nI({children:e}){return u.jsx(yk,{children:u.jsx(rI,{children:e})})}const iI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(bP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(wP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(Ey,{}),label:"Settings"}];function sI({children:e}){const t=En(),r=nl(),[n,i]=y.useState(!1),[s,o]=y.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=d=>{t(d),i(!1)},a=()=>{o(d=>{const h=!d;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})},c=d=>`nav-item${r.pathname.startsWith(d)?" active":""} cursor-pointer ${s?"justify-center py-2.5 px-0":""}`;return u.jsxs("div",{className:`app-layout${n?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[u.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"})]}),n&&u.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:d=>d.key==="Escape"&&i(!1)}),u.jsxs("aside",{className:`sidebar ${n?"sidebar-open":""}`,children:[u.jsxs("div",{className:"sidebar-header",children:[u.jsxs("div",{className:`sidebar-logo ${s?"justify-center gap-0":""}`,children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!s&&u.jsx("span",{children:"ADHDev"})]}),u.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),u.jsx("nav",{className:"sidebar-nav",children:iI.map(d=>u.jsxs("div",{className:c(d.path),id:`nav-${d.id}`,onClick:()=>l(d.path),title:s?d.label:void 0,children:[u.jsx("span",{className:"nav-icon",children:d.icon}),!s&&d.label]},d.id))}),u.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[u.jsxs("div",{className:`nav-item cursor-pointer${r.pathname==="/about"?" active":""} ${s?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>t("/about"),title:s?"About":void 0,children:[u.jsx("span",{className:"nav-icon",children:u.jsx(kP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.5.47"]}),u.jsx(_R,{collapsed:s}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const oI=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],lI=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],aI=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],Ou={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function cI(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.5.47"]})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:oI.map(e=>u.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[u.jsx("div",{className:"text-xl mb-1.5",children:e.icon}),u.jsx("div",{className:"font-semibold text-[13px] mb-1",children:e.title}),u.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:e.desc})]},e.title))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:Ou.ides},{label:"Extension agents",items:Ou.agents},{label:"CLI agents",items:Ou.cli}].map(e=>u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:e.label}),u.jsx("div",{className:"flex flex-col gap-1",children:e.items.map(t=>u.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:t},t))})]},e.label))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),u.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:u.jsxs("table",{className:"w-full text-[13px]",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-bg-secondary",children:[u.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),u.jsx("tbody",{children:aI.map((e,t)=>u.jsxs("tr",{className:t%2===0?"bg-bg-glass":"",children:[u.jsx("td",{className:"px-4 py-2 text-text-secondary",children:e.feature}),u.jsx("td",{className:"text-center px-4 py-2",children:e.selfhost?u.jsx("span",{className:"text-emerald-500",children:"✓"}):u.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),u.jsx("td",{className:"text-center px-4 py-2",children:u.jsx("span",{className:"text-emerald-500",children:"✓"})})]},e.feature))})]})})]}),u.jsx("section",{className:"mb-10",children:u.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),u.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:lI.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 ADHDev · Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function uI(){const{ides:e}=Ho(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ci(),{userName:i}=Ho(),[s,o]=y.useState(i||"");y.useEffect(()=>{i!==void 0&&o(i)},[i]);const l=h=>{const f=h.target.value.trim();t!=null&&t.id&&f!==i&&n(t.id,"set_user_name",{userName:f}).catch(console.error)},[a,c]=y.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=h=>{c(h);try{localStorage.setItem("adhdev_sound",h?"1":"0")}catch{}};return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx(uR,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Yi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.5.47"]}),u.jsx("span",{className:"text-text-muted",children:"Status"}),u.jsx("span",{className:t?"text-green-400":"text-yellow-400",children:t?"● Running":"○ Not connected"}),u.jsx("span",{className:"text-text-muted",children:"WebSocket"}),u.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),u.jsx("span",{className:"text-text-muted",children:"HTTP"}),u.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),u.jsx(Yi,{title:"Detected IDEs",className:"mb-4",children:r.length===0?u.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(h=>u.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:`w-2 h-2 rounded-full ${h.running?"bg-green-400":"bg-text-muted/30"}`}),u.jsx("span",{className:"text-sm font-medium",children:h.name})]}),u.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:h.type})]},h.type))})}),u.jsx(Yi,{title:"Machine",className:"mb-4",children:u.jsx(kR,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Yi,{title:"Chat theme",className:"mb-4",children:u.jsx(MR,{})}),u.jsx(Yi,{title:"Notifications",className:"mb-4",children:u.jsx(SR,{})}),u.jsx(Yi,{title:"Preferences",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-hover transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]}),u.jsx(Gi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})})]})]})}LR();function O_(){const{ides:e}=Ho(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(ea,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(ea,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(ea,{to:"/dashboard",replace:!0})}function hI(){return u.jsx(vk,{children:u.jsx(nI,{children:u.jsx(kk,{value:{sendCommand:ha,sendData:()=>!1},children:u.jsx(sI,{children:u.jsxs(pk,{children:[u.jsx(dn,{path:"/dashboard",element:u.jsx($R,{})}),u.jsx(dn,{path:"/ide/:id",element:u.jsx(WR,{})}),u.jsx(dn,{path:"/machine",element:u.jsx(O_,{})}),u.jsx(dn,{path:"/machines/:id",element:u.jsx(GR,{})}),u.jsx(dn,{path:"/machines",element:u.jsx(O_,{})}),u.jsx(dn,{path:"/about",element:u.jsx(cI,{})}),u.jsx(dn,{path:"/settings",element:u.jsx(uI,{})}),u.jsx(dn,{path:"*",element:u.jsx(ea,{to:"/dashboard",replace:!0})})]})})})})})}r0(document.getElementById("root")).render(u.jsx(y.StrictMode,{children:u.jsx(hI,{})}));
|
|
199
|
+
This will disconnect CDP and optionally kill the process.`))try{const j=await t(q.daemonId,"stop_ide",{ideType:q.type,killProcess:!0});j!=null&&j.success?A("info",`${Rr(q.type)} stopped`):A("error",`Stop failed: ${(j==null?void 0:j.error)||"Unknown error"}`)}catch(j){A("error",`Stop failed: ${j.message}`)}},[A,t]),z=y.useCallback(async()=>{if(e)try{const q=await t(e,"detect_ides",{});A("info",`Found ${((q==null?void 0:q.result)||[]).length} IDE(s)`)}catch(q){A("error",`Detection failed: ${q.message}`)}},[e,A,t]),V=y.useCallback(async()=>{if(e){a(!0);try{const q=await t(e,"get_recent_workspaces",{});q!=null&&q.success&&Array.isArray(q==null?void 0:q.result)&&w(q.result)}catch(q){A("error",`Failed: ${q.message}`)}finally{a(!1)}}},[e,A,t]),D=y.useCallback(async q=>{if(!(!e||!q.trim())){d(!0);try{const j=await t(e,"workspace_add",{path:q.trim()});j!=null&&j.success?A("info",`Workspace added: ${q.trim()}`):A("error",(j==null?void 0:j.error)||"workspace_add failed")}catch(j){A("error",j.message)}finally{d(!1)}return!0}},[e,A,t]),$=y.useCallback(async q=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const j=await t(e,"workspace_remove",{id:q});j!=null&&j.success?A("info","Workspace removed"):A("error",(j==null?void 0:j.error)||"workspace_remove failed")}catch(j){A("error",j.message)}finally{d(!1)}}},[e,A,t]),b=y.useCallback(async q=>{var j;if(e){d(!0);try{const F=await t(e,"workspace_set_default",q===null?{clear:!0}:{id:q});if(F!=null&&F.success){A("info",q?"Default workspace updated":"Default workspace cleared");const Y=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";Y&&((j=T.current)==null||j.call(T,Y))}else A("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){A("error",F.message)}finally{d(!1)}}},[e,A,t]),J=y.useCallback(async q=>{var F;if(!e||!q.trim())return;const j=q.trim();d(!0);try{const Y=await t(e,"workspace_set_default",{path:j});Y!=null&&Y.success?(A("info","Default workspace set from history"),(F=T.current)==null||F.call(T,j)):A("error",(Y==null?void 0:Y.error)||"Could not set default (path missing on disk?)")}catch(Y){A("error",Y.message)}finally{d(!1)}},[e,A,t]),re=y.useCallback(async()=>{var q;if(e){f(!0);try{const j=await t(e,"get_cli_history",{}),F=(j==null?void 0:j.history)??((q=j==null?void 0:j.result)==null?void 0:q.history);j!=null&&j.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),N=y.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:M}),A("info",`Nickname set to "${M||"(cleared)"}"`),S(!1)}catch(q){A("error",`Failed: ${q.message}`)}},[e,M,A,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:x,setEditingNickname:S,nicknameInput:M,setNicknameInput:C,addLog:A,handleLaunchIde:E,runLaunchCliCore:B,handleLaunchCli:R,handleStopCli:L,handleRestartIde:P,handleStopIde:O,handleDetectIdes:z,handleLoadRecentWorkspaces:V,handleWorkspaceAdd:D,handleWorkspaceRemove:$,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:J,loadCliHistory:re,handleSaveNickname:N,setOnDefaultWorkspaceChanged:k}}function UR(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function VR({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=En(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:w}=o,[g,v]=y.useState("");y.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),y.useEffect(()=>{d()},[d]);const x=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-x)/e.totalMem*100))):0,M=e.loadavg[0]||0,C=T=>{const k=i.find(A=>A.type===T);(k==null?void 0:k.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(zl,{icon:u.jsx(Sg,{size:16}),label:"Uptime",value:dM(e.uptime)}),u.jsx(zl,{icon:u.jsx(ll,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(zl,{icon:u.jsx(Py,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(zl,{icon:u.jsx(Ly,{size:16}),label:"ACPs",value:`${n.length}`})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),u.jsxs("div",{className:"flex gap-6",children:[u.jsx(x_,{value:Math.min(Math.round(M/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${M.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(x_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${b_(e.totalMem-x)} / ${b_(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`})]})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(Wa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:T=>void m(T.target.value===""?null:T.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(T=>u.jsx("option",{value:T.id,children:T.label||T.path},T.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:T=>v(T.target.value),onKeyDown:T=>T.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(T=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:T.path,children:T.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(T.id),children:"Remove"})]},T.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(Sg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((T,k)=>{const A=T.label||`${T.cliType} · ${(T.dir||"").split("/").filter(Boolean).pop()||T.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:T.dir,children:[s(T.cliType)," ",A]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:T.dir,children:T.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:T.cliType,dir:T.dir,argsStr:(T.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>C(T.cliType),children:"Open tab…"})]})]},`${T.cliType}-${T.dir}-${T.timestamp}-${k}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(T=>{const k=T.path.split("/").filter(Boolean).pop()||T.path,A=T.kind==="ide"?"IDE":T.kind==="cli"?"CLI":T.kind==="acp"?"ACP":T.kind==="default"||T.kind==="active"?"●":"",E=(T.kind==="cli"||T.kind==="acp")&&!!T.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:T.path,children:k}),A&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:A}),T.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:T.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:UR(T.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[E&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:T.agentType,dir:T.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(T.path),children:"Set default"})]})]},`${T.path}-${T.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(T=>{var A;const k=(T.agentStreams||[]).some(E=>E.status==="generating"||E.status==="streaming")||((A=T.activeChat)==null?void 0:A.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${T.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${k?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(T.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Rr(T.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:T.workspace||""}),k&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${k?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:k?"#fb923c":"#22c55e",boxShadow:k?"0 0 8px rgba(249,115,22,0.4)":"none",animation:k?"pulse-dot 1.5s infinite":"none"}})]},T.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(T=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(T.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:T.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:T.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:T.status==="stopped"?"#ef4444":"#22c55e"}})]},T.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(T=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${T.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(T.type)}),T.name||T.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:T.running?"#22c55e":"#475569"}})]},T.type))})]})]})}function KR({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=En(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=y.useState({}),[m,_]=y.useState(null),w=e.detectedIdes||[];return y.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),x=(v==null?void 0:v.result)||v;x!=null&&x.success&&(x!=null&&x.ides)&&p(x.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Rr(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ll,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const x=`${g.type}.${v.type}`;_(x);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(M=>M.type===v.type?{...M,enabled:!M.enabled}:M)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",w.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.map(g=>{const v=g.running||r.some(x=>(x.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Rr(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),w.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(EP,{size:12})," Scan"]})]})]})]})}function j_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=En(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,w=e==="cli",g=w?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=w?"CLI":"ACP Agent",x=r.filter(L=>L.category===e),[S,M]=y.useState(""),[C,T]=y.useState(""),[k,A]=y.useState(""),[E,B]=y.useState("");y.useEffect(()=>{!S&&x.length>0&&M(x[0].type)},[S,x.length]),y.useEffect(()=>{t.defaultWorkspacePath&&!C&&T(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const R=L=>w?L.cliName:L.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:L=>M(L.target.value),className:"machine-input",children:x.length>0?x.map(L=>u.jsxs("option",{value:L.type,children:[L.icon," ",L.displayName]},L.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:C,onChange:L=>T(L.target.value),className:"machine-input flex-1 min-w-[200px]"}),!w&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:E,onChange:L=>B(L.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:k,onChange:L=>A(L.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,C,k||void 0,w?void 0:E||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:k||void 0,model:w?void 0:E||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:k||void 0,model:w?void 0:E||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",w?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(L=>{const P=w?null:L;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(L.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:R(L)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:L.workspace}),(P==null?void 0:P.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",P.currentModel]}),(P==null?void 0:P.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",P.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${L.status==="stopped"?"bg-red-500/[0.08] text-red-500":L.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:L.status}),!w&&u.jsx("button",{onClick:()=>o(`/ide/${L.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Fa,{size:14})}),L.status==="stopped"?u.jsx("button",{onClick:()=>l(L.type,L.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(L.type,L.workspace,L.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},L.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const L=new Set(x.map(O=>O.type)),P=p.filter(O=>L.has(O.cliType));return P.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:P.map((O,z)=>{var V,D;return u.jsxs("div",{onClick:()=>{M(O.cliType),T(O.dir),A((O.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-[background] duration-150",onMouseEnter:$=>$.currentTarget.style.background="var(--bg-glass-hover)",onMouseLeave:$=>$.currentTarget.style.background="var(--bg-glass)",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(O.cliType)}),u.jsx("span",{children:((V=O.dir)==null?void 0:V.split("/").filter(Boolean).pop())||"root"}),((D=O.cliArgs)==null?void 0:D.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:O.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:O.timestamp?new Date(O.timestamp).toLocaleDateString():""})]},z)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",w?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((L,P)=>u.jsx("button",{onClick:()=>T(L),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:L,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Wa,{size:12})," ",L.split("/").filter(Boolean).pop()||L]})},P))})]})]})}function qR({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=y.useState([]),[s,o]=y.useState(!1),[l,a]=y.useState(null),[c,d]=y.useState("all"),h=y.useCallback(async()=>{var p;if(e){o(!0);try{const m=await r(e,"get_provider_settings",{}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&(_!=null&&_.settings)){const w=[];for(const[g,v]of Object.entries(_.settings)){const x=t.find(S=>S.type===g);w.push({type:g,displayName:(x==null?void 0:x.displayName)||g,icon:(x==null?void 0:x.icon)||"",category:(x==null?void 0:x.category)||"unknown",schema:v,values:((p=_.values)==null?void 0:p[g])||{}})}w.sort((g,v)=>g.category.localeCompare(v.category)||g.displayName.localeCompare(v.displayName)),i(w)}}catch{}o(!1)}},[e,t,r]);y.useEffect(()=>{n.length===0&&h()},[]);const f=async(p,m,_)=>{a(`${p}.${m}`),i(w=>w.map(g=>g.type===p?{...g,values:{...g.values,[m]:_}}:g));try{const w=await r(e,"set_provider_setting",{providerType:p,key:m,value:_});w!=null&&w.success||h()}catch{h()}a(null)};return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-4",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(p=>u.jsx("button",{onClick:()=>d(p),className:`machine-btn text-[10px] px-2 py-0.5 ${c===p?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:p.toUpperCase()},p))]}),u.jsx("button",{onClick:h,disabled:s,className:"machine-btn",children:s?"⏳ Loading...":"↻ Refresh"})]}),c!=="all"&&n.filter(p=>p.category===c).length>1&&(()=>{const p=n.filter(g=>g.category===c),m=new Map;for(const g of p)for(const v of g.schema){if(v.type!=="boolean")continue;const x=m.get(v.key),S=!!(g.values[v.key]??v.default);x?(x.onCount+=S?1:0,x.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const w=async(g,v)=>{for(const x of p)await f(x.type,g,v)};return u.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[u.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",c.toUpperCase()," providers (",p.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([g,v])=>{const x=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void w(g,!0),disabled:x,className:`machine-btn text-[9px] px-1.5 py-px ${x?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void w(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const w=parseInt(_.target.value)||0;m.min!==void 0&&w<m.min||m.max!==void 0&&w>m.max||f(p.type,m.key,w)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function YR({machineId:e,sendDaemonCommand:t}){const[r,n]=y.useState([]),[i,s]=y.useState(0),[o,l]=y.useState(!0),[a,c]=y.useState("debug"),d=y.useRef(null),h=y.useRef(!1);return y.useEffect(()=>{if(!e||!o)return;const f=async()=>{try{const m=await t(e,"get_logs",{count:200,minLevel:a,since:i}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&Array.isArray(_==null?void 0:_.logs)&&_.logs.length>0){n(g=>[...g,..._.logs.map(x=>({timestamp:x.ts,level:x.level,message:`[${x.category}] ${x.message}`}))].slice(-300));const w=Math.max(..._.logs.map(g=>g.ts));s(w)}}catch{}};f();const p=setInterval(f,3e3);return()=>clearInterval(p)},[e,o,i,a,t]),y.useEffect(()=>{if(o&&r.length>0){const f=h.current?"smooth":"instant";setTimeout(()=>{var p;(p=d.current)==null||p.scrollIntoView({behavior:f}),h.current=!0},50)}},[r.length,o]),u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(f=>u.jsx("button",{onClick:()=>{c(f),n([]),s(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${a===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsxs("span",{className:"text-[10px] text-text-muted",children:[r.length," entries"]}),u.jsx("button",{onClick:()=>l(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),u.jsx("button",{onClick:()=>{n([]),s(0)},className:"machine-btn",children:"Clear"})]})]}),u.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[r.length===0&&u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),r.map((f,p)=>u.jsxs("div",{className:"flex gap-2 py-px",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#64748b":"#94a3b8"},children:[u.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(f.timestamp).toLocaleTimeString()}),u.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#475569":"#8b5cf6"},children:f.level==="error"?"ERR":f.level==="warn"?"WRN":f.level==="debug"?"DBG":"INF"}),u.jsx("span",{children:f.message})]},p)),u.jsx("div",{ref:d})]})]})}function XR({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/[0.08] transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function GR(){var S,M,C,T,k,A,E,B,R,L;const{id:e}=d0(),t=En(),{sendCommand:r}=ci(),n=Cc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=y.useState("overview"),a=y.useRef(null),c=HR({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(P=>P.id===e&&P.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(P=>({type:P.type,displayName:P.displayName,icon:P.icon,category:P.category})),f={};for(const P of h)f[P.type]=P.icon;const p=P=>f[P]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((M=d.machine)==null?void 0:M.platform)||"unknown",arch:((C=d.machine)==null?void 0:C.arch)||"",cpus:((T=d.machine)==null?void 0:T.cpus)||0,totalMem:((k=d.machine)==null?void 0:k.totalMem)||0,freeMem:((A=d.machine)==null?void 0:A.freeMem)||0,availableMem:(E=d.machine)==null?void 0:E.availableMem,loadavg:((B=d.machine)==null?void 0:B.loadavg)||[],uptime:((R=d.machine)==null?void 0:R.uptime)||0,release:((L=d.machine)==null?void 0:L.release)||"",cdpConnected:!!(d.ides||[]).some(P=>P.cdpConnected),machineNickname:d.machineNickname||null,p2p:d.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:d.detectedIdes||[],managedIdeIds:d.managedIdeIds||[],managedCliIds:d.managedCliIds||[],workspaces:d.workspaces||[],defaultWorkspaceId:d.defaultWorkspaceId??d.activeWorkspaceId??null,defaultWorkspacePath:d.defaultWorkspacePath??d.activeWorkspacePath??null,workspaceActivity:d.workspaceActivity||[]}:null,_=i.filter(P=>P.daemonId===e&&!P.daemonMode).filter(P=>!w_(P)&&!S_(P)).map(P=>({id:P.id,type:P.type,version:P.version||"",instanceId:P.instanceId||"",status:P.status,workspace:P.workspace||null,terminals:P.terminals||0,aiAgents:fM(P.aiAgents||P.agents||[]),activeChat:P.activeChat||null,chats:P.chats||[],agentStreams:P.agentStreams||[],cdpConnected:P.cdpConnected||!1,daemonId:e})),w=i.filter(P=>P.daemonId===e&&w_(P)).map(P=>({id:P.id,type:P.type,cliName:P.cliName||P.type,status:P.status,workspace:P.workspace||"",activeChat:P.activeChat||null,daemonId:e})),g=i.filter(P=>P.daemonId===e&&S_(P)).map(P=>({id:P.id,type:P.type,acpName:P.cliName||P.type,status:P.status,workspace:P.workspace||"",activeChat:P.activeChat||null,currentModel:P.currentModel,currentPlan:P.currentPlan,daemonId:e}));if(!m)return s?u.jsxs("div",{className:"p-10 text-center text-text-muted",children:[u.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),u.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):u.jsx("div",{className:"p-10 text-center text-text-muted",children:u.jsx("p",{children:"⏳ Loading machine..."})});const v=m.machineNickname||m.hostname,x=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(PP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ll,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ty,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ly,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ey,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(SP,{size:14})," Logs"]})}];return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[u.jsx("div",{className:"flex items-center justify-between w-full",children:u.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[c.editingNickname?u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsx("input",{autoFocus:!0,value:c.nicknameInput,onChange:P=>c.setNicknameInput(P.target.value),onKeyDown:P=>{P.key==="Enter"&&c.handleSaveNickname(),P.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:x.map(P=>u.jsxs("button",{onClick:()=>l(P.id),className:`machine-tab shrink-0${o===P.id?" active":""}`,children:[P.label,P.count!==void 0&&u.jsx("span",{className:"tab-count",children:P.count})]},P.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(VR,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:P=>l(P)}),o==="ides"&&u.jsx(KR,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(j_,{category:"cli",machine:m,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(j_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(qR,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(YR,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(XR,{machine:m,launchPick:c.launchPick,actions:c})]})}function QR(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,n=new URLSearchParams(window.location.search).get("token");return n?`${t}?token=${encodeURIComponent(n)}`:t}const A_=QR(),B_=3e3,JR=3e4;let mn=null,ZR=0;const Ga=new Map,Md=new Set;let gi=null;async function ha(e,t,r){const n=mn;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++ZR}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{Ga.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);Ga.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),n.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:r||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:r||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class eI{constructor(t){As(this,"daemonId");As(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN}get connectionState(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return ha(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return ha(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,gi&&(clearInterval(gi),gi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await ha(n,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const s=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());Md.forEach(o=>o(this.daemonId,s))}}catch{}};r(),gi=setInterval(r,2e3)}stopScreenshots(t){gi&&(clearInterval(gi),gi=null)}}let _i=null;function tI(e){(!_i||_i.daemonId!==e)&&(_i=new eI(e));const t=vr._originalGet||vr.get.bind(vr);vr._originalGet=t,vr.get=r=>r===e||r.startsWith("standalone")?_i:t(r),vr.getState=r=>(r===e||r.startsWith("standalone"))&&(_i==null?void 0:_i.connectionState)||"disconnected",vr.onScreenshot=(r,n)=>(Md.add(n),()=>{Md.delete(n)})}function rI({children:e}){const t=y.useRef(Cm()),r=Cm();t.current=r;const{setUserName:n}=Ho(),i=y.useRef(n);i.current=n;const[,s]=y.useState("disconnected"),o=y.useRef(null),l=y.useRef(),a=y.useRef(B_),c=y.useRef(!0);return y.useEffect(()=>{c.current=!0;function d(){var p,m;if(!c.current||((p=o.current)==null?void 0:p.readyState)===WebSocket.OPEN||((m=o.current)==null?void 0:m.readyState)===WebSocket.CONNECTING)return;s("connecting"),console.log(`[Standalone WS] Connecting to ${A_}...`);let f;try{f=new WebSocket(A_)}catch(_){console.error("[Standalone WS] Failed to create WebSocket:",_),h();return}o.current=f,f.onopen=()=>{if(!c.current){f.close();return}s("connected"),a.current=B_,console.log("[Standalone WS] Connected")},mn=f,f.onmessage=_=>{var w;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=Ga.get(g.requestId);v&&(Ga.delete(g.requestId),g.type==="error"?v.reject(new Error(((w=g.data)==null?void 0:w.message)||"Command failed")):v.resolve(g.data));return}if(g.type==="status"||g.type==="initial_state"){const v=g.data;if(!v)return;const{injectEntries:x,markLoaded:S}=t.current,M=v.id||"standalone";tI(M);const C=xM(v,{daemonId:M});C.length>0&&x(C),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,JR),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,mn=null)}},[]),u.jsx(u.Fragment,{children:e})}function nI({children:e}){return u.jsx(yk,{children:u.jsx(rI,{children:e})})}const iI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(bP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(wP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(Ey,{}),label:"Settings"}];function sI({children:e}){const t=En(),r=nl(),[n,i]=y.useState(!1),[s,o]=y.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=d=>{t(d),i(!1)},a=()=>{o(d=>{const h=!d;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})},c=d=>`nav-item${r.pathname.startsWith(d)?" active":""} cursor-pointer ${s?"justify-center py-2.5 px-0":""}`;return u.jsxs("div",{className:`app-layout${n?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[u.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"})]}),n&&u.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:d=>d.key==="Escape"&&i(!1)}),u.jsxs("aside",{className:`sidebar ${n?"sidebar-open":""}`,children:[u.jsxs("div",{className:"sidebar-header",children:[u.jsxs("div",{className:`sidebar-logo ${s?"justify-center gap-0":""}`,children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!s&&u.jsx("span",{children:"ADHDev"})]}),u.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),u.jsx("nav",{className:"sidebar-nav",children:iI.map(d=>u.jsxs("div",{className:c(d.path),id:`nav-${d.id}`,onClick:()=>l(d.path),title:s?d.label:void 0,children:[u.jsx("span",{className:"nav-icon",children:d.icon}),!s&&d.label]},d.id))}),u.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[u.jsxs("div",{className:`nav-item cursor-pointer${r.pathname==="/about"?" active":""} ${s?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>t("/about"),title:s?"About":void 0,children:[u.jsx("span",{className:"nav-icon",children:u.jsx(kP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.5.49"]}),u.jsx(_R,{collapsed:s}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const oI=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],lI=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],aI=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],Ou={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function cI(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.5.49"]})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:oI.map(e=>u.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[u.jsx("div",{className:"text-xl mb-1.5",children:e.icon}),u.jsx("div",{className:"font-semibold text-[13px] mb-1",children:e.title}),u.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:e.desc})]},e.title))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:Ou.ides},{label:"Extension agents",items:Ou.agents},{label:"CLI agents",items:Ou.cli}].map(e=>u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:e.label}),u.jsx("div",{className:"flex flex-col gap-1",children:e.items.map(t=>u.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:t},t))})]},e.label))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),u.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:u.jsxs("table",{className:"w-full text-[13px]",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-bg-secondary",children:[u.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),u.jsx("tbody",{children:aI.map((e,t)=>u.jsxs("tr",{className:t%2===0?"bg-bg-glass":"",children:[u.jsx("td",{className:"px-4 py-2 text-text-secondary",children:e.feature}),u.jsx("td",{className:"text-center px-4 py-2",children:e.selfhost?u.jsx("span",{className:"text-emerald-500",children:"✓"}):u.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),u.jsx("td",{className:"text-center px-4 py-2",children:u.jsx("span",{className:"text-emerald-500",children:"✓"})})]},e.feature))})]})})]}),u.jsx("section",{className:"mb-10",children:u.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),u.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:lI.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 ADHDev · Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function uI(){const{ides:e}=Ho(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ci(),{userName:i}=Ho(),[s,o]=y.useState(i||"");y.useEffect(()=>{i!==void 0&&o(i)},[i]);const l=h=>{const f=h.target.value.trim();t!=null&&t.id&&f!==i&&n(t.id,"set_user_name",{userName:f}).catch(console.error)},[a,c]=y.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=h=>{c(h);try{localStorage.setItem("adhdev_sound",h?"1":"0")}catch{}};return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx(uR,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Yi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.5.49"]}),u.jsx("span",{className:"text-text-muted",children:"Status"}),u.jsx("span",{className:t?"text-green-400":"text-yellow-400",children:t?"● Running":"○ Not connected"}),u.jsx("span",{className:"text-text-muted",children:"WebSocket"}),u.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),u.jsx("span",{className:"text-text-muted",children:"HTTP"}),u.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),u.jsx(Yi,{title:"Detected IDEs",className:"mb-4",children:r.length===0?u.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(h=>u.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:`w-2 h-2 rounded-full ${h.running?"bg-green-400":"bg-text-muted/30"}`}),u.jsx("span",{className:"text-sm font-medium",children:h.name})]}),u.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:h.type})]},h.type))})}),u.jsx(Yi,{title:"Machine",className:"mb-4",children:u.jsx(kR,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Yi,{title:"Chat theme",className:"mb-4",children:u.jsx(MR,{})}),u.jsx(Yi,{title:"Notifications",className:"mb-4",children:u.jsx(SR,{})}),u.jsx(Yi,{title:"Preferences",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-hover transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]}),u.jsx(Gi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})})]})]})}LR();function O_(){const{ides:e}=Ho(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(ea,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(ea,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(ea,{to:"/dashboard",replace:!0})}function hI(){return u.jsx(vk,{children:u.jsx(nI,{children:u.jsx(kk,{value:{sendCommand:ha,sendData:()=>!1},children:u.jsx(sI,{children:u.jsxs(pk,{children:[u.jsx(dn,{path:"/dashboard",element:u.jsx($R,{})}),u.jsx(dn,{path:"/ide/:id",element:u.jsx(WR,{})}),u.jsx(dn,{path:"/machine",element:u.jsx(O_,{})}),u.jsx(dn,{path:"/machines/:id",element:u.jsx(GR,{})}),u.jsx(dn,{path:"/machines",element:u.jsx(O_,{})}),u.jsx(dn,{path:"/about",element:u.jsx(cI,{})}),u.jsx(dn,{path:"/settings",element:u.jsx(uI,{})}),u.jsx(dn,{path:"*",element:u.jsx(ea,{to:"/dashboard",replace:!0})})]})})})})})}r0(document.getElementById("root")).render(u.jsx(y.StrictMode,{children:u.jsx(hI,{})}));
|
package/public/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="description" content="ADHDev self-hosted dashboard for controlling AI agents" />
|
|
8
8
|
<link rel="icon" href="/otter-logo.png" />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-Cd67318d.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-kO2DEidE.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|