@pixelbyte-software/pixcode 1.46.4 → 1.46.5
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.
|
@@ -226,7 +226,7 @@ import{j as s,a as mN,R as Wf,o as Kf,_ as t_,b as r_,m as hN,E as Pn,T as fN,P
|
|
|
226
226
|
*
|
|
227
227
|
* This source code is licensed under the ISC license.
|
|
228
228
|
* See the LICENSE file in the root directory of this source tree.
|
|
229
|
-
*/const ZP=[["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"}]],XP=wt("workflow",ZP),eg=UN,JN=DR,Nw=IR,JP=GR,QP=kR,tg=TR,eD=BN,qr=HN,tD=C7,rg=y7,On=w7,rD=S7,Lr=jR,ca=BN,jd=LR,QN=CR,nD=h7,aD=g7,ng=MR,it=$N,Mt=$N,hu=UR,eC=zR,sD=D8,Ln=J7,Er=e8,nr=p7,Mn=d7,tC=v8,Ir=aL,fu=WN,iD=WN,_d=t7,to=j7,rC=T7,Xl=VN,bl=P7,ro=H7,Vt=q7,Wn=p8,Ra=l8,ps=d8,oD=$8,lD=x8,_l=C8,Jl=J8,cD=VR,Ql=n7,dD=yL,uD=Qf,pD=Qf,yh=z8,nC=h8,mD=i8,hD=cL,fD=Z8,gD=I8,aC=M8,vh=Qf,ag=H8,Gt=q8,Tr=wL,bD=K7,da=j8,St=KN,wh=KN,gu=mL,sg=XR,xD=YR,kh=WR,yD=Z7,ua=GN,vD=GN,wD=SL,Ws=CL,kD=o7,Il=s7,ig=R7,si=a8,og=r8,kn=g8,sC=VN,bo=qN,SD=qN,iC=S8,mn=T8,lg=L8,cg=B7,oC=bL,ND=K8,ec=rL,CD=eL,Dt=O7,ED=xR,tc=$7,Wr=oL,$i=uL,dg=fL,Jr=F7,bu=QR,TD=DL,rc=UL,ug=ZN,AD=ZN,Or=NP,dd=EP,jD=AP,gi=LL,bi=ML,_D=zL,nl=GL,Gi=VL,Cw=ZL,al=JL,Uo=rP,ID=aP,lC=gP,Sh=iP,ns=dP,$o=lP,Ew=pP,Go=hP,Nh=xP,RD=vP,Ch=kP,Oi=RP,sl=PP,qa=OP,xi=FP,LD=BP,Eh=$P,PD=VP,Ho=YP,Sn=XP,Rl=KL,cC=eP,DD=_P,OD=WP,MD=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],FD={up:JN,down:eg,left:QP,right:tg},Vo=e=>e.preventDefault(),Tw="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",zD="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 Aw({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Pe("settings"),[i,o]=m.useState(!1),[l,c]=m.useState(!1),d=m.useCallback(h=>{Vs(e.current,{type:"input",data:h})},[e]),u=m.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=m.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const h=await navigator.clipboard.readText();h.length>0&&d(h)}catch{}},[d]),f=m.useCallback(h=>{let g=h;if(i&&h.length===1){const b=h.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&h.length===1&&(g="\x1B"+g,c(!1)),d(g)},[i,l,d]);return s.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:s.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:[s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>{p()},disabled:!r,className:dp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(to,{className:"h-4 w-4"})}),MD.map(h=>{if(h.type==="modifier"){const g=h.modifier==="ctrl"?i:l,b=h.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:b,disabled:!r,className:g?zD:Tw,children:h.label},h.id)}if(h.type==="arrow"){const g=FD[h.icon];return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>d(h.sequence),disabled:!r,className:dp,children:s.jsx(g,{className:"h-4 w-4"})},h.id)}return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>f(h.sequence),disabled:!r,className:Tw,children:h.label},h.id)}),s.jsx("button",{type:"button",onPointerDown:Vo,onClick:u,disabled:!r,className:dp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(eD,{className:"h-4 w-4"})})]})})}function dC({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:i=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=Pe("chat"),[d,u]=m.useState(!1),[p,f]=m.useState(null),h=m.useRef(null),g=m.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:k,authUrl:N,authUrlVersion:S,connectToShell:j,disconnectFromShell:_,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:E}=pR({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),R=m.useCallback(()=>{const G=x.current;if(!G)return;const B=G.buffer.active,Q=B.baseY+B.cursorY,J=Math.min(B.baseY+B.length-1,Q+10),me=Math.max(0,Q-VI),fe=[];for(let Y=me;Y<=J;Y++){const xe=B.getLine(Y);xe&&fe.push(xe.translateToString().trimEnd())}let oe=-1;for(let Y=fe.length-1;Y>=0;Y--)if(/esc to cancel/i.test(fe[Y])||/enter to select/i.test(fe[Y])){oe=Y;break}if(oe===-1){f(null);return}const he=new Map,ce=Math.max(0,oe-qI);for(let Y=oe-1;Y>=ce;Y--){const xe=fe[Y].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(xe){const D=xe[1],le=xe[2].trim();parseInt(D,10)<=WI&&le.length>0&&!he.has(D)&&he.set(D,le)}}const we=[];for(let Y=1;Y<=he.size&&he.has(String(Y));Y++)we.push({number:String(Y),label:he.get(String(Y))});f(we.length>=KI?we:null)},[x]),T=m.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(R,HI)},[R]);m.useEffect(()=>{g.current=T},[T]),m.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),m.useEffect(()=>{v||(h.current&&(clearTimeout(h.current),h.current=null),f(null))},[v]),m.useEffect(()=>{if(!l||!w||!v)return;const G=()=>{x.current?.focus()},B=window.requestAnimationFrame(G),Q=window.setTimeout(G,0);return()=>{window.cancelAnimationFrame(B),window.clearTimeout(Q)}},[l,v,w,x]);const I=m.useCallback(G=>{Vs(y.current,{type:"input",data:G})},[y]),C=m.useMemo(()=>lR(t),[t]),F=m.useMemo(()=>C?C.slice(0,30):null,[C]),q=m.useMemo(()=>C?C.slice(0,50):null,[C]),z=m.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},$I)},[]);if(!e)return s.jsx(hR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(gR,{terminalContainerRef:b,authUrl:N,authUrlVersion:S,initialCommand:r,isConnected:v,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:E}),s.jsx(Aw,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const H=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:q}):c("shell.startSession"),$=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),P=w?k?"connecting":v?null:"connect":"loading",V=P==="connecting"?$:H;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(fR,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:F,onDisconnect:_,onRestart:z,statusNewSessionText:c("shell.status.newSession"),statusInitializingText:c("shell.status.initializing"),statusRestartingText:c("shell.status.restarting"),disconnectLabel:c("shell.actions.disconnect"),disconnectTitle:c("shell.actions.disconnectTitle"),restartLabel:c("shell.actions.restart"),restartTitle:c("shell.actions.restartTitle"),disableRestart:d||v}),s.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[s.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),P&&s.jsx(mR,{mode:P,description:V,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:j}),p&&v&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:G=>G.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(G=>s.jsxs("button",{type:"button",onClick:()=>{I(G.number),f(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:`${G.number}. ${G.label}`,children:[G.number,". ",G.label]},G.number)),s.jsx("button",{type:"button",onClick:()=>{I("\x1B"),f(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"})]})})]}),s.jsx(Aw,{wsRef:y,terminalRef:x,isConnected:v})]})}function BD({className:e}){return s.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.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:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),s.jsx("p",{children:"A project is required to open a shell"})]})})}function UD({title:e,isCompleted:t,onClose:r=null}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&s.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&s.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function uC({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:i=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1}){const[h,g]=m.useState(!1),b=n!==null?n:r!==null,x=m.useCallback(y=>{g(!0),o?.(y)},[o]);return e?s.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&s.jsx(UD,{title:c,isCompleted:h,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(dC,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:i})})]}):s.jsx(BD,{className:d})}const $D=(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"),GD={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:r}){return s.jsx("button",{onClick:r,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function HD({provider:e}){const[t,r]=m.useState(""),[n,a]=m.useState(!1),[i,o]=m.useState("idle"),[l,c]=m.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await Se(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return s.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[s.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",s.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."]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"url",value:t,onChange:u=>r(u.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:u=>{u.key==="Enter"&&d()}}),s.jsx("button",{onClick:()=>void d(),disabled:n||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:n?s.jsx(Mt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),i==="ok"&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx(nr,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),i==="error"&&l&&s.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function VD({provider:e,onSaved:t}){const r=GD[e],[n,a]=m.useState(""),[i,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState("idle"),[p,f]=m.useState(null);m.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await Se("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await Se(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&i.trim()?i.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);u("ok"),a(""),t()}catch(b){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:s.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:s.jsx(SD,{className:"h-5 w-5 text-foreground"})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),s.jsxs("a",{href:r.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",r.keyConsoleLabel,s.jsx(Lr,{className:"h-3 w-3"})]})]})]}),r.notes&&s.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),s.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",s.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",s.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),s.jsx("input",{type:"url",value:i,onChange:g=>o(g.target.value),placeholder:r.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.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."})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[s.jsxs("button",{onClick:()=>void h(),disabled:l||!n.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?s.jsx(Mt,{className:"h-4 w-4 animate-spin"}):s.jsx(nr,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&s.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):s.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function pC({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:i=!1}){const{t:o}=Pe("common"),l=r!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=m.useMemo(()=>`${jl[r]??r} Login`,[r]);if(!e)return null;const p=$D(r,a),f=h=>n?.(h);return s.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:s.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:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),s.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:s.jsx(St,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(jw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(jw,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),s.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(uC,{project:TI,command:p,onComplete:f,minimal:!0})}),s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(HD,{provider:r})})]}):s.jsx(VD,{provider:r,onSaved:()=>f(0)})})]})})}const qD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),WD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},KD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},YD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),ZD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:r,alt:"OpenCode",className:e})},XD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function pr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(KD,{className:t}):e==="codex"?s.jsx(WD,{className:t}):e==="gemini"?s.jsx(YD,{className:t}):e==="qwen"?s.jsx(XD,{className:t}):e==="opencode"?s.jsx(ZD,{className:t}):s.jsx(qD,{className:t})}function JD({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:i,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return s.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:s.jsx(pr,{provider:e,className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&s.jsx(nr,{className:"h-4 w-4 text-green-500"})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&s.jsx("button",{onClick:o,className:`${i} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const QD=[{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 eO({providerStatuses:e,onOpenProviderLogin:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),s.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),s.jsx("div",{className:"space-y-3",children:QD.map(r=>s.jsx(JD,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),s.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:s.jsx("p",{children:"You can configure these later in Settings."})})]})}function tO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.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:s.jsx(Or,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),s.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(wD,{className:"h-4 w-4"}),"Git Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",id:"gitName",value:e,onChange:i=>n(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:r}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(yD,{className:"h-4 w-4"}),"Git Email ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:i=>a(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:r}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const _w=[{title:"Git Configuration",icon:Or,required:!0},{title:"Connect Agents",icon:QN,required:!1},{title:"Task System",icon:Jl,required:!1}];function rO({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:_w.map((t,r)=>{const n=r<e,a=r===e,i=t.icon;return s.jsxs("div",{className:"contents",children:[s.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[s.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:n?s.jsx(nr,{className:"h-6 w-6"}):s.jsx(i,{className:"h-6 w-6"})}),s.jsxs("div",{className:"mt-2 text-center",children:[s.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&s.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<_w.length-1&&s.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const nO=e=>e?e.installation?.isInstalled?e.installation.version?`TaskMaster CLI installed (${e.installation.version}).`:"TaskMaster CLI installed.":e.installation?.reason||"TaskMaster CLI is not installed yet.":"Checking TaskMaster installation...";function aO({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=m.useState(null),[i,o]=m.useState(!0),[l,c]=m.useState(!1),[d,u]=m.useState([]),[p,f]=m.useState(""),h=m.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=m.useMemo(()=>!e||g,[e,g]);m.useEffect(()=>{r(x)},[r,x]);const y=m.useCallback(async()=>{o(!0),f("");try{const w=await Se("/api/taskmaster/installation-status"),k=await w.json();a(k),w.ok||f(k.installation?.reason||"TaskMaster status check failed.")}catch(w){a(null),f(w instanceof Error?w.message:"TaskMaster status check failed.")}finally{o(!1)}},[]);m.useEffect(()=>(y(),()=>{h.current?.close(),h.current=null}),[y]);const v=m.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await Se("/api/taskmaster/install",{method:"POST"}),k=await w.json();if(!w.ok||!k.success||!k.jobId)throw new Error(k.error||k.message||"TaskMaster install could not start.");const N=localStorage.getItem(mu),S=N?`?token=${encodeURIComponent(N)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(k.jobId)}/stream${S}`);h.current=j,j.addEventListener("log",_=>{const A=JSON.parse(_.data);u(E=>[...E,A].slice(-80))}),j.addEventListener("done",_=>{const A=JSON.parse(_.data);if(j.close(),h.current=null,c(!1),!A.success){f(A.error||A.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),h.current=null,c(!1),f("TaskMaster install stream disconnected.")}}catch(w){c(!1),f(w instanceof Error?w.message:"TaskMaster install could not start.")}},[y]);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:"Task System"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Decide whether Pixcode should enable TaskMaster-backed planning, kanban tasks, PRD parsing, and agent task execution from the start."})]}),s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-background p-4 transition-colors hover:bg-muted/40",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:w=>t(w.target.checked),className:"mt-1 h-4 w-4"}),s.jsxs("span",{className:"min-w-0 space-y-1",children:[s.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Enable TaskMaster features"}),s.jsx("span",{className:"block text-sm leading-6 text-muted-foreground",children:"This keeps the Tasks panel, PRD tools, and orchestration task sync available. You can change it later in Settings."})]})]}),e&&s.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[g?s.jsx(Mn,{className:"h-5 w-5 text-green-600"}):s.jsx(Jr,{className:"h-5 w-5 text-primary"}),s.jsx("h3",{className:"font-medium text-foreground",children:"TaskMaster CLI"})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:nO(n)}),g&&!b&&s.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"MCP server is not configured yet. Core task files work now; MCP can be connected later from Settings."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void y(),disabled:i||l,className:"rounded-md border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:i?"Checking...":"Refresh"}),!g&&s.jsxs("button",{type:"button",onClick:()=>void v(),disabled:l,className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60",children:[l&&s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),l?"Installing...":"Install"]})]})]}),p&&s.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300",children:p}),d.length>0&&s.jsx("pre",{className:"max-h-48 overflow-auto rounded-md bg-black p-3 text-xs leading-5 text-green-200",children:d.map(w=>`${w.stream}> ${w.chunk}`).join("")})]})]})}const Iw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Rw=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function sO({onComplete:e}){const[t,r]=m.useState(0),[n,a]=m.useState(""),[i,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),[p,f]=m.useState(null),[h,g]=m.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=m.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=Jf(),k=m.useRef(void 0),N=m.useCallback(async()=>{try{const T=await Se("/api/user/git-config");if(!T.ok)return;const I=await T.json();I.gitName&&a(I.gitName),I.gitEmail&&o(I.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);m.useEffect(()=>{N(),w()},[N,w]),m.useEffect(()=>{const T=k.current;k.current=p,T!=null&&p===null&&w()},[p,w]);const S=T=>{f(T)},j=T=>{T===0&&p&&v(p)},_=async()=>{if(u(""),t!==0){r(T=>T+1);return}if(!n.trim()||!i.trim()){u("Both git name and email are required.");return}if(!Iw.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await Se("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:i})});if(!T.ok){const I=await Rw(T,"Failed to save git configuration");throw new Error(I)}r(I=>I+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},A=()=>{u(""),r(T=>T-1)},E=async()=>{if(h&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(h));const T=await Se("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const I=await Rw(T,"Failed to complete onboarding");throw new Error(I)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},R=t===0?!!(n.trim()&&i.trim()&&Iw.test(i)):t===2?!h||b:!0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"w-full max-w-2xl",children:[s.jsx(rO,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(tO,{gitName:n,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?s.jsx(eO,{providerStatuses:y,onOpenProviderLogin:S}):s.jsx(aO,{enabled:h,onEnabledChange:g,onReadyChange:x}),d&&s.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:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),s.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[s.jsxs("button",{onClick:A,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:[s.jsx(rg,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<2?s.jsx("button",{onClick:_,disabled:!R||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?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(On,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:E,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?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(nr,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(pC,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const iO=["0s","0.1s","0.2s"];function oO(){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(ua,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),s.jsx("div",{className:"flex items-center justify-center space-x-2",children:iO.map(e=>s.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function mC({errorMessage:e}){return e?s.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function Bs({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:i,type:o="text",name:l,autoComplete:c}){return s.jsxs("div",{children:[s.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),s.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(d.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:i})]})}function hC({title:e,description:t,children:r,footerText:n,logo:a}){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsx("div",{className:"w-full max-w-md",children:s.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:a??s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(ua,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,s.jsx("div",{className:"text-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),s.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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"})}),s.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 lO={username:"",password:""};function cO(){const{t:e}=Pe("auth"),{login:t}=ai(),[r,n]=m.useState(lO),[a,i]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),i(""),!r.username.trim()||!r.password){i(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||i(p.error),l(!1)},[r.password,r.username,t,e]);return s.jsx(hC,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(Bs,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(Bs,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(mC,{errorMessage:a}),s.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 dO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function uO(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 pO(){const{register:e}=ai(),[t,r]=m.useState(dO),[n,a]=m.useState(""),[i,o]=m.useState(!1),l=m.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=uO(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 s.jsx(hC,{title:"Welcome to Pixcode",description:"Set up your account to get started",footerText:"This is a single-user system. Only one account can be created.",logo:s.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:i,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:[s.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),s.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),s.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:i,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:[s.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),s.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&s.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[s.jsx(Bs,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:i,autoComplete:"url"}),s.jsx(Bs,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:i,type:"password",autoComplete:"off"})]}),s.jsx(Bs,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(Bs,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(Bs,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(mC,{errorMessage:n}),s.jsx("button",{type:"submit",disabled:i,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:i?"Setting up...":"Create Account"})]})})}function mO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=ai();return r?s.jsx(oO,{}):n?s.jsx(pO,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(sO,{onComplete:i}):s.jsx(cO,{})}const fC=m.createContext(null),gC=()=>{const e=m.useContext(fC);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},hO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},fO=()=>{const e=m.useRef(null),t=m.useRef(!1),r=m.useRef(!1),[n,a]=m.useState(null),[i,o]=m.useState(!1),l=m.useRef(null),{token:c}=ai(),d=m.useCallback(()=>{if(!t.current)try{const f=hO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const h=new WebSocket(f);h.onopen=()=>{o(!0),e.current=h,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},h.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},h.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},h.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);m.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=m.useCallback(f=>{const h=e.current;h&&h.readyState===WebSocket.OPEN?h.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return m.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:i}),[u,n,i])},gO=({children:e})=>{const t=fO();return s.jsx(fC.Provider,{value:t,children:e})},bC=m.createContext(null);function bO(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Lw(e){return{...e,taskMasterConfigured:e.taskmaster?.hasTaskmaster??!1,taskMasterStatus:e.taskmaster?.status??"not-configured",taskCount:Number(e.taskmaster?.metadata?.taskCount??0),completedCount:Number(e.taskmaster?.metadata?.completed??0)}}function xO(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function yO(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function xo(){const e=m.useContext(bC);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function vO({children:e}){const{latestMessage:t}=gC(),{user:r,token:n,isLoading:a}=ai(),[i,o]=m.useState([]),[l,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(null),[h,g]=m.useState([]),[b,x]=m.useState(null),[y,v]=m.useState(!1),[w,k]=m.useState(!1),[N,S]=m.useState(!1),[j,_]=m.useState(null),A=m.useRef(null);m.useEffect(()=>{A.current=l?.name??null},[l?.name]);const E=m.useCallback(()=>{_(null)},[]),R=m.useCallback((z,H)=>{console.error(`TaskMaster ${z} error:`,H),_(bO(z,H))},[]),T=m.useCallback(z=>{const H=z?Lw(z):null;c(H),u(H?.taskmaster??null),g([]),x(null)},[]),I=m.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),E();const z=await dt.get("/projects");if(!z.ok)throw new Error(`Failed to fetch projects: ${z.status}`);const H=await z.json(),P=(Array.isArray(H)?H:[]).map(B=>Lw(B));o(P);const V=A.current;if(!V)return;const G=P.find(B=>B.name===V)??null;c(G),u(G?.taskmaster??null)}catch(z){R("load projects",z)}finally{v(!1)}},[E,R,n,r]),C=m.useCallback(async()=>{const z=l?.name;if(!z||!r||!n){g([]),x(null);return}try{k(!0),E();const H=await dt.get(`/taskmaster/tasks/${encodeURIComponent(z)}`);if(!H.ok){const V=await H.json();throw new Error(V.message??"Failed to load tasks")}const $=await H.json(),P=Array.isArray($.tasks)?$.tasks:[];g(P),x(xO(P))}catch(H){R("load tasks",H),g([]),x(null)}finally{k(!1)}},[E,l?.name,R,n,r]),F=m.useCallback(async()=>{if(!r||!n){f(null);return}try{S(!0),E();const z=await dt.get("/mcp-utils/taskmaster-server");if(!z.ok)throw new Error(`Failed to load MCP status: ${z.status}`);const H=await z.json();f(H)}catch(z){R("check MCP server status",z),f(null)}finally{S(!1)}},[E,R,n,r]);m.useEffect(()=>{!a&&r&&n&&(I(),F())},[a,F,I,n,r]),m.useEffect(()=>{l?.name&&r&&n&&C()},[l?.name,C,n,r]),m.useEffect(()=>{const z=t;if(yO(z)){if(z.type==="taskmaster-project-updated"&&z.projectName){I();return}if(z.type==="taskmaster-tasks-updated"&&z.projectName===l?.name){C();return}z.type==="taskmaster-mcp-status-changed"&&F()}},[l?.name,t,F,I,C]);const q=m.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:h,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:N,error:j,refreshProjects:I,setCurrentProject:T,refreshTasks:C,refreshMCPStatus:F,clearError:E}),[E,l,j,y,N,w,p,b,d,i,F,I,C,T,h]);return s.jsx(bC.Provider,{value:q,children:e})}const xC=m.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0,refreshTaskMasterInstallation:async()=>{}}),xu=()=>{const e=m.useContext(xC);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},wO=({children:e})=>{const{user:t,token:r,isLoading:n}=ai(),[a,i]=m.useState(()=>{const v=localStorage.getItem("tasks-enabled");return v!==null?JSON.parse(v):!0}),[o,l]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,h]=m.useState(!0),g=!!(t&&r);m.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]);const b=m.useCallback(async({signal:v}={})=>{if(!n){if(!g){p(null),l(null),d(null),h(!1);return}h(!0);try{const w=await dt.get("/taskmaster/installation-status");if(v?.aborted)return;if(w.ok){const k=await w.json();if(v?.aborted)return;p(k),l(k.installation?.isInstalled||!1),d(k.isReady||!1);const N=localStorage.getItem("tasks-enabled");!k.installation?.isInstalled&&!N&&i(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(w){if(v?.aborted)return;console.error("Error checking TaskMaster installation:",w),l(!1),d(!1)}finally{v?.aborted||h(!1)}}},[g,n]);m.useEffect(()=>{const v=new AbortController,w=setTimeout(()=>{b({signal:v.signal})},0);return()=>{v.abort(),clearTimeout(w)}},[b]);const y={tasksEnabled:a,setTasksEnabled:i,toggleTasksEnabled:()=>{i(v=>!v)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f,refreshTaskMasterInstallation:b};return s.jsx(xC.Provider,{value:y,children:e})},yC=m.createContext(null);function yu(){const e=m.useContext(yC);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function kO({children:e}){const{user:t,token:r,isLoading:n}=ai(),[a,i]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&r),p=m.useCallback(async()=>{if(!u){i([]),d(null),l(!1);return}l(!0);try{const x=await Se("/api/plugins");if(x.ok){const y=await x.json();i(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{n||p()},[n,p]);const f=m.useCallback(async x=>{try{const y=await Se("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=m.useCallback(async(x,y)=>{try{const v=await Se(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const k=await v.json();w=k.details||k.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return s.jsx(yC.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const Pw=e=>typeof window>"u"?!1:window.innerWidth<e,Dw=()=>{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 pg(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,i]=m.useState(()=>r?Pw(t):!1),[o,l]=m.useState(()=>n?Dw():!1);return m.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{i(Pw(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),m.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(Dw())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const mg="pixcode.updateCheck.preferences",Th="pixcode:update-check-settings-changed",hg=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],Ah={frequency:"30m"};function Ow(e){return hg.find(t=>t.value===e.frequency)?.intervalMs??null}function vC(e){if(!e||typeof e!="object")return Ah;const t=e.frequency;return hg.some(r=>r.value===t)?{frequency:t}:Ah}function Mw(){try{const e=localStorage.getItem(mg);return vC(e?JSON.parse(e):null)}catch{return Ah}}function SO(e){const t=vC(e);localStorage.setItem(mg,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(Th,{detail:t}))}const up=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const i=r[a]||0,o=n[a]||0;if(i!==o)return i-o}return 0},NO="1.46.4",jh="pixcode:update-available",CO=360*60*1e3,pp=new Map;function wC(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function EO(e,t){try{const r=localStorage.getItem(wC(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function Fw(e,t,r){localStorage.setItem(wC(e,t),JSON.stringify(r))}function TO(e,t){const r=`${e}/${t}`,n=pp.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async i=>({status:i.status,ok:i.ok,data:await i.json().catch(()=>({}))})).finally(()=>{pp.delete(r)});return pp.set(r,a),a}const kC=(e,t)=>{const[r,n]=m.useState(!1),[a,i]=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(()=>Mw()),[x,y]=m.useState(NO),v=m.useRef(null),w=m.useCallback(N=>{SO(N),b(N)},[]);m.useEffect(()=>{const N=()=>b(Mw()),S=j=>{j.key===mg&&N()};return window.addEventListener("storage",S),window.addEventListener(Th,N),()=>{window.removeEventListener("storage",S),window.removeEventListener(Th,N)}},[]),m.useEffect(()=>{let N=!1;const S=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(N)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};S();const j=()=>{S()};return window.addEventListener("focus",j),()=>{N=!0,window.removeEventListener("focus",j)}},[]),m.useEffect(()=>{if(!x)return;let N=!1;const S=(T,I,C,F)=>({updateAvailable:!!(T&&up(T,x)>0),latestVersion:T,releaseInfo:I,currentVersion:x,checkedAt:C,status:F}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(jh,{detail:T}))},_=(T,I,C,F="success")=>{if(!T||!I)return n(!1),i(null),l(null),h(C),S(null,null,C,F);i(T),n(up(T,x)>0),l(I),h(C);const q=S(T,I,C,F);return j(q),q},A=async({force:T=!1}={})=>{const I=Ow(g),C=EO(e,t),F=Date.now();if(!T&&I===null)return p("idle"),_(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!T&&C?.fetchedAt&&I!==null&&F-C.fetchedAt<I)return p("success"),_(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!T&&C?.rateLimitedUntil&&C.rateLimitedUntil>F)return p("error"),_(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const q=await TO(e,t);if(N)return S(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const z=q.data;if(!q.ok)return q.status===403&&Fw(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:F+Math.max(I??0,CO)}),p("error"),_(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(z.tag_name){const H=z.tag_name.replace(/^v/,""),$=up(H,x)>0,P={title:z.name||z.tag_name,body:z.body||"",htmlUrl:z.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:z.published_at||""};Fw(e,t,{fetchedAt:F,latestVersion:H,releaseInfo:P}),i(H),n($),$&&RN({key:`app-update:${H}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${H}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:H,installMode:c}}),l(P),p("success"),h(F);const V=S(H,P,F,"success");return j(V),V}else return n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}catch(q){return console.error("Version check failed:",q),n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}};v.current=A,A();const E=Ow(g),R=E===null?null:window.setInterval(()=>{A()},E);return()=>{N=!0,R!==null&&window.clearInterval(R)}},[e,t,x,c,g]);const k=m.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:k,updateCheckPreferences:g,updatePreferences:w}},Us={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},AO=["flat","grouped"],jO=e=>typeof e=="string"&&AO.includes(e),Id=Object.keys(Us),_O=new Set(Id),mp="ui-preferences:sync",IO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Rd=(e,t,r)=>e==="historyView"?jO(t)?t:r:IO(t,r),RO=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Rd(e,n,t)}catch{return t}},LO=e=>{if(typeof window>"u")return Us;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return Id.reduce((a,i)=>(a[i]=Rd(i,n[i],Us[i]),a),{...Us})}}}catch{}return Id.reduce((t,r)=>(t[r]=RO(r,Us[r]),t),{...Us})};function PO(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!_O.has(r))return e;const a=Rd(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const i of Id){if(!(i in r))continue;const o=r[i],l=Rd(i,o,e[i]);a[i]!==l&&(a[i]=l,n=!0)}return n?a:e}case"reset":return{...Us,...t.value||{}};default:return e}}function fg(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=m.useReducer(PO,e,LO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(mp,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(mp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(mp,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const DO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},OO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},MO=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},zw=(e,t)=>`${e}::${t}`,FO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},zO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},BO=/(?:^|[\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,UO=e=>{if(!e)return[];const t=new Set,r=new RegExp(BO.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],i=a.lastIndexOf(".");if(i>-1){const o=a.slice(i+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},Ks=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),$O=(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"),GO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),HO=(e,t,r)=>{const n=Ks(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:$O(e,r),sessionTime:GO(e),messageCount:Number(e.messageCount||0)}},SC=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),i=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=>!i(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>i(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],h=new Map;for(const g of[...r,...n,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>Ks(b).getTime()-Ks(g).getTime())},Bw=(e,t)=>{const r=SC(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const i=Ks(a);return i>n?i:n},new Date(0))},VO=(e,t,r,n)=>{const a=[...e];return a.sort((i,o)=>{const l=r.has(i.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?Bw(o,n).getTime()-Bw(i,n).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},qO=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),i=n.name.toLowerCase();return a.includes(r)||i.includes(r)}):e},WO=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},KO=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 YO({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setCurrentProject:p,setSidebarVisible:f,sidebarVisible:h}){const[g,b]=m.useState(new Set),[x,y]=m.useState(null),[v,w]=m.useState(!1),[k,N]=m.useState(""),[S,j]=m.useState({}),[_,A]=m.useState({}),[E,R]=m.useState(new Set),[T,I]=m.useState(new Date),[C,F]=m.useState("name"),[q,z]=m.useState(!1),[H,$]=m.useState({}),[P,V]=m.useState(null),[G,B]=m.useState(""),[Q,J]=m.useState(""),[me,fe]=m.useState(new Set),[oe,he]=m.useState(null),[ce,we]=m.useState(null),[Y,xe]=m.useState(!1),[D,le]=m.useState(()=>OO()),[ie,M]=m.useState(()=>FO()),[W,ne]=m.useState("projects"),[ge,ke]=m.useState(null),[ue,Ee]=m.useState(!1),[se,te]=m.useState(null),ee=m.useRef(null),pe=m.useRef(0),Te=m.useRef(null),je=!a&&!h;m.useEffect(()=>{const Re=setInterval(()=>{I(new Date)},6e4);return()=>clearInterval(Re)},[]),m.useEffect(()=>{A({}),R(new Set),$({})},[e]),m.useEffect(()=>{t&&b(Re=>{if(Re.has(t.name))return Re;const Ue=new Set(Re);return Ue.add(t.name),Ue})},[r,t]),m.useEffect(()=>{if(e.length>0&&!n){const Re=new Set;e.forEach(Ue=>{Ue.sessions&&Ue.sessions.length>=0&&Re.add(Ue.name)}),R(Re)}},[e,n]),m.useEffect(()=>{const Re=()=>{F(DO())};Re();const Ue=Qe=>{Qe.key==="claude-settings"&&Re()},mt=()=>Re();return window.addEventListener("storage",Ue),window.addEventListener("pixcode:settings-changed",mt),()=>{window.removeEventListener("storage",Ue),window.removeEventListener("pixcode:settings-changed",mt)}},[]),m.useEffect(()=>{ee.current&&clearTimeout(ee.current),Te.current&&(Te.current.close(),Te.current=null);const Re=Q.trim();if(W!=="conversations"||Re.length<2){pe.current+=1,ke(null),te(null),Ee(!1);return}Ee(!0);const Ue=++pe.current;return ee.current=setTimeout(()=>{if(Ue!==pe.current)return;const mt=dt.searchConversationsUrl(Re),Qe=new EventSource(mt);Te.current=Qe;const Et=[];let Z=0;Qe.addEventListener("result",Ne=>{if(Ue!==pe.current){Qe.close();return}try{const ye=JSON.parse(Ne.data);Et.push(ye.projectResult),Z=ye.totalMatches,ke({results:[...Et],totalMatches:Z,query:Re}),te({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),Qe.addEventListener("progress",Ne=>{if(Ue!==pe.current){Qe.close();return}try{const ye=JSON.parse(Ne.data);Z=ye.totalMatches,te({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),Qe.addEventListener("done",()=>{if(Ue!==pe.current){Qe.close();return}Qe.close(),Te.current=null,Ee(!1),te(null),Et.length===0&&ke({results:[],totalMatches:0,query:Re})}),Qe.addEventListener("error",()=>{if(Ue!==pe.current){Qe.close();return}Qe.close(),Te.current=null,Ee(!1),te(null),Et.length===0&&ke({results:[],totalMatches:0,query:Re})})},400),()=>{ee.current&&clearTimeout(ee.current),Te.current&&(Te.current.close(),Te.current=null)}},[Q,W]);const Ve=m.useCallback(Re=>{b(Ue=>{const mt=new Set;return Ue.has(Re)||mt.add(Re),mt})},[]),Ze=m.useCallback((Re,Ue)=>{c({...Re,__projectName:Ue})},[c]),ut=m.useCallback(Re=>{le(Ue=>{const mt=new Set(Ue);return mt.has(Re)?mt.delete(Re):mt.add(Re),MO(mt),mt})},[]),Xe=m.useCallback(Re=>D.has(Re),[D]),_t=m.useCallback((Re,Ue)=>{M(mt=>{const Qe=zw(Re,Ue),Et=new Set(mt);return Et.has(Qe)?Et.delete(Qe):Et.add(Qe),zO(Et),Et})},[]),xt=m.useCallback((Re,Ue)=>ie.has(zw(Re,Ue)),[ie]),lt=m.useCallback(Re=>SC(Re,_),[_]),ct=m.useMemo(()=>e.map(Re=>{const Ue=H[Re.name];return Ue===void 0?Re:{...Re,sessionMeta:{...Re.sessionMeta,hasMore:Ue}}}),[H,e]),Nt=m.useMemo(()=>VO(ct,C,D,_),[_,C,ct,D]),It=m.useMemo(()=>qO(Nt,Q),[Q,Nt]),Rt=m.useCallback(Re=>{y(Re.name),N(Re.displayName)},[]),kr=m.useCallback(()=>{y(null),N("")},[]),ar=m.useCallback(async Re=>{try{(await dt.renameProject(Re,k)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ue){console.error("Error renaming project:",Ue)}finally{y(null),N("")}},[k]),hr=m.useCallback((Re,Ue,mt,Qe="claude")=>{we({projectName:Re,sessionId:Ue,sessionTitle:mt,provider:Qe})},[]),Sr=m.useCallback(async()=>{if(!ce)return;const{projectName:Re,sessionId:Ue,provider:mt}=ce;we(null);try{let Qe;if(mt==="codex"?Qe=await dt.deleteCodexSession(Ue):mt==="gemini"?Qe=await dt.deleteGeminiSession(Ue):mt==="qwen"?Qe=await dt.deleteQwenSession(Ue):Qe=await dt.deleteSession(Re,Ue),Qe.ok)d?.(Ue);else{const Et=await Qe.text();console.error("[Sidebar] Failed to delete session:",{status:Qe.status,error:Et}),alert(i("messages.deleteSessionFailed"))}}catch(Qe){console.error("[Sidebar] Error deleting session:",Qe),alert(i("messages.deleteSessionError"))}},[d,ce,i]),De=m.useCallback(Re=>{he({project:Re,sessionCount:lt(Re).length})},[lt]),Je=m.useCallback(async(Re=!1)=>{if(!oe)return;const{project:Ue,sessionCount:mt}=oe,Qe=mt===0;he(null),fe(Et=>new Set([...Et,Ue.name]));try{const Et=await dt.deleteProject(Ue.name,!Qe,Re);if(Et.ok)u?.(Ue.name);else{const Z=await Et.json();alert(Z.error||i("messages.deleteProjectFailed"))}}catch(Et){console.error("Error deleting project:",Et),alert(i("messages.deleteProjectError"))}finally{fe(Et=>{const Z=new Set(Et);return Z.delete(Ue.name),Z})}},[oe,u,i]),We=m.useCallback(async Re=>{const Ue=H[Re.name];if(!(!(Ue!==void 0?Ue:Re.sessionMeta?.hasMore===!0)||S[Re.name])){j(Qe=>({...Qe,[Re.name]:!0}));try{const Qe=(Re.sessions?.length||0)+(_[Re.name]?.length||0),Et=await dt.sessions(Re.name,5,Qe);if(!Et.ok)return;const Z=await Et.json();A(Ne=>({...Ne,[Re.name]:[...Ne[Re.name]||[],...Z.sessions||[]]})),Z.hasMore===!1&&$(Ne=>({...Ne,[Re.name]:!1}))}catch(Qe){console.error("Error loading more sessions:",Qe)}finally{j(Qe=>({...Qe,[Re.name]:!1}))}}},[_,S,H]),pt=m.useCallback(Re=>{l(Re),p(Re)},[l,p]),Fe=m.useCallback(async()=>{z(!0);try{await o()}finally{z(!1)}},[o]),qe=m.useCallback(async(Re,Ue,mt,Qe)=>{const Et=mt.trim();if(!Et){V(null),B("");return}try{const Z=await dt.renameSession(Ue,Et,Qe);Z.ok?await o():(console.error("[Sidebar] Failed to rename session:",Z.status),alert(i("messages.renameSessionFailed")))}catch(Z){console.error("[Sidebar] Error renaming session:",Z),alert(i("messages.renameSessionError"))}finally{V(null),B("")}},[o,i]),gt=m.useCallback(()=>{f(!1)},[f]),sr=m.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:je,expandedProjects:g,editingProject:x,showNewProject:v,editingName:k,loadingSessions:S,additionalSessions:_,initialSessionsLoaded:E,currentTime:T,projectSortOrder:C,isRefreshing:q,editingSession:P,editingSessionName:G,searchFilter:Q,deletingProjects:me,deleteConfirmation:oe,sessionDeleteConfirmation:ce,showVersionModal:Y,starredProjects:D,starredSessions:ie,filteredProjects:It,toggleProject:Ve,handleSessionClick:Ze,toggleStarProject:ut,isProjectStarred:Xe,toggleStarSession:_t,isSessionStarred:xt,getProjectSessions:lt,startEditing:Rt,cancelEditing:kr,saveProjectName:ar,showDeleteSessionConfirmation:hr,confirmDeleteSession:Sr,requestProjectDelete:De,confirmDeleteProject:Je,loadMoreSessions:We,handleProjectSelect:pt,refreshProjects:Fe,updateSessionSummary:qe,collapseSidebar:gt,expandSidebar:sr,setShowNewProject:w,setEditingName:N,setEditingSession:V,setEditingSessionName:B,searchMode:W,setSearchMode:ne,conversationResults:ge,isSearching:ue,searchProgress:se,clearConversationResults:m.useCallback(()=>{pe.current+=1,Te.current&&(Te.current.close(),Te.current=null),Ee(!1),te(null),ke(null)},[]),setSearchFilter:J,setDeleteConfirmation:he,setSessionDeleteConfirmation:we,setShowVersionModal:xe}}const ZO="https://discord.gg/buxwujPNRE",XO="https://github.com/alicomert/pixcode/issues/new";function JO({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 QO({onExpand:e,onOpenControlRoom:t,onShowSettings:r,updateAvailable:n,onShowVersionModal:a,t:i}){return s.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[s.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":i("common:versionUpdate.ariaLabels.showSidebar"),title:i("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(aD,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),t&&s.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":i("actions.controlRoom",{defaultValue:"Control Room"}),title:i("actions.controlRoom",{defaultValue:"Control Room"}),children:s.jsx(Wr,{className:"h-4 w-4 text-primary"})}),s.jsx("button",{onClick:r,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("actions.settings"),title:i("actions.settings"),children:s.jsx(Dt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:XO,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":i("actions.reportIssue"),title:i("actions.reportIssue"),children:s.jsx(Il,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:ZO,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":i("actions.joinCommunity"),title:i("actions.joinCommunity"),children:s.jsx(JO,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&s.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":i("common:versionUpdate.ariaLabels.updateAvailable"),title:i("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(Wr,{className:"h-4 w-4 text-blue-500"}),s.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function NC(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=NC(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function CC(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=NC(e))&&(n&&(n+=" "),n+=t);return n}const Uw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$w=CC,gg=(e,t)=>r=>{var n;if(t?.variants==null)return $w(e,r?.class,r?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=i?.[d];if(u===null)return null;const f=Uw(u)||Uw(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...h}=u;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,f]:d},[]);return $w(e,o,c,r?.class,r?.className)},bg="-",eM=e=>{const t=rM(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(bg);return l[0]===""&&l.length!==1&&l.shift(),EC(l,t)||tM(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},EC=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?EC(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(bg);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Gw=/^\[(.+)\]$/,tM=e=>{if(Gw.test(e)){const t=Gw.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},rM=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)_h(r[a],n,a,t);return n},_h=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Hw(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(nM(a)){_h(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{_h(o,Hw(t,i),r,n)})})},Hw=(e,t)=>{let r=e;return t.split(bg).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},nM=e=>e.isThemeGetter,aM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(i,o)=>{r.set(i,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=n.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},Ih="!",Rh=":",sM=Rh.length,iM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const i=[];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===Rh){i.push(a.slice(c,g)),c=g+sM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=oM(u),f=p!==u,h=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+Rh,i=n;n=o=>o.startsWith(a)?i(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=i=>r({className:i,parseClassName:a})}return n},oM=e=>e.endsWith(Ih)?e.substring(0,e.length-1):e.startsWith(Ih)?e.substring(1):e,lM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let i=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...i.sort(),o),i=[]):i.push(o)}),a.push(...i.sort()),a}},cM=e=>({cache:aM(e.cacheSize),parseClassName:iM(e),sortModifiers:lM(e),...eM(e)}),dM=/\s+/,uM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(dM);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=i(f).join(":"),w=h?v+Ih:v,k=w+y;if(o.includes(k))continue;o.push(k);const N=a(y,x);for(let S=0;S<N.length;++S){const j=N[S];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function pM(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=TC(t))&&(n&&(n+=" "),n+=r);return n}const TC=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=TC(e[n]))&&(r&&(r+=" "),r+=t);return r};function mM(e,...t){let r,n,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=cM(d),n=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=uM(c,r);return a(c,u),u}return function(){return i(pM.apply(null,arguments))}}const fr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},AC=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jC=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hM=/^\d+\/\d+$/,fM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gM=/\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$/,bM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,xM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yi=e=>hM.test(e),bt=e=>!!e&&!Number.isNaN(Number(e)),Wa=e=>!!e&&Number.isInteger(Number(e)),hp=e=>e.endsWith("%")&&bt(e.slice(0,-1)),ya=e=>fM.test(e),vM=()=>!0,wM=e=>gM.test(e)&&!bM.test(e),_C=()=>!1,kM=e=>xM.test(e),SM=e=>yM.test(e),NM=e=>!Ge(e)&&!He(e),CM=e=>yo(e,LC,_C),Ge=e=>AC.test(e),As=e=>yo(e,PC,wM),fp=e=>yo(e,_M,bt),Vw=e=>yo(e,IC,_C),EM=e=>yo(e,RC,SM),Sc=e=>yo(e,DC,kM),He=e=>jC.test(e),qo=e=>vo(e,PC),TM=e=>vo(e,IM),qw=e=>vo(e,IC),AM=e=>vo(e,LC),jM=e=>vo(e,RC),Nc=e=>vo(e,DC,!0),yo=(e,t,r)=>{const n=AC.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},vo=(e,t,r=!1)=>{const n=jC.exec(e);return n?n[1]?t(n[1]):r:!1},IC=e=>e==="position"||e==="percentage",RC=e=>e==="image"||e==="url",LC=e=>e==="length"||e==="size"||e==="bg-size",PC=e=>e==="length",_M=e=>e==="number",IM=e=>e==="family-name",DC=e=>e==="shadow",RM=()=>{const e=fr("color"),t=fr("font"),r=fr("text"),n=fr("font-weight"),a=fr("tracking"),i=fr("leading"),o=fr("breakpoint"),l=fr("container"),c=fr("spacing"),d=fr("radius"),u=fr("shadow"),p=fr("inset-shadow"),f=fr("text-shadow"),h=fr("drop-shadow"),g=fr("blur"),b=fr("perspective"),x=fr("aspect"),y=fr("ease"),v=fr("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"],N=()=>[...k(),He,Ge],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],_=()=>[He,Ge,c],A=()=>[yi,"full","auto",..._()],E=()=>[Wa,"none","subgrid",He,Ge],R=()=>["auto",{span:["full",Wa,He,Ge]},Wa,He,Ge],T=()=>[Wa,"auto",He,Ge],I=()=>["auto","min","max","fr",He,Ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],F=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",..._()],z=()=>[yi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],H=()=>[e,He,Ge],$=()=>[...k(),qw,Vw,{position:[He,Ge]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",AM,CM,{size:[He,Ge]}],G=()=>[hp,qo,As],B=()=>["","none","full",d,He,Ge],Q=()=>["",bt,qo,As],J=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[bt,hp,qw,Vw],oe=()=>["","none",g,He,Ge],he=()=>["none",bt,He,Ge],ce=()=>["none",bt,He,Ge],we=()=>[bt,He,Ge],Y=()=>[yi,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ya],breakpoint:[ya],color:[vM],container:[ya],"drop-shadow":[ya],ease:["in","out","in-out"],font:[NM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ya],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ya],shadow:[ya],spacing:["px",bt],text:[ya],"text-shadow":[ya],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yi,Ge,He,x]}],container:["container"],columns:[{columns:[bt,Ge,He,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:N()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Wa,"auto",He,Ge]}],basis:[{basis:[yi,"full","auto",l,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[bt,yi,"auto","initial","none",Ge]}],grow:[{grow:["",bt,He,Ge]}],shrink:[{shrink:["",bt,He,Ge]}],order:[{order:[Wa,"first","last","none",He,Ge]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...F(),"normal"]}],"justify-self":[{"justify-self":["auto",...F()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...F(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...F(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...F(),"baseline"]}],"place-self":[{"place-self":["auto",...F()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",r,qo,As]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,He,fp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",hp,Ge]}],"font-family":[{font:[TM,Ge,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,He,Ge]}],"line-clamp":[{"line-clamp":[bt,"none",He,fp]}],leading:[{leading:[i,..._()]}],"list-image":[{"list-image":["none",He,Ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",He,Ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:H()}],"text-color":[{text:H()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[bt,"from-font","auto",He,As]}],"text-decoration-color":[{decoration:H()}],"underline-offset":[{"underline-offset":[bt,"auto",He,Ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",He,Ge]}],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",He,Ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:$()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Wa,He,Ge],radial:["",He,Ge],conic:[Wa,He,Ge]},jM,EM]}],"bg-color":[{bg:H()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:H()}],"gradient-via":[{via:H()}],"gradient-to":[{to:H()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:H()}],"border-color-x":[{"border-x":H()}],"border-color-y":[{"border-y":H()}],"border-color-s":[{"border-s":H()}],"border-color-e":[{"border-e":H()}],"border-color-t":[{"border-t":H()}],"border-color-r":[{"border-r":H()}],"border-color-b":[{"border-b":H()}],"border-color-l":[{"border-l":H()}],"divide-color":[{divide:H()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[bt,He,Ge]}],"outline-w":[{outline:["",bt,qo,As]}],"outline-color":[{outline:H()}],shadow:[{shadow:["","none",u,Nc,Sc]}],"shadow-color":[{shadow:H()}],"inset-shadow":[{"inset-shadow":["none",p,Nc,Sc]}],"inset-shadow-color":[{"inset-shadow":H()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:H()}],"ring-offset-w":[{"ring-offset":[bt,As]}],"ring-offset-color":[{"ring-offset":H()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":H()}],"text-shadow":[{"text-shadow":["none",f,Nc,Sc]}],"text-shadow-color":[{"text-shadow":H()}],opacity:[{opacity:[bt,He,Ge]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"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":[bt]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":H()}],"mask-image-linear-to-color":[{"mask-linear-to":H()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":H()}],"mask-image-t-to-color":[{"mask-t-to":H()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":H()}],"mask-image-r-to-color":[{"mask-r-to":H()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":H()}],"mask-image-b-to-color":[{"mask-b-to":H()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":H()}],"mask-image-l-to-color":[{"mask-l-to":H()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":H()}],"mask-image-x-to-color":[{"mask-x-to":H()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":H()}],"mask-image-y-to-color":[{"mask-y-to":H()}],"mask-image-radial":[{"mask-radial":[He,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":H()}],"mask-image-radial-to-color":[{"mask-radial-to":H()}],"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":[bt]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":H()}],"mask-image-conic-to-color":[{"mask-conic-to":H()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:$()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ge]}],filter:[{filter:["","none",He,Ge]}],blur:[{blur:oe()}],brightness:[{brightness:[bt,He,Ge]}],contrast:[{contrast:[bt,He,Ge]}],"drop-shadow":[{"drop-shadow":["","none",h,Nc,Sc]}],"drop-shadow-color":[{"drop-shadow":H()}],grayscale:[{grayscale:["",bt,He,Ge]}],"hue-rotate":[{"hue-rotate":[bt,He,Ge]}],invert:[{invert:["",bt,He,Ge]}],saturate:[{saturate:[bt,He,Ge]}],sepia:[{sepia:["",bt,He,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ge]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[bt,He,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[bt,He,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",bt,He,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[bt,He,Ge]}],"backdrop-invert":[{"backdrop-invert":["",bt,He,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[bt,He,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[bt,He,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",bt,He,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",He,Ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[bt,"initial",He,Ge]}],ease:[{ease:["linear","initial",y,He,Ge]}],delay:[{delay:[bt,He,Ge]}],animate:[{animate:["none",v,He,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,He,Ge]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[He,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],accent:[{accent:H()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:H()}],"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",He,Ge]}],"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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",He,Ge]}],fill:[{fill:["none",...H()]}],"stroke-w":[{stroke:[bt,qo,As,fp]}],stroke:[{stroke:["none",...H()]}],"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"]}},LM=mM(RM);function be(...e){return LM(CC(e))}function PM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const DM=gg("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"}}),OC=m.forwardRef(({className:e,variant:t,...r},n)=>s.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:be(DM({variant:t}),e),...r}));OC.displayName="Alert";const OM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-title",className:be("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));OM.displayName="AlertTitle";const MM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-description",className:be("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));MM.displayName="AlertDescription";const FM=gg("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 st({className:e,variant:t,...r}){return s.jsx("div",{className:be(FM({variant:t}),e),...r})}const zM=gg("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"}}),Ce=m.forwardRef(({className:e,variant:t,size:r,...n},a)=>s.jsx("button",{className:be(zM({variant:t,size:r,className:e})),ref:a,...n}));Ce.displayName="Button";const MC=m.createContext(null),FC=()=>{const e=m.useContext(MC);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},zC=({className:e,approval:t="pending",children:r,...n})=>{const a=m.useMemo(()=>({approval:t}),[t]);return s.jsx(MC.Provider,{value:a,children:s.jsx(OC,{className:be("flex flex-col gap-2",e),...n,children:r})})};zC.displayName="Confirmation";const BC=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:be("text-muted-foreground inline text-sm",e),...t});BC.displayName="ConfirmationTitle";const UC=({children:e})=>{const{approval:t}=FC();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};UC.displayName="ConfirmationRequest";const $C=({className:e,...t})=>{const{approval:r}=FC();return r!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:be("flex items-center justify-end gap-2 self-end",e),...t})};$C.displayName="ConfirmationActions";const ud=({variant:e="default",...t})=>s.jsx(Ce,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});ud.displayName="ConfirmationAction";const GC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));GC.displayName="Card";const HC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("flex flex-col space-y-1.5 p-4",e),...t}));HC.displayName="CardHeader";const VC=m.forwardRef(({className:e,...t},r)=>s.jsx("h3",{ref:r,className:be("font-semibold leading-none tracking-tight",e),...t}));VC.displayName="CardTitle";const BM=m.forwardRef(({className:e,...t},r)=>s.jsx("p",{ref:r,className:be("text-sm text-muted-foreground",e),...t}));BM.displayName="CardDescription";const qC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("p-4 pt-0",e),...t}));qC.displayName="CardContent";const WC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("flex items-center p-4 pt-0",e),...t}));WC.displayName="CardFooter";const UM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("ml-auto shrink-0",e),...t}));UM.displayName="CardAction";const KC=m.createContext(null);function YC(){const e=m.useContext(KC);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const ms=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...i},o)=>{const[l,c]=m.useState(e),d=t!==void 0,u=d?t:l,p=m.useCallback(h=>{d||c(h),r?.(h)},[d,r]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(KC.Provider,{value:f,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...i,children:a})})});ms.displayName="Collapsible";const La=m.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:i,onOpenChange:o}=YC(),l=m.useCallback(c=>{o(!i),e?.(c)},[i,o,e]);return s.jsx("button",{ref:a,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:l,className:r,...n,children:t})});La.displayName="CollapsibleTrigger";const hs=m.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=YC();return s.jsx("div",{ref:n,"data-state":a?"open":"closed",className:be("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:s.jsx("div",{className:"overflow-hidden",children:t})})});hs.displayName="CollapsibleContent";const ZC=m.createContext(null);function xg(){const e=m.useContext(ZC);if(!e)throw new Error("Command components must be used within <Command>");return e}const XC=m.forwardRef(({className:e,children:t,...r},n)=>{const[a,i]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=m.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=m.useCallback((v,w)=>{const k=o.current.get(v);k&&Object.assign(k,w)},[]),f=m.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[k,N]of o.current)(!v||N.value.includes(v))&&w.add(k);return w},[a,l]),h=m.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=h;if(w.length===0)return;if(v.key==="Enter"){w.find(A=>A.id===g)?.onSelect();return}const k=w.findIndex(_=>_.id===g);let N;v.key==="ArrowDown"?N=k<w.length-1?k+1:0:N=k>0?k-1:w.length-1;const S=w[N].id;b(S),w[N].element?.scrollIntoView({block:"nearest"})},[h,g]),y=m.useMemo(()=>({search:a,setSearch:i,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return s.jsx(ZC.Provider,{value:y,children:s.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:be("flex flex-col",e),onKeyDown:x,...r,children:t})})});XC.displayName="Command";const JC=m.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:i}=xg();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(da,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>i(o.target.value),placeholder:t,className:be("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})});JC.displayName="CommandInput";const QC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,role:"listbox",className:be("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));QC.displayName="CommandList";const eE=m.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=xg();return!n||a.size>0?null:s.jsx("div",{ref:r,className:be("py-6 text-center text-sm text-muted-foreground",e),...t})});eE.displayName="CommandEmpty";const tE=m.forwardRef(({className:e,heading:t,children:r,...n},a)=>s.jsxs("div",{ref:a,className:be("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&s.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));tE.displayName="CommandGroup";const rE=m.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=xg(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:r||(()=>{})})},[h,r,f]);const x=m.useCallback(v=>{g.current=v,f(h,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[h,f,o]);if(!l.has(h))return null;const y=c===h;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:be("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==h&&d(h)},onClick:()=>!n&&r?.(),...i,children:a})});rE.displayName="CommandItem";const $M=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("-mx-1 h-px bg-border",e),...t}));$M.displayName="CommandSeparator";function Lh({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=$a(),i=typeof e=="boolean"&&typeof t=="function",o=i?e:n,l=()=>{if(i&&t){t(!o);return}a()};return s.jsxs("button",{onClick:l,className:be("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":r,children:[s.jsx("span",{className:"sr-only",children:r}),s.jsx("span",{className:be("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?s.jsx(lg,{className:"h-3 w-3 text-primary"}):s.jsx(dg,{className:"h-3 w-3 text-white dark:text-background"})})]})}const nE=m.createContext(null);function aE(){const e=m.useContext(nE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const sE=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,i]=m.useState(r),o=m.useRef(null),l=e!==void 0,c=l?e:a,d=m.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=m.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(nE.Provider,{value:u,children:n})},GM=m.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:i,triggerRef:o}=aE(),l=m.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(r&&m.isValidElement(t)){const c=t;return m.cloneElement(c,{onClick:d=>{i(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return s.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});GM.displayName="DialogTrigger";const Ww='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',yg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=aE(),d=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),m.useEffect(()=>{if(!o)return;const p=h=>{if(h.key==="Escape"){h.stopPropagation(),r?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(Ww));if(g.length===0)return;const b=g[0],x=g[g.length-1];h.shiftKey&&document.activeElement===b?(h.preventDefault(),x.focus()):!h.shiftKey&&document.activeElement===x&&(h.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(Ww)?.focus()})},[o]),o?uu.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50",children:[s.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),s.jsx("div",{ref:p=>{d.current=p,typeof i=="function"?i(p):i&&(i.current=p)},role:"dialog","aria-modal":"true",className:be("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});yg.displayName="DialogContent";const vg=m.forwardRef(({className:e,...t},r)=>s.jsx("h2",{ref:r,className:be("sr-only",e),...t}));vg.displayName="DialogTitle";const Be=m.forwardRef(({className:e,type:t,...r},n)=>s.jsx("input",{type:t,className:be("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Be.displayName="Input";const wg=m.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>s.jsx("div",{className:be("relative overflow-hidden",e),...n,children:s.jsx("div",{ref:a,className:be("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));wg.displayName="ScrollArea";const Ld=m.memo(({children:e,className:t,as:r="span"})=>s.jsx(r,{className:be("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}));Ld.displayName="Shimmer";const iE=m.createContext(null),HM=()=>{const e=m.useContext(iE);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},VM=1e3,qM=1e3,Ph=m.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:i,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=m.useState(c),f=r!==void 0,h=f?r:u,g=m.useCallback(S=>{f||p(S),a?.(S)},[f,a]),[b,x]=m.useState(i),y=m.useRef(t),[v,w]=m.useState(!1),k=m.useRef(null);m.useEffect(()=>{i!==void 0&&x(i)},[i]),m.useEffect(()=>{t?(y.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/qM)),k.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(y.current&&!t&&h&&!v){const S=setTimeout(()=>{g(!1),w(!0)},VM);return()=>clearTimeout(S)}},[t,h,g,v]);const N=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return s.jsx(iE.Provider,{value:N,children:s.jsx(ms,{open:h,onOpenChange:g,className:be("not-prose",e),...l,children:o})})});Ph.displayName="Reasoning";const WM=(e,t)=>e||t===0?s.jsx(Ld,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Dh=m.memo(({className:e,children:t,getThinkingMessage:r=WM,...n})=>{const{isStreaming:a,isOpen:i,duration:o}=HM();return s.jsx(La,{className:be("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??s.jsxs(s.Fragment,{children:[s.jsx(AD,{className:"h-4 w-4"}),r(a,o),s.jsx(HN,{className:be("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Dh.displayName="ReasoningTrigger";const Oh=m.memo(({className:e,children:t,...r})=>s.jsx(hs,{className:be("mt-4 text-sm text-muted-foreground",e),...r,children:t}));Oh.displayName="ReasoningContent";function KM(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 na({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[i,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(),N=8,S={position:"fixed",zIndex:9999};switch(r){case"bottom":S.left=k.left+k.width/2,S.top=k.bottom+N,S.transform="translateX(-50%)";break;case"left":S.left=k.left-N,S.top=k.top+k.height/2,S.transform="translate(-100%, -50%)";break;case"right":S.left=k.right+N,S.top=k.top+k.height/2,S.transform="translateY(-50%)";break;case"top":default:S.left=k.left+k.width/2,S.top=k.top-N,S.transform="translate(-50%, -100%)";break}f(S)},[r]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!i||typeof document>"u")return;const w=k=>{const N=k.target;N instanceof Node&&d.current?.contains(N)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),m.useEffect(()=>{if(!i){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)}},[i,h]),t?s.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&uu.createPortal(s.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:be("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",n),children:[t,s.jsx("div",{className:be("absolute w-0 h-0 border-4 border-transparent",KM(r))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const oE=m.createContext(null),lE=m.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const i=m.useMemo(()=>({status:t}),[t]);return s.jsx(oE.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:be("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});lE.displayName="PromptInput";const cE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:be("px-3 pt-3",e),...t}));cE.displayName="PromptInputHeader";const dE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:be("relative",e),...t}));dE.displayName="PromptInputBody";const uE=m.forwardRef(({className:e,...t},r)=>s.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:be("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}));uE.displayName="PromptInputTextarea";const pE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:be("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));pE.displayName="PromptInputFooter";const mE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:be("flex items-center gap-1",e),...t}));mE.displayName="PromptInputTools";const pd=m.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const i=s.jsx(Ce,{ref:a,type:"button",variant:"ghost",size:"icon",className:be("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?s.jsx(na,{content:t.shortcut?s.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,s.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:i}):i});pd.displayName="PromptInputButton";const hE=m.forwardRef(({className:e,status:t,children:r,...n},a)=>{const i=m.useContext(oE),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Ce,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:be("h-8 w-8 rounded-lg",e),...n,children:r??(l?s.jsx(gu,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(sD,{className:"h-4 w-4"}))})});hE.displayName="PromptInputSubmit";function kg({children:e,className:t}){return s.jsx("div",{className:be("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Sg({isActive:e,onClick:t,children:r,className:n}){return s.jsx("button",{onClick:t,className:be("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",n),children:r})}const fE=m.createContext(null);function gE(){const e=m.useContext(fE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const bE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:be("space-y-0.5",e),...t}));bE.displayName="Queue";const xE=m.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const i=m.useMemo(()=>({status:e}),[e]);return s.jsx(fE.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:be("flex items-start gap-2 py-0.5",t),...n,children:r})})});xE.displayName="QueueItem";const yE=m.forwardRef(({className:e,...t},r)=>{const{status:n}=gE();return s.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:be("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});yE.displayName="QueueItemIndicator";const vE=m.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=gE();return s.jsx("div",{ref:n,"data-slot":"queue-item-content",className:be("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...r,children:t})});vE.displayName="QueueItemContent";const Kw="https://github.com/alicomert/pixcode/issues/new",YM="https://github.com/alicomert/pixcode",Yw="https://discord.gg/buxwujPNRE";function Zw({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 ZM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onOpenControlRoom:i,onShowSettings:o,t:l}){return s.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.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:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Nw,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),s.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})}),s.jsx("div",{className:"px-3 py-2 md:hidden",children:s.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:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Nw,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),s.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})})]}),s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.jsxs("a",{href:Kw,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:[s.jsx(Il,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:Yw,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:[s.jsx(Zw,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.joinCommunity")})]})}),i&&s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.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:i,children:[s.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-primary/10 text-primary",children:s.jsx(Wr,{className:"h-3.5 w-3.5"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.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:[s.jsx(Dt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:YM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",l("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:Kw,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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Il,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:Yw,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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Zw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.joinCommunity")})]})}),i&&s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.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:i,children:[s.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-primary/15",children:s.jsx(Wr,{className:"w-4.5 h-4.5 text-primary"})}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-base font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),s.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),s.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:s.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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.settings")})]})})]})}const Xw="PIXCODE_GITHUB_STARS",Jw="PIXCODE_HIDE_GITHUB_STAR",XM=3600*1e3,JM=(e,t)=>{const[r,n]=m.useState(null),[a,i]=m.useState(()=>{try{return localStorage.getItem(Jw)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Xw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<XM){n(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){n(p);try{localStorage.setItem(Xw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{i(!0);try{localStorage.setItem(Jw,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},QM="https://github.com/alicomert/pixcode";function e9({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 t9(){const{formattedCount:e,isDismissed:t,dismiss:r}=JM("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:QM,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:[s.jsx(e9,{className:"h-3.5 w-3.5"}),s.jsx($i,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium",children:"Star"}),e&&s.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),s.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:s.jsx(St,{className:"h-2.5 w-2.5"})})]})}function Qw({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return s.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:be(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[s.jsx(_l,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:be(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[s.jsx(cD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function r9({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:h,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:s.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:s.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[s.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"}),s.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"})]})})}),s.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return s.jsxs("div",{className:"flex-shrink-0",children:[s.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[s.jsx(Ce,{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:s.jsx(it,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(Ce,{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:s.jsx(Gt,{className:"h-4 w-4"})}),s.jsx(Ce,{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:s.jsx(nD,{className:"h-4 w-4"})})]})]}),s.jsx(t9,{}),f&&s.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:[s.jsx(Wr,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[s.jsx(Qw,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:be("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:[s.jsx(Wn,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:be("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:[s.jsx(ua,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(Be,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.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:s.jsx(St,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider hidden md:block"}),s.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[s.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:s.jsx(it,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),s.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:s.jsx(ps,{className:"h-4 w-4"})})]})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Qw,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:be("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:[s.jsx(Wn,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:be("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:[s.jsx(ua,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(Be,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.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:s.jsx(St,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const n9=160,ek=180;function wE({actions:e,className:t,triggerLabel:r}){const[n,a]=m.useState(!1),[i,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-n9;p<8&&(p=8);let f=u.bottom+4;f+ek>window.innerHeight&&(f=Math.max(8,u.top-4-ek)),o({top:f,left:p})},[n]),m.useEffect(()=>{if(!n)return;const u=h=>{const g=h.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=h=>{h.key==="Escape"&&a(!1)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:be("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",n&&"bg-accent text-foreground opacity-100",t),children:s.jsx(bD,{className:"h-3.5 w-3.5"})}),n&&i&&uu.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:be("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 s.jsxs("div",{children:[g&&s.jsx("div",{className:"my-1 h-px bg-border/60"}),s.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:be("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:[s.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const tk={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},a9={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},s9=e=>e==="fully-configured"?{icon:Mn,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:e==="taskmaster-only"?{icon:Dt,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:e==="mcp-only"?{icon:Ln,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:St,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function i9({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=s9(e),i=a.icon;return n?s.jsxs("div",{className:be("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,r),title:a.title,children:[s.jsx(i,{className:tk[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:be("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,a9[t],r),title:a.title,children:s.jsx(i,{className:be(tk[t],a.colorClassName)})})}const o9=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const i=a.getTime()-n.getTime(),o=Math.floor(i/1e3),l=Math.floor(i/(1e3*60)),c=Math.floor(i/(1e3*60*60)),d=Math.floor(i/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function rk({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:i,className:o}){const l=d=>s.jsx($i,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:pD,onClick:r},{id:"star",label:e?i("actions.unstarSession",{defaultValue:"Remove star"}):i("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:i("actions.delete"),icon:Tr,onClick:a,danger:!0}),s.jsx(wE,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const l9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},nk={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function kE({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:h,onSessionSelect:g,onDeleteSession:b,t:x}){const y=HO(t,n,x),v=r?.id===t.id,w=a===t.id,k=t.__provider,N=l9[k]??k,S=nk[k]??nk.claude,j=UO(y.sessionName),_=()=>{h(e),g(t,e.name)},A=()=>{p(e.name,t.id,i,k)},E=()=>{b(e.name,t.id,y.sessionName,k)},R=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),I=s.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[s.jsxs("span",{className:be("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",S),children:[s.jsx(pr,{provider:k,className:"h-2.5 w-2.5"}),N]}),s.jsx("span",{className:"text-muted-foreground/80",children:o9(y.sessionTime,n,x)}),y.isActive&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[s.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),j.slice(0,3).map(z=>s.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:[".",z]},z))]}),C=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:z=>c(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Enter"?A():z.key==="Escape"&&u()},onClick:z=>z.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}),s.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:z=>{z.stopPropagation(),A()},title:x("tooltips.save"),children:s.jsx(nr,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),s.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:z=>{z.stopPropagation(),u()},title:x("tooltips.cancel"),children:s.jsx(St,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),F=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:be("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:_,children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:be("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(pr,{provider:k,className:"h-3 w-3"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[o&&s.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]}),s.jsx("div",{className:"flex-shrink-0",onClick:z=>z.stopPropagation(),children:s.jsx(rk,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:E,t:x,className:"!opacity-100"})})]})})}),q=s.jsxs("div",{className:be("group/item relative hidden md:block"),children:[s.jsxs(Ce,{variant:"ghost",className:be("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&s.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&s.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),s.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[s.jsx("div",{className:be("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:s.jsx(pr,{provider:k,className:"h-3 w-3"})}),s.jsx("div",{className:"min-w-0 flex-1",children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&s.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:z=>z.stopPropagation(),children:s.jsx(rk,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:E,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[F,q]})}const c9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function d9(){return s.jsx(s.Fragment,{children:Array.from({length:3}).map((e,t)=>s.jsx("div",{className:"rounded-md p-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),s.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function u9({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:k,t:N}){const[S,j]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let E=!1;const R=async()=>{const I=await Se(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const C=await I.json();E||j((C.runs??[]).slice(0,5))};R();const T=window.setInterval(()=>{R()},15e3);return()=>{E=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const _=r.length>0,A=e.sessionMeta?.hasMore===!0;return s.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[s.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:s.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:[s.jsx(Gt,{className:"h-3 w-3"}),N("sessions.newSession")]})}),s.jsxs(Ce,{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:[s.jsx(Gt,{className:"h-3 w-3"}),N("sessions.newSession")]}),S.length>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(Sn,{className:"h-3 w-3"}),N("orchestration.section")]}),S.map(E=>{const R=[...new Set(E.nodeRuns.map(T=>c9(T.adapterId)).filter(Boolean))];return s.jsx("button",{type:"button",onClick:()=>k?.(e,E.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Sn,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:E.input||N("orchestration.fallbackTitle")}),s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[R.slice(0,4).map(T=>s.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:s.jsx(pr,{provider:T,className:"h-3 w-3"})},T)),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:N(`common:orchestration.status.${E.status}`,{defaultValue:E.status})})]})]})]})},E.id)})]}),a?!_&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:N("sessions.noSessions")})}):r.map(E=>s.jsx(kE,{project:e,session:E,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,E.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:N},E.id)):s.jsx(d9,{}),_&&A&&s.jsx(Ce,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:i,children:i?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),N("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(qr,{className:"h-3 w-3"}),N("sessions.showMore")]})})]})}const p9=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function m9({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:S,onCancelEditingProject:j,onSaveProjectName:_,onDeleteProject:A,onSessionSelect:E,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:C,onEditingSessionNameChange:F,onStartEditingSession:q,onCancelEditingSession:z,onSaveEditingSession:H,t:$}){const P=t?.name===e.name,V=o===e.name,G=e.sessionMeta?.hasMore===!0,B=p9(c,G),Q=`${B} session${c.length===1?"":"s"}`,J=WO(e,b),me=()=>v(e.name),fe=()=>k(e.name),oe=()=>{_(e.name)},he=()=>{t?.name!==e.name&&w(e),me()};return s.jsxs("div",{className:be("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[s.jsxs("div",{className:"md:group group",children:[s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:be("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",P&&"bg-primary/5 border-primary/20",i&&!P&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:me,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s.jsx("div",{className:be("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?s.jsx(Ra,{className:"h-4 w-4 text-primary"}):s.jsx(Wn,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:V?s.jsx("input",{type:"text",value:l,onChange:ce=>y(ce.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:$("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ce=>ce.stopPropagation(),onKeyDown:ce=>{ce.key==="Enter"&&oe(),ce.key==="Escape"&&j()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[s.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&s.jsx(i9,{status:J,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:Q})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:V?s.jsxs(s.Fragment,{children:[s.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:ce=>{ce.stopPropagation(),oe()},children:s.jsx(nr,{className:"h-4 w-4 text-white"})}),s.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:ce=>{ce.stopPropagation(),j()},children:s.jsx(St,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:be("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"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:ce=>{ce.stopPropagation(),fe()},title:$(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx($i,{className:be("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),s.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:ce=>{ce.stopPropagation(),A(e)},children:s.jsx(Tr,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),s.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:ce=>{ce.stopPropagation(),S(e)},children:s.jsx(yh,{className:"h-4 w-4 text-primary"})}),s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?s.jsx(qr,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(On,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Ce,{variant:"ghost",className:be("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",P&&"bg-accent text-accent-foreground",i&&!P&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:he,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?s.jsx(Ra,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Wn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:V?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:ce=>y(ce.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:$("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ce=>{ce.key==="Enter"&&oe(),ce.key==="Escape"&&j()}}),s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):s.jsxs("div",{children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[B,e.fullPath!==e.displayName&&s.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),s.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:V?s.jsxs(s.Fragment,{children:[s.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:ce=>{ce.stopPropagation(),oe()},children:s.jsx(nr,{className:"h-3 w-3"})}),s.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:ce=>{ce.stopPropagation(),j()},children:s.jsx(St,{className:"h-3 w-3"})})]}):s.jsxs(s.Fragment,{children:[i&&s.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:ce=>{ce.stopPropagation(),fe()},title:$("tooltips.removeFromFavorites"),children:s.jsx($i,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(wE,{triggerLabel:$("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:$("actions.rename"),icon:yh,onClick:()=>S(e)},{id:"star",label:$(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:$i,onClick:fe},{id:"delete",label:$("actions.delete",{defaultValue:"Delete"}),icon:Tr,onClick:()=>A(e),danger:!0}]}),n?s.jsx(qr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(On,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(u9,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:x,onEditingSessionNameChange:F,onStartEditingSession:q,onCancelEditingSession:z,onSaveEditingSession:H,onToggleStarSession:N,onProjectSelect:w,onSessionSelect:E,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:C,t:$})]})}function SE({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&s.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("/")})]}):s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(Wn,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(da,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function h9({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:h,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:k,onToggleProject:N,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:E,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:q,onOpenOrchestration:z,onEditingSessionNameChange:H,onStartEditingSession:$,onCancelEditingSession:P,onSaveEditingSession:V,t:G}){const B=s.jsx(SE,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:G});m.useEffect(()=>{let he="Pixcode";const ce=r?.displayName?.trim();ce&&(he=`${ce} - ${he}`),document.title=he},[r]);const Q=!a&&e.length>0&&t.length>0,J=he=>he.source==="history"||he.autoDiscovered===!0&&he.isManuallyAdded!==!0,me=t.filter(he=>!J(he)),fe=t.filter(he=>J(he)),oe=he=>s.jsx(m9,{project:he,selectedProject:r,selectedSession:n,isExpanded:o.has(he.name),isDeleting:g.has(he.name),isStarred:v(he.name),editingProject:l,editingName:c,sessions:y(he),initialSessionsLoaded:u.has(he.name),isLoadingSessions:!!d[he.name],currentTime:p,editingSession:f,editingSessionName:h,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:k,onToggleProject:N,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:E,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:q,onOpenOrchestration:z,onEditingSessionNameChange:H,onStartEditingSession:$,onCancelEditingSession:P,onSaveEditingSession:V,t:G},he.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:Q?s.jsxs(s.Fragment,{children:[me.map(he=>oe(he)),fe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:G("projects.detectedFromHistory")}),fe.map(he=>oe(he))]})]}):B})}function Sa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function NE(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
|
|
229
|
+
*/const ZP=[["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"}]],XP=wt("workflow",ZP),eg=UN,JN=DR,Nw=IR,JP=GR,QP=kR,tg=TR,eD=BN,qr=HN,tD=C7,rg=y7,On=w7,rD=S7,Lr=jR,ca=BN,jd=LR,QN=CR,nD=h7,aD=g7,ng=MR,it=$N,Mt=$N,hu=UR,eC=zR,sD=D8,Ln=J7,Er=e8,nr=p7,Mn=d7,tC=v8,Ir=aL,fu=WN,iD=WN,_d=t7,to=j7,rC=T7,Xl=VN,bl=P7,ro=H7,Vt=q7,Wn=p8,Ra=l8,ps=d8,oD=$8,lD=x8,_l=C8,Jl=J8,cD=VR,Ql=n7,dD=yL,uD=Qf,pD=Qf,yh=z8,nC=h8,mD=i8,hD=cL,fD=Z8,gD=I8,aC=M8,vh=Qf,ag=H8,Gt=q8,Tr=wL,bD=K7,da=j8,St=KN,wh=KN,gu=mL,sg=XR,xD=YR,kh=WR,yD=Z7,ua=GN,vD=GN,wD=SL,Ws=CL,kD=o7,Il=s7,ig=R7,si=a8,og=r8,kn=g8,sC=VN,bo=qN,SD=qN,iC=S8,mn=T8,lg=L8,cg=B7,oC=bL,ND=K8,ec=rL,CD=eL,Dt=O7,ED=xR,tc=$7,Wr=oL,$i=uL,dg=fL,Jr=F7,bu=QR,TD=DL,rc=UL,ug=ZN,AD=ZN,Or=NP,dd=EP,jD=AP,gi=LL,bi=ML,_D=zL,nl=GL,Gi=VL,Cw=ZL,al=JL,Uo=rP,ID=aP,lC=gP,Sh=iP,ns=dP,$o=lP,Ew=pP,Go=hP,Nh=xP,RD=vP,Ch=kP,Oi=RP,sl=PP,qa=OP,xi=FP,LD=BP,Eh=$P,PD=VP,Ho=YP,Sn=XP,Rl=KL,cC=eP,DD=_P,OD=WP,MD=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],FD={up:JN,down:eg,left:QP,right:tg},Vo=e=>e.preventDefault(),Tw="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",zD="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 Aw({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Pe("settings"),[i,o]=m.useState(!1),[l,c]=m.useState(!1),d=m.useCallback(h=>{Vs(e.current,{type:"input",data:h})},[e]),u=m.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=m.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const h=await navigator.clipboard.readText();h.length>0&&d(h)}catch{}},[d]),f=m.useCallback(h=>{let g=h;if(i&&h.length===1){const b=h.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&h.length===1&&(g="\x1B"+g,c(!1)),d(g)},[i,l,d]);return s.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:s.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:[s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>{p()},disabled:!r,className:dp,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(to,{className:"h-4 w-4"})}),MD.map(h=>{if(h.type==="modifier"){const g=h.modifier==="ctrl"?i:l,b=h.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:b,disabled:!r,className:g?zD:Tw,children:h.label},h.id)}if(h.type==="arrow"){const g=FD[h.icon];return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>d(h.sequence),disabled:!r,className:dp,children:s.jsx(g,{className:"h-4 w-4"})},h.id)}return s.jsx("button",{type:"button",onPointerDown:Vo,onClick:()=>f(h.sequence),disabled:!r,className:Tw,children:h.label},h.id)}),s.jsx("button",{type:"button",onPointerDown:Vo,onClick:u,disabled:!r,className:dp,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(eD,{className:"h-4 w-4"})})]})})}function dC({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:i=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=Pe("chat"),[d,u]=m.useState(!1),[p,f]=m.useState(null),h=m.useRef(null),g=m.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:k,authUrl:N,authUrlVersion:S,connectToShell:j,disconnectFromShell:_,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:E}=pR({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),R=m.useCallback(()=>{const G=x.current;if(!G)return;const B=G.buffer.active,Q=B.baseY+B.cursorY,J=Math.min(B.baseY+B.length-1,Q+10),me=Math.max(0,Q-VI),fe=[];for(let Y=me;Y<=J;Y++){const xe=B.getLine(Y);xe&&fe.push(xe.translateToString().trimEnd())}let oe=-1;for(let Y=fe.length-1;Y>=0;Y--)if(/esc to cancel/i.test(fe[Y])||/enter to select/i.test(fe[Y])){oe=Y;break}if(oe===-1){f(null);return}const he=new Map,ce=Math.max(0,oe-qI);for(let Y=oe-1;Y>=ce;Y--){const xe=fe[Y].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(xe){const D=xe[1],le=xe[2].trim();parseInt(D,10)<=WI&&le.length>0&&!he.has(D)&&he.set(D,le)}}const we=[];for(let Y=1;Y<=he.size&&he.has(String(Y));Y++)we.push({number:String(Y),label:he.get(String(Y))});f(we.length>=KI?we:null)},[x]),T=m.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(R,HI)},[R]);m.useEffect(()=>{g.current=T},[T]),m.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),m.useEffect(()=>{v||(h.current&&(clearTimeout(h.current),h.current=null),f(null))},[v]),m.useEffect(()=>{if(!l||!w||!v)return;const G=()=>{x.current?.focus()},B=window.requestAnimationFrame(G),Q=window.setTimeout(G,0);return()=>{window.cancelAnimationFrame(B),window.clearTimeout(Q)}},[l,v,w,x]);const I=m.useCallback(G=>{Vs(y.current,{type:"input",data:G})},[y]),C=m.useMemo(()=>lR(t),[t]),F=m.useMemo(()=>C?C.slice(0,30):null,[C]),q=m.useMemo(()=>C?C.slice(0,50):null,[C]),z=m.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},$I)},[]);if(!e)return s.jsx(hR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(gR,{terminalContainerRef:b,authUrl:N,authUrlVersion:S,initialCommand:r,isConnected:v,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:E}),s.jsx(Aw,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const H=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:q}):c("shell.startSession"),$=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),P=w?k?"connecting":v?null:"connect":"loading",V=P==="connecting"?$:H;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(fR,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:F,onDisconnect:_,onRestart:z,statusNewSessionText:c("shell.status.newSession"),statusInitializingText:c("shell.status.initializing"),statusRestartingText:c("shell.status.restarting"),disconnectLabel:c("shell.actions.disconnect"),disconnectTitle:c("shell.actions.disconnectTitle"),restartLabel:c("shell.actions.restart"),restartTitle:c("shell.actions.restartTitle"),disableRestart:d||v}),s.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[s.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),P&&s.jsx(mR,{mode:P,description:V,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:j}),p&&v&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:G=>G.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(G=>s.jsxs("button",{type:"button",onClick:()=>{I(G.number),f(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:`${G.number}. ${G.label}`,children:[G.number,". ",G.label]},G.number)),s.jsx("button",{type:"button",onClick:()=>{I("\x1B"),f(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"})]})})]}),s.jsx(Aw,{wsRef:y,terminalRef:x,isConnected:v})]})}function BD({className:e}){return s.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.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:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),s.jsx("p",{children:"A project is required to open a shell"})]})})}function UD({title:e,isCompleted:t,onClose:r=null}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&s.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&s.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function uC({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:i=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1}){const[h,g]=m.useState(!1),b=n!==null?n:r!==null,x=m.useCallback(y=>{g(!0),o?.(y)},[o]);return e?s.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&s.jsx(UD,{title:c,isCompleted:h,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(dC,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:i})})]}):s.jsx(BD,{className:d})}const $D=(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"),GD={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:r}){return s.jsx("button",{onClick:r,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function HD({provider:e}){const[t,r]=m.useState(""),[n,a]=m.useState(!1),[i,o]=m.useState("idle"),[l,c]=m.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await Se(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return s.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[s.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",s.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."]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"url",value:t,onChange:u=>r(u.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:u=>{u.key==="Enter"&&d()}}),s.jsx("button",{onClick:()=>void d(),disabled:n||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:n?s.jsx(Mt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),i==="ok"&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx(nr,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),i==="error"&&l&&s.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function VD({provider:e,onSaved:t}){const r=GD[e],[n,a]=m.useState(""),[i,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState("idle"),[p,f]=m.useState(null);m.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await Se("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const h=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await Se(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&i.trim()?i.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);u("ok"),a(""),t()}catch(b){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:s.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:s.jsx(SD,{className:"h-5 w-5 text-foreground"})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),s.jsxs("a",{href:r.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",r.keyConsoleLabel,s.jsx(Lr,{className:"h-3 w-3"})]})]})]}),r.notes&&s.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),s.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",s.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",s.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),s.jsx("input",{type:"url",value:i,onChange:g=>o(g.target.value),placeholder:r.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.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."})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[s.jsxs("button",{onClick:()=>void h(),disabled:l||!n.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?s.jsx(Mt,{className:"h-4 w-4 animate-spin"}):s.jsx(nr,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&s.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):s.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function pC({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:i=!1}){const{t:o}=Pe("common"),l=r!=="cursor",[c,d]=m.useState(l?"apiKey":"browser");m.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=m.useMemo(()=>`${jl[r]??r} Login`,[r]);if(!e)return null;const p=$D(r,a),f=h=>n?.(h);return s.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:s.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:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),s.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:s.jsx(St,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(jw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(jw,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),s.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(uC,{project:TI,command:p,onComplete:f,minimal:!0})}),s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(HD,{provider:r})})]}):s.jsx(VD,{provider:r,onSaved:()=>f(0)})})]})})}const qD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),WD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},KD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},YD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),ZD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=$a(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:r,alt:"OpenCode",className:e})},XD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function pr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(KD,{className:t}):e==="codex"?s.jsx(WD,{className:t}):e==="gemini"?s.jsx(YD,{className:t}):e==="qwen"?s.jsx(XD,{className:t}):e==="opencode"?s.jsx(ZD,{className:t}):s.jsx(qD,{className:t})}function JD({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:i,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return s.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:s.jsx(pr,{provider:e,className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&s.jsx(nr,{className:"h-4 w-4 text-green-500"})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&s.jsx("button",{onClick:o,className:`${i} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const QD=[{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 eO({providerStatuses:e,onOpenProviderLogin:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),s.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),s.jsx("div",{className:"space-y-3",children:QD.map(r=>s.jsx(JD,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),s.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:s.jsx("p",{children:"You can configure these later in Settings."})})]})}function tO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.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:s.jsx(Or,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),s.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(wD,{className:"h-4 w-4"}),"Git Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",id:"gitName",value:e,onChange:i=>n(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:r}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(yD,{className:"h-4 w-4"}),"Git Email ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:i=>a(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:r}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const _w=[{title:"Git Configuration",icon:Or,required:!0},{title:"Connect Agents",icon:QN,required:!1},{title:"Task System",icon:Jl,required:!1}];function rO({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:_w.map((t,r)=>{const n=r<e,a=r===e,i=t.icon;return s.jsxs("div",{className:"contents",children:[s.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[s.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:n?s.jsx(nr,{className:"h-6 w-6"}):s.jsx(i,{className:"h-6 w-6"})}),s.jsxs("div",{className:"mt-2 text-center",children:[s.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&s.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<_w.length-1&&s.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const nO=e=>e?e.installation?.isInstalled?e.installation.version?`TaskMaster CLI installed (${e.installation.version}).`:"TaskMaster CLI installed.":e.installation?.reason||"TaskMaster CLI is not installed yet.":"Checking TaskMaster installation...";function aO({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=m.useState(null),[i,o]=m.useState(!0),[l,c]=m.useState(!1),[d,u]=m.useState([]),[p,f]=m.useState(""),h=m.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=m.useMemo(()=>!e||g,[e,g]);m.useEffect(()=>{r(x)},[r,x]);const y=m.useCallback(async()=>{o(!0),f("");try{const w=await Se("/api/taskmaster/installation-status"),k=await w.json();a(k),w.ok||f(k.installation?.reason||"TaskMaster status check failed.")}catch(w){a(null),f(w instanceof Error?w.message:"TaskMaster status check failed.")}finally{o(!1)}},[]);m.useEffect(()=>(y(),()=>{h.current?.close(),h.current=null}),[y]);const v=m.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await Se("/api/taskmaster/install",{method:"POST"}),k=await w.json();if(!w.ok||!k.success||!k.jobId)throw new Error(k.error||k.message||"TaskMaster install could not start.");const N=localStorage.getItem(mu),S=N?`?token=${encodeURIComponent(N)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(k.jobId)}/stream${S}`);h.current=j,j.addEventListener("log",_=>{const A=JSON.parse(_.data);u(E=>[...E,A].slice(-80))}),j.addEventListener("done",_=>{const A=JSON.parse(_.data);if(j.close(),h.current=null,c(!1),!A.success){f(A.error||A.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),h.current=null,c(!1),f("TaskMaster install stream disconnected.")}}catch(w){c(!1),f(w instanceof Error?w.message:"TaskMaster install could not start.")}},[y]);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:"Task System"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Decide whether Pixcode should enable TaskMaster-backed planning, kanban tasks, PRD parsing, and agent task execution from the start."})]}),s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-background p-4 transition-colors hover:bg-muted/40",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:w=>t(w.target.checked),className:"mt-1 h-4 w-4"}),s.jsxs("span",{className:"min-w-0 space-y-1",children:[s.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Enable TaskMaster features"}),s.jsx("span",{className:"block text-sm leading-6 text-muted-foreground",children:"This keeps the Tasks panel, PRD tools, and orchestration task sync available. You can change it later in Settings."})]})]}),e&&s.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[g?s.jsx(Mn,{className:"h-5 w-5 text-green-600"}):s.jsx(Jr,{className:"h-5 w-5 text-primary"}),s.jsx("h3",{className:"font-medium text-foreground",children:"TaskMaster CLI"})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:nO(n)}),g&&!b&&s.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"MCP server is not configured yet. Core task files work now; MCP can be connected later from Settings."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void y(),disabled:i||l,className:"rounded-md border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:i?"Checking...":"Refresh"}),!g&&s.jsxs("button",{type:"button",onClick:()=>void v(),disabled:l,className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60",children:[l&&s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),l?"Installing...":"Install"]})]})]}),p&&s.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300",children:p}),d.length>0&&s.jsx("pre",{className:"max-h-48 overflow-auto rounded-md bg-black p-3 text-xs leading-5 text-green-200",children:d.map(w=>`${w.stream}> ${w.chunk}`).join("")})]})]})}const Iw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Rw=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function sO({onComplete:e}){const[t,r]=m.useState(0),[n,a]=m.useState(""),[i,o]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),[p,f]=m.useState(null),[h,g]=m.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=m.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=Jf(),k=m.useRef(void 0),N=m.useCallback(async()=>{try{const T=await Se("/api/user/git-config");if(!T.ok)return;const I=await T.json();I.gitName&&a(I.gitName),I.gitEmail&&o(I.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);m.useEffect(()=>{N(),w()},[N,w]),m.useEffect(()=>{const T=k.current;k.current=p,T!=null&&p===null&&w()},[p,w]);const S=T=>{f(T)},j=T=>{T===0&&p&&v(p)},_=async()=>{if(u(""),t!==0){r(T=>T+1);return}if(!n.trim()||!i.trim()){u("Both git name and email are required.");return}if(!Iw.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await Se("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:i})});if(!T.ok){const I=await Rw(T,"Failed to save git configuration");throw new Error(I)}r(I=>I+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},A=()=>{u(""),r(T=>T-1)},E=async()=>{if(h&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(h));const T=await Se("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const I=await Rw(T,"Failed to complete onboarding");throw new Error(I)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},R=t===0?!!(n.trim()&&i.trim()&&Iw.test(i)):t===2?!h||b:!0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"w-full max-w-2xl",children:[s.jsx(rO,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(tO,{gitName:n,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?s.jsx(eO,{providerStatuses:y,onOpenProviderLogin:S}):s.jsx(aO,{enabled:h,onEnabledChange:g,onReadyChange:x}),d&&s.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:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),s.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[s.jsxs("button",{onClick:A,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:[s.jsx(rg,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<2?s.jsx("button",{onClick:_,disabled:!R||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?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(On,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:E,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?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(nr,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(pC,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const iO=["0s","0.1s","0.2s"];function oO(){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(ua,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),s.jsx("div",{className:"flex items-center justify-center space-x-2",children:iO.map(e=>s.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function mC({errorMessage:e}){return e?s.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function Bs({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:i,type:o="text",name:l,autoComplete:c}){return s.jsxs("div",{children:[s.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),s.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(d.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:i})]})}function hC({title:e,description:t,children:r,footerText:n,logo:a}){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsx("div",{className:"w-full max-w-md",children:s.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:a??s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(ua,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,s.jsx("div",{className:"text-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),s.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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"})}),s.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 lO={username:"",password:""};function cO(){const{t:e}=Pe("auth"),{login:t}=ai(),[r,n]=m.useState(lO),[a,i]=m.useState(""),[o,l]=m.useState(!1),c=m.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=m.useCallback(async u=>{if(u.preventDefault(),i(""),!r.username.trim()||!r.password){i(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||i(p.error),l(!1)},[r.password,r.username,t,e]);return s.jsx(hC,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(Bs,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(Bs,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(mC,{errorMessage:a}),s.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 dO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function uO(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 pO(){const{register:e}=ai(),[t,r]=m.useState(dO),[n,a]=m.useState(""),[i,o]=m.useState(!1),l=m.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=m.useCallback(async d=>{d.preventDefault(),a("");const u=uO(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 s.jsx(hC,{title:"Welcome to Pixcode",description:"Set up your account to get started",footerText:"This is a single-user system. Only one account can be created.",logo:s.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:i,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:[s.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),s.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),s.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:i,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:[s.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),s.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&s.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[s.jsx(Bs,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:i,autoComplete:"url"}),s.jsx(Bs,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:i,type:"password",autoComplete:"off"})]}),s.jsx(Bs,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(Bs,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(Bs,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(mC,{errorMessage:n}),s.jsx("button",{type:"submit",disabled:i,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:i?"Setting up...":"Create Account"})]})})}function mO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=ai();return r?s.jsx(oO,{}):n?s.jsx(pO,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(sO,{onComplete:i}):s.jsx(cO,{})}const fC=m.createContext(null),gC=()=>{const e=m.useContext(fC);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},hO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},fO=()=>{const e=m.useRef(null),t=m.useRef(!1),r=m.useRef(!1),[n,a]=m.useState(null),[i,o]=m.useState(!1),l=m.useRef(null),{token:c}=ai(),d=m.useCallback(()=>{if(!t.current)try{const f=hO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const h=new WebSocket(f);h.onopen=()=>{o(!0),e.current=h,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},h.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},h.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},h.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);m.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=m.useCallback(f=>{const h=e.current;h&&h.readyState===WebSocket.OPEN?h.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return m.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:i}),[u,n,i])},gO=({children:e})=>{const t=fO();return s.jsx(fC.Provider,{value:t,children:e})},bC=m.createContext(null);function bO(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Lw(e){return{...e,taskMasterConfigured:e.taskmaster?.hasTaskmaster??!1,taskMasterStatus:e.taskmaster?.status??"not-configured",taskCount:Number(e.taskmaster?.metadata?.taskCount??0),completedCount:Number(e.taskmaster?.metadata?.completed??0)}}function xO(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function yO(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function xo(){const e=m.useContext(bC);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function vO({children:e}){const{latestMessage:t}=gC(),{user:r,token:n,isLoading:a}=ai(),[i,o]=m.useState([]),[l,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(null),[h,g]=m.useState([]),[b,x]=m.useState(null),[y,v]=m.useState(!1),[w,k]=m.useState(!1),[N,S]=m.useState(!1),[j,_]=m.useState(null),A=m.useRef(null);m.useEffect(()=>{A.current=l?.name??null},[l?.name]);const E=m.useCallback(()=>{_(null)},[]),R=m.useCallback((z,H)=>{console.error(`TaskMaster ${z} error:`,H),_(bO(z,H))},[]),T=m.useCallback(z=>{const H=z?Lw(z):null;c(H),u(H?.taskmaster??null),g([]),x(null)},[]),I=m.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),E();const z=await dt.get("/projects");if(!z.ok)throw new Error(`Failed to fetch projects: ${z.status}`);const H=await z.json(),P=(Array.isArray(H)?H:[]).map(B=>Lw(B));o(P);const V=A.current;if(!V)return;const G=P.find(B=>B.name===V)??null;c(G),u(G?.taskmaster??null)}catch(z){R("load projects",z)}finally{v(!1)}},[E,R,n,r]),C=m.useCallback(async()=>{const z=l?.name;if(!z||!r||!n){g([]),x(null);return}try{k(!0),E();const H=await dt.get(`/taskmaster/tasks/${encodeURIComponent(z)}`);if(!H.ok){const V=await H.json();throw new Error(V.message??"Failed to load tasks")}const $=await H.json(),P=Array.isArray($.tasks)?$.tasks:[];g(P),x(xO(P))}catch(H){R("load tasks",H),g([]),x(null)}finally{k(!1)}},[E,l?.name,R,n,r]),F=m.useCallback(async()=>{if(!r||!n){f(null);return}try{S(!0),E();const z=await dt.get("/mcp-utils/taskmaster-server");if(!z.ok)throw new Error(`Failed to load MCP status: ${z.status}`);const H=await z.json();f(H)}catch(z){R("check MCP server status",z),f(null)}finally{S(!1)}},[E,R,n,r]);m.useEffect(()=>{!a&&r&&n&&(I(),F())},[a,F,I,n,r]),m.useEffect(()=>{l?.name&&r&&n&&C()},[l?.name,C,n,r]),m.useEffect(()=>{const z=t;if(yO(z)){if(z.type==="taskmaster-project-updated"&&z.projectName){I();return}if(z.type==="taskmaster-tasks-updated"&&z.projectName===l?.name){C();return}z.type==="taskmaster-mcp-status-changed"&&F()}},[l?.name,t,F,I,C]);const q=m.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:h,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:N,error:j,refreshProjects:I,setCurrentProject:T,refreshTasks:C,refreshMCPStatus:F,clearError:E}),[E,l,j,y,N,w,p,b,d,i,F,I,C,T,h]);return s.jsx(bC.Provider,{value:q,children:e})}const xC=m.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0,refreshTaskMasterInstallation:async()=>{}}),xu=()=>{const e=m.useContext(xC);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},wO=({children:e})=>{const{user:t,token:r,isLoading:n}=ai(),[a,i]=m.useState(()=>{const v=localStorage.getItem("tasks-enabled");return v!==null?JSON.parse(v):!0}),[o,l]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,h]=m.useState(!0),g=!!(t&&r);m.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]);const b=m.useCallback(async({signal:v}={})=>{if(!n){if(!g){p(null),l(null),d(null),h(!1);return}h(!0);try{const w=await dt.get("/taskmaster/installation-status");if(v?.aborted)return;if(w.ok){const k=await w.json();if(v?.aborted)return;p(k),l(k.installation?.isInstalled||!1),d(k.isReady||!1);const N=localStorage.getItem("tasks-enabled");!k.installation?.isInstalled&&!N&&i(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(w){if(v?.aborted)return;console.error("Error checking TaskMaster installation:",w),l(!1),d(!1)}finally{v?.aborted||h(!1)}}},[g,n]);m.useEffect(()=>{const v=new AbortController,w=setTimeout(()=>{b({signal:v.signal})},0);return()=>{v.abort(),clearTimeout(w)}},[b]);const y={tasksEnabled:a,setTasksEnabled:i,toggleTasksEnabled:()=>{i(v=>!v)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f,refreshTaskMasterInstallation:b};return s.jsx(xC.Provider,{value:y,children:e})},yC=m.createContext(null);function yu(){const e=m.useContext(yC);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function kO({children:e}){const{user:t,token:r,isLoading:n}=ai(),[a,i]=m.useState([]),[o,l]=m.useState(!0),[c,d]=m.useState(null),u=!!(t&&r),p=m.useCallback(async()=>{if(!u){i([]),d(null),l(!1);return}l(!0);try{const x=await Se("/api/plugins");if(x.ok){const y=await x.json();i(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);m.useEffect(()=>{n||p()},[n,p]);const f=m.useCallback(async x=>{try{const y=await Se("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),h=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=m.useCallback(async x=>{try{const y=await Se(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=m.useCallback(async(x,y)=>{try{const v=await Se(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const k=await v.json();w=k.details||k.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return s.jsx(yC.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:h,updatePlugin:g,togglePlugin:b},children:e})}const Pw=e=>typeof window>"u"?!1:window.innerWidth<e,Dw=()=>{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 pg(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,i]=m.useState(()=>r?Pw(t):!1),[o,l]=m.useState(()=>n?Dw():!1);return m.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{i(Pw(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),m.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(Dw())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const mg="pixcode.updateCheck.preferences",Th="pixcode:update-check-settings-changed",hg=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],Ah={frequency:"30m"};function Ow(e){return hg.find(t=>t.value===e.frequency)?.intervalMs??null}function vC(e){if(!e||typeof e!="object")return Ah;const t=e.frequency;return hg.some(r=>r.value===t)?{frequency:t}:Ah}function Mw(){try{const e=localStorage.getItem(mg);return vC(e?JSON.parse(e):null)}catch{return Ah}}function SO(e){const t=vC(e);localStorage.setItem(mg,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(Th,{detail:t}))}const up=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const i=r[a]||0,o=n[a]||0;if(i!==o)return i-o}return 0},NO="1.46.5",jh="pixcode:update-available",CO=360*60*1e3,pp=new Map;function wC(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function EO(e,t){try{const r=localStorage.getItem(wC(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function Fw(e,t,r){localStorage.setItem(wC(e,t),JSON.stringify(r))}function TO(e,t){const r=`${e}/${t}`,n=pp.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async i=>({status:i.status,ok:i.ok,data:await i.json().catch(()=>({}))})).finally(()=>{pp.delete(r)});return pp.set(r,a),a}const kC=(e,t)=>{const[r,n]=m.useState(!1),[a,i]=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(()=>Mw()),[x,y]=m.useState(NO),v=m.useRef(null),w=m.useCallback(N=>{SO(N),b(N)},[]);m.useEffect(()=>{const N=()=>b(Mw()),S=j=>{j.key===mg&&N()};return window.addEventListener("storage",S),window.addEventListener(Th,N),()=>{window.removeEventListener("storage",S),window.removeEventListener(Th,N)}},[]),m.useEffect(()=>{let N=!1;const S=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(N)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};S();const j=()=>{S()};return window.addEventListener("focus",j),()=>{N=!0,window.removeEventListener("focus",j)}},[]),m.useEffect(()=>{if(!x)return;let N=!1;const S=(T,I,C,F)=>({updateAvailable:!!(T&&up(T,x)>0),latestVersion:T,releaseInfo:I,currentVersion:x,checkedAt:C,status:F}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(jh,{detail:T}))},_=(T,I,C,F="success")=>{if(!T||!I)return n(!1),i(null),l(null),h(C),S(null,null,C,F);i(T),n(up(T,x)>0),l(I),h(C);const q=S(T,I,C,F);return j(q),q},A=async({force:T=!1}={})=>{const I=Ow(g),C=EO(e,t),F=Date.now();if(!T&&I===null)return p("idle"),_(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!T&&C?.fetchedAt&&I!==null&&F-C.fetchedAt<I)return p("success"),_(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!T&&C?.rateLimitedUntil&&C.rateLimitedUntil>F)return p("error"),_(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const q=await TO(e,t);if(N)return S(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const z=q.data;if(!q.ok)return q.status===403&&Fw(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:F+Math.max(I??0,CO)}),p("error"),_(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(z.tag_name){const H=z.tag_name.replace(/^v/,""),$=up(H,x)>0,P={title:z.name||z.tag_name,body:z.body||"",htmlUrl:z.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:z.published_at||""};Fw(e,t,{fetchedAt:F,latestVersion:H,releaseInfo:P}),i(H),n($),$&&RN({key:`app-update:${H}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${H}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:H,installMode:c}}),l(P),p("success"),h(F);const V=S(H,P,F,"success");return j(V),V}else return n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}catch(q){return console.error("Version check failed:",q),n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}};v.current=A,A();const E=Ow(g),R=E===null?null:window.setInterval(()=>{A()},E);return()=>{N=!0,R!==null&&window.clearInterval(R)}},[e,t,x,c,g]);const k=m.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:k,updateCheckPreferences:g,updatePreferences:w}},Us={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},AO=["flat","grouped"],jO=e=>typeof e=="string"&&AO.includes(e),Id=Object.keys(Us),_O=new Set(Id),mp="ui-preferences:sync",IO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Rd=(e,t,r)=>e==="historyView"?jO(t)?t:r:IO(t,r),RO=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Rd(e,n,t)}catch{return t}},LO=e=>{if(typeof window>"u")return Us;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return Id.reduce((a,i)=>(a[i]=Rd(i,n[i],Us[i]),a),{...Us})}}}catch{}return Id.reduce((t,r)=>(t[r]=RO(r,Us[r]),t),{...Us})};function PO(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!_O.has(r))return e;const a=Rd(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const i of Id){if(!(i in r))continue;const o=r[i],l=Rd(i,o,e[i]);a[i]!==l&&(a[i]=l,n=!0)}return n?a:e}case"reset":return{...Us,...t.value||{}};default:return e}}function fg(e="uiPreferences"){const t=m.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=m.useReducer(PO,e,LO);return m.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(mp,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),m.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(mp,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(mp,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const DO=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},OO=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},MO=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},zw=(e,t)=>`${e}::${t}`,FO=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},zO=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},BO=/(?:^|[\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,UO=e=>{if(!e)return[];const t=new Set,r=new RegExp(BO.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],i=a.lastIndexOf(".");if(i>-1){const o=a.slice(i+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},Ks=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),$O=(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"),GO=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),HO=(e,t,r)=>{const n=Ks(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:$O(e,r),sessionTime:GO(e),messageCount:Number(e.messageCount||0)}},SC=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),i=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=>!i(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>i(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],h=new Map;for(const g of[...r,...n,...a,...c,...p,...f])h.has(g.id)||h.set(g.id,g);return[...h.values()].sort((g,b)=>Ks(b).getTime()-Ks(g).getTime())},Bw=(e,t)=>{const r=SC(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const i=Ks(a);return i>n?i:n},new Date(0))},VO=(e,t,r,n)=>{const a=[...e];return a.sort((i,o)=>{const l=r.has(i.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?Bw(o,n).getTime()-Bw(i,n).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},qO=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),i=n.name.toLowerCase();return a.includes(r)||i.includes(r)}):e},WO=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},KO=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 YO({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setCurrentProject:p,setSidebarVisible:f,sidebarVisible:h}){const[g,b]=m.useState(new Set),[x,y]=m.useState(null),[v,w]=m.useState(!1),[k,N]=m.useState(""),[S,j]=m.useState({}),[_,A]=m.useState({}),[E,R]=m.useState(new Set),[T,I]=m.useState(new Date),[C,F]=m.useState("name"),[q,z]=m.useState(!1),[H,$]=m.useState({}),[P,V]=m.useState(null),[G,B]=m.useState(""),[Q,J]=m.useState(""),[me,fe]=m.useState(new Set),[oe,he]=m.useState(null),[ce,we]=m.useState(null),[Y,xe]=m.useState(!1),[D,le]=m.useState(()=>OO()),[ie,M]=m.useState(()=>FO()),[W,ne]=m.useState("projects"),[ge,ke]=m.useState(null),[ue,Ee]=m.useState(!1),[se,te]=m.useState(null),ee=m.useRef(null),pe=m.useRef(0),Te=m.useRef(null),je=!a&&!h;m.useEffect(()=>{const Re=setInterval(()=>{I(new Date)},6e4);return()=>clearInterval(Re)},[]),m.useEffect(()=>{A({}),R(new Set),$({})},[e]),m.useEffect(()=>{t&&b(Re=>{if(Re.has(t.name))return Re;const Ue=new Set(Re);return Ue.add(t.name),Ue})},[r,t]),m.useEffect(()=>{if(e.length>0&&!n){const Re=new Set;e.forEach(Ue=>{Ue.sessions&&Ue.sessions.length>=0&&Re.add(Ue.name)}),R(Re)}},[e,n]),m.useEffect(()=>{const Re=()=>{F(DO())};Re();const Ue=Qe=>{Qe.key==="claude-settings"&&Re()},mt=()=>Re();return window.addEventListener("storage",Ue),window.addEventListener("pixcode:settings-changed",mt),()=>{window.removeEventListener("storage",Ue),window.removeEventListener("pixcode:settings-changed",mt)}},[]),m.useEffect(()=>{ee.current&&clearTimeout(ee.current),Te.current&&(Te.current.close(),Te.current=null);const Re=Q.trim();if(W!=="conversations"||Re.length<2){pe.current+=1,ke(null),te(null),Ee(!1);return}Ee(!0);const Ue=++pe.current;return ee.current=setTimeout(()=>{if(Ue!==pe.current)return;const mt=dt.searchConversationsUrl(Re),Qe=new EventSource(mt);Te.current=Qe;const Et=[];let Z=0;Qe.addEventListener("result",Ne=>{if(Ue!==pe.current){Qe.close();return}try{const ye=JSON.parse(Ne.data);Et.push(ye.projectResult),Z=ye.totalMatches,ke({results:[...Et],totalMatches:Z,query:Re}),te({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),Qe.addEventListener("progress",Ne=>{if(Ue!==pe.current){Qe.close();return}try{const ye=JSON.parse(Ne.data);Z=ye.totalMatches,te({scannedProjects:ye.scannedProjects,totalProjects:ye.totalProjects})}catch{}}),Qe.addEventListener("done",()=>{if(Ue!==pe.current){Qe.close();return}Qe.close(),Te.current=null,Ee(!1),te(null),Et.length===0&&ke({results:[],totalMatches:0,query:Re})}),Qe.addEventListener("error",()=>{if(Ue!==pe.current){Qe.close();return}Qe.close(),Te.current=null,Ee(!1),te(null),Et.length===0&&ke({results:[],totalMatches:0,query:Re})})},400),()=>{ee.current&&clearTimeout(ee.current),Te.current&&(Te.current.close(),Te.current=null)}},[Q,W]);const Ve=m.useCallback(Re=>{b(Ue=>{const mt=new Set;return Ue.has(Re)||mt.add(Re),mt})},[]),Ze=m.useCallback((Re,Ue)=>{c({...Re,__projectName:Ue})},[c]),ut=m.useCallback(Re=>{le(Ue=>{const mt=new Set(Ue);return mt.has(Re)?mt.delete(Re):mt.add(Re),MO(mt),mt})},[]),Xe=m.useCallback(Re=>D.has(Re),[D]),_t=m.useCallback((Re,Ue)=>{M(mt=>{const Qe=zw(Re,Ue),Et=new Set(mt);return Et.has(Qe)?Et.delete(Qe):Et.add(Qe),zO(Et),Et})},[]),xt=m.useCallback((Re,Ue)=>ie.has(zw(Re,Ue)),[ie]),lt=m.useCallback(Re=>SC(Re,_),[_]),ct=m.useMemo(()=>e.map(Re=>{const Ue=H[Re.name];return Ue===void 0?Re:{...Re,sessionMeta:{...Re.sessionMeta,hasMore:Ue}}}),[H,e]),Nt=m.useMemo(()=>VO(ct,C,D,_),[_,C,ct,D]),It=m.useMemo(()=>qO(Nt,Q),[Q,Nt]),Rt=m.useCallback(Re=>{y(Re.name),N(Re.displayName)},[]),kr=m.useCallback(()=>{y(null),N("")},[]),ar=m.useCallback(async Re=>{try{(await dt.renameProject(Re,k)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ue){console.error("Error renaming project:",Ue)}finally{y(null),N("")}},[k]),hr=m.useCallback((Re,Ue,mt,Qe="claude")=>{we({projectName:Re,sessionId:Ue,sessionTitle:mt,provider:Qe})},[]),Sr=m.useCallback(async()=>{if(!ce)return;const{projectName:Re,sessionId:Ue,provider:mt}=ce;we(null);try{let Qe;if(mt==="codex"?Qe=await dt.deleteCodexSession(Ue):mt==="gemini"?Qe=await dt.deleteGeminiSession(Ue):mt==="qwen"?Qe=await dt.deleteQwenSession(Ue):Qe=await dt.deleteSession(Re,Ue),Qe.ok)d?.(Ue);else{const Et=await Qe.text();console.error("[Sidebar] Failed to delete session:",{status:Qe.status,error:Et}),alert(i("messages.deleteSessionFailed"))}}catch(Qe){console.error("[Sidebar] Error deleting session:",Qe),alert(i("messages.deleteSessionError"))}},[d,ce,i]),De=m.useCallback(Re=>{he({project:Re,sessionCount:lt(Re).length})},[lt]),Je=m.useCallback(async(Re=!1)=>{if(!oe)return;const{project:Ue,sessionCount:mt}=oe,Qe=mt===0;he(null),fe(Et=>new Set([...Et,Ue.name]));try{const Et=await dt.deleteProject(Ue.name,!Qe,Re);if(Et.ok)u?.(Ue.name);else{const Z=await Et.json();alert(Z.error||i("messages.deleteProjectFailed"))}}catch(Et){console.error("Error deleting project:",Et),alert(i("messages.deleteProjectError"))}finally{fe(Et=>{const Z=new Set(Et);return Z.delete(Ue.name),Z})}},[oe,u,i]),We=m.useCallback(async Re=>{const Ue=H[Re.name];if(!(!(Ue!==void 0?Ue:Re.sessionMeta?.hasMore===!0)||S[Re.name])){j(Qe=>({...Qe,[Re.name]:!0}));try{const Qe=(Re.sessions?.length||0)+(_[Re.name]?.length||0),Et=await dt.sessions(Re.name,5,Qe);if(!Et.ok)return;const Z=await Et.json();A(Ne=>({...Ne,[Re.name]:[...Ne[Re.name]||[],...Z.sessions||[]]})),Z.hasMore===!1&&$(Ne=>({...Ne,[Re.name]:!1}))}catch(Qe){console.error("Error loading more sessions:",Qe)}finally{j(Qe=>({...Qe,[Re.name]:!1}))}}},[_,S,H]),pt=m.useCallback(Re=>{l(Re),p(Re)},[l,p]),Fe=m.useCallback(async()=>{z(!0);try{await o()}finally{z(!1)}},[o]),qe=m.useCallback(async(Re,Ue,mt,Qe)=>{const Et=mt.trim();if(!Et){V(null),B("");return}try{const Z=await dt.renameSession(Ue,Et,Qe);Z.ok?await o():(console.error("[Sidebar] Failed to rename session:",Z.status),alert(i("messages.renameSessionFailed")))}catch(Z){console.error("[Sidebar] Error renaming session:",Z),alert(i("messages.renameSessionError"))}finally{V(null),B("")}},[o,i]),gt=m.useCallback(()=>{f(!1)},[f]),sr=m.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:je,expandedProjects:g,editingProject:x,showNewProject:v,editingName:k,loadingSessions:S,additionalSessions:_,initialSessionsLoaded:E,currentTime:T,projectSortOrder:C,isRefreshing:q,editingSession:P,editingSessionName:G,searchFilter:Q,deletingProjects:me,deleteConfirmation:oe,sessionDeleteConfirmation:ce,showVersionModal:Y,starredProjects:D,starredSessions:ie,filteredProjects:It,toggleProject:Ve,handleSessionClick:Ze,toggleStarProject:ut,isProjectStarred:Xe,toggleStarSession:_t,isSessionStarred:xt,getProjectSessions:lt,startEditing:Rt,cancelEditing:kr,saveProjectName:ar,showDeleteSessionConfirmation:hr,confirmDeleteSession:Sr,requestProjectDelete:De,confirmDeleteProject:Je,loadMoreSessions:We,handleProjectSelect:pt,refreshProjects:Fe,updateSessionSummary:qe,collapseSidebar:gt,expandSidebar:sr,setShowNewProject:w,setEditingName:N,setEditingSession:V,setEditingSessionName:B,searchMode:W,setSearchMode:ne,conversationResults:ge,isSearching:ue,searchProgress:se,clearConversationResults:m.useCallback(()=>{pe.current+=1,Te.current&&(Te.current.close(),Te.current=null),Ee(!1),te(null),ke(null)},[]),setSearchFilter:J,setDeleteConfirmation:he,setSessionDeleteConfirmation:we,setShowVersionModal:xe}}const ZO="https://discord.gg/buxwujPNRE",XO="https://github.com/alicomert/pixcode/issues/new";function JO({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 QO({onExpand:e,onOpenControlRoom:t,onShowSettings:r,updateAvailable:n,onShowVersionModal:a,t:i}){return s.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[s.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":i("common:versionUpdate.ariaLabels.showSidebar"),title:i("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(aD,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),t&&s.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":i("actions.controlRoom",{defaultValue:"Control Room"}),title:i("actions.controlRoom",{defaultValue:"Control Room"}),children:s.jsx(Wr,{className:"h-4 w-4 text-primary"})}),s.jsx("button",{onClick:r,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("actions.settings"),title:i("actions.settings"),children:s.jsx(Dt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:XO,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":i("actions.reportIssue"),title:i("actions.reportIssue"),children:s.jsx(Il,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:ZO,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":i("actions.joinCommunity"),title:i("actions.joinCommunity"),children:s.jsx(JO,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&s.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":i("common:versionUpdate.ariaLabels.updateAvailable"),title:i("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(Wr,{className:"h-4 w-4 text-blue-500"}),s.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function NC(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=NC(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function CC(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=NC(e))&&(n&&(n+=" "),n+=t);return n}const Uw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$w=CC,gg=(e,t)=>r=>{var n;if(t?.variants==null)return $w(e,r?.class,r?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=i?.[d];if(u===null)return null;const f=Uw(u)||Uw(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...h}=u;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,f]:d},[]);return $w(e,o,c,r?.class,r?.className)},bg="-",eM=e=>{const t=rM(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(bg);return l[0]===""&&l.length!==1&&l.shift(),EC(l,t)||tM(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},EC=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?EC(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(bg);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Gw=/^\[(.+)\]$/,tM=e=>{if(Gw.test(e)){const t=Gw.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},rM=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)_h(r[a],n,a,t);return n},_h=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Hw(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(nM(a)){_h(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{_h(o,Hw(t,i),r,n)})})},Hw=(e,t)=>{let r=e;return t.split(bg).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},nM=e=>e.isThemeGetter,aM=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(i,o)=>{r.set(i,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=n.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},Ih="!",Rh=":",sM=Rh.length,iM=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const i=[];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===Rh){i.push(a.slice(c,g)),c=g+sM;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=oM(u),f=p!==u,h=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+Rh,i=n;n=o=>o.startsWith(a)?i(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=i=>r({className:i,parseClassName:a})}return n},oM=e=>e.endsWith(Ih)?e.substring(0,e.length-1):e.startsWith(Ih)?e.substring(1):e,lM=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let i=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...i.sort(),o),i=[]):i.push(o)}),a.push(...i.sort()),a}},cM=e=>({cache:aM(e.cacheSize),parseClassName:iM(e),sortModifiers:lM(e),...eM(e)}),dM=/\s+/,uM=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(dM);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=i(f).join(":"),w=h?v+Ih:v,k=w+y;if(o.includes(k))continue;o.push(k);const N=a(y,x);for(let S=0;S<N.length;++S){const j=N[S];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function pM(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=TC(t))&&(n&&(n+=" "),n+=r);return n}const TC=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=TC(e[n]))&&(r&&(r+=" "),r+=t);return r};function mM(e,...t){let r,n,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=cM(d),n=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=uM(c,r);return a(c,u),u}return function(){return i(pM.apply(null,arguments))}}const fr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},AC=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jC=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hM=/^\d+\/\d+$/,fM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gM=/\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$/,bM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,xM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yi=e=>hM.test(e),bt=e=>!!e&&!Number.isNaN(Number(e)),Wa=e=>!!e&&Number.isInteger(Number(e)),hp=e=>e.endsWith("%")&&bt(e.slice(0,-1)),ya=e=>fM.test(e),vM=()=>!0,wM=e=>gM.test(e)&&!bM.test(e),_C=()=>!1,kM=e=>xM.test(e),SM=e=>yM.test(e),NM=e=>!Ge(e)&&!He(e),CM=e=>yo(e,LC,_C),Ge=e=>AC.test(e),As=e=>yo(e,PC,wM),fp=e=>yo(e,_M,bt),Vw=e=>yo(e,IC,_C),EM=e=>yo(e,RC,SM),Sc=e=>yo(e,DC,kM),He=e=>jC.test(e),qo=e=>vo(e,PC),TM=e=>vo(e,IM),qw=e=>vo(e,IC),AM=e=>vo(e,LC),jM=e=>vo(e,RC),Nc=e=>vo(e,DC,!0),yo=(e,t,r)=>{const n=AC.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},vo=(e,t,r=!1)=>{const n=jC.exec(e);return n?n[1]?t(n[1]):r:!1},IC=e=>e==="position"||e==="percentage",RC=e=>e==="image"||e==="url",LC=e=>e==="length"||e==="size"||e==="bg-size",PC=e=>e==="length",_M=e=>e==="number",IM=e=>e==="family-name",DC=e=>e==="shadow",RM=()=>{const e=fr("color"),t=fr("font"),r=fr("text"),n=fr("font-weight"),a=fr("tracking"),i=fr("leading"),o=fr("breakpoint"),l=fr("container"),c=fr("spacing"),d=fr("radius"),u=fr("shadow"),p=fr("inset-shadow"),f=fr("text-shadow"),h=fr("drop-shadow"),g=fr("blur"),b=fr("perspective"),x=fr("aspect"),y=fr("ease"),v=fr("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"],N=()=>[...k(),He,Ge],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],_=()=>[He,Ge,c],A=()=>[yi,"full","auto",..._()],E=()=>[Wa,"none","subgrid",He,Ge],R=()=>["auto",{span:["full",Wa,He,Ge]},Wa,He,Ge],T=()=>[Wa,"auto",He,Ge],I=()=>["auto","min","max","fr",He,Ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],F=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",..._()],z=()=>[yi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],H=()=>[e,He,Ge],$=()=>[...k(),qw,Vw,{position:[He,Ge]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",AM,CM,{size:[He,Ge]}],G=()=>[hp,qo,As],B=()=>["","none","full",d,He,Ge],Q=()=>["",bt,qo,As],J=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[bt,hp,qw,Vw],oe=()=>["","none",g,He,Ge],he=()=>["none",bt,He,Ge],ce=()=>["none",bt,He,Ge],we=()=>[bt,He,Ge],Y=()=>[yi,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ya],breakpoint:[ya],color:[vM],container:[ya],"drop-shadow":[ya],ease:["in","out","in-out"],font:[NM],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ya],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ya],shadow:[ya],spacing:["px",bt],text:[ya],"text-shadow":[ya],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yi,Ge,He,x]}],container:["container"],columns:[{columns:[bt,Ge,He,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:N()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Wa,"auto",He,Ge]}],basis:[{basis:[yi,"full","auto",l,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[bt,yi,"auto","initial","none",Ge]}],grow:[{grow:["",bt,He,Ge]}],shrink:[{shrink:["",bt,He,Ge]}],order:[{order:[Wa,"first","last","none",He,Ge]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...F(),"normal"]}],"justify-self":[{"justify-self":["auto",...F()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...F(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...F(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...F(),"baseline"]}],"place-self":[{"place-self":["auto",...F()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",r,qo,As]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,He,fp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",hp,Ge]}],"font-family":[{font:[TM,Ge,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,He,Ge]}],"line-clamp":[{"line-clamp":[bt,"none",He,fp]}],leading:[{leading:[i,..._()]}],"list-image":[{"list-image":["none",He,Ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",He,Ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:H()}],"text-color":[{text:H()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[bt,"from-font","auto",He,As]}],"text-decoration-color":[{decoration:H()}],"underline-offset":[{"underline-offset":[bt,"auto",He,Ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",He,Ge]}],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",He,Ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:$()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Wa,He,Ge],radial:["",He,Ge],conic:[Wa,He,Ge]},jM,EM]}],"bg-color":[{bg:H()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:H()}],"gradient-via":[{via:H()}],"gradient-to":[{to:H()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:H()}],"border-color-x":[{"border-x":H()}],"border-color-y":[{"border-y":H()}],"border-color-s":[{"border-s":H()}],"border-color-e":[{"border-e":H()}],"border-color-t":[{"border-t":H()}],"border-color-r":[{"border-r":H()}],"border-color-b":[{"border-b":H()}],"border-color-l":[{"border-l":H()}],"divide-color":[{divide:H()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[bt,He,Ge]}],"outline-w":[{outline:["",bt,qo,As]}],"outline-color":[{outline:H()}],shadow:[{shadow:["","none",u,Nc,Sc]}],"shadow-color":[{shadow:H()}],"inset-shadow":[{"inset-shadow":["none",p,Nc,Sc]}],"inset-shadow-color":[{"inset-shadow":H()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:H()}],"ring-offset-w":[{"ring-offset":[bt,As]}],"ring-offset-color":[{"ring-offset":H()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":H()}],"text-shadow":[{"text-shadow":["none",f,Nc,Sc]}],"text-shadow-color":[{"text-shadow":H()}],opacity:[{opacity:[bt,He,Ge]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"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":[bt]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":H()}],"mask-image-linear-to-color":[{"mask-linear-to":H()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":H()}],"mask-image-t-to-color":[{"mask-t-to":H()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":H()}],"mask-image-r-to-color":[{"mask-r-to":H()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":H()}],"mask-image-b-to-color":[{"mask-b-to":H()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":H()}],"mask-image-l-to-color":[{"mask-l-to":H()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":H()}],"mask-image-x-to-color":[{"mask-x-to":H()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":H()}],"mask-image-y-to-color":[{"mask-y-to":H()}],"mask-image-radial":[{"mask-radial":[He,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":H()}],"mask-image-radial-to-color":[{"mask-radial-to":H()}],"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":[bt]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":H()}],"mask-image-conic-to-color":[{"mask-conic-to":H()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:$()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ge]}],filter:[{filter:["","none",He,Ge]}],blur:[{blur:oe()}],brightness:[{brightness:[bt,He,Ge]}],contrast:[{contrast:[bt,He,Ge]}],"drop-shadow":[{"drop-shadow":["","none",h,Nc,Sc]}],"drop-shadow-color":[{"drop-shadow":H()}],grayscale:[{grayscale:["",bt,He,Ge]}],"hue-rotate":[{"hue-rotate":[bt,He,Ge]}],invert:[{invert:["",bt,He,Ge]}],saturate:[{saturate:[bt,He,Ge]}],sepia:[{sepia:["",bt,He,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ge]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[bt,He,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[bt,He,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",bt,He,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[bt,He,Ge]}],"backdrop-invert":[{"backdrop-invert":["",bt,He,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[bt,He,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[bt,He,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",bt,He,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",He,Ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[bt,"initial",He,Ge]}],ease:[{ease:["linear","initial",y,He,Ge]}],delay:[{delay:[bt,He,Ge]}],animate:[{animate:["none",v,He,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,He,Ge]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[He,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],accent:[{accent:H()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:H()}],"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",He,Ge]}],"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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",He,Ge]}],fill:[{fill:["none",...H()]}],"stroke-w":[{stroke:[bt,qo,As,fp]}],stroke:[{stroke:["none",...H()]}],"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"]}},LM=mM(RM);function be(...e){return LM(CC(e))}function PM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const DM=gg("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"}}),OC=m.forwardRef(({className:e,variant:t,...r},n)=>s.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:be(DM({variant:t}),e),...r}));OC.displayName="Alert";const OM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-title",className:be("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));OM.displayName="AlertTitle";const MM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-description",className:be("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));MM.displayName="AlertDescription";const FM=gg("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 st({className:e,variant:t,...r}){return s.jsx("div",{className:be(FM({variant:t}),e),...r})}const zM=gg("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"}}),Ce=m.forwardRef(({className:e,variant:t,size:r,...n},a)=>s.jsx("button",{className:be(zM({variant:t,size:r,className:e})),ref:a,...n}));Ce.displayName="Button";const MC=m.createContext(null),FC=()=>{const e=m.useContext(MC);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},zC=({className:e,approval:t="pending",children:r,...n})=>{const a=m.useMemo(()=>({approval:t}),[t]);return s.jsx(MC.Provider,{value:a,children:s.jsx(OC,{className:be("flex flex-col gap-2",e),...n,children:r})})};zC.displayName="Confirmation";const BC=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:be("text-muted-foreground inline text-sm",e),...t});BC.displayName="ConfirmationTitle";const UC=({children:e})=>{const{approval:t}=FC();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};UC.displayName="ConfirmationRequest";const $C=({className:e,...t})=>{const{approval:r}=FC();return r!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:be("flex items-center justify-end gap-2 self-end",e),...t})};$C.displayName="ConfirmationActions";const ud=({variant:e="default",...t})=>s.jsx(Ce,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});ud.displayName="ConfirmationAction";const GC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));GC.displayName="Card";const HC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("flex flex-col space-y-1.5 p-4",e),...t}));HC.displayName="CardHeader";const VC=m.forwardRef(({className:e,...t},r)=>s.jsx("h3",{ref:r,className:be("font-semibold leading-none tracking-tight",e),...t}));VC.displayName="CardTitle";const BM=m.forwardRef(({className:e,...t},r)=>s.jsx("p",{ref:r,className:be("text-sm text-muted-foreground",e),...t}));BM.displayName="CardDescription";const qC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("p-4 pt-0",e),...t}));qC.displayName="CardContent";const WC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("flex items-center p-4 pt-0",e),...t}));WC.displayName="CardFooter";const UM=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("ml-auto shrink-0",e),...t}));UM.displayName="CardAction";const KC=m.createContext(null);function YC(){const e=m.useContext(KC);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const ms=m.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...i},o)=>{const[l,c]=m.useState(e),d=t!==void 0,u=d?t:l,p=m.useCallback(h=>{d||c(h),r?.(h)},[d,r]),f=m.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(KC.Provider,{value:f,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...i,children:a})})});ms.displayName="Collapsible";const La=m.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:i,onOpenChange:o}=YC(),l=m.useCallback(c=>{o(!i),e?.(c)},[i,o,e]);return s.jsx("button",{ref:a,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:l,className:r,...n,children:t})});La.displayName="CollapsibleTrigger";const hs=m.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=YC();return s.jsx("div",{ref:n,"data-state":a?"open":"closed",className:be("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:s.jsx("div",{className:"overflow-hidden",children:t})})});hs.displayName="CollapsibleContent";const ZC=m.createContext(null);function xg(){const e=m.useContext(ZC);if(!e)throw new Error("Command components must be used within <Command>");return e}const XC=m.forwardRef(({className:e,children:t,...r},n)=>{const[a,i]=m.useState(""),o=m.useRef(new Map),[l,c]=m.useState(0),d=m.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=m.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=m.useCallback((v,w)=>{const k=o.current.get(v);k&&Object.assign(k,w)},[]),f=m.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[k,N]of o.current)(!v||N.value.includes(v))&&w.add(k);return w},[a,l]),h=m.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=m.useState(null);m.useEffect(()=>{b(h.length>0?h[0].id:null)},[h]);const x=m.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=h;if(w.length===0)return;if(v.key==="Enter"){w.find(A=>A.id===g)?.onSelect();return}const k=w.findIndex(_=>_.id===g);let N;v.key==="ArrowDown"?N=k<w.length-1?k+1:0:N=k>0?k-1:w.length-1;const S=w[N].id;b(S),w[N].element?.scrollIntoView({block:"nearest"})},[h,g]),y=m.useMemo(()=>({search:a,setSearch:i,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return s.jsx(ZC.Provider,{value:y,children:s.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:be("flex flex-col",e),onKeyDown:x,...r,children:t})})});XC.displayName="Command";const JC=m.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:i}=xg();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(da,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>i(o.target.value),placeholder:t,className:be("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})});JC.displayName="CommandInput";const QC=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,role:"listbox",className:be("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));QC.displayName="CommandList";const eE=m.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=xg();return!n||a.size>0?null:s.jsx("div",{ref:r,className:be("py-6 text-center text-sm text-muted-foreground",e),...t})});eE.displayName="CommandEmpty";const tE=m.forwardRef(({className:e,heading:t,children:r,...n},a)=>s.jsxs("div",{ref:a,className:be("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&s.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));tE.displayName="CommandGroup";const rE=m.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=xg(),h=m.useId(),g=m.useRef(null),b=t||(typeof a=="string"?a:"");m.useEffect(()=>(u({id:h,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(h)),[h,b,u,p]),m.useEffect(()=>{f(h,{onSelect:r||(()=>{})})},[h,r,f]);const x=m.useCallback(v=>{g.current=v,f(h,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[h,f,o]);if(!l.has(h))return null;const y=c===h;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:be("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==h&&d(h)},onClick:()=>!n&&r?.(),...i,children:a})});rE.displayName="CommandItem";const $M=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:be("-mx-1 h-px bg-border",e),...t}));$M.displayName="CommandSeparator";function Lh({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=$a(),i=typeof e=="boolean"&&typeof t=="function",o=i?e:n,l=()=>{if(i&&t){t(!o);return}a()};return s.jsxs("button",{onClick:l,className:be("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":r,children:[s.jsx("span",{className:"sr-only",children:r}),s.jsx("span",{className:be("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?s.jsx(lg,{className:"h-3 w-3 text-primary"}):s.jsx(dg,{className:"h-3 w-3 text-white dark:text-background"})})]})}const nE=m.createContext(null);function aE(){const e=m.useContext(nE);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const sE=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,i]=m.useState(r),o=m.useRef(null),l=e!==void 0,c=l?e:a,d=m.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=m.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(nE.Provider,{value:u,children:n})},GM=m.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:i,triggerRef:o}=aE(),l=m.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(r&&m.isValidElement(t)){const c=t;return m.cloneElement(c,{onClick:d=>{i(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return s.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});GM.displayName="DialogTrigger";const Ww='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',yg=m.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=aE(),d=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),m.useEffect(()=>{if(!o)return;const p=h=>{if(h.key==="Escape"){h.stopPropagation(),r?.(),l(!1);return}if(h.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(Ww));if(g.length===0)return;const b=g[0],x=g[g.length-1];h.shiftKey&&document.activeElement===b?(h.preventDefault(),x.focus()):!h.shiftKey&&document.activeElement===x&&(h.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),m.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(Ww)?.focus()})},[o]),o?uu.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50",children:[s.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),s.jsx("div",{ref:p=>{d.current=p,typeof i=="function"?i(p):i&&(i.current=p)},role:"dialog","aria-modal":"true",className:be("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});yg.displayName="DialogContent";const vg=m.forwardRef(({className:e,...t},r)=>s.jsx("h2",{ref:r,className:be("sr-only",e),...t}));vg.displayName="DialogTitle";const Be=m.forwardRef(({className:e,type:t,...r},n)=>s.jsx("input",{type:t,className:be("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Be.displayName="Input";const wg=m.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>s.jsx("div",{className:be("relative overflow-hidden",e),...n,children:s.jsx("div",{ref:a,className:be("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));wg.displayName="ScrollArea";const Ld=m.memo(({children:e,className:t,as:r="span"})=>s.jsx(r,{className:be("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}));Ld.displayName="Shimmer";const iE=m.createContext(null),HM=()=>{const e=m.useContext(iE);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},VM=1e3,qM=1e3,Ph=m.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:i,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=m.useState(c),f=r!==void 0,h=f?r:u,g=m.useCallback(S=>{f||p(S),a?.(S)},[f,a]),[b,x]=m.useState(i),y=m.useRef(t),[v,w]=m.useState(!1),k=m.useRef(null);m.useEffect(()=>{i!==void 0&&x(i)},[i]),m.useEffect(()=>{t?(y.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/qM)),k.current=null)},[t]),m.useEffect(()=>{t&&!h&&!d&&g(!0)},[t,h,g,d]),m.useEffect(()=>{if(y.current&&!t&&h&&!v){const S=setTimeout(()=>{g(!1),w(!0)},VM);return()=>clearTimeout(S)}},[t,h,g,v]);const N=m.useMemo(()=>({duration:b,isOpen:h,isStreaming:t,setIsOpen:g}),[b,h,t,g]);return s.jsx(iE.Provider,{value:N,children:s.jsx(ms,{open:h,onOpenChange:g,className:be("not-prose",e),...l,children:o})})});Ph.displayName="Reasoning";const WM=(e,t)=>e||t===0?s.jsx(Ld,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Dh=m.memo(({className:e,children:t,getThinkingMessage:r=WM,...n})=>{const{isStreaming:a,isOpen:i,duration:o}=HM();return s.jsx(La,{className:be("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??s.jsxs(s.Fragment,{children:[s.jsx(AD,{className:"h-4 w-4"}),r(a,o),s.jsx(HN,{className:be("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Dh.displayName="ReasoningTrigger";const Oh=m.memo(({className:e,children:t,...r})=>s.jsx(hs,{className:be("mt-4 text-sm text-muted-foreground",e),...r,children:t}));Oh.displayName="ReasoningContent";function KM(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 na({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[i,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(),N=8,S={position:"fixed",zIndex:9999};switch(r){case"bottom":S.left=k.left+k.width/2,S.top=k.bottom+N,S.transform="translateX(-50%)";break;case"left":S.left=k.left-N,S.top=k.top+k.height/2,S.transform="translate(-100%, -50%)";break;case"right":S.left=k.right+N,S.top=k.top+k.height/2,S.transform="translateY(-50%)";break;case"top":default:S.left=k.left+k.width/2,S.top=k.top-N,S.transform="translate(-50%, -100%)";break}f(S)},[r]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return m.useEffect(()=>()=>{g()},[]),m.useEffect(()=>{if(!i||typeof document>"u")return;const w=k=>{const N=k.target;N instanceof Node&&d.current?.contains(N)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),m.useEffect(()=>{if(!i){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)}},[i,h]),t?s.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&uu.createPortal(s.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:be("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",n),children:[t,s.jsx("div",{className:be("absolute w-0 h-0 border-4 border-transparent",KM(r))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const oE=m.createContext(null),lE=m.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const i=m.useMemo(()=>({status:t}),[t]);return s.jsx(oE.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:be("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});lE.displayName="PromptInput";const cE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:be("px-3 pt-3",e),...t}));cE.displayName="PromptInputHeader";const dE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:be("relative",e),...t}));dE.displayName="PromptInputBody";const uE=m.forwardRef(({className:e,...t},r)=>s.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:be("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}));uE.displayName="PromptInputTextarea";const pE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:be("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));pE.displayName="PromptInputFooter";const mE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:be("flex items-center gap-1",e),...t}));mE.displayName="PromptInputTools";const pd=m.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const i=s.jsx(Ce,{ref:a,type:"button",variant:"ghost",size:"icon",className:be("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?s.jsx(na,{content:t.shortcut?s.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,s.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:i}):i});pd.displayName="PromptInputButton";const hE=m.forwardRef(({className:e,status:t,children:r,...n},a)=>{const i=m.useContext(oE),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Ce,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:be("h-8 w-8 rounded-lg",e),...n,children:r??(l?s.jsx(gu,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(sD,{className:"h-4 w-4"}))})});hE.displayName="PromptInputSubmit";function kg({children:e,className:t}){return s.jsx("div",{className:be("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Sg({isActive:e,onClick:t,children:r,className:n}){return s.jsx("button",{onClick:t,className:be("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",n),children:r})}const fE=m.createContext(null);function gE(){const e=m.useContext(fE);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const bE=m.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:be("space-y-0.5",e),...t}));bE.displayName="Queue";const xE=m.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const i=m.useMemo(()=>({status:e}),[e]);return s.jsx(fE.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:be("flex items-start gap-2 py-0.5",t),...n,children:r})})});xE.displayName="QueueItem";const yE=m.forwardRef(({className:e,...t},r)=>{const{status:n}=gE();return s.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:be("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});yE.displayName="QueueItemIndicator";const vE=m.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=gE();return s.jsx("div",{ref:n,"data-slot":"queue-item-content",className:be("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...r,children:t})});vE.displayName="QueueItemContent";const Kw="https://github.com/alicomert/pixcode/issues/new",YM="https://github.com/alicomert/pixcode",Yw="https://discord.gg/buxwujPNRE";function Zw({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 ZM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onOpenControlRoom:i,onShowSettings:o,t:l}){return s.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.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:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Nw,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),s.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})}),s.jsx("div",{className:"px-3 py-2 md:hidden",children:s.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:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Nw,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),s.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:l("version.updateAvailable")})]})]})})]}),s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.jsxs("a",{href:Kw,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:[s.jsx(Il,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:Yw,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:[s.jsx(Zw,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.joinCommunity")})]})}),i&&s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.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:i,children:[s.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-primary/10 text-primary",children:s.jsx(Wr,{className:"h-3.5 w-3.5"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.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:[s.jsx(Dt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:l("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:YM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",l("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:Kw,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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Il,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:Yw,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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Zw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.joinCommunity")})]})}),i&&s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.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:i,children:[s.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-primary/15",children:s.jsx(Wr,{className:"w-4.5 h-4.5 text-primary"})}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-base font-semibold text-foreground",children:l("actions.controlRoom",{defaultValue:"Control Room"})}),s.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l("actions.controlRoomDescription",{defaultValue:"Admin, access, runs"})})]})]})}),s.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:s.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:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:l("actions.settings")})]})})]})}const Xw="PIXCODE_GITHUB_STARS",Jw="PIXCODE_HIDE_GITHUB_STAR",XM=3600*1e3,JM=(e,t)=>{const[r,n]=m.useState(null),[a,i]=m.useState(()=>{try{return localStorage.getItem(Jw)==="true"}catch{return!1}});m.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Xw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<XM){n(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){n(p);try{localStorage.setItem(Xw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=m.useCallback(()=>{i(!0);try{localStorage.setItem(Jw,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},QM="https://github.com/alicomert/pixcode";function e9({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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 t9(){const{formattedCount:e,isDismissed:t,dismiss:r}=JM("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:QM,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:[s.jsx(e9,{className:"h-3.5 w-3.5"}),s.jsx($i,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium",children:"Star"}),e&&s.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),s.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:s.jsx(St,{className:"h-2.5 w-2.5"})})]})}function Qw({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return s.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:be(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[s.jsx(_l,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:be(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[s.jsx(cD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function r9({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:h,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:s.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:s.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[s.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"}),s.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"})]})})}),s.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return s.jsxs("div",{className:"flex-shrink-0",children:[s.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[s.jsx(Ce,{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:s.jsx(it,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(Ce,{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:s.jsx(Gt,{className:"h-4 w-4"})}),s.jsx(Ce,{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:s.jsx(nD,{className:"h-4 w-4"})})]})]}),s.jsx(t9,{}),f&&s.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:[s.jsx(Wr,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[s.jsx(Qw,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:be("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:[s.jsx(Wn,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:be("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:[s.jsx(ua,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(Be,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.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:s.jsx(St,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider hidden md:block"}),s.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[s.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:s.jsx(it,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),s.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:s.jsx(ps,{className:"h-4 w-4"})})]})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Qw,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:be("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:[s.jsx(Wn,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:be("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:[s.jsx(ua,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(Be,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.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:s.jsx(St,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const n9=160,ek=180;function wE({actions:e,className:t,triggerLabel:r}){const[n,a]=m.useState(!1),[i,o]=m.useState(null),l=m.useRef(null),c=m.useRef(null);m.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-n9;p<8&&(p=8);let f=u.bottom+4;f+ek>window.innerHeight&&(f=Math.max(8,u.top-4-ek)),o({top:f,left:p})},[n]),m.useEffect(()=>{if(!n)return;const u=h=>{const g=h.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=h=>{h.key==="Escape"&&a(!1)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:be("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",n&&"bg-accent text-foreground opacity-100",t),children:s.jsx(bD,{className:"h-3.5 w-3.5"})}),n&&i&&uu.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:be("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 s.jsxs("div",{children:[g&&s.jsx("div",{className:"my-1 h-px bg-border/60"}),s.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:be("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:[s.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const tk={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},a9={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},s9=e=>e==="fully-configured"?{icon:Mn,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:e==="taskmaster-only"?{icon:Dt,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:e==="mcp-only"?{icon:Ln,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:St,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function i9({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=s9(e),i=a.icon;return n?s.jsxs("div",{className:be("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,r),title:a.title,children:[s.jsx(i,{className:tk[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:be("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,a9[t],r),title:a.title,children:s.jsx(i,{className:be(tk[t],a.colorClassName)})})}const o9=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const i=a.getTime()-n.getTime(),o=Math.floor(i/1e3),l=Math.floor(i/(1e3*60)),c=Math.floor(i/(1e3*60*60)),d=Math.floor(i/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function rk({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:i,className:o}){const l=d=>s.jsx($i,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:pD,onClick:r},{id:"star",label:e?i("actions.unstarSession",{defaultValue:"Remove star"}):i("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:i("actions.delete"),icon:Tr,onClick:a,danger:!0}),s.jsx(wE,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const l9={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},nk={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function kE({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:h,onSessionSelect:g,onDeleteSession:b,t:x}){const y=HO(t,n,x),v=r?.id===t.id,w=a===t.id,k=t.__provider,N=l9[k]??k,S=nk[k]??nk.claude,j=UO(y.sessionName),_=()=>{h(e),g(t,e.name)},A=()=>{p(e.name,t.id,i,k)},E=()=>{b(e.name,t.id,y.sessionName,k)},R=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),I=s.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[s.jsxs("span",{className:be("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",S),children:[s.jsx(pr,{provider:k,className:"h-2.5 w-2.5"}),N]}),s.jsx("span",{className:"text-muted-foreground/80",children:o9(y.sessionTime,n,x)}),y.isActive&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[s.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),j.slice(0,3).map(z=>s.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:[".",z]},z))]}),C=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:z=>c(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Enter"?A():z.key==="Escape"&&u()},onClick:z=>z.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}),s.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:z=>{z.stopPropagation(),A()},title:x("tooltips.save"),children:s.jsx(nr,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),s.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:z=>{z.stopPropagation(),u()},title:x("tooltips.cancel"),children:s.jsx(St,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),F=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:be("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:_,children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:be("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(pr,{provider:k,className:"h-3 w-3"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[o&&s.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]}),s.jsx("div",{className:"flex-shrink-0",onClick:z=>z.stopPropagation(),children:s.jsx(rk,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:E,t:x,className:"!opacity-100"})})]})})}),q=s.jsxs("div",{className:be("group/item relative hidden md:block"),children:[s.jsxs(Ce,{variant:"ghost",className:be("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&s.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&s.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),s.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[s.jsx("div",{className:be("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:s.jsx(pr,{provider:k,className:"h-3 w-3"})}),s.jsx("div",{className:"min-w-0 flex-1",children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&s.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:z=>z.stopPropagation(),children:s.jsx(rk,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:E,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[F,q]})}const c9=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function d9(){return s.jsx(s.Fragment,{children:Array.from({length:3}).map((e,t)=>s.jsx("div",{className:"rounded-md p-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),s.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function u9({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:k,t:N}){const[S,j]=m.useState([]);if(m.useEffect(()=>{if(!t)return;let E=!1;const R=async()=>{const I=await Se(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const C=await I.json();E||j((C.runs??[]).slice(0,5))};R();const T=window.setInterval(()=>{R()},15e3);return()=>{E=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const _=r.length>0,A=e.sessionMeta?.hasMore===!0;return s.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[s.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:s.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:[s.jsx(Gt,{className:"h-3 w-3"}),N("sessions.newSession")]})}),s.jsxs(Ce,{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:[s.jsx(Gt,{className:"h-3 w-3"}),N("sessions.newSession")]}),S.length>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(Sn,{className:"h-3 w-3"}),N("orchestration.section")]}),S.map(E=>{const R=[...new Set(E.nodeRuns.map(T=>c9(T.adapterId)).filter(Boolean))];return s.jsx("button",{type:"button",onClick:()=>k?.(e,E.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Sn,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:E.input||N("orchestration.fallbackTitle")}),s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[R.slice(0,4).map(T=>s.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:s.jsx(pr,{provider:T,className:"h-3 w-3"})},T)),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:N(`common:orchestration.status.${E.status}`,{defaultValue:E.status})})]})]})]})},E.id)})]}),a?!_&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:N("sessions.noSessions")})}):r.map(E=>s.jsx(kE,{project:e,session:E,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,E.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:h,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:N},E.id)):s.jsx(d9,{}),_&&A&&s.jsx(Ce,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:i,children:i?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),N("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(qr,{className:"h-3 w-3"}),N("sessions.showMore")]})})]})}const p9=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function m9({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:k,onToggleStarSession:N,onStartEditingProject:S,onCancelEditingProject:j,onSaveProjectName:_,onDeleteProject:A,onSessionSelect:E,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:C,onEditingSessionNameChange:F,onStartEditingSession:q,onCancelEditingSession:z,onSaveEditingSession:H,t:$}){const P=t?.name===e.name,V=o===e.name,G=e.sessionMeta?.hasMore===!0,B=p9(c,G),Q=`${B} session${c.length===1?"":"s"}`,J=WO(e,b),me=()=>v(e.name),fe=()=>k(e.name),oe=()=>{_(e.name)},he=()=>{t?.name!==e.name&&w(e),me()};return s.jsxs("div",{className:be("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[s.jsxs("div",{className:"md:group group",children:[s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:be("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",P&&"bg-primary/5 border-primary/20",i&&!P&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:me,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s.jsx("div",{className:be("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?s.jsx(Ra,{className:"h-4 w-4 text-primary"}):s.jsx(Wn,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:V?s.jsx("input",{type:"text",value:l,onChange:ce=>y(ce.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:$("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ce=>ce.stopPropagation(),onKeyDown:ce=>{ce.key==="Enter"&&oe(),ce.key==="Escape"&&j()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[s.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&s.jsx(i9,{status:J,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:Q})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:V?s.jsxs(s.Fragment,{children:[s.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:ce=>{ce.stopPropagation(),oe()},children:s.jsx(nr,{className:"h-4 w-4 text-white"})}),s.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:ce=>{ce.stopPropagation(),j()},children:s.jsx(St,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:be("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"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:ce=>{ce.stopPropagation(),fe()},title:$(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx($i,{className:be("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),s.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:ce=>{ce.stopPropagation(),A(e)},children:s.jsx(Tr,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),s.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:ce=>{ce.stopPropagation(),S(e)},children:s.jsx(yh,{className:"h-4 w-4 text-primary"})}),s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?s.jsx(qr,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(On,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Ce,{variant:"ghost",className:be("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",P&&"bg-accent text-accent-foreground",i&&!P&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:he,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?s.jsx(Ra,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Wn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:V?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:ce=>y(ce.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:$("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ce=>{ce.key==="Enter"&&oe(),ce.key==="Escape"&&j()}}),s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):s.jsxs("div",{children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[B,e.fullPath!==e.displayName&&s.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),s.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:V?s.jsxs(s.Fragment,{children:[s.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:ce=>{ce.stopPropagation(),oe()},children:s.jsx(nr,{className:"h-3 w-3"})}),s.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:ce=>{ce.stopPropagation(),j()},children:s.jsx(St,{className:"h-3 w-3"})})]}):s.jsxs(s.Fragment,{children:[i&&s.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:ce=>{ce.stopPropagation(),fe()},title:$("tooltips.removeFromFavorites"),children:s.jsx($i,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(wE,{triggerLabel:$("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:$("actions.rename"),icon:yh,onClick:()=>S(e)},{id:"star",label:$(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:$i,onClick:fe},{id:"delete",label:$("actions.delete",{defaultValue:"Delete"}),icon:Tr,onClick:()=>A(e),danger:!0}]}),n?s.jsx(qr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(On,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(u9,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:h,isSessionStarred:x,onEditingSessionNameChange:F,onStartEditingSession:q,onCancelEditingSession:z,onSaveEditingSession:H,onToggleStarSession:N,onProjectSelect:w,onSessionSelect:E,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:C,t:$})]})}function SE({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&s.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("/")})]}):s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(Wn,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(da,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function h9({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:h,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:k,onToggleProject:N,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:E,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:q,onOpenOrchestration:z,onEditingSessionNameChange:H,onStartEditingSession:$,onCancelEditingSession:P,onSaveEditingSession:V,t:G}){const B=s.jsx(SE,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:G});m.useEffect(()=>{let he="Pixcode";const ce=r?.displayName?.trim();ce&&(he=`${ce} - ${he}`),document.title=he},[r]);const Q=!a&&e.length>0&&t.length>0,J=he=>he.source==="history"||he.autoDiscovered===!0&&he.isManuallyAdded!==!0,me=t.filter(he=>!J(he)),fe=t.filter(he=>J(he)),oe=he=>s.jsx(m9,{project:he,selectedProject:r,selectedSession:n,isExpanded:o.has(he.name),isDeleting:g.has(he.name),isStarred:v(he.name),editingProject:l,editingName:c,sessions:y(he),initialSessionsLoaded:u.has(he.name),isLoadingSessions:!!d[he.name],currentTime:p,editingSession:f,editingSessionName:h,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:k,onToggleProject:N,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:E,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:q,onOpenOrchestration:z,onEditingSessionNameChange:H,onStartEditingSession:$,onCancelEditingSession:P,onSaveEditingSession:V,t:G},he.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:Q?s.jsxs(s.Fragment,{children:[me.map(he=>oe(he)),fe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:G("projects.detectedFromHistory")}),fe.map(he=>oe(he))]})]}):B})}function Sa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function NE(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
|
|
230
230
|
* GSAP 3.15.0
|
|
231
231
|
* https://gsap.com
|
|
232
232
|
*
|
|
@@ -247,7 +247,7 @@ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),n.put(i,13)}},Gp=r,G
|
|
|
247
247
|
The chosen QR Code version cannot contain this amount of data.
|
|
248
248
|
Minimum version required to store current data is: `+R+`.
|
|
249
249
|
`);const T=w(j,_,E),I=e.getSymbolSize(j),C=new n(I);return h(C,j),g(C),b(C,j),y(C,_,0),j>=7&&x(C,j),v(C,T),isNaN(A)&&(A=o.getBestMask(C,y.bind(null,C,_))),o.applyMask(A,C),y(C,_,A),{modules:C,version:j,errorCorrectionLevel:_,maskPattern:A,segments:E}}return Ep.create=function(j,_){if(typeof j>"u"||j==="")throw new Error("No input text");let A=t.M,E,R;return typeof _<"u"&&(A=t.from(_.errorCorrectionLevel,t.M),E=d.from(_.version),R=o.from(_.maskPattern),_.toSJISFunc&&e.setToSJISFunction(_.toSJISFunc)),N(j,E,A,R)},Ep}var Vp={},qp={},Yk;function C3(){return Yk||(Yk=1,function(e){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let n=r.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+r);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(i){return[i,i]}))),n.length===6&&n.push("F","F");const a=parseInt(n.join(""),16);return{r:a>>24&255,g:a>>16&255,b:a>>8&255,a:a&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const a=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,i=n.width&&n.width>=21?n.width:void 0,o=n.scale||4;return{width:i,scale:i?4:o,margin:a,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,a){return a.width&&a.width>=n+a.margin*2?a.width/(n+a.margin*2):a.scale},e.getImageWidth=function(n,a){const i=e.getScale(n,a);return Math.floor((n+a.margin*2)*i)},e.qrToImageData=function(n,a,i){const o=a.modules.size,l=a.modules.data,c=e.getScale(o,i),d=Math.floor((o+i.margin*2)*c),u=i.margin*c,p=[i.color.light,i.color.dark];for(let f=0;f<d;f++)for(let h=0;h<d;h++){let g=(f*d+h)*4,b=i.color.light;if(f>=u&&h>=u&&f<d-u&&h<d-u){const x=Math.floor((f-u)/c),y=Math.floor((h-u)/c);b=p[l[x*o+y]?1:0]}n[g++]=b.r,n[g++]=b.g,n[g++]=b.b,n[g]=b.a}}}(qp)),qp}var Zk;function oz(){return Zk||(Zk=1,function(e){const t=C3();function r(a,i,o){a.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=o,i.width=o,i.style.height=o+"px",i.style.width=o+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,o,l){let c=l,d=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(d=n()),c=t.getOptions(c);const u=t.getImageWidth(i.modules.size,c),p=d.getContext("2d"),f=p.createImageData(u,u);return t.qrToImageData(f.data,i,c),r(p,d,u),p.putImageData(f,0,0),d},e.renderToDataURL=function(i,o,l){let c=l;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const d=e.render(i,o,c),u=c.type||"image/png",p=c.rendererOpts||{};return d.toDataURL(u,p.quality)}}(Vp)),Vp}var Wp={},Xk;function lz(){if(Xk)return Wp;Xk=1;const e=C3();function t(a,i){const o=a.a/255,l=i+'="'+a.hex+'"';return o<1?l+" "+i+'-opacity="'+o.toFixed(2).slice(1)+'"':l}function r(a,i,o){let l=a+i;return typeof o<"u"&&(l+=" "+o),l}function n(a,i,o){let l="",c=0,d=!1,u=0;for(let p=0;p<a.length;p++){const f=Math.floor(p%i),h=Math.floor(p/i);!f&&!d&&(d=!0),a[p]?(u++,p>0&&f>0&&a[p-1]||(l+=d?r("M",f+o,.5+h+o):r("m",c,0),c=0,d=!1),f+1<i&&a[p+1]||(l+=r("h",u),u=0)):c++}return l}return Wp.render=function(i,o,l){const c=e.getOptions(o),d=i.modules.size,u=i.modules.data,p=d+c.margin*2,f=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",h="<path "+t(c.color.dark,"stroke")+' d="'+n(u,d,c.margin)+'"/>',g='viewBox="0 0 '+p+" "+p+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+g+' shape-rendering="crispEdges">'+f+h+`</svg>
|
|
250
|
-
`;return typeof l=="function"&&l(null,x),x},Wp}var Jk;function cz(){if(Jk)return wi;Jk=1;const e=GF(),t=iz(),r=oz(),n=lz();function a(i,o,l,c,d){const u=[].slice.call(arguments,1),p=u.length,f=typeof u[p-1]=="function";if(!f&&!e())throw new Error("Callback required as last argument");if(f){if(p<2)throw new Error("Too few arguments provided");p===2?(d=l,l=o,o=c=void 0):p===3&&(o.getContext&&typeof d>"u"?(d=c,c=void 0):(d=c,c=l,l=o,o=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=o,o=c=void 0):p===2&&!o.getContext&&(c=l,l=o,o=void 0),new Promise(function(h,g){try{const b=t.create(l,c);h(i(b,o,c))}catch(b){g(b)}})}try{const h=t.create(l,c);d(null,i(h,o,c))}catch(h){d(h)}}return wi.create=t.create,wi.toCanvas=a.bind(null,r.render),wi.toDataURL=a.bind(null,r.renderToDataURL),wi.toString=a.bind(null,function(i,o,l){return n.render(i,l)}),wi}var dz=cz();const E3=ni(dz),uz=["lan","tailscale","cloudflare_tunnel","custom_domain"],pz=["sameNetwork","secureTunnel","tailscale","customDomain"];async function Is(e,t){const r=await Se(e,t),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n?.error?.message||n?.error||`HTTP ${r.status}`);return n}const Kp=async e=>{try{return await E3.toDataURL(e,{margin:1,width:220})}catch(t){return console.error("QR generation failed for",e,t),null}};function mz(){const{t:e}=Pe("settings"),[t,r]=m.useState(null),[n,a]=m.useState(null),[i,o]=m.useState(null),[l,c]=m.useState(null),[d,u]=m.useState([]),[p,f]=m.useState([]),[h,g]=m.useState(null),[b,x]=m.useState(null),[y,v]=m.useState(!0),[w,k]=m.useState(!1),[N,S]=m.useState(!1),[j,_]=m.useState(!1),[A,E]=m.useState(null),[R,T]=m.useState(null),[I,C]=m.useState(null),[F,q]=m.useState(null),[z,H]=m.useState({mode:"custom_domain",label:"",url:"",targetPort:"3001"}),$=m.useMemo(()=>[...n?.localUrl?[{host:"127.0.0.1",label:e("access.local.thisDevice"),family:"IPv4",url:n.localUrl}]:[],...t?.endpoints||[]],[t?.endpoints,n?.localUrl,e]),P=m.useMemo(()=>t?.endpoints||[],[t?.endpoints]),V=P[0]?.url||n?.localUrl||"",G=l?.tunnel?.url||"",B=i?.pixcodeUrl||"",Q=m.useCallback(async xe=>{const D=[];xe?.tunnel?.running&&xe.tunnel.url&&D.push({key:`tunnel:${xe.tunnel.url}`,label:xe.tunnel.binary||e("access.tunnel.qrLabel"),url:xe.tunnel.url}),f(await Promise.all(D.map(async le=>({...le,dataUrl:await Kp(le.url)}))))},[e]),J=m.useCallback(async()=>{v(!0),E(null);try{const[xe,D,le,ie]=await Promise.all([Is("/api/network/endpoints"),Is("/api/platformization/remote-access"),Is("/api/platformization/remote-access/tailscale"),Is("/api/network/external")]);r(xe),a(D.remoteAccess),o(le.tailscale),c(ie),C(ie.tunnel?.installHint??null),await Q(ie),g(le.tailscale.pixcodeUrl?{key:`tailscale:${le.tailscale.pixcodeUrl}`,label:e("access.links.tailscale"),url:le.tailscale.pixcodeUrl,dataUrl:await Kp(le.tailscale.pixcodeUrl)}:null),H(M=>({...M,targetPort:String(D.remoteAccess?.configs?.[0]?.targetPort||xe.port||M.targetPort)}))}catch(xe){E(xe instanceof Error?xe.message:String(xe))}finally{v(!1)}},[Q,e]);m.useEffect(()=>{J()},[J]),m.useEffect(()=>{let xe=!1;return(async()=>{const le=await Promise.all(P.map(async ie=>({key:ie.url,label:ie.label,url:ie.url,dataUrl:await Kp(ie.url)})));xe||u(le)})(),()=>{xe=!0}},[P]);const me=async xe=>{try{await navigator.clipboard.writeText(xe),q(xe),window.setTimeout(()=>q(D=>D===xe?null:D),1500)}catch{q(null)}},fe=async()=>{k(!0),E(null);try{await Is("/api/platformization/remote-access/configs",{method:"POST",body:JSON.stringify(z)}),await J()}catch(xe){E(xe instanceof Error?xe.message:String(xe))}finally{k(!1)}},oe=async(xe,D,le)=>{if(le){k(!0),E(null);try{await Is("/api/platformization/remote-access/configs",{method:"POST",body:JSON.stringify({mode:xe,label:D,url:le,targetPort:t?.port||z.targetPort})}),await J()}catch(ie){E(ie instanceof Error?ie.message:String(ie))}finally{k(!1)}}},he=async(xe=z.url)=>{if(xe.trim()){S(!0),E(null);try{const D=await Is("/api/platformization/remote-access/health",{method:"POST",body:JSON.stringify({url:xe})});x(D.health)}catch(D){E(D instanceof Error?D.message:String(D))}finally{S(!1)}}},ce=async()=>{_(!0),T(null);try{const xe=!!l?.tunnel?.running,D=await Se("/api/network/tunnel",{method:xe?"DELETE":"POST"}),le=await D.json().catch(()=>({}));if(!D.ok){if(C(le.installHint??le.tunnel?.installHint??null),le.tunnel){const ie={tunnel:le.tunnel};c(ie),await Q(ie)}if(D.status===424){T(e("access.tunnel.installNeeded"));return}throw new Error(le.error||`HTTP ${D.status}`)}await J()}catch(xe){T(xe instanceof Error?xe.message:String(xe))}finally{_(!1)}},we=xe=>{const D=F===xe.url;return s.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-md border border-border/60 bg-background p-3",children:[s.jsx("div",{className:"flex h-24 w-24 flex-shrink-0 items-center justify-center rounded-md bg-white p-1 sm:h-28 sm:w-28",children:xe.dataUrl?s.jsx("img",{src:xe.dataUrl,alt:e("access.qrAlt",{url:xe.url}),className:"h-full w-full"}):s.jsx(fz,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:xe.label}),s.jsx("button",{type:"button",title:xe.url,onClick:()=>void me(xe.url),className:"mt-1 block w-full truncate text-left text-sm font-medium text-foreground hover:text-primary",children:xe.url}),s.jsxs(Ce,{type:"button",size:"sm",variant:D?"default":"outline",className:"mt-2 h-8 px-2 text-xs",onClick:()=>void me(xe.url),children:[s.jsx(to,{className:"h-3.5 w-3.5"}),e(D?"access.copied":"access.copy")]})]})]},xe.key)},Y=I||l?.tunnel?.installHint||null;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:s.jsx(kn,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e("access.title")}),s.jsx("p",{className:"mt-0.5 max-w-2xl text-sm text-muted-foreground",children:e("access.description")})]})]}),s.jsxs(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>void J(),disabled:y,children:[s.jsx(it,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),e("access.refresh")]})]}),A&&s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}),s.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 sm:p-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ir,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.guide.title")}),s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:e("access.guide.description")})]})]}),s.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:pz.map((xe,D)=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:D+1}),s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:e(`access.options.${xe}.title`)})]}),s.jsx("p",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:e(`access.options.${xe}.description`)})]},xe))})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsx(Tc,{icon:s.jsx(cg,{className:"h-5 w-5"}),title:e("access.local.title"),description:e("access.local.description"),badge:P.length?e("access.status.ready"):e("access.status.detecting"),children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/20 p-3",children:[s.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:e("access.local.thisDevice")}),s.jsx("div",{className:"mt-1 truncate font-mono text-xs text-foreground",children:n?.localUrl||"-"}),n?.localUrl&&s.jsxs(Ce,{type:"button",size:"sm",variant:F===n.localUrl?"default":"outline",className:"mt-2 h-8 px-2 text-xs",onClick:()=>void me(n.localUrl||""),children:[s.jsx(to,{className:"h-3.5 w-3.5"}),F===n.localUrl?e("access.copied"):e("access.copy")]})]}),d.length>0?s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 xl:grid-cols-1 2xl:grid-cols-2",children:d.map(we)}):s.jsx("div",{className:"rounded-md border border-border/60 bg-background p-3 text-sm text-muted-foreground",children:e(y?"access.local.loading":"access.local.empty")}),V&&s.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>void oe("lan",e("access.local.saveLabel"),V),disabled:w,children:e("access.local.save")})]})}),s.jsx(Tc,{icon:s.jsx(ig,{className:"h-5 w-5"}),title:e("access.tunnel.title"),description:e("access.tunnel.description"),badge:l?.tunnel?.running?e("access.tunnel.running"):e("access.status.optional"),tone:"amber",children:s.jsxs("div",{className:"space-y-3",children:[R&&s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:R}),s.jsxs("div",{className:"flex flex-col gap-3 rounded-md border border-border/60 bg-background p-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:e("access.tunnel.secureLink")}),l?.tunnel?.running&&s.jsxs(st,{variant:"secondary",children:[e("access.tunnel.running")," · ",l.tunnel.binary]})]}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("access.tunnel.help")})]}),s.jsxs(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>void ce(),disabled:j,children:[j&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),l?.tunnel?.running?e("access.tunnel.stop"):e("access.tunnel.start")]})]}),p.length>0&&s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 xl:grid-cols-1 2xl:grid-cols-2",children:p.map(we)}),G&&s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(Ce,{type:"button",size:"sm",onClick:()=>void oe("cloudflare_tunnel",e("access.tunnel.saveLabel"),G),disabled:w,children:e("access.tunnel.save")}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void he(G),disabled:N,children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]}),Y&&s.jsx(hz,{hint:Y,fallbackTitle:e("access.tunnel.installTitle")})]})})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsx(Tc,{icon:s.jsx(Ws,{className:"h-5 w-5"}),title:e("access.tailscale.title"),description:i?.message||e("access.tailscale.description"),badge:e(B?"access.status.ready":"access.status.guided"),children:s.jsx("div",{className:"space-y-3",children:B?s.jsxs(s.Fragment,{children:[h&&we(h),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(Ce,{type:"button",size:"sm",onClick:()=>void oe("tailscale",e("access.tailscale.saveLabel"),B),disabled:w,children:e("access.tailscale.save")}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void he(B),disabled:N,children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]})]}):s.jsxs("div",{className:"rounded-md border border-border/60 bg-background p-3",children:[s.jsxs("ol",{className:"list-decimal space-y-2 pl-4 text-sm leading-relaxed text-muted-foreground",children:[s.jsx("li",{children:e("access.tailscale.steps.installServer")}),s.jsx("li",{children:e("access.tailscale.steps.installUserDevice")}),s.jsx("li",{children:e("access.tailscale.steps.login")}),s.jsx("li",{children:e("access.tailscale.steps.refresh")})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?.installUrl&&s.jsxs("a",{href:i.installUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",children:[s.jsx(Lr,{className:"h-3.5 w-3.5"}),e("access.tailscale.openInstall")]}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void J(),disabled:y,children:[s.jsx(it,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),e("access.refresh")]})]})]})})}),s.jsxs(Tc,{icon:s.jsx(tc,{className:"h-5 w-5"}),title:e("access.advanced.title"),description:e("access.advanced.description"),badge:e("access.advanced.badge"),children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx("select",{value:z.mode,onChange:xe=>H({...z,mode:xe.target.value}),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:uz.map(xe=>s.jsx("option",{value:xe,children:e(`access.modes.${xe}`)},xe))}),s.jsx(Be,{placeholder:e("access.fields.label"),value:z.label,onChange:xe=>H({...z,label:xe.target.value})}),s.jsx(Be,{placeholder:e("access.fields.url"),value:z.url,onChange:xe=>H({...z,url:xe.target.value})}),s.jsx(Be,{placeholder:e("access.fields.port"),value:z.targetPort,onChange:xe=>H({...z,targetPort:xe.target.value})})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[s.jsxs(Ce,{type:"button",onClick:()=>void fe(),disabled:w||!z.url.trim(),children:[w&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.save")]}),s.jsxs(Ce,{type:"button",variant:"outline",onClick:()=>void he(),disabled:N||!z.url.trim(),children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]}),b&&s.jsxs("div",{className:"mt-3 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-foreground",children:[s.jsx(Mn,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:b.reachable?e("access.health.reachable"):e("access.health.unreachable")}),s.jsx(st,{variant:b.https?"secondary":"destructive",children:b.https?"HTTPS":"HTTP"})]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:b.message})]})]})]}),s.jsxs("section",{className:"rounded-md border border-border/60 bg-background",children:[s.jsxs("div",{className:"border-b border-border/60 bg-muted/20 px-3 py-2",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.configured.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:e("access.configured.description")})]}),s.jsxs("div",{className:"divide-y divide-border/50",children:[(n?.configs||[]).map(xe=>s.jsxs("div",{className:"px-3 py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:xe.label}),s.jsx("button",{type:"button",className:"mt-1 block max-w-full truncate text-left text-xs text-muted-foreground hover:text-foreground",onClick:()=>xe.url&&void me(xe.url),children:xe.url||e("access.configured.noUrl")})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(st,{variant:"secondary",children:e(`access.modes.${xe.mode}`,{defaultValue:xe.mode})}),s.jsx(st,{variant:xe.public?"destructive":"secondary",children:xe.public?e("access.configured.public"):e("access.configured.private")})]})]}),xe.url&&s.jsx(Ce,{className:"mt-2",type:"button",size:"sm",variant:"outline",onClick:()=>void he(xe.url||""),children:e("access.check")})]},xe.id)),(n?.configs||[]).length===0&&s.jsx("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:e("access.configured.empty")})]})]}),s.jsx("section",{className:"rounded-md border border-primary/20 bg-primary/5 px-3 py-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ir,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.team.title")}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("access.team.description")})]})]})}),s.jsx("div",{className:"sr-only",children:$.map(xe=>s.jsx("span",{children:xe.url},xe.url))})]})}function Tc({icon:e,title:t,description:r,badge:n,tone:a="primary",children:i}){const o=a==="amber"?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-primary/10 text-primary";return s.jsxs("section",{className:"rounded-md border border-border/60 bg-background",children:[s.jsx("div",{className:"border-b border-border/60 bg-muted/20 p-3",children:s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsx("div",{className:`flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl ${o}`,children:e}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:t}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:r})]})]}),s.jsx(st,{variant:"secondary",className:"w-fit",children:n})]})}),s.jsx("div",{className:"p-3",children:i})]})}function hz({hint:e,fallbackTitle:t}){return s.jsxs("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 p-3 text-xs text-amber-800 dark:text-amber-100",children:[s.jsx("div",{className:"font-semibold",children:e.title||t}),e.message&&s.jsx("p",{className:"mt-1 leading-5",children:e.message}),!!e.commands?.length&&s.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-4",children:e.commands?.map(r=>s.jsx("li",{className:"font-mono text-[11px]",children:r},r))}),e.docsUrl&&s.jsxs("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 font-medium underline",children:[s.jsx(Lr,{className:"h-3 w-3"}),e.docsUrl]})]})}function fz(){return s.jsx("div",{className:"text-xs text-muted-foreground",children:"QR"})}const Gg={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Nu={claude:["user","project","local"],cursor:["user","project"],codex:["user","project"],gemini:["user","project"],qwen:["user","project"],opencode:["user","project"]},Cu={claude:["stdio","http","sse"],cursor:["stdio","http"],codex:["stdio","http"],gemini:["stdio","http","sse"],qwen:["stdio","http","sse"],opencode:["stdio","http","sse"]},gz=["user","project"],T3=["stdio","http"],bz={claude:"bg-purple-600 text-white hover:bg-purple-700",cursor:"bg-purple-600 text-white hover:bg-purple-700",codex:"bg-gray-800 text-white hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600",gemini:"bg-blue-600 text-white hover:bg-blue-700",qwen:"bg-orange-600 text-white hover:bg-orange-700",opencode:"bg-teal-600 text-white hover:bg-teal-700"},Hg={claude:!1,cursor:!1,codex:!0,gemini:!0,qwen:!0,opencode:!0},xz={name:"",scope:"user",workspacePath:"",transport:"stdio",command:"",args:[],env:{},cwd:"",url:"",headers:{},envVars:[],bearerTokenEnvVar:"",envHttpHeaders:{},importMode:"form",jsonInput:""},A3=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ya=e=>typeof e=="string"&&e.trim()?e.trim():void 0,Qk=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0,Yp=e=>{if(!A3(e))return;const t={};return Object.entries(e).forEach(([r,n])=>{typeof n=="string"&&(t[r]=n)}),Object.keys(t).length>0?t:void 0},Zp=e=>Object.entries(e).map(([t,r])=>`${t}=${r}`).join(`
|
|
250
|
+
`;return typeof l=="function"&&l(null,x),x},Wp}var Jk;function cz(){if(Jk)return wi;Jk=1;const e=GF(),t=iz(),r=oz(),n=lz();function a(i,o,l,c,d){const u=[].slice.call(arguments,1),p=u.length,f=typeof u[p-1]=="function";if(!f&&!e())throw new Error("Callback required as last argument");if(f){if(p<2)throw new Error("Too few arguments provided");p===2?(d=l,l=o,o=c=void 0):p===3&&(o.getContext&&typeof d>"u"?(d=c,c=void 0):(d=c,c=l,l=o,o=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=o,o=c=void 0):p===2&&!o.getContext&&(c=l,l=o,o=void 0),new Promise(function(h,g){try{const b=t.create(l,c);h(i(b,o,c))}catch(b){g(b)}})}try{const h=t.create(l,c);d(null,i(h,o,c))}catch(h){d(h)}}return wi.create=t.create,wi.toCanvas=a.bind(null,r.render),wi.toDataURL=a.bind(null,r.renderToDataURL),wi.toString=a.bind(null,function(i,o,l){return n.render(i,l)}),wi}var dz=cz();const E3=ni(dz),uz=["lan","tailscale","cloudflare_tunnel","custom_domain"],pz=["sameNetwork","secureTunnel","tailscale","customDomain"];async function Is(e,t){const r=await Se(e,t),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n?.error?.message||n?.error||`HTTP ${r.status}`);return n}const Kp=async e=>{try{return await E3.toDataURL(e,{margin:1,width:220})}catch(t){return console.error("QR generation failed for",e,t),null}};function mz(){const{t:e}=Pe("settings"),[t,r]=m.useState(null),[n,a]=m.useState(null),[i,o]=m.useState(null),[l,c]=m.useState(null),[d,u]=m.useState([]),[p,f]=m.useState([]),[h,g]=m.useState(null),[b,x]=m.useState(null),[y,v]=m.useState(!0),[w,k]=m.useState(!1),[N,S]=m.useState(!1),[j,_]=m.useState(!1),[A,E]=m.useState(null),[R,T]=m.useState(null),[I,C]=m.useState(null),[F,q]=m.useState(null),[z,H]=m.useState({mode:"custom_domain",label:"",url:"",targetPort:"3001"}),$=m.useMemo(()=>[...n?.localUrl?[{host:"127.0.0.1",label:e("access.local.thisDevice"),family:"IPv4",url:n.localUrl}]:[],...t?.endpoints||[]],[t?.endpoints,n?.localUrl,e]),P=m.useMemo(()=>t?.endpoints||[],[t?.endpoints]),V=P[0]?.url||n?.localUrl||"",G=l?.tunnel?.url||"",B=i?.pixcodeUrl||"",Q=m.useCallback(async xe=>{const D=[];xe?.tunnel?.running&&xe.tunnel.url&&D.push({key:`tunnel:${xe.tunnel.url}`,label:xe.tunnel.binary||e("access.tunnel.qrLabel"),url:xe.tunnel.url}),f(await Promise.all(D.map(async le=>({...le,dataUrl:await Kp(le.url)}))))},[e]),J=m.useCallback(async()=>{v(!0),E(null);try{const[xe,D,le,ie]=await Promise.all([Is("/api/network/endpoints"),Is("/api/platformization/remote-access"),Is("/api/platformization/remote-access/tailscale"),Is("/api/network/external")]);r(xe),a(D.remoteAccess),o(le.tailscale),c(ie),C(ie.tunnel?.installHint??null),await Q(ie),g(le.tailscale.pixcodeUrl?{key:`tailscale:${le.tailscale.pixcodeUrl}`,label:e("access.links.tailscale"),url:le.tailscale.pixcodeUrl,dataUrl:await Kp(le.tailscale.pixcodeUrl)}:null),H(M=>({...M,targetPort:String(D.remoteAccess?.configs?.[0]?.targetPort||xe.port||M.targetPort)}))}catch(xe){E(xe instanceof Error?xe.message:String(xe))}finally{v(!1)}},[Q,e]);m.useEffect(()=>{J()},[J]),m.useEffect(()=>{let xe=!1;return(async()=>{const le=await Promise.all(P.map(async ie=>({key:ie.url,label:ie.label,url:ie.url,dataUrl:await Kp(ie.url)})));xe||u(le)})(),()=>{xe=!0}},[P]);const me=async xe=>{try{await navigator.clipboard.writeText(xe),q(xe),window.setTimeout(()=>q(D=>D===xe?null:D),1500)}catch{q(null)}},fe=async()=>{k(!0),E(null);try{await Is("/api/platformization/remote-access/configs",{method:"POST",body:JSON.stringify(z)}),await J()}catch(xe){E(xe instanceof Error?xe.message:String(xe))}finally{k(!1)}},oe=async(xe,D,le)=>{if(le){k(!0),E(null);try{await Is("/api/platformization/remote-access/configs",{method:"POST",body:JSON.stringify({mode:xe,label:D,url:le,targetPort:t?.port||z.targetPort})}),await J()}catch(ie){E(ie instanceof Error?ie.message:String(ie))}finally{k(!1)}}},he=async(xe=z.url)=>{if(xe.trim()){S(!0),E(null);try{const D=await Is("/api/platformization/remote-access/health",{method:"POST",body:JSON.stringify({url:xe})});x(D.health)}catch(D){E(D instanceof Error?D.message:String(D))}finally{S(!1)}}},ce=async()=>{_(!0),T(null);try{const xe=!!l?.tunnel?.running,D=await Se("/api/network/tunnel",{method:xe?"DELETE":"POST"}),le=await D.json().catch(()=>({}));if(!D.ok){if(C(le.installHint??le.tunnel?.installHint??null),le.tunnel){const ie={tunnel:le.tunnel};c(ie),await Q(ie)}if(D.status===424){T(e("access.tunnel.installNeeded"));return}throw new Error(le.error||`HTTP ${D.status}`)}await J()}catch(xe){T(xe instanceof Error?xe.message:String(xe))}finally{_(!1)}},we=xe=>{const D=F===xe.url;return s.jsxs("div",{className:"flex min-w-0 flex-col gap-4 rounded-md border border-border/60 bg-background p-4 sm:flex-row sm:items-center",children:[s.jsx("div",{className:"flex h-32 w-32 flex-shrink-0 items-center justify-center rounded-md bg-white p-1",children:xe.dataUrl?s.jsx("img",{src:xe.dataUrl,alt:e("access.qrAlt",{url:xe.url}),className:"h-full w-full"}):s.jsx(fz,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:xe.label}),s.jsx("button",{type:"button",title:xe.url,onClick:()=>void me(xe.url),className:"mt-1 block w-full break-all text-left font-mono text-sm font-medium leading-relaxed text-foreground hover:text-primary",children:xe.url}),s.jsxs(Ce,{type:"button",size:"sm",variant:D?"default":"outline",className:"mt-2 h-8 px-2 text-xs",onClick:()=>void me(xe.url),children:[s.jsx(to,{className:"h-3.5 w-3.5"}),e(D?"access.copied":"access.copy")]})]})]},xe.key)},Y=I||l?.tunnel?.installHint||null;return s.jsxs("div",{className:"mx-auto max-w-5xl space-y-8",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:s.jsx(kn,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e("access.title")}),s.jsx("p",{className:"mt-0.5 max-w-2xl text-sm text-muted-foreground",children:e("access.description")})]})]}),s.jsxs(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>void J(),disabled:y,children:[s.jsx(it,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),e("access.refresh")]})]}),A&&s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}),s.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-4 sm:p-6",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ir,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.guide.title")}),s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:e("access.guide.description")})]})]}),s.jsx("div",{className:"mt-5 grid gap-4 md:grid-cols-2",children:pz.map((xe,D)=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background p-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:D+1}),s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:e(`access.options.${xe}.title`)})]}),s.jsx("p",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:e(`access.options.${xe}.description`)})]},xe))})]}),s.jsxs("section",{className:"space-y-5",children:[s.jsx(Tc,{icon:s.jsx(cg,{className:"h-5 w-5"}),title:e("access.local.title"),description:e("access.local.description"),badge:P.length?e("access.status.ready"):e("access.status.detecting"),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/20 p-4",children:[s.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:e("access.local.thisDevice")}),s.jsx("div",{className:"mt-1 truncate font-mono text-xs text-foreground",children:n?.localUrl||"-"}),n?.localUrl&&s.jsxs(Ce,{type:"button",size:"sm",variant:F===n.localUrl?"default":"outline",className:"mt-2 h-8 px-2 text-xs",onClick:()=>void me(n.localUrl||""),children:[s.jsx(to,{className:"h-3.5 w-3.5"}),F===n.localUrl?e("access.copied"):e("access.copy")]})]}),d.length>0?s.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:d.map(we)}):s.jsx("div",{className:"rounded-md border border-border/60 bg-background p-4 text-sm text-muted-foreground",children:e(y?"access.local.loading":"access.local.empty")}),V&&s.jsx(Ce,{type:"button",variant:"outline",size:"sm",onClick:()=>void oe("lan",e("access.local.saveLabel"),V),disabled:w,children:e("access.local.save")})]})}),s.jsx(Tc,{icon:s.jsx(ig,{className:"h-5 w-5"}),title:e("access.tunnel.title"),description:e("access.tunnel.description"),badge:l?.tunnel?.running?e("access.tunnel.running"):e("access.status.optional"),tone:"amber",children:s.jsxs("div",{className:"space-y-4",children:[R&&s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:R}),s.jsxs("div",{className:"flex flex-col gap-4 rounded-md border border-border/60 bg-background p-4 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:e("access.tunnel.secureLink")}),l?.tunnel?.running&&s.jsxs(st,{variant:"secondary",children:[e("access.tunnel.running")," · ",l.tunnel.binary]})]}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("access.tunnel.help")})]}),s.jsxs(Ce,{type:"button",variant:"outline",size:"sm",className:"w-full flex-shrink-0 sm:w-auto",onClick:()=>void ce(),disabled:j,children:[j&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),l?.tunnel?.running?e("access.tunnel.stop"):e("access.tunnel.start")]})]}),p.length>0&&s.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:p.map(we)}),G&&s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(Ce,{type:"button",size:"sm",onClick:()=>void oe("cloudflare_tunnel",e("access.tunnel.saveLabel"),G),disabled:w,children:e("access.tunnel.save")}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void he(G),disabled:N,children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]}),Y&&s.jsx(hz,{hint:Y,fallbackTitle:e("access.tunnel.installTitle")})]})})]}),s.jsxs("section",{className:"space-y-5",children:[s.jsx(Tc,{icon:s.jsx(Ws,{className:"h-5 w-5"}),title:e("access.tailscale.title"),description:i?.message||e("access.tailscale.description"),badge:e(B?"access.status.ready":"access.status.guided"),children:s.jsx("div",{className:"space-y-4",children:B?s.jsxs(s.Fragment,{children:[h&&we(h),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(Ce,{type:"button",size:"sm",onClick:()=>void oe("tailscale",e("access.tailscale.saveLabel"),B),disabled:w,children:e("access.tailscale.save")}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void he(B),disabled:N,children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]})]}):s.jsxs("div",{className:"rounded-md border border-border/60 bg-background p-4",children:[s.jsxs("ol",{className:"list-decimal space-y-2 pl-4 text-sm leading-relaxed text-muted-foreground",children:[s.jsx("li",{children:e("access.tailscale.steps.installServer")}),s.jsx("li",{children:e("access.tailscale.steps.installUserDevice")}),s.jsx("li",{children:e("access.tailscale.steps.login")}),s.jsx("li",{children:e("access.tailscale.steps.refresh")})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?.installUrl&&s.jsxs("a",{href:i.installUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",children:[s.jsx(Lr,{className:"h-3.5 w-3.5"}),e("access.tailscale.openInstall")]}),s.jsxs(Ce,{type:"button",size:"sm",variant:"outline",onClick:()=>void J(),disabled:y,children:[s.jsx(it,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),e("access.refresh")]})]})]})})}),s.jsxs(Tc,{icon:s.jsx(tc,{className:"h-5 w-5"}),title:e("access.advanced.title"),description:e("access.advanced.description"),badge:e("access.advanced.badge"),children:[s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[s.jsx("select",{value:z.mode,onChange:xe=>H({...z,mode:xe.target.value}),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:uz.map(xe=>s.jsx("option",{value:xe,children:e(`access.modes.${xe}`)},xe))}),s.jsx(Be,{placeholder:e("access.fields.label"),value:z.label,onChange:xe=>H({...z,label:xe.target.value})}),s.jsx(Be,{placeholder:e("access.fields.url"),value:z.url,onChange:xe=>H({...z,url:xe.target.value})}),s.jsx(Be,{placeholder:e("access.fields.port"),value:z.targetPort,onChange:xe=>H({...z,targetPort:xe.target.value})})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[s.jsxs(Ce,{type:"button",onClick:()=>void fe(),disabled:w||!z.url.trim(),children:[w&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.save")]}),s.jsxs(Ce,{type:"button",variant:"outline",onClick:()=>void he(),disabled:N||!z.url.trim(),children:[N&&s.jsx(it,{className:"h-3.5 w-3.5 animate-spin"}),e("access.check")]})]}),b&&s.jsxs("div",{className:"mt-3 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-foreground",children:[s.jsx(Mn,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:b.reachable?e("access.health.reachable"):e("access.health.unreachable")}),s.jsx(st,{variant:b.https?"secondary":"destructive",children:b.https?"HTTPS":"HTTP"})]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:b.message})]})]})]}),s.jsxs("section",{className:"rounded-md border border-border/60 bg-background",children:[s.jsxs("div",{className:"border-b border-border/60 bg-muted/20 p-4 sm:p-5",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.configured.title")}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("access.configured.description")})]}),s.jsxs("div",{className:"divide-y divide-border/50",children:[(n?.configs||[]).map(xe=>s.jsxs("div",{className:"p-4 sm:p-5",children:[s.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:xe.label}),s.jsx("button",{type:"button",className:"mt-1 block max-w-full break-all text-left font-mono text-xs leading-relaxed text-muted-foreground hover:text-foreground",onClick:()=>xe.url&&void me(xe.url),children:xe.url||e("access.configured.noUrl")})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(st,{variant:"secondary",children:e(`access.modes.${xe.mode}`,{defaultValue:xe.mode})}),s.jsx(st,{variant:xe.public?"destructive":"secondary",children:xe.public?e("access.configured.public"):e("access.configured.private")})]})]}),xe.url&&s.jsx(Ce,{className:"mt-2",type:"button",size:"sm",variant:"outline",onClick:()=>void he(xe.url||""),children:e("access.check")})]},xe.id)),(n?.configs||[]).length===0&&s.jsx("div",{className:"p-5 text-sm text-muted-foreground",children:e("access.configured.empty")})]})]}),s.jsx("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-4 sm:p-5",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ir,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:e("access.team.title")}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e("access.team.description")})]})]})}),s.jsx("div",{className:"sr-only",children:$.map(xe=>s.jsx("span",{children:xe.url},xe.url))})]})}function Tc({icon:e,title:t,description:r,badge:n,tone:a="primary",children:i}){const o=a==="amber"?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-primary/10 text-primary";return s.jsxs("section",{className:"rounded-md border border-border/60 bg-background",children:[s.jsx("div",{className:"border-b border-border/60 bg-muted/20 p-4 sm:p-5",children:s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-4",children:[s.jsx("div",{className:`flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-xl ${o}`,children:e}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:t}),s.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:r})]})]}),s.jsx(st,{variant:"secondary",className:"w-fit",children:n})]})}),s.jsx("div",{className:"p-4 sm:p-5",children:i})]})}function hz({hint:e,fallbackTitle:t}){return s.jsxs("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 p-4 text-xs text-amber-800 dark:text-amber-100",children:[s.jsx("div",{className:"font-semibold",children:e.title||t}),e.message&&s.jsx("p",{className:"mt-1 leading-5",children:e.message}),!!e.commands?.length&&s.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-4",children:e.commands?.map(r=>s.jsx("li",{className:"font-mono text-[11px]",children:r},r))}),e.docsUrl&&s.jsxs("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 font-medium underline",children:[s.jsx(Lr,{className:"h-3 w-3"}),e.docsUrl]})]})}function fz(){return s.jsx("div",{className:"text-xs text-muted-foreground",children:"QR"})}const Gg={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Nu={claude:["user","project","local"],cursor:["user","project"],codex:["user","project"],gemini:["user","project"],qwen:["user","project"],opencode:["user","project"]},Cu={claude:["stdio","http","sse"],cursor:["stdio","http"],codex:["stdio","http"],gemini:["stdio","http","sse"],qwen:["stdio","http","sse"],opencode:["stdio","http","sse"]},gz=["user","project"],T3=["stdio","http"],bz={claude:"bg-purple-600 text-white hover:bg-purple-700",cursor:"bg-purple-600 text-white hover:bg-purple-700",codex:"bg-gray-800 text-white hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600",gemini:"bg-blue-600 text-white hover:bg-blue-700",qwen:"bg-orange-600 text-white hover:bg-orange-700",opencode:"bg-teal-600 text-white hover:bg-teal-700"},Hg={claude:!1,cursor:!1,codex:!0,gemini:!0,qwen:!0,opencode:!0},xz={name:"",scope:"user",workspacePath:"",transport:"stdio",command:"",args:[],env:{},cwd:"",url:"",headers:{},envVars:[],bearerTokenEnvVar:"",envHttpHeaders:{},importMode:"form",jsonInput:""},A3=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ya=e=>typeof e=="string"&&e.trim()?e.trim():void 0,Qk=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0,Yp=e=>{if(!A3(e))return;const t={};return Object.entries(e).forEach(([r,n])=>{typeof n=="string"&&(t[r]=n)}),Object.keys(t).length>0?t:void 0},Zp=e=>Object.entries(e).map(([t,r])=>`${t}=${r}`).join(`
|
|
251
251
|
`),Xp=e=>{const t={};return e.split(`
|
|
252
252
|
`).forEach(r=>{const[n,...a]=r.split("=");n?.trim()&&(t[n.trim()]=a.join("=").trim())}),t},e2=e=>e.split(`
|
|
253
253
|
`).map(t=>t.trim()).filter(Boolean),yz=e=>{const t=String(e??"");return t.length<=4?"****":`${t.slice(0,2)}****${t.slice(-2)}`},vz=e=>e==="user"||e==="local"||e==="project",Vg=e=>e==="stdio"||e==="http"||e==="sse",j3=e=>e.fullPath||e.path||"",gd=e=>e instanceof Error?e.message:"Unknown error",_3=(e,t,r)=>{if(!(r?.supportedTransports??Cu[e]).includes(t))throw new Error(r?.unsupportedTransportMessage?.(t)??`${e} does not support ${t} MCP servers`)},wz=(e,t,r)=>{const n=JSON.parse(t.jsonInput);if(!A3(n))throw new Error("JSON configuration must be an object");const a=Ya(n.transport)??Ya(n.type),i=Vg(a)?a:void 0;if(!i)throw new Error("Missing required field: type");if(_3(e,i,r),i==="stdio"&&!Ya(n.command))throw new Error("stdio type requires a command field");if((i==="http"||i==="sse")&&!Ya(n.url))throw new Error(`${i} type requires a url field`);return{name:t.name.trim(),scope:t.scope,workspacePath:t.scope==="user"?void 0:t.workspacePath,transport:i,command:Ya(n.command),args:Qk(n.args)??[],env:Yp(n.env)??{},cwd:r?.supportsWorkingDirectory??Hg[e]?Ya(n.cwd):void 0,url:Ya(n.url),headers:Yp(n.headers??n.http_headers)??{},envVars:r?.includeProviderSpecificFields??e==="codex"?Qk(n.envVars??n.env_vars)??[]:void 0,bearerTokenEnvVar:r?.includeProviderSpecificFields??e==="codex"?Ya(n.bearerTokenEnvVar??n.bearer_token_env_var):void 0,envHttpHeaders:r?.includeProviderSpecificFields??e==="codex"?Yp(n.envHttpHeaders??n.env_http_headers)??{}:void 0}},t2=(e,t,r)=>{if(t.importMode==="json")return wz(e,t,r);_3(e,t.transport,r);const n=r?.supportsWorkingDirectory??Hg[e],a=r?.includeProviderSpecificFields??e==="codex";return{name:t.name.trim(),scope:t.scope,workspacePath:t.scope==="user"?void 0:t.workspacePath,transport:t.transport,command:t.transport==="stdio"?t.command.trim():void 0,args:t.transport==="stdio"?t.args:void 0,env:t.env,cwd:n&&t.cwd.trim()||void 0,url:t.transport!=="stdio"?t.url.trim():void 0,headers:t.transport!=="stdio"?t.headers:void 0,envVars:a?t.envVars:void 0,bearerTokenEnvVar:a&&t.bearerTokenEnvVar.trim()||void 0,envHttpHeaders:a?t.envHttpHeaders:void 0}},kz=3e4,ki=new Map,Eu=async e=>e.json(),Tu=(e,t)=>{if(!e||typeof e!="object")return t;const r=e,n=r.error;if(n&&typeof n=="object"){const i=n.message;if(typeof i=="string"&&i.trim())return i}if(typeof n=="string"&&n.trim())return n;const a=r.details;return typeof a=="string"&&a.trim()?a:t},Sz=(e,t="stdio")=>Vg(e)?e:t,Nz=(e,t)=>vz(e)?e:t,Cz=(e,t,r,n)=>{const a=Sz(r.transport,r.url?"http":"stdio");return{provider:e,name:String(r.name??""),scope:Nz(r.scope,t),transport:a,command:r.command,args:r.args??[],env:r.env??{},cwd:r.cwd,url:r.url,headers:r.headers??{},envVars:r.envVars??[],bearerTokenEnvVar:r.bearerTokenEnvVar,envHttpHeaders:r.envHttpHeaders??{},workspacePath:n?.path||r.workspacePath,projectName:n?.name||r.projectName,projectDisplayName:n?.displayName||r.projectDisplayName}},Ez=e=>{const t=new Set;return e.reduce((r,n)=>{const a=j3(n);return!a||t.has(a)||(t.add(a),r.push({name:n.name,displayName:n.displayName||n.name,path:a})),r},[])},r2=async(e,t,r)=>{const n=new URLSearchParams({scope:t});r?.path&&n.set("workspacePath",r.path);const a=await Se(`/api/providers/${e}/mcp/servers?${n.toString()}`),i=await Eu(a);if(!a.ok||!i.success)throw new Error(Tu(i,`Failed to load ${e} MCP servers`));return(i.data.servers||[]).map(o=>Cz(e,t,o,r))},n2=async(e,t)=>{const r=new URLSearchParams({scope:t.scope});t.workspacePath&&r.set("workspacePath",t.workspacePath);const n=await Se(`/api/providers/${e}/mcp/servers/${encodeURIComponent(t.name)}?${r.toString()}`,{method:"DELETE"}),a=await Eu(n);if(!n.ok||!a.success)throw new Error(Tu(a,"Failed to delete MCP server"))},Tz=async(e,t)=>{const r=await Se(`/api/providers/${e}/mcp/servers`,{method:"POST",body:JSON.stringify(t)}),n=await Eu(r);if(!r.ok||!n.success)throw new Error(Tu(n,"Failed to save MCP server"))},Az=async e=>{const t=await Se("/api/providers/mcp/servers/global",{method:"POST",body:JSON.stringify(e)}),r=await Eu(t);if(!t.ok||!r.success)throw new Error(Tu(r,"Failed to save MCP server to all providers"));return r.data.results||[]},jz=(e,t)=>e.name!==t.name||e.scope!==t.scope||(e.workspacePath||"")!==(t.workspacePath||""),a2=e=>`${e.provider}:${e.scope}:${e.workspacePath||"global"}:${e.name}`,_z=(e,t)=>{const r=t.map(n=>n.path).sort().join("|");return`${e}:${r}`},Iz=e=>e.map(t=>`${Gg[t.provider]}: ${t.error||"Unknown error"}`).join("; "),bd=e=>{const t={user:0,project:1,local:2};return[...e].sort((r,n)=>{const a=t[r.scope]-t[n.scope];if(a!==0)return a;const i=(r.projectDisplayName||"").localeCompare(n.projectDisplayName||"");return i!==0?i:r.name.localeCompare(n.name)})},Rz=(e,t)=>{const r=new Map;return e.forEach(n=>{r.set(a2(n),n)}),t.forEach(n=>{r.set(a2(n),n)}),bd([...r.values()])},s2=(e,t,r,n)=>{const a=e.filter(i=>i.scope!==r||(i.workspacePath||"")!==(n||""));return Rz(a,t)};function Lz({selectedProvider:e,currentProjects:t}){const[r,n]=m.useState([]),[a,i]=m.useState(!1),[o,l]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,h]=m.useState(!1),[g,b]=m.useState(!1),[x,y]=m.useState(!1),[v,w]=m.useState(null),k=m.useRef(0),N=m.useMemo(()=>Ez(t),[t]),S=m.useMemo(()=>_z(e,N),[N,e]),j=m.useCallback(async(F={})=>{const q=k.current+1;k.current=q;const z=ki.get(S);if(!F.force&&z&&Date.now()-z.updatedAt<kz){n(z.servers),i(!1),h(!1),l(null);return}z&&!F.force?n(z.servers):n([]),i(!z),h(!1),l(null);const $=Nu[e];let P=z&&!F.force?z.servers:[],V=null;if($.includes("user"))try{const Q=await r2(e,"user");if(k.current!==q)return;P=s2(P,Q,"user"),n(bd(P))}catch(Q){V=gd(Q)}if(k.current!==q)return;i(!1);const G=[];if(N.forEach(Q=>{$.includes("project")&&G.push({scope:"project",project:Q}),$.includes("local")&&G.push({scope:"local",project:Q})}),G.length===0){const Q=bd(P);ki.set(S,{servers:Q,updatedAt:Date.now()}),l(V);return}if(h(!0),await Promise.all(G.map(async({scope:Q,project:J})=>{try{const me=await r2(e,Q,J);if(k.current!==q)return;P=s2(P,me,Q,J.path),n(P)}catch(me){V=V||gd(me)}})),k.current!==q)return;const B=bd(P);ki.set(S,{servers:B,updatedAt:Date.now()}),n(B),l(V),h(!1)},[S,N,e]),_=m.useCallback(F=>{w(F||null),b(!0)},[]),A=m.useCallback(()=>{b(!1),w(null)},[]),E=m.useCallback(()=>{y(!0)},[]),R=m.useCallback(()=>{y(!1)},[]),T=m.useCallback(async(F,q)=>{const z=t2(e,F);if(z.scope!=="user"&&!z.workspacePath)throw new Error("Select a project for project-scoped MCP servers");await Tz(e,z),q&&jz(q,z)&&await n2(e,q),ki.delete(S),await j({force:!0}),p("success"),A()},[S,A,j,e]),I=m.useCallback(async F=>{const q=t2(e,F,{supportedTransports:T3,supportsWorkingDirectory:!1,includeProviderSpecificFields:!1,unsupportedTransportMessage:$=>`Add MCP Server supports only stdio and http across all providers, not ${$}.`});if(q.scope==="local")throw new Error("Add MCP Server supports only user or project scope across all providers.");if(q.scope!=="user"&&!q.workspacePath)throw new Error("Select a project for project-scoped MCP servers");const z=await Az(q);ki.clear(),await j({force:!0});const H=z.filter($=>!$.created);if(H.length>0)throw p("error"),new Error(`Failed to add MCP server to all providers. ${Iz(H)}`);p("success"),R()},[R,j,e]),C=m.useCallback(async F=>{if(window.confirm("Are you sure you want to delete this MCP server?")){d(null);try{await n2(e,F),ki.delete(S),await j({force:!0}),p("success")}catch(q){d(gd(q)),p("error")}}},[S,j,e]);return m.useEffect(()=>{j()},[j]),m.useEffect(()=>{b(!1),y(!1),w(null),d(null),p(null)},[e]),m.useEffect(()=>{if(u===null)return;const F=window.setTimeout(()=>p(null),2e3);return()=>window.clearTimeout(F)},[u]),{servers:r,isLoading:a,isLoadingProjectScopes:f,loadError:o,deleteError:c,saveStatus:u,isFormOpen:g,isGlobalFormOpen:x,editingServer:v,openForm:_,openGlobalForm:E,closeForm:A,closeGlobalForm:R,submitForm:T,submitGlobalForm:I,deleteServer:C,refreshServers:j}}const xd=(e,t=Nu[e],r=Cu[e])=>({...xz,scope:t[0],transport:r[0],args:[],env:{},headers:{},envVars:[],envHttpHeaders:{}}),Pz=(e,t,r,n)=>({...xd(e,r,n),name:t.name,scope:t.scope,workspacePath:t.workspacePath||"",transport:t.transport,command:t.command||"",args:t.args||[],env:t.env||{},cwd:t.cwd||"",url:t.url||"",headers:t.headers||{},envVars:t.envVars||[],bearerTokenEnvVar:t.bearerTokenEnvVar||"",envHttpHeaders:t.envHttpHeaders||{}}),Jp=e=>({args:e.args.join(`
|