@pixelbyte-software/pixcode 1.53.13 → 1.53.14

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 _N,R as LN,o as PN,_ as P6,b as D6,T as DN,P as ON,S as sc,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 xD=[["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"}]],vD=Nt("workflow",xD),x4=o4,yD=S7,Kw=v7,wD=d7,v4=f7,kD=s4,Fr=d4,Tg=i8,ma=o8,SD=c8,Fn=b7,ha=s4,Hd=w7,y4=m7,Iu=e8,_u=n8,Ag=N7,rt=l4,Rt=l4,Lu=j7,CD=T7,ND=mL,ua=P8,cn=O8,Wt=Q7,Oa=Z7,w4=eL,Rn=_L,lc=h4,ED=h4,Gd=U7,co=u8,To=u4,Ys=g8,uo=E8,En=A8,Un=W8,Er=$8,gi=G8,TD=xL,AD=Q8,k4=iL,jg=EL,jD=I7,RD=H7,ID=VL,S4=m4,Yh=fL,_D=K8,Zh=m4,C4=yL,Ht=kL,An=qL,N4=R8,Ma=cL,wt=f4,Xh=f4,Pu=zL,Rg=M7,LD=D7,Vd=L7,PD=_8,Tr=c4,DD=c4,OD=YL,as=XL,Ig=q7,Ul=V7,_g=h8,cc=B8,Lg=F8,lr=Z8,E4=u4,Du=p4,MD=p4,T4=rL,gr=oL,A4=uL,Ou=k8,j4=HL,R4=CL,Ao=RL,FD=AL,Ot=x8,Qh=s7,dc=C8,cr=DL,_a=ML,I4=UL,On=y8,Pg=z7,zD=oP,Ti=mP,Dg=b4,BD=b4,_n=KP,kd=ZP,Mu=QP,ws=iP,ks=cP,UD=uP,hl=fP,Zs=bP,Yw=yP,fl=kP,Zo=EP,$D=AP,_4=BP,Jh=RP,Wr=PP,Xo=_P,Zw=OP,Qo=FP,ef=$P,HD=GP,tf=WP,Hs=nD,gl=aD,Xa=sD,Ss=lD,GD=dD,nf=pD,VD=fD,Jo=bD,Ar=vD,Fu=CP,WD=eD,qD=[{type:"key",id:"ctrl-c",label:"Ctrl-C",sequence:""},{type:"key",id:"ctrl-d",label:"Ctrl-D",sequence:""},{type:"key",id:"ctrl-l",label:"Ctrl-L",sequence:"\f"},{type:"key",id:"ctrl-z",label:"Ctrl-Z",sequence:""},{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"enter",label:"Enter",sequence:"\r"},{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"}],KD={up:yD,down:x4,left:wD,right:v4},el=e=>e.preventDefault(),Xw="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",YD="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",Dp="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 Qw({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=Fe("settings"),[s,o]=m.useState(!1),[l,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useCallback(b=>{$d(e.current,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 v=b.toLowerCase().charCodeAt(0);v>=97&&v<=122&&(x=String.fromCharCode(v-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 ${r} z-40 px-2 pb-[max(env(safe-area-inset-bottom),0px)] 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:el,onClick:()=>{h()},disabled:!n,className:Dp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(co,{className:"h-4 w-4"})}),qD.map(b=>{if(b.type==="modifier"){const x=b.modifier==="ctrl"?s:l,v=b.modifier==="ctrl"?()=>o(y=>!y):()=>c(y=>!y);return i.jsx("button",{type:"button",onPointerDown:el,onClick:v,disabled:!n,className:x?YD:Xw,children:b.label},b.id)}if(b.type==="arrow"){const x=KD[b.icon];return i.jsx("button",{type:"button",onPointerDown:el,onClick:()=>p(b.sequence),disabled:!n,className:Dp,children:i.jsx(x,{className:"h-4 w-4"})},b.id)}return i.jsx("button",{type:"button",onPointerDown:el,onClick:()=>g(b.sequence),disabled:!n,className:Xw,children:b.label},b.id)}),i.jsx("button",{type:"button",onPointerDown:el,onClick:f,disabled:!n,className:Dp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(kD,{className:"h-4 w-4"})})]})})}function ZD({tabId:e,selectedProject:t=null,selectedSession:n=null,initialCommand:r=null,isPlainShell:a=!1,onProcessComplete:s=null,minimal:o=!1,autoConnect:l=!1,forceNewSession:c=!1,startupInput:d=null,permissionOverride:u=null,provider:p=null,isActive:f=!0,onClose:h=null}){const{t:g}=Fe("chat"),[b,x]=m.useState(!1),[v,y]=m.useState(null),w=m.useRef(null),k=m.useRef(null),{terminalContainerRef:S,terminalRef:C,wsRef:A,isConnected:R,isInitialized:j,isConnecting:T,authUrl:L,authUrlVersion:E,connectToShell:I,disconnectFromShell:N,openAuthUrlInBrowser:O,copyAuthUrlToClipboard:B}=e7({tabId:e,selectedProject:t,selectedSession:n,initialCommand:r,isPlainShell:a,minimal:o,autoConnect:l,forceNewSession:c,startupInput:d,permissionOverride:u,provider:p,isRestarting:b,onProcessComplete:s,onOutputRef:k}),F=m.useCallback(()=>{const Se=C.current;if(!Se)return;const Ne=Se.buffer.active,je=Ne.baseY+Ne.cursorY,M=Math.min(Ne.baseY+Ne.length-1,je+10),ue=Math.max(0,je-E_),de=[];for(let ce=ue;ce<=M;ce++){const te=Ne.getLine(ce);te&&de.push(te.translateToString().trimEnd())}let V=-1;for(let ce=de.length-1;ce>=0;ce--)if(/esc to cancel/i.test(de[ce])||/enter to select/i.test(de[ce])){V=ce;break}if(V===-1){y(null);return}const K=new Map,ne=Math.max(0,V-T_);for(let ce=V-1;ce>=ne;ce--){const te=de[ce].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(te){const Ce=te[1],pe=te[2].trim();parseInt(Ce,10)<=A_&&pe.length>0&&!K.has(Ce)&&K.set(Ce,pe)}}const ee=[];for(let ce=1;ce<=K.size&&K.has(String(ce));ce++)ee.push({number:String(ce),label:K.get(String(ce))});y(ee.length>=j_?ee:null)},[C]),Y=m.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(F,N_)},[F]);m.useEffect(()=>{k.current=Y},[Y]),m.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),m.useEffect(()=>{R||(w.current&&(clearTimeout(w.current),w.current=null),y(null))},[R]),m.useEffect(()=>{if(!f||!j||!R)return;const Se=()=>{C.current?.focus()},Ne=window.requestAnimationFrame(Se),je=window.setTimeout(Se,0);return()=>{window.cancelAnimationFrame(Ne),window.clearTimeout(je)}},[f,R,j,C]);const X=m.useCallback(Se=>{$d(A.current,Se)},[A]),P=m.useMemo(()=>q_(n),[n]),U=m.useMemo(()=>p||(n?.__provider?n.__provider:window.localStorage.getItem("selected-provider")||"claude"),[p,n?.__provider]),H=Dn[U]??"Claude Code",z=m.useMemo(()=>P?P.slice(0,30):null,[P]),J=m.useMemo(()=>P?P.slice(0,50):null,[P]),ie=m.useCallback(()=>{x(!0),window.setTimeout(()=>{x(!1)},S_)},[]),fe=m.useCallback(()=>{N(),h?.()},[N,h]);if(!t)return i.jsx(n7,{title:g("shell.selectProject.title"),description:g("shell.selectProject.description")});if(o)return i.jsxs(i.Fragment,{children:[i.jsx(a7,{terminalContainerRef:S,authUrl:L,authUrlVersion:E,initialCommand:r,isConnected:R,openAuthUrlInBrowser:O,copyAuthUrlToClipboard:B}),i.jsx(Qw,{wsRef:A,terminalRef:C,isConnected:R,bottomOffset:"bottom-0"})]});const le=a?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:t.displayName}):n?g("shell.resumeSession",{displayName:J}):g("shell.startProviderSession",{provider:H,defaultValue:"Start a new {{provider}} session"}),se=a?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:t.displayName}):g("shell.startProviderCli",{provider:H,projectName:t.displayName,defaultValue:"Starting {{provider}} in {{projectName}}"}),ge=j?T?"connecting":R?null:"connect":"loading",me=ge==="connecting"?se:le;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(r7,{isConnected:R,isInitialized:j,isRestarting:b,hasSession:!!n,sessionDisplayNameShort:z,onDisconnect:fe,onRestart:ie,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||R}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2 pb-16 md:pb-2",children:[i.jsx("div",{ref:S,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),ge&&i.jsx(t7,{mode:ge,description:me,loadingLabel:g("shell.loading"),connectLabel:g("shell.actions.connect"),connectTitle:g("shell.actions.connectTitle"),connectingLabel:g("shell.connecting"),onConnect:I}),v&&R&&i.jsx("div",{className:"absolute inset-x-0 bottom-14 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm md:bottom-0",onMouseDown:Se=>Se.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.map(Se=>i.jsxs("button",{type:"button",onClick:()=>{X(`${Se.number}\r`),y(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:`${Se.number}. ${Se.label}`,children:[Se.number,". ",Se.label]},Se.number)),i.jsx("button",{type:"button",onClick:()=>{X("\x1B"),y(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(Qw,{wsRef:A,terminalRef:C,isConnected:R})]})}function XD({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:n=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)"})]}),n&&i.jsx("button",{onClick:n,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 $l({project:e=null,session:t=null,command:n=null,isPlainShell:r=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,permissionOverride:b=null,provider:x=null,tabId:v=null}){const[y,w]=m.useState(!1),k=m.useMemo(()=>v||`tab_${crypto.randomUUID()}`,[v]),S=r!==null?r:n!==null,C=m.useCallback(A=>{w(!0),o?.(A)},[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:y,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(ZD,{tabId:k,selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:S,isActive:a,onProcessComplete:C,minimal:f,autoConnect:f?!0:s,forceNewSession:h,startupInput:g,permissionOverride:b,provider:x,onClose:l})})]}):i.jsx(XD,{className:d})}const JD=(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"),eO={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 Jw({active:e,children:t,onClick:n}){return i.jsx("button",{onClick:n,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 tO({provider:e}){const[t,n]=m.useState(""),[r,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 Ee(`/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"),n("")}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=>n(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:r||!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:r?i.jsx(Rt,{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(Wt,{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 nO({provider:e,onSaved:t}){const n=eO[e],[r,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 Ee("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const v=x.data?.[e];v?.baseUrl&&o(v.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=r.trim();if(g){c(!0),f(null),u("idle");try{const b=await Ee(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:n.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 n?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(MD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.keyLabel}),i.jsxs("a",{href:n.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 ",n.keyConsoleLabel,i.jsx(Fn,{className:"h-3 w-3"})]})]})]}),n.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:n.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:r,onChange:g=>a(g.target.value),placeholder:n.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."]})]}),n.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:n.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||!r.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(Rt,{className:"h-4 w-4 animate-spin"}):i.jsx(Wt,{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 L4({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Fe("common"),l=n!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,n,l]);const u=m.useMemo(()=>`${Dn[n]??n} Login`,[n]);if(!e)return null;const p=JD(n,a),f=h=>r?.(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(wt,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(Jw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(Jw,{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($l,{project:d_,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(tO,{provider:n})})]}):i.jsx(nO,{provider:n,onSaved:()=>f(0)})})]})})}const rO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),aO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},iO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},sO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),oO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa(),n=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:n,alt:"OpenCode",className:e})},lO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function nn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(iO,{className:t}):e==="codex"?i.jsx(aO,{className:t}):e==="gemini"?i.jsx(sO,{className:t}):e==="qwen"?i.jsx(lO,{className:t}):e==="opencode"?i.jsx(oO,{className:t}):i.jsx(rO,{className:t})}function cO({provider:e,title:t,status:n,connectedClassName:r,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=n.authenticated?r:"border-border bg-card",c=n.loading?"Checking...":n.authenticated?n.email||"Connected":n.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(nn,{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,n.authenticated&&i.jsx(Wt,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!n.authenticated&&!n.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 dO=[{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 ek({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:dO.map(n=>i.jsx(cO,{provider:n.provider,title:n.title,status:e[n.provider],connectedClassName:n.connectedClassName,iconContainerClassName:n.iconContainerClassName,loginButtonClassName:n.loginButtonClassName,onLogin:()=>t(n.provider)},n.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 uO({gitName:e,gitEmail:t,isSubmitting:n,onGitNameChange:r,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(_n,{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(OD,{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=>r(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:n}),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(PD,{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:n}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const tk=[{title:"Git Configuration",icon:_n,required:!0},{title:"Connect Agents",icon:y4,required:!1}];function pO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:tk.map((t,n)=>{const r=n<e,a=n===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 ${r?"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:r?i.jsx(Wt,{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"})]})]}),n<tk.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${r?"bg-green-500":"bg-border"}`})]},t.title)})})})}const nk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,rk=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function mO({onComplete:e}){const[t,n]=m.useState(0),[r,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}=Ru(),x=m.useRef(void 0),v=m.useCallback(async()=>{try{const R=await Ee("/api/user/git-config");if(!R.ok)return;const j=await R.json();j.gitName&&a(j.gitName),j.gitEmail&&o(j.gitEmail)}catch(R){console.error("Error loading git config:",R)}},[]);m.useEffect(()=>{v(),b()},[v,b]),m.useEffect(()=>{const R=x.current;x.current=p,R!=null&&p===null&&b()},[p,b]);const y=R=>{f(R)},w=R=>{R===0&&p&&g(p)},k=async()=>{if(u(""),t!==0){n(R=>R+1);return}if(!r.trim()||!s.trim()){u("Both git name and email are required.");return}if(!nk.test(s)){u("Please enter a valid email address.");return}c(!0);try{const R=await Ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:s})});if(!R.ok){const j=await rk(R,"Failed to save git configuration");throw new Error(j)}n(j=>j+1)}catch(R){u(R instanceof Error?R.message:"Failed to save git configuration")}finally{c(!1)}},S=()=>{u(""),n(R=>R-1)},C=async()=>{c(!0),u("");try{const R=await Ee("/api/user/complete-onboarding",{method:"POST"});if(!R.ok){const j=await rk(R,"Failed to complete onboarding");throw new Error(j)}await e?.()}catch(R){u(R instanceof Error?R.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&s.trim()&&nk.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(pO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(uO,{gitName:r,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(ek,{providerStatuses:h,onOpenProviderLogin:y}):i.jsx(ek,{providerStatuses:h,onOpenProviderLogin:y}),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:S,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(Tg,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<1?i.jsx("button",{onClick:k,disabled:!A||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(Rt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(ma,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:C,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(Rt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Wt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(L4,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:w})]})}const hO=["0s","0.1s","0.2s"];function fO(){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(Tr,{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:hO.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 P4({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 Vi({id:e,label:t,value:n,onChange:r,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:n,onChange:d=>r(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 D4({title:e,description:t,children:n,footerText:r,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(Tr,{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})]}),n,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:r})}),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 gO={username:"",password:""};function bO(){const{t:e}=Fe("auth"),{login:t}=oc(),[n,r]=m.useState(gO),[a,s]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{r(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),s(""),!n.username.trim()||!n.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(n.username.trim(),n.password);p.success||s(p.error),l(!1)},[n.password,n.username,t,e]);return i.jsx(D4,{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(Vi,{id:"username",label:e("login.username"),value:n.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(Vi,{id:"password",label:e("login.password"),value:n.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx(P4,{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 xO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function vO(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 yO(){const{register:e}=oc(),[t,n]=m.useState(xO),[r,a]=m.useState(""),[s,o]=m.useState(!1),l=m.useCallback((d,u)=>{n(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=vO(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(D4,{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(Vi,{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(Vi,{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(Vi,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(Vi,{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(Vi,{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(P4,{errorMessage:r}),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 wO({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=oc();return n?i.jsx(fO,{}):r?i.jsx(yO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(mO,{onComplete:s}):i.jsx(bO,{})}const O4=m.createContext(null),M4=()=>{const e=m.useContext(O4);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},kO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},SO=()=>{const e=m.useRef(null),t=m.useRef(!1),n=m.useRef(!1),[r,a]=m.useState(null),[s,o]=m.useState(!1),l=m.useRef(null),{token:c}=oc(),d=m.useCallback(()=>{if(!t.current)try{const f=kO(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,n.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),n.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:r,isConnected:s}),[u,r,s])},CO=({children:e})=>{const t=SO();return i.jsx(O4.Provider,{value:t,children:e})},F4=m.createContext(null);function uc(){const e=m.useContext(F4);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function NO({children:e}){const{user:t,token:n,isLoading:r}=oc(),[a,s]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&n),p=m.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await Ee("/api/plugins");if(x.ok){const v=await x.json();s(v.plugins||[]),d(null)}else{let v=`Failed to fetch plugins (${x.status})`;try{const y=await x.json();v=y.details||y.error||v}catch{v=x.statusText||v}d(v)}}catch(x){const v=x instanceof Error?x.message:"Failed to fetch plugins";d(v),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{r||p()},[r,p]);const f=m.useCallback(async x=>{try{const v=await Ee("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Install failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const v=await Ee(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Uninstall failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const v=await Ee(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Update failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Update failed"}}},[p]),b=m.useCallback(async(x,v)=>{try{const y=await Ee(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:v})});if(!y.ok){let w=`Toggle failed (${y.status})`;try{const k=await y.json();w=k.details||k.error||w}catch{w=y.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Toggle failed"}}},[p]);return i.jsx(F4.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const ak=e=>typeof window>"u"?!1:window.innerWidth<e,ik=()=>{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 Og(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,s]=m.useState(()=>n?ak(t):!1),[o,l]=m.useState(()=>r?ik():!1);return m.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{s(ak(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,n]),m.useEffect(()=>{if(!r||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(ik())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[r]),{isMobile:a,isPWA:o}}const Mg="pixcode.updateCheck.preferences",rf="pixcode:update-check-settings-changed",Fg=[{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}],af={frequency:"30m"};function sk(e){return Fg.find(t=>t.value===e.frequency)?.intervalMs??null}function z4(e){if(!e||typeof e!="object")return af;const t=e.frequency;return Fg.some(n=>n.value===t)?{frequency:t}:af}function ok(){try{const e=localStorage.getItem(Mg);return z4(e?JSON.parse(e):null)}catch{return af}}function EO(e){const t=z4(e);localStorage.setItem(Mg,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(rf,{detail:t}))}const Op=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let a=0;a<Math.max(n.length,r.length);a++){const s=n[a]||0,o=r[a]||0;if(s!==o)return s-o}return 0},TO="1.53.12",Wd="pixcode:update-available",AO=360*60*1e3,Mp=new Map;function B4(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function jO(e,t){try{const n=localStorage.getItem(B4(e,t));if(!n)return null;const r=JSON.parse(n);return{fetchedAt:typeof r.fetchedAt=="number"?r.fetchedAt:null,latestVersion:typeof r.latestVersion=="string"?r.latestVersion:null,releaseInfo:r.releaseInfo??null,rateLimitedUntil:typeof r.rateLimitedUntil=="number"?r.rateLimitedUntil:void 0}}catch{return null}}function lk(e,t,n){localStorage.setItem(B4(e,t),JSON.stringify(n))}function RO(e,t){const n=`${e}/${t}`,r=Mp.get(n);if(r)return r;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(()=>{Mp.delete(n)});return Mp.set(n,a),a}const zg=(e,t)=>{const[n,r]=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(()=>ok()),[x,v]=m.useState(TO),y=m.useRef(null),w=m.useCallback(S=>{EO(S),b(S)},[]);m.useEffect(()=>{const S=()=>b(ok()),C=A=>{A.key===Mg&&S()};return window.addEventListener("storage",C),window.addEventListener(rf,S),()=>{window.removeEventListener("storage",C),window.removeEventListener(rf,S)}},[]),m.useEffect(()=>{let S=!1;const C=async()=>{try{const j=await(await fetch("/health",{cache:"no-store"})).json();if(S)return;(j.installMode==="npm"||j.installMode==="git")&&d(j.installMode),typeof j.version=="string"&&/^\d+\.\d+\.\d+/.test(j.version)&&v(j.version)}catch{}};C();const A=()=>{C()};return window.addEventListener("focus",A),()=>{S=!0,window.removeEventListener("focus",A)}},[]),m.useEffect(()=>{if(!x)return;let S=!1;const C=(E,I,N,O)=>({updateAvailable:!!(E&&Op(E,x)>0),latestVersion:E,releaseInfo:I,currentVersion:x,checkedAt:N,status:O}),A=E=>{!E.updateAvailable||!E.latestVersion||!E.releaseInfo||window.dispatchEvent(new CustomEvent(Wd,{detail:E}))},R=(E,I,N,O="success")=>{if(!E||!I)return r(!1),s(null),l(null),h(N),C(null,null,N,O);s(E),r(Op(E,x)>0),l(I),h(N);const B=C(E,I,N,O);return A(B),B},j=async({force:E=!1}={})=>{const I=sk(g),N=jO(e,t),O=Date.now();if(!E&&I===null)return p("idle"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");if(!E&&N?.fetchedAt&&I!==null&&O-N.fetchedAt<I)return p("success"),R(N.latestVersion,N.releaseInfo,N.fetchedAt,"success");if(!E&&N?.rateLimitedUntil&&N.rateLimitedUntil>O)return p("error"),R(N.latestVersion,N.releaseInfo,N.fetchedAt,"error");try{p("checking");const B=await RO(e,t);if(S)return C(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");const F=B.data;if(!B.ok)return B.status===403&&lk(e,t,{fetchedAt:N?.fetchedAt??null,latestVersion:N?.latestVersion??null,releaseInfo:N?.releaseInfo??null,rateLimitedUntil:O+Math.max(I??0,AO)}),p("error"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error");if(F.tag_name){const Y=F.tag_name.replace(/^v/,""),X=Op(Y,x)>0,P={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};lk(e,t,{fetchedAt:O,latestVersion:Y,releaseInfo:P}),s(Y),r(X),X&&QN({key:`app-update:${Y}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${Y}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:Y,installMode:c}}),l(P),p("success"),h(O);const U=C(Y,P,O,"success");return A(U),U}else return r(!1),s(null),l(null),p("error"),C(null,null,null,"error")}catch(B){return console.error("Version check failed:",B),p("error"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error")}};y.current=j,j();const T=sk(g),L=T===null?null:window.setInterval(()=>{j()},T);return()=>{S=!0,L!==null&&window.clearInterval(L)}},[e,t,x,c,g]);const k=m.useCallback(async()=>y.current?await y.current({force:!0}):null,[]);return{updateAvailable:n,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:k,updateCheckPreferences:g,updatePreferences:w}},Wi={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat",autoShowAgentDiff:"always"},IO=["flat","grouped"],_O=e=>typeof e=="string"&&IO.includes(e),LO=["always","openOnly","off"],PO=e=>typeof e=="string"&&LO.includes(e),qd=Object.keys(Wi),DO=new Set(qd),Fp="ui-preferences:sync",OO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Kd=(e,t,n)=>e==="historyView"?_O(t)?t:n:e==="autoShowAgentDiff"?PO(t)?t:n:OO(t,n),MO=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return Kd(e,r,t)}catch{return t}},FO=e=>{if(typeof window>"u")return Wi;try{const t=localStorage.getItem(e);if(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;return qd.reduce((a,s)=>(a[s]=Kd(s,r[s],Wi[s]),a),{...Wi})}}}catch{}return qd.reduce((t,n)=>(t[n]=MO(n,Wi[n]),t),{...Wi})};function zO(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!DO.has(n))return e;const a=Kd(n,r,e[n]);return e[n]===a?e:{...e,[n]:a}}case"set_many":{const n=t.value||{};let r=!1;const a={...e};for(const s of qd){if(!(s in n))continue;const o=n[s],l=Kd(s,o,e[s]);a[s]!==l&&(a[s]=l,r=!0)}return r?a:e}case"reset":return{...Wi,...t.value||{}};default:return e}}function zu(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=m.useReducer(zO,e,FO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Fp,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||r({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(Fp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Fp,d)}},[e]),{preferences:n,setPreference:(l,c)=>{r({type:"set",key:l,value:c})},setPreferences:l=>{r({type:"set_many",value:l})},resetPreferences:l=>{r({type:"reset",value:l})},dispatch:r}}const BO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},UO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},$O=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},ck=(e,t)=>`${e}::${t}`,HO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},GO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},VO=/(?:^|[\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,WO=e=>{if(!e)return[];const t=new Set,n=new RegExp(VO.source,"gi");let r;for(;(r=n.exec(e))!==null;){const a=r[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]},Xi=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),qO=(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"),KO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),YO=(e,t,n)=>{const r=Xi(e),a=Math.floor((t.getTime()-r.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:qO(e,n),sessionTime:KO(e),messageCount:Number(e.messageCount||0)}},U4=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),r=(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[...n,...r,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>Xi(b).getTime()-Xi(g).getTime())},dk=(e,t)=>{const n=U4(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const s=Xi(a);return s>r?s:r},new Date(0))},ZO=(e,t,n,r)=>{const a=[...e];return a.sort((s,o)=>{const l=n.has(s.name),c=n.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?dk(o,r).getTime()-dk(s,r).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},XO=(e,t)=>{const n=t.trim().toLowerCase();return n?e.filter(r=>{const a=(r.displayName||r.name).toLowerCase(),s=r.name.toLowerCase();return a.includes(n)||s.includes(n)}):e},QO=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 JO({projects:e,selectedProject:t,selectedSession:n,isLoading:r,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),[v,y]=m.useState(!1),[w,k]=m.useState(""),[S,C]=m.useState({}),[A,R]=m.useState({}),[j,T]=m.useState(new Set),[L,E]=m.useState(new Date),[I,N]=m.useState("name"),[O,B]=m.useState(!1),[F,Y]=m.useState({}),[X,P]=m.useState(null),[U,H]=m.useState(""),[z,J]=m.useState(""),[ie,fe]=m.useState(new Set),[le,se]=m.useState(null),[ge,me]=m.useState(null),[Se,Ne]=m.useState(!1),[je,M]=m.useState(()=>UO()),[ue,de]=m.useState(()=>HO()),[V,K]=m.useState("projects"),[ne,ee]=m.useState(null),[ce,te]=m.useState(!1),[Ce,pe]=m.useState(null),q=m.useRef(null),G=m.useRef(0),ae=m.useRef(null),xe=!a&&!f;m.useEffect(()=>{const Me=setInterval(()=>{E(new Date)},6e4);return()=>clearInterval(Me)},[]),m.useEffect(()=>{R({}),T(new Set),Y({})},[e]),m.useEffect(()=>{t&&g(Me=>{if(Me.has(t.name))return Me;const We=new Set(Me);return We.add(t.name),We})},[n,t]),m.useEffect(()=>{if(e.length>0&&!r){const Me=new Set;e.forEach(We=>{We.sessions&&We.sessions.length>=0&&Me.add(We.name)}),T(Me)}},[e,r]),m.useEffect(()=>{const Me=()=>{N(BO())};Me();const We=et=>{et.key==="claude-settings"&&Me()},mt=()=>Me();return window.addEventListener("storage",We),window.addEventListener("pixcode:settings-changed",mt),()=>{window.removeEventListener("storage",We),window.removeEventListener("pixcode:settings-changed",mt)}},[]),m.useEffect(()=>{q.current&&clearTimeout(q.current),ae.current&&(ae.current.close(),ae.current=null);const Me=z.trim();if(V!=="conversations"||Me.length<2){G.current+=1,ee(null),pe(null),te(!1);return}te(!0);const We=++G.current;return q.current=setTimeout(()=>{if(We!==G.current)return;const mt=At.searchConversationsUrl(Me),et=new EventSource(mt);ae.current=et;const we=[];let ze=0;et.addEventListener("result",W=>{if(We!==G.current){et.close();return}try{const ye=JSON.parse(W.data);we.push(ye.projectResult),ze=ye.totalMatches,ee({results:[...we],totalMatches:ze,query:Me}),pe({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),et.addEventListener("progress",W=>{if(We!==G.current){et.close();return}try{const ye=JSON.parse(W.data);ze=ye.totalMatches,pe({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),et.addEventListener("done",()=>{if(We!==G.current){et.close();return}et.close(),ae.current=null,te(!1),pe(null),we.length===0&&ee({results:[],totalMatches:0,query:Me})}),et.addEventListener("error",()=>{if(We!==G.current){et.close();return}et.close(),ae.current=null,te(!1),pe(null),we.length===0&&ee({results:[],totalMatches:0,query:Me})})},400),()=>{q.current&&clearTimeout(q.current),ae.current&&(ae.current.close(),ae.current=null)}},[z,V]);const De=m.useCallback(Me=>{g(We=>{const mt=new Set;return We.has(Me)||mt.add(Me),mt})},[]),Ve=m.useCallback((Me,We)=>{c({...Me,__projectName:We})},[c]),Ze=m.useCallback(Me=>{M(We=>{const mt=new Set(We);return mt.has(Me)?mt.delete(Me):mt.add(Me),$O(mt),mt})},[]),ht=m.useCallback(Me=>je.has(Me),[je]),Qe=m.useCallback((Me,We)=>{de(mt=>{const et=ck(Me,We),we=new Set(mt);return we.has(et)?we.delete(et):we.add(et),GO(we),we})},[]),bt=m.useCallback((Me,We)=>ue.has(ck(Me,We)),[ue]),dt=m.useCallback(Me=>U4(Me,A),[A]),st=m.useMemo(()=>e.map(Me=>{const We=F[Me.name];return We===void 0?Me:{...Me,sessionMeta:{...Me.sessionMeta,hasMore:We}}}),[F,e]),pt=m.useMemo(()=>ZO(st,I,je,A),[A,I,st,je]),kt=m.useMemo(()=>XO(pt,z),[z,pt]),_t=m.useCallback(Me=>{x(Me.name),k(Me.displayName)},[]),Lt=m.useCallback(()=>{x(null),k("")},[]),gn=m.useCallback(async Me=>{try{(await At.renameProject(Me,w)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(We){console.error("Error renaming project:",We)}finally{x(null),k("")}},[w]),Yt=m.useCallback((Me,We,mt,et="claude")=>{me({projectName:Me,sessionId:We,sessionTitle:mt,provider:et})},[]),dn=m.useCallback(async()=>{if(!ge)return;const{projectName:Me,sessionId:We,provider:mt}=ge;me(null);try{let et;if(mt==="codex"?et=await At.deleteCodexSession(We):mt==="gemini"?et=await At.deleteGeminiSession(We):mt==="qwen"?et=await At.deleteQwenSession(We):et=await At.deleteSession(Me,We),et.ok)d?.(We);else{const we=await et.text();console.error("[Sidebar] Failed to delete session:",{status:et.status,error:we}),alert(s("messages.deleteSessionFailed"))}}catch(et){console.error("[Sidebar] Error deleting session:",et),alert(s("messages.deleteSessionError"))}},[d,ge,s]),bn=m.useCallback(Me=>{se({project:Me,sessionCount:dt(Me).length})},[dt]),Le=m.useCallback(async(Me=!1)=>{if(!le)return;const{project:We,sessionCount:mt}=le,et=mt===0;se(null),fe(we=>new Set([...we,We.name]));try{const we=await At.deleteProject(We.name,!et,Me);if(we.ok)u?.(We.name);else{const ze=await we.json();alert(ze.error||s("messages.deleteProjectFailed"))}}catch(we){console.error("Error deleting project:",we),alert(s("messages.deleteProjectError"))}finally{fe(we=>{const ze=new Set(we);return ze.delete(We.name),ze})}},[le,u,s]),Xe=m.useCallback(async Me=>{const We=F[Me.name];if(!(!(We!==void 0?We:Me.sessionMeta?.hasMore===!0)||S[Me.name])){C(et=>({...et,[Me.name]:!0}));try{const et=(Me.sessions?.length||0)+(A[Me.name]?.length||0),we=await At.sessions(Me.name,5,et);if(!we.ok)return;const ze=await we.json();R(W=>({...W,[Me.name]:[...W[Me.name]||[],...ze.sessions||[]]})),ze.hasMore===!1&&Y(W=>({...W,[Me.name]:!1}))}catch(et){console.error("Error loading more sessions:",et)}finally{C(et=>({...et,[Me.name]:!1}))}}},[A,S,F]),Re=m.useCallback(Me=>{l(Me)},[l]),$e=m.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),nt=m.useCallback(async(Me,We,mt,et)=>{const we=mt.trim();if(!we){P(null),H("");return}try{const ze=await At.renameSession(We,we,et);ze.ok?await o():(console.error("[Sidebar] Failed to rename session:",ze.status),alert(s("messages.renameSessionFailed")))}catch(ze){console.error("[Sidebar] Error renaming session:",ze),alert(s("messages.renameSessionError"))}finally{P(null),H("")}},[o,s]),xt=m.useCallback(()=>{p(!1)},[p]),Dt=m.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:xe,expandedProjects:h,editingProject:b,showNewProject:v,editingName:w,loadingSessions:S,additionalSessions:A,initialSessionsLoaded:j,currentTime:L,projectSortOrder:I,isRefreshing:O,editingSession:X,editingSessionName:U,searchFilter:z,deletingProjects:ie,deleteConfirmation:le,sessionDeleteConfirmation:ge,showVersionModal:Se,starredProjects:je,starredSessions:ue,filteredProjects:kt,toggleProject:De,handleSessionClick:Ve,toggleStarProject:Ze,isProjectStarred:ht,toggleStarSession:Qe,isSessionStarred:bt,getProjectSessions:dt,startEditing:_t,cancelEditing:Lt,saveProjectName:gn,showDeleteSessionConfirmation:Yt,confirmDeleteSession:dn,requestProjectDelete:bn,confirmDeleteProject:Le,loadMoreSessions:Xe,handleProjectSelect:Re,refreshProjects:$e,updateSessionSummary:nt,collapseSidebar:xt,expandSidebar:Dt,setShowNewProject:y,setEditingName:k,setEditingSession:P,setEditingSessionName:H,searchMode:V,setSearchMode:K,conversationResults:ne,isSearching:ce,searchProgress:Ce,clearConversationResults:m.useCallback(()=>{G.current+=1,ae.current&&(ae.current.close(),ae.current=null),te(!1),pe(null),ee(null)},[]),setSearchFilter:J,setDeleteConfirmation:se,setSessionDeleteConfirmation:me,setShowVersionModal:Ne}}const eM="https://discord.gg/buxwujPNRE",tM="https://github.com/alicomert/pixcode/issues/new";function nM({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 rM({onExpand:e,onOpenControlRoom:t,onShowSettings:n,updateAvailable:r,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(_u,{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(cr,{className:"h-4 w-4 text-primary"})}),i.jsx("button",{onClick:n,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(Ot,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:tM,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(Ul,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:eM,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(nM,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&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(cr,{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 $4(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=$4(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function H4(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=$4(e))&&(r&&(r+=" "),r+=t);return r}const uk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,pk=H4,Bg=(e,t)=>n=>{var r;if(t?.variants==null)return pk(e,n?.class,n?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=n?.[d],p=s?.[d];if(u===null)return null;const f=uk(u)||uk(p);return a[d][f]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.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 pk(e,o,c,n?.class,n?.className)},Ug="-",aM=e=>{const t=sM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(Ug);return l[0]===""&&l.length!==1&&l.shift(),G4(l,t)||iM(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},G4=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?G4(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Ug);return t.validators.find(({validator:o})=>o(s))?.classGroupId},mk=/^\[(.+)\]$/,iM=e=>{if(mk.test(e)){const t=mk.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},sM=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)sf(n[a],r,a,t);return r},sf=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:hk(t,a);s.classGroupId=n;return}if(typeof a=="function"){if(oM(a)){sf(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([s,o])=>{sf(o,hk(t,s),n,r)})})},hk=(e,t)=>{let n=e;return t.split(Ug).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},oM=e=>e.isThemeGetter,lM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const a=(s,o)=>{n.set(s,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return a(s,o),o},set(s,o){n.has(s)?n.set(s,o):a(s,o)}}},of="!",lf=":",cM=lf.length,dM=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=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===lf){s.push(a.slice(c,g)),c=g+cM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=uM(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+lf,s=r;r=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const a=r;r=s=>n({className:s,parseClassName:a})}return r},uM=e=>e.endsWith(of)?e.substring(0,e.length-1):e.startsWith(of)?e.substring(1):e,pM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const a=[];let s=[];return r.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},mM=e=>({cache:lM(e.cacheSize),parseClassName:dM(e),sortModifiers:pM(e),...aM(e)}),hM=/\s+/,fM=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(hM);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}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,v=r(x?g.substring(0,b):g);if(!v){if(!x){c=u+(c.length>0?" "+c:c);continue}if(v=r(g),!v){c=u+(c.length>0?" "+c:c);continue}x=!1}const y=s(f).join(":"),w=h?y+of:y,k=w+v;if(o.includes(k))continue;o.push(k);const S=a(v,x);for(let C=0;C<S.length;++C){const A=S[C];o.push(w+A)}c=u+(c.length>0?" "+c:c)}return c};function gM(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=V4(t))&&(r&&(r+=" "),r+=n);return r}const V4=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=V4(e[r]))&&(n&&(n+=" "),n+=t);return n};function bM(e,...t){let n,r,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return n=mM(d),r=n.cache.get,a=n.cache.set,s=l,l(c)}function l(c){const d=r(c);if(d)return d;const u=fM(c,n);return a(c,u),u}return function(){return s(gM.apply(null,arguments))}}const xn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},W4=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,q4=/^\((?:(\w[\w-]*):)?(.+)\)$/i,xM=/^\d+\/\d+$/,vM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yM=/\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$/,wM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,SM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Cs=e=>xM.test(e),vt=e=>!!e&&!Number.isNaN(Number(e)),Qa=e=>!!e&&Number.isInteger(Number(e)),zp=e=>e.endsWith("%")&&vt(e.slice(0,-1)),Sa=e=>vM.test(e),CM=()=>!0,NM=e=>yM.test(e)&&!wM.test(e),K4=()=>!1,EM=e=>kM.test(e),TM=e=>SM.test(e),AM=e=>!Ke(e)&&!Ye(e),jM=e=>jo(e,X4,K4),Ke=e=>W4.test(e),Di=e=>jo(e,Q4,NM),Bp=e=>jo(e,PM,vt),fk=e=>jo(e,Y4,K4),RM=e=>jo(e,Z4,TM),Dc=e=>jo(e,J4,EM),Ye=e=>q4.test(e),tl=e=>Ro(e,Q4),IM=e=>Ro(e,DM),gk=e=>Ro(e,Y4),_M=e=>Ro(e,X4),LM=e=>Ro(e,Z4),Oc=e=>Ro(e,J4,!0),jo=(e,t,n)=>{const r=W4.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ro=(e,t,n=!1)=>{const r=q4.exec(e);return r?r[1]?t(r[1]):n:!1},Y4=e=>e==="position"||e==="percentage",Z4=e=>e==="image"||e==="url",X4=e=>e==="length"||e==="size"||e==="bg-size",Q4=e=>e==="length",PM=e=>e==="number",DM=e=>e==="family-name",J4=e=>e==="shadow",OM=()=>{const e=xn("color"),t=xn("font"),n=xn("text"),r=xn("font-weight"),a=xn("tracking"),s=xn("leading"),o=xn("breakpoint"),l=xn("container"),c=xn("spacing"),d=xn("radius"),u=xn("shadow"),p=xn("inset-shadow"),f=xn("text-shadow"),h=xn("drop-shadow"),g=xn("blur"),b=xn("perspective"),x=xn("aspect"),v=xn("ease"),y=xn("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...k(),Ye,Ke],C=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],R=()=>[Ye,Ke,c],j=()=>[Cs,"full","auto",...R()],T=()=>[Qa,"none","subgrid",Ye,Ke],L=()=>["auto",{span:["full",Qa,Ye,Ke]},Qa,Ye,Ke],E=()=>[Qa,"auto",Ye,Ke],I=()=>["auto","min","max","fr",Ye,Ke],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...R()],F=()=>[Cs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],Y=()=>[e,Ye,Ke],X=()=>[...k(),gk,fk,{position:[Ye,Ke]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],U=()=>["auto","cover","contain",_M,jM,{size:[Ye,Ke]}],H=()=>[zp,tl,Di],z=()=>["","none","full",d,Ye,Ke],J=()=>["",vt,tl,Di],ie=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[vt,zp,gk,fk],se=()=>["","none",g,Ye,Ke],ge=()=>["none",vt,Ye,Ke],me=()=>["none",vt,Ye,Ke],Se=()=>[vt,Ye,Ke],Ne=()=>[Cs,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sa],breakpoint:[Sa],color:[CM],container:[Sa],"drop-shadow":[Sa],ease:["in","out","in-out"],font:[AM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sa],shadow:[Sa],spacing:["px",vt],text:[Sa],"text-shadow":[Sa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Cs,Ke,Ye,x]}],container:["container"],columns:[{columns:[vt,Ke,Ye,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:S()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:j()}],"inset-x":[{"inset-x":j()}],"inset-y":[{"inset-y":j()}],start:[{start:j()}],end:[{end:j()}],top:[{top:j()}],right:[{right:j()}],bottom:[{bottom:j()}],left:[{left:j()}],visibility:["visible","invisible","collapse"],z:[{z:[Qa,"auto",Ye,Ke]}],basis:[{basis:[Cs,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[vt,Cs,"auto","initial","none",Ke]}],grow:[{grow:["",vt,Ye,Ke]}],shrink:[{shrink:["",vt,Ye,Ke]}],order:[{order:[Qa,"first","last","none",Ye,Ke]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"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",n,tl,Di]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ye,Bp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zp,Ke]}],"font-family":[{font:[IM,Ke,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,Ye,Ke]}],"line-clamp":[{"line-clamp":[vt,"none",Ye,Bp]}],leading:[{leading:[s,...R()]}],"list-image":[{"list-image":["none",Ye,Ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ye,Ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Y()}],"text-color":[{text:Y()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:[vt,"from-font","auto",Ye,Di]}],"text-decoration-color":[{decoration:Y()}],"underline-offset":[{"underline-offset":[vt,"auto",Ye,Ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ye,Ke]}],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",Ye,Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:X()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:U()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qa,Ye,Ke],radial:["",Ye,Ke],conic:[Qa,Ye,Ke]},LM,RM]}],"bg-color":[{bg:Y()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:Y()}],"gradient-via":[{via:Y()}],"gradient-to":[{to:Y()}],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:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ie(),"hidden","none"]}],"divide-style":[{divide:[...ie(),"hidden","none"]}],"border-color":[{border:Y()}],"border-color-x":[{"border-x":Y()}],"border-color-y":[{"border-y":Y()}],"border-color-s":[{"border-s":Y()}],"border-color-e":[{"border-e":Y()}],"border-color-t":[{"border-t":Y()}],"border-color-r":[{"border-r":Y()}],"border-color-b":[{"border-b":Y()}],"border-color-l":[{"border-l":Y()}],"divide-color":[{divide:Y()}],"outline-style":[{outline:[...ie(),"none","hidden"]}],"outline-offset":[{"outline-offset":[vt,Ye,Ke]}],"outline-w":[{outline:["",vt,tl,Di]}],"outline-color":[{outline:Y()}],shadow:[{shadow:["","none",u,Oc,Dc]}],"shadow-color":[{shadow:Y()}],"inset-shadow":[{"inset-shadow":["none",p,Oc,Dc]}],"inset-shadow-color":[{"inset-shadow":Y()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Y()}],"ring-offset-w":[{"ring-offset":[vt,Di]}],"ring-offset-color":[{"ring-offset":Y()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":Y()}],"text-shadow":[{"text-shadow":["none",f,Oc,Dc]}],"text-shadow-color":[{"text-shadow":Y()}],opacity:[{opacity:[vt,Ye,Ke]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"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":[vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":Y()}],"mask-image-linear-to-color":[{"mask-linear-to":Y()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":Y()}],"mask-image-t-to-color":[{"mask-t-to":Y()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":Y()}],"mask-image-r-to-color":[{"mask-r-to":Y()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":Y()}],"mask-image-b-to-color":[{"mask-b-to":Y()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":Y()}],"mask-image-l-to-color":[{"mask-l-to":Y()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":Y()}],"mask-image-x-to-color":[{"mask-x-to":Y()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":Y()}],"mask-image-y-to-color":[{"mask-y-to":Y()}],"mask-image-radial":[{"mask-radial":[Ye,Ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":Y()}],"mask-image-radial-to-color":[{"mask-radial-to":Y()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":Y()}],"mask-image-conic-to-color":[{"mask-conic-to":Y()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:X()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:U()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ye,Ke]}],filter:[{filter:["","none",Ye,Ke]}],blur:[{blur:se()}],brightness:[{brightness:[vt,Ye,Ke]}],contrast:[{contrast:[vt,Ye,Ke]}],"drop-shadow":[{"drop-shadow":["","none",h,Oc,Dc]}],"drop-shadow-color":[{"drop-shadow":Y()}],grayscale:[{grayscale:["",vt,Ye,Ke]}],"hue-rotate":[{"hue-rotate":[vt,Ye,Ke]}],invert:[{invert:["",vt,Ye,Ke]}],saturate:[{saturate:[vt,Ye,Ke]}],sepia:[{sepia:["",vt,Ye,Ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Ye,Ke]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[vt,Ye,Ke]}],"backdrop-contrast":[{"backdrop-contrast":[vt,Ye,Ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",vt,Ye,Ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[vt,Ye,Ke]}],"backdrop-invert":[{"backdrop-invert":["",vt,Ye,Ke]}],"backdrop-opacity":[{"backdrop-opacity":[vt,Ye,Ke]}],"backdrop-saturate":[{"backdrop-saturate":[vt,Ye,Ke]}],"backdrop-sepia":[{"backdrop-sepia":["",vt,Ye,Ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ye,Ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[vt,"initial",Ye,Ke]}],ease:[{ease:["linear","initial",v,Ye,Ke]}],delay:[{delay:[vt,Ye,Ke]}],animate:[{animate:["none",y,Ye,Ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Ye,Ke]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:Se()}],"skew-x":[{"skew-x":Se()}],"skew-y":[{"skew-y":Se()}],transform:[{transform:[Ye,Ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],accent:[{accent:Y()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Y()}],"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",Ye,Ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ye,Ke]}],fill:[{fill:["none",...Y()]}],"stroke-w":[{stroke:[vt,tl,Di,Bp]}],stroke:[{stroke:["none",...Y()]}],"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"]}},MM=bM(OM);function ve(...e){return MM(H4(e))}function FM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const zM=Bg("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"}}),eE=m.forwardRef(({className:e,variant:t,...n},r)=>i.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:ve(zM({variant:t}),e),...n}));eE.displayName="Alert";const BM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"alert-title",className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));BM.displayName="AlertTitle";const UM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"alert-description",className:ve("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));UM.displayName="AlertDescription";const $M=Bg("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 yt({className:e,variant:t,...n}){return i.jsx("div",{className:ve($M({variant:t}),e),...n})}const HM=Bg("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"}}),Te=m.forwardRef(({className:e,variant:t,size:n,...r},a)=>i.jsx("button",{className:ve(HM({variant:t,size:n,className:e})),ref:a,...r}));Te.displayName="Button";const tE=m.createContext(null),nE=()=>{const e=m.useContext(tE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},rE=({className:e,approval:t="pending",children:n,...r})=>{const a=m.useMemo(()=>({approval:t}),[t]);return i.jsx(tE.Provider,{value:a,children:i.jsx(eE,{className:ve("flex flex-col gap-2",e),...r,children:n})})};rE.displayName="Confirmation";const aE=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:ve("text-muted-foreground inline text-sm",e),...t});aE.displayName="ConfirmationTitle";const iE=({children:e})=>{const{approval:t}=nE();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};iE.displayName="ConfirmationRequest";const sE=({className:e,...t})=>{const{approval:n}=nE();return n!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:ve("flex items-center justify-end gap-2 self-end",e),...t})};sE.displayName="ConfirmationActions";const Sd=({variant:e="default",...t})=>i.jsx(Te,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Sd.displayName="ConfirmationAction";const oE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));oE.displayName="Card";const lE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("flex flex-col space-y-1.5 p-4",e),...t}));lE.displayName="CardHeader";const cE=m.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:ve("font-semibold leading-none tracking-tight",e),...t}));cE.displayName="CardTitle";const GM=m.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:ve("text-sm text-muted-foreground",e),...t}));GM.displayName="CardDescription";const dE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("p-4 pt-0",e),...t}));dE.displayName="CardContent";const uE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("flex items-center p-4 pt-0",e),...t}));uE.displayName="CardFooter";const VM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("ml-auto shrink-0",e),...t}));VM.displayName="CardAction";const pE=m.createContext(null);function mE(){const e=m.useContext(pE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const bi=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,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),n?.(h)},[d,n]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(pE.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:r,...s,children:a})})});bi.displayName="Collapsible";const Fa=m.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:s,onOpenChange:o}=mE(),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:n,...r,children:t})});Fa.displayName="CollapsibleTrigger";const xi=m.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=mE();return i.jsx("div",{ref:r,"data-state":a?"open":"closed",className:ve("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...n,children:i.jsx("div",{className:"overflow-hidden",children:t})})});xi.displayName="CollapsibleContent";const hE=m.createContext(null);function $g(){const e=m.useContext(hE);if(!e)throw new Error("Command components must be used within <Command>");return e}const fE=m.forwardRef(({className:e,children:t,...n},r)=>{const[a,s]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(y=>{o.current.set(y.id,y),c(w=>w+1)},[]),u=m.useCallback(y=>{o.current.delete(y),c(w=>w+1)},[]),p=m.useCallback((y,w)=>{const k=o.current.get(y);k&&Object.assign(k,w)},[]),f=m.useMemo(()=>{const y=a.toLowerCase(),w=new Set;for(const[k,S]of o.current)(!y||S.value.includes(y))&&w.add(k);return w},[a,l]),h=m.useMemo(()=>{const y=[];for(const[,w]of o.current)f.has(w.id)&&y.push(w);return y},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(y=>{if(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter")y.preventDefault();else return;const w=h;if(w.length===0)return;if(y.key==="Enter"){w.find(j=>j.id===g)?.onSelect();return}const k=w.findIndex(R=>R.id===g);let S;y.key==="ArrowDown"?S=k<w.length-1?k+1:0:S=k>0?k-1:w.length-1;const C=w[S].id;b(C),w[S].element?.scrollIntoView({block:"nearest"})},[h,g]),v=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(hE.Provider,{value:v,children:i.jsx("div",{ref:r,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:ve("flex flex-col",e),onKeyDown:x,...n,children:t})})});fE.displayName="Command";const gE=m.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:s}=$g();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(Ma,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:r,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:ve("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),...n})]})});gE.displayName="CommandInput";const bE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,role:"listbox",className:ve("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));bE.displayName="CommandList";const xE=m.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=$g();return!r||a.size>0?null:i.jsx("div",{ref:n,className:ve("py-6 text-center text-sm text-muted-foreground",e),...t})});xE.displayName="CommandEmpty";const vE=m.forwardRef(({className:e,heading:t,children:n,...r},a)=>i.jsxs("div",{ref:a,className:ve("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...r,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),n]}));vE.displayName="CommandGroup";const yE=m.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=$g(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:n||(()=>{})})},[h,n,f]);const x=m.useCallback(y=>{g.current=y,f(h,{element:y}),typeof o=="function"?o(y):o&&(o.current=y)},[h,f,o]);if(!l.has(h))return null;const v=c===h;return i.jsx("div",{ref:x,role:"option","aria-selected":v,"aria-disabled":r||void 0,"data-active":v||void 0,className:ve("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",v&&"bg-accent text-accent-foreground",r&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!r&&c!==h&&d(h)},onClick:()=>!r&&n?.(),...s,children:a})});yE.displayName="CommandItem";const WM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("-mx-1 h-px bg-border",e),...t}));WM.displayName="CommandSeparator";function Yd({checked:e,onToggle:t,ariaLabel:n}){const{t:r}=Fe("settings"),{isDarkMode:a,toggleDarkMode:s}=qa(),o=typeof e=="boolean",l=o?e:a,c=n||r("quickSettings.darkMode",{defaultValue:"Toggle dark mode"}),d=()=>{if(o){t?.(!l);return}s()};return i.jsxs("button",{onClick:d,className:ve("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",l?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":l,"aria-label":c,children:[i.jsx("span",{className:"sr-only",children:c}),i.jsx("span",{className:ve("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",l?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:l?i.jsx(A4,{className:"h-3 w-3 text-primary"}):i.jsx(I4,{className:"h-3 w-3 text-white dark:text-background"})})]})}const wE=m.createContext(null);function kE(){const e=m.useContext(wE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const SE=({open:e,onOpenChange:t,defaultOpen:n=!1,children:r})=>{const[a,s]=m.useState(n),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(wE.Provider,{value:u,children:r})},qM=m.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:s,triggerRef:o}=kE(),l=m.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(n&&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,...r,children:t})});qM.displayName="DialogTrigger";const bk='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Hg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=kE(),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(),n?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(bk));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,n]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(bk)?.focus()})},[o]),o?Au.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:()=>{r?.(),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:ve("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});Hg.displayName="DialogContent";const Gg=m.forwardRef(({className:e,...t},n)=>i.jsx("h2",{ref:n,className:ve("sr-only",e),...t}));Gg.displayName="DialogTitle";const qe=m.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:ve("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:r,...n}));qe.displayName="Input";const Vg=m.forwardRef(({className:e,contentClassName:t,children:n,...r},a)=>i.jsx("div",{className:ve("relative overflow-hidden",e),...r,children:i.jsx("div",{ref:a,className:ve("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:n})}));Vg.displayName="ScrollArea";const Zd=m.memo(({children:e,className:t,as:n="span"})=>i.jsx(n,{className:ve("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}));Zd.displayName="Shimmer";const CE=m.createContext(null),KM=()=>{const e=m.useContext(CE);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},YM=1e3,ZM=1e3,cf=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:s,children:o,...l})=>{const c=r??t,d=r===!1,[u,p]=m.useState(c),f=n!==void 0,h=f?n:u,g=m.useCallback(C=>{f||p(C),a?.(C)},[f,a]),[b,x]=m.useState(s),v=m.useRef(t),[y,w]=m.useState(!1),k=m.useRef(null);m.useEffect(()=>{s!==void 0&&x(s)},[s]),m.useEffect(()=>{t?(v.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/ZM)),k.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(v.current&&!t&&h&&!y){const C=setTimeout(()=>{g(!1),w(!0)},YM);return()=>clearTimeout(C)}},[t,h,g,y]);const S=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return i.jsx(CE.Provider,{value:S,children:i.jsx(bi,{open:h,onOpenChange:g,className:ve("not-prose",e),...l,children:o})})});cf.displayName="Reasoning";const XM=(e,t)=>e||t===0?i.jsx(Zd,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),df=m.memo(({className:e,children:t,getThinkingMessage:n=XM,...r})=>{const{isStreaming:a,isOpen:s,duration:o}=KM();return i.jsx(Fa,{className:ve("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...r,children:t??i.jsxs(i.Fragment,{children:[i.jsx(BD,{className:"h-4 w-4"}),n(a,o),i.jsx(d4,{className:ve("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});df.displayName="ReasoningTrigger";const uf=m.memo(({className:e,children:t,...n})=>i.jsx(xi,{className:ve("mt-4 text-sm text-muted-foreground",e),...n,children:t}));uf.displayName="ReasoningContent";function QM(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 pf({children:e,content:t,position:n="top",className:r="",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 k=w.getBoundingClientRect(),S=8,C={position:"fixed",zIndex:9999};switch(n){case"bottom":C.left=k.left+k.width/2,C.top=k.bottom+S,C.transform="translateX(-50%)";break;case"left":C.left=k.left-S,C.top=k.top+k.height/2,C.transform="translate(-100%, -50%)";break;case"right":C.left=k.right+S,C.top=k.top+k.height/2,C.transform="translateY(-50%)";break;case"top":default:C.left=k.left+k.width/2,C.top=k.top-S,C.transform="translate(-50%, -100%)";break}f(C)},[n]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},v=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},y=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!s||typeof document>"u")return;const w=k=>{const S=k.target;S instanceof Node&&d.current?.contains(S)||(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),k=()=>h();return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[s,h]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:v,onTouchEnd:y,onTouchCancel:y,children:[e,s&&typeof document<"u"&&Au.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:ve("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",r),children:[t,i.jsx("div",{className:ve("absolute w-0 h-0 border-4 border-transparent",QM(n))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const NE=m.createContext(null),EE=m.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const s=m.useMemo(()=>({status:t}),[t]);return i.jsx(NE.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:ve("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),...r,children:n})})});EE.displayName="PromptInput";const TE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:ve("px-3 pt-3",e),...t}));TE.displayName="PromptInputHeader";const AE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:ve("relative",e),...t}));AE.displayName="PromptInputBody";const jE=m.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{ref:n,"data-slot":"prompt-input-textarea",className:ve("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}));jE.displayName="PromptInputTextarea";const RE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-footer",className:ve("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));RE.displayName="PromptInputFooter";const IE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-tools",className:ve("flex items-center gap-1",e),...t}));IE.displayName="PromptInputTools";const Cd=m.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const s=i.jsx(Te,{ref:a,type:"button",variant:"ghost",size:"icon",className:ve("h-8 w-8 [&_svg]:size-4",e),...r,children:n});return t?i.jsx(pf,{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});Cd.displayName="PromptInputButton";const _E=m.forwardRef(({className:e,status:t,children:n,...r},a)=>{const s=m.useContext(NE),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(Te,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:ve("h-8 w-8 rounded-lg",e),...r,children:n??(l?i.jsx(Pu,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(ND,{className:"h-4 w-4"}))})});_E.displayName="PromptInputSubmit";function Bu({children:e,className:t}){return i.jsx("div",{className:ve("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Uu({isActive:e,onClick:t,children:n,className:r}){return i.jsx("button",{onClick:t,className:ve("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",r),children:n})}const LE=m.createContext(null);function PE(){const e=m.useContext(LE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const DE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:ve("space-y-0.5",e),...t}));DE.displayName="Queue";const OE=m.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const s=m.useMemo(()=>({status:e}),[e]);return i.jsx(LE.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:ve("flex items-start gap-2 py-0.5",t),...r,children:n})})});OE.displayName="QueueItem";const ME=m.forwardRef(({className:e,...t},n)=>{const{status:r}=PE();return i.jsxs("div",{ref:n,"data-slot":"queue-item-indicator","aria-hidden":"true",className:ve("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[r==="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"})}),r==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),r==="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})})]})});ME.displayName="QueueItemIndicator";const FE=m.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=PE();return i.jsx("div",{ref:r,"data-slot":"queue-item-content",className:ve("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),...n,children:t})});FE.displayName="QueueItemContent";const xk="https://github.com/alicomert/pixcode/issues/new",JM="https://github.com/alicomert/pixcode",vk="https://discord.gg/buxwujPNRE";function yk({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 e9({updateAvailable:e,releaseInfo:t,latestVersion:n,currentVersion:r,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(Kw,{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${n}`}),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(Kw,{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${n}`}),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:xk,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(Ul,{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:vk,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(yk,{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(cr,{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(Ot,{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:JM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",r," – ",l("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:xk,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(Ul,{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:vk,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(yk,{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(cr,{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(Ot,{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 wk="PIXCODE_GITHUB_STARS",kk="PIXCODE_HIDE_GITHUB_STAR",t9=3600*1e3,n9=(e,t)=>{const[n,r]=m.useState(null),[a,s]=m.useState(()=>{try{return localStorage.getItem(kk)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(wk);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<t9){r(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"){r(p);try{localStorage.setItem(wk,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{s(!0);try{localStorage.setItem(kk,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},r9="https://github.com/alicomert/pixcode";function a9({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 i9(){const{formattedCount:e,isDismissed:t,dismiss:n}=n9("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:r9,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(a9,{className:"h-3.5 w-3.5"}),i.jsx(_a,{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:r=>{r.preventDefault(),r.stopPropagation(),n()},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(wt,{className:"h-2.5 w-2.5"})})]})}function Sk({value:e,onChange:t,t:n}){const r="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":n("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:ve(r,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(k4,{className:"h-3 w-3"}),n("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:ve(r,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(jD,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function s9({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,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 v=()=>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(v,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(Te,{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(Te,{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(Te,{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(Iu,{className:"h-4 w-4"})})]})]}),i.jsx(i9,{}),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(cr,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),r>0&&!n&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Sk,{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:ve("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(Un,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ve("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(Tr,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Ma,{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(qe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:y=>s(y.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(wt,{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(v,{}),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(gi,{className:"h-4 w-4"})})]})]}),r>0&&!n&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Sk,{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:ve("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(Un,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ve("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(Tr,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(qe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:y=>s(y.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(wt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const o9=160,Ck=180;function zE({actions:e,className:t,triggerLabel:n}){const[r,a]=m.useState(!1),[s,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!r||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-o9;p<8&&(p=8);let f=u.bottom+4;f+Ck>window.innerHeight&&(f=Math.max(8,u.top-4-Ck)),o({top:f,left:p})},[r]),m.useEffect(()=>{if(!r)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)}},[r]);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":r,"aria-label":n||"Actions",title:n||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:ve("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",r&&"bg-accent text-foreground opacity-100",t),children:i.jsx(N4,{className:"h-3.5 w-3.5"})}),r&&s&&Au.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:ve("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:ve("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 l9=(e,t,n)=>{const r=new Date(e),a=t;if(isNaN(r.getTime()))return n?n("status.unknown"):"Unknown";const s=a.getTime()-r.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?n?n("time.justNow"):"Just now":l===1?n?n("time.oneMinuteAgo"):"1 min ago":l<60?n?n("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?n?n("time.oneHourAgo"):"1 hour ago":c<24?n?n("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?n?n("time.oneDayAgo"):"1 day ago":d<7?n?n("time.daysAgo",{count:d}):`${d} days ago`:r.toLocaleDateString()};function Nk({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:s,className:o}){const l=d=>i.jsx(_a,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:S4,onClick:n},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:r}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:An,onClick:a,danger:!0}),i.jsx(zE,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const c9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Ek={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 BE({project:e,session:t,selectedSession:n,currentTime:r,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 v=YO(t,r,x),y=n?.id===t.id,w=a===t.id,k=t.__provider,S=c9[k]??k,C=Ek[k]??Ek.claude,A=WO(v.sessionName),R=()=>{h(e),g(t,e.name)},j=()=>{p(e.name,t.id,s,k)},T=()=>{b(e.name,t.id,v.sessionName,k)},L=()=>d(t.id,v.sessionName),E=()=>f(e.name,t.id),I=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:ve("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",C),children:[i.jsx(nn,{provider:k,className:"h-2.5 w-2.5"}),S]}),i.jsx("span",{className:"text-muted-foreground/80",children:l9(v.sessionTime,r,x)}),v.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"})]}),A.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))]}),N=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"?j():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(),j()},title:x("tooltips.save"),children:i.jsx(Wt,{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(wt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),O=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ve("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",y&&"border-primary/30 bg-primary/5 shadow-sm",!y&&v.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!y&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:R,children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:ve("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",y?"bg-primary/10":"bg-muted/60"),children:i.jsx(nn,{provider:k,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:v.sessionName})]}),I]}),i.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:i.jsx(Nk,{isStarred:o,canDelete:!v.isCursorSession,onRename:L,onToggleStar:E,onDelete:T,t:x,className:"!opacity-100"})})]})})}),B=i.jsxs("div",{className:ve("group/item relative hidden md:block"),children:[i.jsxs(Te,{variant:"ghost",className:ve("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",y&&"bg-accent text-accent-foreground",o&&!y&&"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:[y&&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"}),!y&&!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:ve("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",y?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:i.jsx(nn,{provider:k,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:N}):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:v.sessionName})]}),I]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:i.jsx(Nk,{isStarred:o,canDelete:!v.isCursorSession,onRename:L,onToggleStar:E,onDelete:T,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[O,B]})}const d9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function u9(){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 p9({project:e,isExpanded:t,sessions:n,selectedSession:r,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:v,onLoadMoreSessions:y,onNewSession:w,onOpenOrchestration:k,t:S}){const[C,A]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let T=!1;const L=async()=>{const I=await Ee(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const N=await I.json();T||A((N.runs??[]).slice(0,5))};L();const E=window.setInterval(()=>{L()},15e3);return()=>{T=!0,window.clearInterval(E)}},[t,e.name]),!t)return null;const R=n.length>0,j=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"}),S("sessions.newSession")]})}),i.jsxs(Te,{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"}),S("sessions.newSession")]}),C.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(Ar,{className:"h-3 w-3"}),S("orchestration.section")]}),C.map(T=>{const L=[...new Set(T.nodeRuns.map(E=>d9(E.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>k?.(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(Ar,{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||S("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[L.slice(0,4).map(E=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(nn,{provider:E,className:"h-3 w-3"})},E)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:S(`common:orchestration.status.${T.status}`,{defaultValue:T.status})})]})]})]})},T.id)})]}),a?!R&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:S("sessions.noSessions")})}):n.map(T=>i.jsx(BE,{project:e,session:T,selectedSession:r,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:v,t:S},T.id)):i.jsx(u9,{}),R&&j&&i.jsx(Te,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>y(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"}),S("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Fr,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const m9=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function h9({project:e,selectedProject:t,selectedSession:n,isExpanded:r,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:v,onToggleStarProject:y,onToggleStarSession:w,onStartEditingProject:k,onCancelEditingProject:S,onSaveProjectName:C,onDeleteProject:A,onSessionSelect:R,onDeleteSession:j,onLoadMoreSessions:T,onNewSession:L,onOpenOrchestration:E,onEditingSessionNameChange:I,onStartEditingSession:N,onCancelEditingSession:O,onSaveEditingSession:B,t:F}){const Y=t?.name===e.name,X=o===e.name,P=e.sessionMeta?.hasMore===!0,U=m9(c,P),H=`${U} session${c.length===1?"":"s"}`,z=()=>x(e.name),J=()=>y(e.name),ie=()=>{C(e.name)},fe=()=>{t?.name!==e.name&&v(e),z()};return i.jsxs("div",{className:ve("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:ve("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",Y&&"bg-primary/5 border-primary/20",s&&!Y&&"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:ve("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",r?"bg-primary/10":"bg-muted"),children:r?i.jsx(Er,{className:"h-4 w-4 text-primary"}):i.jsx(Un,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:X?i.jsx("input",{type:"text",value:l,onChange:le=>b(le.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:le=>le.stopPropagation(),onKeyDown:le=>{le.key==="Enter"&&ie(),le.key==="Escape"&&S()},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:X?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:le=>{le.stopPropagation(),ie()},children:i.jsx(Wt,{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:le=>{le.stopPropagation(),S()},children:i.jsx(wt,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:ve("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:le=>{le.stopPropagation(),J()},title:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(_a,{className:ve("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:le=>{le.stopPropagation(),A(e)},children:i.jsx(An,{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:le=>{le.stopPropagation(),k(e)},children:i.jsx(Yh,{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:r?i.jsx(Fr,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(ma,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(Te,{variant:"ghost",className:ve("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",Y&&"bg-accent text-accent-foreground",s&&!Y&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:fe,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?i.jsx(Er,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Un,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:X?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:le=>b(le.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:le=>{le.key==="Enter"&&ie(),le.key==="Escape"&&S()}}),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:[U,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:X?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:le=>{le.stopPropagation(),ie()},children:i.jsx(Wt,{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:le=>{le.stopPropagation(),S()},children:i.jsx(wt,{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:le=>{le.stopPropagation(),J()},title:F("tooltips.removeFromFavorites"),children:i.jsx(_a,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(zE,{triggerLabel:F("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:F("actions.rename"),icon:Yh,onClick:()=>k(e)},{id:"star",label:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:_a,onClick:J},{id:"delete",label:F("actions.delete",{defaultValue:"Delete"}),icon:An,onClick:()=>A(e),danger:!0}]}),r?i.jsx(Fr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(ma,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(p9,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingSessionNameChange:I,onStartEditingSession:N,onCancelEditingSession:O,onSaveEditingSession:B,onToggleStarSession:w,onProjectSelect:v,onSessionSelect:R,onDeleteSession:j,onLoadMoreSessions:T,onNewSession:L,onOpenOrchestration:E,t:F})]})}function UE({isLoading:e,loadingProgress:t,projectsCount:n,filteredProjectsCount:r,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")})]}):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(Un,{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")})]}):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(Ma,{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 f9({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,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:v,onEditingNameChange:y,onToggleProject:w,onProjectSelect:k,onToggleStarProject:S,onToggleStarSession:C,onStartEditingProject:A,onCancelEditingProject:R,onSaveProjectName:j,onDeleteProject:T,onSessionSelect:L,onDeleteSession:E,onLoadMoreSessions:I,onNewSession:N,onOpenOrchestration:O,onEditingSessionNameChange:B,onStartEditingSession:F,onCancelEditingSession:Y,onSaveEditingSession:X,t:P}){const U=i.jsx(UE,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:P});m.useEffect(()=>{let le="Pixcode";const se=n?.displayName?.trim();se&&(le=`${se} - ${le}`),document.title=le},[n]);const H=!a&&e.length>0&&t.length>0,z=le=>le.source==="history"||le.autoDiscovered===!0&&le.isManuallyAdded!==!0,J=t.filter(le=>!z(le)),ie=t.filter(le=>z(le)),fe=le=>i.jsx(h9,{project:le,selectedProject:n,selectedSession:r,isExpanded:o.has(le.name),isDeleting:g.has(le.name),isStarred:x(le.name),editingProject:l,editingName:c,sessions:b(le),initialSessionsLoaded:u.has(le.name),isLoadingSessions:!!d[le.name],currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:v,onEditingNameChange:y,onToggleProject:w,onProjectSelect:k,onToggleStarProject:S,onToggleStarSession:C,onStartEditingProject:A,onCancelEditingProject:R,onSaveProjectName:j,onDeleteProject:T,onSessionSelect:L,onDeleteSession:E,onLoadMoreSessions:I,onNewSession:N,onOpenOrchestration:O,onEditingSessionNameChange:B,onStartEditingSession:F,onCancelEditingSession:Y,onSaveEditingSession:X,t:P},le.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:H?i.jsxs(i.Fragment,{children:[J.map(le=>fe(le)),ie.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:P("projects.detectedFromHistory")}),ie.map(le=>fe(le))]})]}):U})}function Ea(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $E(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
220
+ */const xD=[["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"}]],vD=Nt("workflow",xD),x4=o4,yD=S7,Kw=v7,wD=d7,v4=f7,kD=s4,Fr=d4,Tg=i8,ma=o8,SD=c8,Fn=b7,ha=s4,Hd=w7,y4=m7,Iu=e8,_u=n8,Ag=N7,rt=l4,Rt=l4,Lu=j7,CD=T7,ND=mL,ua=P8,cn=O8,Wt=Q7,Oa=Z7,w4=eL,Rn=_L,lc=h4,ED=h4,Gd=U7,co=u8,To=u4,Ys=g8,uo=E8,En=A8,Un=W8,Er=$8,gi=G8,TD=xL,AD=Q8,k4=iL,jg=EL,jD=I7,RD=H7,ID=VL,S4=m4,Yh=fL,_D=K8,Zh=m4,C4=yL,Ht=kL,An=qL,N4=R8,Ma=cL,wt=f4,Xh=f4,Pu=zL,Rg=M7,LD=D7,Vd=L7,PD=_8,Tr=c4,DD=c4,OD=YL,as=XL,Ig=q7,Ul=V7,_g=h8,cc=B8,Lg=F8,lr=Z8,E4=u4,Du=p4,MD=p4,T4=rL,gr=oL,A4=uL,Ou=k8,j4=HL,R4=CL,Ao=RL,FD=AL,Ot=x8,Qh=s7,dc=C8,cr=DL,_a=ML,I4=UL,On=y8,Pg=z7,zD=oP,Ti=mP,Dg=b4,BD=b4,_n=KP,kd=ZP,Mu=QP,ws=iP,ks=cP,UD=uP,hl=fP,Zs=bP,Yw=yP,fl=kP,Zo=EP,$D=AP,_4=BP,Jh=RP,Wr=PP,Xo=_P,Zw=OP,Qo=FP,ef=$P,HD=GP,tf=WP,Hs=nD,gl=aD,Xa=sD,Ss=lD,GD=dD,nf=pD,VD=fD,Jo=bD,Ar=vD,Fu=CP,WD=eD,qD=[{type:"key",id:"ctrl-c",label:"Ctrl-C",sequence:""},{type:"key",id:"ctrl-d",label:"Ctrl-D",sequence:""},{type:"key",id:"ctrl-l",label:"Ctrl-L",sequence:"\f"},{type:"key",id:"ctrl-z",label:"Ctrl-Z",sequence:""},{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"enter",label:"Enter",sequence:"\r"},{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"}],KD={up:yD,down:x4,left:wD,right:v4},el=e=>e.preventDefault(),Xw="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",YD="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",Dp="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 Qw({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=Fe("settings"),[s,o]=m.useState(!1),[l,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useCallback(b=>{$d(e.current,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 v=b.toLowerCase().charCodeAt(0);v>=97&&v<=122&&(x=String.fromCharCode(v-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 ${r} z-40 px-2 pb-[max(env(safe-area-inset-bottom),0px)] 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:el,onClick:()=>{h()},disabled:!n,className:Dp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(co,{className:"h-4 w-4"})}),qD.map(b=>{if(b.type==="modifier"){const x=b.modifier==="ctrl"?s:l,v=b.modifier==="ctrl"?()=>o(y=>!y):()=>c(y=>!y);return i.jsx("button",{type:"button",onPointerDown:el,onClick:v,disabled:!n,className:x?YD:Xw,children:b.label},b.id)}if(b.type==="arrow"){const x=KD[b.icon];return i.jsx("button",{type:"button",onPointerDown:el,onClick:()=>p(b.sequence),disabled:!n,className:Dp,children:i.jsx(x,{className:"h-4 w-4"})},b.id)}return i.jsx("button",{type:"button",onPointerDown:el,onClick:()=>g(b.sequence),disabled:!n,className:Xw,children:b.label},b.id)}),i.jsx("button",{type:"button",onPointerDown:el,onClick:f,disabled:!n,className:Dp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(kD,{className:"h-4 w-4"})})]})})}function ZD({tabId:e,selectedProject:t=null,selectedSession:n=null,initialCommand:r=null,isPlainShell:a=!1,onProcessComplete:s=null,minimal:o=!1,autoConnect:l=!1,forceNewSession:c=!1,startupInput:d=null,permissionOverride:u=null,provider:p=null,isActive:f=!0,onClose:h=null}){const{t:g}=Fe("chat"),[b,x]=m.useState(!1),[v,y]=m.useState(null),w=m.useRef(null),k=m.useRef(null),{terminalContainerRef:S,terminalRef:C,wsRef:A,isConnected:R,isInitialized:j,isConnecting:T,authUrl:L,authUrlVersion:E,connectToShell:I,disconnectFromShell:N,openAuthUrlInBrowser:O,copyAuthUrlToClipboard:B}=e7({tabId:e,selectedProject:t,selectedSession:n,initialCommand:r,isPlainShell:a,minimal:o,autoConnect:l,forceNewSession:c,startupInput:d,permissionOverride:u,provider:p,isRestarting:b,onProcessComplete:s,onOutputRef:k}),F=m.useCallback(()=>{const Se=C.current;if(!Se)return;const Ne=Se.buffer.active,je=Ne.baseY+Ne.cursorY,M=Math.min(Ne.baseY+Ne.length-1,je+10),ue=Math.max(0,je-E_),de=[];for(let ce=ue;ce<=M;ce++){const te=Ne.getLine(ce);te&&de.push(te.translateToString().trimEnd())}let V=-1;for(let ce=de.length-1;ce>=0;ce--)if(/esc to cancel/i.test(de[ce])||/enter to select/i.test(de[ce])){V=ce;break}if(V===-1){y(null);return}const K=new Map,ne=Math.max(0,V-T_);for(let ce=V-1;ce>=ne;ce--){const te=de[ce].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(te){const Ce=te[1],pe=te[2].trim();parseInt(Ce,10)<=A_&&pe.length>0&&!K.has(Ce)&&K.set(Ce,pe)}}const ee=[];for(let ce=1;ce<=K.size&&K.has(String(ce));ce++)ee.push({number:String(ce),label:K.get(String(ce))});y(ee.length>=j_?ee:null)},[C]),Y=m.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(F,N_)},[F]);m.useEffect(()=>{k.current=Y},[Y]),m.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),m.useEffect(()=>{R||(w.current&&(clearTimeout(w.current),w.current=null),y(null))},[R]),m.useEffect(()=>{if(!f||!j||!R)return;const Se=()=>{C.current?.focus()},Ne=window.requestAnimationFrame(Se),je=window.setTimeout(Se,0);return()=>{window.cancelAnimationFrame(Ne),window.clearTimeout(je)}},[f,R,j,C]);const X=m.useCallback(Se=>{$d(A.current,Se)},[A]),P=m.useMemo(()=>q_(n),[n]),U=m.useMemo(()=>p||(n?.__provider?n.__provider:window.localStorage.getItem("selected-provider")||"claude"),[p,n?.__provider]),H=Dn[U]??"Claude Code",z=m.useMemo(()=>P?P.slice(0,30):null,[P]),J=m.useMemo(()=>P?P.slice(0,50):null,[P]),ie=m.useCallback(()=>{x(!0),window.setTimeout(()=>{x(!1)},S_)},[]),fe=m.useCallback(()=>{N(),h?.()},[N,h]);if(!t)return i.jsx(n7,{title:g("shell.selectProject.title"),description:g("shell.selectProject.description")});if(o)return i.jsxs(i.Fragment,{children:[i.jsx(a7,{terminalContainerRef:S,authUrl:L,authUrlVersion:E,initialCommand:r,isConnected:R,openAuthUrlInBrowser:O,copyAuthUrlToClipboard:B}),i.jsx(Qw,{wsRef:A,terminalRef:C,isConnected:R,bottomOffset:"bottom-0"})]});const le=a?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:t.displayName}):n?g("shell.resumeSession",{displayName:J}):g("shell.startProviderSession",{provider:H,defaultValue:"Start a new {{provider}} session"}),se=a?g("shell.runCommand",{command:r||g("shell.defaultCommand"),projectName:t.displayName}):g("shell.startProviderCli",{provider:H,projectName:t.displayName,defaultValue:"Starting {{provider}} in {{projectName}}"}),ge=j?T?"connecting":R?null:"connect":"loading",me=ge==="connecting"?se:le;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(r7,{isConnected:R,isInitialized:j,isRestarting:b,hasSession:!!n,sessionDisplayNameShort:z,onDisconnect:fe,onRestart:ie,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||R}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2 pb-16 md:pb-2",children:[i.jsx("div",{ref:S,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),ge&&i.jsx(t7,{mode:ge,description:me,loadingLabel:g("shell.loading"),connectLabel:g("shell.actions.connect"),connectTitle:g("shell.actions.connectTitle"),connectingLabel:g("shell.connecting"),onConnect:I}),v&&R&&i.jsx("div",{className:"absolute inset-x-0 bottom-14 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm md:bottom-0",onMouseDown:Se=>Se.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.map(Se=>i.jsxs("button",{type:"button",onClick:()=>{X(`${Se.number}\r`),y(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:`${Se.number}. ${Se.label}`,children:[Se.number,". ",Se.label]},Se.number)),i.jsx("button",{type:"button",onClick:()=>{X("\x1B"),y(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(Qw,{wsRef:A,terminalRef:C,isConnected:R})]})}function XD({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:n=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)"})]}),n&&i.jsx("button",{onClick:n,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 $l({project:e=null,session:t=null,command:n=null,isPlainShell:r=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,permissionOverride:b=null,provider:x=null,tabId:v=null}){const[y,w]=m.useState(!1),k=m.useMemo(()=>v||`tab_${crypto.randomUUID()}`,[v]),S=r!==null?r:n!==null,C=m.useCallback(A=>{w(!0),o?.(A)},[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:y,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(ZD,{tabId:k,selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:S,isActive:a,onProcessComplete:C,minimal:f,autoConnect:f?!0:s,forceNewSession:h,startupInput:g,permissionOverride:b,provider:x,onClose:l})})]}):i.jsx(XD,{className:d})}const JD=(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"),eO={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 Jw({active:e,children:t,onClick:n}){return i.jsx("button",{onClick:n,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 tO({provider:e}){const[t,n]=m.useState(""),[r,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 Ee(`/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"),n("")}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=>n(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:r||!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:r?i.jsx(Rt,{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(Wt,{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 nO({provider:e,onSaved:t}){const n=eO[e],[r,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 Ee("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const v=x.data?.[e];v?.baseUrl&&o(v.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=r.trim();if(g){c(!0),f(null),u("idle");try{const b=await Ee(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:n.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 n?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(MD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.keyLabel}),i.jsxs("a",{href:n.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 ",n.keyConsoleLabel,i.jsx(Fn,{className:"h-3 w-3"})]})]})]}),n.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:n.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:r,onChange:g=>a(g.target.value),placeholder:n.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."]})]}),n.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:n.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||!r.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(Rt,{className:"h-4 w-4 animate-spin"}):i.jsx(Wt,{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 L4({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Fe("common"),l=n!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,n,l]);const u=m.useMemo(()=>`${Dn[n]??n} Login`,[n]);if(!e)return null;const p=JD(n,a),f=h=>r?.(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(wt,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(Jw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(Jw,{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($l,{project:d_,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(tO,{provider:n})})]}):i.jsx(nO,{provider:n,onSaved:()=>f(0)})})]})})}const rO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),aO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},iO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},sO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),oO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa(),n=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:n,alt:"OpenCode",className:e})},lO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function nn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(iO,{className:t}):e==="codex"?i.jsx(aO,{className:t}):e==="gemini"?i.jsx(sO,{className:t}):e==="qwen"?i.jsx(lO,{className:t}):e==="opencode"?i.jsx(oO,{className:t}):i.jsx(rO,{className:t})}function cO({provider:e,title:t,status:n,connectedClassName:r,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=n.authenticated?r:"border-border bg-card",c=n.loading?"Checking...":n.authenticated?n.email||"Connected":n.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(nn,{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,n.authenticated&&i.jsx(Wt,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!n.authenticated&&!n.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 dO=[{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 ek({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:dO.map(n=>i.jsx(cO,{provider:n.provider,title:n.title,status:e[n.provider],connectedClassName:n.connectedClassName,iconContainerClassName:n.iconContainerClassName,loginButtonClassName:n.loginButtonClassName,onLogin:()=>t(n.provider)},n.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 uO({gitName:e,gitEmail:t,isSubmitting:n,onGitNameChange:r,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(_n,{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(OD,{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=>r(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:n}),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(PD,{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:n}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const tk=[{title:"Git Configuration",icon:_n,required:!0},{title:"Connect Agents",icon:y4,required:!1}];function pO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:tk.map((t,n)=>{const r=n<e,a=n===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 ${r?"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:r?i.jsx(Wt,{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"})]})]}),n<tk.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${r?"bg-green-500":"bg-border"}`})]},t.title)})})})}const nk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,rk=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function mO({onComplete:e}){const[t,n]=m.useState(0),[r,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}=Ru(),x=m.useRef(void 0),v=m.useCallback(async()=>{try{const R=await Ee("/api/user/git-config");if(!R.ok)return;const j=await R.json();j.gitName&&a(j.gitName),j.gitEmail&&o(j.gitEmail)}catch(R){console.error("Error loading git config:",R)}},[]);m.useEffect(()=>{v(),b()},[v,b]),m.useEffect(()=>{const R=x.current;x.current=p,R!=null&&p===null&&b()},[p,b]);const y=R=>{f(R)},w=R=>{R===0&&p&&g(p)},k=async()=>{if(u(""),t!==0){n(R=>R+1);return}if(!r.trim()||!s.trim()){u("Both git name and email are required.");return}if(!nk.test(s)){u("Please enter a valid email address.");return}c(!0);try{const R=await Ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:s})});if(!R.ok){const j=await rk(R,"Failed to save git configuration");throw new Error(j)}n(j=>j+1)}catch(R){u(R instanceof Error?R.message:"Failed to save git configuration")}finally{c(!1)}},S=()=>{u(""),n(R=>R-1)},C=async()=>{c(!0),u("");try{const R=await Ee("/api/user/complete-onboarding",{method:"POST"});if(!R.ok){const j=await rk(R,"Failed to complete onboarding");throw new Error(j)}await e?.()}catch(R){u(R instanceof Error?R.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&s.trim()&&nk.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(pO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(uO,{gitName:r,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(ek,{providerStatuses:h,onOpenProviderLogin:y}):i.jsx(ek,{providerStatuses:h,onOpenProviderLogin:y}),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:S,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(Tg,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<1?i.jsx("button",{onClick:k,disabled:!A||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(Rt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(ma,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:C,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(Rt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Wt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(L4,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:w})]})}const hO=["0s","0.1s","0.2s"];function fO(){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(Tr,{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:hO.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 P4({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 Vi({id:e,label:t,value:n,onChange:r,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:n,onChange:d=>r(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 D4({title:e,description:t,children:n,footerText:r,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(Tr,{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})]}),n,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:r})}),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 gO={username:"",password:""};function bO(){const{t:e}=Fe("auth"),{login:t}=oc(),[n,r]=m.useState(gO),[a,s]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{r(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),s(""),!n.username.trim()||!n.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(n.username.trim(),n.password);p.success||s(p.error),l(!1)},[n.password,n.username,t,e]);return i.jsx(D4,{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(Vi,{id:"username",label:e("login.username"),value:n.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(Vi,{id:"password",label:e("login.password"),value:n.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx(P4,{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 xO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function vO(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 yO(){const{register:e}=oc(),[t,n]=m.useState(xO),[r,a]=m.useState(""),[s,o]=m.useState(!1),l=m.useCallback((d,u)=>{n(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=vO(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(D4,{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(Vi,{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(Vi,{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(Vi,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(Vi,{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(Vi,{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(P4,{errorMessage:r}),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 wO({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=oc();return n?i.jsx(fO,{}):r?i.jsx(yO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(mO,{onComplete:s}):i.jsx(bO,{})}const O4=m.createContext(null),M4=()=>{const e=m.useContext(O4);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},kO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},SO=()=>{const e=m.useRef(null),t=m.useRef(!1),n=m.useRef(!1),[r,a]=m.useState(null),[s,o]=m.useState(!1),l=m.useRef(null),{token:c}=oc(),d=m.useCallback(()=>{if(!t.current)try{const f=kO(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,n.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),n.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:r,isConnected:s}),[u,r,s])},CO=({children:e})=>{const t=SO();return i.jsx(O4.Provider,{value:t,children:e})},F4=m.createContext(null);function uc(){const e=m.useContext(F4);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function NO({children:e}){const{user:t,token:n,isLoading:r}=oc(),[a,s]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&n),p=m.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await Ee("/api/plugins");if(x.ok){const v=await x.json();s(v.plugins||[]),d(null)}else{let v=`Failed to fetch plugins (${x.status})`;try{const y=await x.json();v=y.details||y.error||v}catch{v=x.statusText||v}d(v)}}catch(x){const v=x instanceof Error?x.message:"Failed to fetch plugins";d(v),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{r||p()},[r,p]);const f=m.useCallback(async x=>{try{const v=await Ee("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Install failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const v=await Ee(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Uninstall failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const v=await Ee(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),y=await v.json();return v.ok?(await p(),{success:!0}):{success:!1,error:y.details||y.error||"Update failed"}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Update failed"}}},[p]),b=m.useCallback(async(x,v)=>{try{const y=await Ee(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:v})});if(!y.ok){let w=`Toggle failed (${y.status})`;try{const k=await y.json();w=k.details||k.error||w}catch{w=y.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Toggle failed"}}},[p]);return i.jsx(F4.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const ak=e=>typeof window>"u"?!1:window.innerWidth<e,ik=()=>{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 Og(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,s]=m.useState(()=>n?ak(t):!1),[o,l]=m.useState(()=>r?ik():!1);return m.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{s(ak(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,n]),m.useEffect(()=>{if(!r||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(ik())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[r]),{isMobile:a,isPWA:o}}const Mg="pixcode.updateCheck.preferences",rf="pixcode:update-check-settings-changed",Fg=[{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}],af={frequency:"30m"};function sk(e){return Fg.find(t=>t.value===e.frequency)?.intervalMs??null}function z4(e){if(!e||typeof e!="object")return af;const t=e.frequency;return Fg.some(n=>n.value===t)?{frequency:t}:af}function ok(){try{const e=localStorage.getItem(Mg);return z4(e?JSON.parse(e):null)}catch{return af}}function EO(e){const t=z4(e);localStorage.setItem(Mg,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(rf,{detail:t}))}const Op=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let a=0;a<Math.max(n.length,r.length);a++){const s=n[a]||0,o=r[a]||0;if(s!==o)return s-o}return 0},TO="1.53.14",Wd="pixcode:update-available",AO=360*60*1e3,Mp=new Map;function B4(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function jO(e,t){try{const n=localStorage.getItem(B4(e,t));if(!n)return null;const r=JSON.parse(n);return{fetchedAt:typeof r.fetchedAt=="number"?r.fetchedAt:null,latestVersion:typeof r.latestVersion=="string"?r.latestVersion:null,releaseInfo:r.releaseInfo??null,rateLimitedUntil:typeof r.rateLimitedUntil=="number"?r.rateLimitedUntil:void 0}}catch{return null}}function lk(e,t,n){localStorage.setItem(B4(e,t),JSON.stringify(n))}function RO(e,t){const n=`${e}/${t}`,r=Mp.get(n);if(r)return r;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(()=>{Mp.delete(n)});return Mp.set(n,a),a}const zg=(e,t)=>{const[n,r]=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(()=>ok()),[x,v]=m.useState(TO),y=m.useRef(null),w=m.useCallback(S=>{EO(S),b(S)},[]);m.useEffect(()=>{const S=()=>b(ok()),C=A=>{A.key===Mg&&S()};return window.addEventListener("storage",C),window.addEventListener(rf,S),()=>{window.removeEventListener("storage",C),window.removeEventListener(rf,S)}},[]),m.useEffect(()=>{let S=!1;const C=async()=>{try{const j=await(await fetch("/health",{cache:"no-store"})).json();if(S)return;(j.installMode==="npm"||j.installMode==="git")&&d(j.installMode),typeof j.version=="string"&&/^\d+\.\d+\.\d+/.test(j.version)&&v(j.version)}catch{}};C();const A=()=>{C()};return window.addEventListener("focus",A),()=>{S=!0,window.removeEventListener("focus",A)}},[]),m.useEffect(()=>{if(!x)return;let S=!1;const C=(E,I,N,O)=>({updateAvailable:!!(E&&Op(E,x)>0),latestVersion:E,releaseInfo:I,currentVersion:x,checkedAt:N,status:O}),A=E=>{!E.updateAvailable||!E.latestVersion||!E.releaseInfo||window.dispatchEvent(new CustomEvent(Wd,{detail:E}))},R=(E,I,N,O="success")=>{if(!E||!I)return r(!1),s(null),l(null),h(N),C(null,null,N,O);s(E),r(Op(E,x)>0),l(I),h(N);const B=C(E,I,N,O);return A(B),B},j=async({force:E=!1}={})=>{const I=sk(g),N=jO(e,t),O=Date.now();if(!E&&I===null)return p("idle"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");if(!E&&N?.fetchedAt&&I!==null&&O-N.fetchedAt<I)return p("success"),R(N.latestVersion,N.releaseInfo,N.fetchedAt,"success");if(!E&&N?.rateLimitedUntil&&N.rateLimitedUntil>O)return p("error"),R(N.latestVersion,N.releaseInfo,N.fetchedAt,"error");try{p("checking");const B=await RO(e,t);if(S)return C(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");const F=B.data;if(!B.ok)return B.status===403&&lk(e,t,{fetchedAt:N?.fetchedAt??null,latestVersion:N?.latestVersion??null,releaseInfo:N?.releaseInfo??null,rateLimitedUntil:O+Math.max(I??0,AO)}),p("error"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error");if(F.tag_name){const Y=F.tag_name.replace(/^v/,""),X=Op(Y,x)>0,P={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};lk(e,t,{fetchedAt:O,latestVersion:Y,releaseInfo:P}),s(Y),r(X),X&&QN({key:`app-update:${Y}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${Y}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:Y,installMode:c}}),l(P),p("success"),h(O);const U=C(Y,P,O,"success");return A(U),U}else return r(!1),s(null),l(null),p("error"),C(null,null,null,"error")}catch(B){return console.error("Version check failed:",B),p("error"),R(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error")}};y.current=j,j();const T=sk(g),L=T===null?null:window.setInterval(()=>{j()},T);return()=>{S=!0,L!==null&&window.clearInterval(L)}},[e,t,x,c,g]);const k=m.useCallback(async()=>y.current?await y.current({force:!0}):null,[]);return{updateAvailable:n,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:k,updateCheckPreferences:g,updatePreferences:w}},Wi={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat",autoShowAgentDiff:"always"},IO=["flat","grouped"],_O=e=>typeof e=="string"&&IO.includes(e),LO=["always","openOnly","off"],PO=e=>typeof e=="string"&&LO.includes(e),qd=Object.keys(Wi),DO=new Set(qd),Fp="ui-preferences:sync",OO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Kd=(e,t,n)=>e==="historyView"?_O(t)?t:n:e==="autoShowAgentDiff"?PO(t)?t:n:OO(t,n),MO=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return Kd(e,r,t)}catch{return t}},FO=e=>{if(typeof window>"u")return Wi;try{const t=localStorage.getItem(e);if(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;return qd.reduce((a,s)=>(a[s]=Kd(s,r[s],Wi[s]),a),{...Wi})}}}catch{}return qd.reduce((t,n)=>(t[n]=MO(n,Wi[n]),t),{...Wi})};function zO(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!DO.has(n))return e;const a=Kd(n,r,e[n]);return e[n]===a?e:{...e,[n]:a}}case"set_many":{const n=t.value||{};let r=!1;const a={...e};for(const s of qd){if(!(s in n))continue;const o=n[s],l=Kd(s,o,e[s]);a[s]!==l&&(a[s]=l,r=!0)}return r?a:e}case"reset":return{...Wi,...t.value||{}};default:return e}}function zu(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=m.useReducer(zO,e,FO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Fp,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||r({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(Fp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Fp,d)}},[e]),{preferences:n,setPreference:(l,c)=>{r({type:"set",key:l,value:c})},setPreferences:l=>{r({type:"set_many",value:l})},resetPreferences:l=>{r({type:"reset",value:l})},dispatch:r}}const BO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},UO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},$O=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},ck=(e,t)=>`${e}::${t}`,HO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},GO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},VO=/(?:^|[\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,WO=e=>{if(!e)return[];const t=new Set,n=new RegExp(VO.source,"gi");let r;for(;(r=n.exec(e))!==null;){const a=r[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]},Xi=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),qO=(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"),KO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),YO=(e,t,n)=>{const r=Xi(e),a=Math.floor((t.getTime()-r.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:qO(e,n),sessionTime:KO(e),messageCount:Number(e.messageCount||0)}},U4=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),r=(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[...n,...r,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>Xi(b).getTime()-Xi(g).getTime())},dk=(e,t)=>{const n=U4(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const s=Xi(a);return s>r?s:r},new Date(0))},ZO=(e,t,n,r)=>{const a=[...e];return a.sort((s,o)=>{const l=n.has(s.name),c=n.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?dk(o,r).getTime()-dk(s,r).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},XO=(e,t)=>{const n=t.trim().toLowerCase();return n?e.filter(r=>{const a=(r.displayName||r.name).toLowerCase(),s=r.name.toLowerCase();return a.includes(n)||s.includes(n)}):e},QO=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 JO({projects:e,selectedProject:t,selectedSession:n,isLoading:r,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),[v,y]=m.useState(!1),[w,k]=m.useState(""),[S,C]=m.useState({}),[A,R]=m.useState({}),[j,T]=m.useState(new Set),[L,E]=m.useState(new Date),[I,N]=m.useState("name"),[O,B]=m.useState(!1),[F,Y]=m.useState({}),[X,P]=m.useState(null),[U,H]=m.useState(""),[z,J]=m.useState(""),[ie,fe]=m.useState(new Set),[le,se]=m.useState(null),[ge,me]=m.useState(null),[Se,Ne]=m.useState(!1),[je,M]=m.useState(()=>UO()),[ue,de]=m.useState(()=>HO()),[V,K]=m.useState("projects"),[ne,ee]=m.useState(null),[ce,te]=m.useState(!1),[Ce,pe]=m.useState(null),q=m.useRef(null),G=m.useRef(0),ae=m.useRef(null),xe=!a&&!f;m.useEffect(()=>{const Me=setInterval(()=>{E(new Date)},6e4);return()=>clearInterval(Me)},[]),m.useEffect(()=>{R({}),T(new Set),Y({})},[e]),m.useEffect(()=>{t&&g(Me=>{if(Me.has(t.name))return Me;const We=new Set(Me);return We.add(t.name),We})},[n,t]),m.useEffect(()=>{if(e.length>0&&!r){const Me=new Set;e.forEach(We=>{We.sessions&&We.sessions.length>=0&&Me.add(We.name)}),T(Me)}},[e,r]),m.useEffect(()=>{const Me=()=>{N(BO())};Me();const We=et=>{et.key==="claude-settings"&&Me()},mt=()=>Me();return window.addEventListener("storage",We),window.addEventListener("pixcode:settings-changed",mt),()=>{window.removeEventListener("storage",We),window.removeEventListener("pixcode:settings-changed",mt)}},[]),m.useEffect(()=>{q.current&&clearTimeout(q.current),ae.current&&(ae.current.close(),ae.current=null);const Me=z.trim();if(V!=="conversations"||Me.length<2){G.current+=1,ee(null),pe(null),te(!1);return}te(!0);const We=++G.current;return q.current=setTimeout(()=>{if(We!==G.current)return;const mt=At.searchConversationsUrl(Me),et=new EventSource(mt);ae.current=et;const we=[];let ze=0;et.addEventListener("result",W=>{if(We!==G.current){et.close();return}try{const ye=JSON.parse(W.data);we.push(ye.projectResult),ze=ye.totalMatches,ee({results:[...we],totalMatches:ze,query:Me}),pe({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),et.addEventListener("progress",W=>{if(We!==G.current){et.close();return}try{const ye=JSON.parse(W.data);ze=ye.totalMatches,pe({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),et.addEventListener("done",()=>{if(We!==G.current){et.close();return}et.close(),ae.current=null,te(!1),pe(null),we.length===0&&ee({results:[],totalMatches:0,query:Me})}),et.addEventListener("error",()=>{if(We!==G.current){et.close();return}et.close(),ae.current=null,te(!1),pe(null),we.length===0&&ee({results:[],totalMatches:0,query:Me})})},400),()=>{q.current&&clearTimeout(q.current),ae.current&&(ae.current.close(),ae.current=null)}},[z,V]);const De=m.useCallback(Me=>{g(We=>{const mt=new Set;return We.has(Me)||mt.add(Me),mt})},[]),Ve=m.useCallback((Me,We)=>{c({...Me,__projectName:We})},[c]),Ze=m.useCallback(Me=>{M(We=>{const mt=new Set(We);return mt.has(Me)?mt.delete(Me):mt.add(Me),$O(mt),mt})},[]),ht=m.useCallback(Me=>je.has(Me),[je]),Qe=m.useCallback((Me,We)=>{de(mt=>{const et=ck(Me,We),we=new Set(mt);return we.has(et)?we.delete(et):we.add(et),GO(we),we})},[]),bt=m.useCallback((Me,We)=>ue.has(ck(Me,We)),[ue]),dt=m.useCallback(Me=>U4(Me,A),[A]),st=m.useMemo(()=>e.map(Me=>{const We=F[Me.name];return We===void 0?Me:{...Me,sessionMeta:{...Me.sessionMeta,hasMore:We}}}),[F,e]),pt=m.useMemo(()=>ZO(st,I,je,A),[A,I,st,je]),kt=m.useMemo(()=>XO(pt,z),[z,pt]),_t=m.useCallback(Me=>{x(Me.name),k(Me.displayName)},[]),Lt=m.useCallback(()=>{x(null),k("")},[]),gn=m.useCallback(async Me=>{try{(await At.renameProject(Me,w)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(We){console.error("Error renaming project:",We)}finally{x(null),k("")}},[w]),Yt=m.useCallback((Me,We,mt,et="claude")=>{me({projectName:Me,sessionId:We,sessionTitle:mt,provider:et})},[]),dn=m.useCallback(async()=>{if(!ge)return;const{projectName:Me,sessionId:We,provider:mt}=ge;me(null);try{let et;if(mt==="codex"?et=await At.deleteCodexSession(We):mt==="gemini"?et=await At.deleteGeminiSession(We):mt==="qwen"?et=await At.deleteQwenSession(We):et=await At.deleteSession(Me,We),et.ok)d?.(We);else{const we=await et.text();console.error("[Sidebar] Failed to delete session:",{status:et.status,error:we}),alert(s("messages.deleteSessionFailed"))}}catch(et){console.error("[Sidebar] Error deleting session:",et),alert(s("messages.deleteSessionError"))}},[d,ge,s]),bn=m.useCallback(Me=>{se({project:Me,sessionCount:dt(Me).length})},[dt]),Le=m.useCallback(async(Me=!1)=>{if(!le)return;const{project:We,sessionCount:mt}=le,et=mt===0;se(null),fe(we=>new Set([...we,We.name]));try{const we=await At.deleteProject(We.name,!et,Me);if(we.ok)u?.(We.name);else{const ze=await we.json();alert(ze.error||s("messages.deleteProjectFailed"))}}catch(we){console.error("Error deleting project:",we),alert(s("messages.deleteProjectError"))}finally{fe(we=>{const ze=new Set(we);return ze.delete(We.name),ze})}},[le,u,s]),Xe=m.useCallback(async Me=>{const We=F[Me.name];if(!(!(We!==void 0?We:Me.sessionMeta?.hasMore===!0)||S[Me.name])){C(et=>({...et,[Me.name]:!0}));try{const et=(Me.sessions?.length||0)+(A[Me.name]?.length||0),we=await At.sessions(Me.name,5,et);if(!we.ok)return;const ze=await we.json();R(W=>({...W,[Me.name]:[...W[Me.name]||[],...ze.sessions||[]]})),ze.hasMore===!1&&Y(W=>({...W,[Me.name]:!1}))}catch(et){console.error("Error loading more sessions:",et)}finally{C(et=>({...et,[Me.name]:!1}))}}},[A,S,F]),Re=m.useCallback(Me=>{l(Me)},[l]),$e=m.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),nt=m.useCallback(async(Me,We,mt,et)=>{const we=mt.trim();if(!we){P(null),H("");return}try{const ze=await At.renameSession(We,we,et);ze.ok?await o():(console.error("[Sidebar] Failed to rename session:",ze.status),alert(s("messages.renameSessionFailed")))}catch(ze){console.error("[Sidebar] Error renaming session:",ze),alert(s("messages.renameSessionError"))}finally{P(null),H("")}},[o,s]),xt=m.useCallback(()=>{p(!1)},[p]),Dt=m.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:xe,expandedProjects:h,editingProject:b,showNewProject:v,editingName:w,loadingSessions:S,additionalSessions:A,initialSessionsLoaded:j,currentTime:L,projectSortOrder:I,isRefreshing:O,editingSession:X,editingSessionName:U,searchFilter:z,deletingProjects:ie,deleteConfirmation:le,sessionDeleteConfirmation:ge,showVersionModal:Se,starredProjects:je,starredSessions:ue,filteredProjects:kt,toggleProject:De,handleSessionClick:Ve,toggleStarProject:Ze,isProjectStarred:ht,toggleStarSession:Qe,isSessionStarred:bt,getProjectSessions:dt,startEditing:_t,cancelEditing:Lt,saveProjectName:gn,showDeleteSessionConfirmation:Yt,confirmDeleteSession:dn,requestProjectDelete:bn,confirmDeleteProject:Le,loadMoreSessions:Xe,handleProjectSelect:Re,refreshProjects:$e,updateSessionSummary:nt,collapseSidebar:xt,expandSidebar:Dt,setShowNewProject:y,setEditingName:k,setEditingSession:P,setEditingSessionName:H,searchMode:V,setSearchMode:K,conversationResults:ne,isSearching:ce,searchProgress:Ce,clearConversationResults:m.useCallback(()=>{G.current+=1,ae.current&&(ae.current.close(),ae.current=null),te(!1),pe(null),ee(null)},[]),setSearchFilter:J,setDeleteConfirmation:se,setSessionDeleteConfirmation:me,setShowVersionModal:Ne}}const eM="https://discord.gg/buxwujPNRE",tM="https://github.com/alicomert/pixcode/issues/new";function nM({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 rM({onExpand:e,onOpenControlRoom:t,onShowSettings:n,updateAvailable:r,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(_u,{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(cr,{className:"h-4 w-4 text-primary"})}),i.jsx("button",{onClick:n,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(Ot,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:tM,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(Ul,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:eM,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(nM,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&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(cr,{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 $4(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=$4(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function H4(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=$4(e))&&(r&&(r+=" "),r+=t);return r}const uk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,pk=H4,Bg=(e,t)=>n=>{var r;if(t?.variants==null)return pk(e,n?.class,n?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=n?.[d],p=s?.[d];if(u===null)return null;const f=uk(u)||uk(p);return a[d][f]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.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 pk(e,o,c,n?.class,n?.className)},Ug="-",aM=e=>{const t=sM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(Ug);return l[0]===""&&l.length!==1&&l.shift(),G4(l,t)||iM(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},G4=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?G4(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Ug);return t.validators.find(({validator:o})=>o(s))?.classGroupId},mk=/^\[(.+)\]$/,iM=e=>{if(mk.test(e)){const t=mk.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},sM=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)sf(n[a],r,a,t);return r},sf=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:hk(t,a);s.classGroupId=n;return}if(typeof a=="function"){if(oM(a)){sf(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([s,o])=>{sf(o,hk(t,s),n,r)})})},hk=(e,t)=>{let n=e;return t.split(Ug).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},oM=e=>e.isThemeGetter,lM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const a=(s,o)=>{n.set(s,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return a(s,o),o},set(s,o){n.has(s)?n.set(s,o):a(s,o)}}},of="!",lf=":",cM=lf.length,dM=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=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===lf){s.push(a.slice(c,g)),c=g+cM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=uM(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+lf,s=r;r=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const a=r;r=s=>n({className:s,parseClassName:a})}return r},uM=e=>e.endsWith(of)?e.substring(0,e.length-1):e.startsWith(of)?e.substring(1):e,pM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const a=[];let s=[];return r.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},mM=e=>({cache:lM(e.cacheSize),parseClassName:dM(e),sortModifiers:pM(e),...aM(e)}),hM=/\s+/,fM=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(hM);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}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,v=r(x?g.substring(0,b):g);if(!v){if(!x){c=u+(c.length>0?" "+c:c);continue}if(v=r(g),!v){c=u+(c.length>0?" "+c:c);continue}x=!1}const y=s(f).join(":"),w=h?y+of:y,k=w+v;if(o.includes(k))continue;o.push(k);const S=a(v,x);for(let C=0;C<S.length;++C){const A=S[C];o.push(w+A)}c=u+(c.length>0?" "+c:c)}return c};function gM(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=V4(t))&&(r&&(r+=" "),r+=n);return r}const V4=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=V4(e[r]))&&(n&&(n+=" "),n+=t);return n};function bM(e,...t){let n,r,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return n=mM(d),r=n.cache.get,a=n.cache.set,s=l,l(c)}function l(c){const d=r(c);if(d)return d;const u=fM(c,n);return a(c,u),u}return function(){return s(gM.apply(null,arguments))}}const xn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},W4=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,q4=/^\((?:(\w[\w-]*):)?(.+)\)$/i,xM=/^\d+\/\d+$/,vM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yM=/\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$/,wM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,SM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Cs=e=>xM.test(e),vt=e=>!!e&&!Number.isNaN(Number(e)),Qa=e=>!!e&&Number.isInteger(Number(e)),zp=e=>e.endsWith("%")&&vt(e.slice(0,-1)),Sa=e=>vM.test(e),CM=()=>!0,NM=e=>yM.test(e)&&!wM.test(e),K4=()=>!1,EM=e=>kM.test(e),TM=e=>SM.test(e),AM=e=>!Ke(e)&&!Ye(e),jM=e=>jo(e,X4,K4),Ke=e=>W4.test(e),Di=e=>jo(e,Q4,NM),Bp=e=>jo(e,PM,vt),fk=e=>jo(e,Y4,K4),RM=e=>jo(e,Z4,TM),Dc=e=>jo(e,J4,EM),Ye=e=>q4.test(e),tl=e=>Ro(e,Q4),IM=e=>Ro(e,DM),gk=e=>Ro(e,Y4),_M=e=>Ro(e,X4),LM=e=>Ro(e,Z4),Oc=e=>Ro(e,J4,!0),jo=(e,t,n)=>{const r=W4.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ro=(e,t,n=!1)=>{const r=q4.exec(e);return r?r[1]?t(r[1]):n:!1},Y4=e=>e==="position"||e==="percentage",Z4=e=>e==="image"||e==="url",X4=e=>e==="length"||e==="size"||e==="bg-size",Q4=e=>e==="length",PM=e=>e==="number",DM=e=>e==="family-name",J4=e=>e==="shadow",OM=()=>{const e=xn("color"),t=xn("font"),n=xn("text"),r=xn("font-weight"),a=xn("tracking"),s=xn("leading"),o=xn("breakpoint"),l=xn("container"),c=xn("spacing"),d=xn("radius"),u=xn("shadow"),p=xn("inset-shadow"),f=xn("text-shadow"),h=xn("drop-shadow"),g=xn("blur"),b=xn("perspective"),x=xn("aspect"),v=xn("ease"),y=xn("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...k(),Ye,Ke],C=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],R=()=>[Ye,Ke,c],j=()=>[Cs,"full","auto",...R()],T=()=>[Qa,"none","subgrid",Ye,Ke],L=()=>["auto",{span:["full",Qa,Ye,Ke]},Qa,Ye,Ke],E=()=>[Qa,"auto",Ye,Ke],I=()=>["auto","min","max","fr",Ye,Ke],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...R()],F=()=>[Cs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],Y=()=>[e,Ye,Ke],X=()=>[...k(),gk,fk,{position:[Ye,Ke]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],U=()=>["auto","cover","contain",_M,jM,{size:[Ye,Ke]}],H=()=>[zp,tl,Di],z=()=>["","none","full",d,Ye,Ke],J=()=>["",vt,tl,Di],ie=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[vt,zp,gk,fk],se=()=>["","none",g,Ye,Ke],ge=()=>["none",vt,Ye,Ke],me=()=>["none",vt,Ye,Ke],Se=()=>[vt,Ye,Ke],Ne=()=>[Cs,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sa],breakpoint:[Sa],color:[CM],container:[Sa],"drop-shadow":[Sa],ease:["in","out","in-out"],font:[AM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sa],shadow:[Sa],spacing:["px",vt],text:[Sa],"text-shadow":[Sa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Cs,Ke,Ye,x]}],container:["container"],columns:[{columns:[vt,Ke,Ye,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:S()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:j()}],"inset-x":[{"inset-x":j()}],"inset-y":[{"inset-y":j()}],start:[{start:j()}],end:[{end:j()}],top:[{top:j()}],right:[{right:j()}],bottom:[{bottom:j()}],left:[{left:j()}],visibility:["visible","invisible","collapse"],z:[{z:[Qa,"auto",Ye,Ke]}],basis:[{basis:[Cs,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[vt,Cs,"auto","initial","none",Ke]}],grow:[{grow:["",vt,Ye,Ke]}],shrink:[{shrink:["",vt,Ye,Ke]}],order:[{order:[Qa,"first","last","none",Ye,Ke]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"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",n,tl,Di]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ye,Bp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zp,Ke]}],"font-family":[{font:[IM,Ke,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,Ye,Ke]}],"line-clamp":[{"line-clamp":[vt,"none",Ye,Bp]}],leading:[{leading:[s,...R()]}],"list-image":[{"list-image":["none",Ye,Ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ye,Ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Y()}],"text-color":[{text:Y()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:[vt,"from-font","auto",Ye,Di]}],"text-decoration-color":[{decoration:Y()}],"underline-offset":[{"underline-offset":[vt,"auto",Ye,Ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ye,Ke]}],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",Ye,Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:X()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:U()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qa,Ye,Ke],radial:["",Ye,Ke],conic:[Qa,Ye,Ke]},LM,RM]}],"bg-color":[{bg:Y()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:Y()}],"gradient-via":[{via:Y()}],"gradient-to":[{to:Y()}],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:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ie(),"hidden","none"]}],"divide-style":[{divide:[...ie(),"hidden","none"]}],"border-color":[{border:Y()}],"border-color-x":[{"border-x":Y()}],"border-color-y":[{"border-y":Y()}],"border-color-s":[{"border-s":Y()}],"border-color-e":[{"border-e":Y()}],"border-color-t":[{"border-t":Y()}],"border-color-r":[{"border-r":Y()}],"border-color-b":[{"border-b":Y()}],"border-color-l":[{"border-l":Y()}],"divide-color":[{divide:Y()}],"outline-style":[{outline:[...ie(),"none","hidden"]}],"outline-offset":[{"outline-offset":[vt,Ye,Ke]}],"outline-w":[{outline:["",vt,tl,Di]}],"outline-color":[{outline:Y()}],shadow:[{shadow:["","none",u,Oc,Dc]}],"shadow-color":[{shadow:Y()}],"inset-shadow":[{"inset-shadow":["none",p,Oc,Dc]}],"inset-shadow-color":[{"inset-shadow":Y()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Y()}],"ring-offset-w":[{"ring-offset":[vt,Di]}],"ring-offset-color":[{"ring-offset":Y()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":Y()}],"text-shadow":[{"text-shadow":["none",f,Oc,Dc]}],"text-shadow-color":[{"text-shadow":Y()}],opacity:[{opacity:[vt,Ye,Ke]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"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":[vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":Y()}],"mask-image-linear-to-color":[{"mask-linear-to":Y()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":Y()}],"mask-image-t-to-color":[{"mask-t-to":Y()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":Y()}],"mask-image-r-to-color":[{"mask-r-to":Y()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":Y()}],"mask-image-b-to-color":[{"mask-b-to":Y()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":Y()}],"mask-image-l-to-color":[{"mask-l-to":Y()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":Y()}],"mask-image-x-to-color":[{"mask-x-to":Y()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":Y()}],"mask-image-y-to-color":[{"mask-y-to":Y()}],"mask-image-radial":[{"mask-radial":[Ye,Ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":Y()}],"mask-image-radial-to-color":[{"mask-radial-to":Y()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":Y()}],"mask-image-conic-to-color":[{"mask-conic-to":Y()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:X()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:U()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ye,Ke]}],filter:[{filter:["","none",Ye,Ke]}],blur:[{blur:se()}],brightness:[{brightness:[vt,Ye,Ke]}],contrast:[{contrast:[vt,Ye,Ke]}],"drop-shadow":[{"drop-shadow":["","none",h,Oc,Dc]}],"drop-shadow-color":[{"drop-shadow":Y()}],grayscale:[{grayscale:["",vt,Ye,Ke]}],"hue-rotate":[{"hue-rotate":[vt,Ye,Ke]}],invert:[{invert:["",vt,Ye,Ke]}],saturate:[{saturate:[vt,Ye,Ke]}],sepia:[{sepia:["",vt,Ye,Ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Ye,Ke]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[vt,Ye,Ke]}],"backdrop-contrast":[{"backdrop-contrast":[vt,Ye,Ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",vt,Ye,Ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[vt,Ye,Ke]}],"backdrop-invert":[{"backdrop-invert":["",vt,Ye,Ke]}],"backdrop-opacity":[{"backdrop-opacity":[vt,Ye,Ke]}],"backdrop-saturate":[{"backdrop-saturate":[vt,Ye,Ke]}],"backdrop-sepia":[{"backdrop-sepia":["",vt,Ye,Ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ye,Ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[vt,"initial",Ye,Ke]}],ease:[{ease:["linear","initial",v,Ye,Ke]}],delay:[{delay:[vt,Ye,Ke]}],animate:[{animate:["none",y,Ye,Ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Ye,Ke]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:Se()}],"skew-x":[{"skew-x":Se()}],"skew-y":[{"skew-y":Se()}],transform:[{transform:[Ye,Ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],accent:[{accent:Y()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Y()}],"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",Ye,Ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ye,Ke]}],fill:[{fill:["none",...Y()]}],"stroke-w":[{stroke:[vt,tl,Di,Bp]}],stroke:[{stroke:["none",...Y()]}],"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"]}},MM=bM(OM);function ve(...e){return MM(H4(e))}function FM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const zM=Bg("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"}}),eE=m.forwardRef(({className:e,variant:t,...n},r)=>i.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:ve(zM({variant:t}),e),...n}));eE.displayName="Alert";const BM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"alert-title",className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));BM.displayName="AlertTitle";const UM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"alert-description",className:ve("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));UM.displayName="AlertDescription";const $M=Bg("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 yt({className:e,variant:t,...n}){return i.jsx("div",{className:ve($M({variant:t}),e),...n})}const HM=Bg("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"}}),Te=m.forwardRef(({className:e,variant:t,size:n,...r},a)=>i.jsx("button",{className:ve(HM({variant:t,size:n,className:e})),ref:a,...r}));Te.displayName="Button";const tE=m.createContext(null),nE=()=>{const e=m.useContext(tE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},rE=({className:e,approval:t="pending",children:n,...r})=>{const a=m.useMemo(()=>({approval:t}),[t]);return i.jsx(tE.Provider,{value:a,children:i.jsx(eE,{className:ve("flex flex-col gap-2",e),...r,children:n})})};rE.displayName="Confirmation";const aE=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:ve("text-muted-foreground inline text-sm",e),...t});aE.displayName="ConfirmationTitle";const iE=({children:e})=>{const{approval:t}=nE();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};iE.displayName="ConfirmationRequest";const sE=({className:e,...t})=>{const{approval:n}=nE();return n!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:ve("flex items-center justify-end gap-2 self-end",e),...t})};sE.displayName="ConfirmationActions";const Sd=({variant:e="default",...t})=>i.jsx(Te,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Sd.displayName="ConfirmationAction";const oE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));oE.displayName="Card";const lE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("flex flex-col space-y-1.5 p-4",e),...t}));lE.displayName="CardHeader";const cE=m.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:ve("font-semibold leading-none tracking-tight",e),...t}));cE.displayName="CardTitle";const GM=m.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:ve("text-sm text-muted-foreground",e),...t}));GM.displayName="CardDescription";const dE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("p-4 pt-0",e),...t}));dE.displayName="CardContent";const uE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("flex items-center p-4 pt-0",e),...t}));uE.displayName="CardFooter";const VM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("ml-auto shrink-0",e),...t}));VM.displayName="CardAction";const pE=m.createContext(null);function mE(){const e=m.useContext(pE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const bi=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,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),n?.(h)},[d,n]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(pE.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:r,...s,children:a})})});bi.displayName="Collapsible";const Fa=m.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:s,onOpenChange:o}=mE(),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:n,...r,children:t})});Fa.displayName="CollapsibleTrigger";const xi=m.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=mE();return i.jsx("div",{ref:r,"data-state":a?"open":"closed",className:ve("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...n,children:i.jsx("div",{className:"overflow-hidden",children:t})})});xi.displayName="CollapsibleContent";const hE=m.createContext(null);function $g(){const e=m.useContext(hE);if(!e)throw new Error("Command components must be used within <Command>");return e}const fE=m.forwardRef(({className:e,children:t,...n},r)=>{const[a,s]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(y=>{o.current.set(y.id,y),c(w=>w+1)},[]),u=m.useCallback(y=>{o.current.delete(y),c(w=>w+1)},[]),p=m.useCallback((y,w)=>{const k=o.current.get(y);k&&Object.assign(k,w)},[]),f=m.useMemo(()=>{const y=a.toLowerCase(),w=new Set;for(const[k,S]of o.current)(!y||S.value.includes(y))&&w.add(k);return w},[a,l]),h=m.useMemo(()=>{const y=[];for(const[,w]of o.current)f.has(w.id)&&y.push(w);return y},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(y=>{if(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter")y.preventDefault();else return;const w=h;if(w.length===0)return;if(y.key==="Enter"){w.find(j=>j.id===g)?.onSelect();return}const k=w.findIndex(R=>R.id===g);let S;y.key==="ArrowDown"?S=k<w.length-1?k+1:0:S=k>0?k-1:w.length-1;const C=w[S].id;b(C),w[S].element?.scrollIntoView({block:"nearest"})},[h,g]),v=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(hE.Provider,{value:v,children:i.jsx("div",{ref:r,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:ve("flex flex-col",e),onKeyDown:x,...n,children:t})})});fE.displayName="Command";const gE=m.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:s}=$g();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(Ma,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:r,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:ve("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),...n})]})});gE.displayName="CommandInput";const bE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,role:"listbox",className:ve("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));bE.displayName="CommandList";const xE=m.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=$g();return!r||a.size>0?null:i.jsx("div",{ref:n,className:ve("py-6 text-center text-sm text-muted-foreground",e),...t})});xE.displayName="CommandEmpty";const vE=m.forwardRef(({className:e,heading:t,children:n,...r},a)=>i.jsxs("div",{ref:a,className:ve("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...r,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),n]}));vE.displayName="CommandGroup";const yE=m.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=$g(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:n||(()=>{})})},[h,n,f]);const x=m.useCallback(y=>{g.current=y,f(h,{element:y}),typeof o=="function"?o(y):o&&(o.current=y)},[h,f,o]);if(!l.has(h))return null;const v=c===h;return i.jsx("div",{ref:x,role:"option","aria-selected":v,"aria-disabled":r||void 0,"data-active":v||void 0,className:ve("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",v&&"bg-accent text-accent-foreground",r&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!r&&c!==h&&d(h)},onClick:()=>!r&&n?.(),...s,children:a})});yE.displayName="CommandItem";const WM=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:ve("-mx-1 h-px bg-border",e),...t}));WM.displayName="CommandSeparator";function Yd({checked:e,onToggle:t,ariaLabel:n}){const{t:r}=Fe("settings"),{isDarkMode:a,toggleDarkMode:s}=qa(),o=typeof e=="boolean",l=o?e:a,c=n||r("quickSettings.darkMode",{defaultValue:"Toggle dark mode"}),d=()=>{if(o){t?.(!l);return}s()};return i.jsxs("button",{onClick:d,className:ve("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",l?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":l,"aria-label":c,children:[i.jsx("span",{className:"sr-only",children:c}),i.jsx("span",{className:ve("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",l?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:l?i.jsx(A4,{className:"h-3 w-3 text-primary"}):i.jsx(I4,{className:"h-3 w-3 text-white dark:text-background"})})]})}const wE=m.createContext(null);function kE(){const e=m.useContext(wE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const SE=({open:e,onOpenChange:t,defaultOpen:n=!1,children:r})=>{const[a,s]=m.useState(n),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(wE.Provider,{value:u,children:r})},qM=m.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:s,triggerRef:o}=kE(),l=m.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(n&&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,...r,children:t})});qM.displayName="DialogTrigger";const bk='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Hg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=kE(),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(),n?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(bk));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,n]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(bk)?.focus()})},[o]),o?Au.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:()=>{r?.(),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:ve("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});Hg.displayName="DialogContent";const Gg=m.forwardRef(({className:e,...t},n)=>i.jsx("h2",{ref:n,className:ve("sr-only",e),...t}));Gg.displayName="DialogTitle";const qe=m.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:ve("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:r,...n}));qe.displayName="Input";const Vg=m.forwardRef(({className:e,contentClassName:t,children:n,...r},a)=>i.jsx("div",{className:ve("relative overflow-hidden",e),...r,children:i.jsx("div",{ref:a,className:ve("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:n})}));Vg.displayName="ScrollArea";const Zd=m.memo(({children:e,className:t,as:n="span"})=>i.jsx(n,{className:ve("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}));Zd.displayName="Shimmer";const CE=m.createContext(null),KM=()=>{const e=m.useContext(CE);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},YM=1e3,ZM=1e3,cf=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:s,children:o,...l})=>{const c=r??t,d=r===!1,[u,p]=m.useState(c),f=n!==void 0,h=f?n:u,g=m.useCallback(C=>{f||p(C),a?.(C)},[f,a]),[b,x]=m.useState(s),v=m.useRef(t),[y,w]=m.useState(!1),k=m.useRef(null);m.useEffect(()=>{s!==void 0&&x(s)},[s]),m.useEffect(()=>{t?(v.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/ZM)),k.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(v.current&&!t&&h&&!y){const C=setTimeout(()=>{g(!1),w(!0)},YM);return()=>clearTimeout(C)}},[t,h,g,y]);const S=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return i.jsx(CE.Provider,{value:S,children:i.jsx(bi,{open:h,onOpenChange:g,className:ve("not-prose",e),...l,children:o})})});cf.displayName="Reasoning";const XM=(e,t)=>e||t===0?i.jsx(Zd,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),df=m.memo(({className:e,children:t,getThinkingMessage:n=XM,...r})=>{const{isStreaming:a,isOpen:s,duration:o}=KM();return i.jsx(Fa,{className:ve("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...r,children:t??i.jsxs(i.Fragment,{children:[i.jsx(BD,{className:"h-4 w-4"}),n(a,o),i.jsx(d4,{className:ve("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});df.displayName="ReasoningTrigger";const uf=m.memo(({className:e,children:t,...n})=>i.jsx(xi,{className:ve("mt-4 text-sm text-muted-foreground",e),...n,children:t}));uf.displayName="ReasoningContent";function QM(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 pf({children:e,content:t,position:n="top",className:r="",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 k=w.getBoundingClientRect(),S=8,C={position:"fixed",zIndex:9999};switch(n){case"bottom":C.left=k.left+k.width/2,C.top=k.bottom+S,C.transform="translateX(-50%)";break;case"left":C.left=k.left-S,C.top=k.top+k.height/2,C.transform="translate(-100%, -50%)";break;case"right":C.left=k.right+S,C.top=k.top+k.height/2,C.transform="translateY(-50%)";break;case"top":default:C.left=k.left+k.width/2,C.top=k.top-S,C.transform="translate(-50%, -100%)";break}f(C)},[n]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},v=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},y=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!s||typeof document>"u")return;const w=k=>{const S=k.target;S instanceof Node&&d.current?.contains(S)||(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),k=()=>h();return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[s,h]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:v,onTouchEnd:y,onTouchCancel:y,children:[e,s&&typeof document<"u"&&Au.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:ve("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",r),children:[t,i.jsx("div",{className:ve("absolute w-0 h-0 border-4 border-transparent",QM(n))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const NE=m.createContext(null),EE=m.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const s=m.useMemo(()=>({status:t}),[t]);return i.jsx(NE.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:ve("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),...r,children:n})})});EE.displayName="PromptInput";const TE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:ve("px-3 pt-3",e),...t}));TE.displayName="PromptInputHeader";const AE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:ve("relative",e),...t}));AE.displayName="PromptInputBody";const jE=m.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{ref:n,"data-slot":"prompt-input-textarea",className:ve("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}));jE.displayName="PromptInputTextarea";const RE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-footer",className:ve("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));RE.displayName="PromptInputFooter";const IE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"prompt-input-tools",className:ve("flex items-center gap-1",e),...t}));IE.displayName="PromptInputTools";const Cd=m.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const s=i.jsx(Te,{ref:a,type:"button",variant:"ghost",size:"icon",className:ve("h-8 w-8 [&_svg]:size-4",e),...r,children:n});return t?i.jsx(pf,{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});Cd.displayName="PromptInputButton";const _E=m.forwardRef(({className:e,status:t,children:n,...r},a)=>{const s=m.useContext(NE),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(Te,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:ve("h-8 w-8 rounded-lg",e),...r,children:n??(l?i.jsx(Pu,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(ND,{className:"h-4 w-4"}))})});_E.displayName="PromptInputSubmit";function Bu({children:e,className:t}){return i.jsx("div",{className:ve("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Uu({isActive:e,onClick:t,children:n,className:r}){return i.jsx("button",{onClick:t,className:ve("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",r),children:n})}const LE=m.createContext(null);function PE(){const e=m.useContext(LE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const DE=m.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:ve("space-y-0.5",e),...t}));DE.displayName="Queue";const OE=m.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const s=m.useMemo(()=>({status:e}),[e]);return i.jsx(LE.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:ve("flex items-start gap-2 py-0.5",t),...r,children:n})})});OE.displayName="QueueItem";const ME=m.forwardRef(({className:e,...t},n)=>{const{status:r}=PE();return i.jsxs("div",{ref:n,"data-slot":"queue-item-indicator","aria-hidden":"true",className:ve("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[r==="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"})}),r==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),r==="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})})]})});ME.displayName="QueueItemIndicator";const FE=m.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=PE();return i.jsx("div",{ref:r,"data-slot":"queue-item-content",className:ve("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),...n,children:t})});FE.displayName="QueueItemContent";const xk="https://github.com/alicomert/pixcode/issues/new",JM="https://github.com/alicomert/pixcode",vk="https://discord.gg/buxwujPNRE";function yk({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 e9({updateAvailable:e,releaseInfo:t,latestVersion:n,currentVersion:r,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(Kw,{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${n}`}),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(Kw,{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${n}`}),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:xk,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(Ul,{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:vk,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(yk,{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(cr,{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(Ot,{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:JM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",r," – ",l("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:xk,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(Ul,{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:vk,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(yk,{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(cr,{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(Ot,{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 wk="PIXCODE_GITHUB_STARS",kk="PIXCODE_HIDE_GITHUB_STAR",t9=3600*1e3,n9=(e,t)=>{const[n,r]=m.useState(null),[a,s]=m.useState(()=>{try{return localStorage.getItem(kk)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(wk);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<t9){r(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"){r(p);try{localStorage.setItem(wk,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{s(!0);try{localStorage.setItem(kk,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},r9="https://github.com/alicomert/pixcode";function a9({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 i9(){const{formattedCount:e,isDismissed:t,dismiss:n}=n9("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:r9,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(a9,{className:"h-3.5 w-3.5"}),i.jsx(_a,{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:r=>{r.preventDefault(),r.stopPropagation(),n()},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(wt,{className:"h-2.5 w-2.5"})})]})}function Sk({value:e,onChange:t,t:n}){const r="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":n("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:ve(r,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(k4,{className:"h-3 w-3"}),n("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:ve(r,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(jD,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function s9({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,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 v=()=>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(v,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(Te,{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(Te,{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(Te,{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(Iu,{className:"h-4 w-4"})})]})]}),i.jsx(i9,{}),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(cr,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),r>0&&!n&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Sk,{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:ve("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(Un,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ve("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(Tr,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Ma,{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(qe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:y=>s(y.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(wt,{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(v,{}),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(gi,{className:"h-4 w-4"})})]})]}),r>0&&!n&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Sk,{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:ve("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(Un,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ve("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(Tr,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Ma,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(qe,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:y=>s(y.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(wt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const o9=160,Ck=180;function zE({actions:e,className:t,triggerLabel:n}){const[r,a]=m.useState(!1),[s,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!r||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-o9;p<8&&(p=8);let f=u.bottom+4;f+Ck>window.innerHeight&&(f=Math.max(8,u.top-4-Ck)),o({top:f,left:p})},[r]),m.useEffect(()=>{if(!r)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)}},[r]);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":r,"aria-label":n||"Actions",title:n||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:ve("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",r&&"bg-accent text-foreground opacity-100",t),children:i.jsx(N4,{className:"h-3.5 w-3.5"})}),r&&s&&Au.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:ve("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:ve("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 l9=(e,t,n)=>{const r=new Date(e),a=t;if(isNaN(r.getTime()))return n?n("status.unknown"):"Unknown";const s=a.getTime()-r.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?n?n("time.justNow"):"Just now":l===1?n?n("time.oneMinuteAgo"):"1 min ago":l<60?n?n("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?n?n("time.oneHourAgo"):"1 hour ago":c<24?n?n("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?n?n("time.oneDayAgo"):"1 day ago":d<7?n?n("time.daysAgo",{count:d}):`${d} days ago`:r.toLocaleDateString()};function Nk({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:s,className:o}){const l=d=>i.jsx(_a,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:S4,onClick:n},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:r}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:An,onClick:a,danger:!0}),i.jsx(zE,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const c9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Ek={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 BE({project:e,session:t,selectedSession:n,currentTime:r,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 v=YO(t,r,x),y=n?.id===t.id,w=a===t.id,k=t.__provider,S=c9[k]??k,C=Ek[k]??Ek.claude,A=WO(v.sessionName),R=()=>{h(e),g(t,e.name)},j=()=>{p(e.name,t.id,s,k)},T=()=>{b(e.name,t.id,v.sessionName,k)},L=()=>d(t.id,v.sessionName),E=()=>f(e.name,t.id),I=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:ve("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",C),children:[i.jsx(nn,{provider:k,className:"h-2.5 w-2.5"}),S]}),i.jsx("span",{className:"text-muted-foreground/80",children:l9(v.sessionTime,r,x)}),v.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"})]}),A.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))]}),N=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"?j():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(),j()},title:x("tooltips.save"),children:i.jsx(Wt,{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(wt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),O=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ve("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",y&&"border-primary/30 bg-primary/5 shadow-sm",!y&&v.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!y&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:R,children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:ve("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",y?"bg-primary/10":"bg-muted/60"),children:i.jsx(nn,{provider:k,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:v.sessionName})]}),I]}),i.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:i.jsx(Nk,{isStarred:o,canDelete:!v.isCursorSession,onRename:L,onToggleStar:E,onDelete:T,t:x,className:"!opacity-100"})})]})})}),B=i.jsxs("div",{className:ve("group/item relative hidden md:block"),children:[i.jsxs(Te,{variant:"ghost",className:ve("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",y&&"bg-accent text-accent-foreground",o&&!y&&"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:[y&&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"}),!y&&!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:ve("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",y?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:i.jsx(nn,{provider:k,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:N}):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:v.sessionName})]}),I]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:i.jsx(Nk,{isStarred:o,canDelete:!v.isCursorSession,onRename:L,onToggleStar:E,onDelete:T,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[O,B]})}const d9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function u9(){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 p9({project:e,isExpanded:t,sessions:n,selectedSession:r,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:v,onLoadMoreSessions:y,onNewSession:w,onOpenOrchestration:k,t:S}){const[C,A]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let T=!1;const L=async()=>{const I=await Ee(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const N=await I.json();T||A((N.runs??[]).slice(0,5))};L();const E=window.setInterval(()=>{L()},15e3);return()=>{T=!0,window.clearInterval(E)}},[t,e.name]),!t)return null;const R=n.length>0,j=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"}),S("sessions.newSession")]})}),i.jsxs(Te,{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"}),S("sessions.newSession")]}),C.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(Ar,{className:"h-3 w-3"}),S("orchestration.section")]}),C.map(T=>{const L=[...new Set(T.nodeRuns.map(E=>d9(E.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>k?.(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(Ar,{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||S("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[L.slice(0,4).map(E=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(nn,{provider:E,className:"h-3 w-3"})},E)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:S(`common:orchestration.status.${T.status}`,{defaultValue:T.status})})]})]})]})},T.id)})]}),a?!R&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:S("sessions.noSessions")})}):n.map(T=>i.jsx(BE,{project:e,session:T,selectedSession:r,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:v,t:S},T.id)):i.jsx(u9,{}),R&&j&&i.jsx(Te,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>y(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"}),S("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Fr,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const m9=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function h9({project:e,selectedProject:t,selectedSession:n,isExpanded:r,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:v,onToggleStarProject:y,onToggleStarSession:w,onStartEditingProject:k,onCancelEditingProject:S,onSaveProjectName:C,onDeleteProject:A,onSessionSelect:R,onDeleteSession:j,onLoadMoreSessions:T,onNewSession:L,onOpenOrchestration:E,onEditingSessionNameChange:I,onStartEditingSession:N,onCancelEditingSession:O,onSaveEditingSession:B,t:F}){const Y=t?.name===e.name,X=o===e.name,P=e.sessionMeta?.hasMore===!0,U=m9(c,P),H=`${U} session${c.length===1?"":"s"}`,z=()=>x(e.name),J=()=>y(e.name),ie=()=>{C(e.name)},fe=()=>{t?.name!==e.name&&v(e),z()};return i.jsxs("div",{className:ve("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:ve("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",Y&&"bg-primary/5 border-primary/20",s&&!Y&&"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:ve("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",r?"bg-primary/10":"bg-muted"),children:r?i.jsx(Er,{className:"h-4 w-4 text-primary"}):i.jsx(Un,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:X?i.jsx("input",{type:"text",value:l,onChange:le=>b(le.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:le=>le.stopPropagation(),onKeyDown:le=>{le.key==="Enter"&&ie(),le.key==="Escape"&&S()},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:X?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:le=>{le.stopPropagation(),ie()},children:i.jsx(Wt,{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:le=>{le.stopPropagation(),S()},children:i.jsx(wt,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:ve("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:le=>{le.stopPropagation(),J()},title:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(_a,{className:ve("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:le=>{le.stopPropagation(),A(e)},children:i.jsx(An,{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:le=>{le.stopPropagation(),k(e)},children:i.jsx(Yh,{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:r?i.jsx(Fr,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(ma,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(Te,{variant:"ghost",className:ve("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",Y&&"bg-accent text-accent-foreground",s&&!Y&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:fe,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?i.jsx(Er,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Un,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:X?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:le=>b(le.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:le=>{le.key==="Enter"&&ie(),le.key==="Escape"&&S()}}),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:[U,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:X?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:le=>{le.stopPropagation(),ie()},children:i.jsx(Wt,{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:le=>{le.stopPropagation(),S()},children:i.jsx(wt,{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:le=>{le.stopPropagation(),J()},title:F("tooltips.removeFromFavorites"),children:i.jsx(_a,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(zE,{triggerLabel:F("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:F("actions.rename"),icon:Yh,onClick:()=>k(e)},{id:"star",label:F(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:_a,onClick:J},{id:"delete",label:F("actions.delete",{defaultValue:"Delete"}),icon:An,onClick:()=>A(e),danger:!0}]}),r?i.jsx(Fr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(ma,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(p9,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:g,onEditingSessionNameChange:I,onStartEditingSession:N,onCancelEditingSession:O,onSaveEditingSession:B,onToggleStarSession:w,onProjectSelect:v,onSessionSelect:R,onDeleteSession:j,onLoadMoreSessions:T,onNewSession:L,onOpenOrchestration:E,t:F})]})}function UE({isLoading:e,loadingProgress:t,projectsCount:n,filteredProjectsCount:r,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")})]}):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(Un,{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")})]}):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(Ma,{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 f9({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,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:v,onEditingNameChange:y,onToggleProject:w,onProjectSelect:k,onToggleStarProject:S,onToggleStarSession:C,onStartEditingProject:A,onCancelEditingProject:R,onSaveProjectName:j,onDeleteProject:T,onSessionSelect:L,onDeleteSession:E,onLoadMoreSessions:I,onNewSession:N,onOpenOrchestration:O,onEditingSessionNameChange:B,onStartEditingSession:F,onCancelEditingSession:Y,onSaveEditingSession:X,t:P}){const U=i.jsx(UE,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:P});m.useEffect(()=>{let le="Pixcode";const se=n?.displayName?.trim();se&&(le=`${se} - ${le}`),document.title=le},[n]);const H=!a&&e.length>0&&t.length>0,z=le=>le.source==="history"||le.autoDiscovered===!0&&le.isManuallyAdded!==!0,J=t.filter(le=>!z(le)),ie=t.filter(le=>z(le)),fe=le=>i.jsx(h9,{project:le,selectedProject:n,selectedSession:r,isExpanded:o.has(le.name),isDeleting:g.has(le.name),isStarred:x(le.name),editingProject:l,editingName:c,sessions:b(le),initialSessionsLoaded:u.has(le.name),isLoadingSessions:!!d[le.name],currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:v,onEditingNameChange:y,onToggleProject:w,onProjectSelect:k,onToggleStarProject:S,onToggleStarSession:C,onStartEditingProject:A,onCancelEditingProject:R,onSaveProjectName:j,onDeleteProject:T,onSessionSelect:L,onDeleteSession:E,onLoadMoreSessions:I,onNewSession:N,onOpenOrchestration:O,onEditingSessionNameChange:B,onStartEditingSession:F,onCancelEditingSession:Y,onSaveEditingSession:X,t:P},le.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:H?i.jsxs(i.Fragment,{children:[J.map(le=>fe(le)),ie.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:P("projects.detectedFromHistory")}),ie.map(le=>fe(le))]})]}):U})}function Ea(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $E(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
  *