@adhdev/daemon-standalone 0.5.55 → 0.5.57

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.
@@ -67,7 +67,7 @@ Error generating stack: `+s.message+`
67
67
  */function Fh(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(i=>[r,i]):[[r,n]])},[]))}function Ck(e,t){let r=Fh(e);return t&&t.forEach((n,i)=>{r.has(i)||t.getAll(i).forEach(s=>{r.append(i,s)})}),r}const Ek="6";try{window.__reactRouterVersion=Ek}catch{}const Nk="startTransition",Mm=Sb[Nk];function Tk(e){let{basename:t,children:r,future:n,window:i}=e,s=x.useRef();s.current==null&&(s.current=IS({window:i,v5Compat:!0}));let o=s.current,[l,a]=x.useState({action:o.action,location:o.location}),{v7_startTransition:c}=n||{},d=x.useCallback(h=>{c&&Mm?Mm(()=>a(h)):a(h)},[a,c]);return x.useLayoutEffect(()=>o.listen(d),[o,d]),x.useEffect(()=>wk(n),[n]),x.createElement(Sk,{basename:t,children:r,location:l.location,navigationType:l.action,navigator:o,future:n})}var jm;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(jm||(jm={}));var Im;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Im||(Im={}));function Ey(e){let t=x.useRef(Fh(e)),r=x.useRef(!1),n=ol(),i=x.useMemo(()=>Ck(n.search,r.current?null:t.current),[n.search]),s=Tn(),o=x.useCallback((l,a)=>{const c=Fh(typeof l=="function"?l(i):l);r.current=!0,s("?"+c,a)},[s,i]);return[i,o]}const Ny=x.createContext({ides:[],updateIdeChats:()=>{},screenshotMap:{},setScreenshotMap:()=>{},initialLoaded:!1,toasts:[],setToasts:()=>{},wsStatus:"connected",isConnected:!0,connectionStates:{},connectionTransports:{},showReconnected:!1,userName:void 0,setUserName:()=>{},isP2PActive:!1,p2pStates:{},userRole:void 0}),Ty=x.createContext({injectEntries:()=>{},markLoaded:()=>{},getIdes:()=>[]});function Pk(e,t){var o,l,a,c;const r=Date.now();if(t.length===0)return e.map(d=>({...d,_lastUpdate:r}));const n=new Map;for(const d of t)n.set(d.id,d);for(const d of e){const h=n.get(d.id);if(!h){n.set(d.id,{...d,_lastUpdate:r});continue}const f=d.timestamp||r,p=h._lastUpdate||h.timestamp||0;if(f>=p){const m=(o=d.chats)!=null&&o.length?d.chats:h.chats;n.set(d.id,{...h,...d,chats:m,_lastUpdate:r})}else(l=d.chats)!=null&&l.length&&!((a=h.chats)!=null&&a.length)&&n.set(d.id,{...h,chats:d.chats})}const i=new Set(e.map(d=>d.id)),s=new Set;for(const d of e){const h=d.daemonId||((c=d.id)==null?void 0:c.split(":")[0]);h&&s.add(h)}for(const[d,h]of n){const f=h.daemonId||d.split(":")[0];if(!s.has(f))continue;const p=r-(h._lastUpdate||h.timestamp||0);(d.includes(":cli:")&&!i.has(d)&&p>1e4||d.includes(":acp:")&&!i.has(d)&&p>1e4||d.includes(":ide:")&&!i.has(d)&&p>3e4)&&n.delete(d)}for(const[d,h]of n)r-(h._lastUpdate||h.timestamp||0)>3e5&&h.status!=="online"&&n.delete(d);return Array.from(n.values())}function Lk({children:e,connectionOverrides:t}){const[r,n]=x.useState([]),[i,s]=x.useState({}),[o,l]=x.useState(!1),[a,c]=x.useState([]),[d,h]=x.useState(void 0),f=x.useCallback((_,w)=>{n(g=>g.map(v=>v.id===_?{...v,chats:w}:v))},[]),p={injectEntries:_=>{n(w=>w.length===0?_:Pk(_,w))},markLoaded:()=>l(!0),getIdes:()=>r},m=t;return u.jsx(Ty.Provider,{value:p,children:u.jsx(Ny.Provider,{value:{ides:r,updateIdeChats:f,screenshotMap:i,setScreenshotMap:s,initialLoaded:o,toasts:a,setToasts:c,wsStatus:(m==null?void 0:m.wsStatus)??"connected",isConnected:(m==null?void 0:m.isConnected)??!0,connectionStates:(m==null?void 0:m.connectionStates)??{},connectionTransports:(m==null?void 0:m.connectionTransports)??{},showReconnected:(m==null?void 0:m.showReconnected)??!1,retryConnection:m==null?void 0:m.retryConnection,isP2PActive:(m==null?void 0:m.isP2PActive)??!1,p2pStates:(m==null?void 0:m.p2pStates)??{},userRole:m==null?void 0:m.userRole,userName:d,setUserName:h},children:e})})}function Vo(){return x.useContext(Ny)}function Dm(){return x.useContext(Ty)}function Rk(e){const{baseUrl:t,getToken:r,onUnauthorized:n}=e;async function i(s,o={}){const l={"Content-Type":"application/json",...o.headers||{}},a=r==null?void 0:r();a&&(l.Authorization=`Bearer ${a}`);const c=s.startsWith("http")?s:`${t}${s.startsWith("/")?"":"/"}${s}`,d=await fetch(c,{...o,headers:l});if(d.status===401)throw n==null||n(),new Error("Unauthorized");if(!d.ok){const h=await d.json().catch(()=>({error:d.statusText}));throw new Error(h.error||`API Error: ${d.status}`)}return d.json()}return{getDaemons:()=>i("/api/v1/daemons"),getDaemonStatus:s=>i(`/api/v1/daemons/${s}/status`),sendCommand:(s,o,l={})=>i(`/api/v1/daemons/${s}/command`,{method:"POST",body:JSON.stringify({type:o,payload:l})}),execTerminal:(s,o,l)=>i(`/api/v1/daemons/${s}/terminal`,{method:"POST",body:JSON.stringify({command:o,name:l})}),sendAgentMessage:(s,o,l)=>i(`/api/v1/shortcuts/${s}/chat`,{method:"POST",body:JSON.stringify({agentType:o,message:l})}),getAgentStatus:s=>i(`/api/v1/shortcuts/${s}/status`),approveAgent:(s,o,l)=>i(`/api/v1/shortcuts/${s}/approve`,{method:"POST",body:JSON.stringify({agentType:o,action:l?"approve":"reject"})}),request:i}}const Mk=Rk({baseUrl:"http://localhost:3847"});x.createContext(Mk);const jk={sendCommand:async()=>{throw new Error("TransportContext not initialized")}},Py=x.createContext(jk);function Ik({value:e,children:t}){return u.jsx(Py.Provider,{value:e,children:t})}function hi(){return x.useContext(Py)}function Dk(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const Ak=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ok={};function Am(e,t){return(Ok.jsx?Bk:Ak).test(e)}const zk=/[ \t\n\f\r]/g;function $k(e){return typeof e=="object"?e.type==="text"?Bm(e.value):!1:Bm(e)}function Bm(e){return e.replace(zk,"")===""}class ll{constructor(t,r,n){this.normal=r,this.property=t,n&&(this.space=n)}}ll.prototype.normal={};ll.prototype.property={};ll.prototype.space=void 0;function Ly(e,t){const r={},n={};for(const i of e)Object.assign(r,i.property),Object.assign(n,i.normal);return new ll(r,n,t)}function Wh(e){return e.toLowerCase()}class mr{constructor(t,r){this.attribute=r,this.property=t}}mr.prototype.attribute="";mr.prototype.booleanish=!1;mr.prototype.boolean=!1;mr.prototype.commaOrSpaceSeparated=!1;mr.prototype.commaSeparated=!1;mr.prototype.defined=!1;mr.prototype.mustUseProperty=!1;mr.prototype.number=!1;mr.prototype.overloadedBoolean=!1;mr.prototype.property="";mr.prototype.spaceSeparated=!1;mr.prototype.space=void 0;let Fk=0;const je=Ui(),_t=Ui(),Hh=Ui(),ie=Ui(),Je=Ui(),xs=Ui(),vr=Ui();function Ui(){return 2**++Fk}const Uh=Object.freeze(Object.defineProperty({__proto__:null,boolean:je,booleanish:_t,commaOrSpaceSeparated:vr,commaSeparated:xs,number:ie,overloadedBoolean:Hh,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),cu=Object.keys(Uh);class $f extends mr{constructor(t,r,n,i){let s=-1;if(super(t,r),Om(this,"space",i),typeof n=="number")for(;++s<cu.length;){const o=cu[s];Om(this,cu[s],(n&Uh[o])===Uh[o])}}}$f.prototype.defined=!0;function Om(e,t,r){r&&(e[t]=r)}function js(e){const t={},r={};for(const[n,i]of Object.entries(e.properties)){const s=new $f(n,e.transform(e.attributes||{},n),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),t[n]=s,r[Wh(n)]=n,r[Wh(s.attribute)]=n}return new ll(t,r,e.space)}const Ry=js({properties:{ariaActiveDescendant:null,ariaAtomic:_t,ariaAutoComplete:null,ariaBusy:_t,ariaChecked:_t,ariaColCount:ie,ariaColIndex:ie,ariaColSpan:ie,ariaControls:Je,ariaCurrent:null,ariaDescribedBy:Je,ariaDetails:null,ariaDisabled:_t,ariaDropEffect:Je,ariaErrorMessage:null,ariaExpanded:_t,ariaFlowTo:Je,ariaGrabbed:_t,ariaHasPopup:null,ariaHidden:_t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Je,ariaLevel:ie,ariaLive:null,ariaModal:_t,ariaMultiLine:_t,ariaMultiSelectable:_t,ariaOrientation:null,ariaOwns:Je,ariaPlaceholder:null,ariaPosInSet:ie,ariaPressed:_t,ariaReadOnly:_t,ariaRelevant:null,ariaRequired:_t,ariaRoleDescription:Je,ariaRowCount:ie,ariaRowIndex:ie,ariaRowSpan:ie,ariaSelected:_t,ariaSetSize:ie,ariaSort:null,ariaValueMax:ie,ariaValueMin:ie,ariaValueNow:ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function My(e,t){return t in e?e[t]:t}function jy(e,t){return My(e,t.toLowerCase())}const Wk=js({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xs,acceptCharset:Je,accessKey:Je,action:null,allow:null,allowFullScreen:je,allowPaymentRequest:je,allowUserMedia:je,alt:null,as:null,async:je,autoCapitalize:null,autoComplete:Je,autoFocus:je,autoPlay:je,blocking:Je,capture:null,charSet:null,checked:je,cite:null,className:Je,cols:ie,colSpan:null,content:null,contentEditable:_t,controls:je,controlsList:Je,coords:ie|xs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:je,defer:je,dir:null,dirName:null,disabled:je,download:Hh,draggable:_t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:je,formTarget:null,headers:Je,height:ie,hidden:Hh,high:ie,href:null,hrefLang:null,htmlFor:Je,httpEquiv:Je,id:null,imageSizes:null,imageSrcSet:null,inert:je,inputMode:null,integrity:null,is:null,isMap:je,itemId:null,itemProp:Je,itemRef:Je,itemScope:je,itemType:Je,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:je,low:ie,manifest:null,max:null,maxLength:ie,media:null,method:null,min:null,minLength:ie,multiple:je,muted:je,name:null,nonce:null,noModule:je,noValidate:je,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:je,optimum:ie,pattern:null,ping:Je,placeholder:null,playsInline:je,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:je,referrerPolicy:null,rel:Je,required:je,reversed:je,rows:ie,rowSpan:ie,sandbox:Je,scope:null,scoped:je,seamless:je,selected:je,shadowRootClonable:je,shadowRootDelegatesFocus:je,shadowRootMode:null,shape:null,size:ie,sizes:null,slot:null,span:ie,spellCheck:_t,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ie,step:null,style:null,tabIndex:ie,target:null,title:null,translate:null,type:null,typeMustMatch:je,useMap:null,value:_t,width:ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Je,axis:null,background:null,bgColor:null,border:ie,borderColor:null,bottomMargin:ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:je,declare:je,event:null,face:null,frame:null,frameBorder:null,hSpace:ie,leftMargin:ie,link:null,longDesc:null,lowSrc:null,marginHeight:ie,marginWidth:ie,noResize:je,noHref:je,noShade:je,noWrap:je,object:null,profile:null,prompt:null,rev:null,rightMargin:ie,rules:null,scheme:null,scrolling:_t,standby:null,summary:null,text:null,topMargin:ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:je,disableRemotePlayback:je,prefix:null,property:null,results:ie,security:null,unselectable:null},space:"html",transform:jy}),Hk=js({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:vr,accentHeight:ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ie,amplitude:ie,arabicForm:null,ascent:ie,attributeName:null,attributeType:null,azimuth:ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ie,by:null,calcMode:null,capHeight:ie,className:Je,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ie,diffuseConstant:ie,direction:null,display:null,dur:null,divisor:ie,dominantBaseline:null,download:je,dx:null,dy:null,edgeMode:null,editable:null,elevation:ie,enableBackground:null,end:null,event:null,exponent:ie,externalResourcesRequired:null,fill:null,fillOpacity:ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xs,g2:xs,glyphName:xs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ie,horizOriginX:ie,horizOriginY:ie,id:null,ideographic:ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ie,k:ie,k1:ie,k2:ie,k3:ie,k4:ie,kernelMatrix:vr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ie,overlineThickness:ie,paintOrder:null,panose1:null,path:null,pathLength:ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Je,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ie,pointsAtY:ie,pointsAtZ:ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vr,rev:vr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vr,requiredFeatures:vr,requiredFonts:vr,requiredFormats:vr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ie,specularExponent:ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ie,strikethroughThickness:ie,string:null,stroke:null,strokeDashArray:vr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ie,strokeOpacity:ie,strokeWidth:null,style:null,surfaceScale:ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vr,tabIndex:ie,tableValues:null,target:null,targetX:ie,targetY:ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ie,underlineThickness:ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ie,values:null,vAlphabetic:ie,vMathematical:ie,vectorEffect:null,vHanging:ie,vIdeographic:ie,version:null,vertAdvY:ie,vertOriginX:ie,vertOriginY:ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:My}),Iy=js({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Dy=js({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:jy}),Ay=js({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Uk={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Kk=/[A-Z]/g,zm=/-[a-z]/g,Vk=/^data[-\w.:]+$/i;function qk(e,t){const r=Wh(t);let n=t,i=mr;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Vk.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(zm,Xk);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!zm.test(s)){let o=s.replace(Kk,Yk);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=$f}return new i(n,t)}function Yk(e){return"-"+e.toLowerCase()}function Xk(e){return e.charAt(1).toUpperCase()}const Gk=Ly([Ry,Wk,Iy,Dy,Ay],"html"),Ff=Ly([Ry,Hk,Iy,Dy,Ay],"svg");function Qk(e){return e.join(" ").trim()}var Wf={},$m=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Jk=/\n/g,Zk=/^\s*/,eC=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,tC=/^:\s*/,rC=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,nC=/^[;\s]*/,iC=/^\s+|\s+$/g,sC=`
68
68
  `,Fm="/",Wm="*",ki="",oC="comment",lC="declaration";function aC(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var r=1,n=1;function i(m){var _=m.match(Jk);_&&(r+=_.length);var w=m.lastIndexOf(sC);n=~w?m.length-w:n+m.length}function s(){var m={line:r,column:n};return function(_){return _.position=new o(m),c(),_}}function o(m){this.start=m,this.end={line:r,column:n},this.source=t.source}o.prototype.content=e;function l(m){var _=new Error(t.source+":"+r+":"+n+": "+m);if(_.reason=m,_.filename=t.source,_.line=r,_.column=n,_.source=e,!t.silent)throw _}function a(m){var _=m.exec(e);if(_){var w=_[0];return i(w),e=e.slice(w.length),_}}function c(){a(Zk)}function d(m){var _;for(m=m||[];_=h();)_!==!1&&m.push(_);return m}function h(){var m=s();if(!(Fm!=e.charAt(0)||Wm!=e.charAt(1))){for(var _=2;ki!=e.charAt(_)&&(Wm!=e.charAt(_)||Fm!=e.charAt(_+1));)++_;if(_+=2,ki===e.charAt(_-1))return l("End of comment missing");var w=e.slice(2,_-2);return n+=2,i(w),e=e.slice(_),n+=2,m({type:oC,comment:w})}}function f(){var m=s(),_=a(eC);if(_){if(h(),!a(tC))return l("property missing ':'");var w=a(rC),g=m({type:lC,property:Hm(_[0].replace($m,ki)),value:w?Hm(w[0].replace($m,ki)):ki});return a(nC),g}}function p(){var m=[];d(m);for(var _;_=f();)_!==!1&&(m.push(_),d(m));return m}return c(),p()}function Hm(e){return e?e.replace(iC,ki):ki}var cC=aC,uC=_a&&_a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wf,"__esModule",{value:!0});Wf.default=dC;const hC=uC(cC);function dC(e,t){let r=null;if(!e||typeof e!="string")return r;const n=(0,hC.default)(e),i=typeof t=="function";return n.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:l}=s;i?t(o,l,s):l&&(r=r||{},r[o]=l)}),r}var xc={};Object.defineProperty(xc,"__esModule",{value:!0});xc.camelCase=void 0;var fC=/^--[a-zA-Z0-9_-]+$/,pC=/-([a-z])/g,mC=/^[^-]+$/,gC=/^-(webkit|moz|ms|o|khtml)-/,_C=/^-(ms)-/,vC=function(e){return!e||mC.test(e)||fC.test(e)},xC=function(e,t){return t.toUpperCase()},Um=function(e,t){return"".concat(t,"-")},yC=function(e,t){return t===void 0&&(t={}),vC(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(_C,Um):e=e.replace(gC,Um),e.replace(pC,xC))};xc.camelCase=yC;var bC=_a&&_a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},wC=bC(Wf),SC=xc;function Kh(e,t){var r={};return!e||typeof e!="string"||(0,wC.default)(e,function(n,i){n&&i&&(r[(0,SC.camelCase)(n,t)]=i)}),r}Kh.default=Kh;var kC=Kh;const CC=Wd(kC),By=Oy("end"),Hf=Oy("start");function Oy(e){return t;function t(r){const n=r&&r.position&&r.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function EC(e){const t=Hf(e),r=By(e);if(t&&r)return{start:t,end:r}}function wo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Km(e.position):"start"in e||"end"in e?Km(e):"line"in e||"column"in e?Vh(e):""}function Vh(e){return Vm(e&&e.line)+":"+Vm(e&&e.column)}function Km(e){return Vh(e&&e.start)+"-"+Vh(e&&e.end)}function Vm(e){return e&&typeof e=="number"?e:1}class Gt extends Error{constructor(t,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let i="",s={},o=!1;if(r&&("line"in r&&"column"in r?s={place:r}:"start"in r&&"end"in r?s={place:r}:"type"in r?s={ancestors:[r],place:r.position}:s={...r}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof n=="string"){const a=n.indexOf(":");a===-1?s.ruleId=n:(s.source=n.slice(0,a),s.ruleId=n.slice(a+1))}if(!s.place&&s.ancestors&&s.ancestors){const a=s.ancestors[s.ancestors.length-1];a&&(s.place=a.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=wo(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;const Uf={}.hasOwnProperty,NC=new Map,TC=/[A-Z]/g,PC=new Set(["table","tbody","thead","tfoot","tr"]),LC=new Set(["td","th"]),zy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function RC(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let n;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=zC(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=OC(r,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ff:Gk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=$y(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function $y(e,t,r){if(t.type==="element")return MC(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return jC(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return DC(e,t,r);if(t.type==="mdxjsEsm")return IC(e,t);if(t.type==="root")return AC(e,t,r);if(t.type==="text")return BC(e,t)}function MC(e,t,r){const n=e.schema;let i=n;t.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=Ff,e.schema=i),e.ancestors.push(t);const s=Wy(e,t.tagName,!1),o=$C(e,t);let l=Vf(e,t);return PC.has(t.tagName)&&(l=l.filter(function(a){return typeof a=="string"?!$k(a):!0})),Fy(e,o,s,t),Kf(o,l),e.ancestors.pop(),e.schema=n,e.create(t,s,o,r)}function jC(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}qo(e,t.position)}function IC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);qo(e,t.position)}function DC(e,t,r){const n=e.schema;let i=n;t.name==="svg"&&n.space==="html"&&(i=Ff,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Wy(e,t.name,!0),o=FC(e,t),l=Vf(e,t);return Fy(e,o,s,t),Kf(o,l),e.ancestors.pop(),e.schema=n,e.create(t,s,o,r)}function AC(e,t,r){const n={};return Kf(n,Vf(e,t)),e.create(t,e.Fragment,n,r)}function BC(e,t){return t.value}function Fy(e,t,r,n){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=n)}function Kf(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function OC(e,t,r){return n;function n(i,s,o,l){const c=Array.isArray(o.children)?r:t;return l?c(s,o,l):c(s,o)}}function zC(e,t){return r;function r(n,i,s,o){const l=Array.isArray(s.children),a=Hf(n);return t(i,s,o,l,{columnNumber:a?a.column-1:void 0,fileName:e,lineNumber:a?a.line:void 0},void 0)}}function $C(e,t){const r={};let n,i;for(i in t.properties)if(i!=="children"&&Uf.call(t.properties,i)){const s=WC(e,i,t.properties[i]);if(s){const[o,l]=s;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&LC.has(t.tagName)?n=l:r[o]=l}}if(n){const s=r.style||(r.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function FC(e,t){const r={};for(const n of t.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&e.evaluater){const s=n.data.estree.body[0];s.type;const o=s.expression;o.type;const l=o.properties[0];l.type,Object.assign(r,e.evaluater.evaluateExpression(l.argument))}else qo(e,t.position);else{const i=n.name;let s;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&e.evaluater){const l=n.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else qo(e,t.position);else s=n.value===null?!0:n.value;r[i]=s}return r}function Vf(e,t){const r=[];let n=-1;const i=e.passKeys?new Map:NC;for(;++n<t.children.length;){const s=t.children[n];let o;if(e.passKeys){const a=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(a){const c=i.get(a)||0;o=a+"-"+c,i.set(a,c+1)}}const l=$y(e,s,o);l!==void 0&&r.push(l)}return r}function WC(e,t,r){const n=qk(e.schema,t);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?Dk(r):Qk(r)),n.property==="style"){let i=typeof r=="object"?r:HC(e,String(r));return e.stylePropertyNameCase==="css"&&(i=UC(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&n.space?Uk[n.property]||n.property:n.attribute,r]}}function HC(e,t){try{return CC(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const n=r,i=new Gt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=zy+"#cannot-parse-style-attribute",i}}function Wy(e,t,r){let n;if(!r)n={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const l=Am(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}n=o}else n=Am(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(n.type==="Literal"){const i=n.value;return Uf.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(n);qo(e)}function qo(e,t){const r=new Gt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=zy+"#cannot-handle-mdx-estrees-without-createevaluater",r}function UC(e){const t={};let r;for(r in e)Uf.call(e,r)&&(t[KC(r)]=e[r]);return t}function KC(e){let t=e.replace(TC,VC);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function VC(e){return"-"+e.toLowerCase()}const uu={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},qC={};function qf(e,t){const r=qC,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Hy(e,n,i)}function Hy(e,t,r){if(YC(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return qm(e.children,t,r)}return Array.isArray(e)?qm(e,t,r):""}function qm(e,t,r){const n=[];let i=-1;for(;++i<e.length;)n[i]=Hy(e[i],t,r);return n.join("")}function YC(e){return!!(e&&typeof e=="object")}const Ym=document.createElement("i");function Yf(e){const t="&"+e+";";Ym.innerHTML=t;const r=Ym.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}function Sr(e,t,r,n){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,r=r>0?r:0,n.length<1e4)o=Array.from(n),o.unshift(t,r),e.splice(...o);else for(r&&e.splice(t,r);s<n.length;)o=n.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ir(e,t){return e.length>0?(Sr(e,e.length,0,t),e):t}const Xm={}.hasOwnProperty;function Uy(e){const t={};let r=-1;for(;++r<e.length;)XC(t,e[r]);return t}function XC(e,t){let r;for(r in t){const i=(Xm.call(e,r)?e[r]:void 0)||(e[r]={}),s=t[r];let o;if(s)for(o in s){Xm.call(i,o)||(i[o]=[]);const l=s[o];GC(i[o],Array.isArray(l)?l:l?[l]:[])}}}function GC(e,t){let r=-1;const n=[];for(;++r<t.length;)(t[r].add==="after"?e:n).push(t[r]);Sr(e,0,0,n)}function Ky(e,t){const r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Xr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const er=di(/[A-Za-z]/),Yt=di(/[\dA-Za-z]/),QC=di(/[#-'*+\--9=?A-Z^-~]/);function Wa(e){return e!==null&&(e<32||e===127)}const qh=di(/\d/),JC=di(/[\dA-Fa-f]/),ZC=di(/[!-/:-@[-`{-~]/);function we(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Be(e){return e===-2||e===-1||e===32}const yc=di(new RegExp("\\p{P}|\\p{S}","u")),zi=di(/\s/);function di(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function Is(e){const t=[];let r=-1,n=0,i=0;for(;++r<e.length;){const s=e.charCodeAt(r);let o="";if(s===37&&Yt(e.charCodeAt(r+1))&&Yt(e.charCodeAt(r+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(r+1);s<56320&&l>56319&&l<57344?(o=String.fromCharCode(s,l),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(n,r),encodeURIComponent(o)),n=r+i+1,o=""),i&&(r+=i,i=0)}return t.join("")+e.slice(n)}function He(e,t,r,n){const i=n?n-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(a){return Be(a)?(e.enter(r),l(a)):t(a)}function l(a){return Be(a)&&s++<i?(e.consume(a),l):(e.exit(r),t(a))}}const e2={tokenize:t2};function t2(e){const t=e.attempt(this.parser.constructs.contentInitial,n,i);let r;return t;function n(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),He(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const a=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=a),r=a,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return we(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),o)}}const r2={tokenize:n2},Gm={tokenize:i2};function n2(e){const t=this,r=[];let n=0,i,s,o;return l;function l(y){if(n<r.length){const S=r[n];return t.containerState=S[1],e.attempt(S[0].continuation,a,c)(y)}return c(y)}function a(y){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const S=t.events.length;let L=S,E;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){E=t.events[L][1].end;break}g(n);let P=S;for(;P<t.events.length;)t.events[P][1].end={...E},P++;return Sr(t.events,L+1,0,t.events.slice(S)),t.events.length=P,c(y)}return l(y)}function c(y){if(n===r.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gm,d,h)(y)}function d(y){return i&&v(),g(n),f(y)}function h(y){return t.parser.lazy[t.now().line]=n!==r.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(Gm,p,m)(y)}function p(y){return n++,r.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&v(),g(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),_(y)}function _(y){if(y===null){w(e.exit("chunkFlow"),!0),g(0),e.consume(y);return}return we(y)?(e.consume(y),w(e.exit("chunkFlow")),n=0,t.interrupt=void 0,l):(e.consume(y),_)}function w(y,S){const L=t.sliceStream(y);if(S&&L.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(L),t.parser.lazy[y.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<o&&(!i.events[E][1].end||i.events[E][1].end.offset>o))return;const P=t.events.length;let N=P,A,k;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(A){k=t.events[N][1].end;break}A=!0}for(g(n),E=P;E<t.events.length;)t.events[E][1].end={...k},E++;Sr(t.events,N+1,0,t.events.slice(P)),t.events.length=E}}function g(y){let S=r.length;for(;S-- >y;){const L=r[S];t.containerState=L[1],L[0].exit.call(t,e)}r.length=y}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function i2(e,t,r){return He(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ns(e){if(e===null||Qe(e)||zi(e))return 1;if(yc(e))return 2}function bc(e,t,r){const n=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!n.includes(s)&&(t=s(t,r),n.push(s))}return t}const Yh={name:"attention",resolveAll:s2,tokenize:o2};function s2(e,t){let r=-1,n,i,s,o,l,a,c,d;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(n=r;n--;)if(e[n][0]==="exit"&&e[n][1].type==="attentionSequence"&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[n][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const h={...e[n][1].end},f={...e[r][1].start};Qm(h,-a),Qm(f,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:{...e[n][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:f},s={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[r][1].start}},i={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[n][1].end={...o.start},e[r][1].start={...l.end},c=[],e[n][1].end.offset-e[n][1].start.offset&&(c=Ir(c,[["enter",e[n][1],t],["exit",e[n][1],t]])),c=Ir(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=Ir(c,bc(t.parser.constructs.insideSpan.null,e.slice(n+1,r),t)),c=Ir(c,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[r][1].end.offset-e[r][1].start.offset?(d=2,c=Ir(c,[["enter",e[r][1],t],["exit",e[r][1],t]])):d=0,Sr(e,n-1,r-n+3,c),r=n+c.length-d-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function o2(e,t){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,i=Ns(n);let s;return o;function o(a){return s=a,e.enter("attentionSequence"),l(a)}function l(a){if(a===s)return e.consume(a),l;const c=e.exit("attentionSequence"),d=Ns(a),h=!d||d===2&&i||r.includes(a),f=!i||i===2&&d||r.includes(n);return c._open=!!(s===42?h:h&&(i||!f)),c._close=!!(s===42?f:f&&(d||!h)),t(a)}}function Qm(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const l2={name:"autolink",tokenize:a2};function a2(e,t,r){let n=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return er(p)?(e.consume(p),o):p===64?r(p):c(p)}function o(p){return p===43||p===45||p===46||Yt(p)?(n=1,l(p)):c(p)}function l(p){return p===58?(e.consume(p),n=0,a):(p===43||p===45||p===46||Yt(p))&&n++<32?(e.consume(p),l):(n=0,c(p))}function a(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Wa(p)?r(p):(e.consume(p),a)}function c(p){return p===64?(e.consume(p),d):QC(p)?(e.consume(p),c):r(p)}function d(p){return Yt(p)?h(p):r(p)}function h(p){return p===46?(e.consume(p),n=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||Yt(p))&&n++<63){const m=p===45?f:h;return e.consume(p),m}return r(p)}}const al={partial:!0,tokenize:c2};function c2(e,t,r){return n;function n(s){return Be(s)?He(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||we(s)?t(s):r(s)}}const Vy={continuation:{tokenize:h2},exit:d2,name:"blockQuote",tokenize:u2};function u2(e,t,r){const n=this;return i;function i(o){if(o===62){const l=n.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return r(o)}function s(o){return Be(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function h2(e,t,r){const n=this;return i;function i(o){return Be(o)?He(e,s,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Vy,t,r)(o)}}function d2(e){e.exit("blockQuote")}const qy={name:"characterEscape",tokenize:f2};function f2(e,t,r){return n;function n(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return ZC(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(s)}}const Yy={name:"characterReference",tokenize:p2};function p2(e,t,r){const n=this;let i=0,s,o;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),a}function a(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Yt,d(h))}function c(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=JC,d):(e.enter("characterReferenceValue"),s=7,o=qh,d(h))}function d(h){if(h===59&&i){const f=e.exit("characterReferenceValue");return o===Yt&&!Yf(n.sliceSerialize(f))?r(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(h)&&i++<s?(e.consume(h),d):r(h)}}const Jm={partial:!0,tokenize:g2},Zm={concrete:!0,name:"codeFenced",tokenize:m2};function m2(e,t,r){const n=this,i={partial:!0,tokenize:L};let s=0,o=0,l;return a;function a(E){return c(E)}function c(E){const P=n.events[n.events.length-1];return s=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(E)}function d(E){return E===l?(o++,e.consume(E),d):o<3?r(E):(e.exit("codeFencedFenceSequence"),Be(E)?He(e,h,"whitespace")(E):h(E))}function h(E){return E===null||we(E)?(e.exit("codeFencedFence"),n.interrupt?t(E):e.check(Jm,_,S)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(E))}function f(E){return E===null||we(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(E)):Be(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),He(e,p,"whitespace")(E)):E===96&&E===l?r(E):(e.consume(E),f)}function p(E){return E===null||we(E)?h(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||we(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(E)):E===96&&E===l?r(E):(e.consume(E),m)}function _(E){return e.attempt(i,S,w)(E)}function w(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),g}function g(E){return s>0&&Be(E)?He(e,v,"linePrefix",s+1)(E):v(E)}function v(E){return E===null||we(E)?e.check(Jm,_,S)(E):(e.enter("codeFlowValue"),y(E))}function y(E){return E===null||we(E)?(e.exit("codeFlowValue"),v(E)):(e.consume(E),y)}function S(E){return e.exit("codeFenced"),t(E)}function L(E,P,N){let A=0;return k;function k(B){return E.enter("lineEnding"),E.consume(B),E.exit("lineEnding"),O}function O(B){return E.enter("codeFencedFence"),Be(B)?He(E,I,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):I(B)}function I(B){return B===l?(E.enter("codeFencedFenceSequence"),R(B)):N(B)}function R(B){return B===l?(A++,E.consume(B),R):A>=o?(E.exit("codeFencedFenceSequence"),Be(B)?He(E,C,"whitespace")(B):C(B)):N(B)}function C(B){return B===null||we(B)?(E.exit("codeFencedFence"),P(B)):N(B)}}}function g2(e,t,r){const n=this;return i;function i(o){return o===null?r(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return n.parser.lazy[n.now().line]?r(o):t(o)}}const hu={name:"codeIndented",tokenize:v2},_2={partial:!0,tokenize:x2};function v2(e,t,r){const n=this;return i;function i(c){return e.enter("codeIndented"),He(e,s,"linePrefix",5)(c)}function s(c){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(c):r(c)}function o(c){return c===null?a(c):we(c)?e.attempt(_2,o,a)(c):(e.enter("codeFlowValue"),l(c))}function l(c){return c===null||we(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),l)}function a(c){return e.exit("codeIndented"),t(c)}}function x2(e,t,r){const n=this;return i;function i(o){return n.parser.lazy[n.now().line]?r(o):we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):He(e,s,"linePrefix",5)(o)}function s(o){const l=n.events[n.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):we(o)?i(o):r(o)}}const y2={name:"codeText",previous:w2,resolve:b2,tokenize:S2};function b2(e){let t=e.length-4,r=3,n,i;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=r;++n<t;)if(e[n][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[t][1].type="codeTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)i===void 0?n!==t&&e[n][1].type!=="lineEnding"&&(i=n):(n===t||e[n][1].type==="lineEnding")&&(e[i][1].type="codeTextData",n!==i+2&&(e[i][1].end=e[n-1][1].end,e.splice(i+2,n-i-2),t-=n-i-2,n=i+2),i=void 0);return e}function w2(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function S2(e,t,r){let n=0,i,s;return o;function o(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),n++,l):(e.exit("codeTextSequence"),a(h))}function a(h){return h===null?r(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),a):h===96?(s=e.enter("codeTextSequence"),i=0,d(h)):we(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),a):(e.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||we(h)?(e.exit("codeTextData"),a(h)):(e.consume(h),c)}function d(h){return h===96?(e.consume(h),i++,d):i===n?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(s.type="codeTextData",c(h))}}class k2{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,r){const n=r??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(t,n):t>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(t,r,n){const i=r||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&qs(this.left,n),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),qs(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),qs(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const r=this.left.splice(t,Number.POSITIVE_INFINITY);qs(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);qs(this.left,r.reverse())}}}function qs(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function Xy(e){const t={};let r=-1,n,i,s,o,l,a,c;const d=new k2(e);for(;++r<d.length;){for(;r in t;)r=t[r];if(n=d.get(r),r&&n[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(a=n[1]._tokenizer.events,s=0,s<a.length&&a[s][1].type==="lineEndingBlank"&&(s+=2),s<a.length&&a[s][1].type==="content"))for(;++s<a.length&&a[s][1].type!=="content";)a[s][1].type==="chunkText"&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if(n[0]==="enter")n[1].contentType&&(Object.assign(t,C2(d,r)),r=t[r],c=!0);else if(n[1]._container){for(s=r,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(n[1].end={...d.get(i)[1].start},l=d.slice(i,r),l.unshift(n),d.splice(i,r-i+1,l))}}return Sr(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function C2(e,t){const r=e.get(t)[1],n=e.get(t)[2];let i=t-1;const s=[];let o=r._tokenizer;o||(o=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,a=[],c={};let d,h,f=-1,p=r,m=0,_=0;const w=[_];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=n.sliceStream(p),p.next||d.push(null),h&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=r;++f<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(_=f+1,w.push(_),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const g=l.slice(w[f],w[f+1]),v=s.pop();a.push([v,v+g.length-1]),e.splice(v,2,g)}for(a.reverse(),f=-1;++f<a.length;)c[m+a[f][0]]=m+a[f][1],m+=a[f][1]-a[f][0]-1;return c}const E2={resolve:T2,tokenize:P2},N2={partial:!0,tokenize:L2};function T2(e){return Xy(e),e}function P2(e,t){let r;return n;function n(l){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):we(l)?e.check(N2,o,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function L2(e,t,r){const n=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),He(e,s,"linePrefix")}function s(o){if(o===null||we(o))return r(o);const l=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(n.parser.constructs.flow,r,t)(o)}}function Gy(e,t,r,n,i,s,o,l,a){const c=a||Number.POSITIVE_INFINITY;let d=0;return h;function h(g){return g===60?(e.enter(n),e.enter(i),e.enter(s),e.consume(g),e.exit(s),f):g===null||g===32||g===41||Wa(g)?r(g):(e.enter(n),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),_(g))}function f(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(n),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===62?(e.exit("chunkString"),e.exit(l),f(g)):g===null||g===60||we(g)?r(g):(e.consume(g),g===92?m:p)}function m(g){return g===60||g===62||g===92?(e.consume(g),p):p(g)}function _(g){return!d&&(g===null||g===41||Qe(g))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(n),t(g)):d<c&&g===40?(e.consume(g),d++,_):g===41?(e.consume(g),d--,_):g===null||g===32||g===40||Wa(g)?r(g):(e.consume(g),g===92?w:_)}function w(g){return g===40||g===41||g===92?(e.consume(g),_):_(g)}}function Qy(e,t,r,n,i,s){const o=this;let l=0,a;return c;function c(p){return e.enter(n),e.enter(i),e.consume(p),e.exit(i),e.enter(s),d}function d(p){return l>999||p===null||p===91||p===93&&!a||p===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?r(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(n),t):we(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||we(p)||l++>999?(e.exit("chunkString"),d(p)):(e.consume(p),a||(a=!Be(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),l++,h):h(p)}}function Jy(e,t,r,n,i,s){let o;return l;function l(f){return f===34||f===39||f===40?(e.enter(n),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,a):r(f)}function a(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(n),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),a(o)):f===null?r(f):we(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),He(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===o||f===null||we(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?h:d)}function h(f){return f===o||f===92?(e.consume(f),d):d(f)}}function So(e,t){let r;return n;function n(i){return we(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),r=!0,n):Be(i)?He(e,n,r?"linePrefix":"lineSuffix")(i):t(i)}}const R2={name:"definition",tokenize:j2},M2={partial:!0,tokenize:I2};function j2(e,t,r){const n=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return Qy.call(n,e,l,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return i=Xr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),a):r(p)}function a(p){return Qe(p)?So(e,c)(p):c(p)}function c(p){return Gy(e,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(M2,h,h)(p)}function h(p){return Be(p)?He(e,f,"whitespace")(p):f(p)}function f(p){return p===null||we(p)?(e.exit("definition"),n.parser.defined.push(i),t(p)):r(p)}}function I2(e,t,r){return n;function n(l){return Qe(l)?So(e,i)(l):r(l)}function i(l){return Jy(e,s,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return Be(l)?He(e,o,"whitespace")(l):o(l)}function o(l){return l===null||we(l)?t(l):r(l)}}const D2={name:"hardBreakEscape",tokenize:A2};function A2(e,t,r){return n;function n(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return we(s)?(e.exit("hardBreakEscape"),t(s)):r(s)}}const B2={name:"headingAtx",resolve:O2,tokenize:z2};function O2(e,t){let r=e.length-2,n=3,i,s;return e[n][1].type==="whitespace"&&(n+=2),r-2>n&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&e[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(i={type:"atxHeadingText",start:e[n][1].start,end:e[r][1].end},s={type:"chunkText",start:e[n][1].start,end:e[r][1].end,contentType:"text"},Sr(e,n,r-n+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function z2(e,t,r){let n=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&n++<6?(e.consume(d),o):d===null||Qe(d)?(e.exit("atxHeadingSequence"),l(d)):r(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),a(d)):d===null||we(d)?(e.exit("atxHeading"),t(d)):Be(d)?He(e,l,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function a(d){return d===35?(e.consume(d),a):(e.exit("atxHeadingSequence"),l(d))}function c(d){return d===null||d===35||Qe(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),c)}}const $2=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],eg=["pre","script","style","textarea"],F2={concrete:!0,name:"htmlFlow",resolveTo:U2,tokenize:K2},W2={partial:!0,tokenize:q2},H2={partial:!0,tokenize:V2};function U2(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function K2(e,t,r){const n=this;let i,s,o,l,a;return c;function c(T){return d(T)}function d(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),h}function h(T){return T===33?(e.consume(T),f):T===47?(e.consume(T),s=!0,_):T===63?(e.consume(T),i=3,n.interrupt?t:b):er(T)?(e.consume(T),o=String.fromCharCode(T),w):r(T)}function f(T){return T===45?(e.consume(T),i=2,p):T===91?(e.consume(T),i=5,l=0,m):er(T)?(e.consume(T),i=4,n.interrupt?t:b):r(T)}function p(T){return T===45?(e.consume(T),n.interrupt?t:b):r(T)}function m(T){const Y="CDATA[";return T===Y.charCodeAt(l++)?(e.consume(T),l===Y.length?n.interrupt?t:I:m):r(T)}function _(T){return er(T)?(e.consume(T),o=String.fromCharCode(T),w):r(T)}function w(T){if(T===null||T===47||T===62||Qe(T)){const Y=T===47,D=o.toLowerCase();return!Y&&!s&&eg.includes(D)?(i=1,n.interrupt?t(T):I(T)):$2.includes(o.toLowerCase())?(i=6,Y?(e.consume(T),g):n.interrupt?t(T):I(T)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(T):s?v(T):y(T))}return T===45||Yt(T)?(e.consume(T),o+=String.fromCharCode(T),w):r(T)}function g(T){return T===62?(e.consume(T),n.interrupt?t:I):r(T)}function v(T){return Be(T)?(e.consume(T),v):k(T)}function y(T){return T===47?(e.consume(T),k):T===58||T===95||er(T)?(e.consume(T),S):Be(T)?(e.consume(T),y):k(T)}function S(T){return T===45||T===46||T===58||T===95||Yt(T)?(e.consume(T),S):L(T)}function L(T){return T===61?(e.consume(T),E):Be(T)?(e.consume(T),L):y(T)}function E(T){return T===null||T===60||T===61||T===62||T===96?r(T):T===34||T===39?(e.consume(T),a=T,P):Be(T)?(e.consume(T),E):N(T)}function P(T){return T===a?(e.consume(T),a=null,A):T===null||we(T)?r(T):(e.consume(T),P)}function N(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||Qe(T)?L(T):(e.consume(T),N)}function A(T){return T===47||T===62||Be(T)?y(T):r(T)}function k(T){return T===62?(e.consume(T),O):r(T)}function O(T){return T===null||we(T)?I(T):Be(T)?(e.consume(T),O):r(T)}function I(T){return T===45&&i===2?(e.consume(T),z):T===60&&i===1?(e.consume(T),U):T===62&&i===4?(e.consume(T),Z):T===63&&i===3?(e.consume(T),b):T===93&&i===5?(e.consume(T),$):we(T)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(W2,ne,R)(T)):T===null||we(T)?(e.exit("htmlFlowData"),R(T)):(e.consume(T),I)}function R(T){return e.check(H2,C,ne)(T)}function C(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),B}function B(T){return T===null||we(T)?R(T):(e.enter("htmlFlowData"),I(T))}function z(T){return T===45?(e.consume(T),b):I(T)}function U(T){return T===47?(e.consume(T),o="",M):I(T)}function M(T){if(T===62){const Y=o.toLowerCase();return eg.includes(Y)?(e.consume(T),Z):I(T)}return er(T)&&o.length<8?(e.consume(T),o+=String.fromCharCode(T),M):I(T)}function $(T){return T===93?(e.consume(T),b):I(T)}function b(T){return T===62?(e.consume(T),Z):T===45&&i===2?(e.consume(T),b):I(T)}function Z(T){return T===null||we(T)?(e.exit("htmlFlowData"),ne(T)):(e.consume(T),Z)}function ne(T){return e.exit("htmlFlow"),t(T)}}function V2(e,t,r){const n=this;return i;function i(o){return we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):r(o)}function s(o){return n.parser.lazy[n.now().line]?r(o):t(o)}}function q2(e,t,r){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(al,t,r)}}const Y2={name:"htmlText",tokenize:X2};function X2(e,t,r){const n=this;let i,s,o;return l;function l(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),a}function a(b){return b===33?(e.consume(b),c):b===47?(e.consume(b),L):b===63?(e.consume(b),y):er(b)?(e.consume(b),N):r(b)}function c(b){return b===45?(e.consume(b),d):b===91?(e.consume(b),s=0,m):er(b)?(e.consume(b),v):r(b)}function d(b){return b===45?(e.consume(b),p):r(b)}function h(b){return b===null?r(b):b===45?(e.consume(b),f):we(b)?(o=h,U(b)):(e.consume(b),h)}function f(b){return b===45?(e.consume(b),p):h(b)}function p(b){return b===62?z(b):b===45?f(b):h(b)}function m(b){const Z="CDATA[";return b===Z.charCodeAt(s++)?(e.consume(b),s===Z.length?_:m):r(b)}function _(b){return b===null?r(b):b===93?(e.consume(b),w):we(b)?(o=_,U(b)):(e.consume(b),_)}function w(b){return b===93?(e.consume(b),g):_(b)}function g(b){return b===62?z(b):b===93?(e.consume(b),g):_(b)}function v(b){return b===null||b===62?z(b):we(b)?(o=v,U(b)):(e.consume(b),v)}function y(b){return b===null?r(b):b===63?(e.consume(b),S):we(b)?(o=y,U(b)):(e.consume(b),y)}function S(b){return b===62?z(b):y(b)}function L(b){return er(b)?(e.consume(b),E):r(b)}function E(b){return b===45||Yt(b)?(e.consume(b),E):P(b)}function P(b){return we(b)?(o=P,U(b)):Be(b)?(e.consume(b),P):z(b)}function N(b){return b===45||Yt(b)?(e.consume(b),N):b===47||b===62||Qe(b)?A(b):r(b)}function A(b){return b===47?(e.consume(b),z):b===58||b===95||er(b)?(e.consume(b),k):we(b)?(o=A,U(b)):Be(b)?(e.consume(b),A):z(b)}function k(b){return b===45||b===46||b===58||b===95||Yt(b)?(e.consume(b),k):O(b)}function O(b){return b===61?(e.consume(b),I):we(b)?(o=O,U(b)):Be(b)?(e.consume(b),O):A(b)}function I(b){return b===null||b===60||b===61||b===62||b===96?r(b):b===34||b===39?(e.consume(b),i=b,R):we(b)?(o=I,U(b)):Be(b)?(e.consume(b),I):(e.consume(b),C)}function R(b){return b===i?(e.consume(b),i=void 0,B):b===null?r(b):we(b)?(o=R,U(b)):(e.consume(b),R)}function C(b){return b===null||b===34||b===39||b===60||b===61||b===96?r(b):b===47||b===62||Qe(b)?A(b):(e.consume(b),C)}function B(b){return b===47||b===62||Qe(b)?A(b):r(b)}function z(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):r(b)}function U(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),M}function M(b){return Be(b)?He(e,$,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):$(b)}function $(b){return e.enter("htmlTextData"),o(b)}}const Xf={name:"labelEnd",resolveAll:Z2,resolveTo:eE,tokenize:tE},G2={tokenize:rE},Q2={tokenize:nE},J2={tokenize:iE};function Z2(e){let t=-1;const r=[];for(;++t<e.length;){const n=e[t][1];if(r.push(e[t]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",t+=i}}return e.length!==r.length&&Sr(e,0,e.length,r),e}function eE(e,t){let r=e.length,n=0,i,s,o,l;for(;r--;)if(i=e[r][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=r,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(o=r);const a={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+n+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",a,t],["enter",c,t]],l=Ir(l,e.slice(s+1,s+n+3)),l=Ir(l,[["enter",d,t]]),l=Ir(l,bc(t.parser.constructs.insideSpan.null,e.slice(s+n+4,o-3),t)),l=Ir(l,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),l=Ir(l,e.slice(o+1)),l=Ir(l,[["exit",a,t]]),Sr(e,s,e.length,l),e}function tE(e,t,r){const n=this;let i=n.events.length,s,o;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){s=n.events[i][1];break}return l;function l(f){return s?s._inactive?h(f):(o=n.parser.defined.includes(Xr(n.sliceSerialize({start:s.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),a):r(f)}function a(f){return f===40?e.attempt(G2,d,o?d:h)(f):f===91?e.attempt(Q2,d,o?c:h)(f):o?d(f):h(f)}function c(f){return e.attempt(J2,d,h)(f)}function d(f){return t(f)}function h(f){return s._balanced=!0,r(f)}}function rE(e,t,r){return n;function n(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return Qe(h)?So(e,s)(h):s(h)}function s(h){return h===41?d(h):Gy(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return Qe(h)?So(e,a)(h):d(h)}function l(h){return r(h)}function a(h){return h===34||h===39||h===40?Jy(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function c(h){return Qe(h)?So(e,d)(h):d(h)}function d(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):r(h)}}function nE(e,t,r){const n=this;return i;function i(l){return Qy.call(n,e,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return n.parser.defined.includes(Xr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?t(l):r(l)}function o(l){return r(l)}}function iE(e,t,r){return n;function n(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):r(s)}}const sE={name:"labelStartImage",resolveAll:Xf.resolveAll,tokenize:oE};function oE(e,t,r){const n=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):r(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(l):t(l)}}const lE={name:"labelStartLink",resolveAll:Xf.resolveAll,tokenize:aE};function aE(e,t,r){const n=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):t(o)}}const du={name:"lineEnding",tokenize:cE};function cE(e,t){return r;function r(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),He(e,t,"linePrefix")}}const sa={name:"thematicBreak",tokenize:uE};function uE(e,t,r){let n=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,l(c)}function l(c){return c===i?(e.enter("thematicBreakSequence"),a(c)):n>=3&&(c===null||we(c))?(e.exit("thematicBreak"),t(c)):r(c)}function a(c){return c===i?(e.consume(c),n++,a):(e.exit("thematicBreakSequence"),Be(c)?He(e,l,"whitespace")(c):l(c))}}const cr={continuation:{tokenize:pE},exit:gE,name:"list",tokenize:fE},hE={partial:!0,tokenize:_E},dE={partial:!0,tokenize:mE};function fE(e,t,r){const n=this,i=n.events[n.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(p){const m=n.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!n.containerState.marker||p===n.containerState.marker:qh(p)){if(n.containerState.type||(n.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(sa,r,c)(p):c(p);if(!n.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(p)}return r(p)}function a(p){return qh(p)&&++o<10?(e.consume(p),a):(!n.interrupt||o<2)&&(n.containerState.marker?p===n.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):r(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||p,e.check(al,n.interrupt?r:d,e.attempt(hE,f,h))}function d(p){return n.containerState.initialBlankLine=!0,s++,f(p)}function h(p){return Be(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):r(p)}function f(p){return n.containerState.size=s+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function pE(e,t,r){const n=this;return n.containerState._closeFlow=void 0,e.check(al,i,s);function i(l){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,He(e,t,"listItemIndent",n.containerState.size+1)(l)}function s(l){return n.containerState.furtherBlankLines||!Be(l)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,o(l)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(dE,t,o)(l))}function o(l){return n.containerState._closeFlow=!0,n.interrupt=void 0,He(e,e.attempt(cr,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function mE(e,t,r){const n=this;return He(e,i,"listItemIndent",n.containerState.size+1);function i(s){const o=n.events[n.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===n.containerState.size?t(s):r(s)}}function gE(e){e.exit(this.containerState.type)}function _E(e,t,r){const n=this;return He(e,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=n.events[n.events.length-1];return!Be(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):r(s)}}const tg={name:"setextUnderline",resolveTo:vE,tokenize:xE};function vE(e,t){let r=e.length,n,i,s;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){n=r;break}e[r][1].type==="paragraph"&&(i=r)}else e[r][1].type==="content"&&e.splice(r,1),!s&&e[r][1].type==="definition"&&(s=r);const o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[n][1],t]),e[n][1].end={...e[s][1].end}):e[n][1]=o,e.push(["exit",o,t]),e}function xE(e,t,r){const n=this;let i;return s;function s(c){let d=n.events.length,h;for(;d--;)if(n.events[d][1].type!=="lineEnding"&&n.events[d][1].type!=="linePrefix"&&n.events[d][1].type!=="content"){h=n.events[d][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||h)?(e.enter("setextHeadingLine"),i=c,o(c)):r(c)}function o(c){return e.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(e.consume(c),l):(e.exit("setextHeadingLineSequence"),Be(c)?He(e,a,"lineSuffix")(c):a(c))}function a(c){return c===null||we(c)?(e.exit("setextHeadingLine"),t(c)):r(c)}}const yE={tokenize:bE};function bE(e){const t=this,r=e.attempt(al,n,e.attempt(this.parser.constructs.flowInitial,i,He(e,e.attempt(this.parser.constructs.flow,i,e.attempt(E2,i)),"linePrefix")));return r;function n(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const wE={resolveAll:e0()},SE=Zy("string"),kE=Zy("text");function Zy(e){return{resolveAll:e0(e==="text"?CE:void 0),tokenize:t};function t(r){const n=this,i=this.parser.constructs[e],s=r.attempt(i,o,l);return o;function o(d){return c(d)?s(d):l(d)}function l(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),a}function a(d){return c(d)?(r.exit("data"),s(d)):(r.consume(d),a)}function c(d){if(d===null)return!0;const h=i[d];let f=-1;if(h)for(;++f<h.length;){const p=h[f];if(!p.previous||p.previous.call(n,n.previous))return!0}return!1}}}function e0(e){return t;function t(r,n){let i=-1,s;for(;++i<=r.length;)s===void 0?r[i]&&r[i][1].type==="data"&&(s=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==s+2&&(r[s][1].end=r[i-1][1].end,r.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(r,n):r}}function CE(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const n=e[r-1][1],i=t.sliceStream(n);let s=i.length,o=-1,l=0,a;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(c===-2)a=!0,l++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(l=0),l){const c={type:r===e.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:n.start._bufferIndex+o,_index:n.start._index+s,line:n.end.line,column:n.end.column-l,offset:n.end.offset-l},end:{...n.end}};n.end={...c.start},n.start.offset===n.end.offset?Object.assign(n,c):(e.splice(r,0,["enter",c,t],["exit",c,t]),r+=2)}r++}return e}const EE={42:cr,43:cr,45:cr,48:cr,49:cr,50:cr,51:cr,52:cr,53:cr,54:cr,55:cr,56:cr,57:cr,62:Vy},NE={91:R2},TE={[-2]:hu,[-1]:hu,32:hu},PE={35:B2,42:sa,45:[tg,sa],60:F2,61:tg,95:sa,96:Zm,126:Zm},LE={38:Yy,92:qy},RE={[-5]:du,[-4]:du,[-3]:du,33:sE,38:Yy,42:Yh,60:[l2,Y2],91:lE,92:[D2,qy],93:Xf,95:Yh,96:y2},ME={null:[Yh,wE]},jE={null:[42,95]},IE={null:[]},DE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jE,contentInitial:NE,disable:IE,document:EE,flow:PE,flowInitial:TE,insideSpan:ME,string:LE,text:RE},Symbol.toStringTag,{value:"Module"}));function AE(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const i={},s=[];let o=[],l=[];const a={attempt:P(L),check:P(E),consume:v,enter:y,exit:S,interrupt:P(E,{interrupt:!0})},c={code:null,containerState:{},defineSkip:_,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:h};let d=t.tokenize.call(c,a);return t.resolveAll&&s.push(t),c;function h(O){return o=Ir(o,O),w(),o[o.length-1]!==null?[]:(N(t,0),c.events=bc(s,c.events,c),c.events)}function f(O,I){return OE(p(O),I)}function p(O){return BE(o,O)}function m(){const{_bufferIndex:O,_index:I,line:R,column:C,offset:B}=n;return{_bufferIndex:O,_index:I,line:R,column:C,offset:B}}function _(O){i[O.line]=O.column,k()}function w(){let O;for(;n._index<o.length;){const I=o[n._index];if(typeof I=="string")for(O=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===O&&n._bufferIndex<I.length;)g(I.charCodeAt(n._bufferIndex));else g(I)}}function g(O){d=d(O)}function v(O){we(O)?(n.line++,n.column=1,n.offset+=O===-3?2:1,k()):O!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),c.previous=O}function y(O,I){const R=I||{};return R.type=O,R.start=m(),c.events.push(["enter",R,c]),l.push(R),R}function S(O){const I=l.pop();return I.end=m(),c.events.push(["exit",I,c]),I}function L(O,I){N(O,I.from)}function E(O,I){I.restore()}function P(O,I){return R;function R(C,B,z){let U,M,$,b;return Array.isArray(C)?ne(C):"tokenize"in C?ne([C]):Z(C);function Z(W){return X;function X(he){const me=he!==null&&W[he],Ce=he!==null&&W.null,Se=[...Array.isArray(me)?me:me?[me]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return ne(Se)(he)}}function ne(W){return U=W,M=0,W.length===0?z:T(W[M])}function T(W){return X;function X(he){return b=A(),$=W,W.partial||(c.currentConstruct=W),W.name&&c.parser.constructs.disable.null.includes(W.name)?D():W.tokenize.call(I?Object.assign(Object.create(c),I):c,a,Y,D)(he)}}function Y(W){return O($,b),B}function D(W){return b.restore(),++M<U.length?T(U[M]):z}}}function N(O,I){O.resolveAll&&!s.includes(O)&&s.push(O),O.resolve&&Sr(c.events,I,c.events.length-I,O.resolve(c.events.slice(I),c)),O.resolveTo&&(c.events=O.resolveTo(c.events,c))}function A(){const O=m(),I=c.previous,R=c.currentConstruct,C=c.events.length,B=Array.from(l);return{from:C,restore:z};function z(){n=O,c.previous=I,c.currentConstruct=R,c.events.length=C,l=B,k()}}function k(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function BE(e,t){const r=t.start._index,n=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(r===i)o=[e[r].slice(n,s)];else{if(o=e.slice(r,i),n>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(n):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function OE(e,t){let r=-1;const n=[];let i;for(;++r<e.length;){const s=e[r];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
69
69
  `;break}case-3:{o=`\r
70
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,n.push(o)}return n.join("")}function zE(e){const n={constructs:Uy([DE,...(e||{}).extensions||[]]),content:i(e2),defined:[],document:i(r2),flow:i(yE),lazy:{},string:i(SE),text:i(kE)};return n;function i(s){return o;function o(l){return AE(n,s,l)}}}function $E(e){for(;!Xy(e););return e}const rg=/[\0\t\n\r]/g;function FE(){let e=1,t="",r=!0,n;return i;function i(s,o,l){const a=[];let c,d,h,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,t="",r&&(s.charCodeAt(0)===65279&&h++,r=void 0);h<s.length;){if(rg.lastIndex=h,c=rg.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(h);break}if(p===10&&h===f&&n)a.push(-3),n=void 0;else switch(n&&(a.push(-5),n=void 0),h<f&&(a.push(s.slice(h,f)),e+=f-h),p){case 0:{a.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,a.push(-2);e++<d;)a.push(-1);break}case 10:{a.push(-4),e=1;break}default:n=!0,e=1}h=f+1}return l&&(n&&a.push(-5),t&&a.push(t),a.push(null)),a}}const WE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HE(e){return e.replace(WE,UE)}function UE(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return Ky(r.slice(s?2:1),s?16:10)}return Yf(r)||e}const t0={}.hasOwnProperty;function KE(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),VE(r)($E(zE(r).document().write(FE()(e,t,!0))))}function VE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ye),autolinkProtocol:A,autolinkEmail:A,atxHeading:s(G),blockQuote:s(Ce),characterEscape:A,characterReference:A,codeFenced:s(Se),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Se,o),codeText:s(Fe,o),codeTextData:A,data:A,codeFlowValue:A,definition:s(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(xe),hardBreakEscape:s(_e),hardBreakTrailing:s(_e),htmlFlow:s(Pe,o),htmlFlowData:A,htmlText:s(Pe,o),htmlTextData:A,image:s(Ee),label:o,link:s(ye),listItem:s(At),listItemValue:f,listOrdered:s(wt,h),listUnordered:s(wt),paragraph:s(et),reference:T,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(G),strong:s(or),thematicBreak:s(Bt)},exit:{atxHeading:a(),atxHeadingSequence:L,autolink:a(),autolinkEmail:me,autolinkProtocol:he,blockQuote:a(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:D,characterReferenceMarkerNumeric:D,characterReferenceValue:W,characterReference:X,codeFenced:a(w),codeFencedFence:_,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:k,codeIndented:a(g),codeText:a(B),codeTextData:k,data:k,definition:a(),definitionDestinationString:S,definitionLabelString:v,definitionTitleString:y,emphasis:a(),hardBreakEscape:a(I),hardBreakTrailing:a(I),htmlFlow:a(R),htmlFlowData:k,htmlText:a(C),htmlTextData:k,image:a(U),label:$,labelText:M,lineEnding:O,link:a(z),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Y,resourceDestinationString:b,resourceTitleString:Z,resource:ne,setextHeading:a(N),setextHeadingLineSequence:P,setextHeadingText:E,strong:a(),thematicBreak:a()}};r0(t,(e||{}).mdastExtensions||[]);const r={};return n;function n(q){let oe={type:"root",children:[]};const H={stack:[oe],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:r},te=[];let ce=-1;for(;++ce<q.length;)if(q[ce][1].type==="listOrdered"||q[ce][1].type==="listUnordered")if(q[ce][0]==="enter")te.push(ce);else{const Le=te.pop();ce=i(q,Le,ce)}for(ce=-1;++ce<q.length;){const Le=t[q[ce][0]];t0.call(Le,q[ce][1].type)&&Le[q[ce][1].type].call(Object.assign({sliceSerialize:q[ce][2].sliceSerialize},H),q[ce][1])}if(H.tokenStack.length>0){const Le=H.tokenStack[H.tokenStack.length-1];(Le[1]||ng).call(H,void 0,Le[0])}for(oe.position={start:jn(q.length>0?q[0][1].start:{line:1,column:1,offset:0}),end:jn(q.length>0?q[q.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce<t.transforms.length;)oe=t.transforms[ce](oe)||oe;return oe}function i(q,oe,H){let te=oe-1,ce=-1,Le=!1,Re,Ne,V,se;for(;++te<=H;){const ee=q[te];switch(ee[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ee[0]==="enter"?ce++:ce--,se=void 0;break}case"lineEndingBlank":{ee[0]==="enter"&&(Re&&!se&&!ce&&!V&&(V=te),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!ce&&ee[0]==="enter"&&ee[1].type==="listItemPrefix"||ce===-1&&ee[0]==="exit"&&(ee[1].type==="listUnordered"||ee[1].type==="listOrdered")){if(Re){let be=te;for(Ne=void 0;be--;){const Me=q[be];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;Ne&&(q[Ne][1].type="lineEndingBlank",Le=!0),Me[1].type="lineEnding",Ne=be}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}V&&(!Ne||V<Ne)&&(Re._spread=!0),Re.end=Object.assign({},Ne?q[Ne][1].start:ee[1].end),q.splice(Ne||te,0,["exit",Re,ee[2]]),te++,H++}if(ee[1].type==="listItemPrefix"){const be={type:"listItem",_spread:!1,start:Object.assign({},ee[1].start),end:void 0};Re=be,q.splice(te,0,["enter",be,ee[2]]),te++,H++,V=void 0,se=!0}}}return q[oe][1]._spread=Le,H}function s(q,oe){return H;function H(te){l.call(this,q(te),te),oe&&oe.call(this,te)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(q,oe,H){this.stack[this.stack.length-1].children.push(q),this.stack.push(q),this.tokenStack.push([oe,H||void 0]),q.position={start:jn(oe.start),end:void 0}}function a(q){return oe;function oe(H){q&&q.call(this,H),c.call(this,H)}}function c(q,oe){const H=this.stack.pop(),te=this.tokenStack.pop();if(te)te[0].type!==q.type&&(oe?oe.call(this,q,te[0]):(te[1]||ng).call(this,q,te[0]));else throw new Error("Cannot close `"+q.type+"` ("+wo({start:q.start,end:q.end})+"): it’s not open");H.position.end=jn(q.end)}function d(){return qf(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(q){if(this.data.expectingFirstListItemValue){const oe=this.stack[this.stack.length-2];oe.start=Number.parseInt(this.sliceSerialize(q),10),this.data.expectingFirstListItemValue=void 0}}function p(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.lang=q}function m(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.meta=q}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q.replace(/(\r?\n|\r)$/g,"")}function v(q){const oe=this.resume(),H=this.stack[this.stack.length-1];H.label=oe,H.identifier=Xr(this.sliceSerialize(q)).toLowerCase()}function y(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.title=q}function S(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.url=q}function L(q){const oe=this.stack[this.stack.length-1];if(!oe.depth){const H=this.sliceSerialize(q).length;oe.depth=H}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function P(q){const oe=this.stack[this.stack.length-1];oe.depth=this.sliceSerialize(q).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function A(q){const H=this.stack[this.stack.length-1].children;let te=H[H.length-1];(!te||te.type!=="text")&&(te=Nr(),te.position={start:jn(q.start),end:void 0},H.push(te)),this.stack.push(te)}function k(q){const oe=this.stack.pop();oe.value+=this.sliceSerialize(q),oe.position.end=jn(q.end)}function O(q){const oe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const H=oe.children[oe.children.length-1];H.position.end=jn(q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(oe.type)&&(A.call(this,q),k.call(this,q))}function I(){this.data.atHardBreak=!0}function R(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function C(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function B(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function z(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=oe,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function U(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=oe,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function M(q){const oe=this.sliceSerialize(q),H=this.stack[this.stack.length-2];H.label=HE(oe),H.identifier=Xr(oe).toLowerCase()}function $(){const q=this.stack[this.stack.length-1],oe=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){const te=q.children;H.children=te}else H.alt=oe}function b(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.url=q}function Z(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.title=q}function ne(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function Y(q){const oe=this.resume(),H=this.stack[this.stack.length-1];H.label=oe,H.identifier=Xr(this.sliceSerialize(q)).toLowerCase(),this.data.referenceType="full"}function D(q){this.data.characterReferenceType=q.type}function W(q){const oe=this.sliceSerialize(q),H=this.data.characterReferenceType;let te;H?(te=Ky(oe,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):te=Yf(oe);const ce=this.stack[this.stack.length-1];ce.value+=te}function X(q){const oe=this.stack.pop();oe.position.end=jn(q.end)}function he(q){k.call(this,q);const oe=this.stack[this.stack.length-1];oe.url=this.sliceSerialize(q)}function me(q){k.call(this,q);const oe=this.stack[this.stack.length-1];oe.url="mailto:"+this.sliceSerialize(q)}function Ce(){return{type:"blockquote",children:[]}}function Se(){return{type:"code",lang:null,meta:null,value:""}}function Fe(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function xe(){return{type:"emphasis",children:[]}}function G(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Ee(){return{type:"image",title:null,url:"",alt:null}}function ye(){return{type:"link",title:null,url:"",children:[]}}function wt(q){return{type:"list",ordered:q.type==="listOrdered",start:null,spread:q._spread,children:[]}}function At(q){return{type:"listItem",spread:q._spread,checked:null,children:[]}}function et(){return{type:"paragraph",children:[]}}function or(){return{type:"strong",children:[]}}function Nr(){return{type:"text",value:""}}function Bt(){return{type:"thematicBreak"}}}function jn(e){return{line:e.line,column:e.column,offset:e.offset}}function r0(e,t){let r=-1;for(;++r<t.length;){const n=t[r];Array.isArray(n)?r0(e,n):qE(e,n)}}function qE(e,t){let r;for(r in t)if(t0.call(t,r))switch(r){case"canContainEols":{const n=t[r];n&&e[r].push(...n);break}case"transforms":{const n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{const n=t[r];n&&Object.assign(e[r],n);break}}}function ng(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+wo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+wo({start:t.start,end:t.end})+") is still open")}function YE(e){const t=this;t.parser=r;function r(n){return KE(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function XE(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function GE(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
70
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,n.push(o)}return n.join("")}function zE(e){const n={constructs:Uy([DE,...(e||{}).extensions||[]]),content:i(e2),defined:[],document:i(r2),flow:i(yE),lazy:{},string:i(SE),text:i(kE)};return n;function i(s){return o;function o(l){return AE(n,s,l)}}}function $E(e){for(;!Xy(e););return e}const rg=/[\0\t\n\r]/g;function FE(){let e=1,t="",r=!0,n;return i;function i(s,o,l){const a=[];let c,d,h,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,t="",r&&(s.charCodeAt(0)===65279&&h++,r=void 0);h<s.length;){if(rg.lastIndex=h,c=rg.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(h);break}if(p===10&&h===f&&n)a.push(-3),n=void 0;else switch(n&&(a.push(-5),n=void 0),h<f&&(a.push(s.slice(h,f)),e+=f-h),p){case 0:{a.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,a.push(-2);e++<d;)a.push(-1);break}case 10:{a.push(-4),e=1;break}default:n=!0,e=1}h=f+1}return l&&(n&&a.push(-5),t&&a.push(t),a.push(null)),a}}const WE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HE(e){return e.replace(WE,UE)}function UE(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return Ky(r.slice(s?2:1),s?16:10)}return Yf(r)||e}const t0={}.hasOwnProperty;function KE(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),VE(r)($E(zE(r).document().write(FE()(e,t,!0))))}function VE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ye),autolinkProtocol:A,autolinkEmail:A,atxHeading:s(G),blockQuote:s(Ce),characterEscape:A,characterReference:A,codeFenced:s(Se),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Se,o),codeText:s(Fe,o),codeTextData:A,data:A,codeFlowValue:A,definition:s(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(xe),hardBreakEscape:s(_e),hardBreakTrailing:s(_e),htmlFlow:s(Pe,o),htmlFlowData:A,htmlText:s(Pe,o),htmlTextData:A,image:s(Ee),label:o,link:s(ye),listItem:s(At),listItemValue:f,listOrdered:s(wt,h),listUnordered:s(wt),paragraph:s(et),reference:T,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(G),strong:s(or),thematicBreak:s(Bt)},exit:{atxHeading:a(),atxHeadingSequence:L,autolink:a(),autolinkEmail:me,autolinkProtocol:he,blockQuote:a(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:D,characterReferenceMarkerNumeric:D,characterReferenceValue:W,characterReference:X,codeFenced:a(w),codeFencedFence:_,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:k,codeIndented:a(g),codeText:a(B),codeTextData:k,data:k,definition:a(),definitionDestinationString:S,definitionLabelString:v,definitionTitleString:y,emphasis:a(),hardBreakEscape:a(I),hardBreakTrailing:a(I),htmlFlow:a(R),htmlFlowData:k,htmlText:a(C),htmlTextData:k,image:a(U),label:$,labelText:M,lineEnding:O,link:a(z),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Y,resourceDestinationString:b,resourceTitleString:Z,resource:ne,setextHeading:a(N),setextHeadingLineSequence:P,setextHeadingText:E,strong:a(),thematicBreak:a()}};r0(t,(e||{}).mdastExtensions||[]);const r={};return n;function n(q){let oe={type:"root",children:[]};const H={stack:[oe],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:r},ee=[];let ce=-1;for(;++ce<q.length;)if(q[ce][1].type==="listOrdered"||q[ce][1].type==="listUnordered")if(q[ce][0]==="enter")ee.push(ce);else{const Le=ee.pop();ce=i(q,Le,ce)}for(ce=-1;++ce<q.length;){const Le=t[q[ce][0]];t0.call(Le,q[ce][1].type)&&Le[q[ce][1].type].call(Object.assign({sliceSerialize:q[ce][2].sliceSerialize},H),q[ce][1])}if(H.tokenStack.length>0){const Le=H.tokenStack[H.tokenStack.length-1];(Le[1]||ng).call(H,void 0,Le[0])}for(oe.position={start:jn(q.length>0?q[0][1].start:{line:1,column:1,offset:0}),end:jn(q.length>0?q[q.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce<t.transforms.length;)oe=t.transforms[ce](oe)||oe;return oe}function i(q,oe,H){let ee=oe-1,ce=-1,Le=!1,Re,Ne,V,se;for(;++ee<=H;){const te=q[ee];switch(te[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{te[0]==="enter"?ce++:ce--,se=void 0;break}case"lineEndingBlank":{te[0]==="enter"&&(Re&&!se&&!ce&&!V&&(V=ee),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!ce&&te[0]==="enter"&&te[1].type==="listItemPrefix"||ce===-1&&te[0]==="exit"&&(te[1].type==="listUnordered"||te[1].type==="listOrdered")){if(Re){let be=ee;for(Ne=void 0;be--;){const Me=q[be];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;Ne&&(q[Ne][1].type="lineEndingBlank",Le=!0),Me[1].type="lineEnding",Ne=be}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}V&&(!Ne||V<Ne)&&(Re._spread=!0),Re.end=Object.assign({},Ne?q[Ne][1].start:te[1].end),q.splice(Ne||ee,0,["exit",Re,te[2]]),ee++,H++}if(te[1].type==="listItemPrefix"){const be={type:"listItem",_spread:!1,start:Object.assign({},te[1].start),end:void 0};Re=be,q.splice(ee,0,["enter",be,te[2]]),ee++,H++,V=void 0,se=!0}}}return q[oe][1]._spread=Le,H}function s(q,oe){return H;function H(ee){l.call(this,q(ee),ee),oe&&oe.call(this,ee)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(q,oe,H){this.stack[this.stack.length-1].children.push(q),this.stack.push(q),this.tokenStack.push([oe,H||void 0]),q.position={start:jn(oe.start),end:void 0}}function a(q){return oe;function oe(H){q&&q.call(this,H),c.call(this,H)}}function c(q,oe){const H=this.stack.pop(),ee=this.tokenStack.pop();if(ee)ee[0].type!==q.type&&(oe?oe.call(this,q,ee[0]):(ee[1]||ng).call(this,q,ee[0]));else throw new Error("Cannot close `"+q.type+"` ("+wo({start:q.start,end:q.end})+"): it’s not open");H.position.end=jn(q.end)}function d(){return qf(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(q){if(this.data.expectingFirstListItemValue){const oe=this.stack[this.stack.length-2];oe.start=Number.parseInt(this.sliceSerialize(q),10),this.data.expectingFirstListItemValue=void 0}}function p(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.lang=q}function m(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.meta=q}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q.replace(/(\r?\n|\r)$/g,"")}function v(q){const oe=this.resume(),H=this.stack[this.stack.length-1];H.label=oe,H.identifier=Xr(this.sliceSerialize(q)).toLowerCase()}function y(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.title=q}function S(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.url=q}function L(q){const oe=this.stack[this.stack.length-1];if(!oe.depth){const H=this.sliceSerialize(q).length;oe.depth=H}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function P(q){const oe=this.stack[this.stack.length-1];oe.depth=this.sliceSerialize(q).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function A(q){const H=this.stack[this.stack.length-1].children;let ee=H[H.length-1];(!ee||ee.type!=="text")&&(ee=Nr(),ee.position={start:jn(q.start),end:void 0},H.push(ee)),this.stack.push(ee)}function k(q){const oe=this.stack.pop();oe.value+=this.sliceSerialize(q),oe.position.end=jn(q.end)}function O(q){const oe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const H=oe.children[oe.children.length-1];H.position.end=jn(q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(oe.type)&&(A.call(this,q),k.call(this,q))}function I(){this.data.atHardBreak=!0}function R(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function C(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function B(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.value=q}function z(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=oe,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function U(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=oe,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function M(q){const oe=this.sliceSerialize(q),H=this.stack[this.stack.length-2];H.label=HE(oe),H.identifier=Xr(oe).toLowerCase()}function $(){const q=this.stack[this.stack.length-1],oe=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){const ee=q.children;H.children=ee}else H.alt=oe}function b(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.url=q}function Z(){const q=this.resume(),oe=this.stack[this.stack.length-1];oe.title=q}function ne(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function Y(q){const oe=this.resume(),H=this.stack[this.stack.length-1];H.label=oe,H.identifier=Xr(this.sliceSerialize(q)).toLowerCase(),this.data.referenceType="full"}function D(q){this.data.characterReferenceType=q.type}function W(q){const oe=this.sliceSerialize(q),H=this.data.characterReferenceType;let ee;H?(ee=Ky(oe,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ee=Yf(oe);const ce=this.stack[this.stack.length-1];ce.value+=ee}function X(q){const oe=this.stack.pop();oe.position.end=jn(q.end)}function he(q){k.call(this,q);const oe=this.stack[this.stack.length-1];oe.url=this.sliceSerialize(q)}function me(q){k.call(this,q);const oe=this.stack[this.stack.length-1];oe.url="mailto:"+this.sliceSerialize(q)}function Ce(){return{type:"blockquote",children:[]}}function Se(){return{type:"code",lang:null,meta:null,value:""}}function Fe(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function xe(){return{type:"emphasis",children:[]}}function G(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Ee(){return{type:"image",title:null,url:"",alt:null}}function ye(){return{type:"link",title:null,url:"",children:[]}}function wt(q){return{type:"list",ordered:q.type==="listOrdered",start:null,spread:q._spread,children:[]}}function At(q){return{type:"listItem",spread:q._spread,checked:null,children:[]}}function et(){return{type:"paragraph",children:[]}}function or(){return{type:"strong",children:[]}}function Nr(){return{type:"text",value:""}}function Bt(){return{type:"thematicBreak"}}}function jn(e){return{line:e.line,column:e.column,offset:e.offset}}function r0(e,t){let r=-1;for(;++r<t.length;){const n=t[r];Array.isArray(n)?r0(e,n):qE(e,n)}}function qE(e,t){let r;for(r in t)if(t0.call(t,r))switch(r){case"canContainEols":{const n=t[r];n&&e[r].push(...n);break}case"transforms":{const n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{const n=t[r];n&&Object.assign(e[r],n);break}}}function ng(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+wo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+wo({start:t.start,end:t.end})+") is still open")}function YE(e){const t=this;t.parser=r;function r(n){return KE(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function XE(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function GE(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
71
71
  `}]}function QE(e,t){const r=t.value?t.value+`
72
72
  `:"",n={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(n.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:r}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function JE(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ZE(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function e5(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),i=Is(n.toLowerCase()),s=e.footnoteOrder.indexOf(n);let o,l=e.footnoteCounts.get(n);l===void 0?(l=0,e.footnoteOrder.push(n),o=e.footnoteOrder.length):o=s+1,l+=1,e.footnoteCounts.set(n,l);const a={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+i,id:r+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,a);const c={type:"element",tagName:"sup",properties:{},children:[a]};return e.patch(t,c),e.applyData(t,c)}function t5(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r5(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function n0(e,t){const r=t.referenceType;let n="]";if(r==="collapsed"?n+="[]":r==="full"&&(n+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+n}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=n:i.push({type:"text",value:n}),i}function n5(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return n0(e,t);const i={src:Is(n.url||""),alt:t.alt};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function i5(e,t){const r={src:Is(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,n),e.applyData(t,n)}function s5(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const n={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,n),e.applyData(t,n)}function o5(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return n0(e,t);const i={href:Is(n.url||"")};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function l5(e,t){const r={href:Is(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a5(e,t,r){const n=e.all(t),i=r?c5(r):i0(t),s={},o=[];if(typeof t.checked=="boolean"){const d=n[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},n.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<n.length;){const d=n[l];(i||l!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
73
73
  `}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const a=n[n.length-1];a&&(i||a.type!=="element"||a.tagName!=="p")&&o.push({type:"text",value:`
@@ -150,7 +150,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
150
150
  * Fabrice Bellard's javascript vt100 for jslinux:
151
151
  * http://bellard.org/jslinux/
152
152
  * Copyright (c) 2011 Fabrice Bellard
153
- */var oR=class{constructor(e,t,r,n={}){this._terminal=e,this._regex=t,this._handler=r,this._options=n}provideLinks(e,t){let r=aR.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(r,n)=>{if(this._options.hover){let{range:i}=t;this._options.hover(r,n,i)}},t))}};function lR(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var aR=class fa{static computeLink(t,r,n,i){let s=new RegExp(r.source,(r.flags||"")+"g"),[o,l]=fa._getWindowedLineStrings(t-1,n),a=o.join(""),c,d=[];for(;c=s.exec(a);){let h=c[0];if(!lR(h))continue;let[f,p]=fa._mapStrIdx(n,l,0,c.index),[m,_]=fa._mapStrIdx(n,f,p,h.length);if(f===-1||p===-1||m===-1||_===-1)continue;let w={start:{x:p+1,y:f+1},end:{x:_,y:m+1}};d.push({range:w,text:h,activate:i})}return d}static _getWindowedLineStrings(t,r){let n,i=t,s=t,o=0,l="",a=[];if(n=r.buffer.active.getLine(t)){let c=n.translateToString(!0);if(n.isWrapped&&c[0]!==" "){for(o=0;(n=r.buffer.active.getLine(--i))&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),!(!n.isWrapped||l.indexOf(" ")!==-1)););a.reverse()}for(a.push(c),o=0;(n=r.buffer.active.getLine(++s))&&n.isWrapped&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),l.indexOf(" ")===-1););}return[a,i]}static _mapStrIdx(t,r,n,i){let s=t.buffer.active,o=s.getNullCell(),l=n;for(;i;){let a=s.getLine(r);if(!a)return[-1,-1];for(let c=l;c<a.length;++c){a.getCell(c,o);let d=o.getChars();if(o.getWidth()&&(i-=d.length||1,c===a.length-1&&d==="")){let h=s.getLine(r+1);h&&h.isWrapped&&(h.getCell(0,o),o.getWidth()===2&&(i+=1))}if(i<0)return[r,c]}r++,l=0}return[r,l]}},cR=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function uR(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var hR=class{constructor(e=uR,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,r=t.urlRegex||cR;this._linkProvider=this._terminal.registerLinkProvider(new oR(this._terminal,r,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const T_={background:"#0f1117",foreground:"#cdd6f4",cursor:"#f38ba8",cursorAccent:"#0f1117",selectionBackground:"rgba(166, 227, 161, 0.3)",selectionForeground:"#cdd6f4",black:"#45475a",red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#cba6f7",cyan:"#94e2d5",white:"#bac2de",brightBlack:"#585b70",brightRed:"#f38ba8",brightGreen:"#a6e3a1",brightYellow:"#f9e2af",brightBlue:"#89b4fa",brightMagenta:"#cba6f7",brightCyan:"#94e2d5",brightWhite:"#a6adc8"},R1=x.forwardRef(({onInput:e,onResize:t,fontSize:r=13},n)=>{const i=x.useRef(null),s=x.useRef(null),o=x.useRef(null),[l,a]=x.useState(!1);return x.useImperativeHandle(n,()=>({write:c=>{var d;(d=s.current)==null||d.write(c)},clear:()=>{var c;(c=s.current)==null||c.clear()},fit:()=>{var c;try{(c=o.current)==null||c.fit(),s.current&&(t==null||t(s.current.cols,s.current.rows))}catch{}},bumpResize:()=>{var c;try{(c=o.current)==null||c.fit();const d=s.current;if(!d)return;const h=d.cols,f=d.rows;t==null||t(h+5,f),setTimeout(()=>{t==null||t(h,f)},100)}catch{}}})),x.useEffect(()=>{if(!i.current)return;const c=new rR({cursorBlink:!0,cursorStyle:"bar",fontSize:r,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontWeight:"400",letterSpacing:0,lineHeight:1.2,theme:T_,allowTransparency:!0,scrollback:5e3,convertEol:!1}),d=new sR,h=new hR;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),t==null||t(c.cols,c.rows),a(!0)});const f=c.onData(m=>{e(m)}),p=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{d.fit(),t==null||t(c.cols,c.rows)}catch{}})});return p.observe(i.current),s.current=c,o.current=d,()=>{f.dispose(),p.disconnect(),c.dispose(),s.current=null,o.current=null}},[r]),u.jsx("div",{ref:i,className:"w-full h-full rounded-lg overflow-hidden transition-opacity duration-200",style:{background:T_.background,opacity:l?1:0}})});R1.displayName="CliTerminal";function Wl({label:e,value:t,sub:r,icon:n}){return u.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[u.jsx("span",{className:"text-base flex items-center",children:n}),u.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),u.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&u.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function P_({value:e,max:t,label:r,color:n="#8b5cf6",detail:i,compact:s=!1}){const o=t>0?Math.min(Math.round(e/t*100),100):0,l=o>85?"#ef4444":o>60?"#f59e0b":n;return s?u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-0.5",children:[u.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),u.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${o}%`,background:l}})})]}):u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-1.5",children:[u.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),u.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${o}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),i&&u.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:i})]})}function dR({screenshot:e,isCapturing:t,onRefresh:r,onAction:n,addLog:i,connState:s,connScreenshot:o}){const l=x.useRef(null),a=x.useRef(null),c=x.useRef(null),[d,h]=x.useState(!0),[f,p]=x.useState(2e3),[m,_]=x.useState(null),[w,g]=x.useState(""),[,v]=x.useState(!1),[y,S]=x.useState([]),L=x.useRef(0),[E,P]=x.useState(!1),[N,A]=x.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[O,I]=x.useState(k?"mouse":"touch"),[R,C]=x.useState(1),B=x.useRef(!1),[z,U]=x.useState(1),[M,$]=x.useState(0),[b,Z]=x.useState(0),ne=x.useRef(0),T=x.useRef(t),Y=x.useRef(r),D=x.useRef(n),W=x.useRef(null),X=x.useRef(null),he=x.useRef(!1),me=x.useRef(null),Ce=x.useRef(0),Se=x.useRef(null),Fe=x.useRef(1),de=x.useRef({x:0,y:0}),xe=x.useRef(!1),G=x.useRef(z),_e=x.useRef(M),Pe=x.useRef(b),Ee=x.useRef(O);x.useEffect(()=>{T.current=t},[t]),x.useEffect(()=>{Y.current=r},[r]),x.useEffect(()=>{G.current=z},[z]),x.useEffect(()=>{_e.current=M},[M]),x.useEffect(()=>{Pe.current=b},[b]),x.useEffect(()=>{D.current=n},[n]),x.useEffect(()=>{Ee.current=O},[O]),x.useEffect(()=>{var V;(V=l.current)==null||V.focus()},[]);const ye=s==="connected",wt=s!=="connected"&&s!=="connecting",At=ye&&o?o:e;x.useEffect(()=>{if(!k||B.current||!At)return;const V=c.current,se=a.current;if(!V||!se)return;const ee=()=>{const be=se.clientWidth,Me=se.clientHeight,ze=V.naturalWidth,Ot=V.naturalHeight;if(!ze||!Ot||!be||!Me)return;const ve=Math.min(be/ze,Me/Ot),j=Math.max(be/ze,Me/Ot)/ve;j>1.01&&(C(j),U(j),G.current=j),B.current=!0};V.complete&&V.naturalWidth?ee():V.addEventListener("load",ee,{once:!0})},[At,k]);const et=.5;x.useEffect(()=>{z<=et&&($(0),Z(0))},[z,et]);const or=(V,se,ee)=>{if(ee<=et)return{x:0,y:0};const be=(ee-1)/(2*ee)*100,Me=(ee-1)/(2*ee)*100;return{x:Math.max(-be,Math.min(be,V)),y:Math.max(-Me,Math.min(Me,se))}};x.useEffect(()=>{if(!d||!wt)return;let V=null;const se=()=>{V&&clearInterval(V),!document.hidden&&(V=setInterval(()=>{var be;if(!T.current){const Me=((be=l.current)==null?void 0:be.clientWidth)||0,ze=Math.max(400,Math.ceil(Me/100)*100);Y.current(ze)}},f))},ee=()=>{document.hidden?(V&&clearInterval(V),V=null):se()};return se(),document.addEventListener("visibilitychange",ee),()=>{V&&clearInterval(V),document.removeEventListener("visibilitychange",ee)}},[d,wt,f]);const Nr=(V,se)=>{if(!c.current)return null;const ee=c.current.getBoundingClientRect();return!ee.width||!ee.height?null:{nx:Math.max(0,Math.min(1,(V-ee.left)/ee.width)),ny:Math.max(0,Math.min(1,(se-ee.top)/ee.height))}},Bt=(V,se,ee)=>{const be=a.current;if(!be)return;const Me=be.getBoundingClientRect(),ze=++L.current;S(Ot=>[...Ot,{id:ze,x:V-Me.left,y:se-Me.top,type:ee}]),setTimeout(()=>S(Ot=>Ot.filter(ve=>ve.id!==ze)),600)},q=(V,se,ee)=>{const be=c.current,Me=a.current;if(!be||!Me)return;const ze=be.getBoundingClientRect(),Ot=Me.getBoundingClientRect(),ve=be.naturalWidth||ze.width,Ve=be.naturalHeight||ze.height,j=ve/Ve,F=ze.width/ze.height;let Q,K,ae,Te;j>F?(Q=ze.width,K=ze.width/j,ae=0,Te=(ze.height-K)/2):(K=ze.height,Q=ze.height*j,ae=(ze.width-Q)/2,Te=0);const Ue=ze.left-Ot.left+ae+Q*V,$e=ze.top-Ot.top+Te+K*se,We=++L.current;S(qe=>[...qe,{id:We,x:Ue,y:$e,type:ee}]),setTimeout(()=>S(qe=>qe.filter(Ge=>Ge.id!==We)),600)},oe=async V=>{var ee;const se=Nr(V.clientX,V.clientY);if(se){_(`Click: ${Math.round(se.nx*100)}%, ${Math.round(se.ny*100)}%`),Bt(V.clientX,V.clientY,"left"),(ee=l.current)==null||ee.focus();try{const be=await n("input_click",{nx:se.nx,ny:se.ny});be!=null&&be.success||i(`❌ Click failed: ${be==null?void 0:be.error}`)}catch(be){i(`❌ Click error: ${be.message||be}`)}}},H=async(V,se,ee,be=0)=>{try{await n("input_key",{type:ee?"char":"keyDown",key:V,code:se,text:ee?V:void 0,unmodifiedText:ee?V:void 0,modifiers:be})}catch(Me){i(`❌ Key error: ${Me.message||Me}`)}},te=async V=>{if(V.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(V.key)&&V.preventDefault();let ee=0;V.altKey&&(ee|=1),V.ctrlKey&&(ee|=2),V.metaKey&&(ee|=4),V.shiftKey&&(ee|=8),_(`Key: ${V.key}`),await H(V.key,V.code,V.key.length===1,ee)},ce=async V=>{if(V.key==="Enter"){if(V.nativeEvent.isComposing)return;if(w){const se=w;g(""),_(`IME Sent: ${se}`);try{const ee=await n("input_type",{text:se});ee!=null&&ee.success||i(`❌ IME error: ${ee==null?void 0:ee.error}`)}catch(ee){i(`❌ IME error: ${ee.message}`)}}else _("Key: Enter"),await H("Enter","Enter",!1)}};x.useEffect(()=>{const V=l.current;if(!V)return;const se=ee=>{var be;if((be=c.current)!=null&&be.contains(ee.target)){ee.preventDefault();const Me=Date.now();if(Me-ne.current<40)return;ne.current=Me;const ze=Nr(ee.clientX,ee.clientY);if(!ze)return;_(`Scroll: ${Math.round(ee.deltaY)}`),n("input_wheel",{nx:ze.nx,ny:ze.ny,deltaX:Math.round(ee.deltaX),deltaY:Math.round(ee.deltaY)}).catch(()=>{})}};return V.addEventListener("wheel",se,{passive:!1}),()=>V.removeEventListener("wheel",se)},[n]);const[Le,Re]=x.useState(null),Ne=x.useRef(null);return x.useEffect(()=>{if(O==="mouse"&&!Ne.current){const V={nx:.5,ny:.5};Ne.current=V,Re(V)}},[O]),x.useEffect(()=>{const V=l.current;if(!V)return;const se=ve=>{if(!c.current)return null;const Ve=c.current.getBoundingClientRect();return!Ve.width||!Ve.height?null:{nx:Math.max(0,Math.min(1,(ve.clientX-Ve.left)/Ve.width)),ny:Math.max(0,Math.min(1,(ve.clientY-Ve.top)/Ve.height))}},ee=(ve,Ve)=>{if(!c.current)return{dnx:0,dny:0};const j=c.current,F=j.getBoundingClientRect(),Q=j.naturalWidth||F.width,K=j.naturalHeight||F.height,ae=Q/K,Te=F.width/F.height;let Ue,$e;return ae>Te?(Ue=F.width,$e=F.width/ae):($e=F.height,Ue=F.height*ae),{dnx:ve/Ue,dny:Ve/$e}},be=(ve,Ve,j)=>{if(j<=1.05)return;const F=-(ve-.5)*100,Q=-(Ve-.5)*100,K=or(F,Q,j);(Math.abs(K.x-_e.current)>.1||Math.abs(K.y-Pe.current)>.1)&&($(K.x),Z(K.y),_e.current=K.x,Pe.current=K.y)},Me=ve=>{const Ve=a.current;if(Ve&&ve.target instanceof Node&&Ve.contains(ve.target))ve.preventDefault();else return;if(ve.touches.length===1){const j=ve.touches[0];W.current={x:j.clientX,y:j.clientY,time:Date.now()},X.current={x:j.clientX,y:j.clientY},xe.current||(he.current=!1),me.current=setTimeout(()=>{if(!he.current&&!xe.current)if(he.current=!0,Ee.current==="mouse"){const F=Ne.current||{nx:.5,ny:.5};_("Right Click"),q(F.nx,F.ny,"right"),D.current("input_click",{...F,button:"right"}).catch(()=>{})}else{const F=se(j);F&&(_("Right Click"),q(F.nx,F.ny,"right"),D.current("input_click",{...F,button:"right"}).catch(()=>{}))}},500)}else if(ve.touches.length===2){clearTimeout(me.current),he.current=!0,xe.current=!0;const j=ve.touches[1].clientX-ve.touches[0].clientX,F=ve.touches[1].clientY-ve.touches[0].clientY;Se.current=Math.sqrt(j*j+F*F),Fe.current=G.current,de.current={x:(ve.touches[0].clientX+ve.touches[1].clientX)/2,y:(ve.touches[0].clientY+ve.touches[1].clientY)/2}}},ze=ve=>{const Ve=a.current;if(Ve&&ve.target instanceof Node&&Ve.contains(ve.target)&&ve.preventDefault(),ve.touches.length===1&&X.current){const j=ve.touches[0],F=j.clientX-X.current.x,Q=j.clientY-X.current.y;if(!he.current&&W.current){const K=j.clientX-W.current.x,ae=j.clientY-W.current.y;Math.sqrt(K*K+ae*ae)>8&&(he.current=!0,clearTimeout(me.current))}if(he.current)if(Ee.current==="mouse"){const K=ee(F,Q),ae=Ne.current||{nx:.5,ny:.5},Te=Math.max(0,Math.min(1,ae.nx+K.dnx)),Ue=Math.max(0,Math.min(1,ae.ny+K.dny));Ne.current={nx:Te,ny:Ue},Re({nx:Te,ny:Ue}),_(`Cursor: ${Math.round(Te*100)}%, ${Math.round(Ue*100)}%`),be(Te,Ue,G.current);const $e=Date.now();$e-ne.current>=30&&(ne.current=$e,D.current("input_mouseMoved",{nx:Te,ny:Ue}).catch(()=>{}))}else if(G.current>1){const K=a.current;if(K){const ae=K.clientWidth,Te=K.clientHeight,Ue=_e.current+F/ae*100,$e=Pe.current+Q/Te*100,We=or(Ue,$e,G.current);$(We.x),Z(We.y),_e.current=We.x,Pe.current=We.y}}else{const K=se(j);if(K){const ae=Date.now();ae-ne.current>=40&&(ne.current=ae,_("Scroll"),D.current("input_wheel",{nx:K.nx,ny:K.ny,deltaX:Math.round(-F*2.5),deltaY:Math.round(-Q*2.5)}).catch(()=>{}))}}X.current={x:j.clientX,y:j.clientY}}else if(ve.touches.length===2&&Se.current!==null){const j=ve.touches[1].clientX-ve.touches[0].clientX,F=ve.touches[1].clientY-ve.touches[0].clientY,K=Math.sqrt(j*j+F*F)/Se.current,ae=(ve.touches[0].clientX+ve.touches[1].clientX)/2,Te=(ve.touches[0].clientY+ve.touches[1].clientY)/2,Ue=ae-de.current.x,$e=Te-de.current.y,We=Math.abs(K-1)>.03;if(Ee.current==="mouse"){if(We){const qe=Math.max(et,Math.min(5,Fe.current*K));U(qe),G.current=qe}else if(Math.abs(Ue)>2||Math.abs($e)>2){const qe=Ne.current||{nx:.5,ny:.5},Ge=Date.now();Ge-ne.current>=30&&(ne.current=Ge,_("Scroll"),D.current("input_wheel",{nx:qe.nx,ny:qe.ny,deltaX:Math.round(-Ue*3),deltaY:Math.round(-$e*3)}).catch(()=>{}))}}else{const qe=Math.max(et,Math.min(5,Fe.current*K));U(qe),G.current=qe;const Ge=a.current;if(Ge&&qe>1){const Qt=Ge.clientWidth,Rc=Ge.clientHeight,Mc=_e.current+Ue/Qt*100,Bs=Pe.current+$e/Rc*100,lr=or(Mc,Bs,qe);$(lr.x),Z(lr.y),_e.current=lr.x,Pe.current=lr.y}}de.current={x:ae,y:Te}}},Ot=ve=>{var Ve;if(clearTimeout(me.current),Se.current=null,ve.touches.length===1&&xe.current){const j=ve.touches[0];W.current={x:j.clientX,y:j.clientY,time:Date.now()},X.current={x:j.clientX,y:j.clientY},he.current=!0;return}if(ve.touches.length===0){if(xe.current){xe.current=!1,he.current=!1;return}if(ve.changedTouches.length===1&&!he.current){const j=ve.changedTouches[0],F=Date.now(),Q=F-(((Ve=W.current)==null?void 0:Ve.time)||0);if(Q<60||Q>400){he.current=!1;return}if(W.current){const K=j.clientX-W.current.x,ae=j.clientY-W.current.y;if(Math.sqrt(K*K+ae*ae)>12){he.current=!1;return}}if(Ee.current==="mouse"){const K=Ne.current||se(j);K&&(_(`Click: ${Math.round(K.nx*100)}%, ${Math.round(K.ny*100)}%`),q(K.nx,K.ny,"left"),D.current("input_click",{...K}).catch(()=>{}))}else{const K=se(j);if(!K)return;F-Ce.current<300?(_("Double tap"),q(K.nx,K.ny,"double"),D.current("input_click",{...K,clickCount:2}).catch(()=>{}),Ce.current=0):(_(`Tap: ${Math.round(K.nx*100)}%, ${Math.round(K.ny*100)}%`),q(K.nx,K.ny,"left"),D.current("input_click",{...K}).catch(()=>{}),Ce.current=F)}}he.current=!1}};return V.addEventListener("touchstart",Me,{passive:!1}),V.addEventListener("touchmove",ze,{passive:!1}),V.addEventListener("touchend",Ot,{passive:!1}),()=>{V.removeEventListener("touchstart",Me),V.removeEventListener("touchmove",ze),V.removeEventListener("touchend",Ot),clearTimeout(me.current)}},[]),u.jsxs("div",{ref:l,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:te,onContextMenu:V=>V.preventDefault(),onFocus:()=>v(!0),onBlur:()=>v(!1),tabIndex:0,children:[u.jsxs("div",{ref:a,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[At?u.jsx("img",{ref:c,src:At,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${z}) translate(${M}%, ${b}%)`,transformOrigin:"center center",cursor:O==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:oe,onContextMenu:V=>V.preventDefault(),onDragStart:V=>V.preventDefault()}):u.jsxs("div",{className:"text-slate-800 text-center",children:[u.jsx("div",{className:"text-5xl mb-3",children:"🌑"}),u.jsx("div",{className:"text-[13px] font-semibold",children:"Connecting to Host..."})]}),O==="mouse"&&Le&&At&&c.current&&(()=>{var Ue;const V=c.current,se=V.getBoundingClientRect(),ee=(Ue=a.current)==null?void 0:Ue.getBoundingClientRect();if(!ee)return null;const be=V.naturalWidth||se.width,Me=V.naturalHeight||se.height,ze=be/Me,Ot=se.width/se.height;let ve,Ve,j,F;ze>Ot?(ve=se.width,Ve=se.width/ze,j=0,F=(se.height-Ve)/2):(Ve=se.height,ve=se.height*ze,j=(se.width-ve)/2,F=0);const Q=se.left-ee.left+j+ve*Le.nx,K=se.top-ee.top+F+Ve*Le.ny,ae=Math.max(8,Math.min(ee.width-8,Q)),Te=Math.max(8,Math.min(ee.height-8,K));return u.jsxs("div",{style:{position:"absolute",left:ae-8,top:Te-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[u.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})})(),y.map(V=>{const ee={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[V.type];return u.jsxs("div",{style:{position:"absolute",left:V.x,top:V.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[u.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${ee}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),u.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${ee}, 0.9)`,boxShadow:`0 0 12px rgba(${ee}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},V.id)})]}),u.jsxs("div",{onTouchStart:V=>V.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-[1000] flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[u.jsxs("div",{onClick:()=>{I(V=>{const se=V==="touch"?"mouse":"touch";if(se==="mouse"&&!Ne.current){const ee={nx:.5,ny:.5};Ne.current=ee,Re(ee)}return se})},className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${O==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[u.jsx("span",{className:"text-sm",children:O==="mouse"?"🖱️":"👆"}),u.jsx("span",{className:`text-[10px] font-bold ${O==="mouse"?"text-blue-400":"text-slate-400"}`,children:O==="mouse"?"Mouse":"Touch"})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{onClick:()=>{A(!N),P(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${N?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⌨️"})}),N&&u.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-[2000]",style:{animation:"slideUp 0.15s ease-out"},children:u.jsx("input",{type:"text",placeholder:"Type & Enter...",value:w,autoFocus:!0,onTouchStart:V=>V.stopPropagation(),onChange:V=>g(V.target.value),onKeyDown:ce,className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),u.jsx("div",{className:"relative",children:u.jsx("div",{onClick:()=>{P(!E),A(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${E?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⚙️"})})}),u.jsx("div",{className:"w-px h-[18px] bg-white/10"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:ye?"rgba(16,185,129,0.12)":"rgba(251,191,36,0.12)"},children:[u.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:ye?"#10b981":"#fbbf24"}}),u.jsx("span",{className:"text-[8px] font-extrabold",style:{color:ye?"#10b981":"#fbbf24"},children:ye?"Connected":"WS"})]}),z>1&&u.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(z*100),"%"]}),m&&u.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:m})]})]}),E&&u.jsxs("div",{onTouchStart:V=>V.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:1001,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[u.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",z<=(k?R:1)+.01?k?"FILL":"FIT":`${Math.round(z*100)}%`]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:V=>{V.stopPropagation(),U(se=>Math.max(.5,se-.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),u.jsx("button",{onClick:V=>{V.stopPropagation();const se=k?R:1;U(se),G.current=se,$(0),Z(0)},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:k?"FILL":"FIT"}),u.jsx("button",{onClick:V=>{V.stopPropagation(),U(se=>Math.min(5,se+.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]}),u.jsx("button",{onClick:V=>{var be;V.stopPropagation();const se=((be=l.current)==null?void 0:be.clientWidth)||0,ee=se>0?Math.max(400,Math.ceil(se/100)*100):void 0;r(ee)},style:{width:"100%",background:"#3b82f6",color:"#fff",border:"none",padding:"8px",borderRadius:6,fontSize:11,fontWeight:800,cursor:"pointer"},children:"FORCE SYNC"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(255,255,255,0.05)",padding:"6px 10px",borderRadius:6},children:[u.jsx("span",{style:{fontSize:10,color:"#888",fontWeight:700},children:"AUTO REF."}),u.jsx("input",{type:"checkbox",checked:d,onChange:V=>h(V.target.checked)})]}),u.jsxs("select",{value:f,onChange:V=>p(Number(V.target.value)),style:{background:"rgba(255,255,255,0.05)",color:"#fff",border:"none",borderRadius:6,padding:"6px",fontSize:10,fontWeight:600,outline:"none"},children:[u.jsx("option",{value:500,children:"0.5s Interval"}),u.jsx("option",{value:1e3,children:"1.0s Interval"}),u.jsx("option",{value:2e3,children:"2.0s Interval"}),u.jsx("option",{value:4e3,children:"4.0s Interval"})]})]}),u.jsx("style",{children:`
153
+ */var oR=class{constructor(e,t,r,n={}){this._terminal=e,this._regex=t,this._handler=r,this._options=n}provideLinks(e,t){let r=aR.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(r,n)=>{if(this._options.hover){let{range:i}=t;this._options.hover(r,n,i)}},t))}};function lR(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var aR=class fa{static computeLink(t,r,n,i){let s=new RegExp(r.source,(r.flags||"")+"g"),[o,l]=fa._getWindowedLineStrings(t-1,n),a=o.join(""),c,d=[];for(;c=s.exec(a);){let h=c[0];if(!lR(h))continue;let[f,p]=fa._mapStrIdx(n,l,0,c.index),[m,_]=fa._mapStrIdx(n,f,p,h.length);if(f===-1||p===-1||m===-1||_===-1)continue;let w={start:{x:p+1,y:f+1},end:{x:_,y:m+1}};d.push({range:w,text:h,activate:i})}return d}static _getWindowedLineStrings(t,r){let n,i=t,s=t,o=0,l="",a=[];if(n=r.buffer.active.getLine(t)){let c=n.translateToString(!0);if(n.isWrapped&&c[0]!==" "){for(o=0;(n=r.buffer.active.getLine(--i))&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),!(!n.isWrapped||l.indexOf(" ")!==-1)););a.reverse()}for(a.push(c),o=0;(n=r.buffer.active.getLine(++s))&&n.isWrapped&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),l.indexOf(" ")===-1););}return[a,i]}static _mapStrIdx(t,r,n,i){let s=t.buffer.active,o=s.getNullCell(),l=n;for(;i;){let a=s.getLine(r);if(!a)return[-1,-1];for(let c=l;c<a.length;++c){a.getCell(c,o);let d=o.getChars();if(o.getWidth()&&(i-=d.length||1,c===a.length-1&&d==="")){let h=s.getLine(r+1);h&&h.isWrapped&&(h.getCell(0,o),o.getWidth()===2&&(i+=1))}if(i<0)return[r,c]}r++,l=0}return[r,l]}},cR=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function uR(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var hR=class{constructor(e=uR,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,r=t.urlRegex||cR;this._linkProvider=this._terminal.registerLinkProvider(new oR(this._terminal,r,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const T_={background:"#0f1117",foreground:"#cdd6f4",cursor:"#f38ba8",cursorAccent:"#0f1117",selectionBackground:"rgba(166, 227, 161, 0.3)",selectionForeground:"#cdd6f4",black:"#45475a",red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#cba6f7",cyan:"#94e2d5",white:"#bac2de",brightBlack:"#585b70",brightRed:"#f38ba8",brightGreen:"#a6e3a1",brightYellow:"#f9e2af",brightBlue:"#89b4fa",brightMagenta:"#cba6f7",brightCyan:"#94e2d5",brightWhite:"#a6adc8"},R1=x.forwardRef(({onInput:e,onResize:t,fontSize:r=13},n)=>{const i=x.useRef(null),s=x.useRef(null),o=x.useRef(null),[l,a]=x.useState(!1);return x.useImperativeHandle(n,()=>({write:c=>{var d;(d=s.current)==null||d.write(c)},clear:()=>{var c;(c=s.current)==null||c.clear()},fit:()=>{var c;try{(c=o.current)==null||c.fit(),s.current&&(t==null||t(s.current.cols,s.current.rows))}catch{}},bumpResize:()=>{var c;try{(c=o.current)==null||c.fit();const d=s.current;if(!d)return;const h=d.cols,f=d.rows;t==null||t(h+5,f),setTimeout(()=>{t==null||t(h,f)},100)}catch{}}})),x.useEffect(()=>{if(!i.current)return;const c=new rR({cursorBlink:!0,cursorStyle:"bar",fontSize:r,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontWeight:"400",letterSpacing:0,lineHeight:1.2,theme:T_,allowTransparency:!0,scrollback:5e3,convertEol:!1}),d=new sR,h=new hR;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),t==null||t(c.cols,c.rows),a(!0)});const f=c.onData(m=>{e(m)}),p=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{d.fit(),t==null||t(c.cols,c.rows)}catch{}})});return p.observe(i.current),s.current=c,o.current=d,()=>{f.dispose(),p.disconnect(),c.dispose(),s.current=null,o.current=null}},[r]),u.jsx("div",{ref:i,className:"w-full h-full rounded-lg overflow-hidden transition-opacity duration-200",style:{background:T_.background,opacity:l?1:0}})});R1.displayName="CliTerminal";function Wl({label:e,value:t,sub:r,icon:n}){return u.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[u.jsx("span",{className:"text-base flex items-center",children:n}),u.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),u.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&u.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function P_({value:e,max:t,label:r,color:n="#8b5cf6",detail:i,compact:s=!1}){const o=t>0?Math.min(Math.round(e/t*100),100):0,l=o>85?"#ef4444":o>60?"#f59e0b":n;return s?u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-0.5",children:[u.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),u.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${o}%`,background:l}})})]}):u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-1.5",children:[u.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),u.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${o}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),i&&u.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:i})]})}function dR({screenshot:e,isCapturing:t,onRefresh:r,onAction:n,addLog:i,connState:s,connScreenshot:o}){const l=x.useRef(null),a=x.useRef(null),c=x.useRef(null),[d,h]=x.useState(!0),[f,p]=x.useState(2e3),[m,_]=x.useState(null),[w,g]=x.useState(""),[,v]=x.useState(!1),[y,S]=x.useState([]),L=x.useRef(0),[E,P]=x.useState(!1),[N,A]=x.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[O,I]=x.useState(k?"mouse":"touch"),[R,C]=x.useState(1),B=x.useRef(!1),[z,U]=x.useState(1),[M,$]=x.useState(0),[b,Z]=x.useState(0),ne=x.useRef(0),T=x.useRef(t),Y=x.useRef(r),D=x.useRef(n),W=x.useRef(null),X=x.useRef(null),he=x.useRef(!1),me=x.useRef(null),Ce=x.useRef(0),Se=x.useRef(null),Fe=x.useRef(1),de=x.useRef({x:0,y:0}),xe=x.useRef(!1),G=x.useRef(z),_e=x.useRef(M),Pe=x.useRef(b),Ee=x.useRef(O);x.useEffect(()=>{T.current=t},[t]),x.useEffect(()=>{Y.current=r},[r]),x.useEffect(()=>{G.current=z},[z]),x.useEffect(()=>{_e.current=M},[M]),x.useEffect(()=>{Pe.current=b},[b]),x.useEffect(()=>{D.current=n},[n]),x.useEffect(()=>{Ee.current=O},[O]),x.useEffect(()=>{var V;(V=l.current)==null||V.focus()},[]);const ye=s==="connected",wt=s!=="connected"&&s!=="connecting",At=ye&&o?o:e;x.useEffect(()=>{if(!k||B.current||!At)return;const V=c.current,se=a.current;if(!V||!se)return;const te=()=>{const be=se.clientWidth,Me=se.clientHeight,ze=V.naturalWidth,Ot=V.naturalHeight;if(!ze||!Ot||!be||!Me)return;const ve=Math.min(be/ze,Me/Ot),j=Math.max(be/ze,Me/Ot)/ve;j>1.01&&(C(j),U(j),G.current=j),B.current=!0};V.complete&&V.naturalWidth?te():V.addEventListener("load",te,{once:!0})},[At,k]);const et=.5;x.useEffect(()=>{z<=et&&($(0),Z(0))},[z,et]);const or=(V,se,te)=>{if(te<=et)return{x:0,y:0};const be=(te-1)/(2*te)*100,Me=(te-1)/(2*te)*100;return{x:Math.max(-be,Math.min(be,V)),y:Math.max(-Me,Math.min(Me,se))}};x.useEffect(()=>{if(!d||!wt)return;let V=null;const se=()=>{V&&clearInterval(V),!document.hidden&&(V=setInterval(()=>{var be;if(!T.current){const Me=((be=l.current)==null?void 0:be.clientWidth)||0,ze=Math.max(400,Math.ceil(Me/100)*100);Y.current(ze)}},f))},te=()=>{document.hidden?(V&&clearInterval(V),V=null):se()};return se(),document.addEventListener("visibilitychange",te),()=>{V&&clearInterval(V),document.removeEventListener("visibilitychange",te)}},[d,wt,f]);const Nr=(V,se)=>{if(!c.current)return null;const te=c.current.getBoundingClientRect();return!te.width||!te.height?null:{nx:Math.max(0,Math.min(1,(V-te.left)/te.width)),ny:Math.max(0,Math.min(1,(se-te.top)/te.height))}},Bt=(V,se,te)=>{const be=a.current;if(!be)return;const Me=be.getBoundingClientRect(),ze=++L.current;S(Ot=>[...Ot,{id:ze,x:V-Me.left,y:se-Me.top,type:te}]),setTimeout(()=>S(Ot=>Ot.filter(ve=>ve.id!==ze)),600)},q=(V,se,te)=>{const be=c.current,Me=a.current;if(!be||!Me)return;const ze=be.getBoundingClientRect(),Ot=Me.getBoundingClientRect(),ve=be.naturalWidth||ze.width,Ve=be.naturalHeight||ze.height,j=ve/Ve,F=ze.width/ze.height;let Q,K,ae,Te;j>F?(Q=ze.width,K=ze.width/j,ae=0,Te=(ze.height-K)/2):(K=ze.height,Q=ze.height*j,ae=(ze.width-Q)/2,Te=0);const Ue=ze.left-Ot.left+ae+Q*V,$e=ze.top-Ot.top+Te+K*se,We=++L.current;S(qe=>[...qe,{id:We,x:Ue,y:$e,type:te}]),setTimeout(()=>S(qe=>qe.filter(Ge=>Ge.id!==We)),600)},oe=async V=>{var te;const se=Nr(V.clientX,V.clientY);if(se){_(`Click: ${Math.round(se.nx*100)}%, ${Math.round(se.ny*100)}%`),Bt(V.clientX,V.clientY,"left"),(te=l.current)==null||te.focus();try{const be=await n("input_click",{nx:se.nx,ny:se.ny});be!=null&&be.success||i(`❌ Click failed: ${be==null?void 0:be.error}`)}catch(be){i(`❌ Click error: ${be.message||be}`)}}},H=async(V,se,te,be=0)=>{try{await n("input_key",{type:te?"char":"keyDown",key:V,code:se,text:te?V:void 0,unmodifiedText:te?V:void 0,modifiers:be})}catch(Me){i(`❌ Key error: ${Me.message||Me}`)}},ee=async V=>{if(V.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(V.key)&&V.preventDefault();let te=0;V.altKey&&(te|=1),V.ctrlKey&&(te|=2),V.metaKey&&(te|=4),V.shiftKey&&(te|=8),_(`Key: ${V.key}`),await H(V.key,V.code,V.key.length===1,te)},ce=async V=>{if(V.key==="Enter"){if(V.nativeEvent.isComposing)return;if(w){const se=w;g(""),_(`IME Sent: ${se}`);try{const te=await n("input_type",{text:se});te!=null&&te.success||i(`❌ IME error: ${te==null?void 0:te.error}`)}catch(te){i(`❌ IME error: ${te.message}`)}}else _("Key: Enter"),await H("Enter","Enter",!1)}};x.useEffect(()=>{const V=l.current;if(!V)return;const se=te=>{var be;if((be=c.current)!=null&&be.contains(te.target)){te.preventDefault();const Me=Date.now();if(Me-ne.current<40)return;ne.current=Me;const ze=Nr(te.clientX,te.clientY);if(!ze)return;_(`Scroll: ${Math.round(te.deltaY)}`),n("input_wheel",{nx:ze.nx,ny:ze.ny,deltaX:Math.round(te.deltaX),deltaY:Math.round(te.deltaY)}).catch(()=>{})}};return V.addEventListener("wheel",se,{passive:!1}),()=>V.removeEventListener("wheel",se)},[n]);const[Le,Re]=x.useState(null),Ne=x.useRef(null);return x.useEffect(()=>{if(O==="mouse"&&!Ne.current){const V={nx:.5,ny:.5};Ne.current=V,Re(V)}},[O]),x.useEffect(()=>{const V=l.current;if(!V)return;const se=ve=>{if(!c.current)return null;const Ve=c.current.getBoundingClientRect();return!Ve.width||!Ve.height?null:{nx:Math.max(0,Math.min(1,(ve.clientX-Ve.left)/Ve.width)),ny:Math.max(0,Math.min(1,(ve.clientY-Ve.top)/Ve.height))}},te=(ve,Ve)=>{if(!c.current)return{dnx:0,dny:0};const j=c.current,F=j.getBoundingClientRect(),Q=j.naturalWidth||F.width,K=j.naturalHeight||F.height,ae=Q/K,Te=F.width/F.height;let Ue,$e;return ae>Te?(Ue=F.width,$e=F.width/ae):($e=F.height,Ue=F.height*ae),{dnx:ve/Ue,dny:Ve/$e}},be=(ve,Ve,j)=>{if(j<=1.05)return;const F=-(ve-.5)*100,Q=-(Ve-.5)*100,K=or(F,Q,j);(Math.abs(K.x-_e.current)>.1||Math.abs(K.y-Pe.current)>.1)&&($(K.x),Z(K.y),_e.current=K.x,Pe.current=K.y)},Me=ve=>{const Ve=a.current;if(Ve&&ve.target instanceof Node&&Ve.contains(ve.target))ve.preventDefault();else return;if(ve.touches.length===1){const j=ve.touches[0];W.current={x:j.clientX,y:j.clientY,time:Date.now()},X.current={x:j.clientX,y:j.clientY},xe.current||(he.current=!1),me.current=setTimeout(()=>{if(!he.current&&!xe.current)if(he.current=!0,Ee.current==="mouse"){const F=Ne.current||{nx:.5,ny:.5};_("Right Click"),q(F.nx,F.ny,"right"),D.current("input_click",{...F,button:"right"}).catch(()=>{})}else{const F=se(j);F&&(_("Right Click"),q(F.nx,F.ny,"right"),D.current("input_click",{...F,button:"right"}).catch(()=>{}))}},500)}else if(ve.touches.length===2){clearTimeout(me.current),he.current=!0,xe.current=!0;const j=ve.touches[1].clientX-ve.touches[0].clientX,F=ve.touches[1].clientY-ve.touches[0].clientY;Se.current=Math.sqrt(j*j+F*F),Fe.current=G.current,de.current={x:(ve.touches[0].clientX+ve.touches[1].clientX)/2,y:(ve.touches[0].clientY+ve.touches[1].clientY)/2}}},ze=ve=>{const Ve=a.current;if(Ve&&ve.target instanceof Node&&Ve.contains(ve.target)&&ve.preventDefault(),ve.touches.length===1&&X.current){const j=ve.touches[0],F=j.clientX-X.current.x,Q=j.clientY-X.current.y;if(!he.current&&W.current){const K=j.clientX-W.current.x,ae=j.clientY-W.current.y;Math.sqrt(K*K+ae*ae)>8&&(he.current=!0,clearTimeout(me.current))}if(he.current)if(Ee.current==="mouse"){const K=te(F,Q),ae=Ne.current||{nx:.5,ny:.5},Te=Math.max(0,Math.min(1,ae.nx+K.dnx)),Ue=Math.max(0,Math.min(1,ae.ny+K.dny));Ne.current={nx:Te,ny:Ue},Re({nx:Te,ny:Ue}),_(`Cursor: ${Math.round(Te*100)}%, ${Math.round(Ue*100)}%`),be(Te,Ue,G.current);const $e=Date.now();$e-ne.current>=30&&(ne.current=$e,D.current("input_mouseMoved",{nx:Te,ny:Ue}).catch(()=>{}))}else if(G.current>1){const K=a.current;if(K){const ae=K.clientWidth,Te=K.clientHeight,Ue=_e.current+F/ae*100,$e=Pe.current+Q/Te*100,We=or(Ue,$e,G.current);$(We.x),Z(We.y),_e.current=We.x,Pe.current=We.y}}else{const K=se(j);if(K){const ae=Date.now();ae-ne.current>=40&&(ne.current=ae,_("Scroll"),D.current("input_wheel",{nx:K.nx,ny:K.ny,deltaX:Math.round(-F*2.5),deltaY:Math.round(-Q*2.5)}).catch(()=>{}))}}X.current={x:j.clientX,y:j.clientY}}else if(ve.touches.length===2&&Se.current!==null){const j=ve.touches[1].clientX-ve.touches[0].clientX,F=ve.touches[1].clientY-ve.touches[0].clientY,K=Math.sqrt(j*j+F*F)/Se.current,ae=(ve.touches[0].clientX+ve.touches[1].clientX)/2,Te=(ve.touches[0].clientY+ve.touches[1].clientY)/2,Ue=ae-de.current.x,$e=Te-de.current.y,We=Math.abs(K-1)>.03;if(Ee.current==="mouse"){if(We){const qe=Math.max(et,Math.min(5,Fe.current*K));U(qe),G.current=qe}else if(Math.abs(Ue)>2||Math.abs($e)>2){const qe=Ne.current||{nx:.5,ny:.5},Ge=Date.now();Ge-ne.current>=30&&(ne.current=Ge,_("Scroll"),D.current("input_wheel",{nx:qe.nx,ny:qe.ny,deltaX:Math.round(-Ue*3),deltaY:Math.round(-$e*3)}).catch(()=>{}))}}else{const qe=Math.max(et,Math.min(5,Fe.current*K));U(qe),G.current=qe;const Ge=a.current;if(Ge&&qe>1){const Qt=Ge.clientWidth,Rc=Ge.clientHeight,Mc=_e.current+Ue/Qt*100,Bs=Pe.current+$e/Rc*100,lr=or(Mc,Bs,qe);$(lr.x),Z(lr.y),_e.current=lr.x,Pe.current=lr.y}}de.current={x:ae,y:Te}}},Ot=ve=>{var Ve;if(clearTimeout(me.current),Se.current=null,ve.touches.length===1&&xe.current){const j=ve.touches[0];W.current={x:j.clientX,y:j.clientY,time:Date.now()},X.current={x:j.clientX,y:j.clientY},he.current=!0;return}if(ve.touches.length===0){if(xe.current){xe.current=!1,he.current=!1;return}if(ve.changedTouches.length===1&&!he.current){const j=ve.changedTouches[0],F=Date.now(),Q=F-(((Ve=W.current)==null?void 0:Ve.time)||0);if(Q<60||Q>400){he.current=!1;return}if(W.current){const K=j.clientX-W.current.x,ae=j.clientY-W.current.y;if(Math.sqrt(K*K+ae*ae)>12){he.current=!1;return}}if(Ee.current==="mouse"){const K=Ne.current||se(j);K&&(_(`Click: ${Math.round(K.nx*100)}%, ${Math.round(K.ny*100)}%`),q(K.nx,K.ny,"left"),D.current("input_click",{...K}).catch(()=>{}))}else{const K=se(j);if(!K)return;F-Ce.current<300?(_("Double tap"),q(K.nx,K.ny,"double"),D.current("input_click",{...K,clickCount:2}).catch(()=>{}),Ce.current=0):(_(`Tap: ${Math.round(K.nx*100)}%, ${Math.round(K.ny*100)}%`),q(K.nx,K.ny,"left"),D.current("input_click",{...K}).catch(()=>{}),Ce.current=F)}}he.current=!1}};return V.addEventListener("touchstart",Me,{passive:!1}),V.addEventListener("touchmove",ze,{passive:!1}),V.addEventListener("touchend",Ot,{passive:!1}),()=>{V.removeEventListener("touchstart",Me),V.removeEventListener("touchmove",ze),V.removeEventListener("touchend",Ot),clearTimeout(me.current)}},[]),u.jsxs("div",{ref:l,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:ee,onContextMenu:V=>V.preventDefault(),onFocus:()=>v(!0),onBlur:()=>v(!1),tabIndex:0,children:[u.jsxs("div",{ref:a,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[At?u.jsx("img",{ref:c,src:At,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${z}) translate(${M}%, ${b}%)`,transformOrigin:"center center",cursor:O==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:oe,onContextMenu:V=>V.preventDefault(),onDragStart:V=>V.preventDefault()}):u.jsxs("div",{className:"text-slate-800 text-center",children:[u.jsx("div",{className:"text-5xl mb-3",children:"🌑"}),u.jsx("div",{className:"text-[13px] font-semibold",children:"Connecting to Host..."})]}),O==="mouse"&&Le&&At&&c.current&&(()=>{var Ue;const V=c.current,se=V.getBoundingClientRect(),te=(Ue=a.current)==null?void 0:Ue.getBoundingClientRect();if(!te)return null;const be=V.naturalWidth||se.width,Me=V.naturalHeight||se.height,ze=be/Me,Ot=se.width/se.height;let ve,Ve,j,F;ze>Ot?(ve=se.width,Ve=se.width/ze,j=0,F=(se.height-Ve)/2):(Ve=se.height,ve=se.height*ze,j=(se.width-ve)/2,F=0);const Q=se.left-te.left+j+ve*Le.nx,K=se.top-te.top+F+Ve*Le.ny,ae=Math.max(8,Math.min(te.width-8,Q)),Te=Math.max(8,Math.min(te.height-8,K));return u.jsxs("div",{style:{position:"absolute",left:ae-8,top:Te-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[u.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})})(),y.map(V=>{const te={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[V.type];return u.jsxs("div",{style:{position:"absolute",left:V.x,top:V.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[u.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${te}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),u.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${te}, 0.9)`,boxShadow:`0 0 12px rgba(${te}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},V.id)})]}),u.jsxs("div",{onTouchStart:V=>V.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-[1000] flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[u.jsxs("div",{onClick:()=>{I(V=>{const se=V==="touch"?"mouse":"touch";if(se==="mouse"&&!Ne.current){const te={nx:.5,ny:.5};Ne.current=te,Re(te)}return se})},className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${O==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[u.jsx("span",{className:"text-sm",children:O==="mouse"?"🖱️":"👆"}),u.jsx("span",{className:`text-[10px] font-bold ${O==="mouse"?"text-blue-400":"text-slate-400"}`,children:O==="mouse"?"Mouse":"Touch"})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{onClick:()=>{A(!N),P(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${N?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⌨️"})}),N&&u.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-[2000]",style:{animation:"slideUp 0.15s ease-out"},children:u.jsx("input",{type:"text",placeholder:"Type & Enter...",value:w,autoFocus:!0,onTouchStart:V=>V.stopPropagation(),onChange:V=>g(V.target.value),onKeyDown:ce,className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),u.jsx("div",{className:"relative",children:u.jsx("div",{onClick:()=>{P(!E),A(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${E?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⚙️"})})}),u.jsx("div",{className:"w-px h-[18px] bg-white/10"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:ye?"rgba(16,185,129,0.12)":"rgba(251,191,36,0.12)"},children:[u.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:ye?"#10b981":"#fbbf24"}}),u.jsx("span",{className:"text-[8px] font-extrabold",style:{color:ye?"#10b981":"#fbbf24"},children:ye?"Connected":"WS"})]}),z>1&&u.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(z*100),"%"]}),m&&u.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:m})]})]}),E&&u.jsxs("div",{onTouchStart:V=>V.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:1001,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[u.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",z<=(k?R:1)+.01?k?"FILL":"FIT":`${Math.round(z*100)}%`]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:V=>{V.stopPropagation(),U(se=>Math.max(.5,se-.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),u.jsx("button",{onClick:V=>{V.stopPropagation();const se=k?R:1;U(se),G.current=se,$(0),Z(0)},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:k?"FILL":"FIT"}),u.jsx("button",{onClick:V=>{V.stopPropagation(),U(se=>Math.min(5,se+.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]}),u.jsx("button",{onClick:V=>{var be;V.stopPropagation();const se=((be=l.current)==null?void 0:be.clientWidth)||0,te=se>0?Math.max(400,Math.ceil(se/100)*100):void 0;r(te)},style:{width:"100%",background:"#3b82f6",color:"#fff",border:"none",padding:"8px",borderRadius:6,fontSize:11,fontWeight:800,cursor:"pointer"},children:"FORCE SYNC"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(255,255,255,0.05)",padding:"6px 10px",borderRadius:6},children:[u.jsx("span",{style:{fontSize:10,color:"#888",fontWeight:700},children:"AUTO REF."}),u.jsx("input",{type:"checkbox",checked:d,onChange:V=>h(V.target.checked)})]}),u.jsxs("select",{value:f,onChange:V=>p(Number(V.target.value)),style:{background:"rgba(255,255,255,0.05)",color:"#fff",border:"none",borderRadius:6,padding:"6px",fontSize:10,fontWeight:600,outline:"none"},children:[u.jsx("option",{value:500,children:"0.5s Interval"}),u.jsx("option",{value:1e3,children:"1.0s Interval"}),u.jsx("option",{value:2e3,children:"2.0s Interval"}),u.jsx("option",{value:4e3,children:"4.0s Interval"})]})]}),u.jsx("style",{children:`
154
154
  @keyframes slideUp {
155
155
  from { opacity: 0; transform: translateY(6px); }
156
156
  to { opacity: 1; transform: translateY(0); }
@@ -169,7 +169,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
169
169
  100% { transform: scale(0.5); opacity: 0; }
170
170
  }
171
171
  `})]})}function fR({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=x.useRef(null),m=x.useCallback(_=>{if(!n||!o||!p.current)return;const w=p.current,g=w.getBoundingClientRect(),v=(_.clientX-g.left)/g.width*w.naturalWidth,y=(_.clientY-g.top)/g.height*w.naturalHeight;o(v,y,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 M1({activeConv:e,onModalButton:t}){const[r,n]=x.useState(null);if(x.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(B0,{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 pR({ideId:e,ideType:t,agentType:r,agentName:n,serverModel:i,serverMode:s,acpConfigOptions:o,acpModes:l}){var Y;const{sendCommand:a}=hi(),c=!!(o||l),d=`${e}:${r}`,h=Pr.get(d),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[w,g]=x.useState((h==null?void 0:h.models)||[]),[v,y]=x.useState((h==null?void 0:h.modes)||[]),S=D=>D?typeof D=="string"?D:typeof D=="object"?D.name||D.id||JSON.stringify(D):String(D):"",[L,E]=x.useState(S(i)),[P,N]=x.useState(S(s)),[A,k]=x.useState(!1),[O,I]=x.useState(!1),R=x.useRef(0),C=D=>D.map(W=>typeof W=="string"?W:(W==null?void 0:W.name)||(W==null?void 0:W.id)||String(W));x.useEffect(()=>{if(o){const D=o.find(W=>W.category==="model");if(D){const W=C(D.options.map(he=>he.value));g(W),D.currentValue&&E(S(D.currentValue));const X=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...X,models:W})}}if(l&&l.length>0){const D=C(l.map(X=>X.id));y(D);const W=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...W,modes:D})}else if(o){const D=o.find(W=>W.category!=="model");if(D){const W=C(D.options.map(he=>he.value));y(W),D.currentValue&&N(S(D.currentValue));const X=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...X,modes:W})}}},[o,l,d]),x.useEffect(()=>{p(!1),_(!1),E(S(i)),N(S(s));const D=Pr.get(d);D?(g(D.models),y(D.modes)):(g([]),y([]))},[e,r]),x.useEffect(()=>{i&&Date.now()>R.current&&E(S(i))},[i]),x.useEffect(()=>{s&&Date.now()>R.current&&N(S(s))},[s]);const B=x.useCallback(async(D,W={})=>{const X={...W},he=e.split(":");return he.length>=3&&(he[1]==="ide"||he[1]==="cli"||he[1]==="acp")&&(X._targetInstance=he.slice(2).join(":"),X._targetType=he[1]),await a(e,D,X)},[e]),z=async()=>{var D,W;if(w.length>0){p(!f);return}if(c){p(!0);return}k(!0);try{const X=await B("list_extension_models",{agentType:r,ideType:t}),he=(X==null?void 0:X.models)||((D=X==null?void 0:X.result)==null?void 0:D.models)||[],me=C(he);g(me),X!=null&&X.current&&E(S(X.current)),(W=X==null?void 0:X.result)!=null&&W.current&&E(S(X.result.current));const Ce=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...Ce,models:me}),p(!0)}catch{}finally{k(!1)}},U=async()=>{var D,W;if(v.length>0){_(!m);return}if(c){_(!0);return}I(!0);try{const X=await B("list_extension_modes",{agentType:r,ideType:t}),he=(X==null?void 0:X.modes)||((D=X==null?void 0:X.result)==null?void 0:D.modes)||[],me=C(he);y(me),X!=null&&X.current&&N(S(X.current)),(W=X==null?void 0:X.result)!=null&&W.current&&N(S(X.result.current));const Ce=Pr.get(d)||{models:[],modes:[]};Pr.set(d,{...Ce,modes:me}),_(!0)}catch{}finally{I(!1)}},M=async D=>{p(!1),E(D),R.current=Date.now()+5e3;try{c?await B("change_model",{agentType:r,ideType:t,model:D}):await B("set_extension_model",{agentType:r,ideType:t,model:D})}catch{}},$=c&&!(l&&l.length>0)&&(o==null?void 0:o.some(D=>D.category!=="model")),b=$?(Y=o==null?void 0:o.find(D=>D.category!=="model"))==null?void 0:Y.configId:void 0,Z=async D=>{_(!1),N(D),R.current=Date.now()+5e3;try{c&&$&&b?await B("set_thought_level",{agentType:r,ideType:t,configId:b,value:D}):c?await B("set_mode",{agentType:r,ideType:t,mode:D}):await B("set_extension_mode",{agentType:r,ideType:t,mode:D})}catch{}},T={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:T},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?`${T}55`:"transparent",border:"1px solid",color:L?"var(--text-primary)":"var(--text-muted)"},onClick:z,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),A?"...":L||"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(D=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:D===L?`${T}18`:"transparent",color:D===L?T:"var(--text-secondary)",fontWeight:D===L?600:400,borderLeft:D===L?`2px solid ${T}`:"2px solid transparent"},onMouseEnter:W=>{W.currentTarget.style.background=`${T}12`},onMouseLeave:W=>{W.currentTarget.style.background=D===L?`${T}18`:"transparent"},onClick:()=>M(D),children:D},D))]})]})]}),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?`${T}55`:"transparent",border:"1px solid",color:P?"var(--text-primary)":"var(--text-muted)"},onClick:U,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:$?"🧠":"⚡"}),O?"...":P||($?"Thinking":"Mode"),u.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),m&&v.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>_(!1)}),u.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[u.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:$?"SELECT THINKING LEVEL":"SELECT MODE"}),v.map(D=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:D===P?`${T}18`:"transparent",color:D===P?T:"var(--text-secondary)",fontWeight:D===P?600:400,borderLeft:D===P?`2px solid ${T}`:"2px solid transparent"},onMouseEnter:W=>{W.currentTarget.style.background=`${T}12`},onMouseLeave:W=>{W.currentTarget.style.background=D===P?`${T}18`:"transparent"},onClick:()=>Z(D),children:D},D))]})]})]})]})}const oi=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),cn=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function j1({activeConv:e,ides:t,agentInput:r,setAgentInput:n,handleSendChat:i,handleFocusAgent:s,isFocusingAgent:o,messageReceivedAt:l,actionLogs:a,userName:c}){const d=x.useRef(null),{sendCommand:h}=hi(),[f,p]=x.useState([]),[m,_]=x.useState(0),[w,g]=x.useState(!0),[v,y]=x.useState(!1),S=x.useRef("");e.tabKey!==S.current&&(S.current=e.tabKey,p([]),_(0),g(!0));const L=x.useCallback(async()=>{var N,A,k,O,I,R;if(!(v||!w)){y(!0);try{const C=t.find(b=>b.id===e.ideId),B=(C==null?void 0:C.daemonId)||((N=e.ideId)==null?void 0:N.split(":")[0])||"";if(!B){g(!1);return}const z=e.ideType||e.agentType||"",U=(e.ideId||"").split(":"),M=U.length>=3?U.slice(2).join(":"):void 0;console.log("[ChatPane] requestChatHistory:",{daemonId:B,agentType:z,instanceId:M,offset:m});const $=await h(B,"chat_history",{agentType:z,offset:m,limit:30,instanceId:M});console.log("[ChatPane] got result:",{count:((A=$.messages)==null?void 0:A.length)||0,hasMore:$.hasMore}),((k=$.messages)==null?void 0:k.length)>0&&(p(b=>[...$.messages,...b]),_(b=>b+$.messages.length)),g($.hasMore)}catch(C){console.warn("[ChatPane] Failed to load history:",C),!((O=C==null?void 0:C.message)!=null&&O.includes("P2P not available"))&&!((I=C==null?void 0:C.message)!=null&&I.includes("channel not open"))&&!((R=C==null?void 0:C.message)!=null&&R.includes("P2P not connected"))&&g(!1)}finally{y(!1)}}},[v,w,m,t,e]),E=x.useRef(0);x.useEffect(()=>{if(e.messages.length<10&&w&&!v&&f.length===0){const N=E.current;if(N>8)return;const k=setTimeout(()=>{E.current=N+1,L()},N===0?500:3e3);return()=>clearTimeout(k)}else f.length>0&&(E.current=0)},[e.tabKey,e.messages.length,w,v,f.length,L]);const P=(()=>{const N=e.messages.map((O,I)=>{const R=`${e.ideId}-${O.id??`i-${I}`}`;return{...O,receivedAt:O.receivedAt||l[R]||0}});if(f.length===0)return N;const A=new Set(N.map(O=>`${O.role}:${(O.content||"").slice(0,100)}`));return[...f.filter(O=>!A.has(`${O.role}:${(O.content||"").slice(0,100)}`)),...N]})();return u.jsxs(u.Fragment,{children:[u.jsx(qP,{messages:P,actionLogs:a.filter(N=>N.ideId===e.tabKey).sort((N,A)=>N.timestamp-A.timestamp),agentName:e.agentName||e.displayPrimary||"Agent",userName:c,isCliMode:oi(e)||cn(e),isWorking:e.status==="working",contextKey:e.tabKey,onLoadMore:L,isLoadingMore:v,hasMoreHistory:w,emptyState:e.messages.length===0?e.status==="not_monitored"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-3xl opacity-60",children:u.jsx(O0,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Switching...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(qa,{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(OP,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Panel is not visible in IDE"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Opening...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(qa,{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}),!oi(e)&&(()=>{var A,k,O,I;const N=t.find(R=>R.id===e.ideId);return u.jsx(pR,{ideId:e.ideId,ideType:e.ideType,agentType:e.streamSource==="agent-stream"?e.agentType:((k=(A=N==null?void 0:N.agents)==null?void 0:A[0])==null?void 0:k.type)||e.ideType,agentName:e.streamSource==="agent-stream"?e.agentName:((I=(O=N==null?void 0:N.agents)==null?void 0:O[0])==null?void 0:I.name)||e.agentName,serverModel:(N==null?void 0:N.currentModel)||void 0,serverMode:(N==null?void 0:N.currentPlan)||void 0,acpConfigOptions:cn(e)?N==null?void 0:N.acpConfigOptions:void 0,acpModes:cn(e)?N==null?void 0:N.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:N=>n(N.target.value),onPaste:N=>{const A=N.clipboardData.getData("text");A&&n(k=>k+A),N.preventDefault()},onKeyDown:N=>{if(N.key==="Enter"){if(N.nativeEvent.isComposing){N.preventDefault();return}N.preventDefault(),i()}},onBlur:N=>{if(window.innerWidth<768){const A=N.relatedTarget;if((A==null?void 0:A.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary 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 Ou=new Set,I1={emit(e,t){for(const r of Ou)r(e,t)},on(e){return Ou.add(e),()=>{Ou.delete(e)}}};function mR({activeConv:e,ptyBuffers:t,terminalRef:r,agentInput:n,setAgentInput:i,handleSendChat:s,handleModalButton:o}){var p;const l=x.useRef(null),{sendCommand:a,sendData:c}=hi(),d=(p=e.ideId)!=null&&p.includes(":cli:")?e.ideId.split(":cli:")[1]:"",h=e.tabKey,f=e.ideType||e.agentType||"";return x.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]),x.useEffect(()=>{const m=I1.on((_,w)=>{var v;if(!w)return;(_===d||_===f)&&((v=r.current)==null||v.write(w))});return()=>{m()}},[d,f]),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--surface-primary)] border-b border-border-subtle shrink-0",children:[u.jsx("div",{className:"flex gap-1",children:u.jsx("div",{className:"px-3 py-1 rounded-md text-[11px] font-semibold bg-accent text-white",children:"⬛ Terminal"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"text-[10px] text-text-muted",children:[e.agentName," — Terminal"]}),u.jsx("button",{onClick:()=>{if(!r.current||!e)return;const m=t.current.get(e.tabKey);if(m&&m.length>0)for(const _ of m)r.current.write(_);requestAnimationFrame(()=>{requestAnimationFrame(()=>{var _;(_=r.current)==null||_.bumpResize()})})},title:"Refresh terminal (replay buffer + TUI redraw)",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-bg-secondary text-text-secondary border border-border-subtle cursor-pointer leading-none",children:"↺"}),u.jsx("button",{onClick:async()=>{var w;const m=(w=e.ideId)!=null&&w.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";if(!window.confirm(`Stop ${m}?
172
- This will terminate the CLI process.`))return;const _=e.ideId||e.daemonId||"";try{await a(_,"stop_cli",{cliType:m})}catch(g){console.error("Stop CLI failed:",g)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),u.jsx(M1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(R1,{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 gR({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 _R=Vo;function Lc(){return _R()}class vR{constructor(){Os(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 xR=new vR;class yR{constructor(){Os(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 yR,L_=yr;const zu=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),$u=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function bR({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=Tn(),o=Lc(),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(Va,{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&&!zu(e)&&!$u(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm border-none px-2.5 py-1.5 flex items-center gap-1 text-xs",title:"IDE View",children:[u.jsx(z0,{size:14})," IDE"]}),e&&!zu(e)&&!$u(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5 flex items-center gap-1",title:"Chat History",children:u.jsx(DP,{size:16})}),e&&!zu(e)&&!$u(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5",title:"Remote Control",children:u.jsx(ul,{size:16})})]})]})}function Dr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function wR(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 M_(e){return(e.id||"").includes(":cli:")}function j_(e){return(e.id||"").includes(":acp:")}function Bd(e,t){return Dr(e)}function SR(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 kR({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," — ",Dr(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(WP,{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(BP,{size:13})," Refresh History"]})})})]})]})}const I_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function CR({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:I_[n.type]||I_.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 ER=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function NR(e){return e.workspace||""}function TR(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,y,S;const l=[],a=o.daemonId&&i[o.daemonId]||void 0,c=o.daemonId||((w=o.id)==null?void 0:w.split(":")[0])||o.id,d=n?n[c]||"new":void 0,h=NR(o),f=Dr(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(L=>({...L,activeModal:L.activeModal??void 0})):[],_=ER(o);if(_){const L=Bd(o.type),E=(g=o.agents)==null?void 0:g[0],P=(v=o.activeChat)==null?void 0:v.activeModal,N=P&&Array.isArray(P.buttons)&&P.buttons.length>0,A=(y=o.activeChat)==null?void 0:y.status,k=A==="generating"||A==="loading"||A&&A.toLowerCase()==="thinking",I=N||A==="waiting_approval"?"waiting_approval":k?"working":(E==null?void 0:E.status)||"idle",R=o.activeChat||{title:"",messages:[]};let C=R.title&&String(R.title).trim()?String(R.title).trim():"";const B=(S=o.activeChat)==null?void 0:S.id,z=o.chats;if(B&&Array.isArray(z)&&z.length>0){const Z=z.find(ne=>ne.id===B||ne.id&&String(ne.id)===String(B));Z!=null&&Z.title&&String(Z.title).trim()&&(C=String(Z.title).trim())}const U=R.messages||[],M=t[o.id]||[],$=new Map;U.filter(Z=>Z.role==="user").forEach(Z=>{$.set(Z.content,($.get(Z.content)||0)+1)});const b=M.filter(Z=>{const ne=$.get(Z.content)||0;return ne>0?($.set(Z.content,ne-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:L,agentType:oi(o)||cn(o)?o.type:(E==null?void 0:E.type)||"ide-native",status:I,title:C,messages:[...U,...b],ideType:o.type,workspaceName:h,displayPrimary:C||h||L,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:N?P.buttons:void 0,modalMessage:N?P.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(oi(o)||cn(o)))return l;for(const L of m){const E=L.activeModal&&Array.isArray(L.activeModal.buttons)&&L.activeModal.buttons.length>0,P=E?"waiting_approval":L.status==="streaming"?"working":L.status,N=`${o.id}:${L.agentType}`,A=L.messages||[],k=t[N]||[],O=new Map;A.filter(R=>R.role==="user").forEach(R=>{O.set(R.content,(O.get(R.content)||0)+1)});const I=k.filter(R=>{const C=O.get(R.content)||0;return C>0?(O.set(R.content,C-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:L.agentName,agentType:L.agentType,status:P,title:"",messages:[...A,...I],ideType:o.type,workspaceName:h,displayPrimary:h||L.agentName,displaySecondary:`${f}·${L.agentName}`,cdpConnected:o.cdpConnected,modalButtons:E?L.activeModal.buttons:void 0,modalMessage:E?L.activeModal.message:void 0,streamSource:"agent-stream",tabKey:N,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Bd(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 PR(e,t){var l,a,c,d;const r=[],{daemonId:n,existingDaemon:i,timestamp:s}=t,o=s||e.timestamp||Date.now();r.push({...i||{},id:n,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...e.version&&{version:e.version},...e.machine&&{machine:e.machine,platform:e.machine.platform},...e.instanceId&&{instanceId:e.instanceId},...e.machineNickname!==void 0&&{machineNickname:e.machineNickname},...e.p2p&&{p2p:e.p2p},..."system"in e&&{system:e.system},..."hostname"in e&&{hostname:e.hostname},...e.workspaces&&{workspaces:e.workspaces},...e.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:e.defaultWorkspaceId},...e.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:e.defaultWorkspacePath},...e.workspaceActivity&&{workspaceActivity:e.workspaceActivity},...e.detectedIdes&&{detectedIdes:e.detectedIdes},..."availableProviders"in e&&{availableProviders:e.availableProviders},cdpConnected:e.managedIdes.some(h=>h.cdpConnected),managedIdeIds:e.managedIdes.map(h=>`${n}:ide:${h.instanceId}`),managedCliIds:e.managedClis.map(h=>h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`),managedAcpIds:e.managedAcps.map(h=>h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`)});for(const h of e.managedIdes)r.push({id:`${n}:ide:${h.instanceId}`,type:h.ideType,ideType:h.ideType,version:h.ideVersion,status:h.cdpConnected?"online":"detected",daemonId:n,instanceId:h.instanceId,workspace:h.workspace,terminals:h.terminals,agents:h.aiAgents,activeChat:h.activeChat,chats:h.chats,agentStreams:h.agentStreams,cdpConnected:h.cdpConnected,currentModel:h.currentModel,currentPlan:h.currentPlan,currentAutoApprove:h.currentAutoApprove,timestamp:o});for(const h of e.managedClis){const f=h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`;r.push({id:f,type:h.cliType,ideType:h.cliType,agentType:h.cliType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.cliName,mode:h.mode||"terminal",workspace:h.workspace,activeChat:h.activeChat,agentStreams:[{agentType:h.cliType,agentName:h.cliName,extensionId:"cli-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((l=h.activeChat)==null?void 0:l.messages)||[],inputContent:"",activeModal:(a=h.activeChat)==null?void 0:a.activeModal}],timestamp:o,_isCli:!0})}for(const h of e.managedAcps){const f=h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`;r.push({id:f,type:h.acpType,ideType:h.acpType,agentType:h.acpType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.acpName,mode:"chat",workspace:h.workspace,activeChat:h.activeChat,currentModel:h.currentModel,currentPlan:h.currentPlan,acpConfigOptions:h.acpConfigOptions,acpModes:h.acpModes,agentStreams:[{agentType:h.acpType,agentName:h.acpName,extensionId:"acp-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((c=h.activeChat)==null?void 0:c.messages)||[],inputContent:"",activeModal:(d=h.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isAcp:!0})}return r}function D1(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=D1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function LR(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=D1(e))&&(n&&(n+=" "),n+=t);return n}const RR=(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},MR=(e,t)=>({classGroupId:e,validator:t}),A1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ec="-",D_=[],jR="arbitrary..",IR=e=>{const t=AR(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return DR(o);const l=o.split(ec),a=l[0]===""&&l.length>1?1:0;return B1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?RR(c,a):a:c||D_}return r[o]||D_}}},B1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=B1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(ec):e.slice(t).join(ec),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},DR=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?jR+n:void 0})(),AR=e=>{const{theme:t,classGroups:r}=e;return BR(r,t)},BR=(e,t)=>{const r=A1();for(const n in e){const i=e[n];pp(i,r,n,t)}return r},pp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];OR(o,t,r,n)}},OR=(e,t,r,n)=>{if(typeof e=="string"){zR(e,t,r);return}if(typeof e=="function"){$R(e,t,r,n);return}FR(e,t,r,n)},zR=(e,t,r)=>{const n=e===""?t:O1(t,e);n.classGroupId=r},$R=(e,t,r,n)=>{if(WR(e)){pp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(MR(r,e))},FR=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];pp(a,O1(t,l),r,n)}},O1=(e,t)=>{let r=e;const n=t.split(ec),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=A1(),r.nextPart.set(o,l)),r=l}return r},WR=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,HR=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="!",A_=":",UR=[],B_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),KR=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===A_){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 B_(s,p,f,m)};if(t){const i=t+A_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):B_(UR,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},VR=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}},qR=e=>({cache:HR(e.cacheSize),parseClassName:KR(e),sortModifiers:VR(e),...IR(e)}),YR=/\s+/,XR=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(YR);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(":"),y=p?v+Od:v,S=y+g;if(o.indexOf(S)>-1)continue;o.push(S);const L=i(g,w);for(let E=0;E<L.length;++E){const P=L[E];o.push(y+P)}a=d+(a.length>0?" "+a:a)}return a},GR=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=z1(r))&&(i&&(i+=" "),i+=n);return i},z1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=z1(e[n]))&&(r&&(r+=" "),r+=t);return r},QR=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=qR(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=XR(a,r);return i(a,d),d};return s=o,(...a)=>s(GR(...a))},JR=[],Ct=e=>{const t=r=>r[e]||JR;return t.isThemeGetter=!0,t},$1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,F1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZR=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tM=/\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$/,rM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,iM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=e=>ZR.test(e),De=e=>!!e&&!Number.isNaN(Number(e)),On=e=>!!e&&Number.isInteger(Number(e)),Fu=e=>e.endsWith("%")&&De(e.slice(0,-1)),fn=e=>eM.test(e),W1=()=>!0,sM=e=>tM.test(e)&&!rM.test(e),mp=()=>!1,oM=e=>nM.test(e),lM=e=>iM.test(e),aM=e=>!pe(e)&&!ge(e),cM=e=>fi(e,K1,mp),pe=e=>$1.test(e),gi=e=>fi(e,V1,sM),O_=e=>fi(e,_M,De),uM=e=>fi(e,Y1,W1),hM=e=>fi(e,q1,mp),z_=e=>fi(e,H1,mp),dM=e=>fi(e,U1,lM),Hl=e=>fi(e,X1,oM),ge=e=>F1.test(e),to=e=>Vi(e,V1),fM=e=>Vi(e,q1),$_=e=>Vi(e,H1),pM=e=>Vi(e,K1),mM=e=>Vi(e,U1),Ul=e=>Vi(e,X1,!0),gM=e=>Vi(e,Y1,!0),fi=(e,t,r)=>{const n=$1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vi=(e,t,r=!1)=>{const n=F1.exec(e);return n?n[1]?t(n[1]):r:!1},H1=e=>e==="position"||e==="percentage",U1=e=>e==="image"||e==="url",K1=e=>e==="length"||e==="size"||e==="bg-size",V1=e=>e==="length",_M=e=>e==="number",q1=e=>e==="family-name",Y1=e=>e==="number"||e==="weight",X1=e=>e==="shadow",vM=()=>{const e=Ct("color"),t=Ct("font"),r=Ct("text"),n=Ct("font-weight"),i=Ct("tracking"),s=Ct("leading"),o=Ct("breakpoint"),l=Ct("container"),a=Ct("spacing"),c=Ct("radius"),d=Ct("shadow"),h=Ct("inset-shadow"),f=Ct("text-shadow"),p=Ct("drop-shadow"),m=Ct("blur"),_=Ct("perspective"),w=Ct("aspect"),g=Ct("ease"),v=Ct("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...S(),ge,pe],E=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],N=()=>[ge,pe,a],A=()=>[Bn,"full","auto",...N()],k=()=>[On,"none","subgrid",ge,pe],O=()=>["auto",{span:["full",On,ge,pe]},On,ge,pe],I=()=>[On,"auto",ge,pe],R=()=>["auto","min","max","fr",ge,pe],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...N()],U=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],M=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...N()],$=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...N()],b=()=>[e,ge,pe],Z=()=>[...S(),$_,z_,{position:[ge,pe]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",pM,cM,{size:[ge,pe]}],Y=()=>[Fu,to,gi],D=()=>["","none","full",c,ge,pe],W=()=>["",De,to,gi],X=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[De,Fu,$_,z_],Ce=()=>["","none",m,ge,pe],Se=()=>["none",De,ge,pe],Fe=()=>["none",De,ge,pe],de=()=>[De,ge,pe],xe=()=>[Bn,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[fn],breakpoint:[fn],color:[W1],container:[fn],"drop-shadow":[fn],ease:["in","out","in-out"],font:[aM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[fn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[fn],shadow:[fn],spacing:["px",De],text:[fn],"text-shadow":[fn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,pe,ge,w]}],container:["container"],columns:[{columns:[De,pe,ge,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:L()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[On,"auto",ge,pe]}],basis:[{basis:[Bn,"full","auto",l,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,Bn,"auto","initial","none",pe]}],grow:[{grow:["",De,ge,pe]}],shrink:[{shrink:["",De,ge,pe]}],order:[{order:[On,"first","last","none",ge,pe]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:O()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pbs:[{pbs:N()}],pbe:[{pbe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"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",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],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,to,gi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,gM,uM]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fu,pe]}],"font-family":[{font:[fM,hM,t]}],"font-features":[{"font-features":[pe]}],"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,pe]}],"line-clamp":[{"line-clamp":[De,"none",ge,O_]}],leading:[{leading:[s,...N()]}],"list-image":[{"list-image":["none",ge,pe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ge,pe]}],"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:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",ge,gi]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[De,"auto",ge,pe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ge,pe]}],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,pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},On,ge,pe],radial:["",ge,pe],conic:[On,ge,pe]},mM,dM]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:D()}],"rounded-s":[{"rounded-s":D()}],"rounded-e":[{"rounded-e":D()}],"rounded-t":[{"rounded-t":D()}],"rounded-r":[{"rounded-r":D()}],"rounded-b":[{"rounded-b":D()}],"rounded-l":[{"rounded-l":D()}],"rounded-ss":[{"rounded-ss":D()}],"rounded-se":[{"rounded-se":D()}],"rounded-ee":[{"rounded-ee":D()}],"rounded-es":[{"rounded-es":D()}],"rounded-tl":[{"rounded-tl":D()}],"rounded-tr":[{"rounded-tr":D()}],"rounded-br":[{"rounded-br":D()}],"rounded-bl":[{"rounded-bl":D()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...X(),"hidden","none"]}],"divide-style":[{divide:[...X(),"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:[...X(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,ge,pe]}],"outline-w":[{outline:["",De,to,gi]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,Ul,Hl]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,Ul,Hl]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[De,gi]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,Ul,Hl]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[De,ge,pe]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[ge,pe]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ge,pe]}],filter:[{filter:["","none",ge,pe]}],blur:[{blur:Ce()}],brightness:[{brightness:[De,ge,pe]}],contrast:[{contrast:[De,ge,pe]}],"drop-shadow":[{"drop-shadow":["","none",p,Ul,Hl]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",De,ge,pe]}],"hue-rotate":[{"hue-rotate":[De,ge,pe]}],invert:[{invert:["",De,ge,pe]}],saturate:[{saturate:[De,ge,pe]}],sepia:[{sepia:["",De,ge,pe]}],"backdrop-filter":[{"backdrop-filter":["","none",ge,pe]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[De,ge,pe]}],"backdrop-contrast":[{"backdrop-contrast":[De,ge,pe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,ge,pe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,ge,pe]}],"backdrop-invert":[{"backdrop-invert":["",De,ge,pe]}],"backdrop-opacity":[{"backdrop-opacity":[De,ge,pe]}],"backdrop-saturate":[{"backdrop-saturate":[De,ge,pe]}],"backdrop-sepia":[{"backdrop-sepia":["",De,ge,pe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ge,pe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",ge,pe]}],ease:[{ease:["linear","initial",g,ge,pe]}],delay:[{delay:[De,ge,pe]}],animate:[{animate:["none",v,ge,pe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,ge,pe]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Se()}],"rotate-x":[{"rotate-x":Se()}],"rotate-y":[{"rotate-y":Se()}],"rotate-z":[{"rotate-z":Se()}],scale:[{scale:Fe()}],"scale-x":[{"scale-x":Fe()}],"scale-y":[{"scale-y":Fe()}],"scale-z":[{"scale-z":Fe()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ge,pe,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"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,pe]}],"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":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mbs":[{"scroll-mbs":N()}],"scroll-mbe":[{"scroll-mbe":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pbs":[{"scroll-pbs":N()}],"scroll-pbe":[{"scroll-pbe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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,pe]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[De,to,gi,O_]}],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"]}},xM=QR(vM);function Jo(...e){return xM(LR(e))}function yM({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Jo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Qi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Jo("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 bM({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Jo("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 wM={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"},SM={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function kM({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Jo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",wM[e],r),children:[u.jsx("span",{className:Jo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",SM[e])}),n]})}function CM(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function F_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function Wu(e){return e==="system"?CM():e}function EM(){const[e,t]=x.useState(F_),[r,n]=x.useState(()=>Wu(F_()));x.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),x.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=x.useCallback(o=>{t(o),n(Wu(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=x.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(Wu(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}const W_={dark:"Dark",light:"Light",system:"System"};function NM({collapsed:e}){const{preference:t,cycleTheme:r}=EM(),n=t==="dark"?u.jsx(UP,{size:16}):t==="light"?u.jsx(HP,{size:16}):u.jsx(KP,{size:16});return u.jsxs("div",{className:`nav-item cursor-pointer ${e?"justify-center py-2.5 px-0":""}`,onClick:r,title:`Theme: ${W_[t]} (click to cycle)`,children:[u.jsx("span",{className:"nav-icon",children:n}),!e&&u.jsx("span",{className:"text-xs",children:W_[t]})]})}function Zi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}const G1="adhdev_notification_prefs",H_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function TM(){try{const e=localStorage.getItem(G1);if(e){const t=JSON.parse(e);return{...H_,...t}}}catch{}return{...H_}}function PM(e){try{localStorage.setItem(G1,JSON.stringify(e))}catch{}}let vn=TM(),pa=[];function LM(){pa.forEach(e=>e())}function RM(e){vn={...vn,...e},PM(vn),LM()}function MM(){const[,e]=x.useState(0);x.useEffect(()=>{const r=()=>e(n=>n+1);return pa.push(r),()=>{pa=pa.filter(n=>n!==r)}},[]);const t=x.useCallback(r=>{RM(r)},[]);return[{...vn},t]}function Hu(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}}function jM({onPrefChange:e}){const[t,r]=MM(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Zi,{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(Zi,{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(Zi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Zi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Zi,{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 IM({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(bM,{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(BM,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function U_({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 hy.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 DM={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 AM(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return DM[t]||{icon:"📝",name:e}}function BM({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var B,z,U,M;const[s,o]=x.useState("idle"),[l,a]=x.useState(""),[c,d]=x.useState(null),[h,f]=x.useState("idle"),[p,m]=x.useState(""),_=e,w=_.version||_.daemonVersion||null,g=((B=_.machine)==null?void 0:B.hostname)||((z=_.system)==null?void 0:z.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((M=_.system)==null?void 0:M.platform)||"",y=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",L=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),E=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),P=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),N=_.p2p,A=async()=>{var $,b,Z;if(r){o("upgrading"),a("Installing latest version...");try{const ne=await r(e.id,"daemon_upgrade",{});($=ne==null?void 0:ne.result)!=null&&$.upgraded||(b=ne==null?void 0:ne.result)!=null&&b.success?(o("done"),a(`Upgraded to v${ne.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((Z=ne==null?void 0:ne.result)==null?void 0:Z.error)||"Upgrade failed"))}catch(ne){o("error"),a((ne==null?void 0:ne.message)||"Connection lost during upgrade")}}},k=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},O=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},I="0.5.55",R=!w||w!==I,C=L.length+E.length+P.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:y}),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] ${R?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!R&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&R&&u.jsx("button",{onClick:A,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${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(kM,{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:[N&&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 ${N.state==="connected"?"bg-green-400":N.state==="connecting"||N.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",N.state==="connected"?"connected":N.state==="connecting"||N.state==="new"?"connecting...":N.state||"off"]}),N.peers!==void 0&&N.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",N.peers," peer",N.peers!==1?"s":"",")"]})]}),N&&C>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[L.map($=>{const b=AM($.type),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}),Z!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Z?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:Z?"CDP connected":"CDP connecting..."})]},$.id)}),E.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),P.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(U_,{title:"🔌 Disconnect Machine",message:`Disconnect "${y}" from ADHDev?
172
+ This will terminate the CLI process.`))return;const _=e.ideId||e.daemonId||"";try{await a(_,"stop_cli",{cliType:m})}catch(g){console.error("Stop CLI failed:",g)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),u.jsx(M1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(R1,{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 gR({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 _R=Vo;function Lc(){return _R()}class vR{constructor(){Os(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 xR=new vR;class yR{constructor(){Os(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 yR,L_=yr;const zu=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),$u=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function bR({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=Tn(),o=Lc(),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(Va,{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&&!zu(e)&&!$u(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm border-none px-2.5 py-1.5 flex items-center gap-1 text-xs",title:"IDE View",children:[u.jsx(z0,{size:14})," IDE"]}),e&&!zu(e)&&!$u(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5 flex items-center gap-1",title:"Chat History",children:u.jsx(DP,{size:16})}),e&&!zu(e)&&!$u(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5",title:"Remote Control",children:u.jsx(ul,{size:16})})]})]})}function Dr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function wR(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 M_(e){return(e.id||"").includes(":cli:")}function j_(e){return(e.id||"").includes(":acp:")}function Bd(e,t){return Dr(e)}function SR(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 kR({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," — ",Dr(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(WP,{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(BP,{size:13})," Refresh History"]})})})]})]})}const I_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function CR({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:I_[n.type]||I_.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 ER=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function NR(e){return e.workspace||""}function TR(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,y,S;const l=[],a=o.daemonId&&i[o.daemonId]||void 0,c=o.daemonId||((w=o.id)==null?void 0:w.split(":")[0])||o.id,d=n?n[c]||"new":void 0,h=NR(o),f=Dr(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(L=>({...L,activeModal:L.activeModal??void 0})):[],_=ER(o);if(_){const L=Bd(o.type),E=(g=o.agents)==null?void 0:g[0],P=(v=o.activeChat)==null?void 0:v.activeModal,N=P&&Array.isArray(P.buttons)&&P.buttons.length>0,A=(y=o.activeChat)==null?void 0:y.status,k=A==="generating"||A==="loading"||A&&A.toLowerCase()==="thinking",I=N||A==="waiting_approval"?"waiting_approval":k?"working":(E==null?void 0:E.status)||"idle",R=o.activeChat||{title:"",messages:[]};let C=R.title&&String(R.title).trim()?String(R.title).trim():"";const B=(S=o.activeChat)==null?void 0:S.id,z=o.chats;if(B&&Array.isArray(z)&&z.length>0){const Z=z.find(ne=>ne.id===B||ne.id&&String(ne.id)===String(B));Z!=null&&Z.title&&String(Z.title).trim()&&(C=String(Z.title).trim())}const U=R.messages||[],M=t[o.id]||[],$=new Map;U.filter(Z=>Z.role==="user").forEach(Z=>{$.set(Z.content,($.get(Z.content)||0)+1)});const b=M.filter(Z=>{const ne=$.get(Z.content)||0;return ne>0?($.set(Z.content,ne-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:L,agentType:oi(o)||cn(o)?o.type:(E==null?void 0:E.type)||"ide-native",status:I,title:C,messages:[...U,...b],ideType:o.type,workspaceName:h,displayPrimary:C||h||L,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:N?P.buttons:void 0,modalMessage:N?P.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(oi(o)||cn(o)))return l;for(const L of m){const E=L.activeModal&&Array.isArray(L.activeModal.buttons)&&L.activeModal.buttons.length>0,P=E?"waiting_approval":L.status==="streaming"?"working":L.status,N=`${o.id}:${L.agentType}`,A=L.messages||[],k=t[N]||[],O=new Map;A.filter(R=>R.role==="user").forEach(R=>{O.set(R.content,(O.get(R.content)||0)+1)});const I=k.filter(R=>{const C=O.get(R.content)||0;return C>0?(O.set(R.content,C-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:L.agentName,agentType:L.agentType,status:P,title:"",messages:[...A,...I],ideType:o.type,workspaceName:h,displayPrimary:h||L.agentName,displaySecondary:`${f}·${L.agentName}`,cdpConnected:o.cdpConnected,modalButtons:E?L.activeModal.buttons:void 0,modalMessage:E?L.activeModal.message:void 0,streamSource:"agent-stream",tabKey:N,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Bd(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 PR(e,t){var l,a,c,d;const r=[],{daemonId:n,existingDaemon:i,timestamp:s}=t,o=s||e.timestamp||Date.now();r.push({...i||{},id:n,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...e.version&&{version:e.version},...e.machine&&{machine:e.machine,platform:e.machine.platform},...e.instanceId&&{instanceId:e.instanceId},...e.machineNickname!==void 0&&{machineNickname:e.machineNickname},...e.p2p&&{p2p:e.p2p},..."system"in e&&{system:e.system},..."hostname"in e&&{hostname:e.hostname},...e.workspaces&&{workspaces:e.workspaces},...e.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:e.defaultWorkspaceId},...e.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:e.defaultWorkspacePath},...e.workspaceActivity&&{workspaceActivity:e.workspaceActivity},...e.detectedIdes&&{detectedIdes:e.detectedIdes},..."availableProviders"in e&&{availableProviders:e.availableProviders},cdpConnected:e.managedIdes.some(h=>h.cdpConnected),managedIdeIds:e.managedIdes.map(h=>`${n}:ide:${h.instanceId}`),managedCliIds:e.managedClis.map(h=>h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`),managedAcpIds:e.managedAcps.map(h=>h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`)});for(const h of e.managedIdes)r.push({id:`${n}:ide:${h.instanceId}`,type:h.ideType,ideType:h.ideType,version:h.ideVersion,status:h.cdpConnected?"online":"detected",daemonId:n,instanceId:h.instanceId,workspace:h.workspace,terminals:h.terminals,agents:h.aiAgents,activeChat:h.activeChat,chats:h.chats,agentStreams:h.agentStreams,cdpConnected:h.cdpConnected,currentModel:h.currentModel,currentPlan:h.currentPlan,currentAutoApprove:h.currentAutoApprove,timestamp:o});for(const h of e.managedClis){const f=h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`;r.push({id:f,type:h.cliType,ideType:h.cliType,agentType:h.cliType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.cliName,mode:h.mode||"terminal",workspace:h.workspace,activeChat:h.activeChat,agentStreams:[{agentType:h.cliType,agentName:h.cliName,extensionId:"cli-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((l=h.activeChat)==null?void 0:l.messages)||[],inputContent:"",activeModal:(a=h.activeChat)==null?void 0:a.activeModal}],timestamp:o,_isCli:!0})}for(const h of e.managedAcps){const f=h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`;r.push({id:f,type:h.acpType,ideType:h.acpType,agentType:h.acpType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.acpName,mode:"chat",workspace:h.workspace,activeChat:h.activeChat,currentModel:h.currentModel,currentPlan:h.currentPlan,acpConfigOptions:h.acpConfigOptions,acpModes:h.acpModes,agentStreams:[{agentType:h.acpType,agentName:h.acpName,extensionId:"acp-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((c=h.activeChat)==null?void 0:c.messages)||[],inputContent:"",activeModal:(d=h.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isAcp:!0})}return r}function D1(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=D1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function LR(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=D1(e))&&(n&&(n+=" "),n+=t);return n}const RR=(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},MR=(e,t)=>({classGroupId:e,validator:t}),A1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ec="-",D_=[],jR="arbitrary..",IR=e=>{const t=AR(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return DR(o);const l=o.split(ec),a=l[0]===""&&l.length>1?1:0;return B1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?RR(c,a):a:c||D_}return r[o]||D_}}},B1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=B1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(ec):e.slice(t).join(ec),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},DR=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?jR+n:void 0})(),AR=e=>{const{theme:t,classGroups:r}=e;return BR(r,t)},BR=(e,t)=>{const r=A1();for(const n in e){const i=e[n];pp(i,r,n,t)}return r},pp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];OR(o,t,r,n)}},OR=(e,t,r,n)=>{if(typeof e=="string"){zR(e,t,r);return}if(typeof e=="function"){$R(e,t,r,n);return}FR(e,t,r,n)},zR=(e,t,r)=>{const n=e===""?t:O1(t,e);n.classGroupId=r},$R=(e,t,r,n)=>{if(WR(e)){pp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(MR(r,e))},FR=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];pp(a,O1(t,l),r,n)}},O1=(e,t)=>{let r=e;const n=t.split(ec),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=A1(),r.nextPart.set(o,l)),r=l}return r},WR=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,HR=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="!",A_=":",UR=[],B_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),KR=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===A_){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 B_(s,p,f,m)};if(t){const i=t+A_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):B_(UR,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},VR=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}},qR=e=>({cache:HR(e.cacheSize),parseClassName:KR(e),sortModifiers:VR(e),...IR(e)}),YR=/\s+/,XR=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(YR);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(":"),y=p?v+Od:v,S=y+g;if(o.indexOf(S)>-1)continue;o.push(S);const L=i(g,w);for(let E=0;E<L.length;++E){const P=L[E];o.push(y+P)}a=d+(a.length>0?" "+a:a)}return a},GR=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=z1(r))&&(i&&(i+=" "),i+=n);return i},z1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=z1(e[n]))&&(r&&(r+=" "),r+=t);return r},QR=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=qR(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=XR(a,r);return i(a,d),d};return s=o,(...a)=>s(GR(...a))},JR=[],Ct=e=>{const t=r=>r[e]||JR;return t.isThemeGetter=!0,t},$1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,F1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZR=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tM=/\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$/,rM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,iM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=e=>ZR.test(e),De=e=>!!e&&!Number.isNaN(Number(e)),On=e=>!!e&&Number.isInteger(Number(e)),Fu=e=>e.endsWith("%")&&De(e.slice(0,-1)),fn=e=>eM.test(e),W1=()=>!0,sM=e=>tM.test(e)&&!rM.test(e),mp=()=>!1,oM=e=>nM.test(e),lM=e=>iM.test(e),aM=e=>!pe(e)&&!ge(e),cM=e=>fi(e,K1,mp),pe=e=>$1.test(e),gi=e=>fi(e,V1,sM),O_=e=>fi(e,_M,De),uM=e=>fi(e,Y1,W1),hM=e=>fi(e,q1,mp),z_=e=>fi(e,H1,mp),dM=e=>fi(e,U1,lM),Hl=e=>fi(e,X1,oM),ge=e=>F1.test(e),to=e=>Vi(e,V1),fM=e=>Vi(e,q1),$_=e=>Vi(e,H1),pM=e=>Vi(e,K1),mM=e=>Vi(e,U1),Ul=e=>Vi(e,X1,!0),gM=e=>Vi(e,Y1,!0),fi=(e,t,r)=>{const n=$1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vi=(e,t,r=!1)=>{const n=F1.exec(e);return n?n[1]?t(n[1]):r:!1},H1=e=>e==="position"||e==="percentage",U1=e=>e==="image"||e==="url",K1=e=>e==="length"||e==="size"||e==="bg-size",V1=e=>e==="length",_M=e=>e==="number",q1=e=>e==="family-name",Y1=e=>e==="number"||e==="weight",X1=e=>e==="shadow",vM=()=>{const e=Ct("color"),t=Ct("font"),r=Ct("text"),n=Ct("font-weight"),i=Ct("tracking"),s=Ct("leading"),o=Ct("breakpoint"),l=Ct("container"),a=Ct("spacing"),c=Ct("radius"),d=Ct("shadow"),h=Ct("inset-shadow"),f=Ct("text-shadow"),p=Ct("drop-shadow"),m=Ct("blur"),_=Ct("perspective"),w=Ct("aspect"),g=Ct("ease"),v=Ct("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...S(),ge,pe],E=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],N=()=>[ge,pe,a],A=()=>[Bn,"full","auto",...N()],k=()=>[On,"none","subgrid",ge,pe],O=()=>["auto",{span:["full",On,ge,pe]},On,ge,pe],I=()=>[On,"auto",ge,pe],R=()=>["auto","min","max","fr",ge,pe],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...N()],U=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],M=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...N()],$=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...N()],b=()=>[e,ge,pe],Z=()=>[...S(),$_,z_,{position:[ge,pe]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",pM,cM,{size:[ge,pe]}],Y=()=>[Fu,to,gi],D=()=>["","none","full",c,ge,pe],W=()=>["",De,to,gi],X=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[De,Fu,$_,z_],Ce=()=>["","none",m,ge,pe],Se=()=>["none",De,ge,pe],Fe=()=>["none",De,ge,pe],de=()=>[De,ge,pe],xe=()=>[Bn,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[fn],breakpoint:[fn],color:[W1],container:[fn],"drop-shadow":[fn],ease:["in","out","in-out"],font:[aM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[fn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[fn],shadow:[fn],spacing:["px",De],text:[fn],"text-shadow":[fn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,pe,ge,w]}],container:["container"],columns:[{columns:[De,pe,ge,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:L()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[On,"auto",ge,pe]}],basis:[{basis:[Bn,"full","auto",l,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,Bn,"auto","initial","none",pe]}],grow:[{grow:["",De,ge,pe]}],shrink:[{shrink:["",De,ge,pe]}],order:[{order:[On,"first","last","none",ge,pe]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:O()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pbs:[{pbs:N()}],pbe:[{pbe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"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",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],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,to,gi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,gM,uM]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fu,pe]}],"font-family":[{font:[fM,hM,t]}],"font-features":[{"font-features":[pe]}],"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,pe]}],"line-clamp":[{"line-clamp":[De,"none",ge,O_]}],leading:[{leading:[s,...N()]}],"list-image":[{"list-image":["none",ge,pe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ge,pe]}],"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:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",ge,gi]}],"text-decoration-color":[{decoration:b()}],"underline-offset":[{"underline-offset":[De,"auto",ge,pe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ge,pe]}],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,pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},On,ge,pe],radial:["",ge,pe],conic:[On,ge,pe]},mM,dM]}],"bg-color":[{bg:b()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:b()}],"gradient-via":[{via:b()}],"gradient-to":[{to:b()}],rounded:[{rounded:D()}],"rounded-s":[{"rounded-s":D()}],"rounded-e":[{"rounded-e":D()}],"rounded-t":[{"rounded-t":D()}],"rounded-r":[{"rounded-r":D()}],"rounded-b":[{"rounded-b":D()}],"rounded-l":[{"rounded-l":D()}],"rounded-ss":[{"rounded-ss":D()}],"rounded-se":[{"rounded-se":D()}],"rounded-ee":[{"rounded-ee":D()}],"rounded-es":[{"rounded-es":D()}],"rounded-tl":[{"rounded-tl":D()}],"rounded-tr":[{"rounded-tr":D()}],"rounded-br":[{"rounded-br":D()}],"rounded-bl":[{"rounded-bl":D()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...X(),"hidden","none"]}],"divide-style":[{divide:[...X(),"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:[...X(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,ge,pe]}],"outline-w":[{outline:["",De,to,gi]}],"outline-color":[{outline:b()}],shadow:[{shadow:["","none",d,Ul,Hl]}],"shadow-color":[{shadow:b()}],"inset-shadow":[{"inset-shadow":["none",h,Ul,Hl]}],"inset-shadow-color":[{"inset-shadow":b()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:b()}],"ring-offset-w":[{"ring-offset":[De,gi]}],"ring-offset-color":[{"ring-offset":b()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":b()}],"text-shadow":[{"text-shadow":["none",f,Ul,Hl]}],"text-shadow-color":[{"text-shadow":b()}],opacity:[{opacity:[De,ge,pe]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":b()}],"mask-image-linear-to-color":[{"mask-linear-to":b()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":b()}],"mask-image-t-to-color":[{"mask-t-to":b()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":b()}],"mask-image-r-to-color":[{"mask-r-to":b()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":b()}],"mask-image-b-to-color":[{"mask-b-to":b()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":b()}],"mask-image-l-to-color":[{"mask-l-to":b()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":b()}],"mask-image-x-to-color":[{"mask-x-to":b()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":b()}],"mask-image-y-to-color":[{"mask-y-to":b()}],"mask-image-radial":[{"mask-radial":[ge,pe]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":b()}],"mask-image-radial-to-color":[{"mask-radial-to":b()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":b()}],"mask-image-conic-to-color":[{"mask-conic-to":b()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ge,pe]}],filter:[{filter:["","none",ge,pe]}],blur:[{blur:Ce()}],brightness:[{brightness:[De,ge,pe]}],contrast:[{contrast:[De,ge,pe]}],"drop-shadow":[{"drop-shadow":["","none",p,Ul,Hl]}],"drop-shadow-color":[{"drop-shadow":b()}],grayscale:[{grayscale:["",De,ge,pe]}],"hue-rotate":[{"hue-rotate":[De,ge,pe]}],invert:[{invert:["",De,ge,pe]}],saturate:[{saturate:[De,ge,pe]}],sepia:[{sepia:["",De,ge,pe]}],"backdrop-filter":[{"backdrop-filter":["","none",ge,pe]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[De,ge,pe]}],"backdrop-contrast":[{"backdrop-contrast":[De,ge,pe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,ge,pe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,ge,pe]}],"backdrop-invert":[{"backdrop-invert":["",De,ge,pe]}],"backdrop-opacity":[{"backdrop-opacity":[De,ge,pe]}],"backdrop-saturate":[{"backdrop-saturate":[De,ge,pe]}],"backdrop-sepia":[{"backdrop-sepia":["",De,ge,pe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ge,pe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",ge,pe]}],ease:[{ease:["linear","initial",g,ge,pe]}],delay:[{delay:[De,ge,pe]}],animate:[{animate:["none",v,ge,pe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,ge,pe]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Se()}],"rotate-x":[{"rotate-x":Se()}],"rotate-y":[{"rotate-y":Se()}],"rotate-z":[{"rotate-z":Se()}],scale:[{scale:Fe()}],"scale-x":[{"scale-x":Fe()}],"scale-y":[{"scale-y":Fe()}],"scale-z":[{"scale-z":Fe()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ge,pe,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"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,pe]}],"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":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mbs":[{"scroll-mbs":N()}],"scroll-mbe":[{"scroll-mbe":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pbs":[{"scroll-pbs":N()}],"scroll-pbe":[{"scroll-pbe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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,pe]}],fill:[{fill:["none",...b()]}],"stroke-w":[{stroke:[De,to,gi,O_]}],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"]}},xM=QR(vM);function Jo(...e){return xM(LR(e))}function yM({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Jo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Qi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Jo("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 bM({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Jo("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 wM={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"},SM={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function kM({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Jo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",wM[e],r),children:[u.jsx("span",{className:Jo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",SM[e])}),n]})}function CM(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function F_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function Wu(e){return e==="system"?CM():e}function EM(){const[e,t]=x.useState(F_),[r,n]=x.useState(()=>Wu(F_()));x.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),x.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=x.useCallback(o=>{t(o),n(Wu(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=x.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(Wu(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}const W_={dark:"Dark",light:"Light",system:"System"};function NM({collapsed:e}){const{preference:t,cycleTheme:r}=EM(),n=t==="dark"?u.jsx(UP,{size:16}):t==="light"?u.jsx(HP,{size:16}):u.jsx(KP,{size:16});return u.jsxs("div",{className:`nav-item cursor-pointer ${e?"justify-center py-2.5 px-0":""}`,onClick:r,title:`Theme: ${W_[t]} (click to cycle)`,children:[u.jsx("span",{className:"nav-icon",children:n}),!e&&u.jsx("span",{className:"text-xs",children:W_[t]})]})}function Zi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}const G1="adhdev_notification_prefs",H_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function TM(){try{const e=localStorage.getItem(G1);if(e){const t=JSON.parse(e);return{...H_,...t}}}catch{}return{...H_}}function PM(e){try{localStorage.setItem(G1,JSON.stringify(e))}catch{}}let vn=TM(),pa=[];function LM(){pa.forEach(e=>e())}function RM(e){vn={...vn,...e},PM(vn),LM()}function MM(){const[,e]=x.useState(0);x.useEffect(()=>{const r=()=>e(n=>n+1);return pa.push(r),()=>{pa=pa.filter(n=>n!==r)}},[]);const t=x.useCallback(r=>{RM(r)},[]);return[{...vn},t]}function Hu(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}}function jM({onPrefChange:e}){const[t,r]=MM(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Zi,{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(Zi,{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(Zi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Zi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Zi,{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 IM({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(bM,{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(BM,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function U_({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 hy.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 DM={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 AM(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return DM[t]||{icon:"📝",name:e}}function BM({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var B,z,U,M;const[s,o]=x.useState("idle"),[l,a]=x.useState(""),[c,d]=x.useState(null),[h,f]=x.useState("idle"),[p,m]=x.useState(""),_=e,w=_.version||_.daemonVersion||null,g=((B=_.machine)==null?void 0:B.hostname)||((z=_.system)==null?void 0:z.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((M=_.system)==null?void 0:M.platform)||"",y=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",L=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),E=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),P=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),N=_.p2p,A=async()=>{var $,b,Z;if(r){o("upgrading"),a("Installing latest version...");try{const ne=await r(e.id,"daemon_upgrade",{});($=ne==null?void 0:ne.result)!=null&&$.upgraded||(b=ne==null?void 0:ne.result)!=null&&b.success?(o("done"),a(`Upgraded to v${ne.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((Z=ne==null?void 0:ne.result)==null?void 0:Z.error)||"Upgrade failed"))}catch(ne){o("error"),a((ne==null?void 0:ne.message)||"Connection lost during upgrade")}}},k=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},O=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},I="0.5.57",R=!w||w!==I,C=L.length+E.length+P.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:y}),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] ${R?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",w,!R&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&R&&u.jsx("button",{onClick:A,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${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(kM,{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:[N&&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 ${N.state==="connected"?"bg-green-400":N.state==="connecting"||N.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",N.state==="connected"?"connected":N.state==="connecting"||N.state==="new"?"connecting...":N.state||"off"]}),N.peers!==void 0&&N.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",N.peers," peer",N.peers!==1?"s":"",")"]})]}),N&&C>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[L.map($=>{const b=AM($.type),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}),Z!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Z?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:Z?"CDP connected":"CDP connecting..."})]},$.id)}),E.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),P.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(U_,{title:"🔌 Disconnect Machine",message:`Disconnect "${y}" from ADHDev?
173
173
 
174
174
  This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
175
175
 
@@ -180,11 +180,11 @@ This will:
180
180
  • Invalidate the connection token
181
181
  • Require running "adhdev setup" again on that machine
182
182
 
183
- Use this if you accidentally set up on a shared/public computer and want to ensure it can never reconnect.`,confirmLabel:"Revoke Token",confirmColor:"red",onConfirm:O,onCancel:()=>d(null)})]})}const zd={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#1e1e24",assistantText:"#e0e0e0",containerBg:"#111114",accentColor:"#818cf8",sendButton:"#6366f1",inputBorder:"#2a2a35",bubbleRadius:16},$d={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#f3f4f6",assistantText:"#1f2937",containerBg:"#f9fafb",accentColor:"#6366f1",sendButton:"#6366f1",inputBorder:"#d1d5db",bubbleRadius:16},OM=[{id:"midnight",name:"Midnight",description:"Default gradient with violet accents",preview:{dark:{userBubble:"linear-gradient(135deg, #8b5cf6, #4f46e5)",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #7c3aed, #0ea5e9)",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f6f7f9",textColor:"#52525b"}}},{id:"aurora",name:"Aurora",description:"Vibrant pink-orange with rounded bubbles",preview:{dark:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow bubbles with clean design",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}}],Q1="adhdev-chat-theme",J1="adhdev-chat-theme-custom";function ma(){return typeof window>"u"?"midnight":localStorage.getItem(Q1)||"midnight"}function Vr(e){try{const t=localStorage.getItem(J1);if(t){const r=JSON.parse(t);return{...e==="dark"?zd:$d,...r[e]}}}catch{}return e==="dark"?zd:$d}function Kl(e,t){localStorage.setItem(J1,JSON.stringify({dark:e,light:t}))}function ji(e){const t=document.documentElement;t.style.setProperty("--chat-user-bg",e.userBubble),t.style.setProperty("--chat-user-color",e.userText),t.style.setProperty("--chat-user-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px 4px ${e.bubbleRadius}px`),t.style.setProperty("--chat-assistant-bg",e.assistantBubble),t.style.setProperty("--chat-assistant-color",e.assistantText),t.style.setProperty("--chat-assistant-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px ${e.bubbleRadius}px 4px`),t.style.setProperty("--chat-assistant-border",`1px solid ${e.accentColor}22`),t.style.setProperty("--chat-container-bg",e.containerBg),t.style.setProperty("--chat-thought-accent",e.accentColor),t.style.setProperty("--chat-tool-accent",e.accentColor),t.style.setProperty("--chat-action-color",e.accentColor),t.style.setProperty("--chat-send-bg",e.sendButton),t.style.setProperty("--chat-input-border",e.inputBorder)}function zM(){const e=document.documentElement;["--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(r=>e.style.removeProperty(r))}function $M(e){if(localStorage.setItem(Q1,e),document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Eo()?"dark":"light";ji(Vr(t))}else zM()}function FM(){const e=ma();if(e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Eo()?"dark":"light";ji(Vr(t))}}function Eo(){const e=document.documentElement.getAttribute("data-theme");return e?e==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function zn({label:e,value:t,onChange:r}){return u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:e}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("input",{type:"color",value:t,onChange:n=>r(n.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:t,onChange:n=>{/^#[0-9a-fA-F]{0,6}$/.test(n.target.value)&&r(n.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function WM({dark:e,onColorsChange:t}){const r=e?"dark":"light",[n,i]=x.useState(()=>Vr(r));x.useEffect(()=>{i(Vr(r))},[r]);const s=x.useCallback((o,l)=>{i(a=>{const c={...a,[o]:l},h=Vr(r==="dark"?"light":"dark");return r==="dark"?Kl(c,h):Kl(h,c),ji(c),t(c),c})},[r,t]);return u.jsxs("div",{style:{marginTop:12,padding:"14px 16px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[u.jsxs("div",{style:{fontSize:"0.7rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.06em",marginBottom:10},children:["Customize (",e?"Dark":"Light"," mode)"]}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsx(zn,{label:"User bubble",value:n.userBubble,onChange:o=>s("userBubble",o)}),u.jsx(zn,{label:"User text",value:n.userText,onChange:o=>s("userText",o)}),u.jsx(zn,{label:"Agent bubble",value:n.assistantBubble,onChange:o=>s("assistantBubble",o)}),u.jsx(zn,{label:"Agent text",value:n.assistantText,onChange:o=>s("assistantText",o)}),u.jsx(zn,{label:"Background",value:n.containerBg,onChange:o=>s("containerBg",o)}),u.jsx(zn,{label:"Accent",value:n.accentColor,onChange:o=>s("accentColor",o)}),u.jsx(zn,{label:"Send button",value:n.sendButton,onChange:o=>s("sendButton",o)}),u.jsx(zn,{label:"Input border",value:n.inputBorder,onChange:o=>s("inputBorder",o)}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:"Radius"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[u.jsx("input",{type:"range",min:4,max:24,value:n.bubbleRadius,onChange:o=>s("bubbleRadius",Number(o.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[n.bubbleRadius,"px"]})]})]})]}),u.jsx("button",{onClick:()=>{const o=e?zd:$d,a=Vr(e?"light":"dark");e?Kl(o,a):Kl(a,o),i(o),ji(o),t(o)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function HM(){const[e,t]=x.useState(ma),[r,n]=x.useState(!0),[i,s]=x.useState(()=>Vr("dark"));x.useEffect(()=>{n(Eo());const a=new MutationObserver(()=>{const h=Eo();n(h),ma()==="custom"&&ji(Vr(h?"dark":"light"))});a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const c=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const h=Eo();n(h),ma()==="custom"&&ji(Vr(h?"dark":"light"))};return c.addEventListener("change",d),()=>{a.disconnect(),c.removeEventListener("change",d)}},[]),x.useEffect(()=>{e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"&&ji(Vr(r?"dark":"light"))},[]),x.useEffect(()=>{s(Vr(r?"dark":"light"))},[r]);const o=a=>{t(a),$M(a),a==="midnight"&&document.documentElement.removeAttribute("data-chat-theme")},l=[...OM,{id:"custom",name:"Custom",description:"Design your own theme",preview:{dark:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText},light:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText}}}];return u.jsxs("div",{children:[u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:l.map(a=>{const c=e===a.id,d=r?a.preview.dark:a.preview.light,h=a.id==="honey"?"#1a1a1a":a.id==="custom"?i.userText:"#fff";return u.jsxs("button",{onClick:()=>o(a.id),className:"text-left rounded-xl p-3 transition-all",style:{background:c?"var(--bg-glass-hover)":"var(--bg-glass)",border:c?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:c?1:.75},children:[u.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),u.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:h},children:"Fix the bug please"}),u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[c&&u.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-bold text-text-primary",children:a.id==="custom"?"🎨 Custom":a.name}),u.jsx("div",{className:"text-[10px] text-text-muted",children:a.description})]})]})]},a.id)})}),e==="custom"&&u.jsx(WM,{dark:r,onColorsChange:a=>s(a)})]})}const UM={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function KM(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function Z1(){return"Notification"in window&&Notification.permission==="granted"}let _i=null;async function VM(){if(_i!==null)return _i;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return _i=!1,!1;const e=await navigator.serviceWorker.getRegistration();return e?(_i=!!await e.pushManager.getSubscription(),_i):(_i=!1,!1)}catch{return _i=!1,!1}}function qM(e,t,r){if(Z1())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 YM(e,t={}){const r={...UM,...t},n=x.useRef(new Map),i=x.useRef(0),s=x.useRef(null);x.useEffect(()=>{VM().then(l=>{s.current=l})},[]);const o=x.useCallback((l,a,c)=>{const d=Date.now();d-i.current<r.throttleMs||(i.current=d,qM(l,a,c))},[r.throttleMs]);x.useEffect(()=>{var l;if(!(!r.enabled||!Z1())&&Hu("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&&Hu("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&&Hu("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])}const eb="adhdev_hiddenTabs";function XM(){try{const e=localStorage.getItem(eb);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function ro(e){try{localStorage.setItem(eb,JSON.stringify([...e]))}catch{}}function GM(){const[e,t]=x.useState(XM),r=x.useCallback(a=>{t(c=>{const d=new Set(c);return d.has(a)?d.delete(a):d.add(a),ro(d),d})},[]),n=x.useCallback(a=>{t(c=>{if(c.has(a))return c;const d=new Set(c);return d.add(a),ro(d),d})},[]),i=x.useCallback(a=>{t(c=>{if(!c.has(a))return c;const d=new Set(c);return d.delete(a),ro(d),d})},[]),s=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.add(f);return ro(h),h})},[]),o=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.delete(f);return ro(h),h})},[]),l=x.useCallback(a=>e.has(a),[e]);return{hiddenTabs:e,toggleTab:r,hideTab:n,showTab:i,hideAllForDaemon:s,showAllForDaemon:o,isHidden:l}}function tb({sendDaemonCommand:e,activeConv:t,ides:r,updateIdeChats:n,setToasts:i,setLocalUserMessages:s,setClearedTabs:o,setActionLogs:l,pinTab:a,isStandalone:c}){const[d,h]=x.useState(""),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[w,g]=x.useState(!1),v=x.useCallback(async()=>{if(!t)return;const k=d.trim();if(!k)return;const O=t.ideId,I=t.tabKey;h(""),a(I,[100,500,1500,3e3]);const R=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,C={role:"user",content:k,timestamp:Date.now(),_localId:R};s(B=>({...B,[I]:[...B[I]||[],C]}));try{if(oi(t)&&!cn(t)){const B=O||t.daemonId||"";if(!B)return;const z=t.ideType||t.agentType||"";await e(B,"agent_command",{agentType:z,cliType:z,action:"send_chat",message:k,text:k})}else if(cn(t)){const B=O||t.daemonId||"";if(!B)return;await e(B,"send_chat",{message:k,text:k,agentType:t.agentType})}else{const B=O||t.daemonId||"";if(!B)return;await e(B,"send_chat",{message:k,text:k,...t.streamSource==="agent-stream"&&{agentType:t.agentType}})}setTimeout(()=>{const B=Date.now()-6e4;s(z=>{const U=z[I];if(!U)return z;const M=U.filter($=>$.timestamp>B);return M.length===U.length?z:{...z,[I]:M}})},6e4)}catch(B){console.error("Send failed",B),h(k),s(z=>({...z,[I]:(z[I]||[]).filter(U=>U._localId!==R)}))}},[t,d,e,s,a]),y=x.useCallback(async()=>{if(t)try{c?await e(t.ideId,"launch_ide",{ideType:t.ideType,enableCdp:!0}):await e(t.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(k){console.error("Relaunch failed",k)}},[t,c,e]),S=x.useCallback(async k=>{try{await e("standalone","launch_ide",{ideType:k,enableCdp:!0})}catch(O){console.error("Launch failed",O)}},[e]),L=x.useCallback(async k=>{if(t){console.log("[ModalButton] ideId:",t.ideId,"button:",k),l(O=>[...O,{ideId:t.tabKey,text:`🖱️ **${k}** clicked`,timestamp:Date.now()}]);try{const I=(t.modalButtons||[]).indexOf(k),R=k.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),C=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(R),B=t.ideId||t.daemonId||"";(await e(B,"resolve_action",{button:k,action:C?"approve":"reject",...I>=0&&{buttonIndex:I},...t.streamSource==="agent-stream"&&{agentType:t.agentType}})).success||l(U=>[...U,{ideId:t.tabKey,text:`⚠️ **${k}** failed — button not found`,timestamp:Date.now()}])}catch(O){console.error("[ModalButton] Error:",O),l(I=>[...I,{ideId:t.tabKey,text:`❌ **${k}** error`,timestamp:Date.now()}])}}},[t,e,l]),E=x.useCallback(async(k,O)=>{try{const I=k||(t==null?void 0:t.daemonId)||"",R=await e(I,"switch_chat",{id:O,sessionId:O,...(t==null?void 0:t.streamSource)==="agent-stream"&&{agentType:t==null?void 0:t.agentType}}),C=R==null?void 0:R.result;(R==null?void 0:R.success)===!0||C==="switched"||C==="switched-by-title"||(C===!1||C==="not_found"?i(z=>[...z,{id:Date.now(),message:"⚠️ Session tab not found — try refreshing history",type:"warning",timestamp:Date.now()}]):typeof C=="string"&&C.startsWith("error:")?i(z=>[...z,{id:Date.now(),message:`⚠️ Switch error: ${C}`,type:"warning",timestamp:Date.now()}]):i(z=>[...z,{id:Date.now(),message:"⚠️ Session switch failed",type:"warning",timestamp:Date.now()}]))}catch(I){console.error("Switch failed",I),i(R=>[...R,{id:Date.now(),message:`❌ Switch failed: ${I.message||"connection error"}`,type:"warning",timestamp:Date.now()}])}},[t,e,i]),P=x.useCallback(async()=>{if(!(!t||f)){p(!0);try{const k=t.ideId||t.daemonId||"";await e(k,"new_chat",{...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),o(O=>({...O,[t.tabKey]:Date.now()})),s(O=>({...O,[t.tabKey]:[]}))}catch(k){console.error("New chat failed",k)}finally{p(!1)}}},[t,f,e,o,s]),N=x.useCallback(async()=>{if(!t||w)return;g(!0);const k=t.tabKey;try{await e(t.ideId,"agent_stream_focus",{agentType:t.agentType}),a(k,[200,1500,3e3])}catch(O){console.error("Focus agent failed",O)}finally{g(!1)}},[t,w,e,a]),A=x.useCallback(async()=>{var k;if(!(!t||m)){_(!0);try{const O=t.ideId||t.daemonId||"",I=await e(O,"list_chats",{forceExpand:!0,...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),R=(I==null?void 0:I.chats)||((k=I==null?void 0:I.result)==null?void 0:k.chats);I!=null&&I.success&&Array.isArray(R)&&n(t.ideId,R)}catch(O){console.error("Refresh history failed",O)}finally{_(!1)}}},[t,m,e,n]);return{agentInput:d,setAgentInput:h,isCreatingChat:f,isRefreshingHistory:m,isFocusingAgent:w,handleSendChat:v,handleRelaunch:y,handleLaunchIde:S,handleModalButton:L,handleSwitchSession:E,handleNewChat:P,handleFocusAgent:N,handleRefreshHistory:A}}let Uu=null;function QM({conversations:e,ides:t,messageReceivedAt:r,actionLogs:n,ptyBuffers:i,screenshotMap:s,setScreenshotMap:o,sendDaemonCommand:l,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m,userName:_,groupIndex:w,isFocused:g,onFocus:v,isSplitMode:y,numGroups:S,onMoveTab:L,onClose:E,onReceiveTab:P,style:N,detectedIdes:A,handleLaunchIde:k,onActiveTabChange:O,initialActiveTabId:I,initialTabOrder:R,onTabOrderChange:C,onHideTab:B}){const{sendCommand:z}=hi(),U=x.useRef(null),[M,$]=x.useState(!1),b=x.useRef(0),[Z,ne]=x.useState(I??null);x.useEffect(()=>{I&&I!==Z&&ne(I)},[I]);const[T,Y]=x.useState(R??[]),[D,W]=x.useState(null),X=x.useRef(null),he=x.useRef(null);x.useEffect(()=>{const H=new Set(e.map(te=>te.tabKey));Y(te=>{const ce=te.filter(Ne=>H.has(Ne)),Le=e.filter(Ne=>!te.includes(Ne.tabKey)).map(Ne=>Ne.tabKey),Re=[...ce,...Le];return Re.length===te.length&&Re.every((Ne,V)=>Ne===te[V])?te:Re})},[e]);const me=D??T,Ce=x.useMemo(()=>{if(me.length===0)return e;const H=new Map(me.map((te,ce)=>[te,ce]));return[...e].sort((te,ce)=>{const Le=H.get(te.tabKey)??999,Re=H.get(ce.tabKey)??999;return Le-Re})},[e,me]);x.useEffect(()=>{if(Ce.length===0){ne(null),O==null||O(null);return}Z&&Ce.some(H=>H.tabKey===Z)||(ne(Ce[0].tabKey),O==null||O(Ce[0].tabKey))},[Ce,Z]);const Se=Ce.find(H=>H.tabKey===Z),Fe=x.useCallback((H,te,ce)=>{Y(Le=>{const Re=Le.filter(se=>se!==H),Ne=Re.indexOf(te);if(Ne<0)return Le;const V=ce==="left"?Ne:Ne+1;return Re.splice(V,0,H),C==null||C(Re),Re}),W(null)},[C]),de=x.useCallback((H,te,ce)=>{const Re=(T.length>0?T:e.map(se=>se.tabKey)).filter(se=>se!==H),Ne=Re.indexOf(te);if(Ne<0)return;const V=ce==="left"?Ne:Ne+1;Re.splice(V,0,H),X.current=Re,W(Re)},[T,e]),xe=tb({sendDaemonCommand:l,activeConv:Se,ides:t,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m}),[G,_e]=x.useState(null);x.useEffect(()=>{if(!G)return;const H=()=>_e(null);return window.addEventListener("click",H),()=>window.removeEventListener("click",H)},[G]);const Pe="adhdev-tab-shortcuts",Ee=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[ye,wt]=x.useState(()=>{try{return JSON.parse(localStorage.getItem(Pe)||"{}")}catch{return{}}}),[At,et]=x.useState(null),or=x.useCallback(H=>{const te=[];H.metaKey&&te.push(Ee?"⌘":"Meta"),H.ctrlKey&&te.push("Ctrl"),H.altKey&&te.push(Ee?"⌥":"Alt"),H.shiftKey&&te.push(Ee?"⇧":"Shift");const ce=H.key;if(["Control","Alt","Shift","Meta"].includes(ce))return null;const Le=ce.length===1?ce.toUpperCase():ce;return te.push(Le),te.join("+")},[Ee]),Nr=x.useCallback((H,te)=>or(H)===te,[or]),Bt=x.useCallback(H=>{wt(H),localStorage.setItem(Pe,JSON.stringify(H))},[]);x.useEffect(()=>{if(!At)return;const H=te=>{if(te.preventDefault(),te.stopPropagation(),te.key==="Escape"){et(null);return}const ce=or(te);if(!ce)return;const Le={...ye};for(const[Re,Ne]of Object.entries(Le))Ne===ce&&delete Le[Re];Le[At]=ce,Bt(Le),et(null)};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[At,ye,Bt,or]),x.useEffect(()=>{const H=te=>{if(!(!te.ctrlKey&&!te.metaKey&&!te.altKey)){for(const[ce,Le]of Object.entries(ye))if(Nr(te,Le)&&Ce.some(Re=>Re.tabKey===ce)){te.preventDefault(),v(),ne(ce),O==null||O(ce);return}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[ye,Ce,v,O,Nr]);const q=Se&&oi(Se)&&!cn(Se);x.useEffect(()=>{const H=()=>{b.current=0,$(!1)};return window.addEventListener("dragend",H),window.addEventListener("drop",H),()=>{window.removeEventListener("dragend",H),window.removeEventListener("drop",H)}},[]);const oe=x.useRef(null);return x.useEffect(()=>{const H=oe.current;if(!H)return;const te=ce=>{Math.abs(ce.deltaY)>Math.abs(ce.deltaX)&&(ce.preventDefault(),H.scrollLeft+=ce.deltaY)};return H.addEventListener("wheel",te,{passive:!1}),()=>H.removeEventListener("wheel",te)},[]),u.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:v,onDragEnter:H=>{if(H.dataTransfer.types.includes("text/tab-key")){b.current++;const te=Uu;te&&e.some(Le=>Le.tabKey===te)||$(!0)}},onDragOver:H=>{H.dataTransfer.types.includes("text/tab-key")&&H.preventDefault()},onDragLeave:()=>{b.current--,b.current<=0&&(b.current=0,$(!1))},onDrop:H=>{b.current=0,$(!1),W(null);const te=H.dataTransfer.getData("text/tab-key");if(!te)return;H.preventDefault(),e.some(Le=>Le.tabKey===te)?Y(Le=>{const Re=Le.filter(Ne=>Ne!==te);return Re.push(te),C==null||C(Re),Re}):P&&P(te)},style:{...N,outline:M?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[u.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:u.jsxs("div",{ref:oe,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[Ce.map((H,te)=>{const ce=Z===H.tabKey,Le=H.status==="working"?"agent-tab-working":H.status==="waiting_approval"?"agent-tab-waiting":"",Re=H.connectionState==="failed"||H.connectionState==="closed",Ne=he.current===H.tabKey;return u.jsxs("div",{"data-tabkey":H.tabKey,className:`${Le} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!("ontouchstart"in window),onDragStart:V=>{Uu=H.tabKey,he.current=H.tabKey,V.dataTransfer.setData("text/tab-key",H.tabKey),V.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Uu=null,he.current=null;const V=X.current;V&&(Y(V),C==null||C(V)),X.current=null,W(null),b.current=0,$(!1)},onDragOver:V=>{const se=he.current;if(!(!se||se===H.tabKey)&&V.dataTransfer.types.includes("text/tab-key")){V.preventDefault(),V.stopPropagation();const ee=V.currentTarget.getBoundingClientRect(),be=ee.left+ee.width/2,Me=V.clientX<be?"left":"right";de(se,H.tabKey,Me)}},onDrop:V=>{V.preventDefault(),V.stopPropagation();const se=V.dataTransfer.getData("text/tab-key");if(se&&se!==H.tabKey){const ee=V.currentTarget.getBoundingClientRect(),be=ee.left+ee.width/2,Me=V.clientX<be?"left":"right";Ce.some(ze=>ze.tabKey===se)?Fe(se,H.tabKey,Me):P&&P(se)}W(null)},onClick:V=>{V.stopPropagation(),v(),ne(H.tabKey),O==null||O(H.tabKey),H.streamSource==="agent-stream"&&H.agentType&&z(H.ideId,"agent_stream_focus",{agentType:H.agentType}).catch(()=>{}),oi(H)&&setTimeout(()=>{var se,ee;return(ee=(se=U.current)==null?void 0:se.bumpResize)==null?void 0:ee.call(se)},100)},onContextMenu:V=>{"ontouchstart"in window||(V.preventDefault(),_e({x:V.clientX,y:V.clientY,tabKey:H.tabKey}))},style:{background:ce?"var(--bg-primary)":"var(--bg-glass)",borderTop:ce?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:ce?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:ce?"1px solid var(--border-subtle)":"1px solid transparent",opacity:Ne?.4:Re?ce?.6:.3:ce?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[H.status==="working"?u.jsx("div",{className:"tab-spinner"}):H.status==="waiting_approval"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):Re?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):H.connectionState==="connecting"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-blue-400",children:"○"}):H.connectionState==="connected"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):u.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted",children:"●"}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",children:H.displayPrimary}),u.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:Re?u.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):u.jsxs(u.Fragment,{children:[H.displaySecondary,H.machineName&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"opacity-40",children:"·"}),u.jsxs("span",{className:"opacity-70",children:["🖥 ",H.machineName]})]})]})})]}),ye[H.tabKey]&&u.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${ye[H.tabKey]}`,children:ye[H.tabKey]})]},H.tabKey)}),e.length===0&&u.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),u.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",children:Se?u.jsxs(u.Fragment,{children:[u.jsx(M1,{activeConv:Se,onModalButton:xe.handleModalButton}),u.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!q&&!cn(Se)&&s[Se.ideId]?u.jsx(fR,{screenshotUrl:s[Se.ideId],mode:"preview",onDismiss:()=>{const H={...s};delete H[Se.ideId],o(H)}}):!q&&!cn(Se)&&Se.cdpConnected===!1?u.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[u.jsx("span",{className:"text-sm",children:u.jsx(B0,{size:14})}),u.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),u.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:xe.handleRelaunch,children:"Relaunch with CDP"})]}):null}),q?u.jsx(mR,{activeConv:Se,ptyBuffers:i,terminalRef:U,agentInput:xe.agentInput,setAgentInput:xe.setAgentInput,handleSendChat:xe.handleSendChat,handleModalButton:xe.handleModalButton}):u.jsx(j1,{activeConv:Se,ides:t,agentInput:xe.agentInput,setAgentInput:xe.setAgentInput,handleSendChat:xe.handleSendChat,handleFocusAgent:xe.handleFocusAgent,isFocusingAgent:xe.isFocusingAgent,messageReceivedAt:r,actionLogs:n,userName:_})]}):u.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.length===0&&!y&&A&&k?u.jsxs("div",{className:"empty-dashboard",children:[u.jsx("div",{className:"glow-orb",children:u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-12 h-12"})}),u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"font-bold text-lg mb-1.5",children:"Waiting for your IDE"}),u.jsx("div",{className:"text-[13px] text-text-muted",style:{marginBottom:12},children:m?"Launch an IDE with CDP to start monitoring":"Install the daemon, then open your IDE — it connects automatically."}),!m&&u.jsxs("div",{style:{background:"var(--bg-secondary, #111)",borderRadius:"0.5rem",padding:"0.5rem 0.75rem",display:"inline-block",fontFamily:"monospace",fontSize:"0.75rem",color:"var(--accent, #a78bfa)",marginBottom:12,textAlign:"left",border:"1px solid var(--border-subtle, #333)"},children:[u.jsx("span",{style:{color:"var(--text-muted)"},children:"$ "}),"npm i -g adhdev && adhdev setup && adhdev daemon"]}),m&&A.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:A.map(H=>u.jsx("button",{className:"btn btn-sm bg-violet-500/10 border border-violet-500/25 text-violet-400 text-xs font-semibold px-4 py-2 rounded-lg cursor-pointer flex items-center gap-1.5 transition-all",onClick:()=>k(H.type),onMouseEnter:te=>te.currentTarget.style.background="rgba(139,92,246,0.2)",onMouseLeave:te=>te.currentTarget.style.background="rgba(139,92,246,0.1)",children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($P,{size:14})," Launch ",H.name]})},H.type))}),u.jsx("div",{style:{marginTop:8},children:u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Setup guide →"})})]})]}):u.jsx("div",{className:"text-sm text-text-muted opacity-50",children:y?"Move a tab here to view":"No active agent"})})}),G&&u.jsxs("div",{className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:G.x,top:G.y},onClick:()=>_e(null),children:[L&&w>0&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"left"),_e(null)},children:"← Move to Left Group"}),L&&w<S-1&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"right"),_e(null)},children:"Move to Right Group →"}),L&&S<4&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"new"),_e(null)},children:"Split to New Group ◨"}),u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:H=>{H.stopPropagation(),et(G.tabKey),_e(null)},children:["⌨ ",ye[G.tabKey]?`Change shortcut (${ye[G.tabKey]})`:"Set shortcut"]}),ye[G.tabKey]&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{const H={...ye};delete H[G.tabKey],Bt(H),_e(null)},children:"✕ Remove shortcut"}),B&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{B(G.tabKey),_e(null)},children:"🚫 Hide from Dashboard"})]}),!L&&!B&&u.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),At&&u.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>et(null),children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:H=>H.stopPropagation(),children:[u.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),u.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",Ee?"⌘+1":"Ctrl+1",", ",Ee?"⌥+A":"Alt+A",")"]}),u.jsx("div",{className:"text-lg font-mono text-accent-primary animate-pulse",children:"Listening..."}),u.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}const Ku=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and open your IDE — it connects automatically.",code:"npm i -g adhdev && adhdev setup && adhdev daemon"}];function JM({onClose:e}){const[t,r]=x.useState(0),n=Ku[t],i=t===Ku.length-1;return u.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:s=>{s.target===s.currentTarget&&e()},children:[u.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[u.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),u.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:Ku.map((s,o)=>u.jsx("div",{style:{width:o===t?24:8,height:8,borderRadius:4,background:o===t?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},o))}),u.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:n.visual||n.icon}),u.jsxs("div",{style:{textAlign:"center"},children:[u.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[u.jsx("span",{children:n.icon})," ",n.title]}),u.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:n.desc}),n.code&&u.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[u.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),n.code]}),i&&u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[u.jsx("button",{onClick:e,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),u.jsx("button",{onClick:()=>i?e():r(s=>s+1),style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer",transition:"opacity 0.2s"},onMouseEnter:s=>s.currentTarget.style.opacity="0.85",onMouseLeave:s=>s.currentTarget.style.opacity="1",children:i?"Get Started →":"Next →"})]})]}),u.jsx("style",{children:`
183
+ Use this if you accidentally set up on a shared/public computer and want to ensure it can never reconnect.`,confirmLabel:"Revoke Token",confirmColor:"red",onConfirm:O,onCancel:()=>d(null)})]})}const zd={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#1e1e24",assistantText:"#e0e0e0",containerBg:"#111114",accentColor:"#818cf8",sendButton:"#6366f1",inputBorder:"#2a2a35",bubbleRadius:16},$d={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#f3f4f6",assistantText:"#1f2937",containerBg:"#f9fafb",accentColor:"#6366f1",sendButton:"#6366f1",inputBorder:"#d1d5db",bubbleRadius:16},OM=[{id:"midnight",name:"Midnight",description:"Default gradient with violet accents",preview:{dark:{userBubble:"linear-gradient(135deg, #8b5cf6, #4f46e5)",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #7c3aed, #0ea5e9)",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f6f7f9",textColor:"#52525b"}}},{id:"aurora",name:"Aurora",description:"Vibrant pink-orange with rounded bubbles",preview:{dark:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow bubbles with clean design",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}}],Q1="adhdev-chat-theme",J1="adhdev-chat-theme-custom";function ma(){return typeof window>"u"?"midnight":localStorage.getItem(Q1)||"midnight"}function Vr(e){try{const t=localStorage.getItem(J1);if(t){const r=JSON.parse(t);return{...e==="dark"?zd:$d,...r[e]}}}catch{}return e==="dark"?zd:$d}function Kl(e,t){localStorage.setItem(J1,JSON.stringify({dark:e,light:t}))}function ji(e){const t=document.documentElement;t.style.setProperty("--chat-user-bg",e.userBubble),t.style.setProperty("--chat-user-color",e.userText),t.style.setProperty("--chat-user-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px 4px ${e.bubbleRadius}px`),t.style.setProperty("--chat-assistant-bg",e.assistantBubble),t.style.setProperty("--chat-assistant-color",e.assistantText),t.style.setProperty("--chat-assistant-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px ${e.bubbleRadius}px 4px`),t.style.setProperty("--chat-assistant-border",`1px solid ${e.accentColor}22`),t.style.setProperty("--chat-container-bg",e.containerBg),t.style.setProperty("--chat-thought-accent",e.accentColor),t.style.setProperty("--chat-tool-accent",e.accentColor),t.style.setProperty("--chat-action-color",e.accentColor),t.style.setProperty("--chat-send-bg",e.sendButton),t.style.setProperty("--chat-input-border",e.inputBorder)}function zM(){const e=document.documentElement;["--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(r=>e.style.removeProperty(r))}function $M(e){if(localStorage.setItem(Q1,e),document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Eo()?"dark":"light";ji(Vr(t))}else zM()}function FM(){const e=ma();if(e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Eo()?"dark":"light";ji(Vr(t))}}function Eo(){const e=document.documentElement.getAttribute("data-theme");return e?e==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function zn({label:e,value:t,onChange:r}){return u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:e}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("input",{type:"color",value:t,onChange:n=>r(n.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:t,onChange:n=>{/^#[0-9a-fA-F]{0,6}$/.test(n.target.value)&&r(n.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function WM({dark:e,onColorsChange:t}){const r=e?"dark":"light",[n,i]=x.useState(()=>Vr(r));x.useEffect(()=>{i(Vr(r))},[r]);const s=x.useCallback((o,l)=>{i(a=>{const c={...a,[o]:l},h=Vr(r==="dark"?"light":"dark");return r==="dark"?Kl(c,h):Kl(h,c),ji(c),t(c),c})},[r,t]);return u.jsxs("div",{style:{marginTop:12,padding:"14px 16px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[u.jsxs("div",{style:{fontSize:"0.7rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.06em",marginBottom:10},children:["Customize (",e?"Dark":"Light"," mode)"]}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsx(zn,{label:"User bubble",value:n.userBubble,onChange:o=>s("userBubble",o)}),u.jsx(zn,{label:"User text",value:n.userText,onChange:o=>s("userText",o)}),u.jsx(zn,{label:"Agent bubble",value:n.assistantBubble,onChange:o=>s("assistantBubble",o)}),u.jsx(zn,{label:"Agent text",value:n.assistantText,onChange:o=>s("assistantText",o)}),u.jsx(zn,{label:"Background",value:n.containerBg,onChange:o=>s("containerBg",o)}),u.jsx(zn,{label:"Accent",value:n.accentColor,onChange:o=>s("accentColor",o)}),u.jsx(zn,{label:"Send button",value:n.sendButton,onChange:o=>s("sendButton",o)}),u.jsx(zn,{label:"Input border",value:n.inputBorder,onChange:o=>s("inputBorder",o)}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:"Radius"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[u.jsx("input",{type:"range",min:4,max:24,value:n.bubbleRadius,onChange:o=>s("bubbleRadius",Number(o.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[n.bubbleRadius,"px"]})]})]})]}),u.jsx("button",{onClick:()=>{const o=e?zd:$d,a=Vr(e?"light":"dark");e?Kl(o,a):Kl(a,o),i(o),ji(o),t(o)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function HM(){const[e,t]=x.useState(ma),[r,n]=x.useState(!0),[i,s]=x.useState(()=>Vr("dark"));x.useEffect(()=>{n(Eo());const a=new MutationObserver(()=>{const h=Eo();n(h),ma()==="custom"&&ji(Vr(h?"dark":"light"))});a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const c=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const h=Eo();n(h),ma()==="custom"&&ji(Vr(h?"dark":"light"))};return c.addEventListener("change",d),()=>{a.disconnect(),c.removeEventListener("change",d)}},[]),x.useEffect(()=>{e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"&&ji(Vr(r?"dark":"light"))},[]),x.useEffect(()=>{s(Vr(r?"dark":"light"))},[r]);const o=a=>{t(a),$M(a),a==="midnight"&&document.documentElement.removeAttribute("data-chat-theme")},l=[...OM,{id:"custom",name:"Custom",description:"Design your own theme",preview:{dark:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText},light:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText}}}];return u.jsxs("div",{children:[u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:l.map(a=>{const c=e===a.id,d=r?a.preview.dark:a.preview.light,h=a.id==="honey"?"#1a1a1a":a.id==="custom"?i.userText:"#fff";return u.jsxs("button",{onClick:()=>o(a.id),className:"text-left rounded-xl p-3 transition-all",style:{background:c?"var(--bg-glass-hover)":"var(--bg-glass)",border:c?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:c?1:.75},children:[u.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),u.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:h},children:"Fix the bug please"}),u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[c&&u.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-bold text-text-primary",children:a.id==="custom"?"🎨 Custom":a.name}),u.jsx("div",{className:"text-[10px] text-text-muted",children:a.description})]})]})]},a.id)})}),e==="custom"&&u.jsx(WM,{dark:r,onColorsChange:a=>s(a)})]})}const UM={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function KM(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function Z1(){return"Notification"in window&&Notification.permission==="granted"}let _i=null;async function VM(){if(_i!==null)return _i;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return _i=!1,!1;const e=await navigator.serviceWorker.getRegistration();return e?(_i=!!await e.pushManager.getSubscription(),_i):(_i=!1,!1)}catch{return _i=!1,!1}}function qM(e,t,r){if(Z1())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 YM(e,t={}){const r={...UM,...t},n=x.useRef(new Map),i=x.useRef(0),s=x.useRef(null);x.useEffect(()=>{VM().then(l=>{s.current=l})},[]);const o=x.useCallback((l,a,c)=>{const d=Date.now();d-i.current<r.throttleMs||(i.current=d,qM(l,a,c))},[r.throttleMs]);x.useEffect(()=>{var l;if(!(!r.enabled||!Z1())&&Hu("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&&Hu("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&&Hu("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])}const eb="adhdev_hiddenTabs";function XM(){try{const e=localStorage.getItem(eb);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function ro(e){try{localStorage.setItem(eb,JSON.stringify([...e]))}catch{}}function GM(){const[e,t]=x.useState(XM),r=x.useCallback(a=>{t(c=>{const d=new Set(c);return d.has(a)?d.delete(a):d.add(a),ro(d),d})},[]),n=x.useCallback(a=>{t(c=>{if(c.has(a))return c;const d=new Set(c);return d.add(a),ro(d),d})},[]),i=x.useCallback(a=>{t(c=>{if(!c.has(a))return c;const d=new Set(c);return d.delete(a),ro(d),d})},[]),s=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.add(f);return ro(h),h})},[]),o=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.delete(f);return ro(h),h})},[]),l=x.useCallback(a=>e.has(a),[e]);return{hiddenTabs:e,toggleTab:r,hideTab:n,showTab:i,hideAllForDaemon:s,showAllForDaemon:o,isHidden:l}}function tb({sendDaemonCommand:e,activeConv:t,ides:r,updateIdeChats:n,setToasts:i,setLocalUserMessages:s,setClearedTabs:o,setActionLogs:l,pinTab:a,isStandalone:c}){const[d,h]=x.useState(""),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[w,g]=x.useState(!1),v=x.useCallback(async()=>{if(!t)return;const k=d.trim();if(!k)return;const O=t.ideId,I=t.tabKey;h(""),a(I,[100,500,1500,3e3]);const R=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,C={role:"user",content:k,timestamp:Date.now(),_localId:R};s(B=>({...B,[I]:[...B[I]||[],C]}));try{if(oi(t)&&!cn(t)){const B=O||t.daemonId||"";if(!B)return;const z=t.ideType||t.agentType||"";await e(B,"agent_command",{agentType:z,cliType:z,action:"send_chat",message:k,text:k})}else if(cn(t)){const B=O||t.daemonId||"";if(!B)return;await e(B,"send_chat",{message:k,text:k,agentType:t.agentType})}else{const B=O||t.daemonId||"";if(!B)return;await e(B,"send_chat",{message:k,text:k,...t.streamSource==="agent-stream"&&{agentType:t.agentType}})}setTimeout(()=>{const B=Date.now()-6e4;s(z=>{const U=z[I];if(!U)return z;const M=U.filter($=>$.timestamp>B);return M.length===U.length?z:{...z,[I]:M}})},6e4)}catch(B){console.error("Send failed",B),h(k),s(z=>({...z,[I]:(z[I]||[]).filter(U=>U._localId!==R)}))}},[t,d,e,s,a]),y=x.useCallback(async()=>{if(t)try{c?await e(t.ideId,"launch_ide",{ideType:t.ideType,enableCdp:!0}):await e(t.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(k){console.error("Relaunch failed",k)}},[t,c,e]),S=x.useCallback(async k=>{try{await e("standalone","launch_ide",{ideType:k,enableCdp:!0})}catch(O){console.error("Launch failed",O)}},[e]),L=x.useCallback(async k=>{if(t){console.log("[ModalButton] ideId:",t.ideId,"button:",k),l(O=>[...O,{ideId:t.tabKey,text:`🖱️ **${k}** clicked`,timestamp:Date.now()}]);try{const I=(t.modalButtons||[]).indexOf(k),R=k.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),C=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(R),B=t.ideId||t.daemonId||"";(await e(B,"resolve_action",{button:k,action:C?"approve":"reject",...I>=0&&{buttonIndex:I},...t.streamSource==="agent-stream"&&{agentType:t.agentType}})).success||l(U=>[...U,{ideId:t.tabKey,text:`⚠️ **${k}** failed — button not found`,timestamp:Date.now()}])}catch(O){console.error("[ModalButton] Error:",O),l(I=>[...I,{ideId:t.tabKey,text:`❌ **${k}** error`,timestamp:Date.now()}])}}},[t,e,l]),E=x.useCallback(async(k,O)=>{try{const I=k||(t==null?void 0:t.daemonId)||"",R=await e(I,"switch_chat",{id:O,sessionId:O,...(t==null?void 0:t.streamSource)==="agent-stream"&&{agentType:t==null?void 0:t.agentType}}),C=R==null?void 0:R.result;(R==null?void 0:R.success)===!0||C==="switched"||C==="switched-by-title"||(C===!1||C==="not_found"?i(z=>[...z,{id:Date.now(),message:"⚠️ Session tab not found — try refreshing history",type:"warning",timestamp:Date.now()}]):typeof C=="string"&&C.startsWith("error:")?i(z=>[...z,{id:Date.now(),message:`⚠️ Switch error: ${C}`,type:"warning",timestamp:Date.now()}]):i(z=>[...z,{id:Date.now(),message:"⚠️ Session switch failed",type:"warning",timestamp:Date.now()}]))}catch(I){console.error("Switch failed",I),i(R=>[...R,{id:Date.now(),message:`❌ Switch failed: ${I.message||"connection error"}`,type:"warning",timestamp:Date.now()}])}},[t,e,i]),P=x.useCallback(async()=>{if(!(!t||f)){p(!0);try{const k=t.ideId||t.daemonId||"";await e(k,"new_chat",{...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),o(O=>({...O,[t.tabKey]:Date.now()})),s(O=>({...O,[t.tabKey]:[]}))}catch(k){console.error("New chat failed",k)}finally{p(!1)}}},[t,f,e,o,s]),N=x.useCallback(async()=>{if(!t||w)return;g(!0);const k=t.tabKey;try{await e(t.ideId,"agent_stream_focus",{agentType:t.agentType}),a(k,[200,1500,3e3])}catch(O){console.error("Focus agent failed",O)}finally{g(!1)}},[t,w,e,a]),A=x.useCallback(async()=>{var k;if(!(!t||m)){_(!0);try{const O=t.ideId||t.daemonId||"",I=await e(O,"list_chats",{forceExpand:!0,...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),R=(I==null?void 0:I.chats)||((k=I==null?void 0:I.result)==null?void 0:k.chats);I!=null&&I.success&&Array.isArray(R)&&n(t.ideId,R)}catch(O){console.error("Refresh history failed",O)}finally{_(!1)}}},[t,m,e,n]);return{agentInput:d,setAgentInput:h,isCreatingChat:f,isRefreshingHistory:m,isFocusingAgent:w,handleSendChat:v,handleRelaunch:y,handleLaunchIde:S,handleModalButton:L,handleSwitchSession:E,handleNewChat:P,handleFocusAgent:N,handleRefreshHistory:A}}let Uu=null;function QM({conversations:e,ides:t,messageReceivedAt:r,actionLogs:n,ptyBuffers:i,screenshotMap:s,setScreenshotMap:o,sendDaemonCommand:l,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m,userName:_,groupIndex:w,isFocused:g,onFocus:v,isSplitMode:y,numGroups:S,onMoveTab:L,onClose:E,onReceiveTab:P,style:N,detectedIdes:A,handleLaunchIde:k,onActiveTabChange:O,initialActiveTabId:I,initialTabOrder:R,onTabOrderChange:C,onHideTab:B}){const{sendCommand:z}=hi(),U=x.useRef(null),[M,$]=x.useState(!1),b=x.useRef(0),[Z,ne]=x.useState(I??null);x.useEffect(()=>{I&&I!==Z&&ne(I)},[I]);const[T,Y]=x.useState(R??[]),[D,W]=x.useState(null),X=x.useRef(null),he=x.useRef(null);x.useEffect(()=>{const H=new Set(e.map(ee=>ee.tabKey));Y(ee=>{const ce=ee.filter(Ne=>H.has(Ne)),Le=e.filter(Ne=>!ee.includes(Ne.tabKey)).map(Ne=>Ne.tabKey),Re=[...ce,...Le];return Re.length===ee.length&&Re.every((Ne,V)=>Ne===ee[V])?ee:Re})},[e]);const me=D??T,Ce=x.useMemo(()=>{if(me.length===0)return e;const H=new Map(me.map((ee,ce)=>[ee,ce]));return[...e].sort((ee,ce)=>{const Le=H.get(ee.tabKey)??999,Re=H.get(ce.tabKey)??999;return Le-Re})},[e,me]);x.useEffect(()=>{if(Ce.length===0){ne(null),O==null||O(null);return}Z&&Ce.some(H=>H.tabKey===Z)||(ne(Ce[0].tabKey),O==null||O(Ce[0].tabKey))},[Ce,Z]);const Se=Ce.find(H=>H.tabKey===Z),Fe=x.useCallback((H,ee,ce)=>{Y(Le=>{const Re=Le.filter(se=>se!==H),Ne=Re.indexOf(ee);if(Ne<0)return Le;const V=ce==="left"?Ne:Ne+1;return Re.splice(V,0,H),C==null||C(Re),Re}),W(null)},[C]),de=x.useCallback((H,ee,ce)=>{const Re=(T.length>0?T:e.map(se=>se.tabKey)).filter(se=>se!==H),Ne=Re.indexOf(ee);if(Ne<0)return;const V=ce==="left"?Ne:Ne+1;Re.splice(V,0,H),X.current=Re,W(Re)},[T,e]),xe=tb({sendDaemonCommand:l,activeConv:Se,ides:t,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m}),[G,_e]=x.useState(null);x.useEffect(()=>{if(!G)return;const H=ee=>{const ce=document.querySelector("[data-pane-context-menu]");ce&&ce.contains(ee.target)||_e(null)};return window.addEventListener("mousedown",H,!0),()=>window.removeEventListener("mousedown",H,!0)},[G]);const Pe="adhdev-tab-shortcuts",Ee=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[ye,wt]=x.useState(()=>{try{return JSON.parse(localStorage.getItem(Pe)||"{}")}catch{return{}}}),[At,et]=x.useState(null),or=x.useCallback(H=>{const ee=[];H.metaKey&&ee.push(Ee?"⌘":"Meta"),H.ctrlKey&&ee.push("Ctrl"),H.altKey&&ee.push(Ee?"⌥":"Alt"),H.shiftKey&&ee.push(Ee?"⇧":"Shift");const ce=H.key;if(["Control","Alt","Shift","Meta"].includes(ce))return null;const Le=ce.length===1?ce.toUpperCase():ce;return ee.push(Le),ee.join("+")},[Ee]),Nr=x.useCallback((H,ee)=>or(H)===ee,[or]),Bt=x.useCallback(H=>{wt(H),localStorage.setItem(Pe,JSON.stringify(H))},[]);x.useEffect(()=>{if(!At)return;const H=ee=>{if(ee.preventDefault(),ee.stopPropagation(),ee.key==="Escape"){et(null);return}const ce=or(ee);if(!ce)return;const Le={...ye};for(const[Re,Ne]of Object.entries(Le))Ne===ce&&delete Le[Re];Le[At]=ce,Bt(Le),et(null)};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[At,ye,Bt,or]),x.useEffect(()=>{const H=ee=>{if(!(!ee.ctrlKey&&!ee.metaKey&&!ee.altKey)){for(const[ce,Le]of Object.entries(ye))if(Nr(ee,Le)&&Ce.some(Re=>Re.tabKey===ce)){ee.preventDefault(),v(),ne(ce),O==null||O(ce);return}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[ye,Ce,v,O,Nr]);const q=Se&&oi(Se)&&!cn(Se);x.useEffect(()=>{const H=()=>{b.current=0,$(!1)};return window.addEventListener("dragend",H),window.addEventListener("drop",H),()=>{window.removeEventListener("dragend",H),window.removeEventListener("drop",H)}},[]);const oe=x.useRef(null);return x.useEffect(()=>{const H=oe.current;if(!H)return;const ee=ce=>{Math.abs(ce.deltaY)>Math.abs(ce.deltaX)&&(ce.preventDefault(),H.scrollLeft+=ce.deltaY)};return H.addEventListener("wheel",ee,{passive:!1}),()=>H.removeEventListener("wheel",ee)},[]),u.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:v,onDragEnter:H=>{if(H.dataTransfer.types.includes("text/tab-key")){b.current++;const ee=Uu;ee&&e.some(Le=>Le.tabKey===ee)||$(!0)}},onDragOver:H=>{H.dataTransfer.types.includes("text/tab-key")&&H.preventDefault()},onDragLeave:()=>{b.current--,b.current<=0&&(b.current=0,$(!1))},onDrop:H=>{b.current=0,$(!1),W(null);const ee=H.dataTransfer.getData("text/tab-key");if(!ee)return;H.preventDefault(),e.some(Le=>Le.tabKey===ee)?Y(Le=>{const Re=Le.filter(Ne=>Ne!==ee);return Re.push(ee),C==null||C(Re),Re}):P&&P(ee)},style:{...N,outline:M?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[u.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:u.jsxs("div",{ref:oe,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[Ce.map((H,ee)=>{const ce=Z===H.tabKey,Le=H.status==="working"?"agent-tab-working":H.status==="waiting_approval"?"agent-tab-waiting":"",Re=H.connectionState==="failed"||H.connectionState==="closed",Ne=he.current===H.tabKey;return u.jsxs("div",{"data-tabkey":H.tabKey,className:`${Le} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!("ontouchstart"in window),onDragStart:V=>{Uu=H.tabKey,he.current=H.tabKey,V.dataTransfer.setData("text/tab-key",H.tabKey),V.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Uu=null,he.current=null;const V=X.current;V&&(Y(V),C==null||C(V)),X.current=null,W(null),b.current=0,$(!1)},onDragOver:V=>{const se=he.current;if(!(!se||se===H.tabKey)&&V.dataTransfer.types.includes("text/tab-key")){V.preventDefault(),V.stopPropagation();const te=V.currentTarget.getBoundingClientRect(),be=te.left+te.width/2,Me=V.clientX<be?"left":"right";de(se,H.tabKey,Me)}},onDrop:V=>{V.preventDefault(),V.stopPropagation();const se=V.dataTransfer.getData("text/tab-key");if(se&&se!==H.tabKey){const te=V.currentTarget.getBoundingClientRect(),be=te.left+te.width/2,Me=V.clientX<be?"left":"right";Ce.some(ze=>ze.tabKey===se)?Fe(se,H.tabKey,Me):P&&P(se)}W(null)},onClick:V=>{V.stopPropagation(),v(),ne(H.tabKey),O==null||O(H.tabKey),H.streamSource==="agent-stream"&&H.agentType&&z(H.ideId,"agent_stream_focus",{agentType:H.agentType}).catch(()=>{}),oi(H)&&setTimeout(()=>{var se,te;return(te=(se=U.current)==null?void 0:se.bumpResize)==null?void 0:te.call(se)},100)},onContextMenu:V=>{"ontouchstart"in window||(V.preventDefault(),_e({x:V.clientX,y:V.clientY,tabKey:H.tabKey}))},style:{background:ce?"var(--bg-primary)":"var(--bg-glass)",borderTop:ce?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:ce?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:ce?"1px solid var(--border-subtle)":"1px solid transparent",opacity:Ne?.4:Re?ce?.6:.3:ce?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[H.status==="working"?u.jsx("div",{className:"tab-spinner"}):H.status==="waiting_approval"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):Re?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):H.connectionState==="connecting"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-blue-400",children:"○"}):H.connectionState==="connected"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):u.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted",children:"●"}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",children:H.displayPrimary}),u.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:Re?u.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):u.jsxs(u.Fragment,{children:[H.displaySecondary,H.machineName&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"opacity-40",children:"·"}),u.jsxs("span",{className:"opacity-70",children:["🖥 ",H.machineName]})]})]})})]}),ye[H.tabKey]&&u.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${ye[H.tabKey]}`,children:ye[H.tabKey]})]},H.tabKey)}),e.length===0&&u.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),u.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",children:Se?u.jsxs(u.Fragment,{children:[u.jsx(M1,{activeConv:Se,onModalButton:xe.handleModalButton}),u.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!q&&!cn(Se)&&s[Se.ideId]?u.jsx(fR,{screenshotUrl:s[Se.ideId],mode:"preview",onDismiss:()=>{const H={...s};delete H[Se.ideId],o(H)}}):!q&&!cn(Se)&&Se.cdpConnected===!1?u.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[u.jsx("span",{className:"text-sm",children:u.jsx(B0,{size:14})}),u.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),u.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:xe.handleRelaunch,children:"Relaunch with CDP"})]}):null}),q?u.jsx(mR,{activeConv:Se,ptyBuffers:i,terminalRef:U,agentInput:xe.agentInput,setAgentInput:xe.setAgentInput,handleSendChat:xe.handleSendChat,handleModalButton:xe.handleModalButton}):u.jsx(j1,{activeConv:Se,ides:t,agentInput:xe.agentInput,setAgentInput:xe.setAgentInput,handleSendChat:xe.handleSendChat,handleFocusAgent:xe.handleFocusAgent,isFocusingAgent:xe.isFocusingAgent,messageReceivedAt:r,actionLogs:n,userName:_})]}):u.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.length===0&&!y&&A&&k?u.jsxs("div",{className:"empty-dashboard",children:[u.jsx("div",{className:"glow-orb",children:u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-12 h-12"})}),u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"font-bold text-lg mb-1.5",children:"Waiting for your IDE"}),u.jsx("div",{className:"text-[13px] text-text-muted",style:{marginBottom:12},children:m?"Launch an IDE with CDP to start monitoring":"Install the daemon, then open your IDE — it connects automatically."}),!m&&u.jsxs("div",{style:{background:"var(--bg-secondary, #111)",borderRadius:"0.5rem",padding:"0.5rem 0.75rem",display:"inline-block",fontFamily:"monospace",fontSize:"0.75rem",color:"var(--accent, #a78bfa)",marginBottom:12,textAlign:"left",border:"1px solid var(--border-subtle, #333)"},children:[u.jsx("span",{style:{color:"var(--text-muted)"},children:"$ "}),"npm i -g adhdev && adhdev setup && adhdev daemon"]}),m&&A.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:A.map(H=>u.jsx("button",{className:"btn btn-sm bg-violet-500/10 border border-violet-500/25 text-violet-400 text-xs font-semibold px-4 py-2 rounded-lg cursor-pointer flex items-center gap-1.5 transition-all",onClick:()=>k(H.type),onMouseEnter:ee=>ee.currentTarget.style.background="rgba(139,92,246,0.2)",onMouseLeave:ee=>ee.currentTarget.style.background="rgba(139,92,246,0.1)",children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($P,{size:14})," Launch ",H.name]})},H.type))}),u.jsx("div",{style:{marginTop:8},children:u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Setup guide →"})})]})]}):u.jsx("div",{className:"text-sm text-text-muted opacity-50",children:y?"Move a tab here to view":"No active agent"})})}),G&&u.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:G.x,top:G.y},children:[L&&w>0&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"left"),_e(null)},children:"← Move to Left Group"}),L&&w<S-1&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"right"),_e(null)},children:"Move to Right Group →"}),L&&S<4&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:()=>{L(G.tabKey,"new"),_e(null)},children:"Split to New Group ◨"}),u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors",onClick:H=>{H.stopPropagation(),et(G.tabKey),_e(null)},children:["⌨ ",ye[G.tabKey]?`Change shortcut (${ye[G.tabKey]})`:"Set shortcut"]}),ye[G.tabKey]&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{const H={...ye};delete H[G.tabKey],Bt(H),_e(null)},children:"✕ Remove shortcut"}),B&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{B(G.tabKey),_e(null)},children:"🚫 Hide from Dashboard"})]}),!L&&!B&&u.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),At&&u.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>et(null),children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:H=>H.stopPropagation(),children:[u.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),u.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",Ee?"⌘+1":"Ctrl+1",", ",Ee?"⌥+A":"Alt+A",")"]}),u.jsx("div",{className:"text-lg font-mono text-accent-primary animate-pulse",children:"Listening..."}),u.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}const Ku=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and open your IDE — it connects automatically.",code:"npm i -g adhdev && adhdev setup && adhdev daemon"}];function JM({onClose:e}){const[t,r]=x.useState(0),n=Ku[t],i=t===Ku.length-1;return u.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:s=>{s.target===s.currentTarget&&e()},children:[u.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[u.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),u.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:Ku.map((s,o)=>u.jsx("div",{style:{width:o===t?24:8,height:8,borderRadius:4,background:o===t?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},o))}),u.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:n.visual||n.icon}),u.jsxs("div",{style:{textAlign:"center"},children:[u.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[u.jsx("span",{children:n.icon})," ",n.title]}),u.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:n.desc}),n.code&&u.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[u.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),n.code]}),i&&u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[u.jsx("button",{onClick:e,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),u.jsx("button",{onClick:()=>i?e():r(s=>s+1),style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer",transition:"opacity 0.2s"},onMouseEnter:s=>s.currentTarget.style.opacity="0.85",onMouseLeave:s=>s.currentTarget.style.opacity="1",children:i?"Get Started →":"Next →"})]})]}),u.jsx("style",{children:`
184
184
  @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
185
185
  @keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
186
- `})]})}function ZM(){const{sendCommand:e}=hi(),[t,r]=Ey(),n=t.get("activeTab"),i=Lc(),{updateIdeChats:s,screenshotMap:o,setScreenshotMap:l}=i,a=i.ides||[],[c,d]=x.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),h=i.toasts||[],f=i.setToasts||(()=>{}),p=i.wsStatus||"connected",m=i.isConnected??!0,_=i.connectionStates||{};i.retryConnection;const w=i.showReconnected||!1,[g,v]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_splitGroups");if(j){const F=JSON.parse(j);return new Map(F)}}catch{}return new Map}),[y,S]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_focusedGroup");if(j)return parseInt(j,10)||0}catch{}return 0}),[L,E]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_groupActiveTabs");if(j)return JSON.parse(j)}catch{}return{}}),P=x.useRef(!1),[N,A]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_groupTabOrders");if(j)return JSON.parse(j)}catch{}return{}}),[k,O]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_splitSizes");if(j)return JSON.parse(j)}catch{}return[]});x.useEffect(()=>{try{g.size===0?localStorage.removeItem("adhdev_splitGroups"):localStorage.setItem("adhdev_splitGroups",JSON.stringify([...g.entries()]))}catch{}},[g]),x.useEffect(()=>{try{k.length>0?localStorage.setItem("adhdev_splitSizes",JSON.stringify(k)):localStorage.removeItem("adhdev_splitSizes")}catch{}},[k]),x.useEffect(()=>{try{localStorage.setItem("adhdev_focusedGroup",String(y))}catch{}},[y]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupActiveTabs",JSON.stringify(L))}catch{}},[L]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupTabOrders",JSON.stringify(N))}catch{}},[N]);const[I,R]=x.useState(()=>typeof window<"u"&&window.innerWidth<768);x.useEffect(()=>{const j=window.matchMedia("(max-width: 767px)"),F=Q=>R(Q.matches);return j.addEventListener("change",F),()=>j.removeEventListener("change",F)},[]);const C=x.useMemo(()=>I||g.size===0?1:Math.max(1,...g.values())+1,[g,I]),B=C>1,z=x.useCallback((j,F)=>{v(Q=>{const K=new Map(Q);return F===0?K.delete(j):K.set(j,F),K}),S(F)},[]),U=x.useCallback(j=>{v(F=>{const K=(F.size===0?0:Math.max(0,...F.values()))+1;if(K>=4)return F;const ae=new Map(F);return ae.set(j,K),ae}),S(F=>F+1)},[]),M=x.useCallback(j=>{v(F=>{const Q=new Map;for(const[K,ae]of F)ae!==j&&(ae>j?Q.set(K,ae-1):Q.set(K,ae));return Q}),O(F=>{if(F.length<=1)return[];const Q=[...F];Q.splice(j,1);const K=Q.reduce((ae,Te)=>ae+Te,0);return Q.map(ae=>ae/K*100)}),S(0)},[]),$=x.useRef(null),b=x.useCallback((j,F)=>{F.preventDefault();const Q=$.current;if(!Q)return;const K=F.clientX,ae=Q.offsetWidth,Te=k.length===C?[...k]:Array(C).fill(100/C),Ue=We=>{const Ge=(We.clientX-K)/ae*100,Qt=[...Te];Qt[j]=Math.max(15,Te[j]+Ge),Qt[j+1]=Math.max(15,Te[j+1]-Ge),O(Qt)},$e=()=>{document.removeEventListener("mousemove",Ue),document.removeEventListener("mouseup",$e),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ue),document.addEventListener("mouseup",$e)},[k,C]),[Z,ne]=x.useState({}),[T,Y]=x.useState(!1),[D,W]=x.useState([]),[X,he]=x.useState({}),[me,Ce]=x.useState({}),[Se,Fe]=x.useState(!1),[de,xe]=x.useState(!1);x.useEffect(()=>{const j=Q=>{var K;(K=Q.dataTransfer)!=null&&K.types.includes("text/tab-key")&&xe(!0)},F=()=>{xe(!1),Fe(!1)};return window.addEventListener("dragstart",j),window.addEventListener("dragend",F),window.addEventListener("drop",F),()=>{window.removeEventListener("dragstart",j),window.removeEventListener("dragend",F),window.removeEventListener("drop",F)}},[]);const G=a.find(j=>j.type==="adhdev-daemon"),_e=(G==null?void 0:G.detectedIdes)||[],Pe=!!G,Ee=x.useMemo(()=>{const j=a.filter(Q=>Q.type!=="adhdev-daemon"),F=new Map;for(const Q of j){const K=F.get(Q.id);if(!K)F.set(Q.id,Q);else{const ae=(K.workspace?1:0)+(K.activeChat?1:0);((Q.workspace?1:0)+(Q.activeChat?1:0)>ae||(Q.timestamp||0)>(K.timestamp||0))&&F.set(Q.id,Q)}}return Array.from(F.values())},[a]),ye=x.useMemo(()=>{const j=TR(Ee,X,a,_),F=Date.now();return j.map(Q=>{const K=me[Q.tabKey];return K&&F-K<5e3?{...Q,messages:[],title:""}:Q})},[Ee,X,me,a]),{hiddenTabs:wt,toggleTab:At}=GM(),et=x.useMemo(()=>ye.filter(j=>!wt.has(j.tabKey)),[ye,wt]);x.useEffect(()=>{KM()},[]);const or=x.useMemo(()=>et.map(j=>({id:j.tabKey,name:j.title||j.agentName||j.ideId,status:j.status,activeModal:j.modalMessage?{message:j.modalMessage,buttons:j.modalButtons}:null})),[et]);YM(or);const Nr=x.useMemo(()=>{const j=Array.from({length:C},()=>[]);for(const F of et){const Q=g.get(F.tabKey)??0,K=Math.min(Q,C-1);j[K].push(F)}return j},[et,g,C]);x.useEffect(()=>{const j=new Set(et.map(F=>F.tabKey));v(F=>{let Q=!1;const K=new Map;for(const[ae,Te]of F)j.has(ae)?K.set(ae,Te):Q=!0;return Q?K:F})},[ye]),x.useEffect(()=>{if(B)for(let j=C-1;j>=1;j--)[...g.values()].some(Q=>Q===j)||M(j)},[g,C,B,M]),x.useEffect(()=>{if(!n||P.current||ye.length===0)return;const j=ye.find(F=>F.tabKey===n)||ye.find(F=>F.ideId===n)||ye.find(F=>F.ideType===n||F.agentType===n);if(j){const F=g.get(j.tabKey)??0;E(Q=>({...Q,[F]:j.tabKey})),S(F),P.current=!0,r(Q=>{const K=new URLSearchParams(Q);return K.delete("activeTab"),K},{replace:!0})}},[n,ye,g]),x.useEffect(()=>{if(Object.keys(me).length===0)return;const F=setTimeout(()=>{Ce(Q=>{const K=Date.now(),ae={};for(const[Te,Ue]of Object.entries(Q))K-Ue<5e3&&(ae[Te]=Ue);return Object.keys(ae).length===Object.keys(Q).length?Q:ae})},5500);return()=>clearTimeout(F)},[me]);const Bt=x.useMemo(()=>{var F,Q;const j=L[y];if(j){const K=ye.find(ae=>ae.tabKey===j);if(K)return K}return((F=Nr[y])==null?void 0:F[0])||((Q=Nr[0])==null?void 0:Q[0])},[L,y,ye,Nr]),q=x.useCallback((j,F)=>{},[]);x.useEffect(()=>{var K;const j=Date.now();let F=!1;const Q={...Z};for(const ae of ye)(K=ae.messages)!=null&&K.length&&ae.messages.forEach((Te,Ue)=>{const $e=`${ae.ideId}-${Te.id??`i-${Ue}`}`;Q[$e]==null&&(Q[$e]=j,F=!0)});F&&ne(Q)},[ye]);const oe=x.useRef(!1);x.useEffect(()=>{if(!T){oe.current=!1;return}if(!Bt||oe.current||Re)return;const j=a.find(F=>F.id===Bt.ideId);j&&(!j.chats||j.chats.length===0)&&(oe.current=!0,ee())},[T,Bt==null?void 0:Bt.ideId]),x.useEffect(()=>{const j=setInterval(()=>{const F=Date.now()-3e5;W(Q=>{const K=Q.filter(ae=>ae.timestamp>F).slice(-100);return K.length===Q.length?Q:K})},6e4);return()=>clearInterval(j)},[]);const H=x.useRef(new Map);x.useEffect(()=>{const j=(Q,K)=>{var ae;if(K){I1.emit(Q,K);for(const Te of ye){if(!oi(Te))continue;const Ue=(ae=Te.ideId)!=null&&ae.includes(":cli:")?Te.ideId.split(":cli:")[1]:"";if(Q===Ue||Q===Te.agentType||Q===Te.ideType){const We=H.current.get(Te.tabKey)||[];We.push(K),We.length>1e4&&We.splice(0,We.length-5e3),H.current.set(Te.tabKey,We)}}}},F=L_.onPtyOutput(j);return()=>{F()}},[ye]),x.useEffect(()=>{const j=F=>{if(F.ctrlKey&&F.key==="\\"){if(F.preventDefault(),B)v(new Map),S(0);else{const Q=ye[1];Q&&U(Q.tabKey)}return}F.ctrlKey&&(F.key==="["||F.key==="]")&&B&&(F.preventDefault(),S(Q=>F.key==="]"?Math.min(Q+1,C-1):Math.max(Q-1,0)))};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[B,ye,U,C]);const te=x.useRef(new Set),ce=x.useCallback(j=>{var Te,Ue;const F=`${j.ideId||""}:${j.event}:${Math.floor(Date.now()/2e3)}`;if(te.current.has(F))return;te.current.add(F),setTimeout(()=>te.current.delete(F),3e3);const Q=Dr(j.ideType||"");let K="",ae="info";if(j.event==="agent:generating_completed"){const $e=j.duration?` (${j.duration}s)`:"";K=`✅ ${Q} agent task completed${$e}`,ae="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}if(j.ideId){const We={role:"system",timestamp:Date.now(),content:`✅ Task completed${$e}`,_localId:`sys_complete_${Date.now()}`};he(qe=>{for(const Ge of Object.keys(qe))if(Ge.includes(j.ideId))return{...qe,[Ge]:[...qe[Ge]||[],We]};return qe})}}else if(j.event==="agent:generating_started")j.ideId&&he($e=>{const We={...$e};for(const qe of Object.keys(We))qe.includes(j.ideId)&&(We[qe]=(We[qe]||[]).filter(Ge=>{var Qt;return!(Ge.role==="system"&&((Qt=Ge._localId)!=null&&Qt.startsWith("sys_complete_")))}));return We});else if(j.event==="agent:waiting_approval"||j.event==="agent:approval_needed"){if(K=`⚡ ${Q} approval needed`,ae="warning",j.ideId){const $e=j.modalMessage||"Approval requested",We=(Te=j.modalButtons)!=null&&Te.length?j.modalButtons.map(Ge=>`[${Ge}]`).join(" "):"[Approve] [Reject]",qe={role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${$e}
187
- ${We}`,_localId:`sys_approval_${Date.now()}`};he(Ge=>{for(const Qt of Object.keys(Ge))if(Qt.includes(j.ideId))return{...Ge,[Qt]:[...Ge[Qt]||[],qe]};return Ge})}if(j.ideId&&((Ue=j.modalButtons)!=null&&Ue.length)){const $e=j.ideId,We=j.agentType||j.ideType||"",qe=j.ideType||"",Ge=j.modalButtons,Qt=lr=>lr.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),Rc=Ge.map((lr,jc)=>{const Ic=Qt(lr).toLowerCase(),rb=/^(run|approve|accept|yes|allow|always)/.test(Ic),nb=/^(reject|deny|delete|remove|abort|cancel|no)/.test(Ic);return{label:Qt(lr),variant:rb?"primary":nb?"danger":"default",onClick:()=>{let gp=$e;for(const Dc of a)if(Dc.id.startsWith($e)&&(!We||We===Dc.type)){gp=Dc.id;break}const ib=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(Ic);e(gp,"resolve_action",{action:ib?"approve":"reject",button:lr,buttonIndex:jc,agentType:We,ideType:qe}).catch(()=>{})}}}),Mc=j.modalMessage?`⚡ ${Q}: ${j.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:K,Bs=Date.now();f(lr=>[...lr.slice(-4),{id:Bs,message:Mc,type:ae,timestamp:Bs,ideId:$e,actions:Rc}]),setTimeout(()=>f(lr=>lr.filter(jc=>jc.id!==Bs)),15e3),K=""}}if(K){const $e=Date.now();f(We=>[...We.slice(-4),{id:$e,message:K,type:ae,timestamp:$e,ideId:j.ideId}]),setTimeout(()=>f(We=>We.filter(qe=>qe.id!==$e)),5e3)}},[a,e]);x.useEffect(()=>{const j=xR.on("status_event",ce),F=L_.onStatusEvent((Q,K)=>ce(K));return()=>{j(),F()}},[ce]),x.useEffect(()=>{var F;const j=Q=>{const K=Q.data;(K==null?void 0:K.type)==="notification_action"&&K.action==="approve"&&K.ideId&&e(K.ideId,"resolve_action",{action:"approve",button:"Approve"}).catch(ae=>console.error("[SW Action] approve failed:",ae))};return(F=navigator.serviceWorker)==null||F.addEventListener("message",j),()=>{var Q;return(Q=navigator.serviceWorker)==null?void 0:Q.removeEventListener("message",j)}},[]);const{isCreatingChat:Le,isRefreshingHistory:Re,handleLaunchIde:Ne,handleSwitchSession:V,handleNewChat:se,handleRefreshHistory:ee}=tb({sendDaemonCommand:e,activeConv:Bt,ides:a,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:Ce,setActionLogs:W,pinTab:q,isStandalone:Pe}),be=x.useMemo(()=>a.filter(j=>j.type==="adhdev-daemon"&&j.versionMismatch),[a]),[Me,ze]=x.useState(!1),[Ot,ve]=x.useState({}),Ve=x.useCallback(async j=>{var F,Q;ve(K=>({...K,[j]:"upgrading"}));try{const K=await e(j,"daemon_upgrade",{});(F=K==null?void 0:K.result)!=null&&F.upgraded||(Q=K==null?void 0:K.result)!=null&&Q.success?ve(ae=>({...ae,[j]:"done"})):ve(ae=>({...ae,[j]:"error"}))}catch{ve(K=>({...K,[j]:"error"}))}},[e]);return u.jsxs("div",{className:"page-dashboard flex-1 min-h-0 bg-bg-primary text-text-primary flex flex-col overflow-hidden",children:[u.jsx(gR,{wsStatus:p,showReconnected:w}),be.length>0&&!Me&&u.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-amber-500/[0.08] border-b border-amber-500/20 text-xs text-text-secondary shrink-0 flex-wrap",children:[u.jsx("span",{className:"text-sm shrink-0",children:"🔄"}),u.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[u.jsxs("span",{children:["Update available: ",u.jsxs("strong",{children:["v",be[0].version]})," → ",u.jsxs("strong",{children:["v",be[0].serverVersion]})]}),be.map(j=>{var K;const F=j.machineNickname||((K=j.machine)==null?void 0:K.hostname)||j.hostname||"Machine",Q=Ot[j.id];return u.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-amber-500/[0.08] border border-amber-500/15",children:[u.jsx("span",{className:"font-medium text-text-primary",children:F}),u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",j.version]}),Q==="upgrading"?u.jsx("span",{className:"text-[10px] text-amber-400 animate-pulse",children:"upgrading…"}):Q==="done"?u.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):Q==="error"?u.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>Ve(j.id),children:"retry"}):u.jsx("button",{className:"text-[10px] font-semibold text-amber-400 hover:text-amber-300 cursor-pointer px-1.5 py-px rounded bg-amber-500/10 border border-amber-500/20 transition-colors",onClick:()=>Ve(j.id),children:"Upgrade"})]},j.id)})]}),u.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:()=>ze(!0),title:"Dismiss",children:"✕"})]}),u.jsx(bR,{activeConv:Bt,agentCount:Ee.length,wsStatus:p,isConnected:m,onOpenHistory:()=>Y(!0)}),u.jsxs("div",{ref:$,className:`flex-1 min-h-0 flex ${B?"flex-row":"flex-col"} overflow-hidden`,children:[Nr.map((j,F)=>{const Q=B&&k.length===C?`${k[F]}%`:void 0;return u.jsxs(av.Fragment,{children:[B&&F>0&&u.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent-primary/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:K=>b(F-1,K),onDoubleClick:()=>M(F),title:"Drag to resize · Double-click to merge",children:u.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent-primary/10"})}),u.jsx(QM,{style:B?{flexBasis:Q??`${100/C}%`,flexGrow:Q?0:1,flexShrink:Q?0:1}:void 0,conversations:j,ides:a,messageReceivedAt:Z,actionLogs:D,ptyBuffers:H,screenshotMap:o,setScreenshotMap:l,sendDaemonCommand:e,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:Ce,setActionLogs:W,pinTab:q,isStandalone:Pe,userName:i.userName,groupIndex:F,isFocused:y===F,onFocus:()=>S(F),isSplitMode:B,numGroups:C,onMoveTab:(K,ae)=>{ae==="left"&&F>0?z(K,F-1):ae==="right"&&F<C-1?z(K,F+1):ae==="new"&&C<4&&U(K)},onClose:B?()=>M(F):void 0,onReceiveTab:K=>z(K,F),detectedIdes:F===0?_e:void 0,handleLaunchIde:F===0?Ne:void 0,onActiveTabChange:K=>E(ae=>({...ae,[F]:K})),initialActiveTabId:L[F],initialTabOrder:N[F],onTabOrderChange:K=>A(ae=>({...ae,[F]:K})),onHideTab:At})]},F)}),!I&&C<4&&u.jsxs("div",{className:"relative shrink-0 w-0 z-50",children:[u.jsx("div",{className:"fixed right-0 top-0 bottom-0 w-16",style:{pointerEvents:de?"auto":"none"},onDragOver:j=>{j.dataTransfer.types.includes("text/tab-key")&&(j.preventDefault(),Fe(!0))},onDragLeave:()=>Fe(!1),onDrop:j=>{j.preventDefault(),Fe(!1);const F=j.dataTransfer.getData("text/tab-key");F&&U(F)}}),u.jsx("div",{className:"absolute right-0 top-0 bottom-0 pointer-events-none transition-all duration-200",style:{width:Se?"120px":"0px",background:"var(--accent-primary)",opacity:Se?.15:0,borderLeft:Se?"2px dashed var(--accent-primary)":"none"}})]})]}),T&&Bt&&u.jsx(kR,{activeConv:Bt,ides:a,isCreatingChat:Le,isRefreshingHistory:Re,onClose:()=>Y(!1),onNewChat:se,onSwitchSession:V,onRefreshHistory:ee}),u.jsx("style",{children:`
186
+ `})]})}function ZM(){const{sendCommand:e}=hi(),[t,r]=Ey(),n=t.get("activeTab"),i=Lc(),{updateIdeChats:s,screenshotMap:o,setScreenshotMap:l}=i,a=i.ides||[],[c,d]=x.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),h=i.toasts||[],f=i.setToasts||(()=>{}),p=i.wsStatus||"connected",m=i.isConnected??!0,_=i.connectionStates||{};i.retryConnection;const w=i.showReconnected||!1,[g,v]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_splitGroups");if(j){const F=JSON.parse(j);return new Map(F)}}catch{}return new Map}),[y,S]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_focusedGroup");if(j)return parseInt(j,10)||0}catch{}return 0}),[L,E]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_groupActiveTabs");if(j)return JSON.parse(j)}catch{}return{}}),P=x.useRef(!1),[N,A]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_groupTabOrders");if(j)return JSON.parse(j)}catch{}return{}}),[k,O]=x.useState(()=>{try{const j=localStorage.getItem("adhdev_splitSizes");if(j)return JSON.parse(j)}catch{}return[]});x.useEffect(()=>{try{g.size===0?localStorage.removeItem("adhdev_splitGroups"):localStorage.setItem("adhdev_splitGroups",JSON.stringify([...g.entries()]))}catch{}},[g]),x.useEffect(()=>{try{k.length>0?localStorage.setItem("adhdev_splitSizes",JSON.stringify(k)):localStorage.removeItem("adhdev_splitSizes")}catch{}},[k]),x.useEffect(()=>{try{localStorage.setItem("adhdev_focusedGroup",String(y))}catch{}},[y]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupActiveTabs",JSON.stringify(L))}catch{}},[L]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupTabOrders",JSON.stringify(N))}catch{}},[N]);const[I,R]=x.useState(()=>typeof window<"u"&&window.innerWidth<768);x.useEffect(()=>{const j=window.matchMedia("(max-width: 767px)"),F=Q=>R(Q.matches);return j.addEventListener("change",F),()=>j.removeEventListener("change",F)},[]);const C=x.useMemo(()=>I||g.size===0?1:Math.max(1,...g.values())+1,[g,I]),B=C>1,z=x.useCallback((j,F)=>{v(Q=>{const K=new Map(Q);return F===0?K.delete(j):K.set(j,F),K}),S(F)},[]),U=x.useCallback(j=>{v(F=>{const K=(F.size===0?0:Math.max(0,...F.values()))+1;if(K>=4)return F;const ae=new Map(F);return ae.set(j,K),ae}),S(F=>F+1)},[]),M=x.useCallback(j=>{v(F=>{const Q=new Map;for(const[K,ae]of F)ae!==j&&(ae>j?Q.set(K,ae-1):Q.set(K,ae));return Q}),O(F=>{if(F.length<=1)return[];const Q=[...F];Q.splice(j,1);const K=Q.reduce((ae,Te)=>ae+Te,0);return Q.map(ae=>ae/K*100)}),S(0)},[]),$=x.useRef(null),b=x.useCallback((j,F)=>{F.preventDefault();const Q=$.current;if(!Q)return;const K=F.clientX,ae=Q.offsetWidth,Te=k.length===C?[...k]:Array(C).fill(100/C),Ue=We=>{const Ge=(We.clientX-K)/ae*100,Qt=[...Te];Qt[j]=Math.max(15,Te[j]+Ge),Qt[j+1]=Math.max(15,Te[j+1]-Ge),O(Qt)},$e=()=>{document.removeEventListener("mousemove",Ue),document.removeEventListener("mouseup",$e),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ue),document.addEventListener("mouseup",$e)},[k,C]),[Z,ne]=x.useState({}),[T,Y]=x.useState(!1),[D,W]=x.useState([]),[X,he]=x.useState({}),[me,Ce]=x.useState({}),[Se,Fe]=x.useState(!1),[de,xe]=x.useState(!1);x.useEffect(()=>{const j=Q=>{var K;(K=Q.dataTransfer)!=null&&K.types.includes("text/tab-key")&&xe(!0)},F=()=>{xe(!1),Fe(!1)};return window.addEventListener("dragstart",j),window.addEventListener("dragend",F),window.addEventListener("drop",F),()=>{window.removeEventListener("dragstart",j),window.removeEventListener("dragend",F),window.removeEventListener("drop",F)}},[]);const G=a.find(j=>j.type==="adhdev-daemon"),_e=(G==null?void 0:G.detectedIdes)||[],Pe=!!G,Ee=x.useMemo(()=>{const j=a.filter(Q=>Q.type!=="adhdev-daemon"),F=new Map;for(const Q of j){const K=F.get(Q.id);if(!K)F.set(Q.id,Q);else{const ae=(K.workspace?1:0)+(K.activeChat?1:0);((Q.workspace?1:0)+(Q.activeChat?1:0)>ae||(Q.timestamp||0)>(K.timestamp||0))&&F.set(Q.id,Q)}}return Array.from(F.values())},[a]),ye=x.useMemo(()=>{const j=TR(Ee,X,a,_),F=Date.now();return j.map(Q=>{const K=me[Q.tabKey];return K&&F-K<5e3?{...Q,messages:[],title:""}:Q})},[Ee,X,me,a]),{hiddenTabs:wt,toggleTab:At}=GM(),et=x.useMemo(()=>ye.filter(j=>!wt.has(j.tabKey)),[ye,wt]);x.useEffect(()=>{KM()},[]);const or=x.useMemo(()=>et.map(j=>({id:j.tabKey,name:j.title||j.agentName||j.ideId,status:j.status,activeModal:j.modalMessage?{message:j.modalMessage,buttons:j.modalButtons}:null})),[et]);YM(or);const Nr=x.useMemo(()=>{const j=Array.from({length:C},()=>[]);for(const F of et){const Q=g.get(F.tabKey)??0,K=Math.min(Q,C-1);j[K].push(F)}return j},[et,g,C]);x.useEffect(()=>{const j=new Set(et.map(F=>F.tabKey));v(F=>{let Q=!1;const K=new Map;for(const[ae,Te]of F)j.has(ae)?K.set(ae,Te):Q=!0;return Q?K:F})},[ye]),x.useEffect(()=>{if(B)for(let j=C-1;j>=1;j--)[...g.values()].some(Q=>Q===j)||M(j)},[g,C,B,M]),x.useEffect(()=>{if(!n||P.current||ye.length===0)return;const j=ye.find(F=>F.tabKey===n)||ye.find(F=>F.ideId===n)||ye.find(F=>F.ideType===n||F.agentType===n);if(j){const F=g.get(j.tabKey)??0;E(Q=>({...Q,[F]:j.tabKey})),S(F),P.current=!0,r(Q=>{const K=new URLSearchParams(Q);return K.delete("activeTab"),K},{replace:!0})}},[n,ye,g]),x.useEffect(()=>{if(Object.keys(me).length===0)return;const F=setTimeout(()=>{Ce(Q=>{const K=Date.now(),ae={};for(const[Te,Ue]of Object.entries(Q))K-Ue<5e3&&(ae[Te]=Ue);return Object.keys(ae).length===Object.keys(Q).length?Q:ae})},5500);return()=>clearTimeout(F)},[me]);const Bt=x.useMemo(()=>{var F,Q;const j=L[y];if(j){const K=ye.find(ae=>ae.tabKey===j);if(K)return K}return((F=Nr[y])==null?void 0:F[0])||((Q=Nr[0])==null?void 0:Q[0])},[L,y,ye,Nr]),q=x.useCallback((j,F)=>{},[]);x.useEffect(()=>{var K;const j=Date.now();let F=!1;const Q={...Z};for(const ae of ye)(K=ae.messages)!=null&&K.length&&ae.messages.forEach((Te,Ue)=>{const $e=`${ae.ideId}-${Te.id??`i-${Ue}`}`;Q[$e]==null&&(Q[$e]=j,F=!0)});F&&ne(Q)},[ye]);const oe=x.useRef(!1);x.useEffect(()=>{if(!T){oe.current=!1;return}if(!Bt||oe.current||Re)return;const j=a.find(F=>F.id===Bt.ideId);j&&(!j.chats||j.chats.length===0)&&(oe.current=!0,te())},[T,Bt==null?void 0:Bt.ideId]),x.useEffect(()=>{const j=setInterval(()=>{const F=Date.now()-3e5;W(Q=>{const K=Q.filter(ae=>ae.timestamp>F).slice(-100);return K.length===Q.length?Q:K})},6e4);return()=>clearInterval(j)},[]);const H=x.useRef(new Map);x.useEffect(()=>{const j=(Q,K)=>{var ae;if(K){I1.emit(Q,K);for(const Te of ye){if(!oi(Te))continue;const Ue=(ae=Te.ideId)!=null&&ae.includes(":cli:")?Te.ideId.split(":cli:")[1]:"";if(Q===Ue||Q===Te.agentType||Q===Te.ideType){const We=H.current.get(Te.tabKey)||[];We.push(K),We.length>1e4&&We.splice(0,We.length-5e3),H.current.set(Te.tabKey,We)}}}},F=L_.onPtyOutput(j);return()=>{F()}},[ye]),x.useEffect(()=>{const j=F=>{if(F.ctrlKey&&F.key==="\\"){if(F.preventDefault(),B)v(new Map),S(0);else{const Q=ye[1];Q&&U(Q.tabKey)}return}F.ctrlKey&&(F.key==="["||F.key==="]")&&B&&(F.preventDefault(),S(Q=>F.key==="]"?Math.min(Q+1,C-1):Math.max(Q-1,0)))};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[B,ye,U,C]);const ee=x.useRef(new Set),ce=x.useCallback(j=>{var Te,Ue;const F=`${j.ideId||""}:${j.event}:${Math.floor(Date.now()/2e3)}`;if(ee.current.has(F))return;ee.current.add(F),setTimeout(()=>ee.current.delete(F),3e3);const Q=Dr(j.ideType||"");let K="",ae="info";if(j.event==="agent:generating_completed"){const $e=j.duration?` (${j.duration}s)`:"";K=`✅ ${Q} agent task completed${$e}`,ae="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}if(j.ideId){const We={role:"system",timestamp:Date.now(),content:`✅ Task completed${$e}`,_localId:`sys_complete_${Date.now()}`};he(qe=>{for(const Ge of Object.keys(qe))if(Ge.includes(j.ideId))return{...qe,[Ge]:[...qe[Ge]||[],We]};return qe})}}else if(j.event==="agent:generating_started")j.ideId&&he($e=>{const We={...$e};for(const qe of Object.keys(We))qe.includes(j.ideId)&&(We[qe]=(We[qe]||[]).filter(Ge=>{var Qt;return!(Ge.role==="system"&&((Qt=Ge._localId)!=null&&Qt.startsWith("sys_complete_")))}));return We});else if(j.event==="agent:waiting_approval"||j.event==="agent:approval_needed"){if(K=`⚡ ${Q} approval needed`,ae="warning",j.ideId){const $e=j.modalMessage||"Approval requested",We=(Te=j.modalButtons)!=null&&Te.length?j.modalButtons.map(Ge=>`[${Ge}]`).join(" "):"[Approve] [Reject]",qe={role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${$e}
187
+ ${We}`,_localId:`sys_approval_${Date.now()}`};he(Ge=>{for(const Qt of Object.keys(Ge))if(Qt.includes(j.ideId))return{...Ge,[Qt]:[...Ge[Qt]||[],qe]};return Ge})}if(j.ideId&&((Ue=j.modalButtons)!=null&&Ue.length)){const $e=j.ideId,We=j.agentType||j.ideType||"",qe=j.ideType||"",Ge=j.modalButtons,Qt=lr=>lr.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),Rc=Ge.map((lr,jc)=>{const Ic=Qt(lr).toLowerCase(),rb=/^(run|approve|accept|yes|allow|always)/.test(Ic),nb=/^(reject|deny|delete|remove|abort|cancel|no)/.test(Ic);return{label:Qt(lr),variant:rb?"primary":nb?"danger":"default",onClick:()=>{let gp=$e;for(const Dc of a)if(Dc.id.startsWith($e)&&(!We||We===Dc.type)){gp=Dc.id;break}const ib=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(Ic);e(gp,"resolve_action",{action:ib?"approve":"reject",button:lr,buttonIndex:jc,agentType:We,ideType:qe}).catch(()=>{})}}}),Mc=j.modalMessage?`⚡ ${Q}: ${j.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:K,Bs=Date.now();f(lr=>[...lr.slice(-4),{id:Bs,message:Mc,type:ae,timestamp:Bs,ideId:$e,actions:Rc}]),setTimeout(()=>f(lr=>lr.filter(jc=>jc.id!==Bs)),15e3),K=""}}if(K){const $e=Date.now();f(We=>[...We.slice(-4),{id:$e,message:K,type:ae,timestamp:$e,ideId:j.ideId}]),setTimeout(()=>f(We=>We.filter(qe=>qe.id!==$e)),5e3)}},[a,e]);x.useEffect(()=>{const j=xR.on("status_event",ce),F=L_.onStatusEvent((Q,K)=>ce(K));return()=>{j(),F()}},[ce]),x.useEffect(()=>{var F;const j=Q=>{const K=Q.data;(K==null?void 0:K.type)==="notification_action"&&K.action==="approve"&&K.ideId&&e(K.ideId,"resolve_action",{action:"approve",button:"Approve"}).catch(ae=>console.error("[SW Action] approve failed:",ae))};return(F=navigator.serviceWorker)==null||F.addEventListener("message",j),()=>{var Q;return(Q=navigator.serviceWorker)==null?void 0:Q.removeEventListener("message",j)}},[]);const{isCreatingChat:Le,isRefreshingHistory:Re,handleLaunchIde:Ne,handleSwitchSession:V,handleNewChat:se,handleRefreshHistory:te}=tb({sendDaemonCommand:e,activeConv:Bt,ides:a,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:Ce,setActionLogs:W,pinTab:q,isStandalone:Pe}),be=x.useMemo(()=>a.filter(j=>j.type==="adhdev-daemon"&&j.versionMismatch),[a]),[Me,ze]=x.useState(!1),[Ot,ve]=x.useState({}),Ve=x.useCallback(async j=>{var F,Q;ve(K=>({...K,[j]:"upgrading"}));try{const K=await e(j,"daemon_upgrade",{});(F=K==null?void 0:K.result)!=null&&F.upgraded||(Q=K==null?void 0:K.result)!=null&&Q.success?ve(ae=>({...ae,[j]:"done"})):ve(ae=>({...ae,[j]:"error"}))}catch{ve(K=>({...K,[j]:"error"}))}},[e]);return u.jsxs("div",{className:"page-dashboard flex-1 min-h-0 bg-bg-primary text-text-primary flex flex-col overflow-hidden",children:[u.jsx(gR,{wsStatus:p,showReconnected:w}),be.length>0&&!Me&&u.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-amber-500/[0.08] border-b border-amber-500/20 text-xs text-text-secondary shrink-0 flex-wrap",children:[u.jsx("span",{className:"text-sm shrink-0",children:"🔄"}),u.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[u.jsxs("span",{children:["Update available: ",u.jsxs("strong",{children:["v",be[0].version]})," → ",u.jsxs("strong",{children:["v",be[0].serverVersion]})]}),be.map(j=>{var K;const F=j.machineNickname||((K=j.machine)==null?void 0:K.hostname)||j.hostname||"Machine",Q=Ot[j.id];return u.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-amber-500/[0.08] border border-amber-500/15",children:[u.jsx("span",{className:"font-medium text-text-primary",children:F}),u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",j.version]}),Q==="upgrading"?u.jsx("span",{className:"text-[10px] text-amber-400 animate-pulse",children:"upgrading…"}):Q==="done"?u.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):Q==="error"?u.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>Ve(j.id),children:"retry"}):u.jsx("button",{className:"text-[10px] font-semibold text-amber-400 hover:text-amber-300 cursor-pointer px-1.5 py-px rounded bg-amber-500/10 border border-amber-500/20 transition-colors",onClick:()=>Ve(j.id),children:"Upgrade"})]},j.id)})]}),u.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:()=>ze(!0),title:"Dismiss",children:"✕"})]}),u.jsx(bR,{activeConv:Bt,agentCount:Ee.length,wsStatus:p,isConnected:m,onOpenHistory:()=>Y(!0)}),u.jsxs("div",{ref:$,className:`flex-1 min-h-0 flex ${B?"flex-row":"flex-col"} overflow-hidden`,children:[Nr.map((j,F)=>{const Q=B&&k.length===C?`${k[F]}%`:void 0;return u.jsxs(av.Fragment,{children:[B&&F>0&&u.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent-primary/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:K=>b(F-1,K),onDoubleClick:()=>M(F),title:"Drag to resize · Double-click to merge",children:u.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent-primary/10"})}),u.jsx(QM,{style:B?{flexBasis:Q??`${100/C}%`,flexGrow:Q?0:1,flexShrink:Q?0:1}:void 0,conversations:j,ides:a,messageReceivedAt:Z,actionLogs:D,ptyBuffers:H,screenshotMap:o,setScreenshotMap:l,sendDaemonCommand:e,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:Ce,setActionLogs:W,pinTab:q,isStandalone:Pe,userName:i.userName,groupIndex:F,isFocused:y===F,onFocus:()=>S(F),isSplitMode:B,numGroups:C,onMoveTab:(K,ae)=>{ae==="left"&&F>0?z(K,F-1):ae==="right"&&F<C-1?z(K,F+1):ae==="new"&&C<4&&U(K)},onClose:B?()=>M(F):void 0,onReceiveTab:K=>z(K,F),detectedIdes:F===0?_e:void 0,handleLaunchIde:F===0?Ne:void 0,onActiveTabChange:K=>E(ae=>({...ae,[F]:K})),initialActiveTabId:L[F],initialTabOrder:N[F],onTabOrderChange:K=>A(ae=>({...ae,[F]:K})),onHideTab:At})]},F)}),!I&&C<4&&u.jsxs("div",{className:"relative shrink-0 w-0 z-50",children:[u.jsx("div",{className:"fixed right-0 top-0 bottom-0 w-16",style:{pointerEvents:de?"auto":"none"},onDragOver:j=>{j.dataTransfer.types.includes("text/tab-key")&&(j.preventDefault(),Fe(!0))},onDragLeave:()=>Fe(!1),onDrop:j=>{j.preventDefault(),Fe(!1);const F=j.dataTransfer.getData("text/tab-key");F&&U(F)}}),u.jsx("div",{className:"absolute right-0 top-0 bottom-0 pointer-events-none transition-all duration-200",style:{width:Se?"120px":"0px",background:"var(--accent-primary)",opacity:Se?.15:0,borderLeft:Se?"2px dashed var(--accent-primary)":"none"}})]})]}),T&&Bt&&u.jsx(kR,{activeConv:Bt,ides:a,isCreatingChat:Le,isRefreshingHistory:Re,onClose:()=>Y(!1),onNewChat:se,onSwitchSession:V,onRefreshHistory:te}),u.jsx("style",{children:`
188
188
  body { overflow: hidden; overscroll-behavior: none; }
189
189
  .pulse-amber { animation: pulse-amber 2s infinite ease-in-out; }
190
190
  @keyframes pulse-amber {
@@ -199,4 +199,4 @@ ${We}`,_localId:`sys_approval_${Date.now()}`};he(Ge=>{for(const Qt of Object.key
199
199
  }
200
200
  `}),c&&u.jsx(JM,{onClose:()=>{try{localStorage.setItem("adhdev_onboarding_v1","done")}catch{}d(!1)}})]})}function ej(e){return e.split(":")[0]||""}function tj({renderHeaderActions:e}={}){var Fe,de,xe;const{id:t}=wy(),r=Tn(),n=Lc(),i=n.ides||[],s=n.connectionStates||{},{sendCommand:o}=hi(),l=x.useMemo(()=>ej(t||""),[t]),a=x.useMemo(()=>i.find(G=>G.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"),_=x.useMemo(()=>i.find(G=>G.id===l||G.daemonId===l),[i,l]),w=(_==null?void 0:_.machineNickname)||((Fe=_==null?void 0:_.machine)==null?void 0:Fe.hostname)||"",g=(a==null?void 0:a.workspace)||"",[v]=Ey(),y=typeof window<"u"&&window.innerWidth<=768,S=v.get("view")||(y?"chat":"split"),[L,E]=x.useState(S),[P,N]=x.useState("native"),[A,k]=x.useState(""),[O,I]=x.useState(!1),[R,C]=x.useState(null),[B,z]=x.useState(null),[U,M]=x.useState([]),$=h==null?void 0:h.status,b=(((xe=(de=h==null?void 0:h.activeModal)==null?void 0:de.buttons)==null?void 0:xe.length)??0)>0,Z=$==="generating"||$==="loading"||$&&$.toLowerCase()==="thinking",T=b||$==="waiting_approval"?"waiting_approval":Z?"working":$||"idle",Y=x.useMemo(()=>{var G,_e;return{ideId:t||"",daemonId:l,agentName:Bd(c||""),agentType:c||"",status:T,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:(G=h==null?void 0:h.activeModal)==null?void 0:G.buttons,modalMessage:(_e=h==null?void 0:h.activeModal)==null?void 0:_e.message,streamSource:"native",tabKey:`ide-${t}`}},[t,l,c,h,a,d,T]),D=x.useMemo(()=>f.map(G=>{var Pe,Ee;const _e=G.activeModal?"waiting_approval":G.status==="streaming"?"working":G.status||"idle";return{ideId:t||"",daemonId:l,agentName:G.agentName,agentType:G.agentType,status:_e,title:"",messages:G.messages.map((ye,wt)=>({role:ye.role,content:ye.content,kind:ye.kind,id:`${G.agentType}-${wt}`,receivedAt:ye.timestamp})),ideType:G.agentType,workspaceName:"",displayPrimary:G.agentName,displaySecondary:"",cdpConnected:!0,modalButtons:(Pe=G.activeModal)==null?void 0:Pe.buttons,modalMessage:(Ee=G.activeModal)==null?void 0:Ee.message,streamSource:"agent-stream",tabKey:`agent-stream-${G.agentType}`}}),[f,t,l]),W=x.useMemo(()=>P==="native"?Y:D.find(G=>G.agentType===P)||Y,[P,Y,D]);x.useEffect(()=>l?yr.onScreenshot("ide-page",(_e,Pe)=>{if(_e!==l)return;const Ee=new FileReader;Ee.onload=()=>C(Ee.result),Ee.readAsDataURL(Pe)}):void 0,[l]),x.useEffect(()=>l?yr.onStatusEvent((_e,Pe)=>{if(_e!==l)return;let Ee="",ye="info";if(Pe.event==="agent:generating_completed"?(Ee=`✅ Task completed${Pe.duration?` (${Pe.duration}s)`:""}`,ye="success"):(Pe.event==="agent:waiting_approval"||Pe.event==="agent:approval_requested")&&(Ee="⚡ Approval needed",ye="warning"),Ee){const wt=Date.now();M(et=>[...et.slice(-4),{id:wt,message:Ee,type:ye}]),setTimeout(()=>M(et=>et.filter(or=>or.id!==wt)),ye==="warning"?1e4:5e3)}}):void 0,[l]);const X=x.useMemo(()=>{if(!t)return c;const G=t.split(":");return G.length>=3&&G[1]==="ide"?G.slice(2).join(":"):c},[t,c]);x.useEffect(()=>{const G=l?yr.get(l):null;!G||!(m==="connected")||(L!=="chat"&&X?G.startScreenshots(X):G.stopScreenshots(X))},[L,m,X,l]);const he=x.useCallback(async(G,_e={})=>{if(!t)throw new Error("No IDE ID");const Pe={..._e};if(!Pe._targetInstance&&t){const ye=t.split(":");ye.length>=3&&(ye[1]==="ide"||ye[1]==="cli")&&(Pe._targetInstance=ye.slice(2).join(":"),Pe._targetType=ye[1])}const Ee=l?yr.get(l):null;return Ee!=null&&Ee.hasCommandChannel?await Ee.sendCommand(G,Pe):Ee&&Ee.connectionState!=="failed"&&Ee.connectionState!=="closed"&&await new Promise(wt=>{const At=Date.now(),et=()=>{if(Ee.hasCommandChannel)return wt(!0);if(Date.now()-At>3e3)return wt(!1);setTimeout(et,200)};et()})&&Ee.hasCommandChannel?await Ee.sendCommand(G,Pe):await o(t,G,Pe)},[t,l]),me=async()=>{const G=A.trim();if(!(!G||!t||O)){k(""),I(!0);try{await he("send_chat",{message:G,text:G,waitForResponse:!0,...P!=="native"&&{agentType:P}})}catch(_e){console.error("[IDE] Send failed:",_e)}finally{I(!1)}}},Ce=async G=>{if(t)try{const _e=await o(t,"screenshot",{width:G?Math.min(G,1280):1280});_e!=null&&_e.success&&(_e!=null&&_e.base64)&&z(`data:image/jpeg;base64,${_e.base64}`)}catch(_e){console.error("[IDE] Screenshot failed:",_e)}},Se=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(Va,{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(G=>u.jsx("button",{className:"btn btn-secondary btn-sm",style:{border:L===G?"1px solid var(--accent-primary)":"none",background:L===G?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:L===G?"var(--accent-primary)":void 0},onClick:()=>E(G),children:G==="chat"?u.jsx(Va,{size:14}):G==="split"?"⊞":u.jsx(ul,{size:14})},G)),e&&e({daemonId:l,ideInstanceId:t||""}),u.jsxs("button",{className:"btn btn-primary btn-sm border-none px-3 py-1.5 text-xs flex items-center justify-center shrink-0",onClick:()=>r(-1),children:["←",u.jsx("span",{className:"hidden md:inline ml-1",children:"Back"})]})]})]}),u.jsxs("div",{className:"ide-content",children:[u.jsxs("div",{className:`ide-chat-panel ${L==="chat"?"full":""} ${L==="remote"?"hidden":""}`,children:[Se&&u.jsxs("div",{className:"ide-chat-tabs",children:[u.jsx("button",{className:`ide-chat-tab ${P==="native"?"active":""}`,onClick:()=>N("native"),children:d}),f.map(G=>{const _e=P===G.agentType,Pe=G.status==="waiting_approval"||!!G.activeModal,Ee=G.status==="streaming";return u.jsxs("button",{className:`ide-chat-tab ${_e?"active":""}`,onClick:()=>N(G.agentType),children:[u.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",marginRight:5,background:Pe?"#f59e0b":Ee?"var(--accent-primary)":"#64748b",boxShadow:Ee?"0 0 6px var(--accent-primary)":"none"}}),G.agentName,Pe&&u.jsx("span",{className:"ide-ext-badge",style:{background:"#f59e0b22",color:"#f59e0b",marginLeft:4},children:"!"})]},G.agentType)})]}),u.jsx(j1,{activeConv:W,ides:i,agentInput:A,setAgentInput:k,handleSendChat:me,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[],userName:n.userName})]}),u.jsx("div",{className:`ide-remote-panel ${L==="remote"?"full":""} ${L==="chat"?"hidden":""}`,children:u.jsx(dR,{screenshot:B,isCapturing:!1,onRefresh:Ce,addLog:()=>{},connState:m,connScreenshot:R,onAction:async(G,_e)=>{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 Ee=(a==null?void 0:a.instanceId)||X;return await Pe.sendInput(G,_e,Ee)}})})]}),U.length>0&&u.jsx("div",{className:"ide-toasts",children:U.map(G=>u.jsx("div",{className:`ide-toast ${G.type}`,onClick:()=>M(_e=>_e.filter(Pe=>Pe.id!==G.id)),children:G.message},G.id))})]}):u.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function rj({machineId:e,sendDaemonCommand:t,logsEndRef:r}){const[n,i]=x.useState([]),[s,o]=x.useState(null),[l,a]=x.useState(!1),[c,d]=x.useState(!1),[h,f]=x.useState(!1),[p,m]=x.useState([]),[_,w]=x.useState([]),[g,v]=x.useState(null),[y,S]=x.useState(!1),[L,E]=x.useState(""),P=x.useRef(null),N=x.useCallback(Y=>{P.current=Y},[]),A=x.useCallback((Y,D)=>{i(W=>[...W.slice(-100),{timestamp:Date.now(),level:Y,message:D}]),setTimeout(()=>{var W;return(W=r.current)==null?void 0:W.scrollIntoView({behavior:"smooth"})},100)},[r]),k=x.useCallback(async Y=>{if(!(!e||s)){o(Y),A("info",`Launching ${Dr(Y)}...`);try{const D=await t(e,"launch_ide",{ideType:Y,enableCdp:!0});A(D!=null&&D.success?"info":"error",D!=null&&D.success?`${Dr(Y)} launched`:`Failed: ${D==null?void 0:D.error}`)}catch(D){A("error",`Launch error: ${D.message}`)}finally{o(null)}}},[e,s,A,t]),O=x.useCallback(async Y=>{if(!e)return;const{cliType:D,dir:W,workspaceId:X,useDefaultWorkspace:he,useHome:me,argsStr:Ce,model:Se}=Y;if(!D){A("warn","Select a CLI or ACP provider first");return}const Fe=Ce?Ce.split(/\s+/).filter(Boolean):void 0,de=(W==null?void 0:W.trim())||(X?"(saved id)":he?"(default workspace)":me?"(home)":"");A("info",`Launching ${D}${de?` in ${de}`:""}${Se?` (model: ${Se})`:""}...`);try{const xe={cliType:D,cliArgs:Fe,initialModel:Se||void 0};W!=null&&W.trim()?xe.dir=W.trim():X?xe.workspaceId=X:he?xe.useDefaultWorkspace=!0:me&&(xe.useHome=!0);const G=await t(e,"launch_cli",xe),_e=(G==null?void 0:G.result)||G;G!=null&&G.success?(A("info",`${D} launched`),(_e==null?void 0:_e.launchSource)==="home"?A("info","📂 Running in home directory (explicit choice)"):(_e==null?void 0:_e.launchSource)==="defaultWorkspace"&&A("info","📂 Using default workspace (explicit choice)")):(A("error",`Failed: ${(G==null?void 0:G.error)||(_e==null?void 0:_e.error)}`),(G==null?void 0:G.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&v({cliType:D,argsStr:Ce,model:Se}))}catch(xe){A("error",`Launch error: ${xe.message}`)}},[e,A,t]),I=x.useCallback((Y,D,W,X)=>{if(e){if(!Y){A("warn","Select a provider");return}if(!D.trim()){v({cliType:Y,argsStr:W,model:X});return}O({cliType:Y,dir:D,argsStr:W,model:X})}},[e,A,O]),R=x.useCallback(async(Y,D,W)=>{if(e&&window.confirm(`Stop ${Y}?
201
201
  This will terminate the process.`))try{const X=await t(e,"stop_cli",{cliType:Y,dir:D,_targetInstance:W});X!=null&&X.success?A("info",`${Y} stopped`):A("error",`Stop failed: ${(X==null?void 0:X.error)||"Unknown error"}`)}catch(X){A("error",`Stop failed: ${X.message}`)}},[e,A,t]),C=x.useCallback(async Y=>{try{await t(Y.daemonId,"restart_ide",{ideType:Y.type}),A("info",`${Dr(Y.type)} restart initiated`)}catch(D){A("error",`Restart failed: ${D.message}`)}},[A,t]),B=x.useCallback(async Y=>{if(window.confirm(`Stop ${Dr(Y.type)}?
202
- This will disconnect CDP and optionally kill the process.`))try{const D=await t(Y.daemonId,"stop_ide",{ideType:Y.type,killProcess:!0});D!=null&&D.success?A("info",`${Dr(Y.type)} stopped`):A("error",`Stop failed: ${(D==null?void 0:D.error)||"Unknown error"}`)}catch(D){A("error",`Stop failed: ${D.message}`)}},[A,t]),z=x.useCallback(async()=>{if(e)try{const Y=await t(e,"detect_ides",{});A("info",`Found ${((Y==null?void 0:Y.result)||[]).length} IDE(s)`)}catch(Y){A("error",`Detection failed: ${Y.message}`)}},[e,A,t]),U=x.useCallback(async()=>{if(e){a(!0);try{const Y=await t(e,"get_recent_workspaces",{});Y!=null&&Y.success&&Array.isArray(Y==null?void 0:Y.result)&&w(Y.result)}catch(Y){A("error",`Failed: ${Y.message}`)}finally{a(!1)}}},[e,A,t]),M=x.useCallback(async Y=>{if(!(!e||!Y.trim())){d(!0);try{const D=await t(e,"workspace_add",{path:Y.trim()});D!=null&&D.success?A("info",`Workspace added: ${Y.trim()}`):A("error",(D==null?void 0:D.error)||"workspace_add failed")}catch(D){A("error",D.message)}finally{d(!1)}return!0}},[e,A,t]),$=x.useCallback(async Y=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const D=await t(e,"workspace_remove",{id:Y});D!=null&&D.success?A("info","Workspace removed"):A("error",(D==null?void 0:D.error)||"workspace_remove failed")}catch(D){A("error",D.message)}finally{d(!1)}}},[e,A,t]),b=x.useCallback(async Y=>{var D;if(e){d(!0);try{const W=await t(e,"workspace_set_default",Y===null?{clear:!0}:{id:Y});if(W!=null&&W.success){A("info",Y?"Default workspace updated":"Default workspace cleared");const X=typeof W.defaultWorkspacePath=="string"?W.defaultWorkspacePath:"";X&&((D=P.current)==null||D.call(P,X))}else A("error",(W==null?void 0:W.error)||"workspace_set_default failed")}catch(W){A("error",W.message)}finally{d(!1)}}},[e,A,t]),Z=x.useCallback(async Y=>{var W;if(!e||!Y.trim())return;const D=Y.trim();d(!0);try{const X=await t(e,"workspace_set_default",{path:D});X!=null&&X.success?(A("info","Default workspace set from history"),(W=P.current)==null||W.call(P,D)):A("error",(X==null?void 0:X.error)||"Could not set default (path missing on disk?)")}catch(X){A("error",X.message)}finally{d(!1)}},[e,A,t]),ne=x.useCallback(async()=>{var Y;if(e){f(!0);try{const D=await t(e,"get_cli_history",{}),W=(D==null?void 0:D.history)??((Y=D==null?void 0:D.result)==null?void 0:Y.history);D!=null&&D.success&&Array.isArray(W)&&m(W)}catch{}f(!1)}},[e,t]),T=x.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:L}),A("info",`Nickname set to "${L||"(cleared)"}"`),S(!1)}catch(Y){A("error",`Failed: ${Y.message}`)}},[e,L,A,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:y,setEditingNickname:S,nicknameInput:L,setNicknameInput:E,addLog:A,handleLaunchIde:k,runLaunchCliCore:O,handleLaunchCli:I,handleStopCli:R,handleRestartIde:C,handleStopIde:B,handleDetectIdes:z,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:M,handleWorkspaceRemove:$,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:Z,loadCliHistory:ne,handleSaveNickname:T,setOnDefaultWorkspaceChanged:N}}function nj(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function ij({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=Tn(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:w}=o,[g,v]=x.useState("");x.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),x.useEffect(()=>{d()},[d]);const y=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-y)/e.totalMem*100))):0,L=e.loadavg[0]||0,E=P=>{const N=i.find(A=>A.type===P);(N==null?void 0:N.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(Wl,{icon:u.jsx(jg,{size:16}),label:"Uptime",value:wR(e.uptime)}),u.jsx(Wl,{icon:u.jsx(ul,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Wl,{icon:u.jsx(z0,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Wl,{icon:u.jsx($0,{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(P_,{value:Math.min(Math.round(L/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${L.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(P_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${R_(e.totalMem-y)} / ${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.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(qa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:P=>void m(P.target.value===""?null:P.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(P=>u.jsx("option",{value:P.id,children:P.label||P.path},P.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:P=>v(P.target.value),onKeyDown:P=>P.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(P=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:P.path,children:P.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(P.id),children:"Remove"})]},P.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(jg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((P,N)=>{const A=P.label||`${P.cliType} · ${(P.dir||"").split("/").filter(Boolean).pop()||P.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:P.dir,children:[s(P.cliType)," ",A]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:P.dir,children:P.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:P.cliType,dir:P.dir,argsStr:(P.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>E(P.cliType),children:"Open tab…"})]})]},`${P.cliType}-${P.dir}-${P.timestamp}-${N}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(P=>{const N=P.path.split("/").filter(Boolean).pop()||P.path,A=P.kind==="ide"?"IDE":P.kind==="cli"?"CLI":P.kind==="acp"?"ACP":P.kind==="default"||P.kind==="active"?"●":"",k=(P.kind==="cli"||P.kind==="acp")&&!!P.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:P.path,children:N}),A&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:A}),P.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:P.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:nj(P.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[k&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:P.agentType,dir:P.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(P.path),children:"Set default"})]})]},`${P.path}-${P.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(P=>{var A;const N=(P.agentStreams||[]).some(k=>k.status==="generating"||k.status==="streaming")||((A=P.activeChat)==null?void 0:A.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${P.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${N?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Dr(P.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace||""}),N&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${N?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:N?"#fb923c":"#22c55e",boxShadow:N?"0 0 8px rgba(249,115,22,0.4)":"none",animation:N?"pulse-dot 1.5s infinite":"none"}})]},P.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(P=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:P.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:P.status==="stopped"?"#ef4444":"#22c55e"}})]},P.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(P=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${P.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(P.type)}),P.name||P.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:P.running?"#22c55e":"#475569"}})]},P.type))})]})]})}function sj({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=Tn(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=x.useState({}),[m,_]=x.useState(null),w=e.detectedIdes||[];return x.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),y=(v==null?void 0:v.result)||v;y!=null&&y.success&&(y!=null&&y.ides)&&p(y.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Dr(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ul,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const y=`${g.type}.${v.type}`;_(y);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(L=>L.type===v.type?{...L,enabled:!L.enabled}:L)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",w.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.map(g=>{const v=g.running||r.some(y=>(y.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Dr(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),w.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(AP,{size:12})," Scan"]})]})]})]})}function K_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=Tn(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,w=e==="cli",g=w?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=w?"CLI":"ACP Agent",y=r.filter(R=>R.category===e),[S,L]=x.useState(""),[E,P]=x.useState(""),[N,A]=x.useState(""),[k,O]=x.useState("");x.useEffect(()=>{!S&&y.length>0&&L(y[0].type)},[S,y.length]),x.useEffect(()=>{t.defaultWorkspacePath&&!E&&P(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const I=R=>w?R.cliName:R.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:R=>L(R.target.value),className:"machine-input",children:y.length>0?y.map(R=>u.jsxs("option",{value:R.type,children:[R.icon," ",R.displayName]},R.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:E,onChange:R=>P(R.target.value),className:"machine-input flex-1 min-w-[200px]"}),!w&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:k,onChange:R=>O(R.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:N,onChange:R=>A(R.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,E,N||void 0,w?void 0:k||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:N||void 0,model:w?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:N||void 0,model:w?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",w?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(R=>{const C=w?null:R;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(R.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:I(R)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:R.workspace}),(C==null?void 0:C.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",C.currentModel]}),(C==null?void 0:C.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",C.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${R.status==="stopped"?"bg-red-500/[0.08] text-red-500":R.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:R.status}),!w&&u.jsx("button",{onClick:()=>o(`/ide/${R.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Va,{size:14})}),R.status==="stopped"?u.jsx("button",{onClick:()=>l(R.type,R.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(R.type,R.workspace,R.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},R.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const R=new Set(y.map(B=>B.type)),C=p.filter(B=>R.has(B.cliType));return C.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:C.map((B,z)=>{var U,M;return u.jsxs("div",{onClick:()=>{L(B.cliType),P(B.dir),A((B.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-[background] duration-150",onMouseEnter:$=>$.currentTarget.style.background="var(--bg-glass-hover)",onMouseLeave:$=>$.currentTarget.style.background="var(--bg-glass)",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(B.cliType)}),u.jsx("span",{children:((U=B.dir)==null?void 0:U.split("/").filter(Boolean).pop())||"root"}),((M=B.cliArgs)==null?void 0:M.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:B.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:B.timestamp?new Date(B.timestamp).toLocaleDateString():""})]},z)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",w?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((R,C)=>u.jsx("button",{onClick:()=>P(R),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:R,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(qa,{size:12})," ",R.split("/").filter(Boolean).pop()||R]})},C))})]})]})}function oj({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=x.useState([]),[s,o]=x.useState(!1),[l,a]=x.useState(null),[c,d]=x.useState("all"),h=x.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 y=t.find(S=>S.type===g);w.push({type:g,displayName:(y==null?void 0:y.displayName)||g,icon:(y==null?void 0:y.icon)||"",category:(y==null?void 0:y.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]);x.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 y=m.get(v.key),S=!!(g.values[v.key]??v.default);y?(y.onCount+=S?1:0,y.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const w=async(g,v)=>{for(const y of p)await f(y.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 y=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void w(g,!0),disabled:y,className:`machine-btn text-[9px] px-1.5 py-px ${y?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void w(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const w=parseInt(_.target.value)||0;m.min!==void 0&&w<m.min||m.max!==void 0&&w>m.max||f(p.type,m.key,w)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function lj({machineId:e,sendDaemonCommand:t}){const[r,n]=x.useState([]),[i,s]=x.useState(0),[o,l]=x.useState(!0),[a,c]=x.useState("debug"),d=x.useRef(null),h=x.useRef(!1);return x.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(y=>({timestamp:y.ts,level:y.level,message:`[${y.category}] ${y.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]),x.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 aj({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/[0.08] transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function cj(){var S,L,E,P,N,A,k,O,I,R;const{id:e}=wy(),t=Tn(),{sendCommand:r}=hi(),n=Lc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=x.useState("overview"),a=x.useRef(null),c=rj({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(C=>C.id===e&&C.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(C=>({type:C.type,displayName:C.displayName,icon:C.icon,category:C.category})),f={};for(const C of h)f[C.type]=C.icon;const p=C=>f[C]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((L=d.machine)==null?void 0:L.platform)||"unknown",arch:((E=d.machine)==null?void 0:E.arch)||"",cpus:((P=d.machine)==null?void 0:P.cpus)||0,totalMem:((N=d.machine)==null?void 0:N.totalMem)||0,freeMem:((A=d.machine)==null?void 0:A.freeMem)||0,availableMem:(k=d.machine)==null?void 0:k.availableMem,loadavg:((O=d.machine)==null?void 0:O.loadavg)||[],uptime:((I=d.machine)==null?void 0:I.uptime)||0,release:((R=d.machine)==null?void 0:R.release)||"",cdpConnected:!!(d.ides||[]).some(C=>C.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(C=>C.daemonId===e&&!C.daemonMode).filter(C=>!M_(C)&&!j_(C)).map(C=>({id:C.id,type:C.type,version:C.version||"",instanceId:C.instanceId||"",status:C.status,workspace:C.workspace||null,terminals:C.terminals||0,aiAgents:SR(C.aiAgents||C.agents||[]),activeChat:C.activeChat||null,chats:C.chats||[],agentStreams:C.agentStreams||[],cdpConnected:C.cdpConnected||!1,daemonId:e})),w=i.filter(C=>C.daemonId===e&&M_(C)).map(C=>({id:C.id,type:C.type,cliName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,daemonId:e})),g=i.filter(C=>C.daemonId===e&&j_(C)).map(C=>({id:C.id,type:C.type,acpName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,currentModel:C.currentModel,currentPlan:C.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,y=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ul,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(O0,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($0,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(A0,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(jP,{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:C=>c.setNicknameInput(C.target.value),onKeyDown:C=>{C.key==="Enter"&&c.handleSaveNickname(),C.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:y.map(C=>u.jsxs("button",{onClick:()=>l(C.id),className:`machine-tab shrink-0${o===C.id?" active":""}`,children:[C.label,C.count!==void 0&&u.jsx("span",{className:"tab-count",children:C.count})]},C.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(ij,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:C=>l(C)}),o==="ides"&&u.jsx(sj,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(K_,{category:"cli",machine:m,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(K_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(oj,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(lj,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(aj,{machine:m,launchPick:c.launchPick,actions:c})]})}function uj(){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 V_=uj(),q_=3e3,hj=3e4;let _n=null,dj=0;const tc=new Map,Fd=new Set;let vi=null;async function ga(e,t,r){const n=_n;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++dj}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{tc.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);tc.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 fj{constructor(t){Os(this,"daemonId");Os(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 ga(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return ga(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 ga(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());Fd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let xi=null;function pj(e){(!xi||xi.daemonId!==e)&&(xi=new fj(e));const t=yr._originalGet||yr.get.bind(yr);yr._originalGet=t,yr.get=r=>r===e||r.startsWith("standalone")?xi:t(r),yr.getState=r=>(r===e||r.startsWith("standalone"))&&(xi==null?void 0:xi.connectionState)||"disconnected",yr.onScreenshot=(r,n)=>(Fd.add(n),()=>{Fd.delete(n)})}function mj({children:e}){const t=x.useRef(Dm()),r=Dm();t.current=r;const{setUserName:n}=Vo(),i=x.useRef(n);i.current=n;const[,s]=x.useState("disconnected"),o=x.useRef(null),l=x.useRef(),a=x.useRef(q_),c=x.useRef(!0);return x.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 ${V_}...`);let f;try{f=new WebSocket(V_)}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=q_,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=tc.get(g.requestId);v&&(tc.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:y,markLoaded:S}=t.current,L=v.id||"standalone";pj(L);const E=PR(v,{daemonId:L});E.length>0&&y(E),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,hj),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 gj({children:e}){return u.jsx(Lk,{children:u.jsx(mj,{children:e})})}const _j=[{id:"dashboard",path:"/dashboard",icon:u.jsx(RP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(MP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(A0,{}),label:"Settings"}];function vj({children:e}){const t=Tn(),r=ol(),[n,i]=x.useState(!1),[s,o]=x.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:_j.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(IP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.5.55"]}),u.jsx(NM,{collapsed:s}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const xj=[{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."}],yj=[{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."}],bj=[{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}],Vu={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 wj(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.5.55"]})]}),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:xj.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:Vu.ides},{label:"Extension agents",items:Vu.agents},{label:"CLI agents",items:Vu.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:bj.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:yj.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 ADHDev · Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function Sj(){const{ides:e}=Vo(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=hi(),{userName:i}=Vo(),[s,o]=x.useState(i||"");x.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]=x.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(yM,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Qi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.5.55"]}),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(Qi,{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(Qi,{title:"Machine",className:"mb-4",children:u.jsx(IM,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Qi,{title:"Chat theme",className:"mb-4",children:u.jsx(HM,{})}),u.jsx(Qi,{title:"Notifications",className:"mb-4",children:u.jsx(jM,{})}),u.jsx(Qi,{title:"Preferences",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-hover transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]}),u.jsx(Zi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})})]})]})}FM();function Y_(){const{ides:e}=Vo(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(ia,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(ia,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(ia,{to:"/dashboard",replace:!0})}function kj(){return u.jsx(Tk,{children:u.jsx(gj,{children:u.jsx(Ik,{value:{sendCommand:ga,sendData:()=>!1},children:u.jsx(vj,{children:u.jsxs(kk,{children:[u.jsx(pn,{path:"/dashboard",element:u.jsx(ZM,{})}),u.jsx(pn,{path:"/ide/:id",element:u.jsx(tj,{})}),u.jsx(pn,{path:"/machine",element:u.jsx(Y_,{})}),u.jsx(pn,{path:"/machines/:id",element:u.jsx(cj,{})}),u.jsx(pn,{path:"/machines",element:u.jsx(Y_,{})}),u.jsx(pn,{path:"/about",element:u.jsx(wj,{})}),u.jsx(pn,{path:"/settings",element:u.jsx(Sj,{})}),u.jsx(pn,{path:"*",element:u.jsx(ia,{to:"/dashboard",replace:!0})})]})})})})})}dy(document.getElementById("root")).render(u.jsx(x.StrictMode,{children:u.jsx(kj,{})}));
202
+ This will disconnect CDP and optionally kill the process.`))try{const D=await t(Y.daemonId,"stop_ide",{ideType:Y.type,killProcess:!0});D!=null&&D.success?A("info",`${Dr(Y.type)} stopped`):A("error",`Stop failed: ${(D==null?void 0:D.error)||"Unknown error"}`)}catch(D){A("error",`Stop failed: ${D.message}`)}},[A,t]),z=x.useCallback(async()=>{if(e)try{const Y=await t(e,"detect_ides",{});A("info",`Found ${((Y==null?void 0:Y.result)||[]).length} IDE(s)`)}catch(Y){A("error",`Detection failed: ${Y.message}`)}},[e,A,t]),U=x.useCallback(async()=>{if(e){a(!0);try{const Y=await t(e,"get_recent_workspaces",{});Y!=null&&Y.success&&Array.isArray(Y==null?void 0:Y.result)&&w(Y.result)}catch(Y){A("error",`Failed: ${Y.message}`)}finally{a(!1)}}},[e,A,t]),M=x.useCallback(async Y=>{if(!(!e||!Y.trim())){d(!0);try{const D=await t(e,"workspace_add",{path:Y.trim()});D!=null&&D.success?A("info",`Workspace added: ${Y.trim()}`):A("error",(D==null?void 0:D.error)||"workspace_add failed")}catch(D){A("error",D.message)}finally{d(!1)}return!0}},[e,A,t]),$=x.useCallback(async Y=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const D=await t(e,"workspace_remove",{id:Y});D!=null&&D.success?A("info","Workspace removed"):A("error",(D==null?void 0:D.error)||"workspace_remove failed")}catch(D){A("error",D.message)}finally{d(!1)}}},[e,A,t]),b=x.useCallback(async Y=>{var D;if(e){d(!0);try{const W=await t(e,"workspace_set_default",Y===null?{clear:!0}:{id:Y});if(W!=null&&W.success){A("info",Y?"Default workspace updated":"Default workspace cleared");const X=typeof W.defaultWorkspacePath=="string"?W.defaultWorkspacePath:"";X&&((D=P.current)==null||D.call(P,X))}else A("error",(W==null?void 0:W.error)||"workspace_set_default failed")}catch(W){A("error",W.message)}finally{d(!1)}}},[e,A,t]),Z=x.useCallback(async Y=>{var W;if(!e||!Y.trim())return;const D=Y.trim();d(!0);try{const X=await t(e,"workspace_set_default",{path:D});X!=null&&X.success?(A("info","Default workspace set from history"),(W=P.current)==null||W.call(P,D)):A("error",(X==null?void 0:X.error)||"Could not set default (path missing on disk?)")}catch(X){A("error",X.message)}finally{d(!1)}},[e,A,t]),ne=x.useCallback(async()=>{var Y;if(e){f(!0);try{const D=await t(e,"get_cli_history",{}),W=(D==null?void 0:D.history)??((Y=D==null?void 0:D.result)==null?void 0:Y.history);D!=null&&D.success&&Array.isArray(W)&&m(W)}catch{}f(!1)}},[e,t]),T=x.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:L}),A("info",`Nickname set to "${L||"(cleared)"}"`),S(!1)}catch(Y){A("error",`Failed: ${Y.message}`)}},[e,L,A,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:y,setEditingNickname:S,nicknameInput:L,setNicknameInput:E,addLog:A,handleLaunchIde:k,runLaunchCliCore:O,handleLaunchCli:I,handleStopCli:R,handleRestartIde:C,handleStopIde:B,handleDetectIdes:z,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:M,handleWorkspaceRemove:$,handleWorkspaceSetDefault:b,handleWorkspaceResumePath:Z,loadCliHistory:ne,handleSaveNickname:T,setOnDefaultWorkspaceChanged:N}}function nj(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function ij({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=Tn(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:w}=o,[g,v]=x.useState("");x.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),x.useEffect(()=>{d()},[d]);const y=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-y)/e.totalMem*100))):0,L=e.loadavg[0]||0,E=P=>{const N=i.find(A=>A.type===P);(N==null?void 0:N.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(Wl,{icon:u.jsx(jg,{size:16}),label:"Uptime",value:wR(e.uptime)}),u.jsx(Wl,{icon:u.jsx(ul,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Wl,{icon:u.jsx(z0,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Wl,{icon:u.jsx($0,{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(P_,{value:Math.min(Math.round(L/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${L.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(P_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${R_(e.totalMem-y)} / ${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.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(qa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:P=>void m(P.target.value===""?null:P.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(P=>u.jsx("option",{value:P.id,children:P.label||P.path},P.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:P=>v(P.target.value),onKeyDown:P=>P.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(P=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:P.path,children:P.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(P.id),children:"Remove"})]},P.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(jg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((P,N)=>{const A=P.label||`${P.cliType} · ${(P.dir||"").split("/").filter(Boolean).pop()||P.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:P.dir,children:[s(P.cliType)," ",A]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:P.dir,children:P.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:P.cliType,dir:P.dir,argsStr:(P.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>E(P.cliType),children:"Open tab…"})]})]},`${P.cliType}-${P.dir}-${P.timestamp}-${N}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(P=>{const N=P.path.split("/").filter(Boolean).pop()||P.path,A=P.kind==="ide"?"IDE":P.kind==="cli"?"CLI":P.kind==="acp"?"ACP":P.kind==="default"||P.kind==="active"?"●":"",k=(P.kind==="cli"||P.kind==="acp")&&!!P.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:P.path,children:N}),A&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:A}),P.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:P.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:nj(P.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[k&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void w({cliType:P.agentType,dir:P.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(P.path),children:"Set default"})]})]},`${P.path}-${P.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(P=>{var A;const N=(P.agentStreams||[]).some(k=>k.status==="generating"||k.status==="streaming")||((A=P.activeChat)==null?void 0:A.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${P.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${N?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Dr(P.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace||""}),N&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${N?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:N?"#fb923c":"#22c55e",boxShadow:N?"0 0 8px rgba(249,115,22,0.4)":"none",animation:N?"pulse-dot 1.5s infinite":"none"}})]},P.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(P=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:P.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:P.status==="stopped"?"#ef4444":"#22c55e"}})]},P.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(P=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${P.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(P.type)}),P.name||P.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:P.running?"#22c55e":"#475569"}})]},P.type))})]})]})}function sj({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=Tn(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=x.useState({}),[m,_]=x.useState(null),w=e.detectedIdes||[];return x.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),y=(v==null?void 0:v.result)||v;y!=null&&y.success&&(y!=null&&y.ides)&&p(y.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Dr(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ul,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const y=`${g.type}.${v.type}`;_(y);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(L=>L.type===v.type?{...L,enabled:!L.enabled}:L)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",w.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.map(g=>{const v=g.running||r.some(y=>(y.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Dr(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),w.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(AP,{size:12})," Scan"]})]})]})]})}function K_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=Tn(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,w=e==="cli",g=w?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=w?"CLI":"ACP Agent",y=r.filter(R=>R.category===e),[S,L]=x.useState(""),[E,P]=x.useState(""),[N,A]=x.useState(""),[k,O]=x.useState("");x.useEffect(()=>{!S&&y.length>0&&L(y[0].type)},[S,y.length]),x.useEffect(()=>{t.defaultWorkspacePath&&!E&&P(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const I=R=>w?R.cliName:R.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:R=>L(R.target.value),className:"machine-input",children:y.length>0?y.map(R=>u.jsxs("option",{value:R.type,children:[R.icon," ",R.displayName]},R.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:E,onChange:R=>P(R.target.value),className:"machine-input flex-1 min-w-[200px]"}),!w&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:k,onChange:R=>O(R.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:N,onChange:R=>A(R.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,E,N||void 0,w?void 0:k||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:N||void 0,model:w?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:N||void 0,model:w?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",w?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(R=>{const C=w?null:R;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(R.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:I(R)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:R.workspace}),(C==null?void 0:C.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",C.currentModel]}),(C==null?void 0:C.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",C.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${R.status==="stopped"?"bg-red-500/[0.08] text-red-500":R.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:R.status}),!w&&u.jsx("button",{onClick:()=>o(`/ide/${R.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Va,{size:14})}),R.status==="stopped"?u.jsx("button",{onClick:()=>l(R.type,R.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(R.type,R.workspace,R.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},R.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const R=new Set(y.map(B=>B.type)),C=p.filter(B=>R.has(B.cliType));return C.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:C.map((B,z)=>{var U,M;return u.jsxs("div",{onClick:()=>{L(B.cliType),P(B.dir),A((B.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-[background] duration-150",onMouseEnter:$=>$.currentTarget.style.background="var(--bg-glass-hover)",onMouseLeave:$=>$.currentTarget.style.background="var(--bg-glass)",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(B.cliType)}),u.jsx("span",{children:((U=B.dir)==null?void 0:U.split("/").filter(Boolean).pop())||"root"}),((M=B.cliArgs)==null?void 0:M.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:B.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:B.timestamp?new Date(B.timestamp).toLocaleDateString():""})]},z)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",w?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((R,C)=>u.jsx("button",{onClick:()=>P(R),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:R,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(qa,{size:12})," ",R.split("/").filter(Boolean).pop()||R]})},C))})]})]})}function oj({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=x.useState([]),[s,o]=x.useState(!1),[l,a]=x.useState(null),[c,d]=x.useState("all"),h=x.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 y=t.find(S=>S.type===g);w.push({type:g,displayName:(y==null?void 0:y.displayName)||g,icon:(y==null?void 0:y.icon)||"",category:(y==null?void 0:y.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]);x.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 y=m.get(v.key),S=!!(g.values[v.key]??v.default);y?(y.onCount+=S?1:0,y.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const w=async(g,v)=>{for(const y of p)await f(y.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 y=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void w(g,!0),disabled:y,className:`machine-btn text-[9px] px-1.5 py-px ${y?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void w(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const w=parseInt(_.target.value)||0;m.min!==void 0&&w<m.min||m.max!==void 0&&w>m.max||f(p.type,m.key,w)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function lj({machineId:e,sendDaemonCommand:t}){const[r,n]=x.useState([]),[i,s]=x.useState(0),[o,l]=x.useState(!0),[a,c]=x.useState("debug"),d=x.useRef(null),h=x.useRef(!1);return x.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(y=>({timestamp:y.ts,level:y.level,message:`[${y.category}] ${y.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]),x.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 aj({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/[0.08] transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function cj(){var S,L,E,P,N,A,k,O,I,R;const{id:e}=wy(),t=Tn(),{sendCommand:r}=hi(),n=Lc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=x.useState("overview"),a=x.useRef(null),c=rj({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(C=>C.id===e&&C.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(C=>({type:C.type,displayName:C.displayName,icon:C.icon,category:C.category})),f={};for(const C of h)f[C.type]=C.icon;const p=C=>f[C]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((L=d.machine)==null?void 0:L.platform)||"unknown",arch:((E=d.machine)==null?void 0:E.arch)||"",cpus:((P=d.machine)==null?void 0:P.cpus)||0,totalMem:((N=d.machine)==null?void 0:N.totalMem)||0,freeMem:((A=d.machine)==null?void 0:A.freeMem)||0,availableMem:(k=d.machine)==null?void 0:k.availableMem,loadavg:((O=d.machine)==null?void 0:O.loadavg)||[],uptime:((I=d.machine)==null?void 0:I.uptime)||0,release:((R=d.machine)==null?void 0:R.release)||"",cdpConnected:!!(d.ides||[]).some(C=>C.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(C=>C.daemonId===e&&!C.daemonMode).filter(C=>!M_(C)&&!j_(C)).map(C=>({id:C.id,type:C.type,version:C.version||"",instanceId:C.instanceId||"",status:C.status,workspace:C.workspace||null,terminals:C.terminals||0,aiAgents:SR(C.aiAgents||C.agents||[]),activeChat:C.activeChat||null,chats:C.chats||[],agentStreams:C.agentStreams||[],cdpConnected:C.cdpConnected||!1,daemonId:e})),w=i.filter(C=>C.daemonId===e&&M_(C)).map(C=>({id:C.id,type:C.type,cliName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,daemonId:e})),g=i.filter(C=>C.daemonId===e&&j_(C)).map(C=>({id:C.id,type:C.type,acpName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,currentModel:C.currentModel,currentPlan:C.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,y=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ul,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(O0,{size:14})," CLIs"]}),count:w.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($0,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(A0,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(jP,{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:C=>c.setNicknameInput(C.target.value),onKeyDown:C=>{C.key==="Enter"&&c.handleSaveNickname(),C.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:y.map(C=>u.jsxs("button",{onClick:()=>l(C.id),className:`machine-tab shrink-0${o===C.id?" active":""}`,children:[C.label,C.count!==void 0&&u.jsx("span",{className:"tab-count",children:C.count})]},C.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(ij,{machine:m,managedIdes:_,managedClis:w,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:C=>l(C)}),o==="ides"&&u.jsx(sj,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(K_,{category:"cli",machine:m,providers:h,managedEntries:w,getIcon:p,actions:c}),o==="acps"&&u.jsx(K_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(oj,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(lj,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(aj,{machine:m,launchPick:c.launchPick,actions:c})]})}function uj(){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 V_=uj(),q_=3e3,hj=3e4;let _n=null,dj=0;const tc=new Map,Fd=new Set;let vi=null;async function ga(e,t,r){const n=_n;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++dj}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{tc.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);tc.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 fj{constructor(t){Os(this,"daemonId");Os(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 ga(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return ga(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 ga(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());Fd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let xi=null;function pj(e){(!xi||xi.daemonId!==e)&&(xi=new fj(e));const t=yr._originalGet||yr.get.bind(yr);yr._originalGet=t,yr.get=r=>r===e||r.startsWith("standalone")?xi:t(r),yr.getState=r=>(r===e||r.startsWith("standalone"))&&(xi==null?void 0:xi.connectionState)||"disconnected",yr.onScreenshot=(r,n)=>(Fd.add(n),()=>{Fd.delete(n)})}function mj({children:e}){const t=x.useRef(Dm()),r=Dm();t.current=r;const{setUserName:n}=Vo(),i=x.useRef(n);i.current=n;const[,s]=x.useState("disconnected"),o=x.useRef(null),l=x.useRef(),a=x.useRef(q_),c=x.useRef(!0);return x.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 ${V_}...`);let f;try{f=new WebSocket(V_)}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=q_,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=tc.get(g.requestId);v&&(tc.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:y,markLoaded:S}=t.current,L=v.id||"standalone";pj(L);const E=PR(v,{daemonId:L});E.length>0&&y(E),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,hj),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 gj({children:e}){return u.jsx(Lk,{children:u.jsx(mj,{children:e})})}const _j=[{id:"dashboard",path:"/dashboard",icon:u.jsx(RP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(MP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(A0,{}),label:"Settings"}];function vj({children:e}){const t=Tn(),r=ol(),[n,i]=x.useState(!1),[s,o]=x.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:_j.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(IP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.5.57"]}),u.jsx(NM,{collapsed:s}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const xj=[{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."}],yj=[{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."}],bj=[{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}],Vu={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 wj(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.5.57"]})]}),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:xj.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:Vu.ides},{label:"Extension agents",items:Vu.agents},{label:"CLI agents",items:Vu.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:bj.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:yj.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 ADHDev · Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function Sj(){const{ides:e}=Vo(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=hi(),{userName:i}=Vo(),[s,o]=x.useState(i||"");x.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]=x.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(yM,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Qi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.5.57"]}),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(Qi,{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(Qi,{title:"Machine",className:"mb-4",children:u.jsx(IM,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Qi,{title:"Chat theme",className:"mb-4",children:u.jsx(HM,{})}),u.jsx(Qi,{title:"Notifications",className:"mb-4",children:u.jsx(jM,{})}),u.jsx(Qi,{title:"Preferences",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-hover transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]}),u.jsx(Zi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})})]})]})}FM();function Y_(){const{ides:e}=Vo(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(ia,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(ia,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(ia,{to:"/dashboard",replace:!0})}function kj(){return u.jsx(Tk,{children:u.jsx(gj,{children:u.jsx(Ik,{value:{sendCommand:ga,sendData:()=>!1},children:u.jsx(vj,{children:u.jsxs(kk,{children:[u.jsx(pn,{path:"/dashboard",element:u.jsx(ZM,{})}),u.jsx(pn,{path:"/ide/:id",element:u.jsx(tj,{})}),u.jsx(pn,{path:"/machine",element:u.jsx(Y_,{})}),u.jsx(pn,{path:"/machines/:id",element:u.jsx(cj,{})}),u.jsx(pn,{path:"/machines",element:u.jsx(Y_,{})}),u.jsx(pn,{path:"/about",element:u.jsx(wj,{})}),u.jsx(pn,{path:"/settings",element:u.jsx(Sj,{})}),u.jsx(pn,{path:"*",element:u.jsx(ia,{to:"/dashboard",replace:!0})})]})})})})})}dy(document.getElementById("root")).render(u.jsx(x.StrictMode,{children:u.jsx(kj,{})}));