@adhdev/daemon-standalone 0.6.11 → 0.6.12

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -170,7 +170,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
170
170
  }
171
171
  `})]})}function fL({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 I1({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(Ox,{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 Pr=new Map;function pL({ideId:e,ideType:t,agentType:r,agentName:n,serverModel:i,serverMode:s,acpConfigOptions:o,acpModes:l}){var G;const{sendCommand:a}=ui(),c=!!(o||l),d=`${e}:${r}`,h=Pr.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)||[]),k=L=>L?typeof L=="string"?L:typeof L=="object"?L.name||L.id||JSON.stringify(L):String(L):"",[P,C]=y.useState(k(i)),[B,R]=y.useState(k(s)),[$,S]=y.useState(!1),[j,I]=y.useState(!1),T=y.useRef(0),N=L=>L.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 L=o.find(F=>F.category==="model");if(L){const F=N(L.options.map(te=>te.value));g(F),L.currentValue&&C(k(L.currentValue));const D=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...D,models:F})}}if(l&&l.length>0){const L=N(l.map(D=>D.id));x(L);const F=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...F,modes:L})}else if(o){const L=o.find(F=>F.category!=="model");if(L){const F=N(L.options.map(te=>te.value));x(F),L.currentValue&&R(k(L.currentValue));const D=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...D,modes:F})}}},[o,l,d]),y.useEffect(()=>{p(!1),_(!1),C(k(i)),R(k(s));const L=Pr.get(d);L?(g(L.models),x(L.modes)):(g([]),x([]))},[e,r]),y.useEffect(()=>{i&&Date.now()>T.current&&C(k(i))},[i]),y.useEffect(()=>{s&&Date.now()>T.current&&R(k(s))},[s]);const A=y.useCallback(async(L,F={})=>{const D={...F},te=e.split(":");return te.length>=3&&(te[1]==="ide"||te[1]==="cli"||te[1]==="acp")&&(D._targetInstance=te.slice(2).join(":"),D._targetType=te[1]),await a(e,L,D)},[e]),W=async()=>{var L,F;if(w.length>0){p(!f);return}if(c){p(!0);return}S(!0);try{const D=await A("list_extension_models",{agentType:r,ideType:t}),te=(D==null?void 0:D.models)||((L=D==null?void 0:D.result)==null?void 0:L.models)||[],ne=N(te);g(ne),D!=null&&D.current&&C(k(D.current)),(F=D==null?void 0:D.result)!=null&&F.current&&C(k(D.result.current));const ve=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...ve,models:ne}),p(!0)}catch{}finally{S(!1)}},U=async()=>{var L,F;if(v.length>0){_(!m);return}if(c){_(!0);return}I(!0);try{const D=await A("list_extension_modes",{agentType:r,ideType:t}),te=(D==null?void 0:D.modes)||((L=D==null?void 0:D.result)==null?void 0:L.modes)||[],ne=N(te);x(ne),D!=null&&D.current&&R(k(D.current)),(F=D==null?void 0:D.result)!=null&&F.current&&R(k(D.result.current));const ve=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...ve,modes:ne}),_(!0)}catch{}finally{I(!1)}},M=async L=>{p(!1),C(L),T.current=Date.now()+5e3;try{c?await A("change_model",{agentType:r,ideType:t,model:L}):await A("set_extension_model",{agentType:r,ideType:t,model:L})}catch{}},z=c&&!(l&&l.length>0)&&(o==null?void 0:o.some(L=>L.category!=="model")),b=z?(G=o==null?void 0:o.find(L=>L.category!=="model"))==null?void 0:G.configId:void 0,J=async L=>{_(!1),R(L),T.current=Date.now()+5e3;try{c&&z&&b?await A("set_thought_level",{agentType:r,ideType:t,configId:b,value:L}):c?await A("set_mode",{agentType:r,ideType:t,mode:L}):await A("set_extension_mode",{agentType:r,ideType:t,mode:L})}catch{}},E={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:E},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?`${E}55`:"transparent",border:"1px solid",color:P?"var(--text-primary)":"var(--text-muted)"},onClick:W,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),$?"...":P||"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(L=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:L===P?`${E}18`:"transparent",color:L===P?E:"var(--text-secondary)",fontWeight:L===P?600:400,borderLeft:L===P?`2px solid ${E}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${E}12`},onMouseLeave:F=>{F.currentTarget.style.background=L===P?`${E}18`:"transparent"},onClick:()=>M(L),children:L},L))]})]})]}),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?`${E}55`:"transparent",border:"1px solid",color:B?"var(--text-primary)":"var(--text-muted)"},onClick:U,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:z?"🧠":"⚡"}),j?"...":B||(z?"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:z?"SELECT THINKING LEVEL":"SELECT MODE"}),v.map(L=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:L===B?`${E}18`:"transparent",color:L===B?E:"var(--text-secondary)",fontWeight:L===B?600:400,borderLeft:L===B?`2px solid ${E}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${E}12`},onMouseLeave:F=>{F.currentTarget.style.background=L===B?`${E}18`:"transparent"},onClick:()=>J(L),children:L},L))]})]})]})]})}const si=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),an=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function D1({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}=ui(),[f,p]=y.useState([]),[m,_]=y.useState(0),[w,g]=y.useState(!1),[v,x]=y.useState(!1),[k,P]=y.useState(null),C=y.useRef("");y.useEffect(()=>{e.tabKey!==C.current&&(C.current=e.tabKey,p([]),_(0),g(!1),x(!1),P(null))},[e.tabKey]);const B=y.useCallback(async()=>{var S,j,I;if(!v){x(!0),P(null);try{const T=t.find(b=>b.id===e.ideId),N=(T==null?void 0:T.daemonId)||((S=e.ideId)==null?void 0:S.split(":")[0])||"";if(!N){g(!1);return}const A=e.ideType||e.agentType||"",W=(e.ideId||"").split(":"),U=W.length>=3?W.slice(2).join(":"):void 0;console.log("[ChatPane] requestChatHistory:",{daemonId:N,agentType:A,instanceId:U,offset:m});const M=await h(N,"chat_history",{agentType:A,offset:m,limit:30,instanceId:U}),z=(M==null?void 0:M.result)??M;console.log("[ChatPane] got result:",{count:((j=z.messages)==null?void 0:j.length)||0,hasMore:z.hasMore}),((I=z.messages)==null?void 0:I.length)>0&&(p(b=>[...z.messages,...b]),_(b=>b+z.messages.length)),g(!!z.hasMore)}catch(T){console.warn("[ChatPane] Failed to load history:",T);const N=(T==null?void 0:T.message)||"";N.includes("P2P not available")||N.includes("channel not open")||N.includes("P2P not connected")||N.includes("timeout")?P("Connection not ready — tap to retry"):(g(!1),P("Failed to load history"))}finally{x(!1)}}},[v,m,t,e,h]),R=y.useRef("");y.useEffect(()=>{if(R.current===e.tabKey)return;if(e.messages.length>=10){R.current=e.tabKey;return}const S=setTimeout(()=>{R.current=e.tabKey,g(!0),B()},800);return()=>clearTimeout(S)},[e.tabKey]);const $=(()=>{const S=e.messages.map((T,N)=>{const A=`${e.ideId}-${T.id??`i-${N}`}`;return{...T,receivedAt:T.receivedAt||l[A]||0}});if(f.length===0)return S;const j=new Set(S.map(T=>`${T.role}:${(T.content||"").slice(0,100)}`));return[...f.filter(T=>!j.has(`${T.role}:${(T.content||"").slice(0,100)}`)),...S]})();return u.jsxs(u.Fragment,{children:[u.jsx(qT,{messages:$,actionLogs:a.filter(S=>S.ideId===e.tabKey).sort((S,j)=>S.timestamp-j.timestamp),agentName:e.agentName||e.displayPrimary||"Agent",userName:c,isCliMode:si(e)||an(e),isWorking:e.status==="working",contextKey:e.tabKey,onLoadMore:B,isLoadingMore:v,hasMoreHistory:w,loadError:k??void 0,emptyState:e.messages.length===0?e.connectionState==="connecting"||e.connectionState==="new"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-4",children:[u.jsx("div",{className:"connecting-logo-float",children:u.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 0 40px rgba(96,165,250,0.08)"},children:u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:40,height:40,borderRadius:"50%",opacity:.85}})})}),u.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[u.jsxs("div",{className:"text-[13px] text-blue-400 font-medium",children:["Connecting to your machine",u.jsx("span",{className:"connecting-dots"})]}),u.jsx("div",{className:"text-[11px] opacity-35",children:"Establishing P2P connection"})]})]}):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(zx,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-primary",children:o?"⌛ Switching...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Jh,{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($T,{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-primary",children:o?"⌛ Opening...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Jh,{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"})]}):e.status==="idle"&&!v?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-2xl opacity-40 animate-pulse",children:"💬"}),u.jsx("div",{className:"text-[13px] opacity-40",children:"Loading chat..."})]}):void 0:void 0}),!si(e)&&(()=>{var j,I,T,N;const S=t.find(A=>A.id===e.ideId);return u.jsx(pL,{ideId:e.ideId,ideType:e.ideType,agentType:e.streamSource==="agent-stream"?e.agentType:((I=(j=S==null?void 0:S.agents)==null?void 0:j[0])==null?void 0:I.type)||e.ideType,agentName:e.streamSource==="agent-stream"?e.agentName:((N=(T=S==null?void 0:S.agents)==null?void 0:T[0])==null?void 0:N.name)||e.agentName,serverModel:(S==null?void 0:S.currentModel)||void 0,serverMode:(S==null?void 0:S.currentPlan)||void 0,acpConfigOptions:an(e)?S==null?void 0:S.acpConfigOptions:void 0,acpModes:an(e)?S==null?void 0:S.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:S=>n(S.target.value),onPaste:S=>{const j=S.clipboardData.getData("text");j&&n(I=>I+j),S.preventDefault()},onKeyDown:S=>{if(S.key==="Enter"){if(S.nativeEvent.isComposing){S.preventDefault();return}S.preventDefault(),i()}},onBlur:S=>{if(window.innerWidth<768){const j=S.relatedTarget;if((j==null?void 0:j.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary text-sm text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),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()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:r.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,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 Au=new Set,j1={emit(e,t){for(const r of Au)r(e,t)},on(e){return Au.add(e),()=>{Au.delete(e)}}};function mL({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}=ui(),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=j1.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
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(I1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(L1,{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 text-[13px] text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),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()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:n.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,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 gL({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 _L=qo;function Ic(){return _L()}class vL{constructor(){Xt(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 yL=new vL;class xL{constructor(){Xt(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 yr=new xL,M_=yr;const Bu=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),Ou=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function bL({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=Ui(),o=Ic(),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(Ga,{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&&!Bu(e)&&!Ou(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm",title:"IDE View",children:[u.jsx($x,{size:14})," IDE"]}),e&&!Bu(e)&&!Ou(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm",title:"Chat History",children:u.jsx(BT,{size:16})}),e&&!Bu(e)&&!Ou(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm",title:"Remote Control",children:u.jsx(dl,{size:16})})]})]})}function Ur(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function wL(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 R_(e){return e<1024*1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function L_(e){return(e.id||"").includes(":cli:")}function I_(e){return(e.id||"").includes(":acp:")}function Ad(e,t){return Ur(e)}function SL(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 kL({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," — ",Ur(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(KT,{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(zT,{size:13})," Refresh History"]})})})]})]})}const D_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function CL({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:D_[n.type]||D_.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 EL=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function NL(e){return e.workspace||""}function PL(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,k;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=NL(o),f=Ur(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(P=>({...P,activeModal:P.activeModal??void 0})):[],_=EL(o);if(_){const P=Ad(o.type),C=(g=o.agents)==null?void 0:g[0],B=(v=o.activeChat)==null?void 0:v.activeModal,R=B&&Array.isArray(B.buttons)&&B.buttons.length>0,$=(x=o.activeChat)==null?void 0:x.status,S=$==="generating"||$==="loading"||$&&$.toLowerCase()==="thinking",I=R||$==="waiting_approval"?"waiting_approval":S?"working":(C==null?void 0:C.status)||"idle",T=o.activeChat||{title:"",messages:[]};let N=T.title&&String(T.title).trim()?String(T.title).trim():"";const A=(k=o.activeChat)==null?void 0:k.id,W=o.chats;if(A&&Array.isArray(W)&&W.length>0){const J=W.find(ie=>ie.id===A||ie.id&&String(ie.id)===String(A));J!=null&&J.title&&String(J.title).trim()&&(N=String(J.title).trim())}const U=T.messages||[],M=t[o.id]||[],z=new Map;U.filter(J=>J.role==="user").forEach(J=>{z.set(J.content,(z.get(J.content)||0)+1)});const b=M.filter(J=>{const ie=z.get(J.content)||0;return ie>0?(z.set(J.content,ie-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:P,agentType:si(o)||an(o)?o.type:(C==null?void 0:C.type)||"ide-native",status:I,title:N,messages:[...U,...b],ideType:o.type,workspaceName:h,displayPrimary:N||h||P,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:R?B.buttons:void 0,modalMessage:R?B.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(si(o)||an(o)))return l;for(const P of m){const C=P.activeModal&&Array.isArray(P.activeModal.buttons)&&P.activeModal.buttons.length>0,B=C?"waiting_approval":P.status==="streaming"?"working":P.status,R=`${o.id}:${P.agentType}`,$=P.messages||[],S=t[R]||[],j=new Map;$.filter(T=>T.role==="user").forEach(T=>{j.set(T.content,(j.get(T.content)||0)+1)});const I=S.filter(T=>{const N=j.get(T.content)||0;return N>0?(j.set(T.content,N-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:P.agentName,agentType:P.agentType,status:B,title:"",messages:[...$,...I],ideType:o.type,workspaceName:h,displayPrimary:h||P.agentName,displaySecondary:`${f}·${P.agentName}`,cdpConnected:o.cdpConnected,modalButtons:C?P.activeModal.buttons:void 0,modalMessage:C?P.activeModal.message:void 0,streamSource:"agent-stream",tabKey:R,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Ad(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:h,displayPrimary:h||f,displaySecondary:f,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:d}),l})}function TL(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}const A1="adhdev_notification_prefs",j_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function ML(){try{const e=localStorage.getItem(A1);if(e){const t=JSON.parse(e);return{...j_,...t}}}catch{}return{...j_}}function RL(e){try{localStorage.setItem(A1,JSON.stringify(e))}catch{}}let vn=ML(),_a=[];function LL(){_a.forEach(e=>e())}function IL(e){vn={...vn,...e},RL(vn),LL()}function DL(){const[,e]=y.useState(0);y.useEffect(()=>{const r=()=>e(n=>n+1);return _a.push(r),()=>{_a=_a.filter(n=>n!==r)}},[]);const t=y.useCallback(r=>{IL(r)},[]);return[{...vn},t]}function Eo(e){if(!vn.globalEnabled)return!1;switch(e){case"disconnect":return vn.disconnectAlert;case"completion":return vn.completionAlert;case"approval":return vn.approvalAlert;case"browser":return vn.browserNotifications;default:return!0}}const jL={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function AL(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function B1(){return"Notification"in window&&Notification.permission==="granted"}let mi=null;async function BL(){if(mi!==null)return mi;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return mi=!1,!1;const e=await navigator.serviceWorker.getRegistration();return e?(mi=!!await e.pushManager.getSubscription(),mi):(mi=!1,!1)}catch{return mi=!1,!1}}function Bd(e,t,r){if(B1())try{const n=new Notification(e,{body:t,icon:"/otter-logo.png",tag:r||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>n.close(),8e3),n.onclick=()=>{window.focus(),n.close()}}catch{}}function OL(e,t={}){const r={...jL,...t},n=y.useRef(new Map),i=y.useRef(0),s=y.useRef(null);y.useEffect(()=>{BL().then(l=>{s.current=l})},[]);const o=y.useCallback((l,a,c)=>{const d=Date.now();d-i.current<r.throttleMs||(i.current=d,Bd(l,a,c))},[r.throttleMs]);y.useEffect(()=>{var l;if(!(!r.enabled||!B1())&&Eo("browser")&&s.current!==!0){if(document.hasFocus()){for(const a of e)n.current.set(a.id,a.status||"idle");return}for(const a of e){const c=n.current.get(a.id),d=a.status||"idle",h=a.name||a.id;if(r.onApproval&&Eo("approval")&&d==="waiting_approval"&&c!=="waiting_approval"){const f=((l=a.activeModal)==null?void 0:l.message)||"Action requires your approval";o(`🔔 ${h} — Approval needed`,f.slice(0,120),`approval-${a.id}`)}r.onComplete&&Eo("completion")&&c==="generating"&&d==="idle"&&o(`✅ ${h} — Task complete`,"Agent has finished working",`complete-${a.id}`),r.onError&&d==="error"&&c!=="error"&&o(`⚠️ ${h} — Error`,"Agent encountered an error",`error-${a.id}`),n.current.set(a.id,d)}}},[e,r.enabled,r.onApproval,r.onComplete,r.onError,o])}class zL{constructor(){Xt(this,"dedupMap",new Map);Xt(this,"DEDUP_WINDOW_MS",5e3);Xt(this,"DEDUP_MAX_SIZE",50);Xt(this,"DEDUP_CLEANUP_AGE_MS",1e4);Xt(this,"toastCallbacks",[]);Xt(this,"systemMessageCallbacks",[]);Xt(this,"clearSystemMessageCallbacks",[]);Xt(this,"resolveActionFn",null);Xt(this,"viewRequestRespondFn",null);Xt(this,"ides",[])}onToast(t){return this.toastCallbacks.push(t),()=>{this.toastCallbacks=this.toastCallbacks.filter(r=>r!==t)}}onSystemMessage(t){return this.systemMessageCallbacks.push(t),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(r=>r!==t)}}onClearSystemMessage(t){return this.clearSystemMessageCallbacks.push(t),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(r=>r!==t)}}setResolveAction(t){this.resolveActionFn=t}setIdes(t){this.ides=t}setViewRequestRespond(t){this.viewRequestRespondFn=t}emitToast(t){for(const r of this.toastCallbacks)r(t)}emitSystemMessage(t,r){for(const n of this.systemMessageCallbacks)n(t,r)}emitClearSystemMessage(t,r){for(const n of this.clearSystemMessageCallbacks)n(t,r)}isDuplicate(t){const r=Date.now(),n=this.dedupMap.get(t)||0;if(r-n<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(t,r),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[i,s]of this.dedupMap)r-s>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(i);return!1}resolveRouteId(t,r){for(const n of this.ides)if(n.id.startsWith(t)&&(!r||r===n.type))return n.id;return t}handleRawEvent(t,r){var l,a;const n=`${t.ideId||""}:${t.ideType||""}:${t.event}:${t.chatTitle||""}`;if(this.isDuplicate(n))return;const i=Ur(t.ideType||"");let s="",o="info";if(t.event==="agent:generating_completed"){const c=t.duration?` (${t.duration}s)`:"";s=`✅ ${i} agent task completed${c}`,o="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}t.ideId&&this.emitSystemMessage(t.ideId,{role:"system",timestamp:Date.now(),content:`✅ Task completed${c}`,_localId:`sys_complete_${Date.now()}`})}else if(t.event==="agent:generating_started")t.ideId&&this.emitClearSystemMessage(t.ideId,"sys_complete_");else if(t.event==="agent:waiting_approval"){if(s=`⚡ ${i} approval needed`,o="warning",t.ideId){const c=t.modalMessage||"Approval requested",d=(l=t.modalButtons)!=null&&l.length?t.modalButtons.map(h=>`[${h}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(t.ideId,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${c}
173
- ${d}`,_localId:`sys_approval_${Date.now()}`})}if(t.ideId&&((a=t.modalButtons)!=null&&a.length)&&this.resolveActionFn){const c=t.ideId,d=t.agentType||t.ideType||"",h=t.ideType||"",f=t.modalButtons,p=v=>v.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),m=this.resolveActionFn,_=f.map((v,x)=>{const k=p(v).toLowerCase(),P=/^(run|approve|accept|yes|allow|always)/.test(k),C=/^(reject|deny|delete|remove|abort|cancel|no)/.test(k);return{label:p(v),variant:P?"primary":C?"danger":"default",onClick:()=>{const B=this.resolveRouteId(c,d),R=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(k);m(B,"resolve_action",{action:R?"approve":"reject",button:v,buttonIndex:x,agentType:d,ideType:h})}}}),w=t.modalMessage?`⚡ ${i}: ${t.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:s,g=Date.now();this.emitToast({id:g,message:w,type:o,timestamp:g,ideId:c,actions:_,duration:15e3}),s=""}}else if(t.event==="monitor:long_generating"){const c=t.elapsedSec?` (${Math.round(t.elapsedSec/60)}m)`:"";s=`⚠️ ${i} agent is taking a long time${c}`,o="warning",Eo("browser")&&!document.hasFocus()&&Bd(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${t.ideId||t.agentType}`)}else if(t.event==="team:view_request"){const c=t.requesterName||"A team member",d=t.requestId,h=t.orgId;if(s=`👁️ ${c} wants to view your session`,o="warning",d&&h&&this.viewRequestRespondFn){const f=this.viewRequestRespondFn,p=Date.now(),m=[{label:"Approve",variant:"primary",onClick:()=>{f(h,d,"approve").catch(_=>console.error("[EventManager] approve view request failed:",_))}},{label:"Decline",variant:"danger",onClick:()=>{f(h,d,"reject").catch(_=>console.error("[EventManager] reject view request failed:",_))}}];this.emitToast({id:p,message:s,type:o,timestamp:p,actions:m,duration:3e4}),s=""}Eo("browser")&&!document.hasFocus()&&Bd("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else t.event==="team:view_request_approved"?(s="✅ View request approved",o="success"):t.event==="team:view_request_rejected"&&(s=`❌ ${t.targetName||"Team member"} declined your view request`,o="warning");if(s){const c=Date.now();this.emitToast({id:c,message:s,type:o,timestamp:c,ideId:t.ideId,duration:5e3})}}}const gi=new zL;function O1(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=O1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function $L(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=O1(e))&&(n&&(n+=" "),n+=t);return n}const FL=(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},WL=(e,t)=>({classGroupId:e,validator:t}),z1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),nc="-",A_=[],HL="arbitrary..",UL=e=>{const t=VL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return KL(o);const l=o.split(nc),a=l[0]===""&&l.length>1?1:0;return $1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?FL(c,a):a:c||A_}return r[o]||A_}}},$1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=$1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(nc):e.slice(t).join(nc),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},KL=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?HL+n:void 0})(),VL=e=>{const{theme:t,classGroups:r}=e;return qL(r,t)},qL=(e,t)=>{const r=z1();for(const n in e){const i=e[n];mp(i,r,n,t)}return r},mp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];YL(o,t,r,n)}},YL=(e,t,r,n)=>{if(typeof e=="string"){XL(e,t,r);return}if(typeof e=="function"){GL(e,t,r,n);return}QL(e,t,r,n)},XL=(e,t,r)=>{const n=e===""?t:F1(t,e);n.classGroupId=r},GL=(e,t,r,n)=>{if(JL(e)){mp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(WL(r,e))},QL=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];mp(a,F1(t,l),r,n)}},F1=(e,t)=>{let r=e;const n=t.split(nc),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=z1(),r.nextPart.set(o,l)),r=l}return r},JL=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ZL=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)}}},Od="!",B_=":",e4=[],O_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),t4=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===B_){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(Od)?(f=h.slice(0,-1),p=!0):h.startsWith(Od)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return O_(s,p,f,m)};if(t){const i=t+B_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):O_(e4,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},r4=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}},n4=e=>({cache:ZL(e.cacheSize),parseClassName:t4(e),sortModifiers:r4(e),...UL(e)}),i4=/\s+/,s4=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(i4);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+Od:v,k=x+g;if(o.indexOf(k)>-1)continue;o.push(k);const P=i(g,w);for(let C=0;C<P.length;++C){const B=P[C];o.push(x+B)}a=d+(a.length>0?" "+a:a)}return a},o4=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=W1(r))&&(i&&(i+=" "),i+=n);return i},W1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=W1(e[n]))&&(r&&(r+=" "),r+=t);return r},l4=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=n4(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=s4(a,r);return i(a,d),d};return s=o,(...a)=>s(o4(...a))},a4=[],wt=e=>{const t=r=>r[e]||a4;return t.isThemeGetter=!0,t},H1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,U1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,c4=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,u4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,h4=/\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$/,d4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,f4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,p4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=e=>c4.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),On=e=>!!e&&Number.isInteger(Number(e)),zu=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),dn=e=>u4.test(e),K1=()=>!0,m4=e=>h4.test(e)&&!d4.test(e),gp=()=>!1,g4=e=>f4.test(e),_4=e=>p4.test(e),v4=e=>!me(e)&&!ge(e),y4=e=>di(e,Y1,gp),me=e=>H1.test(e),_i=e=>di(e,X1,m4),z_=e=>di(e,N4,Ae),x4=e=>di(e,Q1,K1),b4=e=>di(e,G1,gp),$_=e=>di(e,V1,gp),w4=e=>di(e,q1,_4),Vl=e=>di(e,J1,g4),ge=e=>U1.test(e),eo=e=>qi(e,X1),S4=e=>qi(e,G1),F_=e=>qi(e,V1),k4=e=>qi(e,Y1),C4=e=>qi(e,q1),ql=e=>qi(e,J1,!0),E4=e=>qi(e,Q1,!0),di=(e,t,r)=>{const n=H1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},qi=(e,t,r=!1)=>{const n=U1.exec(e);return n?n[1]?t(n[1]):r:!1},V1=e=>e==="position"||e==="percentage",q1=e=>e==="image"||e==="url",Y1=e=>e==="length"||e==="size"||e==="bg-size",X1=e=>e==="length",N4=e=>e==="number",G1=e=>e==="family-name",Q1=e=>e==="number"||e==="weight",J1=e=>e==="shadow",P4=()=>{const e=wt("color"),t=wt("font"),r=wt("text"),n=wt("font-weight"),i=wt("tracking"),s=wt("leading"),o=wt("breakpoint"),l=wt("container"),a=wt("spacing"),c=wt("radius"),d=wt("shadow"),h=wt("inset-shadow"),f=wt("text-shadow"),p=wt("drop-shadow"),m=wt("blur"),_=wt("perspective"),w=wt("aspect"),g=wt("ease"),v=wt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...k(),ge,me],C=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],R=()=>[ge,me,a],$=()=>[Bn,"full","auto",...R()],S=()=>[On,"none","subgrid",ge,me],j=()=>["auto",{span:["full",On,ge,me]},On,ge,me],I=()=>[On,"auto",ge,me],T=()=>["auto","min","max","fr",ge,me],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],A=()=>["start","end","center","stretch","center-safe","end-safe"],W=()=>["auto",...R()],U=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],M=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...R()],z=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],b=()=>[e,ge,me],J=()=>[...k(),F_,$_,{position:[ge,me]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],E=()=>["auto","cover","contain",k4,y4,{size:[ge,me]}],G=()=>[zu,eo,_i],L=()=>["","none","full",c,ge,me],F=()=>["",Ae,eo,_i],D=()=>["solid","dashed","dotted","double"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[Ae,zu,F_,$_],ve=()=>["","none",m,ge,me],ke=()=>["none",Ae,ge,me],be=()=>["none",Ae,ge,me],ye=()=>[Ae,ge,me],Ce=()=>[Bn,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[dn],breakpoint:[dn],color:[K1],container:[dn],"drop-shadow":[dn],ease:["in","out","in-out"],font:[v4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[dn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[dn],shadow:[dn],spacing:["px",Ae],text:[dn],"text-shadow":[dn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,me,ge,w]}],container:["container"],columns:[{columns:[Ae,me,ge,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:P()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[On,"auto",ge,me]}],basis:[{basis:[Bn,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,Bn,"auto","initial","none",me]}],grow:[{grow:["",Ae,ge,me]}],shrink:[{shrink:["",Ae,ge,me]}],order:[{order:[On,"first","last","none",ge,me]}],"grid-cols":[{"grid-cols":S()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":S()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":T()}],"auto-rows":[{"auto-rows":T()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...A(),"normal"]}],"justify-self":[{"justify-self":["auto",...A()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...A(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...A(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...A(),"baseline"]}],"place-self":[{"place-self":["auto",...A()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:W()}],mx:[{mx:W()}],my:[{my:W()}],ms:[{ms:W()}],me:[{me:W()}],mbs:[{mbs:W()}],mbe:[{mbe:W()}],mt:[{mt:W()}],mr:[{mr:W()}],mb:[{mb:W()}],ml:[{ml:W()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",r,eo,_i]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,E4,x4]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zu,me]}],"font-family":[{font:[S4,b4,t]}],"font-features":[{"font-features":[me]}],"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,ge,me]}],"line-clamp":[{"line-clamp":[Ae,"none",ge,z_]}],leading:[{leading:[s,...R()]}],"list-image":[{"list-image":["none",ge,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ge,me]}],"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:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ge,_i]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[Ae,"auto",ge,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ge,me]}],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",ge,me]}],"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:ie()}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},On,ge,me],radial:["",ge,me],conic:[On,ge,me]},C4,w4]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"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:[...D(),"hidden","none"]}],"divide-style":[{divide:[...D(),"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:[...D(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ge,me]}],"outline-w":[{outline:["",Ae,eo,_i]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,ql,Vl]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,ql,Vl]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[Ae,_i]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,ql,Vl]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[Ae,ge,me]}],"mix-blend":[{"mix-blend":[...te(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":te()}],"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":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"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":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"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":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"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":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"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":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"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":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"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":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[ge,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"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":k()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"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:ie()}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ge,me]}],filter:[{filter:["","none",ge,me]}],blur:[{blur:ve()}],brightness:[{brightness:[Ae,ge,me]}],contrast:[{contrast:[Ae,ge,me]}],"drop-shadow":[{"drop-shadow":["","none",p,ql,Vl]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",Ae,ge,me]}],"hue-rotate":[{"hue-rotate":[Ae,ge,me]}],invert:[{invert:["",Ae,ge,me]}],saturate:[{saturate:[Ae,ge,me]}],sepia:[{sepia:["",Ae,ge,me]}],"backdrop-filter":[{"backdrop-filter":["","none",ge,me]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ge,me]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ge,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ge,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ge,me]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ge,me]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ge,me]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ge,me]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ge,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ge,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",ge,me]}],ease:[{ease:["linear","initial",g,ge,me]}],delay:[{delay:[Ae,ge,me]}],animate:[{animate:["none",v,ge,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,ge,me]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ke()}],"rotate-x":[{"rotate-x":ke()}],"rotate-y":[{"rotate-y":ke()}],"rotate-z":[{"rotate-z":ke()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[ge,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"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",ge,me]}],"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":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",ge,me]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[Ae,eo,_i,z_]}],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"]}},T4=l4(P4);function Zo(...e){return T4($L(e))}function M4({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Zo("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]})]}),r&&u.jsx("p",{className:"hidden sm:block text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Ji({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Zo("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 R4({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Zo("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 L4={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"},I4={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function D4({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Zo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",L4[e],r),children:[u.jsx("span",{className:Zo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",I4[e])}),n]})}function j4(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function W_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function $u(e){return e==="system"?j4():e}function A4(){const[e,t]=y.useState(W_),[r,n]=y.useState(()=>$u(W_()));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($u(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=y.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n($u(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}function es({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"})]})]})}function B4({onPrefChange:e}){const[t,r]=DL(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(es,{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(es,{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(es,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(es,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(es,{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 O4({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(R4,{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(F4,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function H_({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 d0.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 z4={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 $4(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return z4[t]||{icon:"📝",name:e}}function F4({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var A,W,U,M;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=((A=_.machine)==null?void 0:A.hostname)||((W=_.system)==null?void 0:W.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((M=_.system)==null?void 0:M.platform)||"",x=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",k=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",P=t.filter(z=>z.daemonId===e.id&&z.id.includes(":ide:")),C=t.filter(z=>z.daemonId===e.id&&z.id.includes(":cli:")),B=t.filter(z=>z.daemonId===e.id&&z.id.includes(":acp:")),R=_.p2p,$=async()=>{var z,b,J;if(r){o("upgrading"),a("Installing latest version...");try{const ie=await r(e.id,"daemon_upgrade",{});(z=ie==null?void 0:ie.result)!=null&&z.upgraded||(b=ie==null?void 0:ie.result)!=null&&b.success?(o("done"),a(`Upgraded to v${ie.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((J=ie==null?void 0:ie.result)==null?void 0:J.error)||"Upgrade failed"))}catch(ie){o("error"),a((ie==null?void 0:ie.message)||"Connection lost during upgrade")}}},S=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch(z){f("error"),m((z==null?void 0:z.message)||"Failed to disconnect")}}},j=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(z){f("error"),m((z==null?void 0:z.message)||"Failed to revoke token")}}},I="0.6.11",T=!w||w!==I,N=P.length+C.length+B.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:k}),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] ${T?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!T&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&T&&u.jsx("button",{onClick:$,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${I}`,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${I}`}`}),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(D4,{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:[R&&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 ${R.state==="connected"?"bg-green-400":R.state==="connecting"||R.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",R.state==="connected"?"connected":R.state==="connecting"||R.state==="new"?"connecting...":R.state||"off"]}),R.peers!==void 0&&R.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",R.peers," peer",R.peers!==1?"s":"",")"]})]}),R&&N>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),N>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[P.map(z=>{const b=$4(z.type),J=z.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..."})]},z.id)}),C.map(z=>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:z.cliName||"CLI"})]},z.id)),B.map(z=>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:z.cliName||"ACP"})]},z.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(H_,{title:"🔌 Disconnect Machine",message:`Disconnect "${x}" from ADHDev?
173
+ ${d}`,_localId:`sys_approval_${Date.now()}`})}if(t.ideId&&((a=t.modalButtons)!=null&&a.length)&&this.resolveActionFn){const c=t.ideId,d=t.agentType||t.ideType||"",h=t.ideType||"",f=t.modalButtons,p=v=>v.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),m=this.resolveActionFn,_=f.map((v,x)=>{const k=p(v).toLowerCase(),P=/^(run|approve|accept|yes|allow|always)/.test(k),C=/^(reject|deny|delete|remove|abort|cancel|no)/.test(k);return{label:p(v),variant:P?"primary":C?"danger":"default",onClick:()=>{const B=this.resolveRouteId(c,d),R=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(k);m(B,"resolve_action",{action:R?"approve":"reject",button:v,buttonIndex:x,agentType:d,ideType:h})}}}),w=t.modalMessage?`⚡ ${i}: ${t.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:s,g=Date.now();this.emitToast({id:g,message:w,type:o,timestamp:g,ideId:c,actions:_,duration:15e3}),s=""}}else if(t.event==="monitor:long_generating"){const c=t.elapsedSec?` (${Math.round(t.elapsedSec/60)}m)`:"";s=`⚠️ ${i} agent is taking a long time${c}`,o="warning",Eo("browser")&&!document.hasFocus()&&Bd(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${t.ideId||t.agentType}`)}else if(t.event==="team:view_request"){const c=t.requesterName||"A team member",d=t.requestId,h=t.orgId;if(s=`👁️ ${c} wants to view your session`,o="warning",d&&h&&this.viewRequestRespondFn){const f=this.viewRequestRespondFn,p=Date.now(),m=[{label:"Approve",variant:"primary",onClick:()=>{f(h,d,"approve").catch(_=>console.error("[EventManager] approve view request failed:",_))}},{label:"Decline",variant:"danger",onClick:()=>{f(h,d,"reject").catch(_=>console.error("[EventManager] reject view request failed:",_))}}];this.emitToast({id:p,message:s,type:o,timestamp:p,actions:m,duration:3e4}),s=""}Eo("browser")&&!document.hasFocus()&&Bd("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else t.event==="team:view_request_approved"?(s="✅ View request approved",o="success"):t.event==="team:view_request_rejected"&&(s=`❌ ${t.targetName||"Team member"} declined your view request`,o="warning");if(s){const c=Date.now();this.emitToast({id:c,message:s,type:o,timestamp:c,ideId:t.ideId,duration:5e3})}}}const gi=new zL;function O1(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=O1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function $L(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=O1(e))&&(n&&(n+=" "),n+=t);return n}const FL=(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},WL=(e,t)=>({classGroupId:e,validator:t}),z1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),nc="-",A_=[],HL="arbitrary..",UL=e=>{const t=VL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return KL(o);const l=o.split(nc),a=l[0]===""&&l.length>1?1:0;return $1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?FL(c,a):a:c||A_}return r[o]||A_}}},$1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=$1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(nc):e.slice(t).join(nc),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},KL=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?HL+n:void 0})(),VL=e=>{const{theme:t,classGroups:r}=e;return qL(r,t)},qL=(e,t)=>{const r=z1();for(const n in e){const i=e[n];mp(i,r,n,t)}return r},mp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];YL(o,t,r,n)}},YL=(e,t,r,n)=>{if(typeof e=="string"){XL(e,t,r);return}if(typeof e=="function"){GL(e,t,r,n);return}QL(e,t,r,n)},XL=(e,t,r)=>{const n=e===""?t:F1(t,e);n.classGroupId=r},GL=(e,t,r,n)=>{if(JL(e)){mp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(WL(r,e))},QL=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];mp(a,F1(t,l),r,n)}},F1=(e,t)=>{let r=e;const n=t.split(nc),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=z1(),r.nextPart.set(o,l)),r=l}return r},JL=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ZL=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)}}},Od="!",B_=":",e4=[],O_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),t4=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===B_){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(Od)?(f=h.slice(0,-1),p=!0):h.startsWith(Od)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return O_(s,p,f,m)};if(t){const i=t+B_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):O_(e4,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},r4=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}},n4=e=>({cache:ZL(e.cacheSize),parseClassName:t4(e),sortModifiers:r4(e),...UL(e)}),i4=/\s+/,s4=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(i4);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+Od:v,k=x+g;if(o.indexOf(k)>-1)continue;o.push(k);const P=i(g,w);for(let C=0;C<P.length;++C){const B=P[C];o.push(x+B)}a=d+(a.length>0?" "+a:a)}return a},o4=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=W1(r))&&(i&&(i+=" "),i+=n);return i},W1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=W1(e[n]))&&(r&&(r+=" "),r+=t);return r},l4=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=n4(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=s4(a,r);return i(a,d),d};return s=o,(...a)=>s(o4(...a))},a4=[],wt=e=>{const t=r=>r[e]||a4;return t.isThemeGetter=!0,t},H1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,U1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,c4=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,u4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,h4=/\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$/,d4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,f4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,p4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=e=>c4.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),On=e=>!!e&&Number.isInteger(Number(e)),zu=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),dn=e=>u4.test(e),K1=()=>!0,m4=e=>h4.test(e)&&!d4.test(e),gp=()=>!1,g4=e=>f4.test(e),_4=e=>p4.test(e),v4=e=>!me(e)&&!ge(e),y4=e=>di(e,Y1,gp),me=e=>H1.test(e),_i=e=>di(e,X1,m4),z_=e=>di(e,N4,Ae),x4=e=>di(e,Q1,K1),b4=e=>di(e,G1,gp),$_=e=>di(e,V1,gp),w4=e=>di(e,q1,_4),Vl=e=>di(e,J1,g4),ge=e=>U1.test(e),eo=e=>qi(e,X1),S4=e=>qi(e,G1),F_=e=>qi(e,V1),k4=e=>qi(e,Y1),C4=e=>qi(e,q1),ql=e=>qi(e,J1,!0),E4=e=>qi(e,Q1,!0),di=(e,t,r)=>{const n=H1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},qi=(e,t,r=!1)=>{const n=U1.exec(e);return n?n[1]?t(n[1]):r:!1},V1=e=>e==="position"||e==="percentage",q1=e=>e==="image"||e==="url",Y1=e=>e==="length"||e==="size"||e==="bg-size",X1=e=>e==="length",N4=e=>e==="number",G1=e=>e==="family-name",Q1=e=>e==="number"||e==="weight",J1=e=>e==="shadow",P4=()=>{const e=wt("color"),t=wt("font"),r=wt("text"),n=wt("font-weight"),i=wt("tracking"),s=wt("leading"),o=wt("breakpoint"),l=wt("container"),a=wt("spacing"),c=wt("radius"),d=wt("shadow"),h=wt("inset-shadow"),f=wt("text-shadow"),p=wt("drop-shadow"),m=wt("blur"),_=wt("perspective"),w=wt("aspect"),g=wt("ease"),v=wt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...k(),ge,me],C=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],R=()=>[ge,me,a],$=()=>[Bn,"full","auto",...R()],S=()=>[On,"none","subgrid",ge,me],j=()=>["auto",{span:["full",On,ge,me]},On,ge,me],I=()=>[On,"auto",ge,me],T=()=>["auto","min","max","fr",ge,me],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],A=()=>["start","end","center","stretch","center-safe","end-safe"],W=()=>["auto",...R()],U=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],M=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...R()],z=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],b=()=>[e,ge,me],J=()=>[...k(),F_,$_,{position:[ge,me]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],E=()=>["auto","cover","contain",k4,y4,{size:[ge,me]}],G=()=>[zu,eo,_i],L=()=>["","none","full",c,ge,me],F=()=>["",Ae,eo,_i],D=()=>["solid","dashed","dotted","double"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[Ae,zu,F_,$_],ve=()=>["","none",m,ge,me],ke=()=>["none",Ae,ge,me],be=()=>["none",Ae,ge,me],ye=()=>[Ae,ge,me],Ce=()=>[Bn,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[dn],breakpoint:[dn],color:[K1],container:[dn],"drop-shadow":[dn],ease:["in","out","in-out"],font:[v4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[dn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[dn],shadow:[dn],spacing:["px",Ae],text:[dn],"text-shadow":[dn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,me,ge,w]}],container:["container"],columns:[{columns:[Ae,me,ge,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:P()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[On,"auto",ge,me]}],basis:[{basis:[Bn,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,Bn,"auto","initial","none",me]}],grow:[{grow:["",Ae,ge,me]}],shrink:[{shrink:["",Ae,ge,me]}],order:[{order:[On,"first","last","none",ge,me]}],"grid-cols":[{"grid-cols":S()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":S()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":T()}],"auto-rows":[{"auto-rows":T()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...A(),"normal"]}],"justify-self":[{"justify-self":["auto",...A()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...A(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...A(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...A(),"baseline"]}],"place-self":[{"place-self":["auto",...A()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:W()}],mx:[{mx:W()}],my:[{my:W()}],ms:[{ms:W()}],me:[{me:W()}],mbs:[{mbs:W()}],mbe:[{mbe:W()}],mt:[{mt:W()}],mr:[{mr:W()}],mb:[{mb:W()}],ml:[{ml:W()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",r,eo,_i]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,E4,x4]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zu,me]}],"font-family":[{font:[S4,b4,t]}],"font-features":[{"font-features":[me]}],"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,ge,me]}],"line-clamp":[{"line-clamp":[Ae,"none",ge,z_]}],leading:[{leading:[s,...R()]}],"list-image":[{"list-image":["none",ge,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ge,me]}],"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:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ge,_i]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[Ae,"auto",ge,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ge,me]}],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",ge,me]}],"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:ie()}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},On,ge,me],radial:["",ge,me],conic:[On,ge,me]},C4,w4]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"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:[...D(),"hidden","none"]}],"divide-style":[{divide:[...D(),"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:[...D(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ge,me]}],"outline-w":[{outline:["",Ae,eo,_i]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,ql,Vl]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,ql,Vl]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[Ae,_i]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,ql,Vl]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[Ae,ge,me]}],"mix-blend":[{"mix-blend":[...te(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":te()}],"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":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"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":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"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":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"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":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"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":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"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":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"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":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[ge,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"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":k()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"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:ie()}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ge,me]}],filter:[{filter:["","none",ge,me]}],blur:[{blur:ve()}],brightness:[{brightness:[Ae,ge,me]}],contrast:[{contrast:[Ae,ge,me]}],"drop-shadow":[{"drop-shadow":["","none",p,ql,Vl]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",Ae,ge,me]}],"hue-rotate":[{"hue-rotate":[Ae,ge,me]}],invert:[{invert:["",Ae,ge,me]}],saturate:[{saturate:[Ae,ge,me]}],sepia:[{sepia:["",Ae,ge,me]}],"backdrop-filter":[{"backdrop-filter":["","none",ge,me]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ge,me]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ge,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ge,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ge,me]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ge,me]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ge,me]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ge,me]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ge,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ge,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",ge,me]}],ease:[{ease:["linear","initial",g,ge,me]}],delay:[{delay:[Ae,ge,me]}],animate:[{animate:["none",v,ge,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,ge,me]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ke()}],"rotate-x":[{"rotate-x":ke()}],"rotate-y":[{"rotate-y":ke()}],"rotate-z":[{"rotate-z":ke()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[ge,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"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",ge,me]}],"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":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",ge,me]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[Ae,eo,_i,z_]}],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"]}},T4=l4(P4);function Zo(...e){return T4($L(e))}function M4({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Zo("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]})]}),r&&u.jsx("p",{className:"hidden sm:block text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Ji({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Zo("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 R4({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Zo("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 L4={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"},I4={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function D4({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Zo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",L4[e],r),children:[u.jsx("span",{className:Zo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",I4[e])}),n]})}function j4(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function W_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function $u(e){return e==="system"?j4():e}function A4(){const[e,t]=y.useState(W_),[r,n]=y.useState(()=>$u(W_()));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($u(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=y.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n($u(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}function es({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"})]})]})}function B4({onPrefChange:e}){const[t,r]=DL(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(es,{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(es,{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(es,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(es,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(es,{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 O4({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(R4,{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(F4,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function H_({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 d0.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 z4={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 $4(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return z4[t]||{icon:"📝",name:e}}function F4({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var A,W,U,M;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=((A=_.machine)==null?void 0:A.hostname)||((W=_.system)==null?void 0:W.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((M=_.system)==null?void 0:M.platform)||"",x=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",k=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",P=t.filter(z=>z.daemonId===e.id&&z.id.includes(":ide:")),C=t.filter(z=>z.daemonId===e.id&&z.id.includes(":cli:")),B=t.filter(z=>z.daemonId===e.id&&z.id.includes(":acp:")),R=_.p2p,$=async()=>{var z,b,J;if(r){o("upgrading"),a("Installing latest version...");try{const ie=await r(e.id,"daemon_upgrade",{});(z=ie==null?void 0:ie.result)!=null&&z.upgraded||(b=ie==null?void 0:ie.result)!=null&&b.success?(o("done"),a(`Upgraded to v${ie.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((J=ie==null?void 0:ie.result)==null?void 0:J.error)||"Upgrade failed"))}catch(ie){o("error"),a((ie==null?void 0:ie.message)||"Connection lost during upgrade")}}},S=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch(z){f("error"),m((z==null?void 0:z.message)||"Failed to disconnect")}}},j=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(z){f("error"),m((z==null?void 0:z.message)||"Failed to revoke token")}}},I="0.6.12",T=!w||w!==I,N=P.length+C.length+B.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:k}),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] ${T?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!T&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&T&&u.jsx("button",{onClick:$,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${I}`,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${I}`}`}),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(D4,{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:[R&&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 ${R.state==="connected"?"bg-green-400":R.state==="connecting"||R.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",R.state==="connected"?"connected":R.state==="connecting"||R.state==="new"?"connecting...":R.state||"off"]}),R.peers!==void 0&&R.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",R.peers," peer",R.peers!==1?"s":"",")"]})]}),R&&N>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),N>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[P.map(z=>{const b=$4(z.type),J=z.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..."})]},z.id)}),C.map(z=>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:z.cliName||"CLI"})]},z.id)),B.map(z=>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:z.cliName||"ACP"})]},z.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(H_,{title:"🔌 Disconnect Machine",message:`Disconnect "${x}" from ADHDev?
174
174
 
175
175
  This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
176
176
 
@@ -199,4 +199,4 @@ Use this if you accidentally set up on a shared/public computer and want to ensu
199
199
  }
200
200
  `}),c&&u.jsx(sI,{onClose:()=>{try{localStorage.setItem("adhdev_onboarding_v1","done")}catch{}d(!1)}})]})}function lI(e){return e.split(":")[0]||""}function aI({renderHeaderActions:e}={}){var be,ye,Ce;const{id:t}=S0(),r=Ui(),n=Ic(),i=n.ides||[],s=n.connectionStates||{},{sendCommand:o}=ui(),l=y.useMemo(()=>lI(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)||((be=_==null?void 0:_.machine)==null?void 0:be.hostname)||"",g=(a==null?void 0:a.workspace)||"",[v]=N0(),x=typeof window<"u"&&window.innerWidth<=768,k=v.get("view")||(x?"chat":"split"),[P,C]=y.useState(k),[B,R]=y.useState("native"),[$,S]=y.useState(""),[j,I]=y.useState(!1),[T,N]=y.useState(null),[A,W]=y.useState(null),[U,M]=y.useState([]),z=h==null?void 0:h.status,b=(((Ce=(ye=h==null?void 0:h.activeModal)==null?void 0:ye.buttons)==null?void 0:Ce.length)??0)>0,J=z==="generating"||z==="loading"||z&&z.toLowerCase()==="thinking",E=b||z==="waiting_approval"?"waiting_approval":J?"working":z||"idle",G=y.useMemo(()=>{var Q,fe;return{ideId:t||"",daemonId:l,agentName:Ad(c||""),agentType:c||"",status:E,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:(fe=h==null?void 0:h.activeModal)==null?void 0:fe.message,streamSource:"native",tabKey:`ide-${t}`}},[t,l,c,h,a,d,E]),L=y.useMemo(()=>f.map(Q=>{var Pe,Le;const fe=Q.activeModal?"waiting_approval":Q.status==="streaming"?"working":Q.status||"idle";return{ideId:t||"",daemonId:l,agentName:Q.agentName,agentType:Q.agentType,status:fe,title:"",messages:Q.messages.map((Ee,Ke)=>({role:Ee.role,content:Ee.content,kind:Ee.kind,id:`${Q.agentType}-${Ke}`,receivedAt:Ee.timestamp})),ideType:Q.agentType,workspaceName:"",displayPrimary:Q.agentName,displaySecondary:"",cdpConnected:!0,modalButtons:(Pe=Q.activeModal)==null?void 0:Pe.buttons,modalMessage:(Le=Q.activeModal)==null?void 0:Le.message,streamSource:"agent-stream",tabKey:`agent-stream-${Q.agentType}`}}),[f,t,l]),F=y.useMemo(()=>B==="native"?G:L.find(Q=>Q.agentType===B)||G,[B,G,L]);y.useEffect(()=>l?yr.onScreenshot("ide-page",(fe,Pe)=>{if(fe!==l)return;const Le=new FileReader;Le.onload=()=>N(Le.result),Le.readAsDataURL(Pe)}):void 0,[l]),y.useEffect(()=>l?yr.onStatusEvent((fe,Pe)=>{if(fe!==l)return;let Le="",Ee="info";if(Pe.event==="agent:generating_completed"?(Le=`✅ Task completed${Pe.duration?` (${Pe.duration}s)`:""}`,Ee="success"):Pe.event==="agent:waiting_approval"&&(Le="⚡ Approval needed",Ee="warning"),Le){const Ke=Date.now();M(Qe=>[...Qe.slice(-4),{id:Ke,message:Le,type:Ee}]),setTimeout(()=>M(Qe=>Qe.filter(sr=>sr.id!==Ke)),Ee==="warning"?1e4:5e3)}}):void 0,[l]);const D=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?yr.get(l):null;!Q||!(m==="connected")||(P!=="chat"&&D?Q.startScreenshots(D):Q.stopScreenshots(D))},[P,m,D,l]);const te=y.useCallback(async(Q,fe={})=>{if(!t)throw new Error("No IDE ID");const Pe={...fe};if(!Pe._targetInstance&&t){const Ee=t.split(":");Ee.length>=3&&(Ee[1]==="ide"||Ee[1]==="cli")&&(Pe._targetInstance=Ee.slice(2).join(":"),Pe._targetType=Ee[1])}const Le=l?yr.get(l):null;return Le!=null&&Le.hasCommandChannel?await Le.sendCommand(Q,Pe):Le&&Le.connectionState!=="failed"&&Le.connectionState!=="closed"&&await new Promise(Ke=>{const ir=Date.now(),Qe=()=>{if(Le.hasCommandChannel)return Ke(!0);if(Date.now()-ir>3e3)return Ke(!1);setTimeout(Qe,200)};Qe()})&&Le.hasCommandChannel?await Le.sendCommand(Q,Pe):await o(t,Q,Pe)},[t,l]),ne=async()=>{const Q=$.trim();if(!(!Q||!t||j)){S(""),I(!0);try{await te("send_chat",{message:Q,text:Q,waitForResponse:!0,...B!=="native"&&{agentType:B}})}catch(fe){console.error("[IDE] Send failed:",fe)}finally{I(!1)}}},ve=async Q=>{if(t)try{const fe=await o(t,"screenshot",{width:Q?Math.min(Q,1280):1280});fe!=null&&fe.success&&(fe!=null&&fe.base64)&&W(`data:image/jpeg;base64,${fe.base64}`)}catch(fe){console.error("[IDE] Screenshot failed:",fe)}},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(Ga,{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:P===Q?"1px solid var(--accent-primary)":"none",background:P===Q?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:P===Q?"var(--accent-primary)":void 0},onClick:()=>C(Q),children:Q==="chat"?u.jsx(Ga,{size:14}):Q==="split"?"⊞":u.jsx(dl,{size:14})},Q)),e&&e({daemonId:l,ideInstanceId:t||""}),u.jsxs("button",{className:"btn btn-primary btn-sm 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 ${P==="chat"?"full":""} ${P==="remote"?"hidden":""}`,children:[ke&&u.jsxs("div",{className:"ide-chat-tabs",children:[u.jsx("button",{className:`ide-chat-tab ${B==="native"?"active":""}`,onClick:()=>R("native"),children:d}),f.map(Q=>{const fe=B===Q.agentType,Pe=Q.status==="waiting_approval"||!!Q.activeModal,Le=Q.status==="streaming";return u.jsxs("button",{className:`ide-chat-tab ${fe?"active":""}`,onClick:()=>R(Q.agentType),children:[u.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",marginRight:5,background:Pe?"#f59e0b":Le?"var(--accent-primary)":"#64748b",boxShadow:Le?"0 0 6px var(--accent-primary)":"none"}}),Q.agentName,Pe&&u.jsx("span",{className:"ide-ext-badge",style:{background:"#f59e0b22",color:"#f59e0b",marginLeft:4},children:"!"})]},Q.agentType)})]}),u.jsx(D1,{activeConv:F,ides:i,agentInput:$,setAgentInput:S,handleSendChat:ne,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[],userName:n.userName})]}),u.jsx("div",{className:`ide-remote-panel ${P==="remote"?"full":""} ${P==="chat"?"hidden":""}`,children:u.jsx(dL,{screenshot:A,isCapturing:!1,onRefresh:ve,addLog:()=>{},connState:m,connScreenshot:T,onAction:async(Q,fe)=>{const Pe=l?yr.get(l):null;if(!Pe||m!=="connected")return console.warn("[RemoteInput] P2P not connected"),{success:!1,error:"P2P not connected"};const Le=(a==null?void 0:a.instanceId)||D;return await Pe.sendInput(Q,fe,Le)}})})]}),U.length>0&&u.jsx("div",{className:"ide-toasts",children:U.map(Q=>u.jsx("div",{className:`ide-toast ${Q.type}`,onClick:()=>M(fe=>fe.filter(Pe=>Pe.id!==Q.id)),children:Q.message},Q.id))})]}):u.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function cI({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,k]=y.useState(!1),[P,C]=y.useState(""),B=y.useRef(null),R=y.useCallback(G=>{B.current=G},[]),$=y.useCallback((G,L)=>{i(F=>[...F.slice(-100),{timestamp:Date.now(),level:G,message:L}]),setTimeout(()=>{var F;return(F=r.current)==null?void 0:F.scrollIntoView({behavior:"smooth"})},100)},[r]),S=y.useCallback(async(G,L)=>{var F;if(!(!e||s)){o(G),$("info",`Launching ${Ur(G)}${L!=null&&L.workspace?` in ${L.workspace}`:""}...`);try{const D={ideType:G,enableCdp:!0};(F=L==null?void 0:L.workspace)!=null&&F.trim()?D.workspace=L.workspace.trim():L!=null&&L.useDefaultWorkspace&&(D.useDefaultWorkspace=!0);const te=await t(e,"launch_ide",D);$(te!=null&&te.success?"info":"error",te!=null&&te.success?`${Ur(G)} launched`:`Failed: ${te==null?void 0:te.error}`)}catch(D){$("error",`Launch error: ${D.message}`)}finally{o(null)}}},[e,s,$,t]),j=y.useCallback(async G=>{if(!e)return;const{cliType:L,dir:F,workspaceId:D,useDefaultWorkspace:te,useHome:ne,argsStr:ve,model:ke}=G;if(!L){$("warn","Select a CLI or ACP provider first");return}const be=ve?ve.split(/\s+/).filter(Boolean):void 0,ye=(F==null?void 0:F.trim())||(D?"(saved id)":te?"(default workspace)":ne?"(home)":"");$("info",`Launching ${L}${ye?` in ${ye}`:""}${ke?` (model: ${ke})`:""}...`);try{const Ce={cliType:L,cliArgs:be,initialModel:ke||void 0};F!=null&&F.trim()?Ce.dir=F.trim():D?Ce.workspaceId=D:te?Ce.useDefaultWorkspace=!0:ne&&(Ce.useHome=!0);const Q=await t(e,"launch_cli",Ce),fe=(Q==null?void 0:Q.result)||Q;Q!=null&&Q.success?($("info",`${L} launched`),(fe==null?void 0:fe.launchSource)==="home"?$("info","📂 Running in home directory (explicit choice)"):(fe==null?void 0:fe.launchSource)==="defaultWorkspace"&&$("info","📂 Using default workspace (explicit choice)")):($("error",`Failed: ${(Q==null?void 0:Q.error)||(fe==null?void 0:fe.error)}`),(Q==null?void 0:Q.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&v({cliType:L,argsStr:ve,model:ke}))}catch(Ce){$("error",`Launch error: ${Ce.message}`)}},[e,$,t]),I=y.useCallback((G,L,F,D)=>{if(e){if(!G){$("warn","Select a provider");return}if(!L.trim()){v({cliType:G,argsStr:F,model:D});return}j({cliType:G,dir:L,argsStr:F,model:D})}},[e,$,j]),T=y.useCallback(async(G,L,F)=>{if(e&&window.confirm(`Stop ${G}?
201
201
  This will terminate the process.`))try{const D=await t(e,"stop_cli",{cliType:G,dir:L,_targetInstance:F});D!=null&&D.success?$("info",`${G} stopped`):$("error",`Stop failed: ${(D==null?void 0:D.error)||"Unknown error"}`)}catch(D){$("error",`Stop failed: ${D.message}`)}},[e,$,t]),N=y.useCallback(async G=>{try{await t(G.daemonId,"restart_ide",{ideType:G.type}),$("info",`${Ur(G.type)} restart initiated`)}catch(L){$("error",`Restart failed: ${L.message}`)}},[$,t]),A=y.useCallback(async G=>{if(window.confirm(`Stop ${Ur(G.type)}?
202
- This will disconnect CDP and optionally kill the process.`))try{const L=await t(G.daemonId,"stop_ide",{ideType:G.type,killProcess:!0});L!=null&&L.success?$("info",`${Ur(G.type)} stopped`):$("error",`Stop failed: ${(L==null?void 0:L.error)||"Unknown error"}`)}catch(L){$("error",`Stop failed: ${L.message}`)}},[$,t]),W=y.useCallback(async()=>{if(e)try{const G=await t(e,"detect_ides",{});$("info",`Found ${((G==null?void 0:G.result)||[]).length} IDE(s)`)}catch(G){$("error",`Detection failed: ${G.message}`)}},[e,$,t]),U=y.useCallback(async()=>{if(e){a(!0);try{const G=await t(e,"get_recent_workspaces",{});G!=null&&G.success&&Array.isArray(G==null?void 0:G.result)&&w(G.result)}catch(G){$("error",`Failed: ${G.message}`)}finally{a(!1)}}},[e,$,t]),M=y.useCallback(async G=>{if(!(!e||!G.trim())){d(!0);try{const L=await t(e,"workspace_add",{path:G.trim()});L!=null&&L.success?$("info",`Workspace added: ${G.trim()}`):$("error",(L==null?void 0:L.error)||"workspace_add failed")}catch(L){$("error",L.message)}finally{d(!1)}return!0}},[e,$,t]),z=y.useCallback(async G=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const L=await t(e,"workspace_remove",{id:G});L!=null&&L.success?$("info","Workspace removed"):$("error",(L==null?void 0:L.error)||"workspace_remove failed")}catch(L){$("error",L.message)}finally{d(!1)}}},[e,$,t]),b=y.useCallback(async G=>{var L;if(e){d(!0);try{const F=await t(e,"workspace_set_default",G===null?{clear:!0}:{id:G});if(F!=null&&F.success){$("info",G?"Default workspace updated":"Default workspace cleared");const D=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";D&&((L=B.current)==null||L.call(B,D))}else $("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){$("error",F.message)}finally{d(!1)}}},[e,$,t]),J=y.useCallback(async G=>{var F;if(!e||!G.trim())return;const L=G.trim();d(!0);try{const D=await t(e,"workspace_set_default",{path:L});D!=null&&D.success?($("info","Default workspace set from history"),(F=B.current)==null||F.call(B,L)):$("error",(D==null?void 0:D.error)||"Could not set default (path missing on disk?)")}catch(D){$("error",D.message)}finally{d(!1)}},[e,$,t]),ie=y.useCallback(async()=>{var G;if(e){f(!0);try{const L=await t(e,"get_cli_history",{}),F=(L==null?void 0:L.history)??((G=L==null?void 0:L.result)==null?void 0:G.history);L!=null&&L.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),E=y.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:P}),$("info",`Nickname set to "${P||"(cleared)"}"`),k(!1)}catch(G){$("error",`Failed: ${G.message}`)}},[e,P,$,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:x,setEditingNickname:k,nicknameInput:P,setNicknameInput:C,addLog:$,handleLaunchIde:S,runLaunchCliCore:j,handleLaunchCli:I,handleStopCli:T,handleRestartIde:N,handleStopIde:A,handleDetectIdes:W,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:M,handleWorkspaceRemove:z,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:J,loadCliHistory:ie,handleSaveNickname:E,setOnDefaultWorkspaceChanged:R}}function uI({machine:e,managedIdes:t,managedClis:r,managedAcps:n,actions:i}){const{workspaceBusy:s,handleWorkspaceAdd:o,handleWorkspaceRemove:l,handleWorkspaceSetDefault:a}=i,[c,d]=y.useState(""),h=e.availableMem??e.freeMem,f=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-h)/e.totalMem*100))):0,p=e.loadavg[0]||0;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(Kl,{icon:u.jsx(FT,{size:16}),label:"Uptime",value:wL(e.uptime)}),u.jsx(Kl,{icon:u.jsx(dl,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Kl,{icon:u.jsx($x,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Kl,{icon:u.jsx(Fx,{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(T_,{value:Math.min(Math.round(p/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${p.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(T_,{value:f,max:100,label:"Memory",color:"#3b82f6",detail:`${R_(e.totalMem-h)} / ${R_(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.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5 mb-3",children:[u.jsx(Jh,{size:14})," Workspaces"]}),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:s,value:e.defaultWorkspaceId||"",onChange:m=>void a(m.target.value===""?null:m.target.value),children:[u.jsx("option",{value:"",children:"(none)"}),(e.workspaces||[]).map(m=>u.jsx("option",{value:m.id,children:m.label||m.path},m.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:"Add workspace path…",value:c,disabled:s,onChange:m=>d(m.target.value),onKeyDown:m=>m.key==="Enter"&&void(async()=>{await o(c)&&d("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:s,onClick:async()=>{await o(c)&&d("")},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(m=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[m.id===e.defaultWorkspaceId&&u.jsx("span",{className:"text-[10px]",children:"⭐"}),u.jsx("span",{className:"font-mono truncate flex-1",title:m.path,children:m.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:s,onClick:()=>void l(m.id),children:"Remove"})]},m.id))})]})]})}const hI={ide:{label:"IDE",plural:"IDEs",accent:"border-blue-500/[0.12]"},cli:{label:"CLI",plural:"CLIs",accent:"border-violet-500/[0.12]"},acp:{label:"ACP Agent",plural:"ACP agents",accent:"border-emerald-500/[0.12]"}};function Hu({category:e,machine:t,machineId:r,providers:n,managedEntries:i,getIcon:s,actions:o,sendDaemonCommand:l}){const a=Ui(),{handleLaunchIde:c,handleLaunchCli:d,handleStopCli:h,handleRestartIde:f,handleStopIde:p,handleDetectIdes:m,cliHistory:_,loadingHistory:w,loadCliHistory:g,launchingIde:v}=o,x=hI[e],k=e==="ide",P=e==="acp",C=n.filter(D=>D.category===e),[B,R]=y.useState(""),[$,S]=y.useState(""),[j,I]=y.useState(""),[T,N]=y.useState(t.defaultWorkspaceId||""),[A,W]=y.useState("");y.useEffect(()=>{!B&&C.length>0&&R(C[0].type)},[B,C.length]),y.useEffect(()=>{t.defaultWorkspaceId&&!T&&N(t.defaultWorkspaceId)},[t.defaultWorkspaceId]);const U=(()=>{if(T==="__custom__")return A.trim();if(!T)return"";const D=(t.workspaces||[]).find(te=>te.id===T);return(D==null?void 0:D.path)||""})(),[M,z]=y.useState({}),[b,J]=y.useState(null);y.useEffect(()=>{if(!k||!r||!l)return;(async()=>{try{const te=await l(r,"get_ide_extensions",{}),ne=(te==null?void 0:te.result)||te;ne!=null&&ne.success&&(ne!=null&&ne.ides)&&z(ne.ides)}catch{}})()},[k,r,l]);const ie=D=>k?Ur(D.type):e==="cli"?D.cliName:D.acpName,E=k?t.detectedIdes||[]:[],G=()=>{k?c(B,U?{workspace:U}:void 0):d(B,U,$||void 0,P&&j||void 0)},L=D=>{k?p(D):h(D.type,D.workspace,D.id)},F=u.jsxs("div",{className:"flex gap-2 items-center flex-wrap mb-3",children:[u.jsx("select",{value:T,onChange:D=>{N(D.target.value),D.target.value!=="__custom__"&&W("")},className:"machine-input min-w-[200px] flex-1",children:(t.workspaces||[]).length>0?u.jsxs(u.Fragment,{children:[u.jsx("option",{value:"",children:"(no workspace — launch in home)"}),(t.workspaces||[]).map(D=>u.jsxs("option",{value:D.id,children:[D.id===t.defaultWorkspaceId?"⭐ ":"",D.label||D.path.split("/").filter(Boolean).pop()||D.path," — ",D.path]},D.id)),u.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]}):u.jsxs(u.Fragment,{children:[u.jsx("option",{value:"",children:"(no workspaces saved — add in Overview tab)"}),u.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]})}),T==="__custom__"&&u.jsx("input",{type:"text",placeholder:"Enter absolute path…",value:A,onChange:D=>W(D.target.value),className:"machine-input flex-1 min-w-[200px]",autoFocus:!0})]});return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${x.accent}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Launch ",x.label]}),F,k?u.jsx(u.Fragment,{children:u.jsxs("div",{className:"flex flex-wrap gap-2",children:[E.map(D=>{const te=D.running||i.some(ne=>(ne.type||"").toLowerCase()===(D.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>c(D.type||D.id||"",U?{workspace:U}:void 0),disabled:!!v,className:`machine-btn-primary flex items-center gap-1.5 ${te?"!border-green-500/30":""}`,style:{opacity:v&&v!==D.type?.4:1},children:[u.jsx("span",{children:s(D.type)}),te&&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)]"}),v===D.type?"⏳ Launching...":`▶ ${D.name||Ur(D.type)}`,te&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},D.type)}),E.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:m,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(OT,{size:12})," Scan"]})]})]})}):u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:B,onChange:D=>R(D.target.value),className:"machine-input",children:C.length>0?C.map(D=>u.jsxs("option",{value:D.type,children:[D.icon," ",D.displayName]},D.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),P&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:j,onChange:D=>I(D.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:$,onChange:D=>S(D.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:G,className:"machine-btn-primary",children:"▶ Launch"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",i.length,")"]}),i.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 ",x.plural," running"]}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:i.map(D=>{const te=k?D:null,ne=P?D:null;return 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",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:s(D.type)}),u.jsxs("div",{children:[u.jsxs("div",{className:"font-semibold text-[13px] text-text-primary",children:[ie(D),(te==null?void 0:te.version)&&u.jsxs("span",{className:"text-[10px] text-text-muted ml-1.5",children:["v",te.version]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:D.workspace||"—"}),(ne==null?void 0:ne.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",ne.currentModel]}),(ne==null?void 0:ne.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",ne.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${D.status==="stopped"?"bg-red-500/[0.08] text-red-500":D.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:D.status}),k&&u.jsxs(u.Fragment,{children:[u.jsxs("button",{onClick:()=>a(`/ide/${D.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(dl,{size:13})," Control"]}),u.jsx("button",{onClick:()=>f(D),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻"})]}),P&&u.jsx("button",{onClick:()=>a(`/ide/${D.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Ga,{size:14})}),D.status==="stopped"?u.jsx("button",{onClick:()=>k?c(D.type,D.workspace?{workspace:D.workspace}:void 0):d(D.type,D.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>L(D),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]}),te&&te.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:te.aiAgents.map(ve=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${ve.status==="generating"||ve.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[ve.name," · ",ve.status]},ve.id))}),te&&(M[te.type]||[]).length>0&&l&&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:(M[te.type]||[]).map(ve=>u.jsxs("button",{disabled:b===`${te.type}.${ve.type}`,onClick:async()=>{const ke=`${te.type}.${ve.type}`;J(ke);try{await l(r,"set_ide_extension",{ideType:te.type,extensionType:ve.type,enabled:!ve.enabled}),z(be=>({...be,[te.type]:(be[te.type]||[]).map(ye=>ye.type===ve.type?{...ye,enabled:!ye.enabled}:ye)}))}catch(be){console.error("Extension toggle failed:",be)}finally{J(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 ${ve.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 ${ve.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),ve.name,u.jsx("span",{className:"text-[9px] font-normal",children:ve.enabled?"ON":"OFF"})]},ve.type))})]})]},D.id)})}),!k&&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:g,disabled:w,className:"machine-btn",children:w?"⏳":"↻ Load"})]}),(()=>{const D=new Set(C.map(ne=>ne.type)),te=_.filter(ne=>D.has(ne.cliType));return te.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:te.map((ne,ve)=>{var ke,be;return u.jsxs("div",{onClick:()=>{R(ne.cliType),N("__custom__"),W(ne.dir),S((ne.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-colors duration-150 hover:bg-bg-glass-hover",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:s(ne.cliType)}),u.jsx("span",{children:((ke=ne.dir)==null?void 0:ke.split("/").filter(Boolean).pop())||"root"}),((be=ne.cliArgs)==null?void 0:be.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:ne.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:ne.timestamp?new Date(ne.timestamp).toLocaleDateString():""})]},ve)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",x.label," launch history yet."]})})()]})]})}function dI({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(k=>k.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),k=!!(g.values[v.key]??v.default);x?(x.onCount+=k?1:0,x.total+=1):m.set(v.key,{label:v.label||v.key,onCount:k?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,k=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:k,className:`machine-btn text-[9px] px-1.5 py-px ${k?"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 fI({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 pI({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/10 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 mI(){var k,P,C,B,R,$,S,j,I,T;const{id:e}=S0(),t=Ui(),{sendCommand:r}=ui(),n=Ic(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=y.useState("overview"),a=y.useRef(null),c=cI({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(N=>N.id===e&&N.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(N=>({type:N.type,displayName:N.displayName,icon:N.icon,category:N.category})),f={};for(const N of h)f[N.type]=N.icon;const p=N=>f[N]||"",m=d?{id:d.id,hostname:((k=d.machine)==null?void 0:k.hostname)||d.id,platform:((P=d.machine)==null?void 0:P.platform)||"unknown",arch:((C=d.machine)==null?void 0:C.arch)||"",cpus:((B=d.machine)==null?void 0:B.cpus)||0,totalMem:((R=d.machine)==null?void 0:R.totalMem)||0,freeMem:(($=d.machine)==null?void 0:$.freeMem)||0,availableMem:(S=d.machine)==null?void 0:S.availableMem,loadavg:((j=d.machine)==null?void 0:j.loadavg)||[],uptime:((I=d.machine)==null?void 0:I.uptime)||0,release:((T=d.machine)==null?void 0:T.release)||"",cdpConnected:!!(d.ides||[]).some(N=>N.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(N=>N.daemonId===e&&!N.daemonMode).filter(N=>!L_(N)&&!I_(N)).map(N=>({id:N.id,type:N.type,version:N.version||"",instanceId:N.instanceId||"",status:N.status,workspace:N.workspace||null,terminals:N.terminals||0,aiAgents:SL(N.aiAgents||N.agents||[]),activeChat:N.activeChat||null,chats:N.chats||[],agentStreams:N.agentStreams||[],cdpConnected:N.cdpConnected||!1,daemonId:e})),w=i.filter(N=>N.daemonId===e&&L_(N)).map(N=>({id:N.id,type:N.type,cliName:N.cliName||N.type,status:N.status,workspace:N.workspace||"",activeChat:N.activeChat||null,daemonId:e})),g=i.filter(N=>N.daemonId===e&&I_(N)).map(N=>({id:N.id,type:N.type,acpName:N.cliName||N.type,status:N.status,workspace:N.workspace||"",activeChat:N.activeChat||null,currentModel:N.currentModel,currentPlan:N.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(WT,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(dl,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zx,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Fx,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Bx,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(jT,{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:N=>c.setNicknameInput(N.target.value),onKeyDown:N=>{N.key==="Enter"&&c.handleSaveNickname(),N.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"]}),(d==null?void 0:d.version)&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-bg-glass border border-border-subtle text-text-muted shrink-0",children:["v",d.version]}),(d==null?void 0:d.versionMismatch)&&u.jsxs("button",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-amber-500/[0.08] border border-amber-500/20 text-amber-400 cursor-pointer hover:bg-amber-500/[0.15] transition-colors shrink-0",onClick:async()=>{try{await r(e,"daemon_upgrade",{})}catch{}},children:["🔄 Update to v",d.serverVersion]}),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(N=>u.jsxs("button",{onClick:()=>l(N.id),className:`machine-tab shrink-0${o===N.id?" active":""}`,children:[N.label,N.count!==void 0&&u.jsx("span",{className:"tab-count",children:N.count})]},N.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(uI,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,actions:c}),o==="ides"&&u.jsx(Hu,{category:"ide",machine:m,machineId:e,providers:h,managedEntries:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(Hu,{category:"cli",machine:m,machineId:e,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(Hu,{category:"acp",machine:m,machineId:e,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(dI,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(fI,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(pI,{machine:m,launchPick:c.launchPick,actions:c})]})}function gI(){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 q_=gI(),Y_=3e3,_I=3e4;let _n=null,vI=0;const ic=new Map,Wd=new Set;let vi=null;async function xa(e,t,r){const n=_n;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++vI}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{ic.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);ic.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 yI{constructor(t){Xt(this,"daemonId");Xt(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(_n==null?void 0:_n.readyState)===WebSocket.OPEN}get connectionState(){return(_n==null?void 0:_n.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return xa(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return xa(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,vi&&(clearInterval(vi),vi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await xa(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());Wd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let yi=null;function xI(e){(!yi||yi.daemonId!==e)&&(yi=new yI(e));const t=yr._originalGet||yr.get.bind(yr);yr._originalGet=t,yr.get=r=>r===e||r.startsWith("standalone")?yi:t(r),yr.getState=r=>(r===e||r.startsWith("standalone"))&&(yi==null?void 0:yi.connectionState)||"disconnected",yr.onScreenshot=(r,n)=>(Wd.add(n),()=>{Wd.delete(n)})}function bI({children:e}){const t=y.useRef(Am()),r=Am();t.current=r;const{setUserName:n}=qo(),i=y.useRef(n);i.current=n;const[,s]=y.useState("disconnected"),o=y.useRef(null),l=y.useRef(),a=y.useRef(Y_),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 ${q_}...`);let f;try{f=new WebSocket(q_)}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=Y_,console.log("[Standalone WS] Connected")},_n=f,f.onmessage=_=>{var w;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=ic.get(g.requestId);v&&(ic.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:k}=t.current,P=v.id||"standalone";xI(P);const C=TL(v,{daemonId:P});C.length>0&&x(C),k(),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,_I),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,_n=null)}},[]),u.jsx(u.Fragment,{children:e})}function wI({children:e}){return u.jsx(Lk,{children:u.jsx(bI,{children:e})})}const SI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(IT,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(DT,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(Bx,{}),label:"Settings"}];function kI({children:e}){const t=Ui(),r=al(),[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:SI.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(AT,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.11"]}),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 CI=[{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."}],EI=[{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."}],NI=[{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}],Uu={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 PI(){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.6.11"]})]}),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:CI.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:Uu.ides},{label:"Extension agents",items:Uu.agents},{label:"CLI agents",items:Uu.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:NI.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:EI.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 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function TI(){const{ides:e}=qo(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ui(),{userName:i}=qo(),[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(M4,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Ji,{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.6.11"]}),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(Ji,{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(Ji,{title:"Machine",className:"mb-4",children:u.jsx(O4,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Ji,{title:"Theme",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),u.jsx(H4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),u.jsx(X4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),u.jsx(tI,{})]})]})}),u.jsx(Ji,{title:"Notifications",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(B4,{}),u.jsx(es,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})}),u.jsx(Ji,{title:"Preferences",className:"mb-4",children:u.jsx("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-default 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 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()}})]})})})]})]})}q4();function X_(){const{ides:e}=qo(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(la,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(la,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(la,{to:"/dashboard",replace:!0})}function MI(){return u.jsx(Mk,{children:u.jsx(wI,{children:u.jsx(Ak,{value:{sendCommand:xa,sendData:()=>!1},children:u.jsx(kI,{children:u.jsxs(Ek,{children:[u.jsx(pn,{path:"/dashboard",element:u.jsx(oI,{})}),u.jsx(pn,{path:"/ide/:id",element:u.jsx(aI,{})}),u.jsx(pn,{path:"/machine",element:u.jsx(X_,{})}),u.jsx(pn,{path:"/machines/:id",element:u.jsx(mI,{})}),u.jsx(pn,{path:"/machines",element:u.jsx(X_,{})}),u.jsx(pn,{path:"/about",element:u.jsx(PI,{})}),u.jsx(pn,{path:"/settings",element:u.jsx(TI,{})}),u.jsx(pn,{path:"*",element:u.jsx(la,{to:"/dashboard",replace:!0})})]})})})})})}f0(document.getElementById("root")).render(u.jsx(y.StrictMode,{children:u.jsx(MI,{})}));
202
+ This will disconnect CDP and optionally kill the process.`))try{const L=await t(G.daemonId,"stop_ide",{ideType:G.type,killProcess:!0});L!=null&&L.success?$("info",`${Ur(G.type)} stopped`):$("error",`Stop failed: ${(L==null?void 0:L.error)||"Unknown error"}`)}catch(L){$("error",`Stop failed: ${L.message}`)}},[$,t]),W=y.useCallback(async()=>{if(e)try{const G=await t(e,"detect_ides",{});$("info",`Found ${((G==null?void 0:G.result)||[]).length} IDE(s)`)}catch(G){$("error",`Detection failed: ${G.message}`)}},[e,$,t]),U=y.useCallback(async()=>{if(e){a(!0);try{const G=await t(e,"get_recent_workspaces",{});G!=null&&G.success&&Array.isArray(G==null?void 0:G.result)&&w(G.result)}catch(G){$("error",`Failed: ${G.message}`)}finally{a(!1)}}},[e,$,t]),M=y.useCallback(async G=>{if(!(!e||!G.trim())){d(!0);try{const L=await t(e,"workspace_add",{path:G.trim()});L!=null&&L.success?$("info",`Workspace added: ${G.trim()}`):$("error",(L==null?void 0:L.error)||"workspace_add failed")}catch(L){$("error",L.message)}finally{d(!1)}return!0}},[e,$,t]),z=y.useCallback(async G=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const L=await t(e,"workspace_remove",{id:G});L!=null&&L.success?$("info","Workspace removed"):$("error",(L==null?void 0:L.error)||"workspace_remove failed")}catch(L){$("error",L.message)}finally{d(!1)}}},[e,$,t]),b=y.useCallback(async G=>{var L;if(e){d(!0);try{const F=await t(e,"workspace_set_default",G===null?{clear:!0}:{id:G});if(F!=null&&F.success){$("info",G?"Default workspace updated":"Default workspace cleared");const D=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";D&&((L=B.current)==null||L.call(B,D))}else $("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){$("error",F.message)}finally{d(!1)}}},[e,$,t]),J=y.useCallback(async G=>{var F;if(!e||!G.trim())return;const L=G.trim();d(!0);try{const D=await t(e,"workspace_set_default",{path:L});D!=null&&D.success?($("info","Default workspace set from history"),(F=B.current)==null||F.call(B,L)):$("error",(D==null?void 0:D.error)||"Could not set default (path missing on disk?)")}catch(D){$("error",D.message)}finally{d(!1)}},[e,$,t]),ie=y.useCallback(async()=>{var G;if(e){f(!0);try{const L=await t(e,"get_cli_history",{}),F=(L==null?void 0:L.history)??((G=L==null?void 0:L.result)==null?void 0:G.history);L!=null&&L.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),E=y.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:P}),$("info",`Nickname set to "${P||"(cleared)"}"`),k(!1)}catch(G){$("error",`Failed: ${G.message}`)}},[e,P,$,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:x,setEditingNickname:k,nicknameInput:P,setNicknameInput:C,addLog:$,handleLaunchIde:S,runLaunchCliCore:j,handleLaunchCli:I,handleStopCli:T,handleRestartIde:N,handleStopIde:A,handleDetectIdes:W,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:M,handleWorkspaceRemove:z,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:J,loadCliHistory:ie,handleSaveNickname:E,setOnDefaultWorkspaceChanged:R}}function uI({machine:e,managedIdes:t,managedClis:r,managedAcps:n,actions:i}){const{workspaceBusy:s,handleWorkspaceAdd:o,handleWorkspaceRemove:l,handleWorkspaceSetDefault:a}=i,[c,d]=y.useState(""),h=e.availableMem??e.freeMem,f=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-h)/e.totalMem*100))):0,p=e.loadavg[0]||0;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(Kl,{icon:u.jsx(FT,{size:16}),label:"Uptime",value:wL(e.uptime)}),u.jsx(Kl,{icon:u.jsx(dl,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Kl,{icon:u.jsx($x,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Kl,{icon:u.jsx(Fx,{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(T_,{value:Math.min(Math.round(p/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${p.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(T_,{value:f,max:100,label:"Memory",color:"#3b82f6",detail:`${R_(e.totalMem-h)} / ${R_(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.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5 mb-3",children:[u.jsx(Jh,{size:14})," Workspaces"]}),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:s,value:e.defaultWorkspaceId||"",onChange:m=>void a(m.target.value===""?null:m.target.value),children:[u.jsx("option",{value:"",children:"(none)"}),(e.workspaces||[]).map(m=>u.jsx("option",{value:m.id,children:m.label||m.path},m.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:"Add workspace path…",value:c,disabled:s,onChange:m=>d(m.target.value),onKeyDown:m=>m.key==="Enter"&&void(async()=>{await o(c)&&d("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:s,onClick:async()=>{await o(c)&&d("")},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(m=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[m.id===e.defaultWorkspaceId&&u.jsx("span",{className:"text-[10px]",children:"⭐"}),u.jsx("span",{className:"font-mono truncate flex-1",title:m.path,children:m.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:s,onClick:()=>void l(m.id),children:"Remove"})]},m.id))})]})]})}const hI={ide:{label:"IDE",plural:"IDEs",accent:"border-blue-500/[0.12]"},cli:{label:"CLI",plural:"CLIs",accent:"border-violet-500/[0.12]"},acp:{label:"ACP Agent",plural:"ACP agents",accent:"border-emerald-500/[0.12]"}};function Hu({category:e,machine:t,machineId:r,providers:n,managedEntries:i,getIcon:s,actions:o,sendDaemonCommand:l}){const a=Ui(),{handleLaunchIde:c,handleLaunchCli:d,handleStopCli:h,handleRestartIde:f,handleStopIde:p,handleDetectIdes:m,cliHistory:_,loadingHistory:w,loadCliHistory:g,launchingIde:v}=o,x=hI[e],k=e==="ide",P=e==="acp",C=n.filter(D=>D.category===e),[B,R]=y.useState(""),[$,S]=y.useState(""),[j,I]=y.useState(""),[T,N]=y.useState(t.defaultWorkspaceId||""),[A,W]=y.useState("");y.useEffect(()=>{!B&&C.length>0&&R(C[0].type)},[B,C.length]),y.useEffect(()=>{t.defaultWorkspaceId&&!T&&N(t.defaultWorkspaceId)},[t.defaultWorkspaceId]);const U=(()=>{if(T==="__custom__")return A.trim();if(!T)return"";const D=(t.workspaces||[]).find(te=>te.id===T);return(D==null?void 0:D.path)||""})(),[M,z]=y.useState({}),[b,J]=y.useState(null);y.useEffect(()=>{if(!k||!r||!l)return;(async()=>{try{const te=await l(r,"get_ide_extensions",{}),ne=(te==null?void 0:te.result)||te;ne!=null&&ne.success&&(ne!=null&&ne.ides)&&z(ne.ides)}catch{}})()},[k,r,l]);const ie=D=>k?Ur(D.type):e==="cli"?D.cliName:D.acpName,E=k?t.detectedIdes||[]:[],G=()=>{k?c(B,U?{workspace:U}:void 0):d(B,U,$||void 0,P&&j||void 0)},L=D=>{k?p(D):h(D.type,D.workspace,D.id)},F=u.jsxs("div",{className:"flex gap-2 items-center flex-wrap mb-3",children:[u.jsx("select",{value:T,onChange:D=>{N(D.target.value),D.target.value!=="__custom__"&&W("")},className:"machine-input min-w-[200px] flex-1",children:(t.workspaces||[]).length>0?u.jsxs(u.Fragment,{children:[u.jsx("option",{value:"",children:"(no workspace — launch in home)"}),(t.workspaces||[]).map(D=>u.jsxs("option",{value:D.id,children:[D.id===t.defaultWorkspaceId?"⭐ ":"",D.label||D.path.split("/").filter(Boolean).pop()||D.path," — ",D.path]},D.id)),u.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]}):u.jsxs(u.Fragment,{children:[u.jsx("option",{value:"",children:"(no workspaces saved — add in Overview tab)"}),u.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]})}),T==="__custom__"&&u.jsx("input",{type:"text",placeholder:"Enter absolute path…",value:A,onChange:D=>W(D.target.value),className:"machine-input flex-1 min-w-[200px]",autoFocus:!0})]});return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${x.accent}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Launch ",x.label]}),F,k?u.jsx(u.Fragment,{children:u.jsxs("div",{className:"flex flex-wrap gap-2",children:[E.map(D=>{const te=D.running||i.some(ne=>(ne.type||"").toLowerCase()===(D.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>c(D.type||D.id||"",U?{workspace:U}:void 0),disabled:!!v,className:`machine-btn-primary flex items-center gap-1.5 ${te?"!border-green-500/30":""}`,style:{opacity:v&&v!==D.type?.4:1},children:[u.jsx("span",{children:s(D.type)}),te&&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)]"}),v===D.type?"⏳ Launching...":`▶ ${D.name||Ur(D.type)}`,te&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},D.type)}),E.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:m,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(OT,{size:12})," Scan"]})]})]})}):u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:B,onChange:D=>R(D.target.value),className:"machine-input",children:C.length>0?C.map(D=>u.jsxs("option",{value:D.type,children:[D.icon," ",D.displayName]},D.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),P&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:j,onChange:D=>I(D.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:$,onChange:D=>S(D.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:G,className:"machine-btn-primary",children:"▶ Launch"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",i.length,")"]}),i.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 ",x.plural," running"]}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:i.map(D=>{const te=k?D:null,ne=P?D:null;return 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",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:s(D.type)}),u.jsxs("div",{children:[u.jsxs("div",{className:"font-semibold text-[13px] text-text-primary",children:[ie(D),(te==null?void 0:te.version)&&u.jsxs("span",{className:"text-[10px] text-text-muted ml-1.5",children:["v",te.version]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:D.workspace||"—"}),(ne==null?void 0:ne.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",ne.currentModel]}),(ne==null?void 0:ne.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",ne.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${D.status==="stopped"?"bg-red-500/[0.08] text-red-500":D.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:D.status}),k&&u.jsxs(u.Fragment,{children:[u.jsxs("button",{onClick:()=>a(`/ide/${D.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(dl,{size:13})," Control"]}),u.jsx("button",{onClick:()=>f(D),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻"})]}),P&&u.jsx("button",{onClick:()=>a(`/ide/${D.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Ga,{size:14})}),D.status==="stopped"?u.jsx("button",{onClick:()=>k?c(D.type,D.workspace?{workspace:D.workspace}:void 0):d(D.type,D.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>L(D),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]}),te&&te.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:te.aiAgents.map(ve=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${ve.status==="generating"||ve.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[ve.name," · ",ve.status]},ve.id))}),te&&(M[te.type]||[]).length>0&&l&&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:(M[te.type]||[]).map(ve=>u.jsxs("button",{disabled:b===`${te.type}.${ve.type}`,onClick:async()=>{const ke=`${te.type}.${ve.type}`;J(ke);try{await l(r,"set_ide_extension",{ideType:te.type,extensionType:ve.type,enabled:!ve.enabled}),z(be=>({...be,[te.type]:(be[te.type]||[]).map(ye=>ye.type===ve.type?{...ye,enabled:!ye.enabled}:ye)}))}catch(be){console.error("Extension toggle failed:",be)}finally{J(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 ${ve.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 ${ve.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),ve.name,u.jsx("span",{className:"text-[9px] font-normal",children:ve.enabled?"ON":"OFF"})]},ve.type))})]})]},D.id)})}),!k&&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:g,disabled:w,className:"machine-btn",children:w?"⏳":"↻ Load"})]}),(()=>{const D=new Set(C.map(ne=>ne.type)),te=_.filter(ne=>D.has(ne.cliType));return te.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:te.map((ne,ve)=>{var ke,be;return u.jsxs("div",{onClick:()=>{R(ne.cliType),N("__custom__"),W(ne.dir),S((ne.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-colors duration-150 hover:bg-bg-glass-hover",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:s(ne.cliType)}),u.jsx("span",{children:((ke=ne.dir)==null?void 0:ke.split("/").filter(Boolean).pop())||"root"}),((be=ne.cliArgs)==null?void 0:be.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:ne.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:ne.timestamp?new Date(ne.timestamp).toLocaleDateString():""})]},ve)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",x.label," launch history yet."]})})()]})]})}function dI({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(k=>k.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),k=!!(g.values[v.key]??v.default);x?(x.onCount+=k?1:0,x.total+=1):m.set(v.key,{label:v.label||v.key,onCount:k?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,k=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:k,className:`machine-btn text-[9px] px-1.5 py-px ${k?"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 fI({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 pI({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/10 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 mI(){var k,P,C,B,R,$,S,j,I,T;const{id:e}=S0(),t=Ui(),{sendCommand:r}=ui(),n=Ic(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=y.useState("overview"),a=y.useRef(null),c=cI({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(N=>N.id===e&&N.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(N=>({type:N.type,displayName:N.displayName,icon:N.icon,category:N.category})),f={};for(const N of h)f[N.type]=N.icon;const p=N=>f[N]||"",m=d?{id:d.id,hostname:((k=d.machine)==null?void 0:k.hostname)||d.id,platform:((P=d.machine)==null?void 0:P.platform)||"unknown",arch:((C=d.machine)==null?void 0:C.arch)||"",cpus:((B=d.machine)==null?void 0:B.cpus)||0,totalMem:((R=d.machine)==null?void 0:R.totalMem)||0,freeMem:(($=d.machine)==null?void 0:$.freeMem)||0,availableMem:(S=d.machine)==null?void 0:S.availableMem,loadavg:((j=d.machine)==null?void 0:j.loadavg)||[],uptime:((I=d.machine)==null?void 0:I.uptime)||0,release:((T=d.machine)==null?void 0:T.release)||"",cdpConnected:!!(d.ides||[]).some(N=>N.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(N=>N.daemonId===e&&!N.daemonMode).filter(N=>!L_(N)&&!I_(N)).map(N=>({id:N.id,type:N.type,version:N.version||"",instanceId:N.instanceId||"",status:N.status,workspace:N.workspace||null,terminals:N.terminals||0,aiAgents:SL(N.aiAgents||N.agents||[]),activeChat:N.activeChat||null,chats:N.chats||[],agentStreams:N.agentStreams||[],cdpConnected:N.cdpConnected||!1,daemonId:e})),w=i.filter(N=>N.daemonId===e&&L_(N)).map(N=>({id:N.id,type:N.type,cliName:N.cliName||N.type,status:N.status,workspace:N.workspace||"",activeChat:N.activeChat||null,daemonId:e})),g=i.filter(N=>N.daemonId===e&&I_(N)).map(N=>({id:N.id,type:N.type,acpName:N.cliName||N.type,status:N.status,workspace:N.workspace||"",activeChat:N.activeChat||null,currentModel:N.currentModel,currentPlan:N.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(WT,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(dl,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zx,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Fx,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Bx,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(jT,{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:N=>c.setNicknameInput(N.target.value),onKeyDown:N=>{N.key==="Enter"&&c.handleSaveNickname(),N.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"]}),(d==null?void 0:d.version)&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-bg-glass border border-border-subtle text-text-muted shrink-0",children:["v",d.version]}),(d==null?void 0:d.versionMismatch)&&u.jsxs("button",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-amber-500/[0.08] border border-amber-500/20 text-amber-400 cursor-pointer hover:bg-amber-500/[0.15] transition-colors shrink-0",onClick:async()=>{try{await r(e,"daemon_upgrade",{})}catch{}},children:["🔄 Update to v",d.serverVersion]}),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(N=>u.jsxs("button",{onClick:()=>l(N.id),className:`machine-tab shrink-0${o===N.id?" active":""}`,children:[N.label,N.count!==void 0&&u.jsx("span",{className:"tab-count",children:N.count})]},N.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(uI,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,actions:c}),o==="ides"&&u.jsx(Hu,{category:"ide",machine:m,machineId:e,providers:h,managedEntries:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(Hu,{category:"cli",machine:m,machineId:e,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(Hu,{category:"acp",machine:m,machineId:e,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(dI,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(fI,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(pI,{machine:m,launchPick:c.launchPick,actions:c})]})}function gI(){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 q_=gI(),Y_=3e3,_I=3e4;let _n=null,vI=0;const ic=new Map,Wd=new Set;let vi=null;async function xa(e,t,r){const n=_n;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++vI}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{ic.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);ic.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 yI{constructor(t){Xt(this,"daemonId");Xt(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(_n==null?void 0:_n.readyState)===WebSocket.OPEN}get connectionState(){return(_n==null?void 0:_n.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return xa(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return xa(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,vi&&(clearInterval(vi),vi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await xa(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());Wd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let yi=null;function xI(e){(!yi||yi.daemonId!==e)&&(yi=new yI(e));const t=yr._originalGet||yr.get.bind(yr);yr._originalGet=t,yr.get=r=>r===e||r.startsWith("standalone")?yi:t(r),yr.getState=r=>(r===e||r.startsWith("standalone"))&&(yi==null?void 0:yi.connectionState)||"disconnected",yr.onScreenshot=(r,n)=>(Wd.add(n),()=>{Wd.delete(n)})}function bI({children:e}){const t=y.useRef(Am()),r=Am();t.current=r;const{setUserName:n}=qo(),i=y.useRef(n);i.current=n;const[,s]=y.useState("disconnected"),o=y.useRef(null),l=y.useRef(),a=y.useRef(Y_),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 ${q_}...`);let f;try{f=new WebSocket(q_)}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=Y_,console.log("[Standalone WS] Connected")},_n=f,f.onmessage=_=>{var w;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=ic.get(g.requestId);v&&(ic.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:k}=t.current,P=v.id||"standalone";xI(P);const C=TL(v,{daemonId:P});C.length>0&&x(C),k(),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,_I),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,_n=null)}},[]),u.jsx(u.Fragment,{children:e})}function wI({children:e}){return u.jsx(Lk,{children:u.jsx(bI,{children:e})})}const SI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(IT,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(DT,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(Bx,{}),label:"Settings"}];function kI({children:e}){const t=Ui(),r=al(),[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:SI.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(AT,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.12"]}),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 CI=[{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."}],EI=[{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."}],NI=[{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}],Uu={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 PI(){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.6.12"]})]}),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:CI.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:Uu.ides},{label:"Extension agents",items:Uu.agents},{label:"CLI agents",items:Uu.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:NI.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:EI.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 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function TI(){const{ides:e}=qo(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ui(),{userName:i}=qo(),[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(M4,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Ji,{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.6.12"]}),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(Ji,{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(Ji,{title:"Machine",className:"mb-4",children:u.jsx(O4,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Ji,{title:"Theme",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),u.jsx(H4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),u.jsx(X4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),u.jsx(tI,{})]})]})}),u.jsx(Ji,{title:"Notifications",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(B4,{}),u.jsx(es,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})}),u.jsx(Ji,{title:"Preferences",className:"mb-4",children:u.jsx("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-default 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 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()}})]})})})]})]})}q4();function X_(){const{ides:e}=qo(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(la,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(la,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(la,{to:"/dashboard",replace:!0})}function MI(){return u.jsx(Mk,{children:u.jsx(wI,{children:u.jsx(Ak,{value:{sendCommand:xa,sendData:()=>!1},children:u.jsx(kI,{children:u.jsxs(Ek,{children:[u.jsx(pn,{path:"/dashboard",element:u.jsx(oI,{})}),u.jsx(pn,{path:"/ide/:id",element:u.jsx(aI,{})}),u.jsx(pn,{path:"/machine",element:u.jsx(X_,{})}),u.jsx(pn,{path:"/machines/:id",element:u.jsx(mI,{})}),u.jsx(pn,{path:"/machines",element:u.jsx(X_,{})}),u.jsx(pn,{path:"/about",element:u.jsx(PI,{})}),u.jsx(pn,{path:"/settings",element:u.jsx(TI,{})}),u.jsx(pn,{path:"*",element:u.jsx(la,{to:"/dashboard",replace:!0})})]})})})})})}f0(document.getElementById("root")).render(u.jsx(y.StrictMode,{children:u.jsx(MI,{})}));
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-CLV2_aO3.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-XJJTap3M.js"></script>
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-COVmVZzP.css">
12
12
  </head>
13
13
  <body>