@pixelbyte-software/pixcode 1.51.7 → 1.51.8
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.
|
@@ -217,7 +217,7 @@ import{j as i,a as UN,R as $N,o as HN,_ as TI,b as AI,T as GN,P as VN,S as yc,E
|
|
|
217
217
|
*
|
|
218
218
|
* This source code is licensed under the ISC license.
|
|
219
219
|
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
-
*/const pD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],mD=At("workflow",pD),A4=g4,hD=b7,rk=m7,fD=a7,j4=c7,gD=f4,zn=y4,Ho=Q7,Bn=t8,bD=n8,bn=u7,Un=f4,nu=f7,I4=o7,Vu=K7,Wu=Z7,_g=y7,rt=b4,Pt=b4,qu=S7,xD=w7,yD=oP,nn=A8,kr=I8,qt=W7,qa=G7,R4=K8,Gr=EP,wc=S4,vD=S4,au=D7,Co=i8,Cs=v4,us=d8,No=v8,Or=k8,Kr=B8,$n=O8,ji=F8,wD=pP,kD=W8,Pg=Q8,Lg=vP,SD=N7,CD=M7,ND=zP,_4=k4,ef=cP,ED=$8,tf=k4,P4=hP,Ht=gP,Ur=UP,L4=C8,ys=nP,St=C4,rf=C4,kc=PP,Dg=R7,TD=j7,nf=T7,AD=E8,Hn=x4,jD=x4,ID=HP,vs=VP,Og=U7,Eo=z7,Mg=l8,Sc=L8,Fg=_8,kn=G8,Ii=v4,Cc=w4,RD=w4,D4=X8,An=tP,O4=iP,Ku=g8,M4=MP,_D=xP,pa=CP,PD=kP,Wt=p8,F4=e7,Nc=x8,Gn=jP,Ei=RP,z4=DP,tn=h8,zg=P7,LD=tL,Ui=oL,Bg=E4,DD=E4,Yr=$L,Fd=GL,Yu=WL,Os=QP,Ms=nL,OD=iL,jl=cL,po=uL,nk=hL,Il=gL,ml=vL,MD=kL,B4=LL,af=CL,la=AL,hl=EL,ak=IL,fl=_L,sf=OL,FD=FL,of=BL,io=ZL,Rl=JL,oi=eD,Fs=rD,zD=aD,lf=sD,BD=cD,gl=uD,hr=mD,Zu=xL,UD=KL,$D=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],HD={up:hD,down:A4,left:fD,right:j4},bl=e=>e.preventDefault(),ik="shrink-0 rounded-md border border-gray-600 bg-gray-700 px-2.5 py-1.5 text-xs font-medium text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40",GD="shrink-0 rounded-md border border-blue-500 bg-blue-600 px-2.5 py-1.5 text-xs font-medium text-white transition-colors select-none disabled:cursor-not-allowed disabled:opacity-40",Vp="shrink-0 rounded-md border border-gray-600 bg-gray-700 p-1.5 text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40";function sk({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Be("settings"),[s,o]=m.useState(!1),[l,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useCallback(b=>{ls(e.current,{type:"input",data:b})},[e]),f=m.useCallback(()=>{t.current?.scrollToBottom()},[t]),h=m.useCallback(async()=>{if(typeof navigator>"u"||!navigator.clipboard?.readText){u(!0);return}try{const b=await navigator.clipboard.readText();u(!1),b.length>0&&p(b)}catch{u(!0)}},[p]);m.useEffect(()=>{if(!d)return;const b=window.setTimeout(()=>u(!1),2500);return()=>window.clearTimeout(b)},[d]);const g=m.useCallback(b=>{let x=b;if(s&&b.length===1){const y=b.toLowerCase().charCodeAt(0);y>=97&&y<=122&&(x=String.fromCharCode(y-96)),o(!1)}l&&b.length===1&&(x="\x1B"+x,c(!1)),p(x)},[s,l,p]);return i.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:i.jsxs("div",{className:"pointer-events-auto flex items-center gap-1 overflow-x-auto rounded-lg border border-gray-700/80 bg-gray-900/95 px-1.5 py-1.5 shadow-lg backdrop-blur-sm [-webkit-overflow-scrolling:touch] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[d&&i.jsx("span",{className:"shrink-0 rounded-md border border-yellow-500/50 bg-yellow-500/15 px-2 py-1 text-[11px] text-yellow-100",children:"Clipboard blocked"}),i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>{h()},disabled:!r,className:Vp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(Co,{className:"h-4 w-4"})}),$D.map(b=>{if(b.type==="modifier"){const x=b.modifier==="ctrl"?s:l,y=b.modifier==="ctrl"?()=>o(v=>!v):()=>c(v=>!v);return i.jsx("button",{type:"button",onPointerDown:bl,onClick:y,disabled:!r,className:x?GD:ik,children:b.label},b.id)}if(b.type==="arrow"){const x=HD[b.icon];return i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>p(b.sequence),disabled:!r,className:Vp,children:i.jsx(x,{className:"h-4 w-4"})},b.id)}return i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>g(b.sequence),disabled:!r,className:ik,children:b.label},b.id)}),i.jsx("button",{type:"button",onPointerDown:bl,onClick:f,disabled:!r,className:Vp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(gD,{className:"h-4 w-4"})})]})})}function VD({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:s=!1,autoConnect:o=!1,forceNewSession:l=!1,startupInput:c=null,hermesLaunchId:d=null,permissionOverride:u=null,provider:p=null,isActive:f=!0,onClose:h=null}){const{t:g}=Be("chat"),[b,x]=m.useState(!1),[y,v]=m.useState(null),w=m.useRef(null),S=m.useRef(null),{terminalContainerRef:k,terminalRef:N,wsRef:E,isConnected:I,isInitialized:A,isConnecting:T,authUrl:_,authUrlVersion:j,connectToShell:R,disconnectFromShell:C,openAuthUrlInBrowser:D,copyAuthUrlToClipboard:U}=K_({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:s,autoConnect:o,forceNewSession:l,startupInput:c,hermesLaunchId:d,permissionOverride:u,provider:p,isRestarting:b,onProcessComplete:a,onOutputRef:S}),F=m.useCallback(()=>{const ve=N.current;if(!ve)return;const ke=ve.buffer.active,Ie=ke.baseY+ke.cursorY,M=Math.min(ke.baseY+ke.length-1,Ie+10),se=Math.max(0,Ie-w_),de=[];for(let Q=se;Q<=M;Q++){const ce=ke.getLine(Q);ce&&de.push(ce.translateToString().trimEnd())}let Y=-1;for(let Q=de.length-1;Q>=0;Q--)if(/esc to cancel/i.test(de[Q])||/enter to select/i.test(de[Q])){Y=Q;break}if(Y===-1){v(null);return}const $=new Map,ee=Math.max(0,Y-k_);for(let Q=Y-1;Q>=ee;Q--){const ce=de[Q].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(ce){const Te=ce[1],pe=ce[2].trim();parseInt(Te,10)<=S_&&pe.length>0&&!$.has(Te)&&$.set(Te,pe)}}const X=[];for(let Q=1;Q<=$.size&&$.has(String(Q));Q++)X.push({number:String(Q),label:$.get(String(Q))});v(X.length>=C_?X:null)},[N]),W=m.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(F,v_)},[F]);m.useEffect(()=>{S.current=W},[W]),m.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),m.useEffect(()=>{I||(w.current&&(clearTimeout(w.current),w.current=null),v(null))},[I]),m.useEffect(()=>{if(!f||!A||!I)return;const ve=()=>{N.current?.focus()},ke=window.requestAnimationFrame(ve),Ie=window.setTimeout(ve,0);return()=>{window.cancelAnimationFrame(ke),window.clearTimeout(Ie)}},[f,I,A,N]);const K=m.useCallback(ve=>{ls(E.current,{type:"input",data:ve})},[E]),L=m.useMemo(()=>$_(t),[t]),V=m.useMemo(()=>p||(t?.__provider?t.__provider:window.localStorage.getItem("selected-provider")||"claude"),[p,t?.__provider]),H=Pn[V]??"Claude Code",z=m.useMemo(()=>L?L.slice(0,30):null,[L]),te=m.useMemo(()=>L?L.slice(0,50):null,[L]),ne=m.useCallback(()=>{x(!0),window.setTimeout(()=>{x(!1)},x_)},[]),be=m.useCallback(()=>{C(),h?.()},[C,h]);if(!e)return i.jsx(Z_,{title:g("shell.selectProject.title"),description:g("shell.selectProject.description")});if(s)return i.jsxs(i.Fragment,{children:[i.jsx(J_,{terminalContainerRef:k,authUrl:_,authUrlVersion:j,initialCommand:r,isConnected:I,openAuthUrlInBrowser:D,copyAuthUrlToClipboard:U}),i.jsx(sk,{wsRef:E,terminalRef:N,isConnected:I,bottomOffset:"bottom-0"})]});const ue=n?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:e.displayName}):t?g("shell.resumeSession",{displayName:te}):g("shell.startProviderSession",{provider:H,defaultValue:"Start a new {{provider}} session"}),le=n?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:e.displayName}):g("shell.startProviderCli",{provider:H,projectName:e.displayName,defaultValue:"Starting {{provider}} in {{projectName}}"}),me=A?T?"connecting":I?null:"connect":"loading",he=me==="connecting"?le:ue;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(X_,{isConnected:I,isInitialized:A,isRestarting:b,hasSession:!!t,sessionDisplayNameShort:z,onDisconnect:be,onRestart:ne,statusNewSessionText:g("shell.status.newSession"),statusInitializingText:g("shell.status.initializing"),statusRestartingText:g("shell.status.restarting"),disconnectLabel:g("shell.actions.disconnect"),disconnectTitle:g("shell.actions.disconnectTitle"),restartLabel:g("shell.actions.restart"),restartTitle:g("shell.actions.restartTitle"),disableRestart:b||I}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[i.jsx("div",{ref:k,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),me&&i.jsx(Y_,{mode:me,description:he,loadingLabel:g("shell.loading"),connectLabel:g("shell.actions.connect"),connectTitle:g("shell.actions.connectTitle"),connectingLabel:g("shell.connecting"),onConnect:R}),y&&I&&i.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:ve=>ve.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.map(ve=>i.jsxs("button",{type:"button",onClick:()=>{K(`${ve.number}\r`),v(null)},className:"max-w-36 truncate rounded bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",title:`${ve.number}. ${ve.label}`,children:[ve.number,". ",ve.label]},ve.number)),i.jsx("button",{type:"button",onClick:()=>{K("\x1B"),v(null)},className:"rounded bg-gray-700 px-3 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:bg-gray-600",children:"Esc"})]})})]}),i.jsx(sk,{wsRef:E,terminalRef:N,isConnected:I})]})}function WD({className:e}){return i.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:i.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function qD({title:e,isCompleted:t,onClose:r=null}){return i.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&i.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function To({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:s=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1,forceNewSession:h=!1,startupInput:g=null,hermesLaunchId:b=null,permissionOverride:x=null,provider:y=null}){const[v,w]=m.useState(!1),S=n!==null?n:r!==null,k=m.useCallback(N=>{w(!0),o?.(N)},[o]);return e?i.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&i.jsx(qD,{title:c,isCompleted:v,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(VD,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:S,isActive:a,onProcessComplete:k,minimal:f,autoConnect:f?!0:s,forceNewSession:h,startupInput:g,hermesLaunchId:b,permissionOverride:x,provider:y,onClose:l})})]}):i.jsx(WD,{className:d})}const KD=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":e==="opencode"?"opencode auth login":"gemini"),YD={claude:{keyLabel:"Anthropic API Key",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console"},codex:{keyLabel:"OpenAI API Key",keyExample:"sk-...",supportsBaseUrl:!0,baseUrlExample:"https://api.openai.com/v1",keyConsoleUrl:"https://platform.openai.com/api-keys",keyConsoleLabel:"OpenAI Platform"},gemini:{keyLabel:"Gemini API Key",keyExample:"AI...",supportsBaseUrl:!1,keyConsoleUrl:"https://aistudio.google.com/app/apikey",keyConsoleLabel:"Google AI Studio"},qwen:{keyLabel:"OpenAI-Compatible API Key",keyExample:"sk-... or sk-sp-...",supportsBaseUrl:!0,baseUrlExample:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",keyConsoleUrl:"https://github.com/QwenLM/qwen-code",keyConsoleLabel:"Qwen Code Docs",notes:"Accepts any OpenAI-compatible endpoint — Alibaba Cloud, ModelScope, OpenRouter, self-hosted, etc."},opencode:{keyLabel:"Anthropic API Key (default backend)",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console",notes:"OpenCode is multi-provider — this sets the Anthropic credentials. Switch providers via `opencode auth login` or opencode.json."}};function ok({active:e,children:t,onClick:r}){return i.jsx("button",{onClick:r,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function ZD({provider:e}){const[t,r]=m.useState(""),[n,a]=m.useState(!1),[s,o]=m.useState("idle"),[l,c]=m.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await Se(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return i.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[i.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),i.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",i.jsx("code",{className:"rounded bg-background px-1 font-mono text-[11px]",children:"http://127.0.0.1:PORT/…"})," and your browser can't reach it (VPS setups), copy the failing URL from your address bar and paste it below. Pixcode forwards the token exchange to the CLI process on this host."]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",value:t,onChange:u=>r(u.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:u=>{u.key==="Enter"&&d()}}),i.jsx("button",{onClick:()=>void d(),disabled:n||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:n?i.jsx(Pt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),s==="ok"&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[i.jsx(qt,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),s==="error"&&l&&i.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function XD({provider:e,onSaved:t}){const r=YD[e],[n,a]=m.useState(""),[s,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState("idle"),[p,f]=m.useState(null);m.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await Se("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await Se(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&s.trim()?s.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);u("ok"),a(""),t()}catch(b){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?i.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:i.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:i.jsx(RD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),i.jsxs("a",{href:r.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",r.keyConsoleLabel,i.jsx(bn,{className:"h-3 w-3"})]})]})]}),r.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),i.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",i.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),i.jsx("input",{type:"url",value:s,onChange:g=>o(g.target.value),placeholder:r.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),i.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Point at any OpenAI-compatible proxy (OpenRouter, local LLM, self-hosted, budget provider) to cut costs or hit different models."})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[i.jsxs("button",{onClick:()=>void h(),disabled:l||!n.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?i.jsx(Pt,{className:"h-4 w-4 animate-spin"}):i.jsx(qt,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&i.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&i.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):i.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function U4({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Be("common"),l=r!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=m.useMemo(()=>`${Pn[r]??r} Login`,[r]);if(!e)return null;const p=KD(r,a),f=h=>n?.(h);return i.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:i.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),i.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:i.jsx(St,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(ok,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(ok,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),i.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(To,{project:i_,command:p,onComplete:f,minimal:!0})}),i.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:i.jsx(ZD,{provider:r})})]}):i.jsx(XD,{provider:r,onSaved:()=>f(0)})})]})})}const JD=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),QD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},eO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},tO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),rO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:r,alt:"OpenCode",className:e})},nO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function tr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(eO,{className:t}):e==="codex"?i.jsx(QD,{className:t}):e==="gemini"?i.jsx(tO,{className:t}):e==="qwen"?i.jsx(nO,{className:t}):e==="opencode"?i.jsx(rO,{className:t}):e==="hermes"?i.jsx(hr,{className:t}):i.jsx(JD,{className:t})}function aO({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return i.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:i.jsx(tr,{provider:e,className:"h-5 w-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&i.jsx(qt,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&i.jsx("button",{onClick:o,className:`${s} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const iO=[{provider:"claude",title:"Claude Code",connectedClassName:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",iconContainerClassName:"bg-blue-100 dark:bg-blue-900/30",loginButtonClassName:"bg-blue-600 hover:bg-blue-700"},{provider:"cursor",title:"Cursor",connectedClassName:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800",iconContainerClassName:"bg-purple-100 dark:bg-purple-900/30",loginButtonClassName:"bg-purple-600 hover:bg-purple-700"},{provider:"codex",title:"OpenAI Codex",connectedClassName:"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600",iconContainerClassName:"bg-gray-100 dark:bg-gray-800",loginButtonClassName:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"},{provider:"gemini",title:"Gemini",connectedClassName:"bg-teal-50 dark:bg-teal-900/20 border-teal-200 dark:border-teal-800",iconContainerClassName:"bg-teal-100 dark:bg-teal-900/30",loginButtonClassName:"bg-teal-600 hover:bg-teal-700"},{provider:"qwen",title:"Qwen Code",connectedClassName:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800",iconContainerClassName:"bg-orange-100 dark:bg-orange-900/30",loginButtonClassName:"bg-orange-600 hover:bg-orange-700"}];function lk({providerStatuses:e,onOpenProviderLogin:t}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsx("div",{className:"space-y-3",children:iO.map(r=>i.jsx(aO,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),i.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:i.jsx("p",{children:"You can configure these later in Settings."})})]})}function sO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-8 text-center",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30",children:i.jsx(Yr,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(ID,{className:"h-4 w-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:e,onChange:s=>n(s.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(AD,{className:"h-4 w-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:s=>a(s.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const ck=[{title:"Git Configuration",icon:Yr,required:!0},{title:"Connect Agents",icon:I4,required:!1}];function oO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:ck.map((t,r)=>{const n=r<e,a=r===e,s=t.icon;return i.jsxs("div",{className:"contents",children:[i.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[i.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:n?i.jsx(qt,{className:"h-6 w-6"}):i.jsx(s,{className:"h-6 w-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<ck.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const dk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,uk=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function lO({onComplete:e}){const[t,r]=m.useState(0),[n,a]=m.useState(""),[s,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),[p,f]=m.useState(null),{providerAuthStatus:h,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=Gu(),x=m.useRef(void 0),y=m.useCallback(async()=>{try{const I=await Se("/api/user/git-config");if(!I.ok)return;const A=await I.json();A.gitName&&a(A.gitName),A.gitEmail&&o(A.gitEmail)}catch(I){console.error("Error loading git config:",I)}},[]);m.useEffect(()=>{y(),b()},[y,b]),m.useEffect(()=>{const I=x.current;x.current=p,I!=null&&p===null&&b()},[p,b]);const v=I=>{f(I)},w=I=>{I===0&&p&&g(p)},S=async()=>{if(u(""),t!==0){r(I=>I+1);return}if(!n.trim()||!s.trim()){u("Both git name and email are required.");return}if(!dk.test(s)){u("Please enter a valid email address.");return}c(!0);try{const I=await Se("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!I.ok){const A=await uk(I,"Failed to save git configuration");throw new Error(A)}r(A=>A+1)}catch(I){u(I instanceof Error?I.message:"Failed to save git configuration")}finally{c(!1)}},k=()=>{u(""),r(I=>I-1)},N=async()=>{c(!0),u("");try{const I=await Se("/api/user/complete-onboarding",{method:"POST"});if(!I.ok){const A=await uk(I,"Failed to complete onboarding");throw new Error(A)}await e?.()}catch(I){u(I instanceof Error?I.message:"Failed to complete onboarding")}finally{c(!1)}},E=t===0?!!(n.trim()&&s.trim()&&dk.test(s)):!0;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx(oO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(sO,{gitName:n,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(lk,{providerStatuses:h,onOpenProviderLogin:v}):i.jsx(lk,{providerStatuses:h,onOpenProviderLogin:v}),d&&i.jsx("div",{className:"mt-6 rounded-lg border border-red-300 bg-red-100 p-4 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),i.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[i.jsxs("button",{onClick:k,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:[i.jsx(Ho,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<1?i.jsx("button",{onClick:S,disabled:!E||l,className:"flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-400",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(Bn,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:N,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(qt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(U4,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:w})]})}const cO=["0s","0.1s","0.2s"];function dO(){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(Hn,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),i.jsx("div",{className:"flex items-center justify-center space-x-2",children:cO.map(e=>i.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function $4({errorMessage:e}){return e?i.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function as({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:s,type:o="text",name:l,autoComplete:c}){return i.jsxs("div",{children:[i.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),i.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(d.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:s})]})}function H4({title:e,description:t,children:r,footerText:n,logo:a}){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsx("div",{className:"w-full max-w-md",children:i.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:a??i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(Hn,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),i.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),i.jsx("a",{href:"https://github.com/alicomert/pixcode",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground/50 transition-colors hover:text-muted-foreground",children:"Pixcode is open source"})]})]})})})}const uO={username:"",password:""};function pO(){const{t:e}=Be("auth"),{login:t}=vc(),[r,n]=m.useState(uO),[a,s]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),s(""),!r.username.trim()||!r.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||s(p.error),l(!1)},[r.password,r.username,t,e]);return i.jsx(H4,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(as,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(as,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx($4,{errorMessage:a}),i.jsx("button",{type:"submit",disabled:o,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:e(o?"login.loading":"login.submit")})]})})}const mO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function hO(e){return!e.username.trim()||!e.password||!e.confirmPassword?"Please fill in all fields.":e.username.trim().length<3?"Username must be at least 3 characters long.":e.password.length<6?"Password must be at least 6 characters long.":e.password!==e.confirmPassword?"Passwords do not match.":e.connectionMode==="remote"&&!e.remoteUrl.trim()?"Remote Pixcode server URL is required.":null}function fO(){const{register:e}=vc(),[t,r]=m.useState(mO),[n,a]=m.useState(""),[s,o]=m.useState(!1),l=m.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=hO(t);if(u){a(u);return}o(!0);const p=await fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t.connectionMode,remoteUrl:t.connectionMode==="remote"?t.remoteUrl.trim():null,apiKey:t.connectionMode==="remote"?t.remoteApiKey.trim():null})});if(!p.ok){const h=await p.json().catch(()=>null);a(h?.error||"Could not save connection mode."),o(!1);return}const f=await e(t.username.trim(),t.password);f.success||a(f.error),o(!1)},[t,e]);return i.jsx(H4,{title:"Welcome to Pixcode",description:"Create the first admin account to get started",footerText:"The first account becomes admin and can add more users later.",logo:i.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="local"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="remote"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&i.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[i.jsx(as,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:s,autoComplete:"url"}),i.jsx(as,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:s,type:"password",autoComplete:"off"})]}),i.jsx(as,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(as,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(as,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx($4,{errorMessage:n}),i.jsx("button",{type:"submit",disabled:s,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:s?"Setting up...":"Create Account"})]})})}function gO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=vc();return r?i.jsx(dO,{}):n?i.jsx(fO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(lO,{onComplete:s}):i.jsx(pO,{})}const G4=m.createContext(null),V4=()=>{const e=m.useContext(G4);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},bO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},xO=()=>{const e=m.useRef(null),t=m.useRef(!1),r=m.useRef(!1),[n,a]=m.useState(null),[s,o]=m.useState(!1),l=m.useRef(null),{token:c}=vc(),d=m.useCallback(()=>{if(!t.current)try{const f=bO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const h=new WebSocket(f);h.onopen=()=>{o(!0),e.current=h,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},h.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},h.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},h.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);m.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=m.useCallback(f=>{const h=e.current;h&&h.readyState===WebSocket.OPEN?h.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return m.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:s}),[u,n,s])},yO=({children:e})=>{const t=xO();return i.jsx(G4.Provider,{value:t,children:e})},W4=m.createContext(null);function Xu(){const e=m.useContext(W4);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function vO({children:e}){const{user:t,token:r,isLoading:n}=vc(),[a,s]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&r),p=m.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await Se("/api/plugins");if(x.ok){const y=await x.json();s(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{n||p()},[n,p]);const f=m.useCallback(async x=>{try{const y=await Se("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=m.useCallback(async(x,y)=>{try{const v=await Se(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const S=await v.json();w=S.details||S.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return i.jsx(W4.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const pk=e=>typeof window>"u"?!1:window.innerWidth<e,mk=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function Ug(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=m.useState(()=>r?pk(t):!1),[o,l]=m.useState(()=>n?mk():!1);return m.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(pk(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),m.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(mk())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const $g="pixcode.updateCheck.preferences",cf="pixcode:update-check-settings-changed",Hg=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],df={frequency:"30m"};function hk(e){return Hg.find(t=>t.value===e.frequency)?.intervalMs??null}function q4(e){if(!e||typeof e!="object")return df;const t=e.frequency;return Hg.some(r=>r.value===t)?{frequency:t}:df}function fk(){try{const e=localStorage.getItem($g);return q4(e?JSON.parse(e):null)}catch{return df}}function wO(e){const t=q4(e);localStorage.setItem($g,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(cf,{detail:t}))}const Wp=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},kO="1.51.7",iu="pixcode:update-available",SO=360*60*1e3,qp=new Map;function K4(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function CO(e,t){try{const r=localStorage.getItem(K4(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function gk(e,t,r){localStorage.setItem(K4(e,t),JSON.stringify(r))}function NO(e,t){const r=`${e}/${t}`,n=qp.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async s=>({status:s.status,ok:s.ok,data:await s.json().catch(()=>({}))})).finally(()=>{qp.delete(r)});return qp.set(r,a),a}const Gg=(e,t)=>{const[r,n]=m.useState(!1),[a,s]=m.useState(null),[o,l]=m.useState(null),[c,d]=m.useState("git"),[u,p]=m.useState("idle"),[f,h]=m.useState(null),[g,b]=m.useState(()=>fk()),[x,y]=m.useState(kO),v=m.useRef(null),w=m.useCallback(k=>{wO(k),b(k)},[]);m.useEffect(()=>{const k=()=>b(fk()),N=E=>{E.key===$g&&k()};return window.addEventListener("storage",N),window.addEventListener(cf,k),()=>{window.removeEventListener("storage",N),window.removeEventListener(cf,k)}},[]),m.useEffect(()=>{let k=!1;const N=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(k)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};N();const E=()=>{N()};return window.addEventListener("focus",E),()=>{k=!0,window.removeEventListener("focus",E)}},[]),m.useEffect(()=>{if(!x)return;let k=!1;const N=(j,R,C,D)=>({updateAvailable:!!(j&&Wp(j,x)>0),latestVersion:j,releaseInfo:R,currentVersion:x,checkedAt:C,status:D}),E=j=>{!j.updateAvailable||!j.latestVersion||!j.releaseInfo||window.dispatchEvent(new CustomEvent(iu,{detail:j}))},I=(j,R,C,D="success")=>{if(!j||!R)return n(!1),s(null),l(null),h(C),N(null,null,C,D);s(j),n(Wp(j,x)>0),l(R),h(C);const U=N(j,R,C,D);return E(U),U},A=async({force:j=!1}={})=>{const R=hk(g),C=CO(e,t),D=Date.now();if(!j&&R===null)return p("idle"),I(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!j&&C?.fetchedAt&&R!==null&&D-C.fetchedAt<R)return p("success"),I(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!j&&C?.rateLimitedUntil&&C.rateLimitedUntil>D)return p("error"),I(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const U=await NO(e,t);if(k)return N(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const F=U.data;if(!U.ok)return U.status===403&&gk(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:D+Math.max(R??0,SO)}),p("error"),I(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(F.tag_name){const W=F.tag_name.replace(/^v/,""),K=Wp(W,x)>0,L={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};gk(e,t,{fetchedAt:D,latestVersion:W,releaseInfo:L}),s(W),n(K),K&&o4({key:`app-update:${W}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${W}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:W,installMode:c}}),l(L),p("success"),h(D);const V=N(W,L,D,"success");return E(V),V}else return n(!1),s(null),l(null),p("error"),N(null,null,null,"error")}catch(U){return console.error("Version check failed:",U),n(!1),s(null),l(null),p("error"),N(null,null,null,"error")}};v.current=A,A();const T=hk(g),_=T===null?null:window.setInterval(()=>{A()},T);return()=>{k=!0,_!==null&&window.clearInterval(_)}},[e,t,x,c,g]);const S=m.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:S,updateCheckPreferences:g,updatePreferences:w}},is={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},EO=["flat","grouped"],TO=e=>typeof e=="string"&&EO.includes(e),su=Object.keys(is),AO=new Set(su),Kp="ui-preferences:sync",jO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},ou=(e,t,r)=>e==="historyView"?TO(t)?t:r:jO(t,r),IO=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return ou(e,n,t)}catch{return t}},RO=e=>{if(typeof window>"u")return is;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return su.reduce((a,s)=>(a[s]=ou(s,n[s],is[s]),a),{...is})}}}catch{}return su.reduce((t,r)=>(t[r]=IO(r,is[r]),t),{...is})};function _O(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!AO.has(r))return e;const a=ou(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of su){if(!(s in r))continue;const o=r[s],l=ou(s,o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...is,...t.value||{}};default:return e}}function Vg(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=m.useReducer(_O,e,RO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Kp,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(Kp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Kp,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const PO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},LO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},DO=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},bk=(e,t)=>`${e}::${t}`,OO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},MO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},FO=/(?:^|[\s/\\(\[`"'])([\w./-]+?\.(?:ts|tsx|js|jsx|mjs|cjs|py|rb|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|bash|zsh|json|ya?ml|toml|md|mdx|html?|css|scss|less|sql|prisma|graphql|gql|vue|svelte|astro|dart|lua|r|pl|ps1|tf|dockerfile|env))(?:$|[\s:,)\]`"'])/i,zO=e=>{if(!e)return[];const t=new Set,r=new RegExp(FO.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],s=a.lastIndexOf(".");if(s>-1){const o=a.slice(s+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},ps=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||e.createdAt||0),BO=(e,t)=>e.__provider==="cursor"?e.summary||e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.__provider==="gemini"||e.__provider==="qwen"||e.__provider==="opencode"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),UO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),$O=(e,t,r)=>{const n=ps(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:BO(e,r),sessionTime:UO(e),messageCount:Number(e.messageCount||0)}},Y4=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),s=g=>typeof g.id=="string"&&g.id.startsWith("qwen_")||g.provider==="qwen",o=g=>typeof g.id=="string"&&g.id.startsWith("opencode_")||g.provider==="opencode",l=e.geminiSessions||[],c=l.filter(g=>!s(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>s(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],h=new Map;for(const g of[...r,...n,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>ps(b).getTime()-ps(g).getTime())},xk=(e,t)=>{const r=Y4(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=ps(a);return s>n?s:n},new Date(0))},HO=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?xk(o,n).getTime()-xk(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},GO=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},VO=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function WO({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setSidebarVisible:p,sidebarVisible:f}){const[h,g]=m.useState(new Set),[b,x]=m.useState(null),[y,v]=m.useState(!1),[w,S]=m.useState(""),[k,N]=m.useState({}),[E,I]=m.useState({}),[A,T]=m.useState(new Set),[_,j]=m.useState(new Date),[R,C]=m.useState("name"),[D,U]=m.useState(!1),[F,W]=m.useState({}),[K,L]=m.useState(null),[V,H]=m.useState(""),[z,te]=m.useState(""),[ne,be]=m.useState(new Set),[ue,le]=m.useState(null),[me,he]=m.useState(null),[ve,ke]=m.useState(!1),[Ie,M]=m.useState(()=>LO()),[se,de]=m.useState(()=>OO()),[Y,$]=m.useState("projects"),[ee,X]=m.useState(null),[Q,ce]=m.useState(!1),[Te,pe]=m.useState(null),ae=m.useRef(null),B=m.useRef(0),re=m.useRef(null),ge=!a&&!f;m.useEffect(()=>{const Oe=setInterval(()=>{j(new Date)},6e4);return()=>clearInterval(Oe)},[]),m.useEffect(()=>{I({}),T(new Set),W({})},[e]),m.useEffect(()=>{t&&g(Oe=>{if(Oe.has(t.name))return Oe;const Ye=new Set(Oe);return Ye.add(t.name),Ye})},[r,t]),m.useEffect(()=>{if(e.length>0&&!n){const Oe=new Set;e.forEach(Ye=>{Ye.sessions&&Ye.sessions.length>=0&&Oe.add(Ye.name)}),T(Oe)}},[e,n]),m.useEffect(()=>{const Oe=()=>{C(PO())};Oe();const Ye=et=>{et.key==="claude-settings"&&Oe()},it=()=>Oe();return window.addEventListener("storage",Ye),window.addEventListener("pixcode:settings-changed",it),()=>{window.removeEventListener("storage",Ye),window.removeEventListener("pixcode:settings-changed",it)}},[]),m.useEffect(()=>{ae.current&&clearTimeout(ae.current),re.current&&(re.current.close(),re.current=null);const Oe=z.trim();if(Y!=="conversations"||Oe.length<2){B.current+=1,X(null),pe(null),ce(!1);return}ce(!0);const Ye=++B.current;return ae.current=setTimeout(()=>{if(Ye!==B.current)return;const it=Lt.searchConversationsUrl(Oe),et=new EventSource(it);re.current=et;const gt=[];let It=0;et.addEventListener("result",J=>{if(Ye!==B.current){et.close();return}try{const Ee=JSON.parse(J.data);gt.push(Ee.projectResult),It=Ee.totalMatches,X({results:[...gt],totalMatches:It,query:Oe}),pe({scannedProjects:Ee.scannedProjects,totalProjects:Ee.totalProjects})}catch{}}),et.addEventListener("progress",J=>{if(Ye!==B.current){et.close();return}try{const Ee=JSON.parse(J.data);It=Ee.totalMatches,pe({scannedProjects:Ee.scannedProjects,totalProjects:Ee.totalProjects})}catch{}}),et.addEventListener("done",()=>{if(Ye!==B.current){et.close();return}et.close(),re.current=null,ce(!1),pe(null),gt.length===0&&X({results:[],totalMatches:0,query:Oe})}),et.addEventListener("error",()=>{if(Ye!==B.current){et.close();return}et.close(),re.current=null,ce(!1),pe(null),gt.length===0&&X({results:[],totalMatches:0,query:Oe})})},400),()=>{ae.current&&clearTimeout(ae.current),re.current&&(re.current.close(),re.current=null)}},[z,Y]);const je=m.useCallback(Oe=>{g(Ye=>{const it=new Set;return Ye.has(Oe)||it.add(Oe),it})},[]),Ue=m.useCallback((Oe,Ye)=>{c({...Oe,__projectName:Ye})},[c]),Ve=m.useCallback(Oe=>{M(Ye=>{const it=new Set(Ye);return it.has(Oe)?it.delete(Oe):it.add(Oe),DO(it),it})},[]),tt=m.useCallback(Oe=>Ie.has(Oe),[Ie]),We=m.useCallback((Oe,Ye)=>{de(it=>{const et=bk(Oe,Ye),gt=new Set(it);return gt.has(et)?gt.delete(et):gt.add(et),MO(gt),gt})},[]),ht=m.useCallback((Oe,Ye)=>se.has(bk(Oe,Ye)),[se]),dt=m.useCallback(Oe=>Y4(Oe,E),[E]),st=m.useMemo(()=>e.map(Oe=>{const Ye=F[Oe.name];return Ye===void 0?Oe:{...Oe,sessionMeta:{...Oe.sessionMeta,hasMore:Ye}}}),[F,e]),bt=m.useMemo(()=>HO(st,R,Ie,E),[E,R,st,Ie]),wt=m.useMemo(()=>GO(bt,z),[z,bt]),Ft=m.useCallback(Oe=>{x(Oe.name),S(Oe.displayName)},[]),Gt=m.useCallback(()=>{x(null),S("")},[]),ar=m.useCallback(async Oe=>{try{(await Lt.renameProject(Oe,w)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ye){console.error("Error renaming project:",Ye)}finally{x(null),S("")}},[w]),Ut=m.useCallback((Oe,Ye,it,et="claude")=>{he({projectName:Oe,sessionId:Ye,sessionTitle:it,provider:et})},[]),ir=m.useCallback(async()=>{if(!me)return;const{projectName:Oe,sessionId:Ye,provider:it}=me;he(null);try{let et;if(it==="codex"?et=await Lt.deleteCodexSession(Ye):it==="gemini"?et=await Lt.deleteGeminiSession(Ye):it==="qwen"?et=await Lt.deleteQwenSession(Ye):et=await Lt.deleteSession(Oe,Ye),et.ok)d?.(Ye);else{const gt=await et.text();console.error("[Sidebar] Failed to delete session:",{status:et.status,error:gt}),alert(s("messages.deleteSessionFailed"))}}catch(et){console.error("[Sidebar] Error deleting session:",et),alert(s("messages.deleteSessionError"))}},[d,me,s]),Ze=m.useCallback(Oe=>{le({project:Oe,sessionCount:dt(Oe).length})},[dt]),Ae=m.useCallback(async(Oe=!1)=>{if(!ue)return;const{project:Ye,sessionCount:it}=ue,et=it===0;le(null),be(gt=>new Set([...gt,Ye.name]));try{const gt=await Lt.deleteProject(Ye.name,!et,Oe);if(gt.ok)u?.(Ye.name);else{const It=await gt.json();alert(It.error||s("messages.deleteProjectFailed"))}}catch(gt){console.error("Error deleting project:",gt),alert(s("messages.deleteProjectError"))}finally{be(gt=>{const It=new Set(gt);return It.delete(Ye.name),It})}},[ue,u,s]),$e=m.useCallback(async Oe=>{const Ye=F[Oe.name];if(!(!(Ye!==void 0?Ye:Oe.sessionMeta?.hasMore===!0)||k[Oe.name])){N(et=>({...et,[Oe.name]:!0}));try{const et=(Oe.sessions?.length||0)+(E[Oe.name]?.length||0),gt=await Lt.sessions(Oe.name,5,et);if(!gt.ok)return;const It=await gt.json();I(J=>({...J,[Oe.name]:[...J[Oe.name]||[],...It.sessions||[]]})),It.hasMore===!1&&W(J=>({...J,[Oe.name]:!1}))}catch(et){console.error("Error loading more sessions:",et)}finally{N(et=>({...et,[Oe.name]:!1}))}}},[E,k,F]),Ke=m.useCallback(Oe=>{l(Oe)},[l]),ot=m.useCallback(async()=>{U(!0);try{await o()}finally{U(!1)}},[o]),Ct=m.useCallback(async(Oe,Ye,it,et)=>{const gt=it.trim();if(!gt){L(null),H("");return}try{const It=await Lt.renameSession(Ye,gt,et);It.ok?await o():(console.error("[Sidebar] Failed to rename session:",It.status),alert(s("messages.renameSessionFailed")))}catch(It){console.error("[Sidebar] Error renaming session:",It),alert(s("messages.renameSessionError"))}finally{L(null),H("")}},[o,s]),Ot=m.useCallback(()=>{p(!1)},[p]),sr=m.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:ge,expandedProjects:h,editingProject:b,showNewProject:y,editingName:w,loadingSessions:k,additionalSessions:E,initialSessionsLoaded:A,currentTime:_,projectSortOrder:R,isRefreshing:D,editingSession:K,editingSessionName:V,searchFilter:z,deletingProjects:ne,deleteConfirmation:ue,sessionDeleteConfirmation:me,showVersionModal:ve,starredProjects:Ie,starredSessions:se,filteredProjects:wt,toggleProject:je,handleSessionClick:Ue,toggleStarProject:Ve,isProjectStarred:tt,toggleStarSession:We,isSessionStarred:ht,getProjectSessions:dt,startEditing:Ft,cancelEditing:Gt,saveProjectName:ar,showDeleteSessionConfirmation:Ut,confirmDeleteSession:ir,requestProjectDelete:Ze,confirmDeleteProject:Ae,loadMoreSessions:$e,handleProjectSelect:Ke,refreshProjects:ot,updateSessionSummary:Ct,collapseSidebar:Ot,expandSidebar:sr,setShowNewProject:v,setEditingName:S,setEditingSession:L,setEditingSessionName:H,searchMode:Y,setSearchMode:$,conversationResults:ee,isSearching:Q,searchProgress:Te,clearConversationResults:m.useCallback(()=>{B.current+=1,re.current&&(re.current.close(),re.current=null),ce(!1),pe(null),X(null)},[]),setSearchFilter:te,setDeleteConfirmation:le,setSessionDeleteConfirmation:he,setShowVersionModal:ke}}const qO="https://discord.gg/buxwujPNRE",KO="https://github.com/alicomert/pixcode/issues/new";function YO({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function ZO({onExpand:e,onOpenControlRoom:t,onShowSettings:r,updateAvailable:n,onShowVersionModal:a,t:s}){return i.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[i.jsx("button",{onClick:e,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("common:versionUpdate.ariaLabels.showSidebar"),title:s("common:versionUpdate.ariaLabels.showSidebar"),children:i.jsx(Wu,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("div",{className:"nav-divider my-1 w-6"}),t&&i.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg border border-primary/25 bg-primary/10 transition-colors hover:bg-primary/15","aria-label":s("actions.controlRoom",{defaultValue:"Control Room"}),title:s("actions.controlRoom",{defaultValue:"Control Room"}),children:i.jsx(Gn,{className:"h-4 w-4 text-primary"})}),i.jsx("button",{onClick:r,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.settings"),title:s("actions.settings"),children:i.jsx(Wt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:KO,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.reportIssue"),title:s("actions.reportIssue"),children:i.jsx(Eo,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:qO,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.joinCommunity"),title:s("actions.joinCommunity"),children:i.jsx(YO,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&i.jsxs("button",{onClick:a,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("common:versionUpdate.ariaLabels.updateAvailable"),title:s("common:versionUpdate.ariaLabels.updateAvailable"),children:[i.jsx(Gn,{className:"h-4 w-4 text-blue-500"}),i.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function Z4(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=Z4(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function X4(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=Z4(e))&&(n&&(n+=" "),n+=t);return n}const yk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,vk=X4,Wg=(e,t)=>r=>{var n;if(t?.variants==null)return vk(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=s?.[d];if(u===null)return null;const f=yk(u)||yk(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...h}=u;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...s,...l}[b]):{...s,...l}[b]===x})?[...d,p,f]:d},[]);return vk(e,o,c,r?.class,r?.className)},qg="-",XO=e=>{const t=QO(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(qg);return l[0]===""&&l.length!==1&&l.shift(),J4(l,t)||JO(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},J4=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?J4(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(qg);return t.validators.find(({validator:o})=>o(s))?.classGroupId},wk=/^\[(.+)\]$/,JO=e=>{if(wk.test(e)){const t=wk.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},QO=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)uf(r[a],n,a,t);return n},uf=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:kk(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(eM(a)){uf(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{uf(o,kk(t,s),r,n)})})},kk=(e,t)=>{let r=e;return t.split(qg).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},eM=e=>e.isThemeGetter,tM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},pf="!",mf=":",rM=mf.length,nM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let o=0,l=0,c=0,d;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===mf){s.push(a.slice(c,g)),c=g+rM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=aM(u),f=p!==u,h=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+mf,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},aM=e=>e.endsWith(pf)?e.substring(0,e.length-1):e.startsWith(pf)?e.substring(1):e,iM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},sM=e=>({cache:tM(e.cacheSize),parseClassName:nM(e),sortModifiers:iM(e),...XO(e)}),oM=/\s+/,lM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(oM);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=s(f).join(":"),w=h?v+pf:v,S=w+y;if(o.includes(S))continue;o.push(S);const k=a(y,x);for(let N=0;N<k.length;++N){const E=k[N];o.push(w+E)}c=u+(c.length>0?" "+c:c)}return c};function cM(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=Q4(t))&&(n&&(n+=" "),n+=r);return n}const Q4=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Q4(e[n]))&&(r&&(r+=" "),r+=t);return r};function dM(e,...t){let r,n,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=sM(d),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=lM(c,r);return a(c,u),u}return function(){return s(cM.apply(null,arguments))}}const Ir=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},eE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,tE=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uM=/^\d+\/\d+$/,pM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,mM=/\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$/,hM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zs=e=>uM.test(e),kt=e=>!!e&&!Number.isNaN(Number(e)),li=e=>!!e&&Number.isInteger(Number(e)),Yp=e=>e.endsWith("%")&&kt(e.slice(0,-1)),Da=e=>pM.test(e),bM=()=>!0,xM=e=>mM.test(e)&&!hM.test(e),rE=()=>!1,yM=e=>fM.test(e),vM=e=>gM.test(e),wM=e=>!Je(e)&&!Qe(e),kM=e=>Go(e,iE,rE),Je=e=>eE.test(e),Ki=e=>Go(e,sE,xM),Zp=e=>Go(e,TM,kt),Sk=e=>Go(e,nE,rE),SM=e=>Go(e,aE,vM),Kc=e=>Go(e,oE,yM),Qe=e=>tE.test(e),xl=e=>Vo(e,sE),CM=e=>Vo(e,AM),Ck=e=>Vo(e,nE),NM=e=>Vo(e,iE),EM=e=>Vo(e,aE),Yc=e=>Vo(e,oE,!0),Go=(e,t,r)=>{const n=eE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vo=(e,t,r=!1)=>{const n=tE.exec(e);return n?n[1]?t(n[1]):r:!1},nE=e=>e==="position"||e==="percentage",aE=e=>e==="image"||e==="url",iE=e=>e==="length"||e==="size"||e==="bg-size",sE=e=>e==="length",TM=e=>e==="number",AM=e=>e==="family-name",oE=e=>e==="shadow",jM=()=>{const e=Ir("color"),t=Ir("font"),r=Ir("text"),n=Ir("font-weight"),a=Ir("tracking"),s=Ir("leading"),o=Ir("breakpoint"),l=Ir("container"),c=Ir("spacing"),d=Ir("radius"),u=Ir("shadow"),p=Ir("inset-shadow"),f=Ir("text-shadow"),h=Ir("drop-shadow"),g=Ir("blur"),b=Ir("perspective"),x=Ir("aspect"),y=Ir("ease"),v=Ir("animate"),w=()=>["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"],k=()=>[...S(),Qe,Je],N=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],I=()=>[Qe,Je,c],A=()=>[zs,"full","auto",...I()],T=()=>[li,"none","subgrid",Qe,Je],_=()=>["auto",{span:["full",li,Qe,Je]},li,Qe,Je],j=()=>[li,"auto",Qe,Je],R=()=>["auto","min","max","fr",Qe,Je],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...I()],F=()=>[zs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],W=()=>[e,Qe,Je],K=()=>[...S(),Ck,Sk,{position:[Qe,Je]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",NM,kM,{size:[Qe,Je]}],H=()=>[Yp,xl,Ki],z=()=>["","none","full",d,Qe,Je],te=()=>["",kt,xl,Ki],ne=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ue=()=>[kt,Yp,Ck,Sk],le=()=>["","none",g,Qe,Je],me=()=>["none",kt,Qe,Je],he=()=>["none",kt,Qe,Je],ve=()=>[kt,Qe,Je],ke=()=>[zs,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Da],breakpoint:[Da],color:[bM],container:[Da],"drop-shadow":[Da],ease:["in","out","in-out"],font:[wM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Da],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Da],shadow:[Da],spacing:["px",kt],text:[Da],"text-shadow":[Da],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zs,Je,Qe,x]}],container:["container"],columns:[{columns:[kt,Je,Qe,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"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:k()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[li,"auto",Qe,Je]}],basis:[{basis:[zs,"full","auto",l,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[kt,zs,"auto","initial","none",Je]}],grow:[{grow:["",kt,Qe,Je]}],shrink:[{shrink:["",kt,Qe,Je]}],order:[{order:[li,"first","last","none",Qe,Je]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",r,xl,Ki]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Qe,Zp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yp,Je]}],"font-family":[{font:[CM,Je,t]}],"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:[a,Qe,Je]}],"line-clamp":[{"line-clamp":[kt,"none",Qe,Zp]}],leading:[{leading:[s,...I()]}],"list-image":[{"list-image":["none",Qe,Je]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Qe,Je]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[kt,"from-font","auto",Qe,Ki]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[kt,"auto",Qe,Je]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Qe,Je]}],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",Qe,Je]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},li,Qe,Je],radial:["",Qe,Je],conic:[li,Qe,Je]},EM,SM]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[kt,Qe,Je]}],"outline-w":[{outline:["",kt,xl,Ki]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",u,Yc,Kc]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",p,Yc,Kc]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[kt,Ki]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",f,Yc,Kc]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[kt,Qe,Je]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"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":[kt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Qe,Je]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"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":[kt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Qe,Je]}],filter:[{filter:["","none",Qe,Je]}],blur:[{blur:le()}],brightness:[{brightness:[kt,Qe,Je]}],contrast:[{contrast:[kt,Qe,Je]}],"drop-shadow":[{"drop-shadow":["","none",h,Yc,Kc]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",kt,Qe,Je]}],"hue-rotate":[{"hue-rotate":[kt,Qe,Je]}],invert:[{invert:["",kt,Qe,Je]}],saturate:[{saturate:[kt,Qe,Je]}],sepia:[{sepia:["",kt,Qe,Je]}],"backdrop-filter":[{"backdrop-filter":["","none",Qe,Je]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[kt,Qe,Je]}],"backdrop-contrast":[{"backdrop-contrast":[kt,Qe,Je]}],"backdrop-grayscale":[{"backdrop-grayscale":["",kt,Qe,Je]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[kt,Qe,Je]}],"backdrop-invert":[{"backdrop-invert":["",kt,Qe,Je]}],"backdrop-opacity":[{"backdrop-opacity":[kt,Qe,Je]}],"backdrop-saturate":[{"backdrop-saturate":[kt,Qe,Je]}],"backdrop-sepia":[{"backdrop-sepia":["",kt,Qe,Je]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Qe,Je]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[kt,"initial",Qe,Je]}],ease:[{ease:["linear","initial",y,Qe,Je]}],delay:[{delay:[kt,Qe,Je]}],animate:[{animate:["none",v,Qe,Je]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Qe,Je]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[Qe,Je,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"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",Qe,Je]}],"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":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",Qe,Je]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[kt,xl,Ki,Zp]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","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","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","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-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-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-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-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"]}},IM=dM(jM);function xe(...e){return IM(X4(e))}function RM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const _M=Wg("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),lE=m.forwardRef(({className:e,variant:t,...r},n)=>i.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:xe(_M({variant:t}),e),...r}));lE.displayName="Alert";const PM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-title",className:xe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));PM.displayName="AlertTitle";const LM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-description",className:xe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));LM.displayName="AlertDescription";const DM=Wg("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Et({className:e,variant:t,...r}){return i.jsx("div",{className:xe(DM({variant:t}),e),...r})}const OM=Wg("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ne=m.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:xe(OM({variant:t,size:r,className:e})),ref:a,...n}));Ne.displayName="Button";const cE=m.createContext(null),dE=()=>{const e=m.useContext(cE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},uE=({className:e,approval:t="pending",children:r,...n})=>{const a=m.useMemo(()=>({approval:t}),[t]);return i.jsx(cE.Provider,{value:a,children:i.jsx(lE,{className:xe("flex flex-col gap-2",e),...n,children:r})})};uE.displayName="Confirmation";const pE=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:xe("text-muted-foreground inline text-sm",e),...t});pE.displayName="ConfirmationTitle";const mE=({children:e})=>{const{approval:t}=dE();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};mE.displayName="ConfirmationRequest";const hE=({className:e,...t})=>{const{approval:r}=dE();return r!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:xe("flex items-center justify-end gap-2 self-end",e),...t})};hE.displayName="ConfirmationActions";const zd=({variant:e="default",...t})=>i.jsx(Ne,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});zd.displayName="ConfirmationAction";const fE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));fE.displayName="Card";const gE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("flex flex-col space-y-1.5 p-4",e),...t}));gE.displayName="CardHeader";const bE=m.forwardRef(({className:e,...t},r)=>i.jsx("h3",{ref:r,className:xe("font-semibold leading-none tracking-tight",e),...t}));bE.displayName="CardTitle";const MM=m.forwardRef(({className:e,...t},r)=>i.jsx("p",{ref:r,className:xe("text-sm text-muted-foreground",e),...t}));MM.displayName="CardDescription";const xE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("p-4 pt-0",e),...t}));xE.displayName="CardContent";const yE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("flex items-center p-4 pt-0",e),...t}));yE.displayName="CardFooter";const FM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("ml-auto shrink-0",e),...t}));FM.displayName="CardAction";const vE=m.createContext(null);function wE(){const e=m.useContext(vE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const Ri=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...s},o)=>{const[l,c]=m.useState(e),d=t!==void 0,u=d?t:l,p=m.useCallback(h=>{d||c(h),r?.(h)},[d,r]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(vE.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...s,children:a})})});Ri.displayName="Collapsible";const Ka=m.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:s,onOpenChange:o}=wE(),l=m.useCallback(c=>{o(!s),e?.(c)},[s,o,e]);return i.jsx("button",{ref:a,type:"button","aria-expanded":s,"data-state":s?"open":"closed",onClick:l,className:r,...n,children:t})});Ka.displayName="CollapsibleTrigger";const _i=m.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=wE();return i.jsx("div",{ref:n,"data-state":a?"open":"closed",className:xe("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:i.jsx("div",{className:"overflow-hidden",children:t})})});_i.displayName="CollapsibleContent";const kE=m.createContext(null);function Kg(){const e=m.useContext(kE);if(!e)throw new Error("Command components must be used within <Command>");return e}const SE=m.forwardRef(({className:e,children:t,...r},n)=>{const[a,s]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=m.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=m.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),f=m.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[S,k]of o.current)(!v||k.value.includes(v))&&w.add(S);return w},[a,l]),h=m.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=h;if(w.length===0)return;if(v.key==="Enter"){w.find(A=>A.id===g)?.onSelect();return}const S=w.findIndex(I=>I.id===g);let k;v.key==="ArrowDown"?k=S<w.length-1?S+1:0:k=S>0?S-1:w.length-1;const N=w[k].id;b(N),w[k].element?.scrollIntoView({block:"nearest"})},[h,g]),y=m.useMemo(()=>({search:a,setSearch:s,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return i.jsx(kE.Provider,{value:y,children:i.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:xe("flex flex-col",e),onKeyDown:x,...r,children:t})})});SE.displayName="Command";const CE=m.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:s}=Kg();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(ys,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:xe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})});CE.displayName="CommandInput";const NE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,role:"listbox",className:xe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));NE.displayName="CommandList";const EE=m.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=Kg();return!n||a.size>0?null:i.jsx("div",{ref:r,className:xe("py-6 text-center text-sm text-muted-foreground",e),...t})});EE.displayName="CommandEmpty";const TE=m.forwardRef(({className:e,heading:t,children:r,...n},a)=>i.jsxs("div",{ref:a,className:xe("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));TE.displayName="CommandGroup";const AE=m.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=Kg(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:r||(()=>{})})},[h,r,f]);const x=m.useCallback(v=>{g.current=v,f(h,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[h,f,o]);if(!l.has(h))return null;const y=c===h;return i.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:xe("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==h&&d(h)},onClick:()=>!n&&r?.(),...s,children:a})});AE.displayName="CommandItem";const zM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("-mx-1 h-px bg-border",e),...t}));zM.displayName="CommandSeparator";function lu({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=ni(),s=typeof e=="boolean"&&typeof t=="function",o=s?e:n,l=()=>{if(s&&t){t(!o);return}a()};return i.jsxs("button",{onClick:l,className:xe("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":r,children:[i.jsx("span",{className:"sr-only",children:r}),i.jsx("span",{className:xe("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?i.jsx(O4,{className:"h-3 w-3 text-primary"}):i.jsx(z4,{className:"h-3 w-3 text-white dark:text-background"})})]})}const jE=m.createContext(null);function IE(){const e=m.useContext(jE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const RE=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,s]=m.useState(r),o=m.useRef(null),l=e!==void 0,c=l?e:a,d=m.useCallback(p=>{l||s(p),t?.(p)},[l,t]),u=m.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return i.jsx(jE.Provider,{value:u,children:n})},BM=m.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:s,triggerRef:o}=IE(),l=m.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(r&&m.isValidElement(t)){const c=t;return m.cloneElement(c,{onClick:d=>{s(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return i.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});BM.displayName="DialogTrigger";const Nk='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Yg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=IE(),d=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),m.useEffect(()=>{if(!o)return;const p=h=>{if(h.key==="Escape"){h.stopPropagation(),r?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(Nk));if(g.length===0)return;const b=g[0],x=g[g.length-1];h.shiftKey&&document.activeElement===b?(h.preventDefault(),x.focus()):!h.shiftKey&&document.activeElement===x&&(h.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(Nk)?.focus()})},[o]),o?$u.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),i.jsx("div",{ref:p=>{d.current=p,typeof s=="function"?s(p):s&&(s.current=p)},role:"dialog","aria-modal":"true",className:xe("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});Yg.displayName="DialogContent";const Zg=m.forwardRef(({className:e,...t},r)=>i.jsx("h2",{ref:r,className:xe("sr-only",e),...t}));Zg.displayName="DialogTitle";const Xe=m.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:xe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Xe.displayName="Input";const Xg=m.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>i.jsx("div",{className:xe("relative overflow-hidden",e),...n,children:i.jsx("div",{ref:a,className:xe("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Xg.displayName="ScrollArea";const cu=m.memo(({children:e,className:t,as:r="span"})=>i.jsx(r,{className:xe("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",t),children:e}));cu.displayName="Shimmer";const _E=m.createContext(null),UM=()=>{const e=m.useContext(_E);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},$M=1e3,HM=1e3,hf=m.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:s,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=m.useState(c),f=r!==void 0,h=f?r:u,g=m.useCallback(N=>{f||p(N),a?.(N)},[f,a]),[b,x]=m.useState(s),y=m.useRef(t),[v,w]=m.useState(!1),S=m.useRef(null);m.useEffect(()=>{s!==void 0&&x(s)},[s]),m.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/HM)),S.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(y.current&&!t&&h&&!v){const N=setTimeout(()=>{g(!1),w(!0)},$M);return()=>clearTimeout(N)}},[t,h,g,v]);const k=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return i.jsx(_E.Provider,{value:k,children:i.jsx(Ri,{open:h,onOpenChange:g,className:xe("not-prose",e),...l,children:o})})});hf.displayName="Reasoning";const GM=(e,t)=>e||t===0?i.jsx(cu,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),ff=m.memo(({className:e,children:t,getThinkingMessage:r=GM,...n})=>{const{isStreaming:a,isOpen:s,duration:o}=UM();return i.jsx(Ka,{className:xe("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??i.jsxs(i.Fragment,{children:[i.jsx(DD,{className:"h-4 w-4"}),r(a,o),i.jsx(y4,{className:xe("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});ff.displayName="ReasoningTrigger";const gf=m.memo(({className:e,children:t,...r})=>i.jsx(_i,{className:xe("mt-4 text-sm text-muted-foreground",e),...r,children:t}));gf.displayName="ReasoningContent";function VM(e){switch(e){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function bf({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[s,o]=m.useState(!1),l=m.useRef(null),c=m.useRef(!1),d=m.useRef(null),u=m.useRef(null),[p,f]=m.useState(null),h=m.useCallback(()=>{const w=d.current;if(!w)return;const S=w.getBoundingClientRect(),k=8,N={position:"fixed",zIndex:9999};switch(r){case"bottom":N.left=S.left+S.width/2,N.top=S.bottom+k,N.transform="translateX(-50%)";break;case"left":N.left=S.left-k,N.top=S.top+S.height/2,N.transform="translate(-100%, -50%)";break;case"right":N.left=S.right+k,N.top=S.top+S.height/2,N.transform="translateY(-50%)";break;case"top":default:N.left=S.left+S.width/2,N.top=S.top-k,N.transform="translate(-50%, -100%)";break}f(N)},[r]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!s||typeof document>"u")return;const w=S=>{const k=S.target;k instanceof Node&&d.current?.contains(k)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[s]),m.useEffect(()=>{if(!s){f(null);return}const w=window.requestAnimationFrame(h),S=()=>h();return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[s,h]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,s&&typeof document<"u"&&$u.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:xe("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",n),children:[t,i.jsx("div",{className:xe("absolute w-0 h-0 border-4 border-transparent",VM(r))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const PE=m.createContext(null),LE=m.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const s=m.useMemo(()=>({status:t}),[t]);return i.jsx(PE.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:xe("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});LE.displayName="PromptInput";const DE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:xe("px-3 pt-3",e),...t}));DE.displayName="PromptInputHeader";const OE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:xe("relative",e),...t}));OE.displayName="PromptInputBody";const ME=m.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:xe("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 font-mono text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));ME.displayName="PromptInputTextarea";const FE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:xe("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));FE.displayName="PromptInputFooter";const zE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:xe("flex items-center gap-1",e),...t}));zE.displayName="PromptInputTools";const Bd=m.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const s=i.jsx(Ne,{ref:a,type:"button",variant:"ghost",size:"icon",className:xe("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?i.jsx(bf,{content:t.shortcut?i.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,i.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:s}):s});Bd.displayName="PromptInputButton";const BE=m.forwardRef(({className:e,status:t,children:r,...n},a)=>{const s=m.useContext(PE),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(Ne,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:xe("h-8 w-8 rounded-lg",e),...n,children:r??(l?i.jsx(kc,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(yD,{className:"h-4 w-4"}))})});BE.displayName="PromptInputSubmit";function Jg({children:e,className:t}){return i.jsx("div",{className:xe("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Qg({isActive:e,onClick:t,children:r,className:n}){return i.jsx("button",{onClick:t,className:xe("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",n),children:r})}const UE=m.createContext(null);function $E(){const e=m.useContext(UE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const HE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:xe("space-y-0.5",e),...t}));HE.displayName="Queue";const GE=m.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const s=m.useMemo(()=>({status:e}),[e]);return i.jsx(UE.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:xe("flex items-start gap-2 py-0.5",t),...n,children:r})})});GE.displayName="QueueItem";const VE=m.forwardRef(({className:e,...t},r)=>{const{status:n}=$E();return i.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:xe("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});VE.displayName="QueueItemIndicator";const WE=m.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=$E();return i.jsx("div",{ref:n,"data-slot":"queue-item-content",className:xe("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...r,children:t})});WE.displayName="QueueItemContent";const Ek="https://github.com/alicomert/pixcode/issues/new",WM="https://github.com/alicomert/pixcode",Tk="https://discord.gg/buxwujPNRE";function Ak({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function qM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onOpenControlRoom:s,onShowSettings:o,t:l}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:a,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(rk,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})}),i.jsx("div",{className:"px-3 py-2 md:hidden",children:i.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:a,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(rk,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("a",{href:Ek,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[i.jsx(Eo,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.reportIssue")})]})}),i.jsx("div",{className:"hidden px-2 md:block",children:i.jsxs("a",{href:Tk,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[i.jsx(Ak,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.joinCommunity")})]})}),s&&i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg border border-primary/25 bg-primary/5 px-2.5 py-2 text-left transition-colors hover:bg-primary/10",onClick:s,children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-primary/10 text-primary",children:i.jsx(Gn,{className:"h-3.5 w-3.5"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),i.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:o,children:[i.jsx(Wt,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.settings")})]})}),i.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:i.jsxs("a",{href:WM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",l("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:Ek,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Eo,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.reportIssue")})]})}),i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("a",{href:Tk,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Ak,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.joinCommunity")})]})}),s&&i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("button",{className:"flex h-14 w-full items-center gap-3.5 rounded-xl border border-primary/25 bg-primary/10 px-4 transition-all hover:bg-primary/15 active:scale-[0.98]",onClick:s,children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-primary/15",children:i.jsx(Gn,{className:"w-4.5 h-4.5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-base font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),i.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:i.jsxs("button",{className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:o,children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Wt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.settings")})]})})]})}const jk="PIXCODE_GITHUB_STARS",Ik="PIXCODE_HIDE_GITHUB_STAR",KM=3600*1e3,YM=(e,t)=>{const[r,n]=m.useState(null),[a,s]=m.useState(()=>{try{return localStorage.getItem(Ik)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(jk);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<KM){n(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){n(p);try{localStorage.setItem(jk,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{s(!0);try{localStorage.setItem(Ik,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},ZM="https://github.com/alicomert/pixcode";function XM({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function JM(){const{formattedCount:e,isDismissed:t,dismiss:r}=YM("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:ZM,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[i.jsx(XM,{className:"h-3.5 w-3.5"}),i.jsx(Ei,{className:"h-3 w-3"}),i.jsx("span",{className:"font-medium",children:"Star"}),e&&i.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),i.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:i.jsx(St,{className:"h-2.5 w-2.5"})})]})}function Rk({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return i.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:xe(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(Pg,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:xe(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(SD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function QM({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:h,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:i.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:i.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[i.jsx("path",{d:"M2037 3800 c-104 -40 -191 -134 -231 -250 -23 -67 -20 -82 22 -109 31 -20 287 -177 1009 -618 40 -24 82 -56 93 -70 27 -34 27 -102 0 -136 -11 -13 -106 -78 -212 -143 -106 -64 -201 -124 -210 -132 -16 -14 -18 -41 -18 -302 0 -291 2 -310 38 -310 16 0 267 148 610 359 180 111 270 173 310 213 216 217 215 574 -3 793 -37 38 -107 89 -185 136 -69 42 -253 154 -410 249 -434 264 -509 307 -563 326 -57 20 -191 17 -250 -6z"}),i.jsx("path",{d:"M1803 2994 c-10 -5 -13 -156 -13 -709 0 -671 1 -706 20 -767 27 -89 93 -184 167 -240 89 -67 157 -90 281 -96 92 -4 105 -2 117 14 12 16 14 134 15 735 0 669 -1 718 -17 737 -20 23 -514 322 -541 327 -9 2 -23 2 -29 -1z"})]})})}),i.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:d,disabled:u,title:x("tooltips.refresh"),children:i.jsx(rt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:p,title:x("tooltips.createProject"),children:i.jsx(Ht,{className:"h-4 w-4"})}),i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:h,title:x("tooltips.hideSidebar"),children:i.jsx(Vu,{className:"h-4 w-4"})})]})]}),i.jsx(JM,{}),f&&i.jsxs("button",{type:"button",onClick:()=>{f()},className:"mt-2.5 flex w-full items-center justify-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[i.jsx(Gn,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Rk,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Kr,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Hn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(ys,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Xe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&i.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:i.jsx(St,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider hidden md:block"}),i.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:d,disabled:u,children:i.jsx(rt,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:p,children:i.jsx(ji,{className:"h-4 w-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Rk,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Kr,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Hn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(ys,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Xe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&i.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:i.jsx(St,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const e9=160,_k=180;function qE({actions:e,className:t,triggerLabel:r}){const[n,a]=m.useState(!1),[s,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-e9;p<8&&(p=8);let f=u.bottom+4;f+_k>window.innerHeight&&(f=Math.max(8,u.top-4-_k)),o({top:f,left:p})},[n]),m.useEffect(()=>{if(!n)return;const u=h=>{const g=h.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=h=>{h.key==="Escape"&&a(!1)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:xe("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",n&&"bg-accent text-foreground opacity-100",t),children:i.jsx(L4,{className:"h-3.5 w-3.5"})}),n&&s&&$u.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:xe("w-40 rounded-xl border border-border/60 bg-popover p-1 shadow-lg","animate-in fade-in-0 zoom-in-95 duration-100"),onClick:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),children:e.map((u,p)=>{const f=u.icon,h=e[p-1],g=p>0&&u.danger&&!h?.danger;return i.jsxs("div",{children:[g&&i.jsx("div",{className:"my-1 h-px bg-border/60"}),i.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:xe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",u.danger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"text-foreground hover:bg-accent"),children:[i.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const t9=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),d=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function Pk({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:s,className:o}){const l=d=>i.jsx(Ei,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:_4,onClick:r},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:Ur,onClick:a,danger:!0}),i.jsx(qE,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const r9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Lk={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function KE({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:h,onSessionSelect:g,onDeleteSession:b,t:x}){const y=$O(t,n,x),v=r?.id===t.id,w=a===t.id,S=t.__provider,k=r9[S]??S,N=Lk[S]??Lk.claude,E=zO(y.sessionName),I=()=>{h(e),g(t,e.name)},A=()=>{p(e.name,t.id,s,S)},T=()=>{b(e.name,t.id,y.sessionName,S)},_=()=>d(t.id,y.sessionName),j=()=>f(e.name,t.id),R=i.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[i.jsxs("span",{className:xe("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",N),children:[i.jsx(tr,{provider:S,className:"h-2.5 w-2.5"}),k]}),i.jsx("span",{className:"text-muted-foreground/80",children:t9(y.sessionTime,n,x)}),y.isActive&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),E.slice(0,3).map(F=>i.jsxs("span",{className:"rounded-md bg-muted/60 px-1 py-px font-mono text-[9px] uppercase tracking-wide text-muted-foreground ring-1 ring-border/40",children:[".",F]},F))]}),C=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:F=>c(F.target.value),onKeyDown:F=>{F.stopPropagation(),F.key==="Enter"?A():F.key==="Escape"&&u()},onClick:F=>F.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),i.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:F=>{F.stopPropagation(),A()},title:x("tooltips.save"),children:i.jsx(qt,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),i.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:F=>{F.stopPropagation(),u()},title:x("tooltips.cancel"),children:i.jsx(St,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),D=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:xe("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:I,children:w?i.jsx("div",{className:"flex items-center gap-1",children:C}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:xe("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:i.jsx(tr,{provider:S,className:"h-3 w-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[o&&i.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),R]}),i.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:i.jsx(Pk,{isStarred:o,canDelete:!y.isCursorSession,onRename:_,onToggleStar:j,onDelete:T,t:x,className:"!opacity-100"})})]})})}),U=i.jsxs("div",{className:xe("group/item relative hidden md:block"),children:[i.jsxs(Ne,{variant:"ghost",className:xe("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&i.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&i.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),i.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[i.jsx("div",{className:xe("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:i.jsx(tr,{provider:S,className:"h-3 w-3"})}),i.jsx("div",{className:"min-w-0 flex-1",children:w?i.jsx("div",{className:"flex items-center gap-1",children:C}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&i.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),R]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:i.jsx(Pk,{isStarred:o,canDelete:!y.isCursorSession,onRename:_,onToggleStar:j,onDelete:T,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[D,U]})}const n9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function a9(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"rounded-md p-2",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function i9({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:S,t:k}){const[N,E]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let T=!1;const _=async()=>{const R=await Se(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!R.ok)return;const C=await R.json();T||E((C.runs??[]).slice(0,5))};_();const j=window.setInterval(()=>{_()},15e3);return()=>{T=!0,window.clearInterval(j)}},[t,e.name]),!t)return null;const I=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[i.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:i.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{b(e),w(e)},children:[i.jsx(Ht,{className:"h-3 w-3"}),k("sessions.newSession")]})}),i.jsxs(Ne,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>w(e),children:[i.jsx(Ht,{className:"h-3 w-3"}),k("sessions.newSession")]}),N.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[i.jsx(hr,{className:"h-3 w-3"}),k("orchestration.section")]}),N.map(T=>{const _=[...new Set(T.nodeRuns.map(j=>n9(j.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>S?.(e,T.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:i.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[i.jsx(hr,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:T.input||k("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[_.slice(0,4).map(j=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(tr,{provider:j,className:"h-3 w-3"})},j)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:k(`common:orchestration.status.${T.status}`,{defaultValue:T.status})})]})]})]})},T.id)})]}),a?!I&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:k("sessions.noSessions")})}):r.map(T=>i.jsx(KE,{project:e,session:T,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,T.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:k},T.id)):i.jsx(a9,{}),I&&A&&i.jsx(Ne,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),k("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(zn,{className:"h-3 w-3"}),k("sessions.showMore")]})})]})}const s9=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function o9({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingNameChange:b,onToggleProject:x,onProjectSelect:y,onToggleStarProject:v,onToggleStarSession:w,onStartEditingProject:S,onCancelEditingProject:k,onSaveProjectName:N,onDeleteProject:E,onSessionSelect:I,onDeleteSession:A,onLoadMoreSessions:T,onNewSession:_,onOpenOrchestration:j,onEditingSessionNameChange:R,onStartEditingSession:C,onCancelEditingSession:D,onSaveEditingSession:U,t:F}){const W=t?.name===e.name,K=o===e.name,L=e.sessionMeta?.hasMore===!0,V=s9(c,L),H=`${V} session${c.length===1?"":"s"}`,z=()=>x(e.name),te=()=>v(e.name),ne=()=>{N(e.name)},be=()=>{t?.name!==e.name&&y(e),z()};return i.jsxs("div",{className:xe("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"md:group group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:xe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",W&&"bg-primary/5 border-primary/20",s&&!W&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:z,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[i.jsx("div",{className:xe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx($n,{className:"h-4 w-4 text-primary"}):i.jsx(Kr,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:K?i.jsx("input",{type:"text",value:l,onChange:ue=>b(ue.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ue=>ue.stopPropagation(),onKeyDown:ue=>{ue.key==="Enter"&&ne(),ue.key==="Escape"&&k()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:i.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:H})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:K?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:ue=>{ue.stopPropagation(),ne()},children:i.jsx(qt,{className:"h-4 w-4 text-white"})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:ue=>{ue.stopPropagation(),k()},children:i.jsx(St,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:xe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:ue=>{ue.stopPropagation(),te()},title:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(Ei,{className:xe("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:ue=>{ue.stopPropagation(),E(e)},children:i.jsx(Ur,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:ue=>{ue.stopPropagation(),S(e)},children:i.jsx(ef,{className:"h-4 w-4 text-primary"})}),i.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?i.jsx(zn,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(Bn,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(Ne,{variant:"ghost",className:xe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",W&&"bg-accent text-accent-foreground",s&&!W&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:be,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?i.jsx($n,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Kr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:K?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:ue=>b(ue.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ue=>{ue.key==="Enter"&&ne(),ue.key==="Escape"&&k()}}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[V,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:K?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:ue=>{ue.stopPropagation(),ne()},children:i.jsx(qt,{className:"h-3 w-3"})}),i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:ue=>{ue.stopPropagation(),k()},children:i.jsx(St,{className:"h-3 w-3"})})]}):i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded hover:bg-yellow-50 dark:hover:bg-yellow-900/20",onClick:ue=>{ue.stopPropagation(),te()},title:F("tooltips.removeFromFavorites"),children:i.jsx(Ei,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(qE,{triggerLabel:F("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:F("actions.rename"),icon:ef,onClick:()=>S(e)},{id:"star",label:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Ei,onClick:te},{id:"delete",label:F("actions.delete",{defaultValue:"Delete"}),icon:Ur,onClick:()=>E(e),danger:!0}]}),n?i.jsx(zn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(Bn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(i9,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingSessionNameChange:R,onStartEditingSession:C,onCancelEditingSession:D,onSaveEditingSession:U,onToggleStarSession:w,onProjectSelect:y,onSessionSelect:I,onDeleteSession:A,onLoadMoreSessions:T,onNewSession:_,onOpenOrchestration:j,t:F})]})}function YE({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:i.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Kr,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(ys,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function l9({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:h,deletingProjects:g,getProjectSessions:b,isProjectStarred:x,isSessionStarred:y,onEditingNameChange:v,onToggleProject:w,onProjectSelect:S,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:E,onCancelEditingProject:I,onSaveProjectName:A,onDeleteProject:T,onSessionSelect:_,onDeleteSession:j,onLoadMoreSessions:R,onNewSession:C,onOpenOrchestration:D,onEditingSessionNameChange:U,onStartEditingSession:F,onCancelEditingSession:W,onSaveEditingSession:K,t:L}){const V=i.jsx(YE,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:L});m.useEffect(()=>{let ue="Pixcode";const le=r?.displayName?.trim();le&&(ue=`${le} - ${ue}`),document.title=ue},[r]);const H=!a&&e.length>0&&t.length>0,z=ue=>ue.source==="history"||ue.autoDiscovered===!0&&ue.isManuallyAdded!==!0,te=t.filter(ue=>!z(ue)),ne=t.filter(ue=>z(ue)),be=ue=>i.jsx(o9,{project:ue,selectedProject:r,selectedSession:n,isExpanded:o.has(ue.name),isDeleting:g.has(ue.name),isStarred:x(ue.name),editingProject:l,editingName:c,sessions:b(ue),initialSessionsLoaded:u.has(ue.name),isLoadingSessions:!!d[ue.name],currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:y,onEditingNameChange:v,onToggleProject:w,onProjectSelect:S,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:E,onCancelEditingProject:I,onSaveProjectName:A,onDeleteProject:T,onSessionSelect:_,onDeleteSession:j,onLoadMoreSessions:R,onNewSession:C,onOpenOrchestration:D,onEditingSessionNameChange:U,onStartEditingSession:F,onCancelEditingSession:W,onSaveEditingSession:K,t:L},ue.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:H?i.jsxs(i.Fragment,{children:[te.map(ue=>be(ue)),ne.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:L("projects.detectedFromHistory")}),ne.map(ue=>be(ue))]})]}):V})}function Fa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ZE(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
|
|
220
|
+
*/const pD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],mD=At("workflow",pD),A4=g4,hD=b7,rk=m7,fD=a7,j4=c7,gD=f4,zn=y4,Ho=Q7,Bn=t8,bD=n8,bn=u7,Un=f4,nu=f7,I4=o7,Vu=K7,Wu=Z7,_g=y7,rt=b4,Pt=b4,qu=S7,xD=w7,yD=oP,nn=A8,kr=I8,qt=W7,qa=G7,R4=K8,Gr=EP,wc=S4,vD=S4,au=D7,Co=i8,Cs=v4,us=d8,No=v8,Or=k8,Kr=B8,$n=O8,ji=F8,wD=pP,kD=W8,Pg=Q8,Lg=vP,SD=N7,CD=M7,ND=zP,_4=k4,ef=cP,ED=$8,tf=k4,P4=hP,Ht=gP,Ur=UP,L4=C8,ys=nP,St=C4,rf=C4,kc=PP,Dg=R7,TD=j7,nf=T7,AD=E8,Hn=x4,jD=x4,ID=HP,vs=VP,Og=U7,Eo=z7,Mg=l8,Sc=L8,Fg=_8,kn=G8,Ii=v4,Cc=w4,RD=w4,D4=X8,An=tP,O4=iP,Ku=g8,M4=MP,_D=xP,pa=CP,PD=kP,Wt=p8,F4=e7,Nc=x8,Gn=jP,Ei=RP,z4=DP,tn=h8,zg=P7,LD=tL,Ui=oL,Bg=E4,DD=E4,Yr=$L,Fd=GL,Yu=WL,Os=QP,Ms=nL,OD=iL,jl=cL,po=uL,nk=hL,Il=gL,ml=vL,MD=kL,B4=LL,af=CL,la=AL,hl=EL,ak=IL,fl=_L,sf=OL,FD=FL,of=BL,io=ZL,Rl=JL,oi=eD,Fs=rD,zD=aD,lf=sD,BD=cD,gl=uD,hr=mD,Zu=xL,UD=KL,$D=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],HD={up:hD,down:A4,left:fD,right:j4},bl=e=>e.preventDefault(),ik="shrink-0 rounded-md border border-gray-600 bg-gray-700 px-2.5 py-1.5 text-xs font-medium text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40",GD="shrink-0 rounded-md border border-blue-500 bg-blue-600 px-2.5 py-1.5 text-xs font-medium text-white transition-colors select-none disabled:cursor-not-allowed disabled:opacity-40",Vp="shrink-0 rounded-md border border-gray-600 bg-gray-700 p-1.5 text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40";function sk({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Be("settings"),[s,o]=m.useState(!1),[l,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useCallback(b=>{ls(e.current,{type:"input",data:b})},[e]),f=m.useCallback(()=>{t.current?.scrollToBottom()},[t]),h=m.useCallback(async()=>{if(typeof navigator>"u"||!navigator.clipboard?.readText){u(!0);return}try{const b=await navigator.clipboard.readText();u(!1),b.length>0&&p(b)}catch{u(!0)}},[p]);m.useEffect(()=>{if(!d)return;const b=window.setTimeout(()=>u(!1),2500);return()=>window.clearTimeout(b)},[d]);const g=m.useCallback(b=>{let x=b;if(s&&b.length===1){const y=b.toLowerCase().charCodeAt(0);y>=97&&y<=122&&(x=String.fromCharCode(y-96)),o(!1)}l&&b.length===1&&(x="\x1B"+x,c(!1)),p(x)},[s,l,p]);return i.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:i.jsxs("div",{className:"pointer-events-auto flex items-center gap-1 overflow-x-auto rounded-lg border border-gray-700/80 bg-gray-900/95 px-1.5 py-1.5 shadow-lg backdrop-blur-sm [-webkit-overflow-scrolling:touch] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[d&&i.jsx("span",{className:"shrink-0 rounded-md border border-yellow-500/50 bg-yellow-500/15 px-2 py-1 text-[11px] text-yellow-100",children:"Clipboard blocked"}),i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>{h()},disabled:!r,className:Vp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(Co,{className:"h-4 w-4"})}),$D.map(b=>{if(b.type==="modifier"){const x=b.modifier==="ctrl"?s:l,y=b.modifier==="ctrl"?()=>o(v=>!v):()=>c(v=>!v);return i.jsx("button",{type:"button",onPointerDown:bl,onClick:y,disabled:!r,className:x?GD:ik,children:b.label},b.id)}if(b.type==="arrow"){const x=HD[b.icon];return i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>p(b.sequence),disabled:!r,className:Vp,children:i.jsx(x,{className:"h-4 w-4"})},b.id)}return i.jsx("button",{type:"button",onPointerDown:bl,onClick:()=>g(b.sequence),disabled:!r,className:ik,children:b.label},b.id)}),i.jsx("button",{type:"button",onPointerDown:bl,onClick:f,disabled:!r,className:Vp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(gD,{className:"h-4 w-4"})})]})})}function VD({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:s=!1,autoConnect:o=!1,forceNewSession:l=!1,startupInput:c=null,hermesLaunchId:d=null,permissionOverride:u=null,provider:p=null,isActive:f=!0,onClose:h=null}){const{t:g}=Be("chat"),[b,x]=m.useState(!1),[y,v]=m.useState(null),w=m.useRef(null),S=m.useRef(null),{terminalContainerRef:k,terminalRef:N,wsRef:E,isConnected:I,isInitialized:A,isConnecting:T,authUrl:_,authUrlVersion:j,connectToShell:R,disconnectFromShell:C,openAuthUrlInBrowser:D,copyAuthUrlToClipboard:U}=K_({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:s,autoConnect:o,forceNewSession:l,startupInput:c,hermesLaunchId:d,permissionOverride:u,provider:p,isRestarting:b,onProcessComplete:a,onOutputRef:S}),F=m.useCallback(()=>{const ve=N.current;if(!ve)return;const ke=ve.buffer.active,Ie=ke.baseY+ke.cursorY,M=Math.min(ke.baseY+ke.length-1,Ie+10),se=Math.max(0,Ie-w_),de=[];for(let Q=se;Q<=M;Q++){const ce=ke.getLine(Q);ce&&de.push(ce.translateToString().trimEnd())}let Y=-1;for(let Q=de.length-1;Q>=0;Q--)if(/esc to cancel/i.test(de[Q])||/enter to select/i.test(de[Q])){Y=Q;break}if(Y===-1){v(null);return}const $=new Map,ee=Math.max(0,Y-k_);for(let Q=Y-1;Q>=ee;Q--){const ce=de[Q].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(ce){const Te=ce[1],pe=ce[2].trim();parseInt(Te,10)<=S_&&pe.length>0&&!$.has(Te)&&$.set(Te,pe)}}const X=[];for(let Q=1;Q<=$.size&&$.has(String(Q));Q++)X.push({number:String(Q),label:$.get(String(Q))});v(X.length>=C_?X:null)},[N]),W=m.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(F,v_)},[F]);m.useEffect(()=>{S.current=W},[W]),m.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),m.useEffect(()=>{I||(w.current&&(clearTimeout(w.current),w.current=null),v(null))},[I]),m.useEffect(()=>{if(!f||!A||!I)return;const ve=()=>{N.current?.focus()},ke=window.requestAnimationFrame(ve),Ie=window.setTimeout(ve,0);return()=>{window.cancelAnimationFrame(ke),window.clearTimeout(Ie)}},[f,I,A,N]);const K=m.useCallback(ve=>{ls(E.current,{type:"input",data:ve})},[E]),L=m.useMemo(()=>$_(t),[t]),V=m.useMemo(()=>p||(t?.__provider?t.__provider:window.localStorage.getItem("selected-provider")||"claude"),[p,t?.__provider]),H=Pn[V]??"Claude Code",z=m.useMemo(()=>L?L.slice(0,30):null,[L]),te=m.useMemo(()=>L?L.slice(0,50):null,[L]),ne=m.useCallback(()=>{x(!0),window.setTimeout(()=>{x(!1)},x_)},[]),be=m.useCallback(()=>{C(),h?.()},[C,h]);if(!e)return i.jsx(Z_,{title:g("shell.selectProject.title"),description:g("shell.selectProject.description")});if(s)return i.jsxs(i.Fragment,{children:[i.jsx(J_,{terminalContainerRef:k,authUrl:_,authUrlVersion:j,initialCommand:r,isConnected:I,openAuthUrlInBrowser:D,copyAuthUrlToClipboard:U}),i.jsx(sk,{wsRef:E,terminalRef:N,isConnected:I,bottomOffset:"bottom-0"})]});const ue=n?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:e.displayName}):t?g("shell.resumeSession",{displayName:te}):g("shell.startProviderSession",{provider:H,defaultValue:"Start a new {{provider}} session"}),le=n?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:e.displayName}):g("shell.startProviderCli",{provider:H,projectName:e.displayName,defaultValue:"Starting {{provider}} in {{projectName}}"}),me=A?T?"connecting":I?null:"connect":"loading",he=me==="connecting"?le:ue;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(X_,{isConnected:I,isInitialized:A,isRestarting:b,hasSession:!!t,sessionDisplayNameShort:z,onDisconnect:be,onRestart:ne,statusNewSessionText:g("shell.status.newSession"),statusInitializingText:g("shell.status.initializing"),statusRestartingText:g("shell.status.restarting"),disconnectLabel:g("shell.actions.disconnect"),disconnectTitle:g("shell.actions.disconnectTitle"),restartLabel:g("shell.actions.restart"),restartTitle:g("shell.actions.restartTitle"),disableRestart:b||I}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[i.jsx("div",{ref:k,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),me&&i.jsx(Y_,{mode:me,description:he,loadingLabel:g("shell.loading"),connectLabel:g("shell.actions.connect"),connectTitle:g("shell.actions.connectTitle"),connectingLabel:g("shell.connecting"),onConnect:R}),y&&I&&i.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:ve=>ve.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.map(ve=>i.jsxs("button",{type:"button",onClick:()=>{K(`${ve.number}\r`),v(null)},className:"max-w-36 truncate rounded bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",title:`${ve.number}. ${ve.label}`,children:[ve.number,". ",ve.label]},ve.number)),i.jsx("button",{type:"button",onClick:()=>{K("\x1B"),v(null)},className:"rounded bg-gray-700 px-3 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:bg-gray-600",children:"Esc"})]})})]}),i.jsx(sk,{wsRef:E,terminalRef:N,isConnected:I})]})}function WD({className:e}){return i.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:i.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function qD({title:e,isCompleted:t,onClose:r=null}){return i.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&i.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function To({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:s=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1,forceNewSession:h=!1,startupInput:g=null,hermesLaunchId:b=null,permissionOverride:x=null,provider:y=null}){const[v,w]=m.useState(!1),S=n!==null?n:r!==null,k=m.useCallback(N=>{w(!0),o?.(N)},[o]);return e?i.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&i.jsx(qD,{title:c,isCompleted:v,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(VD,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:S,isActive:a,onProcessComplete:k,minimal:f,autoConnect:f?!0:s,forceNewSession:h,startupInput:g,hermesLaunchId:b,permissionOverride:x,provider:y,onClose:l})})]}):i.jsx(WD,{className:d})}const KD=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":e==="opencode"?"opencode auth login":"gemini"),YD={claude:{keyLabel:"Anthropic API Key",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console"},codex:{keyLabel:"OpenAI API Key",keyExample:"sk-...",supportsBaseUrl:!0,baseUrlExample:"https://api.openai.com/v1",keyConsoleUrl:"https://platform.openai.com/api-keys",keyConsoleLabel:"OpenAI Platform"},gemini:{keyLabel:"Gemini API Key",keyExample:"AI...",supportsBaseUrl:!1,keyConsoleUrl:"https://aistudio.google.com/app/apikey",keyConsoleLabel:"Google AI Studio"},qwen:{keyLabel:"OpenAI-Compatible API Key",keyExample:"sk-... or sk-sp-...",supportsBaseUrl:!0,baseUrlExample:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",keyConsoleUrl:"https://github.com/QwenLM/qwen-code",keyConsoleLabel:"Qwen Code Docs",notes:"Accepts any OpenAI-compatible endpoint — Alibaba Cloud, ModelScope, OpenRouter, self-hosted, etc."},opencode:{keyLabel:"Anthropic API Key (default backend)",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console",notes:"OpenCode is multi-provider — this sets the Anthropic credentials. Switch providers via `opencode auth login` or opencode.json."}};function ok({active:e,children:t,onClick:r}){return i.jsx("button",{onClick:r,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function ZD({provider:e}){const[t,r]=m.useState(""),[n,a]=m.useState(!1),[s,o]=m.useState("idle"),[l,c]=m.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await Se(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return i.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[i.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),i.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",i.jsx("code",{className:"rounded bg-background px-1 font-mono text-[11px]",children:"http://127.0.0.1:PORT/…"})," and your browser can't reach it (VPS setups), copy the failing URL from your address bar and paste it below. Pixcode forwards the token exchange to the CLI process on this host."]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",value:t,onChange:u=>r(u.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:u=>{u.key==="Enter"&&d()}}),i.jsx("button",{onClick:()=>void d(),disabled:n||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:n?i.jsx(Pt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),s==="ok"&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[i.jsx(qt,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),s==="error"&&l&&i.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function XD({provider:e,onSaved:t}){const r=YD[e],[n,a]=m.useState(""),[s,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState("idle"),[p,f]=m.useState(null);m.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await Se("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await Se(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&s.trim()?s.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);u("ok"),a(""),t()}catch(b){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?i.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:i.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:i.jsx(RD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),i.jsxs("a",{href:r.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",r.keyConsoleLabel,i.jsx(bn,{className:"h-3 w-3"})]})]})]}),r.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),i.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",i.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),i.jsx("input",{type:"url",value:s,onChange:g=>o(g.target.value),placeholder:r.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),i.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Point at any OpenAI-compatible proxy (OpenRouter, local LLM, self-hosted, budget provider) to cut costs or hit different models."})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[i.jsxs("button",{onClick:()=>void h(),disabled:l||!n.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?i.jsx(Pt,{className:"h-4 w-4 animate-spin"}):i.jsx(qt,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&i.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&i.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):i.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function U4({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Be("common"),l=r!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=m.useMemo(()=>`${Pn[r]??r} Login`,[r]);if(!e)return null;const p=KD(r,a),f=h=>n?.(h);return i.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:i.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),i.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:i.jsx(St,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(ok,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(ok,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),i.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(To,{project:i_,command:p,onComplete:f,minimal:!0})}),i.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:i.jsx(ZD,{provider:r})})]}):i.jsx(XD,{provider:r,onSaved:()=>f(0)})})]})})}const JD=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),QD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},eO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},tO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),rO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ni(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:r,alt:"OpenCode",className:e})},nO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function tr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(eO,{className:t}):e==="codex"?i.jsx(QD,{className:t}):e==="gemini"?i.jsx(tO,{className:t}):e==="qwen"?i.jsx(nO,{className:t}):e==="opencode"?i.jsx(rO,{className:t}):e==="hermes"?i.jsx(hr,{className:t}):i.jsx(JD,{className:t})}function aO({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return i.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:i.jsx(tr,{provider:e,className:"h-5 w-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&i.jsx(qt,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&i.jsx("button",{onClick:o,className:`${s} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const iO=[{provider:"claude",title:"Claude Code",connectedClassName:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",iconContainerClassName:"bg-blue-100 dark:bg-blue-900/30",loginButtonClassName:"bg-blue-600 hover:bg-blue-700"},{provider:"cursor",title:"Cursor",connectedClassName:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800",iconContainerClassName:"bg-purple-100 dark:bg-purple-900/30",loginButtonClassName:"bg-purple-600 hover:bg-purple-700"},{provider:"codex",title:"OpenAI Codex",connectedClassName:"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600",iconContainerClassName:"bg-gray-100 dark:bg-gray-800",loginButtonClassName:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"},{provider:"gemini",title:"Gemini",connectedClassName:"bg-teal-50 dark:bg-teal-900/20 border-teal-200 dark:border-teal-800",iconContainerClassName:"bg-teal-100 dark:bg-teal-900/30",loginButtonClassName:"bg-teal-600 hover:bg-teal-700"},{provider:"qwen",title:"Qwen Code",connectedClassName:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800",iconContainerClassName:"bg-orange-100 dark:bg-orange-900/30",loginButtonClassName:"bg-orange-600 hover:bg-orange-700"}];function lk({providerStatuses:e,onOpenProviderLogin:t}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsx("div",{className:"space-y-3",children:iO.map(r=>i.jsx(aO,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),i.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:i.jsx("p",{children:"You can configure these later in Settings."})})]})}function sO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-8 text-center",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30",children:i.jsx(Yr,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(ID,{className:"h-4 w-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:e,onChange:s=>n(s.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(AD,{className:"h-4 w-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:s=>a(s.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const ck=[{title:"Git Configuration",icon:Yr,required:!0},{title:"Connect Agents",icon:I4,required:!1}];function oO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:ck.map((t,r)=>{const n=r<e,a=r===e,s=t.icon;return i.jsxs("div",{className:"contents",children:[i.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[i.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:n?i.jsx(qt,{className:"h-6 w-6"}):i.jsx(s,{className:"h-6 w-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<ck.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const dk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,uk=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function lO({onComplete:e}){const[t,r]=m.useState(0),[n,a]=m.useState(""),[s,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),[p,f]=m.useState(null),{providerAuthStatus:h,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=Gu(),x=m.useRef(void 0),y=m.useCallback(async()=>{try{const I=await Se("/api/user/git-config");if(!I.ok)return;const A=await I.json();A.gitName&&a(A.gitName),A.gitEmail&&o(A.gitEmail)}catch(I){console.error("Error loading git config:",I)}},[]);m.useEffect(()=>{y(),b()},[y,b]),m.useEffect(()=>{const I=x.current;x.current=p,I!=null&&p===null&&b()},[p,b]);const v=I=>{f(I)},w=I=>{I===0&&p&&g(p)},S=async()=>{if(u(""),t!==0){r(I=>I+1);return}if(!n.trim()||!s.trim()){u("Both git name and email are required.");return}if(!dk.test(s)){u("Please enter a valid email address.");return}c(!0);try{const I=await Se("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!I.ok){const A=await uk(I,"Failed to save git configuration");throw new Error(A)}r(A=>A+1)}catch(I){u(I instanceof Error?I.message:"Failed to save git configuration")}finally{c(!1)}},k=()=>{u(""),r(I=>I-1)},N=async()=>{c(!0),u("");try{const I=await Se("/api/user/complete-onboarding",{method:"POST"});if(!I.ok){const A=await uk(I,"Failed to complete onboarding");throw new Error(A)}await e?.()}catch(I){u(I instanceof Error?I.message:"Failed to complete onboarding")}finally{c(!1)}},E=t===0?!!(n.trim()&&s.trim()&&dk.test(s)):!0;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx(oO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(sO,{gitName:n,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(lk,{providerStatuses:h,onOpenProviderLogin:v}):i.jsx(lk,{providerStatuses:h,onOpenProviderLogin:v}),d&&i.jsx("div",{className:"mt-6 rounded-lg border border-red-300 bg-red-100 p-4 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),i.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[i.jsxs("button",{onClick:k,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:[i.jsx(Ho,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<1?i.jsx("button",{onClick:S,disabled:!E||l,className:"flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-400",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(Bn,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:N,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(qt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(U4,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:w})]})}const cO=["0s","0.1s","0.2s"];function dO(){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(Hn,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),i.jsx("div",{className:"flex items-center justify-center space-x-2",children:cO.map(e=>i.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function $4({errorMessage:e}){return e?i.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function as({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:s,type:o="text",name:l,autoComplete:c}){return i.jsxs("div",{children:[i.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),i.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(d.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:s})]})}function H4({title:e,description:t,children:r,footerText:n,logo:a}){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsx("div",{className:"w-full max-w-md",children:i.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:a??i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(Hn,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),i.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),i.jsx("a",{href:"https://github.com/alicomert/pixcode",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground/50 transition-colors hover:text-muted-foreground",children:"Pixcode is open source"})]})]})})})}const uO={username:"",password:""};function pO(){const{t:e}=Be("auth"),{login:t}=vc(),[r,n]=m.useState(uO),[a,s]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),s(""),!r.username.trim()||!r.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||s(p.error),l(!1)},[r.password,r.username,t,e]);return i.jsx(H4,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(as,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(as,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx($4,{errorMessage:a}),i.jsx("button",{type:"submit",disabled:o,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:e(o?"login.loading":"login.submit")})]})})}const mO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function hO(e){return!e.username.trim()||!e.password||!e.confirmPassword?"Please fill in all fields.":e.username.trim().length<3?"Username must be at least 3 characters long.":e.password.length<6?"Password must be at least 6 characters long.":e.password!==e.confirmPassword?"Passwords do not match.":e.connectionMode==="remote"&&!e.remoteUrl.trim()?"Remote Pixcode server URL is required.":null}function fO(){const{register:e}=vc(),[t,r]=m.useState(mO),[n,a]=m.useState(""),[s,o]=m.useState(!1),l=m.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=hO(t);if(u){a(u);return}o(!0);const p=await fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t.connectionMode,remoteUrl:t.connectionMode==="remote"?t.remoteUrl.trim():null,apiKey:t.connectionMode==="remote"?t.remoteApiKey.trim():null})});if(!p.ok){const h=await p.json().catch(()=>null);a(h?.error||"Could not save connection mode."),o(!1);return}const f=await e(t.username.trim(),t.password);f.success||a(f.error),o(!1)},[t,e]);return i.jsx(H4,{title:"Welcome to Pixcode",description:"Create the first admin account to get started",footerText:"The first account becomes admin and can add more users later.",logo:i.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="local"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="remote"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&i.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[i.jsx(as,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:s,autoComplete:"url"}),i.jsx(as,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:s,type:"password",autoComplete:"off"})]}),i.jsx(as,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(as,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(as,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx($4,{errorMessage:n}),i.jsx("button",{type:"submit",disabled:s,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:s?"Setting up...":"Create Account"})]})})}function gO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=vc();return r?i.jsx(dO,{}):n?i.jsx(fO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(lO,{onComplete:s}):i.jsx(pO,{})}const G4=m.createContext(null),V4=()=>{const e=m.useContext(G4);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},bO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},xO=()=>{const e=m.useRef(null),t=m.useRef(!1),r=m.useRef(!1),[n,a]=m.useState(null),[s,o]=m.useState(!1),l=m.useRef(null),{token:c}=vc(),d=m.useCallback(()=>{if(!t.current)try{const f=bO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const h=new WebSocket(f);h.onopen=()=>{o(!0),e.current=h,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},h.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},h.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},h.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);m.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=m.useCallback(f=>{const h=e.current;h&&h.readyState===WebSocket.OPEN?h.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return m.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:s}),[u,n,s])},yO=({children:e})=>{const t=xO();return i.jsx(G4.Provider,{value:t,children:e})},W4=m.createContext(null);function Xu(){const e=m.useContext(W4);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function vO({children:e}){const{user:t,token:r,isLoading:n}=vc(),[a,s]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&r),p=m.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await Se("/api/plugins");if(x.ok){const y=await x.json();s(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{n||p()},[n,p]);const f=m.useCallback(async x=>{try{const y=await Se("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=m.useCallback(async(x,y)=>{try{const v=await Se(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const S=await v.json();w=S.details||S.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return i.jsx(W4.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const pk=e=>typeof window>"u"?!1:window.innerWidth<e,mk=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function Ug(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=m.useState(()=>r?pk(t):!1),[o,l]=m.useState(()=>n?mk():!1);return m.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(pk(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),m.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(mk())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const $g="pixcode.updateCheck.preferences",cf="pixcode:update-check-settings-changed",Hg=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],df={frequency:"30m"};function hk(e){return Hg.find(t=>t.value===e.frequency)?.intervalMs??null}function q4(e){if(!e||typeof e!="object")return df;const t=e.frequency;return Hg.some(r=>r.value===t)?{frequency:t}:df}function fk(){try{const e=localStorage.getItem($g);return q4(e?JSON.parse(e):null)}catch{return df}}function wO(e){const t=q4(e);localStorage.setItem($g,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(cf,{detail:t}))}const Wp=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},kO="1.51.8",iu="pixcode:update-available",SO=360*60*1e3,qp=new Map;function K4(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function CO(e,t){try{const r=localStorage.getItem(K4(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function gk(e,t,r){localStorage.setItem(K4(e,t),JSON.stringify(r))}function NO(e,t){const r=`${e}/${t}`,n=qp.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async s=>({status:s.status,ok:s.ok,data:await s.json().catch(()=>({}))})).finally(()=>{qp.delete(r)});return qp.set(r,a),a}const Gg=(e,t)=>{const[r,n]=m.useState(!1),[a,s]=m.useState(null),[o,l]=m.useState(null),[c,d]=m.useState("git"),[u,p]=m.useState("idle"),[f,h]=m.useState(null),[g,b]=m.useState(()=>fk()),[x,y]=m.useState(kO),v=m.useRef(null),w=m.useCallback(k=>{wO(k),b(k)},[]);m.useEffect(()=>{const k=()=>b(fk()),N=E=>{E.key===$g&&k()};return window.addEventListener("storage",N),window.addEventListener(cf,k),()=>{window.removeEventListener("storage",N),window.removeEventListener(cf,k)}},[]),m.useEffect(()=>{let k=!1;const N=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(k)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};N();const E=()=>{N()};return window.addEventListener("focus",E),()=>{k=!0,window.removeEventListener("focus",E)}},[]),m.useEffect(()=>{if(!x)return;let k=!1;const N=(j,R,C,D)=>({updateAvailable:!!(j&&Wp(j,x)>0),latestVersion:j,releaseInfo:R,currentVersion:x,checkedAt:C,status:D}),E=j=>{!j.updateAvailable||!j.latestVersion||!j.releaseInfo||window.dispatchEvent(new CustomEvent(iu,{detail:j}))},I=(j,R,C,D="success")=>{if(!j||!R)return n(!1),s(null),l(null),h(C),N(null,null,C,D);s(j),n(Wp(j,x)>0),l(R),h(C);const U=N(j,R,C,D);return E(U),U},A=async({force:j=!1}={})=>{const R=hk(g),C=CO(e,t),D=Date.now();if(!j&&R===null)return p("idle"),I(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!j&&C?.fetchedAt&&R!==null&&D-C.fetchedAt<R)return p("success"),I(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!j&&C?.rateLimitedUntil&&C.rateLimitedUntil>D)return p("error"),I(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const U=await NO(e,t);if(k)return N(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const F=U.data;if(!U.ok)return U.status===403&&gk(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:D+Math.max(R??0,SO)}),p("error"),I(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(F.tag_name){const W=F.tag_name.replace(/^v/,""),K=Wp(W,x)>0,L={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};gk(e,t,{fetchedAt:D,latestVersion:W,releaseInfo:L}),s(W),n(K),K&&o4({key:`app-update:${W}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${W}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:W,installMode:c}}),l(L),p("success"),h(D);const V=N(W,L,D,"success");return E(V),V}else return n(!1),s(null),l(null),p("error"),N(null,null,null,"error")}catch(U){return console.error("Version check failed:",U),n(!1),s(null),l(null),p("error"),N(null,null,null,"error")}};v.current=A,A();const T=hk(g),_=T===null?null:window.setInterval(()=>{A()},T);return()=>{k=!0,_!==null&&window.clearInterval(_)}},[e,t,x,c,g]);const S=m.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:S,updateCheckPreferences:g,updatePreferences:w}},is={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},EO=["flat","grouped"],TO=e=>typeof e=="string"&&EO.includes(e),su=Object.keys(is),AO=new Set(su),Kp="ui-preferences:sync",jO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},ou=(e,t,r)=>e==="historyView"?TO(t)?t:r:jO(t,r),IO=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return ou(e,n,t)}catch{return t}},RO=e=>{if(typeof window>"u")return is;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return su.reduce((a,s)=>(a[s]=ou(s,n[s],is[s]),a),{...is})}}}catch{}return su.reduce((t,r)=>(t[r]=IO(r,is[r]),t),{...is})};function _O(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!AO.has(r))return e;const a=ou(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of su){if(!(s in r))continue;const o=r[s],l=ou(s,o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...is,...t.value||{}};default:return e}}function Vg(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=m.useReducer(_O,e,RO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Kp,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(Kp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Kp,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const PO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},LO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},DO=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},bk=(e,t)=>`${e}::${t}`,OO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},MO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},FO=/(?:^|[\s/\\(\[`"'])([\w./-]+?\.(?:ts|tsx|js|jsx|mjs|cjs|py|rb|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|bash|zsh|json|ya?ml|toml|md|mdx|html?|css|scss|less|sql|prisma|graphql|gql|vue|svelte|astro|dart|lua|r|pl|ps1|tf|dockerfile|env))(?:$|[\s:,)\]`"'])/i,zO=e=>{if(!e)return[];const t=new Set,r=new RegExp(FO.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],s=a.lastIndexOf(".");if(s>-1){const o=a.slice(s+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},ps=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||e.createdAt||0),BO=(e,t)=>e.__provider==="cursor"?e.summary||e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.__provider==="gemini"||e.__provider==="qwen"||e.__provider==="opencode"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),UO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),$O=(e,t,r)=>{const n=ps(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:BO(e,r),sessionTime:UO(e),messageCount:Number(e.messageCount||0)}},Y4=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),s=g=>typeof g.id=="string"&&g.id.startsWith("qwen_")||g.provider==="qwen",o=g=>typeof g.id=="string"&&g.id.startsWith("opencode_")||g.provider==="opencode",l=e.geminiSessions||[],c=l.filter(g=>!s(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>s(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],h=new Map;for(const g of[...r,...n,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>ps(b).getTime()-ps(g).getTime())},xk=(e,t)=>{const r=Y4(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=ps(a);return s>n?s:n},new Date(0))},HO=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?xk(o,n).getTime()-xk(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},GO=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},VO=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function WO({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setSidebarVisible:p,sidebarVisible:f}){const[h,g]=m.useState(new Set),[b,x]=m.useState(null),[y,v]=m.useState(!1),[w,S]=m.useState(""),[k,N]=m.useState({}),[E,I]=m.useState({}),[A,T]=m.useState(new Set),[_,j]=m.useState(new Date),[R,C]=m.useState("name"),[D,U]=m.useState(!1),[F,W]=m.useState({}),[K,L]=m.useState(null),[V,H]=m.useState(""),[z,te]=m.useState(""),[ne,be]=m.useState(new Set),[ue,le]=m.useState(null),[me,he]=m.useState(null),[ve,ke]=m.useState(!1),[Ie,M]=m.useState(()=>LO()),[se,de]=m.useState(()=>OO()),[Y,$]=m.useState("projects"),[ee,X]=m.useState(null),[Q,ce]=m.useState(!1),[Te,pe]=m.useState(null),ae=m.useRef(null),B=m.useRef(0),re=m.useRef(null),ge=!a&&!f;m.useEffect(()=>{const Oe=setInterval(()=>{j(new Date)},6e4);return()=>clearInterval(Oe)},[]),m.useEffect(()=>{I({}),T(new Set),W({})},[e]),m.useEffect(()=>{t&&g(Oe=>{if(Oe.has(t.name))return Oe;const Ye=new Set(Oe);return Ye.add(t.name),Ye})},[r,t]),m.useEffect(()=>{if(e.length>0&&!n){const Oe=new Set;e.forEach(Ye=>{Ye.sessions&&Ye.sessions.length>=0&&Oe.add(Ye.name)}),T(Oe)}},[e,n]),m.useEffect(()=>{const Oe=()=>{C(PO())};Oe();const Ye=et=>{et.key==="claude-settings"&&Oe()},it=()=>Oe();return window.addEventListener("storage",Ye),window.addEventListener("pixcode:settings-changed",it),()=>{window.removeEventListener("storage",Ye),window.removeEventListener("pixcode:settings-changed",it)}},[]),m.useEffect(()=>{ae.current&&clearTimeout(ae.current),re.current&&(re.current.close(),re.current=null);const Oe=z.trim();if(Y!=="conversations"||Oe.length<2){B.current+=1,X(null),pe(null),ce(!1);return}ce(!0);const Ye=++B.current;return ae.current=setTimeout(()=>{if(Ye!==B.current)return;const it=Lt.searchConversationsUrl(Oe),et=new EventSource(it);re.current=et;const gt=[];let It=0;et.addEventListener("result",J=>{if(Ye!==B.current){et.close();return}try{const Ee=JSON.parse(J.data);gt.push(Ee.projectResult),It=Ee.totalMatches,X({results:[...gt],totalMatches:It,query:Oe}),pe({scannedProjects:Ee.scannedProjects,totalProjects:Ee.totalProjects})}catch{}}),et.addEventListener("progress",J=>{if(Ye!==B.current){et.close();return}try{const Ee=JSON.parse(J.data);It=Ee.totalMatches,pe({scannedProjects:Ee.scannedProjects,totalProjects:Ee.totalProjects})}catch{}}),et.addEventListener("done",()=>{if(Ye!==B.current){et.close();return}et.close(),re.current=null,ce(!1),pe(null),gt.length===0&&X({results:[],totalMatches:0,query:Oe})}),et.addEventListener("error",()=>{if(Ye!==B.current){et.close();return}et.close(),re.current=null,ce(!1),pe(null),gt.length===0&&X({results:[],totalMatches:0,query:Oe})})},400),()=>{ae.current&&clearTimeout(ae.current),re.current&&(re.current.close(),re.current=null)}},[z,Y]);const je=m.useCallback(Oe=>{g(Ye=>{const it=new Set;return Ye.has(Oe)||it.add(Oe),it})},[]),Ue=m.useCallback((Oe,Ye)=>{c({...Oe,__projectName:Ye})},[c]),Ve=m.useCallback(Oe=>{M(Ye=>{const it=new Set(Ye);return it.has(Oe)?it.delete(Oe):it.add(Oe),DO(it),it})},[]),tt=m.useCallback(Oe=>Ie.has(Oe),[Ie]),We=m.useCallback((Oe,Ye)=>{de(it=>{const et=bk(Oe,Ye),gt=new Set(it);return gt.has(et)?gt.delete(et):gt.add(et),MO(gt),gt})},[]),ht=m.useCallback((Oe,Ye)=>se.has(bk(Oe,Ye)),[se]),dt=m.useCallback(Oe=>Y4(Oe,E),[E]),st=m.useMemo(()=>e.map(Oe=>{const Ye=F[Oe.name];return Ye===void 0?Oe:{...Oe,sessionMeta:{...Oe.sessionMeta,hasMore:Ye}}}),[F,e]),bt=m.useMemo(()=>HO(st,R,Ie,E),[E,R,st,Ie]),wt=m.useMemo(()=>GO(bt,z),[z,bt]),Ft=m.useCallback(Oe=>{x(Oe.name),S(Oe.displayName)},[]),Gt=m.useCallback(()=>{x(null),S("")},[]),ar=m.useCallback(async Oe=>{try{(await Lt.renameProject(Oe,w)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ye){console.error("Error renaming project:",Ye)}finally{x(null),S("")}},[w]),Ut=m.useCallback((Oe,Ye,it,et="claude")=>{he({projectName:Oe,sessionId:Ye,sessionTitle:it,provider:et})},[]),ir=m.useCallback(async()=>{if(!me)return;const{projectName:Oe,sessionId:Ye,provider:it}=me;he(null);try{let et;if(it==="codex"?et=await Lt.deleteCodexSession(Ye):it==="gemini"?et=await Lt.deleteGeminiSession(Ye):it==="qwen"?et=await Lt.deleteQwenSession(Ye):et=await Lt.deleteSession(Oe,Ye),et.ok)d?.(Ye);else{const gt=await et.text();console.error("[Sidebar] Failed to delete session:",{status:et.status,error:gt}),alert(s("messages.deleteSessionFailed"))}}catch(et){console.error("[Sidebar] Error deleting session:",et),alert(s("messages.deleteSessionError"))}},[d,me,s]),Ze=m.useCallback(Oe=>{le({project:Oe,sessionCount:dt(Oe).length})},[dt]),Ae=m.useCallback(async(Oe=!1)=>{if(!ue)return;const{project:Ye,sessionCount:it}=ue,et=it===0;le(null),be(gt=>new Set([...gt,Ye.name]));try{const gt=await Lt.deleteProject(Ye.name,!et,Oe);if(gt.ok)u?.(Ye.name);else{const It=await gt.json();alert(It.error||s("messages.deleteProjectFailed"))}}catch(gt){console.error("Error deleting project:",gt),alert(s("messages.deleteProjectError"))}finally{be(gt=>{const It=new Set(gt);return It.delete(Ye.name),It})}},[ue,u,s]),$e=m.useCallback(async Oe=>{const Ye=F[Oe.name];if(!(!(Ye!==void 0?Ye:Oe.sessionMeta?.hasMore===!0)||k[Oe.name])){N(et=>({...et,[Oe.name]:!0}));try{const et=(Oe.sessions?.length||0)+(E[Oe.name]?.length||0),gt=await Lt.sessions(Oe.name,5,et);if(!gt.ok)return;const It=await gt.json();I(J=>({...J,[Oe.name]:[...J[Oe.name]||[],...It.sessions||[]]})),It.hasMore===!1&&W(J=>({...J,[Oe.name]:!1}))}catch(et){console.error("Error loading more sessions:",et)}finally{N(et=>({...et,[Oe.name]:!1}))}}},[E,k,F]),Ke=m.useCallback(Oe=>{l(Oe)},[l]),ot=m.useCallback(async()=>{U(!0);try{await o()}finally{U(!1)}},[o]),Ct=m.useCallback(async(Oe,Ye,it,et)=>{const gt=it.trim();if(!gt){L(null),H("");return}try{const It=await Lt.renameSession(Ye,gt,et);It.ok?await o():(console.error("[Sidebar] Failed to rename session:",It.status),alert(s("messages.renameSessionFailed")))}catch(It){console.error("[Sidebar] Error renaming session:",It),alert(s("messages.renameSessionError"))}finally{L(null),H("")}},[o,s]),Ot=m.useCallback(()=>{p(!1)},[p]),sr=m.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:ge,expandedProjects:h,editingProject:b,showNewProject:y,editingName:w,loadingSessions:k,additionalSessions:E,initialSessionsLoaded:A,currentTime:_,projectSortOrder:R,isRefreshing:D,editingSession:K,editingSessionName:V,searchFilter:z,deletingProjects:ne,deleteConfirmation:ue,sessionDeleteConfirmation:me,showVersionModal:ve,starredProjects:Ie,starredSessions:se,filteredProjects:wt,toggleProject:je,handleSessionClick:Ue,toggleStarProject:Ve,isProjectStarred:tt,toggleStarSession:We,isSessionStarred:ht,getProjectSessions:dt,startEditing:Ft,cancelEditing:Gt,saveProjectName:ar,showDeleteSessionConfirmation:Ut,confirmDeleteSession:ir,requestProjectDelete:Ze,confirmDeleteProject:Ae,loadMoreSessions:$e,handleProjectSelect:Ke,refreshProjects:ot,updateSessionSummary:Ct,collapseSidebar:Ot,expandSidebar:sr,setShowNewProject:v,setEditingName:S,setEditingSession:L,setEditingSessionName:H,searchMode:Y,setSearchMode:$,conversationResults:ee,isSearching:Q,searchProgress:Te,clearConversationResults:m.useCallback(()=>{B.current+=1,re.current&&(re.current.close(),re.current=null),ce(!1),pe(null),X(null)},[]),setSearchFilter:te,setDeleteConfirmation:le,setSessionDeleteConfirmation:he,setShowVersionModal:ke}}const qO="https://discord.gg/buxwujPNRE",KO="https://github.com/alicomert/pixcode/issues/new";function YO({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function ZO({onExpand:e,onOpenControlRoom:t,onShowSettings:r,updateAvailable:n,onShowVersionModal:a,t:s}){return i.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[i.jsx("button",{onClick:e,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("common:versionUpdate.ariaLabels.showSidebar"),title:s("common:versionUpdate.ariaLabels.showSidebar"),children:i.jsx(Wu,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("div",{className:"nav-divider my-1 w-6"}),t&&i.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg border border-primary/25 bg-primary/10 transition-colors hover:bg-primary/15","aria-label":s("actions.controlRoom",{defaultValue:"Control Room"}),title:s("actions.controlRoom",{defaultValue:"Control Room"}),children:i.jsx(Gn,{className:"h-4 w-4 text-primary"})}),i.jsx("button",{onClick:r,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.settings"),title:s("actions.settings"),children:i.jsx(Wt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:KO,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.reportIssue"),title:s("actions.reportIssue"),children:i.jsx(Eo,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:qO,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("actions.joinCommunity"),title:s("actions.joinCommunity"),children:i.jsx(YO,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&i.jsxs("button",{onClick:a,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":s("common:versionUpdate.ariaLabels.updateAvailable"),title:s("common:versionUpdate.ariaLabels.updateAvailable"),children:[i.jsx(Gn,{className:"h-4 w-4 text-blue-500"}),i.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function Z4(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=Z4(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function X4(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=Z4(e))&&(n&&(n+=" "),n+=t);return n}const yk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,vk=X4,Wg=(e,t)=>r=>{var n;if(t?.variants==null)return vk(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=s?.[d];if(u===null)return null;const f=yk(u)||yk(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...h}=u;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...s,...l}[b]):{...s,...l}[b]===x})?[...d,p,f]:d},[]);return vk(e,o,c,r?.class,r?.className)},qg="-",XO=e=>{const t=QO(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(qg);return l[0]===""&&l.length!==1&&l.shift(),J4(l,t)||JO(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},J4=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?J4(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(qg);return t.validators.find(({validator:o})=>o(s))?.classGroupId},wk=/^\[(.+)\]$/,JO=e=>{if(wk.test(e)){const t=wk.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},QO=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)uf(r[a],n,a,t);return n},uf=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:kk(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(eM(a)){uf(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{uf(o,kk(t,s),r,n)})})},kk=(e,t)=>{let r=e;return t.split(qg).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},eM=e=>e.isThemeGetter,tM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},pf="!",mf=":",rM=mf.length,nM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let o=0,l=0,c=0,d;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===mf){s.push(a.slice(c,g)),c=g+rM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=aM(u),f=p!==u,h=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+mf,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},aM=e=>e.endsWith(pf)?e.substring(0,e.length-1):e.startsWith(pf)?e.substring(1):e,iM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},sM=e=>({cache:tM(e.cacheSize),parseClassName:nM(e),sortModifiers:iM(e),...XO(e)}),oM=/\s+/,lM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(oM);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=s(f).join(":"),w=h?v+pf:v,S=w+y;if(o.includes(S))continue;o.push(S);const k=a(y,x);for(let N=0;N<k.length;++N){const E=k[N];o.push(w+E)}c=u+(c.length>0?" "+c:c)}return c};function cM(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=Q4(t))&&(n&&(n+=" "),n+=r);return n}const Q4=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Q4(e[n]))&&(r&&(r+=" "),r+=t);return r};function dM(e,...t){let r,n,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=sM(d),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=lM(c,r);return a(c,u),u}return function(){return s(cM.apply(null,arguments))}}const Ir=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},eE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,tE=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uM=/^\d+\/\d+$/,pM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,mM=/\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$/,hM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zs=e=>uM.test(e),kt=e=>!!e&&!Number.isNaN(Number(e)),li=e=>!!e&&Number.isInteger(Number(e)),Yp=e=>e.endsWith("%")&&kt(e.slice(0,-1)),Da=e=>pM.test(e),bM=()=>!0,xM=e=>mM.test(e)&&!hM.test(e),rE=()=>!1,yM=e=>fM.test(e),vM=e=>gM.test(e),wM=e=>!Je(e)&&!Qe(e),kM=e=>Go(e,iE,rE),Je=e=>eE.test(e),Ki=e=>Go(e,sE,xM),Zp=e=>Go(e,TM,kt),Sk=e=>Go(e,nE,rE),SM=e=>Go(e,aE,vM),Kc=e=>Go(e,oE,yM),Qe=e=>tE.test(e),xl=e=>Vo(e,sE),CM=e=>Vo(e,AM),Ck=e=>Vo(e,nE),NM=e=>Vo(e,iE),EM=e=>Vo(e,aE),Yc=e=>Vo(e,oE,!0),Go=(e,t,r)=>{const n=eE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vo=(e,t,r=!1)=>{const n=tE.exec(e);return n?n[1]?t(n[1]):r:!1},nE=e=>e==="position"||e==="percentage",aE=e=>e==="image"||e==="url",iE=e=>e==="length"||e==="size"||e==="bg-size",sE=e=>e==="length",TM=e=>e==="number",AM=e=>e==="family-name",oE=e=>e==="shadow",jM=()=>{const e=Ir("color"),t=Ir("font"),r=Ir("text"),n=Ir("font-weight"),a=Ir("tracking"),s=Ir("leading"),o=Ir("breakpoint"),l=Ir("container"),c=Ir("spacing"),d=Ir("radius"),u=Ir("shadow"),p=Ir("inset-shadow"),f=Ir("text-shadow"),h=Ir("drop-shadow"),g=Ir("blur"),b=Ir("perspective"),x=Ir("aspect"),y=Ir("ease"),v=Ir("animate"),w=()=>["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"],k=()=>[...S(),Qe,Je],N=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],I=()=>[Qe,Je,c],A=()=>[zs,"full","auto",...I()],T=()=>[li,"none","subgrid",Qe,Je],_=()=>["auto",{span:["full",li,Qe,Je]},li,Qe,Je],j=()=>[li,"auto",Qe,Je],R=()=>["auto","min","max","fr",Qe,Je],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...I()],F=()=>[zs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],W=()=>[e,Qe,Je],K=()=>[...S(),Ck,Sk,{position:[Qe,Je]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",NM,kM,{size:[Qe,Je]}],H=()=>[Yp,xl,Ki],z=()=>["","none","full",d,Qe,Je],te=()=>["",kt,xl,Ki],ne=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ue=()=>[kt,Yp,Ck,Sk],le=()=>["","none",g,Qe,Je],me=()=>["none",kt,Qe,Je],he=()=>["none",kt,Qe,Je],ve=()=>[kt,Qe,Je],ke=()=>[zs,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Da],breakpoint:[Da],color:[bM],container:[Da],"drop-shadow":[Da],ease:["in","out","in-out"],font:[wM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Da],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Da],shadow:[Da],spacing:["px",kt],text:[Da],"text-shadow":[Da],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zs,Je,Qe,x]}],container:["container"],columns:[{columns:[kt,Je,Qe,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"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:k()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[li,"auto",Qe,Je]}],basis:[{basis:[zs,"full","auto",l,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[kt,zs,"auto","initial","none",Je]}],grow:[{grow:["",kt,Qe,Je]}],shrink:[{shrink:["",kt,Qe,Je]}],order:[{order:[li,"first","last","none",Qe,Je]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",r,xl,Ki]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Qe,Zp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yp,Je]}],"font-family":[{font:[CM,Je,t]}],"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:[a,Qe,Je]}],"line-clamp":[{"line-clamp":[kt,"none",Qe,Zp]}],leading:[{leading:[s,...I()]}],"list-image":[{"list-image":["none",Qe,Je]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Qe,Je]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[kt,"from-font","auto",Qe,Ki]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[kt,"auto",Qe,Je]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Qe,Je]}],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",Qe,Je]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},li,Qe,Je],radial:["",Qe,Je],conic:[li,Qe,Je]},EM,SM]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[kt,Qe,Je]}],"outline-w":[{outline:["",kt,xl,Ki]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",u,Yc,Kc]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",p,Yc,Kc]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[kt,Ki]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",f,Yc,Kc]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[kt,Qe,Je]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"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":[kt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Qe,Je]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"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":[kt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Qe,Je]}],filter:[{filter:["","none",Qe,Je]}],blur:[{blur:le()}],brightness:[{brightness:[kt,Qe,Je]}],contrast:[{contrast:[kt,Qe,Je]}],"drop-shadow":[{"drop-shadow":["","none",h,Yc,Kc]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",kt,Qe,Je]}],"hue-rotate":[{"hue-rotate":[kt,Qe,Je]}],invert:[{invert:["",kt,Qe,Je]}],saturate:[{saturate:[kt,Qe,Je]}],sepia:[{sepia:["",kt,Qe,Je]}],"backdrop-filter":[{"backdrop-filter":["","none",Qe,Je]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[kt,Qe,Je]}],"backdrop-contrast":[{"backdrop-contrast":[kt,Qe,Je]}],"backdrop-grayscale":[{"backdrop-grayscale":["",kt,Qe,Je]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[kt,Qe,Je]}],"backdrop-invert":[{"backdrop-invert":["",kt,Qe,Je]}],"backdrop-opacity":[{"backdrop-opacity":[kt,Qe,Je]}],"backdrop-saturate":[{"backdrop-saturate":[kt,Qe,Je]}],"backdrop-sepia":[{"backdrop-sepia":["",kt,Qe,Je]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Qe,Je]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[kt,"initial",Qe,Je]}],ease:[{ease:["linear","initial",y,Qe,Je]}],delay:[{delay:[kt,Qe,Je]}],animate:[{animate:["none",v,Qe,Je]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Qe,Je]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[Qe,Je,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"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",Qe,Je]}],"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":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",Qe,Je]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[kt,xl,Ki,Zp]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","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","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","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-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-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-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-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"]}},IM=dM(jM);function xe(...e){return IM(X4(e))}function RM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const _M=Wg("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),lE=m.forwardRef(({className:e,variant:t,...r},n)=>i.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:xe(_M({variant:t}),e),...r}));lE.displayName="Alert";const PM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-title",className:xe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));PM.displayName="AlertTitle";const LM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-description",className:xe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));LM.displayName="AlertDescription";const DM=Wg("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Et({className:e,variant:t,...r}){return i.jsx("div",{className:xe(DM({variant:t}),e),...r})}const OM=Wg("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ne=m.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:xe(OM({variant:t,size:r,className:e})),ref:a,...n}));Ne.displayName="Button";const cE=m.createContext(null),dE=()=>{const e=m.useContext(cE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},uE=({className:e,approval:t="pending",children:r,...n})=>{const a=m.useMemo(()=>({approval:t}),[t]);return i.jsx(cE.Provider,{value:a,children:i.jsx(lE,{className:xe("flex flex-col gap-2",e),...n,children:r})})};uE.displayName="Confirmation";const pE=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:xe("text-muted-foreground inline text-sm",e),...t});pE.displayName="ConfirmationTitle";const mE=({children:e})=>{const{approval:t}=dE();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};mE.displayName="ConfirmationRequest";const hE=({className:e,...t})=>{const{approval:r}=dE();return r!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:xe("flex items-center justify-end gap-2 self-end",e),...t})};hE.displayName="ConfirmationActions";const zd=({variant:e="default",...t})=>i.jsx(Ne,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});zd.displayName="ConfirmationAction";const fE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));fE.displayName="Card";const gE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("flex flex-col space-y-1.5 p-4",e),...t}));gE.displayName="CardHeader";const bE=m.forwardRef(({className:e,...t},r)=>i.jsx("h3",{ref:r,className:xe("font-semibold leading-none tracking-tight",e),...t}));bE.displayName="CardTitle";const MM=m.forwardRef(({className:e,...t},r)=>i.jsx("p",{ref:r,className:xe("text-sm text-muted-foreground",e),...t}));MM.displayName="CardDescription";const xE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("p-4 pt-0",e),...t}));xE.displayName="CardContent";const yE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("flex items-center p-4 pt-0",e),...t}));yE.displayName="CardFooter";const FM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("ml-auto shrink-0",e),...t}));FM.displayName="CardAction";const vE=m.createContext(null);function wE(){const e=m.useContext(vE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const Ri=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...s},o)=>{const[l,c]=m.useState(e),d=t!==void 0,u=d?t:l,p=m.useCallback(h=>{d||c(h),r?.(h)},[d,r]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(vE.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...s,children:a})})});Ri.displayName="Collapsible";const Ka=m.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:s,onOpenChange:o}=wE(),l=m.useCallback(c=>{o(!s),e?.(c)},[s,o,e]);return i.jsx("button",{ref:a,type:"button","aria-expanded":s,"data-state":s?"open":"closed",onClick:l,className:r,...n,children:t})});Ka.displayName="CollapsibleTrigger";const _i=m.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=wE();return i.jsx("div",{ref:n,"data-state":a?"open":"closed",className:xe("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:i.jsx("div",{className:"overflow-hidden",children:t})})});_i.displayName="CollapsibleContent";const kE=m.createContext(null);function Kg(){const e=m.useContext(kE);if(!e)throw new Error("Command components must be used within <Command>");return e}const SE=m.forwardRef(({className:e,children:t,...r},n)=>{const[a,s]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=m.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=m.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),f=m.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[S,k]of o.current)(!v||k.value.includes(v))&&w.add(S);return w},[a,l]),h=m.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=h;if(w.length===0)return;if(v.key==="Enter"){w.find(A=>A.id===g)?.onSelect();return}const S=w.findIndex(I=>I.id===g);let k;v.key==="ArrowDown"?k=S<w.length-1?S+1:0:k=S>0?S-1:w.length-1;const N=w[k].id;b(N),w[k].element?.scrollIntoView({block:"nearest"})},[h,g]),y=m.useMemo(()=>({search:a,setSearch:s,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return i.jsx(kE.Provider,{value:y,children:i.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:xe("flex flex-col",e),onKeyDown:x,...r,children:t})})});SE.displayName="Command";const CE=m.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:s}=Kg();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(ys,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:xe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})});CE.displayName="CommandInput";const NE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,role:"listbox",className:xe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));NE.displayName="CommandList";const EE=m.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=Kg();return!n||a.size>0?null:i.jsx("div",{ref:r,className:xe("py-6 text-center text-sm text-muted-foreground",e),...t})});EE.displayName="CommandEmpty";const TE=m.forwardRef(({className:e,heading:t,children:r,...n},a)=>i.jsxs("div",{ref:a,className:xe("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));TE.displayName="CommandGroup";const AE=m.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=Kg(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:r||(()=>{})})},[h,r,f]);const x=m.useCallback(v=>{g.current=v,f(h,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[h,f,o]);if(!l.has(h))return null;const y=c===h;return i.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:xe("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==h&&d(h)},onClick:()=>!n&&r?.(),...s,children:a})});AE.displayName="CommandItem";const zM=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:xe("-mx-1 h-px bg-border",e),...t}));zM.displayName="CommandSeparator";function lu({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=ni(),s=typeof e=="boolean"&&typeof t=="function",o=s?e:n,l=()=>{if(s&&t){t(!o);return}a()};return i.jsxs("button",{onClick:l,className:xe("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":r,children:[i.jsx("span",{className:"sr-only",children:r}),i.jsx("span",{className:xe("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?i.jsx(O4,{className:"h-3 w-3 text-primary"}):i.jsx(z4,{className:"h-3 w-3 text-white dark:text-background"})})]})}const jE=m.createContext(null);function IE(){const e=m.useContext(jE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const RE=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,s]=m.useState(r),o=m.useRef(null),l=e!==void 0,c=l?e:a,d=m.useCallback(p=>{l||s(p),t?.(p)},[l,t]),u=m.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return i.jsx(jE.Provider,{value:u,children:n})},BM=m.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:s,triggerRef:o}=IE(),l=m.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(r&&m.isValidElement(t)){const c=t;return m.cloneElement(c,{onClick:d=>{s(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return i.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});BM.displayName="DialogTrigger";const Nk='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Yg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=IE(),d=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),m.useEffect(()=>{if(!o)return;const p=h=>{if(h.key==="Escape"){h.stopPropagation(),r?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(Nk));if(g.length===0)return;const b=g[0],x=g[g.length-1];h.shiftKey&&document.activeElement===b?(h.preventDefault(),x.focus()):!h.shiftKey&&document.activeElement===x&&(h.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(Nk)?.focus()})},[o]),o?$u.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),i.jsx("div",{ref:p=>{d.current=p,typeof s=="function"?s(p):s&&(s.current=p)},role:"dialog","aria-modal":"true",className:xe("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});Yg.displayName="DialogContent";const Zg=m.forwardRef(({className:e,...t},r)=>i.jsx("h2",{ref:r,className:xe("sr-only",e),...t}));Zg.displayName="DialogTitle";const Xe=m.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:xe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Xe.displayName="Input";const Xg=m.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>i.jsx("div",{className:xe("relative overflow-hidden",e),...n,children:i.jsx("div",{ref:a,className:xe("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Xg.displayName="ScrollArea";const cu=m.memo(({children:e,className:t,as:r="span"})=>i.jsx(r,{className:xe("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",t),children:e}));cu.displayName="Shimmer";const _E=m.createContext(null),UM=()=>{const e=m.useContext(_E);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},$M=1e3,HM=1e3,hf=m.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:s,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=m.useState(c),f=r!==void 0,h=f?r:u,g=m.useCallback(N=>{f||p(N),a?.(N)},[f,a]),[b,x]=m.useState(s),y=m.useRef(t),[v,w]=m.useState(!1),S=m.useRef(null);m.useEffect(()=>{s!==void 0&&x(s)},[s]),m.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/HM)),S.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(y.current&&!t&&h&&!v){const N=setTimeout(()=>{g(!1),w(!0)},$M);return()=>clearTimeout(N)}},[t,h,g,v]);const k=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return i.jsx(_E.Provider,{value:k,children:i.jsx(Ri,{open:h,onOpenChange:g,className:xe("not-prose",e),...l,children:o})})});hf.displayName="Reasoning";const GM=(e,t)=>e||t===0?i.jsx(cu,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),ff=m.memo(({className:e,children:t,getThinkingMessage:r=GM,...n})=>{const{isStreaming:a,isOpen:s,duration:o}=UM();return i.jsx(Ka,{className:xe("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??i.jsxs(i.Fragment,{children:[i.jsx(DD,{className:"h-4 w-4"}),r(a,o),i.jsx(y4,{className:xe("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});ff.displayName="ReasoningTrigger";const gf=m.memo(({className:e,children:t,...r})=>i.jsx(_i,{className:xe("mt-4 text-sm text-muted-foreground",e),...r,children:t}));gf.displayName="ReasoningContent";function VM(e){switch(e){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function bf({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[s,o]=m.useState(!1),l=m.useRef(null),c=m.useRef(!1),d=m.useRef(null),u=m.useRef(null),[p,f]=m.useState(null),h=m.useCallback(()=>{const w=d.current;if(!w)return;const S=w.getBoundingClientRect(),k=8,N={position:"fixed",zIndex:9999};switch(r){case"bottom":N.left=S.left+S.width/2,N.top=S.bottom+k,N.transform="translateX(-50%)";break;case"left":N.left=S.left-k,N.top=S.top+S.height/2,N.transform="translate(-100%, -50%)";break;case"right":N.left=S.right+k,N.top=S.top+S.height/2,N.transform="translateY(-50%)";break;case"top":default:N.left=S.left+S.width/2,N.top=S.top-k,N.transform="translate(-50%, -100%)";break}f(N)},[r]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!s||typeof document>"u")return;const w=S=>{const k=S.target;k instanceof Node&&d.current?.contains(k)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[s]),m.useEffect(()=>{if(!s){f(null);return}const w=window.requestAnimationFrame(h),S=()=>h();return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[s,h]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,s&&typeof document<"u"&&$u.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:xe("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",n),children:[t,i.jsx("div",{className:xe("absolute w-0 h-0 border-4 border-transparent",VM(r))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const PE=m.createContext(null),LE=m.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const s=m.useMemo(()=>({status:t}),[t]);return i.jsx(PE.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:xe("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});LE.displayName="PromptInput";const DE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:xe("px-3 pt-3",e),...t}));DE.displayName="PromptInputHeader";const OE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:xe("relative",e),...t}));OE.displayName="PromptInputBody";const ME=m.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:xe("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 font-mono text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));ME.displayName="PromptInputTextarea";const FE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:xe("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));FE.displayName="PromptInputFooter";const zE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:xe("flex items-center gap-1",e),...t}));zE.displayName="PromptInputTools";const Bd=m.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const s=i.jsx(Ne,{ref:a,type:"button",variant:"ghost",size:"icon",className:xe("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?i.jsx(bf,{content:t.shortcut?i.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,i.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:s}):s});Bd.displayName="PromptInputButton";const BE=m.forwardRef(({className:e,status:t,children:r,...n},a)=>{const s=m.useContext(PE),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(Ne,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:xe("h-8 w-8 rounded-lg",e),...n,children:r??(l?i.jsx(kc,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(yD,{className:"h-4 w-4"}))})});BE.displayName="PromptInputSubmit";function Jg({children:e,className:t}){return i.jsx("div",{className:xe("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Qg({isActive:e,onClick:t,children:r,className:n}){return i.jsx("button",{onClick:t,className:xe("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",n),children:r})}const UE=m.createContext(null);function $E(){const e=m.useContext(UE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const HE=m.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:xe("space-y-0.5",e),...t}));HE.displayName="Queue";const GE=m.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const s=m.useMemo(()=>({status:e}),[e]);return i.jsx(UE.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:xe("flex items-start gap-2 py-0.5",t),...n,children:r})})});GE.displayName="QueueItem";const VE=m.forwardRef(({className:e,...t},r)=>{const{status:n}=$E();return i.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:xe("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});VE.displayName="QueueItemIndicator";const WE=m.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=$E();return i.jsx("div",{ref:n,"data-slot":"queue-item-content",className:xe("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...r,children:t})});WE.displayName="QueueItemContent";const Ek="https://github.com/alicomert/pixcode/issues/new",WM="https://github.com/alicomert/pixcode",Tk="https://discord.gg/buxwujPNRE";function Ak({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function qM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onOpenControlRoom:s,onShowSettings:o,t:l}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:a,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(rk,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})}),i.jsx("div",{className:"px-3 py-2 md:hidden",children:i.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:a,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(rk,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("a",{href:Ek,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[i.jsx(Eo,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.reportIssue")})]})}),i.jsx("div",{className:"hidden px-2 md:block",children:i.jsxs("a",{href:Tk,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[i.jsx(Ak,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.joinCommunity")})]})}),s&&i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg border border-primary/25 bg-primary/5 px-2.5 py-2 text-left transition-colors hover:bg-primary/10",onClick:s,children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-primary/10 text-primary",children:i.jsx(Gn,{className:"h-3.5 w-3.5"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),i.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:o,children:[i.jsx(Wt,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:l("actions.settings")})]})}),i.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:i.jsxs("a",{href:WM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",l("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:Ek,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Eo,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.reportIssue")})]})}),i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("a",{href:Tk,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Ak,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.joinCommunity")})]})}),s&&i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("button",{className:"flex h-14 w-full items-center gap-3.5 rounded-xl border border-primary/25 bg-primary/10 px-4 transition-all hover:bg-primary/15 active:scale-[0.98]",onClick:s,children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-primary/15",children:i.jsx(Gn,{className:"w-4.5 h-4.5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-base font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),i.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:i.jsxs("button",{className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:o,children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Wt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.settings")})]})})]})}const jk="PIXCODE_GITHUB_STARS",Ik="PIXCODE_HIDE_GITHUB_STAR",KM=3600*1e3,YM=(e,t)=>{const[r,n]=m.useState(null),[a,s]=m.useState(()=>{try{return localStorage.getItem(Ik)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(jk);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<KM){n(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){n(p);try{localStorage.setItem(jk,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{s(!0);try{localStorage.setItem(Ik,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},ZM="https://github.com/alicomert/pixcode";function XM({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function JM(){const{formattedCount:e,isDismissed:t,dismiss:r}=YM("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:ZM,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[i.jsx(XM,{className:"h-3.5 w-3.5"}),i.jsx(Ei,{className:"h-3 w-3"}),i.jsx("span",{className:"font-medium",children:"Star"}),e&&i.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),i.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:i.jsx(St,{className:"h-2.5 w-2.5"})})]})}function Rk({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return i.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:xe(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(Pg,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:xe(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(SD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function QM({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:h,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:i.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:i.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[i.jsx("path",{d:"M2037 3800 c-104 -40 -191 -134 -231 -250 -23 -67 -20 -82 22 -109 31 -20 287 -177 1009 -618 40 -24 82 -56 93 -70 27 -34 27 -102 0 -136 -11 -13 -106 -78 -212 -143 -106 -64 -201 -124 -210 -132 -16 -14 -18 -41 -18 -302 0 -291 2 -310 38 -310 16 0 267 148 610 359 180 111 270 173 310 213 216 217 215 574 -3 793 -37 38 -107 89 -185 136 -69 42 -253 154 -410 249 -434 264 -509 307 -563 326 -57 20 -191 17 -250 -6z"}),i.jsx("path",{d:"M1803 2994 c-10 -5 -13 -156 -13 -709 0 -671 1 -706 20 -767 27 -89 93 -184 167 -240 89 -67 157 -90 281 -96 92 -4 105 -2 117 14 12 16 14 134 15 735 0 669 -1 718 -17 737 -20 23 -514 322 -541 327 -9 2 -23 2 -29 -1z"})]})})}),i.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:d,disabled:u,title:x("tooltips.refresh"),children:i.jsx(rt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:p,title:x("tooltips.createProject"),children:i.jsx(Ht,{className:"h-4 w-4"})}),i.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:h,title:x("tooltips.hideSidebar"),children:i.jsx(Vu,{className:"h-4 w-4"})})]})]}),i.jsx(JM,{}),f&&i.jsxs("button",{type:"button",onClick:()=>{f()},className:"mt-2.5 flex w-full items-center justify-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[i.jsx(Gn,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Rk,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Kr,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Hn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(ys,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Xe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&i.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:i.jsx(St,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider hidden md:block"}),i.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:d,disabled:u,children:i.jsx(rt,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:p,children:i.jsx(ji,{className:"h-4 w-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Rk,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Kr,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:xe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[i.jsx(Hn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(ys,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Xe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&i.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:i.jsx(St,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const e9=160,_k=180;function qE({actions:e,className:t,triggerLabel:r}){const[n,a]=m.useState(!1),[s,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-e9;p<8&&(p=8);let f=u.bottom+4;f+_k>window.innerHeight&&(f=Math.max(8,u.top-4-_k)),o({top:f,left:p})},[n]),m.useEffect(()=>{if(!n)return;const u=h=>{const g=h.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=h=>{h.key==="Escape"&&a(!1)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:xe("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",n&&"bg-accent text-foreground opacity-100",t),children:i.jsx(L4,{className:"h-3.5 w-3.5"})}),n&&s&&$u.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:xe("w-40 rounded-xl border border-border/60 bg-popover p-1 shadow-lg","animate-in fade-in-0 zoom-in-95 duration-100"),onClick:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),children:e.map((u,p)=>{const f=u.icon,h=e[p-1],g=p>0&&u.danger&&!h?.danger;return i.jsxs("div",{children:[g&&i.jsx("div",{className:"my-1 h-px bg-border/60"}),i.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:xe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",u.danger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"text-foreground hover:bg-accent"),children:[i.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const t9=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),d=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function Pk({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:s,className:o}){const l=d=>i.jsx(Ei,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:_4,onClick:r},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:Ur,onClick:a,danger:!0}),i.jsx(qE,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const r9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Lk={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function KE({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:h,onSessionSelect:g,onDeleteSession:b,t:x}){const y=$O(t,n,x),v=r?.id===t.id,w=a===t.id,S=t.__provider,k=r9[S]??S,N=Lk[S]??Lk.claude,E=zO(y.sessionName),I=()=>{h(e),g(t,e.name)},A=()=>{p(e.name,t.id,s,S)},T=()=>{b(e.name,t.id,y.sessionName,S)},_=()=>d(t.id,y.sessionName),j=()=>f(e.name,t.id),R=i.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[i.jsxs("span",{className:xe("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",N),children:[i.jsx(tr,{provider:S,className:"h-2.5 w-2.5"}),k]}),i.jsx("span",{className:"text-muted-foreground/80",children:t9(y.sessionTime,n,x)}),y.isActive&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),E.slice(0,3).map(F=>i.jsxs("span",{className:"rounded-md bg-muted/60 px-1 py-px font-mono text-[9px] uppercase tracking-wide text-muted-foreground ring-1 ring-border/40",children:[".",F]},F))]}),C=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:F=>c(F.target.value),onKeyDown:F=>{F.stopPropagation(),F.key==="Enter"?A():F.key==="Escape"&&u()},onClick:F=>F.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),i.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:F=>{F.stopPropagation(),A()},title:x("tooltips.save"),children:i.jsx(qt,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),i.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:F=>{F.stopPropagation(),u()},title:x("tooltips.cancel"),children:i.jsx(St,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),D=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:xe("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:I,children:w?i.jsx("div",{className:"flex items-center gap-1",children:C}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:xe("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:i.jsx(tr,{provider:S,className:"h-3 w-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[o&&i.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),R]}),i.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:i.jsx(Pk,{isStarred:o,canDelete:!y.isCursorSession,onRename:_,onToggleStar:j,onDelete:T,t:x,className:"!opacity-100"})})]})})}),U=i.jsxs("div",{className:xe("group/item relative hidden md:block"),children:[i.jsxs(Ne,{variant:"ghost",className:xe("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&i.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&i.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),i.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[i.jsx("div",{className:xe("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:i.jsx(tr,{provider:S,className:"h-3 w-3"})}),i.jsx("div",{className:"min-w-0 flex-1",children:w?i.jsx("div",{className:"flex items-center gap-1",children:C}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&i.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),R]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:i.jsx(Pk,{isStarred:o,canDelete:!y.isCursorSession,onRename:_,onToggleStar:j,onDelete:T,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[D,U]})}const n9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function a9(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"rounded-md p-2",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function i9({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:S,t:k}){const[N,E]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let T=!1;const _=async()=>{const R=await Se(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!R.ok)return;const C=await R.json();T||E((C.runs??[]).slice(0,5))};_();const j=window.setInterval(()=>{_()},15e3);return()=>{T=!0,window.clearInterval(j)}},[t,e.name]),!t)return null;const I=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[i.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:i.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{b(e),w(e)},children:[i.jsx(Ht,{className:"h-3 w-3"}),k("sessions.newSession")]})}),i.jsxs(Ne,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>w(e),children:[i.jsx(Ht,{className:"h-3 w-3"}),k("sessions.newSession")]}),N.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[i.jsx(hr,{className:"h-3 w-3"}),k("orchestration.section")]}),N.map(T=>{const _=[...new Set(T.nodeRuns.map(j=>n9(j.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>S?.(e,T.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:i.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[i.jsx(hr,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:T.input||k("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[_.slice(0,4).map(j=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(tr,{provider:j,className:"h-3 w-3"})},j)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:k(`common:orchestration.status.${T.status}`,{defaultValue:T.status})})]})]})]})},T.id)})]}),a?!I&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:k("sessions.noSessions")})}):r.map(T=>i.jsx(KE,{project:e,session:T,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,T.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:k},T.id)):i.jsx(a9,{}),I&&A&&i.jsx(Ne,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),k("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(zn,{className:"h-3 w-3"}),k("sessions.showMore")]})})]})}const s9=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function o9({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingNameChange:b,onToggleProject:x,onProjectSelect:y,onToggleStarProject:v,onToggleStarSession:w,onStartEditingProject:S,onCancelEditingProject:k,onSaveProjectName:N,onDeleteProject:E,onSessionSelect:I,onDeleteSession:A,onLoadMoreSessions:T,onNewSession:_,onOpenOrchestration:j,onEditingSessionNameChange:R,onStartEditingSession:C,onCancelEditingSession:D,onSaveEditingSession:U,t:F}){const W=t?.name===e.name,K=o===e.name,L=e.sessionMeta?.hasMore===!0,V=s9(c,L),H=`${V} session${c.length===1?"":"s"}`,z=()=>x(e.name),te=()=>v(e.name),ne=()=>{N(e.name)},be=()=>{t?.name!==e.name&&y(e),z()};return i.jsxs("div",{className:xe("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"md:group group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:xe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",W&&"bg-primary/5 border-primary/20",s&&!W&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:z,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[i.jsx("div",{className:xe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx($n,{className:"h-4 w-4 text-primary"}):i.jsx(Kr,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:K?i.jsx("input",{type:"text",value:l,onChange:ue=>b(ue.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ue=>ue.stopPropagation(),onKeyDown:ue=>{ue.key==="Enter"&&ne(),ue.key==="Escape"&&k()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:i.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:H})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:K?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:ue=>{ue.stopPropagation(),ne()},children:i.jsx(qt,{className:"h-4 w-4 text-white"})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:ue=>{ue.stopPropagation(),k()},children:i.jsx(St,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:xe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:ue=>{ue.stopPropagation(),te()},title:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(Ei,{className:xe("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:ue=>{ue.stopPropagation(),E(e)},children:i.jsx(Ur,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),i.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:ue=>{ue.stopPropagation(),S(e)},children:i.jsx(ef,{className:"h-4 w-4 text-primary"})}),i.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?i.jsx(zn,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(Bn,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(Ne,{variant:"ghost",className:xe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",W&&"bg-accent text-accent-foreground",s&&!W&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:be,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?i.jsx($n,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Kr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:K?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:ue=>b(ue.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ue=>{ue.key==="Enter"&&ne(),ue.key==="Escape"&&k()}}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[V,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:K?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:ue=>{ue.stopPropagation(),ne()},children:i.jsx(qt,{className:"h-3 w-3"})}),i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:ue=>{ue.stopPropagation(),k()},children:i.jsx(St,{className:"h-3 w-3"})})]}):i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded hover:bg-yellow-50 dark:hover:bg-yellow-900/20",onClick:ue=>{ue.stopPropagation(),te()},title:F("tooltips.removeFromFavorites"),children:i.jsx(Ei,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(qE,{triggerLabel:F("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:F("actions.rename"),icon:ef,onClick:()=>S(e)},{id:"star",label:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Ei,onClick:te},{id:"delete",label:F("actions.delete",{defaultValue:"Delete"}),icon:Ur,onClick:()=>E(e),danger:!0}]}),n?i.jsx(zn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(Bn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(i9,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingSessionNameChange:R,onStartEditingSession:C,onCancelEditingSession:D,onSaveEditingSession:U,onToggleStarSession:w,onProjectSelect:y,onSessionSelect:I,onDeleteSession:A,onLoadMoreSessions:T,onNewSession:_,onOpenOrchestration:j,t:F})]})}function YE({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:i.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Kr,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(ys,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function l9({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:h,deletingProjects:g,getProjectSessions:b,isProjectStarred:x,isSessionStarred:y,onEditingNameChange:v,onToggleProject:w,onProjectSelect:S,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:E,onCancelEditingProject:I,onSaveProjectName:A,onDeleteProject:T,onSessionSelect:_,onDeleteSession:j,onLoadMoreSessions:R,onNewSession:C,onOpenOrchestration:D,onEditingSessionNameChange:U,onStartEditingSession:F,onCancelEditingSession:W,onSaveEditingSession:K,t:L}){const V=i.jsx(YE,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:L});m.useEffect(()=>{let ue="Pixcode";const le=r?.displayName?.trim();le&&(ue=`${le} - ${ue}`),document.title=ue},[r]);const H=!a&&e.length>0&&t.length>0,z=ue=>ue.source==="history"||ue.autoDiscovered===!0&&ue.isManuallyAdded!==!0,te=t.filter(ue=>!z(ue)),ne=t.filter(ue=>z(ue)),be=ue=>i.jsx(o9,{project:ue,selectedProject:r,selectedSession:n,isExpanded:o.has(ue.name),isDeleting:g.has(ue.name),isStarred:x(ue.name),editingProject:l,editingName:c,sessions:b(ue),initialSessionsLoaded:u.has(ue.name),isLoadingSessions:!!d[ue.name],currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:y,onEditingNameChange:v,onToggleProject:w,onProjectSelect:S,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:E,onCancelEditingProject:I,onSaveProjectName:A,onDeleteProject:T,onSessionSelect:_,onDeleteSession:j,onLoadMoreSessions:R,onNewSession:C,onOpenOrchestration:D,onEditingSessionNameChange:U,onStartEditingSession:F,onCancelEditingSession:W,onSaveEditingSession:K,t:L},ue.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:H?i.jsxs(i.Fragment,{children:[te.map(ue=>be(ue)),ne.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:L("projects.detectedFromHistory")}),ne.map(ue=>be(ue))]})]}):V})}function Fa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ZE(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
|
|
221
221
|
* GSAP 3.15.0
|
|
222
222
|
* https://gsap.com
|
|
223
223
|
*
|
|
@@ -261,8 +261,8 @@ API_KEY`})]}),K&&x.importMode==="form"&&x.transport==="http"&&i.jsxs("div",{chil
|
|
|
261
261
|
peer-checked:after:translate-x-4
|
|
262
262
|
`})]})}function yB({running:e,t}){return e?i.jsxs("span",{className:"relative flex items-center gap-1.5",children:[i.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[i.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),i.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-emerald-600 dark:text-emerald-400",children:t("pluginSettings.runningStatus")})]}):null}function vB({plugin:e,index:t,onToggle:r,onUpdate:n,onUninstall:a,updating:s,confirmingUninstall:o,onCancelUninstall:l,updateError:c}){const{t:d}=Be("settings"),u=e.enabled?"bg-emerald-500":"bg-muted-foreground/20";return i.jsxs("div",{className:"relative flex overflow-hidden rounded-lg border border-border bg-card transition-opacity duration-200",style:{opacity:e.enabled?1:.65,animationDelay:`${t*40}ms`},children:[i.jsx("div",{className:`w-[3px] flex-shrink-0 ${u} transition-colors duration-300`}),i.jsxs("div",{className:"min-w-0 flex-1 p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"h-5 w-5 flex-shrink-0 text-foreground/80",children:i.jsx(aT,{pluginName:e.name,iconFile:e.icon,className:"h-5 w-5 [&>svg]:h-full [&>svg]:w-full"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:"text-sm font-semibold leading-none text-foreground",children:e.displayName}),i.jsxs("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["v",e.version]}),i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e.slot}),i.jsx(yB,{running:!!e.serverRunning,t:d})]}),e.description&&i.jsx("p",{className:"mt-1 text-sm leading-snug text-muted-foreground",children:e.description}),i.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.author&&i.jsx("span",{className:"text-xs text-muted-foreground/60",children:e.author}),e.repoUrl&&i.jsxs("a",{href:e.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[i.jsx(Yr,{className:"h-3 w-3"}),i.jsx("span",{className:"max-w-[200px] truncate",children:e.repoUrl.replace(/^https?:\/\/(www\.)?github\.com\//,"")})]})]})]})]}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[i.jsx("button",{onClick:n,disabled:s||!e.repoUrl,title:e.repoUrl?d("pluginSettings.pullLatest"):d("pluginSettings.noGitRemote"),"aria-label":d("pluginSettings.pullLatest"),className:"rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",children:s?i.jsx(Pt,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(rt,{className:"h-3.5 w-3.5"})}),i.jsx("button",{onClick:a,title:d(o?"pluginSettings.confirmUninstall":"pluginSettings.uninstallPlugin"),"aria-label":d("pluginSettings.uninstallPlugin"),className:`rounded p-1.5 transition-colors ${o?"bg-red-50 text-red-500 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/30":"text-muted-foreground hover:bg-muted hover:text-red-500"}`,children:i.jsx(Ur,{className:"h-3.5 w-3.5"})}),i.jsx(xB,{checked:e.enabled,onChange:r,ariaLabel:`${e.enabled?d("pluginSettings.disable"):d("pluginSettings.enable")} ${e.displayName}`})]})]}),o&&i.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 rounded border border-red-200 bg-red-50 px-3 py-2 dark:border-red-800/50 dark:bg-red-950/30",children:[i.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:d("pluginSettings.confirmUninstallMessage",{name:e.displayName})}),i.jsxs("div",{className:"flex gap-1.5",children:[i.jsx("button",{onClick:l,className:"rounded border border-border px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d("pluginSettings.cancel")}),i.jsx("button",{onClick:a,className:"rounded border border-red-300 px-2.5 py-1 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 dark:border-red-700 dark:text-red-400 dark:hover:bg-red-900/30",children:d("pluginSettings.remove")})]})]}),c&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-sm text-red-500",children:[i.jsx(PD,{className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{children:c})]})]})]})}function wB(){const{t:e}=Be("settings"),{plugins:t,loading:r,installPlugin:n,uninstallPlugin:a,updatePlugin:s,togglePlugin:o}=Xu(),[l,c]=m.useState(""),[d,u]=m.useState(!1),[p,f]=m.useState(null),[h,g]=m.useState(null),[b,x]=m.useState(new Set),[y,v]=m.useState({}),w=async N=>{x(I=>new Set(I).add(N)),v(I=>{const A={...I};return delete A[N],A});const E=await s(N);E.success||v(I=>({...I,[N]:E.error||e("pluginSettings.updateFailed")})),x(I=>{const A=new Set(I);return A.delete(N),A})},S=async()=>{if(!l.trim())return;u(!0),f(null);const N=await n(l.trim());N.success?c(""):f(N.error||e("pluginSettings.installFailed")),u(!1)},k=async N=>{if(h!==N){g(N);return}const E=await a(N);E.success||f(E.error||e("pluginSettings.uninstallFailed")),g(null)};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"mb-1 text-base font-semibold text-foreground",children:e("pluginSettings.title")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:e("pluginSettings.description")})]}),i.jsxs("div",{className:"flex items-center gap-0 overflow-hidden rounded-lg border border-border bg-card",children:[i.jsx("span",{className:"flex-shrink-0 pl-3 pr-1 text-muted-foreground/40",children:i.jsx(Yr,{className:"h-3.5 w-3.5"})}),i.jsx("input",{type:"text",value:l,onChange:N=>{c(N.target.value),f(null)},placeholder:e("pluginSettings.installPlaceholder"),"aria-label":e("pluginSettings.installAriaLabel"),className:"flex-1 bg-transparent px-2 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none",onKeyDown:N=>{N.key==="Enter"&&S()}}),i.jsx("button",{onClick:S,disabled:d||!l.trim(),className:"flex-shrink-0 border-l border-border bg-foreground px-4 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-30",children:d?i.jsx(Pt,{className:"h-4 w-4 animate-spin"}):e("pluginSettings.installButton")})]}),p&&i.jsx("p",{className:"-mt-4 text-sm text-red-500",children:p}),i.jsxs("p",{className:"-mt-4 flex items-start gap-1.5 text-xs leading-snug text-muted-foreground/50",children:[i.jsx(wc,{className:"mt-px h-3 w-3 flex-shrink-0"}),i.jsx("span",{children:e("pluginSettings.securityWarning")})]}),r?i.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[i.jsx(Pt,{className:"h-4 w-4 animate-spin"}),e("pluginSettings.scanningPlugins")]}):t.length===0?i.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:e("pluginSettings.noPluginsInstalled")}):i.jsx("div",{className:"space-y-2",children:t.map((N,E)=>{const I=async A=>{const T=await o(N.name,A);T.success||f(T.error||e("pluginSettings.toggleFailed"))};return i.jsx(vB,{plugin:N,index:E,onToggle:A=>void I(A),onUpdate:()=>void w(N.name),onUninstall:()=>void k(N.name),updating:b.has(N.name),confirmingUninstall:h===N.name,onCancelUninstall:()=>g(null),updateError:y[N.name]??null},N.name)})}),i.jsxs("div",{className:"flex items-center justify-center gap-3 border-t border-border/50 pt-2",children:[i.jsx(au,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/40"}),i.jsxs("a",{href:bB,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[e("pluginSettings.docs")," ",i.jsx(bn,{className:"h-2.5 w-2.5"})]})]})]})}const B2=async e=>{try{return await J3.toDataURL(e,{margin:1,width:220})}catch(t){return console.error("QR generation failed for",e,t),null}};function kB(){const{t:e}=Be("settings"),[t,r]=m.useState(null),[n,a]=m.useState([]),[s,o]=m.useState(!0),[l,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(null),[h,g]=m.useState([]),[b,x]=m.useState(!1),[y,v]=m.useState(null),[w,S]=m.useState(null),k=m.useCallback(async()=>{o(!0),c(null);try{const T=await Se("/api/network/endpoints");if(!T.ok)throw new Error(`HTTP ${T.status}`);const _=await T.json();r(_);const j=await Promise.all(_.endpoints.map(async R=>({key:R.url,label:R.label,url:R.url,dataUrl:await B2(R.url)})));a(j)}catch(T){console.error("Failed to load network endpoints",T),c(e("mobile.error"))}finally{o(!1)}},[e]),N=m.useCallback(async()=>{try{const T=await Se("/api/network/external");if(!T.ok)throw new Error(`HTTP ${T.status}`);const _=await T.json();f(_),S(_.tunnel?.installHint??null);const j=[];_.tunnel?.running&&_.tunnel.url&&j.push({key:`tunnel:${_.tunnel.url}`,label:_.tunnel.binary||"tunnel",url:_.tunnel.url});const R=await Promise.all(j.map(async C=>({...C,dataUrl:await B2(C.url)})));g(R)}catch(T){console.error("Failed to load external state",T)}},[]);m.useEffect(()=>{k(),N()},[k,N]);const E=async T=>{try{await navigator.clipboard.writeText(T),u(T),window.setTimeout(()=>u(_=>_===T?null:_),1500)}catch(_){console.error("Clipboard copy failed",_)}},I=async()=>{x(!0),v(null);try{const T=p?.tunnel.running,_=await Se("/api/network/tunnel",{method:T?"DELETE":"POST"}),j=await _.json();if(!_.ok)if(S(j.installHint??j.tunnel?.installHint??null),j.tunnel&&f({tunnel:j.tunnel}),_.status===424)v(e("mobile.external.tunnelUnavailable"));else throw new Error(j.error||`HTTP ${_.status}`);await N()}catch(T){const _=T instanceof Error?T.message:String(T);v(_)}finally{x(!1)}},A=T=>{const _=d===T.url;return i.jsxs("div",{className:"flex items-center gap-4 rounded-xl border border-border/60 bg-background p-4",children:[i.jsx("div",{className:"flex h-28 w-28 flex-shrink-0 items-center justify-center rounded-lg bg-white p-1",children:T.dataUrl?i.jsx("img",{src:T.dataUrl,alt:`QR for ${T.url}`,className:"h-full w-full"}):i.jsx("div",{className:"text-xs text-muted-foreground",children:"—"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:T.label}),i.jsx("button",{type:"button",onClick:()=>void E(T.url),className:"mt-1 block w-full truncate text-left text-sm font-medium text-foreground transition-colors hover:text-primary",title:T.url,children:T.url}),i.jsx("div",{className:"mt-2 flex items-center gap-2",children:i.jsxs("button",{type:"button",onClick:()=>void E(T.url),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[i.jsx(Co,{className:"h-3 w-3"}),e(_?"mobile.copied":"mobile.copy")]})})]})]},T.key)};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:i.jsx(Nc,{className:"h-5 w-5"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h3",{className:"text-base font-semibold text-foreground",children:e("mobile.title")}),i.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e("mobile.description")})]}),i.jsxs("button",{type:"button",onClick:()=>{k(),N()},className:"inline-flex items-center gap-1.5 rounded-lg border border-border/60 bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",disabled:s,children:[i.jsx(rt,{className:`h-3.5 w-3.5 ${s?"animate-spin":""}`}),e("mobile.refresh")]})]}),i.jsx("div",{className:"rounded-lg border border-border/60 bg-muted/20 p-4 text-xs text-muted-foreground",children:i.jsxs("ol",{className:"list-decimal space-y-1 pl-4",children:[i.jsx("li",{children:e("mobile.steps.sameNetwork")}),i.jsx("li",{children:e("mobile.steps.scan")}),i.jsx("li",{children:e("mobile.steps.login")})]})}),l&&i.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3 text-sm text-red-600 dark:text-red-400",children:l}),s&&!t&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(rt,{className:"h-4 w-4 animate-spin"}),e("mobile.loading")]}),t&&n.length===0&&!s&&i.jsx("div",{className:"rounded-lg border border-border/60 bg-muted/20 p-4 text-sm text-muted-foreground",children:e("mobile.noEndpoints")}),i.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:n.map(A)}),i.jsxs("div",{className:"space-y-4 border-t border-border/40 pt-5",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-amber-500/10 text-amber-600 dark:text-amber-400",children:i.jsx(kn,{className:"h-5 w-5"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("mobile.external.title")}),i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:e("mobile.external.description")})]})]}),y&&i.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3 text-xs text-red-600 dark:text-red-400",children:y}),i.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border/60 bg-background p-3",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Mg,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{className:"text-sm font-medium text-foreground",children:e("mobile.external.tunnelTitle")}),p?.tunnel.running&&i.jsxs("span",{className:"rounded-full bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-600 dark:text-green-400",children:[e("mobile.external.tunnelRunning")," · ",p.tunnel.binary]})]}),i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:e("mobile.external.tunnelDescription")})]}),i.jsxs("button",{type:"button",onClick:()=>void I(),disabled:b,className:"ml-3 inline-flex items-center gap-1.5 rounded-lg border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted/50 disabled:opacity-50",children:[b&&i.jsx(rt,{className:"h-3 w-3 animate-spin"}),p?.tunnel.running?e("mobile.external.tunnelStop"):e("mobile.external.tunnelStart")]})]}),(w||p?.tunnel.installHint)&&i.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/10 p-3 text-xs text-amber-800 dark:text-amber-100",children:[i.jsx("div",{className:"font-semibold",children:(w||p?.tunnel.installHint)?.title||"Tunnel setup needed"}),i.jsx("p",{className:"mt-1 leading-5",children:(w||p?.tunnel.installHint)?.message}),!!(w||p?.tunnel.installHint)?.commands?.length&&i.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-4",children:(w||p?.tunnel.installHint)?.commands?.map(T=>i.jsx("li",{className:"font-mono text-[11px]",children:T},T))})]}),h.length>0&&i.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:h.map(A)})]}),t&&i.jsxs("div",{className:"border-t border-border/40 pt-3 text-[11px] text-muted-foreground/80",children:[e("mobile.hostLabel"),": ",i.jsx("span",{className:"font-mono",children:t.hostname})," ","· ",e("mobile.portLabel"),": ",i.jsx("span",{className:"font-mono",children:t.port})]})]})}const ed=({title:e,description:t,children:r})=>i.jsxs("div",{className:"rounded-xl border border-border/60 bg-background p-4",children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e}),t&&i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),r]});function SB(){const{t:e,i18n:t}=Be("settings"),[r,n]=m.useState(null),[a,s]=m.useState(!0),[o,l]=m.useState(""),[c,d]=m.useState(null),[u,p]=m.useState(null),f=m.useCallback(async()=>{s(!0);try{const _=await Se("/api/telegram/status");if(!_.ok)throw new Error(`HTTP ${_.status}`);const j=await _.json();n(j)}catch(_){p(_ instanceof Error?_.message:String(_))}finally{s(!1)}},[]);m.useEffect(()=>{f()},[f]);const h=async()=>{d("token"),p(null);try{const _=await Se("/api/telegram/bot",{method:"POST",body:JSON.stringify({token:o.trim()})}),j=await _.json();if(!_.ok)throw new Error(j.error||`HTTP ${_.status}`);l(""),await f()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{d(null)}},g=async()=>{d("stop"),p(null);try{const _=await Se("/api/telegram/bot/stop",{method:"POST"});if(!_.ok)throw new Error(`HTTP ${_.status}`);await f()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{d(null)}},b=async()=>{d("remove"),p(null);try{const _=await Se("/api/telegram/bot",{method:"DELETE"});if(!_.ok)throw new Error(`HTTP ${_.status}`);await f()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{d(null)}},x=async()=>{d("pair"),p(null);try{const _=await Se("/api/telegram/pairing-code",{method:"POST",body:JSON.stringify({language:t.language})});if(!_.ok)throw new Error(`HTTP ${_.status}`);await f()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{d(null)}},y=async()=>{d("unpair"),p(null);try{const _=await Se("/api/telegram/link",{method:"DELETE"});if(!_.ok)throw new Error(`HTTP ${_.status}`);await f()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{d(null)}},v=async _=>{p(null);try{const j=await Se("/api/telegram/link",{method:"PATCH",body:JSON.stringify(_)});if(!j.ok)throw new Error(`HTTP ${j.status}`);await f()}catch(j){p(j instanceof Error?j.message:String(j))}},w=r?.bot?.configured,S=r?.bot?.running,k=r?.link,N=!!k?.paired,E=k?.pairingCode??null,I=k?.control?.remoteControlEnabled??!0,A=k?.control?.progressMode??"final",T=m.useMemo(()=>{if(!k?.pairingExpiresAt)return null;const _=Date.parse(k.pairingExpiresAt);return Number.isFinite(_)?Math.max(0,_-Date.now()):null},[k?.pairingExpiresAt]);return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:i.jsx(T4,{className:"h-5 w-5"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h3",{className:"text-base font-semibold text-foreground",children:e("telegram.title")}),i.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e("telegram.description")})]}),i.jsx("button",{type:"button",onClick:()=>void f(),className:"inline-flex items-center gap-1.5 rounded-lg border border-border/60 bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",disabled:a,children:i.jsx(rt,{className:`h-3.5 w-3.5 ${a?"animate-spin":""}`})})]}),u&&i.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-500/20 bg-red-500/5 p-3 text-sm text-red-600 dark:text-red-400",children:[i.jsx(nn,{className:"h-4 w-4 flex-shrink-0"}),u]}),i.jsxs(ed,{title:e("telegram.botToken"),description:e("telegram.botTokenHelp"),children:[S&&r?.bot?.username&&i.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-lg border border-green-500/20 bg-green-500/5 px-3 py-2 text-xs text-green-700 dark:text-green-400",children:[i.jsx(qa,{className:"h-3.5 w-3.5"}),e("telegram.botRunning",{username:r.bot.username})]}),w&&!S&&i.jsx("div",{className:"mb-3 rounded-lg border border-amber-500/20 bg-amber-500/5 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:e("telegram.botStopped")}),!S&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"password",value:o,onChange:_=>l(_.target.value),placeholder:e("telegram.botTokenPlaceholder"),className:"flex-1 rounded-lg border border-border/60 bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors focus:border-primary/50"}),i.jsxs("button",{type:"button",onClick:()=>void h(),disabled:!o.trim()||c==="token",className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:[c==="token"&&i.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}),e(c==="token"?"telegram.saving":"telegram.saveToken")]})]}),S&&i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>void g(),disabled:c!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-border/60 bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-muted/50 disabled:opacity-50",children:[c==="stop"&&i.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}),e("telegram.stopBot")]}),i.jsxs("button",{type:"button",onClick:()=>void b(),disabled:c!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-500/10 disabled:opacity-50 dark:text-red-400",children:[i.jsx(Ur,{className:"h-3.5 w-3.5"}),e("telegram.removeToken")]})]})]}),S&&i.jsx(ed,{title:e("telegram.pairing.title"),description:e("telegram.pairing.description"),children:N?i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-green-500/20 bg-green-500/5 px-3 py-2 text-sm text-green-700 dark:text-green-400",children:[i.jsx(qa,{className:"h-4 w-4"}),e("telegram.pairing.verified"),k?.telegramUsername&&i.jsxs("span",{className:"ml-2 font-mono text-xs",children:["@",k.telegramUsername]})]}),i.jsxs("button",{type:"button",onClick:()=>void y(),disabled:c!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-500/10 disabled:opacity-50 dark:text-red-400",children:[i.jsx(Ur,{className:"h-3.5 w-3.5"}),e("telegram.linkedAccount.unpair")]})]}):i.jsxs("div",{className:"space-y-3",children:[E?i.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-primary/20 bg-primary/5 px-4 py-3",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:e("telegram.pairing.code")}),i.jsx("div",{className:"font-mono text-2xl font-semibold tracking-[0.3em] text-foreground",children:E}),T!==null&&i.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[Math.ceil(T/6e4)," min"]})]}),i.jsxs("button",{type:"button",onClick:()=>void x(),disabled:c==="pair",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/60 bg-background px-3 py-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:opacity-50",children:[c==="pair"?i.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}):null,e("telegram.pairing.regenerate")]})]}):i.jsxs("button",{type:"button",onClick:()=>void x(),disabled:c==="pair",className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:[c==="pair"&&i.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}),e("telegram.pairing.regenerate")]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:e("telegram.pairing.notPaired")})]})}),N&&k&&i.jsx(ed,{title:e("telegram.notifications.title"),description:e("telegram.notifications.description"),children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background px-3 py-2.5",children:[i.jsx("span",{className:"text-sm font-medium text-foreground",children:e("telegram.notifications.title")}),i.jsx("input",{type:"checkbox",checked:k.notificationsEnabled,onChange:_=>void v({notificationsEnabled:_.target.checked}),className:"h-4 w-4"})]}),i.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background px-3 py-2.5",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-foreground",children:e("telegram.bridge.title")}),i.jsx("div",{className:"text-xs text-muted-foreground",children:e("telegram.bridge.description")})]}),i.jsx("input",{type:"checkbox",checked:k.bridgeEnabled,onChange:_=>void v({bridgeEnabled:_.target.checked}),className:"h-4 w-4"})]})]})}),N&&k&&i.jsx(ed,{title:e("telegram.control.title"),description:e("telegram.control.description"),children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background px-3 py-2.5",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-foreground",children:e("telegram.control.enabled")}),i.jsx("div",{className:"text-xs text-muted-foreground",children:e("telegram.control.enabledDescription")})]}),i.jsx("input",{type:"checkbox",checked:I,onChange:_=>void v({controlEnabled:_.target.checked}),className:"h-4 w-4"})]}),i.jsxs("label",{className:"block rounded-lg border border-border/60 bg-background px-3 py-2.5",children:[i.jsx("div",{className:"text-sm font-medium text-foreground",children:e("telegram.control.progressMode")}),i.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:e("telegram.control.progressModeDescription")}),i.jsxs("select",{value:A,onChange:_=>void v({progressMode:_.target.value}),className:"w-full rounded-lg border border-border/60 bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors focus:border-primary/50",children:[i.jsx("option",{value:"final",children:e("telegram.control.progressModes.final")}),i.jsx("option",{value:"steps",children:e("telegram.control.progressModes.steps")}),i.jsx("option",{value:"all",children:e("telegram.control.progressModes.all")})]})]}),i.jsxs("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[i.jsxs("div",{children:[e("telegram.control.selectedProject"),": ",k.control?.selectedProjectName||"-"]}),i.jsxs("div",{children:[e("telegram.control.selectedProvider"),": ",k.control?.selectedProvider||"-"]}),i.jsxs("div",{children:[e("telegram.control.selectedModel"),": ",k.control?.selectedModel||"-"]}),i.jsxs("div",{children:[e("telegram.control.selectedWorkflow"),": ",k.control?.selectedWorkflowId||"-"]})]})]})})]})}function Dm({value:e}){const t=e||"unknown",r=t==="ok"||t==="available"||t==="configured"?"border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300":t==="missing"||t==="failed"?"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300":"border-border bg-muted text-muted-foreground";return i.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[11px] font-medium ${r}`,children:t})}function CB(){const[e,t]=m.useState(null),[r,n]=m.useState(!0),[a,s]=m.useState(null),[o,l]=m.useState(!1),c=m.useCallback(async(p=!1)=>{n(!0),s(null);try{const f=await Se(p?"/api/diagnostics/refresh":"/api/diagnostics",{method:p?"POST":"GET"});if(!f.ok)throw new Error(`HTTP ${f.status}`);t(await f.json())}catch(f){s(f instanceof Error?f.message:String(f))}finally{n(!1)}},[]);m.useEffect(()=>{c(!1)},[c]);const d=m.useMemo(()=>Object.entries(e?.providerHealth||{}),[e?.providerHealth]),u=async()=>{e&&(await navigator.clipboard.writeText(JSON.stringify(e,null,2)),l(!0),window.setTimeout(()=>l(!1),1600))};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Diagnostics"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Provider health, WebSocket state, notifications, active runs, and recent errors."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>void c(!0),disabled:r,className:"inline-flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:cursor-wait disabled:opacity-60",children:[i.jsx(rt,{className:`h-4 w-4 ${r?"animate-spin":""}`}),"Refresh"]}),i.jsxs("button",{type:"button",onClick:u,disabled:!e,className:"inline-flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:opacity-50",children:[i.jsx(Co,{className:"h-4 w-4"}),o?"Copied":"Copy bundle"]})]})]}),a&&i.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-700 dark:text-red-300",children:a}),i.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[i.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/20 p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(pa,{className:"h-4 w-4"}),"Runtime"]}),i.jsx(Dm,{value:e?.status||"loading"})]}),i.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["v",e?.version||"..."]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:e?.timestamp||"Waiting for diagnostics"})]}),i.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/20 p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(kn,{className:"h-4 w-4"}),"WebSocket"]}),i.jsx("p",{className:"mt-3 text-2xl font-semibold text-foreground",children:e?.websocket?.clients??0}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"active clients"})]}),i.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/20 p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(Eo,{className:"h-4 w-4"}),"Recent errors"]}),i.jsx("p",{className:"mt-3 text-2xl font-semibold text-foreground",children:e?.recentErrors?.length??0}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"redacted support bundle"})]})]}),i.jsxs("section",{className:"rounded-lg border border-border/70 bg-background",children:[i.jsx("div",{className:"border-b border-border/70 px-4 py-3 text-sm font-semibold text-foreground",children:"Providers"}),i.jsxs("div",{className:"divide-y divide-border/70",children:[d.map(([p,f])=>i.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 text-sm",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:p}),i.jsx("div",{className:"text-xs text-muted-foreground",children:f.checkedAt||"not checked"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Dm,{value:f.auth||"unknown"}),i.jsx(Dm,{value:f.status||"unknown"})]})]},p)),d.length===0&&i.jsx("div",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Provider health has not been collected yet."})]})]})]})}const NB="https://github.com/alicomert/pixcode";function U2({icon:e,title:t,description:r,ctaText:n="Available with Pixcode Pro"}){return i.jsx("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 p-5",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground",children:e}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground",children:t}),i.jsx(An,{className:"h-3 w-3 text-muted-foreground/60"})]}),i.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:r}),i.jsxs("a",{href:NB,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:underline",children:[n,i.jsx(bn,{className:"h-3 w-3"})]})]})]})})}const Om="https://github.com/alicomert/pixcode",EB="https://discord.gg/buxwujPNRE",TB="https://github.com/alicomert/pixcode",$2="https://github.com/alicomert/pixcode";function H2({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function AB({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function jB(e){if(!e)return"";const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<5)return"just now";if(t<60)return`${t}s ago`;const r=Math.floor(t/60);if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:new Date(e).toLocaleString()}function IB(){const{t:e}=Be("settings"),{updateAvailable:t,latestVersion:r,currentVersion:n,releaseInfo:a,checkStatus:s,lastCheckedAt:o,manualCheck:l,updateCheckPreferences:c,updatePreferences:d}=Gg("alicomert","pixcode"),u=a?.htmlUrl||`${Om}/releases`,[p,f]=m.useState(!1),[h,g]=m.useState(!1),b=async()=>{const x=await l();g(!x),f(!0),window.setTimeout(()=>{f(!1),g(!1)},2500)};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/90 shadow-sm",children:i.jsx(Hn,{className:"h-5 w-5 text-primary-foreground"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-base font-semibold text-foreground",children:"Pixcode"}),i.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:["v",n]}),t&&r&&i.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 rounded-full bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-600 transition-colors hover:bg-green-500/20 dark:text-green-400",children:[e("apiKeys.version.updateAvailable",{version:r}),i.jsx(bn,{className:"h-2.5 w-2.5"})]})]}),i.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"Open-source AI coding assistant interface"})]})]}),i.jsx("section",{className:"rounded-xl border border-border/60 bg-muted/20 p-4",children:i.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-end md:justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("label",{htmlFor:"update-check-frequency",className:"text-sm font-semibold text-foreground",children:e("about.updateCheckFrequency",{defaultValue:"Update check frequency"})}),i.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e("about.updateCheckFrequencyHint",{defaultValue:"Pixcode caches GitHub release checks locally so shared IPs do not hit GitHub rate limits."})}),i.jsx("select",{id:"update-check-frequency",value:c.frequency,onChange:x=>d({frequency:x.target.value}),className:"mt-3 w-full rounded-lg border border-border/70 bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors focus:border-primary md:max-w-xs",children:Hg.map(x=>i.jsx("option",{value:x.value,children:e(`about.updateCheckFrequencyOptions.${x.value}`,{defaultValue:x.label})},x.value))})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:b,disabled:s==="checking",className:"inline-flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3.5 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:cursor-wait disabled:opacity-60",children:[s==="checking"?i.jsx(Pt,{className:"h-4 w-4 animate-spin"}):p&&!t&&!h?i.jsx(qa,{className:"h-4 w-4 text-green-600 dark:text-green-400"}):i.jsx(rt,{className:"h-4 w-4"}),i.jsx("span",{children:s==="checking"?e("about.checkingForUpdate",{defaultValue:"Checking…"}):p?h?e("about.checkFailedShort",{defaultValue:"Check failed"}):t?e("about.updateFound",{defaultValue:"Update found"}):e("about.upToDate",{defaultValue:"Up to date"}):e("about.checkForUpdate",{defaultValue:"Check for updates"})})]}),i.jsxs("a",{href:Om,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3.5 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[i.jsx(H2,{className:"h-4 w-4"}),i.jsx(Ei,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:"Star on GitHub"})]})]})]})}),(o||s==="error")&&i.jsxs("p",{className:"-mt-3 text-[11px] text-muted-foreground/70",children:[o?e("about.lastChecked",{defaultValue:"Last checked {{when}}",when:jB(o)}):e("about.notCheckedYet",{defaultValue:"Update check has not completed yet"}),s==="error"&&i.jsxs("span",{className:"ml-2 text-red-500",children:["· ",e("about.checkFailed",{defaultValue:"check failed or delayed by rate limit"})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i.jsxs("a",{href:Om,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(H2,{className:"h-4 w-4"}),"GitHub"]}),i.jsxs("a",{href:EB,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(AB,{className:"h-4 w-4"}),"Discord"]}),i.jsxs("a",{href:TB,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(bn,{className:"h-3.5 w-3.5"}),"Docs"]}),i.jsxs("a",{href:$2,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(bn,{className:"h-3.5 w-3.5"}),"github.com/alicomert/pixcode"]})]}),i.jsxs("div",{className:"rounded-xl border border-primary/10 bg-primary/5 p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Try Pixcode Hosted"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Team collaboration, shared MCP configs, settings sync across environments, and managed infrastructure."}),i.jsxs("a",{href:$2,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:underline",children:["Learn more",i.jsx(bn,{className:"h-3 w-3"})]})]}),i.jsxs("div",{className:"space-y-4 border-t border-border/50 pt-6",children:[i.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Pixcode Pro Features"}),i.jsx(U2,{icon:i.jsx(Mg,{className:"h-5 w-5"}),title:"Sync Settings",description:"Keep your preferences, MCP configs, and theme in sync across all your environments."}),i.jsx(U2,{icon:i.jsx(vs,{className:"h-5 w-5"}),title:"Team Management",description:"Multiple users, role-based access, and shared projects for your team."})]}),i.jsx("div",{className:"border-t border-border/50 pt-4",children:i.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Licensed under AGPL-3.0"})})]})}const iT={theme:"light",fontSize:"14"},RB={allowedCommands:[],disallowedCommands:[],skipPermissions:!1},_B=["agents","hermes","access","appearance","git","api","notifications","plugins","mobile","telegram","diagnostics","about"],G2=e=>e==="tools"?"agents":_B.includes(e)?e:"agents",Ws=(e,t)=>{if(!e)return t;try{return JSON.parse(e)}catch{return t}},PB=e=>e==="acceptEdits"||e==="bypassPermissions"?e:"default",LB=()=>{const e=localStorage.getItem("codeEditorTheme");return e==="dark"||e==="light"?e:localStorage.getItem("theme")==="dark"?"dark":iT.theme},DB=()=>({theme:LB(),wordWrap:localStorage.getItem("codeEditorWordWrap")==="true",showMinimap:localStorage.getItem("codeEditorShowMinimap")!=="false",lineNumbers:localStorage.getItem("codeEditorLineNumbers")!=="false",fontSize:localStorage.getItem("codeEditorFontSize")??iT.fontSize}),OB=async e=>e.json(),V2=()=>({allowedTools:[],disallowedTools:[],skipPermissions:!1}),W2=()=>({...RB}),q2=()=>({allowPatterns:[],denyPatterns:[],skipPermissions:!1}),wl=()=>({channels:{inApp:!0,webPush:!1,telegram:!0,desktop:!0},events:{actionRequired:!0,stop:!0,error:!0,updates:!0}});function MB({isOpen:e,initialTab:t}){const{isDarkMode:r,toggleDarkMode:n}=ni(),a=m.useRef(null),[s,o]=m.useState(()=>G2(t)),[l,c]=m.useState(null),[d,u]=m.useState("name"),[p,f]=m.useState(()=>DB()),[h,g]=m.useState(()=>V2()),[b,x]=m.useState(()=>W2()),[y,v]=m.useState(()=>wl()),[w,S]=m.useState("default"),[k,N]=m.useState("default"),[E,I]=m.useState("default"),[A,T]=m.useState(()=>q2()),[_,j]=m.useState(!1),[R,C]=m.useState(""),{providerAuthStatus:D,checkProviderAuthStatus:U,refreshProviderAuthStatuses:F}=Gu(),W=m.useCallback(async()=>{try{const ne=Ws(localStorage.getItem("claude-settings"),{});g({allowedTools:ne.allowedTools||[],disallowedTools:ne.disallowedTools||[],skipPermissions:!!ne.skipPermissions}),u(ne.projectSortOrder==="date"?"date":"name");const be=Ws(localStorage.getItem("cursor-tools-settings"),{});x({allowedCommands:be.allowedCommands||[],disallowedCommands:be.disallowedCommands||[],skipPermissions:!!be.skipPermissions});const ue=Ws(localStorage.getItem("codex-settings"),{});S(PB(ue.permissionMode));const le=Ws(localStorage.getItem("gemini-settings"),{});N(le.permissionMode||"default");const me=Ws(localStorage.getItem("qwen-settings"),{});I(me.permissionMode||"default");const he=Ws(localStorage.getItem("opencode-settings"),{});T({allowPatterns:he.allowPatterns||[],denyPatterns:he.denyPatterns||[],skipPermissions:!!he.skipPermissions});try{const ve=await Se("/api/settings/notification-preferences");if(ve.ok){const ke=await OB(ve);if(ke.success&&ke.preferences)v(ke.preferences),Ls(ke.preferences);else{const Ie=wl();v(Ie),Ls(Ie)}}else{const ke=wl();v(ke),Ls(ke)}}catch{const ve=wl();v(ve),Ls(ve)}}catch(ne){console.error("Error loading settings:",ne),g(V2()),x(W2()),T(q2());const be=wl();v(be),Ls(be),S("default"),u("name")}},[]),K=m.useCallback(ne=>{C(ne),j(!0)},[]),L=m.useCallback(ne=>{ne!==0||!R||(c("success"),U(R,{force:!0}))},[U,R]),V=m.useCallback(async()=>{c(null);try{const ne=new Date().toISOString();if(localStorage.setItem("claude-settings",JSON.stringify({allowedTools:h.allowedTools,disallowedTools:h.disallowedTools,skipPermissions:h.skipPermissions,projectSortOrder:d,lastUpdated:ne})),localStorage.setItem("cursor-tools-settings",JSON.stringify({allowedCommands:b.allowedCommands,disallowedCommands:b.disallowedCommands,skipPermissions:b.skipPermissions,lastUpdated:ne})),localStorage.setItem("codex-settings",JSON.stringify({permissionMode:w,lastUpdated:ne})),localStorage.setItem("gemini-settings",JSON.stringify({permissionMode:k,lastUpdated:ne})),localStorage.setItem("qwen-settings",JSON.stringify({permissionMode:E,lastUpdated:ne})),localStorage.setItem("opencode-settings",JSON.stringify({allowPatterns:A.allowPatterns,denyPatterns:A.denyPatterns,skipPermissions:A.skipPermissions,lastUpdated:ne})),window.dispatchEvent(new CustomEvent("pixcode:settings-changed")),!(await Se("/api/settings/notification-preferences",{method:"PUT",body:JSON.stringify(y)})).ok)throw new Error("Failed to save notification preferences");Ls(y),c("success")}catch(ne){console.error("Error saving settings:",ne),c("error")}},[h.allowedTools,h.disallowedTools,h.skipPermissions,w,b.allowedCommands,b.disallowedCommands,b.skipPermissions,y,k,E,A.allowPatterns,A.denyPatterns,A.skipPermissions,d]),H=m.useCallback((ne,be)=>{f(ue=>({...ue,[ne]:be}))},[]);m.useEffect(()=>{e&&(o(G2(t)),W(),F())},[t,e,W,F]),m.useEffect(()=>{localStorage.setItem("codeEditorTheme",p.theme),localStorage.setItem("codeEditorWordWrap",String(p.wordWrap)),localStorage.setItem("codeEditorShowMinimap",String(p.showMinimap)),localStorage.setItem("codeEditorLineNumbers",String(p.lineNumbers)),localStorage.setItem("codeEditorFontSize",p.fontSize),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[p]);const z=m.useRef(null),te=m.useRef(!0);return m.useEffect(()=>{if(te.current){te.current=!1;return}return z.current!==null&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{V()},500),()=>{z.current!==null&&window.clearTimeout(z.current)}},[V]),m.useEffect(()=>{if(l===null)return;const ne=window.setTimeout(()=>c(null),2e3);return()=>window.clearTimeout(ne)},[l]),m.useEffect(()=>{e&&(te.current=!0)},[e]),m.useEffect(()=>()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null),z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),{activeTab:s,setActiveTab:o,isDarkMode:r,toggleDarkMode:n,saveStatus:l,projectSortOrder:d,setProjectSortOrder:u,codeEditorSettings:p,updateCodeEditorSetting:H,claudePermissions:h,setClaudePermissions:g,cursorPermissions:b,setCursorPermissions:x,notificationPreferences:y,setNotificationPreferences:v,codexPermissionMode:w,setCodexPermissionMode:S,providerAuthStatus:D,refreshProviderAuthStatuses:F,checkProviderAuthStatus:U,geminiPermissionMode:k,setGeminiPermissionMode:N,qwenPermissionMode:E,setQwenPermissionMode:I,opencodePermissions:A,setOpencodePermissions:T,openLoginForProvider:K,showLoginModal:_,setShowLoginModal:j,loginProvider:R,handleLoginComplete:L}}function FB(e){const t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let s=0;s<n.length;++s)a[s]=n.charCodeAt(s);return a}function zB(){const[e,t]=m.useState(()=>typeof window>"u"||!("Notification"in window)||!("serviceWorker"in navigator)?"unsupported":Notification.permission),[r,n]=m.useState(!1),[a,s]=m.useState(!1),[o,l]=m.useState(null);m.useEffect(()=>{e!=="unsupported"&&navigator.serviceWorker.ready.then(u=>{u.pushManager.getSubscription().then(p=>{n(p!==null)})}).catch(()=>{})},[e]);const c=m.useCallback(async()=>{if(e!=="unsupported"){s(!0),l(null);try{const u=await Notification.requestPermission();if(t(u),u!=="granted")return;const p=await Se("/api/settings/push/vapid-public-key");if(!p.ok)throw new Error(`VAPID key request failed (${p.status})`);const{publicKey:f}=await p.json();if(typeof f!="string"||!f)throw new Error("Missing VAPID public key");const h=await navigator.serviceWorker.ready;await h.update().catch(()=>{});const b=(await h.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:FB(f).buffer})).toJSON(),x=await Se("/api/settings/push/subscribe",{method:"POST",body:JSON.stringify({endpoint:b.endpoint,keys:b.keys})});if(!x.ok)throw new Error(`Push subscription save failed (${x.status})`);n(!0)}catch(u){console.error("Push subscribe failed:",u),l(u instanceof Error?u.message:"Push subscribe failed")}finally{s(!1)}}},[e]),d=m.useCallback(async()=>{s(!0),l(null);try{const p=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(p){const f=p.endpoint;await p.unsubscribe(),await Se("/api/settings/push/unsubscribe",{method:"POST",body:JSON.stringify({endpoint:f})})}n(!1)}catch(u){console.error("Push unsubscribe failed:",u),l(u instanceof Error?u.message:"Push unsubscribe failed")}finally{s(!1)}},[]);return{permission:e,isSubscribed:r,isLoading:a,error:o,subscribe:c,unsubscribe:d}}function BB({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{t:a}=Be("settings"),{activeTab:s,setActiveTab:o,saveStatus:l,projectSortOrder:c,setProjectSortOrder:d,codeEditorSettings:u,updateCodeEditorSetting:p,claudePermissions:f,setClaudePermissions:h,notificationPreferences:g,setNotificationPreferences:b,cursorPermissions:x,setCursorPermissions:y,codexPermissionMode:v,setCodexPermissionMode:w,providerAuthStatus:S,checkProviderAuthStatus:k,refreshProviderAuthStatuses:N,geminiPermissionMode:E,setGeminiPermissionMode:I,qwenPermissionMode:A,setQwenPermissionMode:T,opencodePermissions:_,setOpencodePermissions:j,openLoginForProvider:R,showLoginModal:C,setShowLoginModal:D,loginProvider:U,handleLoginComplete:F}=MB({isOpen:e,initialTab:n}),{permission:W,isSubscribed:K,isLoading:L,error:V,subscribe:H,unsubscribe:z}=zB(),te=async()=>{await H(),b({...g,channels:{...g.channels,webPush:!0}})},ne=async()=>{await z(),b({...g,channels:{...g.channels,webPush:!1}})};if(!e)return null;const be=!!(U&&S[U].authenticated);return i.jsxs("div",{className:"modal-backdrop fixed inset-0 z-[9999] flex items-center justify-center bg-background/80 backdrop-blur-sm md:p-4",children:[i.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden border border-border bg-background shadow-2xl md:h-[90vh] md:max-w-4xl md:rounded-xl",children:[i.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-border px-4 py-3 md:px-5",children:[i.jsx("h2",{className:"text-base font-semibold text-foreground",children:a("title")}),i.jsxs("div",{className:"flex items-center gap-2",children:[l==="success"&&i.jsx("span",{className:"animate-in fade-in text-xs text-muted-foreground",children:a("saveStatus.success")}),i.jsx(Ne,{variant:"ghost",size:"sm",onClick:t,className:"h-10 w-10 touch-manipulation p-0 text-muted-foreground hover:text-foreground active:bg-accent/50",children:i.jsx(St,{className:"h-5 w-5"})})]})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[i.jsx(FF,{activeTab:s,onChange:o}),i.jsx("main",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"settings-content-enter space-y-6 p-4 pb-safe-area-inset-bottom md:space-y-8 md:p-6",children:[s==="appearance"&&i.jsx(iB,{projectSortOrder:c,onProjectSortOrderChange:d,codeEditorSettings:u,onCodeEditorThemeChange:ue=>p("theme",ue),onCodeEditorWordWrapChange:ue=>p("wordWrap",ue),onCodeEditorShowMinimapChange:ue=>p("showMinimap",ue),onCodeEditorLineNumbersChange:ue=>p("lineNumbers",ue),onCodeEditorFontSizeChange:ue=>p("fontSize",ue)}),s==="git"&&i.jsx(pB,{}),s==="access"&&i.jsx(cz,{}),s==="agents"&&i.jsx(aB,{providerAuthStatus:S,onProviderLogin:R,onRefreshProviderAuth:ue=>k(ue,{force:!0}),onRefreshAllProviderAuth:()=>N(void 0,{force:!0}),claudePermissions:f,onClaudePermissionsChange:h,cursorPermissions:x,onCursorPermissionsChange:y,codexPermissionMode:v,onCodexPermissionModeChange:w,geminiPermissionMode:E,onGeminiPermissionModeChange:I,qwenPermissionMode:A,onQwenPermissionModeChange:T,opencodePermissions:_,onOpencodePermissionsChange:j,projects:r}),s==="hermes"&&i.jsx(fB,{onClose:t}),s==="notifications"&&i.jsx(gB,{notificationPreferences:g,onNotificationPreferencesChange:b,pushPermission:W,isPushSubscribed:K,isPushLoading:L,pushError:V,onEnablePush:te,onDisablePush:ne}),s==="api"&&i.jsx(dB,{}),s==="plugins"&&i.jsx(wB,{}),s==="mobile"&&i.jsx(kB,{}),s==="telegram"&&i.jsx(SB,{}),s==="diagnostics"&&i.jsx(CB,{}),s==="about"&&i.jsx(IB,{})]},s)})]})]}),i.jsx(U4,{isOpen:C,onClose:()=>D(!1),provider:U||"claude",onComplete:F,isAuthenticated:be},U||"claude")]})}const bu="pixcode:issue-progress",UB=[{issue:"#6",title:"Strict orchestration handoff with compact packets",state:"completed",source:"v1.37 tracker"},{issue:"#7",title:"Reliable notification center with browser, desktop, and Telegram fallback",state:"completed",source:"v1.37 tracker"},{issue:"#8",title:"Focused orchestration execution dashboard",state:"completed",source:"v1.37 tracker"},{issue:"#9",title:"Chat hydration and realtime message visibility fixes",state:"completed",source:"v1.37 tracker"},{issue:"#10",title:"Multi-project worker slots from the chat prompt",state:"completed",source:"v1.37 tracker"},{issue:"#11",title:"Optional Taskmaster setup during first account setup",state:"completed",source:"v1.37 tracker"},{issue:"#12",title:"Taskmaster execution across CLI providers and Telegram",state:"completed",source:"v1.37 tracker"},{issue:"#13",title:"Update progress mapped to GitHub issues and tasks",state:"completed",source:"v1.37 tracker"}],sT=new RegExp(`<!--\\s*${bu}\\s*-->[\\s\\S]*?<!--\\s*/${bu}\\s*-->`,"i");function $B(e){const t=e.match(sT);return t?t[0].replace(new RegExp(`<!--\\s*${bu}\\s*-->`,"i"),"").replace(new RegExp(`<!--\\s*/${bu}\\s*-->`,"i"),""):e}function HB(e){return e.replace(sT,"").trim()}function K2(e,t){const r=e.trim().toLowerCase(),n=t.toLowerCase();return r==="x"||/\b(done|fixed|complete|completed|shipped)\b/.test(n)?"completed":r==="~"||r==="-"||/\b(in progress|working|started)\b/.test(n)?"in_progress":"pending"}function Y2(e,t){if(!e)return`Task ${t+1}`;const r=e.trim();return/^gh-\d+$/i.test(r)?`#${r.slice(3)}`:r.startsWith("#")?r:`#${r}`}function Z2(e){return e.replace(/\s+-\s+(done|fixed|complete|completed|in progress|pending|shipped)\s*$/i,"").replace(/\s+\((done|fixed|complete|completed|in progress|pending|shipped)\)\s*$/i,"").trim()}function GB(e){if(!e.trim())return[];const t=$B(e),r=[];for(const n of t.split(`
|
|
263
263
|
`)){const a=n.trim();if(!a||a.startsWith("<!--"))continue;const s=a.match(/^[*-]\s+\[([xX ~-])\]\s+(?:(#\d+|GH-\d+)\s*[:\-]?\s*)?(.+)$/);if(s){const l=Z2(s[3]);if(!l)continue;r.push({issue:Y2(s[2],r.length),title:l,state:K2(s[1],l),source:a});continue}const o=a.match(/^[*-]\s+(#\d+|GH-\d+)\s*[:\-]\s*(.+)$/i);if(o){const l=Z2(o[2]);if(!l)continue;r.push({issue:Y2(o[1],r.length),title:l,state:K2("",l),source:a})}}return r}const VB={completed:"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-200",in_progress:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200",pending:"border-gray-200 bg-gray-50 text-gray-600 dark:border-gray-700 dark:bg-gray-900/40 dark:text-gray-300"},WB={completed:"Done",in_progress:"Active",pending:"Queued"};function qB(e,t){const r=GB(e);return r.length>0?r:t?.startsWith("1.37")?UB:[]}function KB({releaseBody:e,version:t}){const{t:r}=Be("common"),n=m.useMemo(()=>qB(e,t),[e,t]);if(n.length===0)return null;const a=n.filter(o=>o.state==="completed").length,s=Math.round(a/n.length*100);return i.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900/30",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:r("versionUpdate.issueProgress.title",{defaultValue:"Issue Progress"})}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r("versionUpdate.issueProgress.subtitle",{defaultValue:"Release work mapped to GitHub issues and tasks."})})]}),i.jsxs("div",{className:"shrink-0 text-right",children:[i.jsxs("div",{className:"font-mono text-sm font-semibold text-gray-900 dark:text-white",children:[a,"/",n.length]}),i.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s,"%"]})]})]}),i.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800",children:i.jsx("div",{className:"h-full rounded-full bg-emerald-500 transition-all duration-500",style:{width:`${s}%`}})}),i.jsx("div",{className:"grid gap-2",children:n.map(o=>i.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 dark:border-gray-700 dark:bg-gray-800/60",children:[i.jsx("div",{className:"min-w-0",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-xs font-semibold text-gray-500 dark:text-gray-400",children:o.issue}),i.jsx("span",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:o.title})]})}),i.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[11px] font-medium ${VB[o.state]}`,children:WB[o.state]})]},`${o.issue}-${o.title}`))})]})}const X2=6e4,YB=1500;function ZB({isOpen:e,onClose:t,releaseInfo:r,currentVersion:n,latestVersion:a,isUpdateAvailable:s=!0}){const{t:o}=Be("common"),l=o("versionUpdate.pixcodeUpgradeCommand"),[c,d]=m.useState(!1),[u,p]=m.useState(""),[f,h]=m.useState(""),[g,b]=m.useState(null),[x,y]=m.useState("idle"),[v,w]=m.useState(null),S=m.useRef(null),k=m.useRef(null);x0(k,"modal");const N=!!(s&&a);m.useEffect(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight)},[u]),m.useEffect(()=>{},[g]);const E=m.useCallback(C=>{p(D=>D+C)},[]);m.useEffect(()=>{e&&(p(""),h(""),b(null),y("idle"),w(null))},[n,e,a]),m.useEffect(()=>{if(!e)return;let C=!1;return Se("/api/system/update-state",{cache:"no-store"}).then(async D=>D.ok?D.json():null).then(D=>{if(C)return;const U=D?.state?.pendingRestart;if(U?.toVersion){w(U.toVersion),y("ready"),p(`Update to ${U.toVersion} is ready. Restart when convenient to apply it.
|
|
264
|
-
`);return}const F=D?.state?.lastAppliedUpdate;F?.toVersion===n&&p(`Pixcode was updated to ${F.toVersion}.
|
|
265
|
-
`)}).catch(()=>{}),()=>{C=!0}},[n,e]);const I=m.useCallback(async C=>{const D=Date.now()+X2;for(await new Promise(U=>setTimeout(U,1e3));Date.now()<D;){try{const U=await fetch("/health",{cache:"no-store"});if(U.ok){const F=await U.json();if(!C||F?.version===C)return!0}}catch{}await new Promise(U=>setTimeout(U,YB))}return!1},[]),A=m.useCallback(async()=>{y("restarting"),E(`
|
|
264
|
+
`);return}const F=D?.state?.lastAppliedUpdate;F?.toVersion===n&&!s&&p(`Pixcode was updated to ${F.toVersion}.
|
|
265
|
+
`)}).catch(()=>{}),()=>{C=!0}},[n,e,s]);const I=m.useCallback(async C=>{const D=Date.now()+X2;for(await new Promise(U=>setTimeout(U,1e3));Date.now()<D;){try{const U=await fetch("/health",{cache:"no-store"});if(U.ok){const F=await U.json();if(!C||F?.version===C)return!0}}catch{}await new Promise(U=>setTimeout(U,YB))}return!1},[]),A=m.useCallback(async()=>{y("restarting"),E(`
|
|
266
266
|
Restarting server...
|
|
267
267
|
`);try{const D=await Se("/api/system/restart",{method:"POST"});if(!D.ok){const U=await D.json().catch(()=>({}));throw new Error(U.error||`Restart request failed (HTTP ${D.status})`)}}catch(D){E(`
|
|
268
268
|
⚠️ Restart request failed: ${D.message}
|
package/dist/index.html
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
<!-- Prevent zoom on iOS -->
|
|
37
37
|
<meta name="format-detection" content="telephone=no" />
|
|
38
|
-
<script type="module" crossorigin src="/assets/index
|
|
38
|
+
<script type="module" crossorigin src="/assets/index--kNEhygZ.js"></script>
|
|
39
39
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-DB6V5Fl1.js">
|
|
40
40
|
<link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CIYNS698.js">
|
|
41
41
|
<link rel="modulepreload" crossorigin href="/assets/vendor-xterm-C7tpxJl7.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixelbyte-software/pixcode",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.8",
|
|
4
4
|
"description": "Self-hosted AI coding agent control room for Claude Code, Cursor CLI, OpenAI Codex, Gemini CLI, Qwen Code, and OpenCode with chat, files, shell, Git, orchestration, API keys, Telegram, MCP, plugins, themes, and desktop/server deployment.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist-server/server/index.js",
|