@pixelbyte-software/pixcode 1.38.1 → 1.38.2

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.
@@ -6,7 +6,7 @@ import{j as s,a as d4,R as Xh,o as Jh,_ as Y6,b as Z6,m as u4,E as kn,T as p4,P
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var xv;function sj(){if(xv)return Cu;xv=1;var e=h_();function t(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function l(p,f){var m=f(),g=n({inst:{value:m,getSnapshot:f}}),b=g[0].inst,x=g[1];return i(function(){b.value=m,b.getSnapshot=f,c(b)&&x({inst:b})},[p,m,f]),a(function(){return c(b)&&x({inst:b}),p(function(){c(b)&&x({inst:b})})},[p]),o(m),m}function c(p){var f=p.getSnapshot;p=p.value;try{var m=f();return!r(p,m)}catch{return!0}}function d(p,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return Cu.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Cu}var yv;function oj(){return yv||(yv=1,Eu.exports=sj()),Eu.exports}var lj=oj();const cj=(e,t)=>{if(Bi(t))return t;if(Y_(t)&&Bi(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const r=e[e.length-1];return typeof r=="function"?"":r}return e},dj={t:cj,ready:!1},uj=()=>()=>{},Re=(e,t={})=>{const{i18n:r}=t,{i18n:n,defaultNS:a}=h.useContext(k4)||{},i=r||n||nj();i&&!i.reportNamespaces&&(i.reportNamespaces=new ij),i||Sm(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=h.useMemo(()=>({...tj(),...i?.options?.react,...t}),[i,t]),{useSuspense:l,keyPrefix:c}=o,d=e||a||i?.options?.defaultNS,u=Bi(d)?[d]:d||["translation"],p=h.useMemo(()=>u,u);i?.reportNamespaces?.addUsedNamespaces?.(p);const f=h.useRef(0),m=h.useCallback(_=>{if(!i)return uj;const{bindI18n:N,bindI18nStore:D}=o,T=()=>{f.current+=1,_()};return N&&i.on(N,T),D&&i.store.on(D,T),()=>{N&&N.split(" ").forEach(R=>i.off(R,T)),D&&D.split(" ").forEach(R=>i.store.off(R,T))}},[i,o]),g=h.useRef(),b=h.useCallback(()=>{if(!i)return dj;const _=!!(i.isInitialized||i.initializedStoreOnce)&&p.every(P=>K_(P,i,o)),N=t.lng||i.language,D=f.current,T=g.current;if(T&&T.ready===_&&T.lng===N&&T.keyPrefix===c&&T.revision===D)return T;const C={t:i.getFixedT(N,o.nsMode==="fallback"?p:p[0],c),ready:_,lng:N,keyPrefix:c,revision:D};return g.current=C,C},[i,p,c,o,t.lng]),[x,y]=h.useState(0),{t:v,ready:w}=lj.useSyncExternalStore(m,b,b);h.useEffect(()=>{if(i&&!w&&!l){const _=()=>y(N=>N+1);t.lng?bv(i,t.lng,p,_):Em(i,p,_)}},[i,t.lng,p,w,l,x]);const k=i||{},E=h.useRef(null),S=h.useRef(),j=_=>{const N=Object.getOwnPropertyDescriptors(_);N.__original&&delete N.__original;const D=Object.create(Object.getPrototypeOf(_),N);if(!Object.prototype.hasOwnProperty.call(D,"__original"))try{Object.defineProperty(D,"__original",{value:_,writable:!1,enumerable:!1,configurable:!1})}catch{}return D},A=h.useMemo(()=>{const _=k,N=_?.language;let D=_;_&&(E.current&&E.current.__original===_?S.current!==N?(D=j(_),E.current=D,S.current=N):D=E.current:(D=j(_),E.current=D,S.current=N));const T=!w&&!l?(...C)=>(Sm(i,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),v(...C)):v,R=[T,D,w];return R.t=T,R.i18n=D,R.ready=w,R},[v,k,w,k.resolvedLanguage,k.language,k.languages]);if(i&&l&&!w)throw new Promise(_=>{const N=()=>_();t.lng?bv(i,t.lng,p,N):Em(i,p,N)});return A};function pj({i18n:e,defaultNS:t,children:r}){const n=h.useMemo(()=>({i18n:e,defaultNS:t}),[e,t]);return h.createElement(k4.Provider,{value:n},r)}const S4="pixcode.theme.accent",vv="pixcode.theme.customLight",wv="pixcode.theme.customDark",E4="#059669",C4="#10b981",el=[{id:"emerald",label:"Emerald",light:"#059669",dark:"#10b981"},{id:"vscode",label:"VS Code",light:"#007acc",dark:"#007acc",darkBackground:"215 28% 7%",darkCard:"215 25% 10%",darkMuted:"215 18% 16%"},{id:"blue",label:"Blue",light:"#2563eb",dark:"#60a5fa"},{id:"violet",label:"Violet",light:"#7c3aed",dark:"#a78bfa"},{id:"amber",label:"Amber",light:"#d97706",dark:"#f59e0b"},{id:"rose",label:"Rose",light:"#e11d48",dark:"#fb7185"},{id:"custom",label:"Custom",light:E4,dark:C4}],mj="emerald";function hj(e){return typeof e=="string"&&el.some(t=>t.id===e)}function fj(){const e=localStorage.getItem(S4);return hj(e)?e:mj}function kv(e,t){const r=localStorage.getItem(e);return r&&/^#[0-9a-fA-F]{6}$/.test(r)?r:t}function gj(e){const t=e.replace("#",""),r=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255,i=Math.max(r,n,a),o=Math.min(r,n,a);let l=0,c=0;const d=(i+o)/2;if(i!==o){const u=i-o;c=d>.5?u/(2-i-o):u/(i+o),i===r?l=(n-a)/u+(n<a?6:0):i===n?l=(a-r)/u+2:l=(r-n)/u+4,l/=6}return`${Math.round(l*360)} ${Math.round(c*100)}% ${Math.round(d*100)}%`}function bj(e){const t=e.replace("#",""),r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return(.2126*r+.7152*n+.0722*a)/255>.58?"160 18% 6%":"210 40% 98%"}function xj(e,t,r,n,a){const i=el.find(c=>c.id===t)??el[0],o=t==="custom"?r?a:n:r?i.dark:i.light,l=gj(o);return e.style.setProperty("--primary",l),e.style.setProperty("--ring",l),e.style.setProperty("--primary-foreground",bj(o)),e.style.setProperty("--nav-tab-glow",`${l} / ${r?"0.25":"0.18"}`),e.style.setProperty("--nav-tab-ring",`${l} / ${r?"0.15":"0.10"}`),e.style.setProperty("--nav-input-focus-ring",`${l} / ${r?"0.25":"0.22"}`),r&&i.darkBackground?(e.style.setProperty("--background",i.darkBackground),e.style.setProperty("--card",i.darkCard??i.darkBackground),e.style.setProperty("--popover",i.darkCard??i.darkBackground),e.style.setProperty("--muted",i.darkMuted??i.darkCard??i.darkBackground),e.style.setProperty("--secondary",i.darkMuted??i.darkCard??i.darkBackground),e.style.setProperty("--accent",i.darkMuted??i.darkCard??i.darkBackground)):["--background","--card","--popover","--muted","--secondary","--accent"].forEach(c=>{e.style.removeProperty(c)}),o}const N4=h.createContext(),Ra=()=>{const e=h.useContext(N4);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e},yj=({children:e})=>{const[t,r]=h.useState(()=>{const g=localStorage.getItem("theme");return g?g==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1}),[n,a]=h.useState(fj),[i,o]=h.useState(()=>kv(vv,E4)),[l,c]=h.useState(()=>kv(wv,C4));h.useEffect(()=>{const g=xj(document.documentElement,n,t,i,l);if(t){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const b=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');b&&b.setAttribute("content","black-translucent");const x=document.querySelector('meta[name="theme-color"]');x&&x.setAttribute("content",g)}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const b=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');b&&b.setAttribute("content","default");const x=document.querySelector('meta[name="theme-color"]');x&&x.setAttribute("content",g)}},[n,l,i,t]),h.useEffect(()=>{if(!window.matchMedia)return;const g=window.matchMedia("(prefers-color-scheme: dark)"),b=x=>{localStorage.getItem("theme")||r(x.matches)};return g.addEventListener("change",b),()=>g.removeEventListener("change",b)},[]);const m={isDarkMode:t,toggleDarkMode:()=>{r(g=>!g)},accentTheme:n,setAccentTheme:g=>{a(g),localStorage.setItem(S4,g)},customLightAccent:i,setCustomLightAccent:g=>{o(g),localStorage.setItem(vv,g)},customDarkAccent:l,setCustomDarkAccent:g=>{c(g),localStorage.setItem(wv,g)}};return s.jsx(N4.Provider,{value:m,children:e})},vj=!1,wj={name:"default",displayName:"default",fullPath:"",path:""},we=(e,t={})=>{const r=localStorage.getItem("auth-token"),n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),r&&(n.Authorization=`Bearer ${r}`),fetch(e,{...t,headers:{...n,...t.headers}}).then(a=>{const i=a.headers.get("X-Refreshed-Token");return i&&localStorage.setItem("auth-token",i),a})},lt={auth:{status:()=>fetch("/api/auth/status"),connectionMode:()=>fetch("/api/auth/connection-mode"),updateConnectionMode:e=>fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>we("/api/auth/user"),logout:()=>we("/api/auth/logout",{method:"POST"})},publicApiManifest:()=>we("/api/public/manifest"),diagnostics:()=>we("/api/diagnostics"),refreshDiagnostics:()=>we("/api/diagnostics/refresh",{method:"POST"}),remoteConnection:()=>we("/api/remote/config"),updateRemoteConnection:e=>we("/api/remote/config",{method:"PUT",body:JSON.stringify(e)}),projects:()=>we("/api/projects"),sessions:(e,t=5,r=0)=>we(`/api/projects/${e}/sessions?limit=${t}&offset=${r}`),unifiedSessionMessages:(e,t="claude",{projectName:r="",projectPath:n="",limit:a=null,offset:i=0}={})=>{const o=new URLSearchParams;o.append("provider",t),r&&o.append("projectName",r),n&&o.append("projectPath",n),a!==null&&(o.append("limit",String(a)),o.append("offset",String(i)));const l=o.toString();return we(`/api/sessions/${encodeURIComponent(e)}/messages${l?`?${l}`:""}`)},renameProject:(e,t)=>we(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>we(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),renameSession:(e,t,r)=>we(`/api/sessions/${e}/rename`,{method:"PUT",body:JSON.stringify({summary:t,provider:r})}),deleteCodexSession:e=>we(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteGeminiSession:e=>we(`/api/gemini/sessions/${e}`,{method:"DELETE"}),deleteQwenSession:e=>we(`/api/qwen/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1,r=!1)=>{const n=new URLSearchParams;t&&n.set("force","true"),r&&n.set("deleteData","true");const a=n.toString();return we(`/api/projects/${e}${a?`?${a}`:""}`,{method:"DELETE"})},searchConversationsUrl:(e,t=50)=>{const r=localStorage.getItem("auth-token"),n=new URLSearchParams({q:e,limit:String(t)});return r&&n.set("token",r),`/api/search/conversations?${n.toString()}`},createWorkspace:e=>we("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),quickStartProject:()=>we("/api/projects/quick-start",{method:"POST",body:"{}"}),readFile:(e,t)=>we(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),readFileBlob:(e,t)=>we(`/api/projects/${e}/files/content?path=${encodeURIComponent(t)}`),saveFile:(e,t,r)=>we(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:r})}),getFiles:(e,t={})=>we(`/api/projects/${e}/files`,t),createFile:(e,{path:t,type:r,name:n})=>we(`/api/projects/${e}/files/create`,{method:"POST",body:JSON.stringify({path:t,type:r,name:n})}),renameFile:(e,{oldPath:t,newName:r})=>we(`/api/projects/${e}/files/rename`,{method:"PUT",body:JSON.stringify({oldPath:t,newName:r})}),deleteFile:(e,{path:t,type:r})=>we(`/api/projects/${e}/files`,{method:"DELETE",body:JSON.stringify({path:t,type:r})}),uploadFiles:(e,t)=>we(`/api/projects/${e}/files/upload`,{method:"POST",body:t,headers:{}}),taskmaster:{init:e=>we(`/api/taskmaster/init/${e}`,{method:"POST"}),addTask:(e,{prompt:t,title:r,description:n,priority:a,dependencies:i})=>we(`/api/taskmaster/add-task/${e}`,{method:"POST",body:JSON.stringify({prompt:t,title:r,description:n,priority:a,dependencies:i})}),parsePRD:(e,{fileName:t,numTasks:r,append:n})=>we(`/api/taskmaster/parse-prd/${e}`,{method:"POST",body:JSON.stringify({fileName:t,numTasks:r,append:n})}),getTemplates:()=>we("/api/taskmaster/prd-templates"),applyTemplate:(e,{templateId:t,fileName:r,customizations:n})=>we(`/api/taskmaster/apply-template/${e}`,{method:"POST",body:JSON.stringify({templateId:t,fileName:r,customizations:n})}),updateTask:(e,t,r)=>we(`/api/taskmaster/update-task/${e}/${t}`,{method:"PUT",body:JSON.stringify(r)})},browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),we(`/api/browse-filesystem?${t}`)},createFolder:e=>we("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),user:{gitConfig:()=>we("/api/user/git-config"),updateGitConfig:(e,t)=>we("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:e,gitEmail:t})}),onboardingStatus:()=>we("/api/user/onboarding-status"),completeOnboarding:()=>we("/api/user/complete-onboarding",{method:"POST"})},get:e=>we(`/api${e}`),post:(e,t)=>we(`/api${e}`,{method:"POST",...t instanceof FormData?{body:t}:{body:JSON.stringify(t)}}),put:(e,t)=>we(`/api${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:(e,t={})=>we(`/api${e}`,{method:"DELETE",...t})},Id="auth-token",bi={authStatusCheckFailed:"Failed to check authentication status",loginFailed:"Login failed",registrationFailed:"Registration failed",networkError:"Network error. Please try again."};async function uo(e){try{return await e.json()}catch{return null}}function Sv(e,t){return e?e.error??e.message??t:t}const T4=h.createContext(null),kj=()=>localStorage.getItem(Id),Sj=e=>{localStorage.setItem(Id,e)},Ej=()=>{localStorage.removeItem(Id)};function Hi(){const e=h.useContext(T4);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Cj({children:e}){const[t,r]=h.useState(null),[n,a]=h.useState(()=>kj()),[i,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState(!0),[p,f]=h.useState(null),m=h.useCallback((S,j)=>{r(S),a(j),Sj(j)},[]),g=h.useCallback(()=>{r(null),a(null),Ej()},[]),b=h.useCallback(async()=>{try{const S=await lt.user.onboardingStatus();if(!S.ok)return;const j=await uo(S);u(!!j?.hasCompletedOnboarding)}catch(S){console.error("Error checking onboarding status:",S),u(!0)}},[]),x=h.useCallback(async()=>{await b()},[b]),y=h.useCallback(async()=>{try{o(!0),f(null);const S=await lt.auth.status();if((await uo(S))?.needsSetup){c(!0);return}if(c(!1),!n)return;const A=await lt.auth.user();if(!A.ok){g();return}const _=await uo(A);if(!_?.user){g();return}r(_.user),await b()}catch(S){console.error("[Auth] Auth status check failed:",S),f(bi.authStatusCheckFailed)}finally{o(!1)}},[b,g,n]);h.useEffect(()=>{y()},[y,b]);const v=h.useCallback(async(S,j)=>{try{f(null);const A=await lt.auth.login(S,j),_=await uo(A);if(!A.ok||!_?.token||!_.user){const N=Sv(_,bi.loginFailed);return f(N),{success:!1,error:N}}return m(_.user,_.token),c(!1),await b(),{success:!0}}catch(A){return console.error("Login error:",A),f(bi.networkError),{success:!1,error:bi.networkError}}},[b,m]),w=h.useCallback(async(S,j)=>{try{f(null);const A=await lt.auth.register(S,j),_=await uo(A);if(!A.ok||!_?.token||!_.user){const N=Sv(_,bi.registrationFailed);return f(N),{success:!1,error:N}}return m(_.user,_.token),c(!1),await b(),{success:!0}}catch(A){return console.error("Registration error:",A),f(bi.networkError),{success:!1,error:bi.networkError}}},[b,m]),k=h.useCallback(()=>{const S=n;g(),S&&lt.auth.logout().catch(j=>{console.error("Logout endpoint error:",j)})},[g,n]),E=h.useMemo(()=>({user:t,token:n,isLoading:i,needsSetup:l,hasCompletedOnboarding:d,error:p,login:v,register:w,logout:k,refreshOnboardingStatus:x}),[p,d,i,v,k,l,x,w,n,t]);return s.jsx(T4.Provider,{value:E,children:e})}const Nj="pixcode.notification.once.",A4="pixcode.notificationPreferences.v1",Tj={action_required:"actionRequired",stop:"stop",error:"error",update:"updates",updates:"updates"};function Aj(e="updates"){try{const t=JSON.parse(localStorage.getItem(A4)??"null");return t?.channels?.desktop===!1?!1:t?.events?.[Tj[e]||e]!==!1}catch{return!0}}function rs(e){try{localStorage.setItem(A4,JSON.stringify(e))}catch{}}async function _4({key:e,title:t,body:r,tag:n,data:a}){return j4({key:e,title:t,body:r,event:"updates",tag:n,data:a})}async function j4({key:e,title:t,body:r,event:n="updates",tag:a,data:i}){if(typeof window>"u"||!("Notification"in window)||Notification.permission!=="granted"||!Aj(n))return!1;const o=`${Nj}${e}`;try{if(localStorage.getItem(o))return!1}catch{}const l={body:r,icon:"/logo-256.png",badge:"/logo-128.png",tag:a,data:i,renotify:!!a};try{const c="serviceWorker"in navigator?await navigator.serviceWorker.ready.catch(()=>null):null;c?.showNotification?await c.showNotification(t,l):new Notification(t,l);try{localStorage.setItem(o,new Date().toISOString())}catch{}return!0}catch(c){return console.warn("Local notification failed:",c),!1}}const I4={claude:"npm install -g @anthropic-ai/claude-code",cursor:"curl https://cursor.com/install -fsSL | bash",codex:"npm install -g @openai/codex",gemini:"npm install -g @google/gemini-cli",qwen:"npm install -g @qwen-code/qwen-code",opencode:"npm install -g opencode-ai"},tl={claude:"Claude Code",cursor:"Cursor CLI",codex:"OpenAI Codex",gemini:"Gemini CLI",qwen:"Qwen Code",opencode:"OpenCode"},R4=["claude","cursor","codex","gemini","qwen","opencode"],Ev={claude:"/api/providers/claude/auth/status",cursor:"/api/providers/cursor/auth/status",codex:"/api/providers/codex/auth/status",gemini:"/api/providers/gemini/auth/status",qwen:"/api/providers/qwen/auth/status",opencode:"/api/providers/opencode/auth/status"},Cv=(e=!0)=>({claude:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},cursor:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},codex:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},gemini:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},qwen:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},opencode:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null}}),_j="Failed to check authentication status",jj="Unknown error",D4="pixcode.providerAuthStatus.cache.v2",Tc=1440*60*1e3,Ij=3600*1e3;let Nv=0;const Rj=e=>e instanceof Error?e.message:jj,Dj=(e,t=null)=>({authenticated:!!e.authenticated,installed:typeof e.installed=="boolean"?e.installed:null,email:e.email??null,method:e.method??null,error:e.error??t,loading:!1,checkedAt:e.checkedAt??new Date().toISOString(),installedVersion:e.installedVersion??null,latestVersion:e.latestVersion??null,updateAvailable:!!e.updateAvailable,versionCheckSkipped:e.versionCheckSkipped??null,fromCache:!!e.fromCache});function Nm(){try{const e=JSON.parse(localStorage.getItem(D4)??"null");return!e||typeof e.savedAt!="number"||!e.statuses?null:e}catch{return null}}function Lj(e){try{localStorage.setItem(D4,JSON.stringify({savedAt:Date.now(),statuses:e}))}catch{}}function Oj(e){const t=Nm(),r=Cv(!1);return t&&Date.now()-t.savedAt<Tc?Object.fromEntries(R4.map(n=>[n,{...r[n],...t.statuses[n],loading:!1,fromCache:!0}])):Cv(e)}function Tv(e,t){if(!t.updateAvailable||!t.latestVersion)return;const r=tl[e]??e,n=t.installedVersion?` ${t.installedVersion}`:"";_4({key:`cli-update:${e}:${t.latestVersion}`,title:`${r} update available`,body:`${r}${n} can update to ${t.latestVersion}.`,tag:`pixcode-cli-update:${e}`,data:{type:"cli-update",provider:e,latestVersion:t.latestVersion}})}function r0({initialLoading:e=!0}={}){const[t,r]=h.useState(()=>Oj(e)),n=h.useCallback(l=>{r(c=>({...c,[l]:{...c[l],loading:!0,error:null}}))},[]),a=h.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]),i=h.useCallback(async(l,c={})=>{const d=Nm(),u=d?.statuses?.[l];if(!c.force&&d&&u&&Date.now()-d.savedAt<Tc){const p={...u,loading:!1,fromCache:!0};a(l,p),Tv(l,p);return}n(l);try{const p=c.force?`${Ev[l]}?refresh=1`:Ev[l],f=await we(p,{cache:"no-store"});if(!f.ok){a(l,{authenticated:!1,installed:null,email:null,method:null,loading:!1,error:_j});return}const m=await f.json(),g=Dj(m.data);Tv(l,g),r(b=>{const x={...b,[l]:g};return Lj(x),x})}catch(p){console.error(`Error checking ${l} auth status:`,p),a(l,{authenticated:!1,installed:null,email:null,method:null,loading:!1,error:Rj(p)})}},[n,a]),o=h.useCallback(async(l=R4,c={})=>{await Promise.all(l.map(d=>i(d,c)))},[i]);return h.useEffect(()=>{const l=window.setInterval(()=>{const c=Date.now();if(c-Nv<Tc)return;const d=Nm();d&&c-d.savedAt<Tc||(Nv=c,o())},Ij);return()=>window.clearInterval(l)},[o]),{providerAuthStatus:t,setProviderAuthStatus:r,checkProviderAuthStatus:i,refreshProviderAuthStatuses:o}}const L4="https://auth.openai.com/codex/device",Mj=200,O4=100,Pj=50,Fj=500,zj=20,Bj=15,$j=5,Uj=2,Gj={cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selectionBackground:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}};function Hj(e){if(!e||typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(t)}return r}async function Sn(e){if(!e)return!1;let t=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{t=!1}return t||(t=Hj(e)),t}function qj(){const e=window.location.protocol==="https:"?"wss:":"ws:",t=localStorage.getItem("auth-token");return t?`${e}//${window.location.host}/shell?token=${encodeURIComponent(t)}`:(console.error("No authentication token found for Shell WebSocket connection"),null)}function Vj(e){try{return JSON.parse(e)}catch{return null}}function Ri(e,t){e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}const Wj=/(?:\u001B\[[0-?]*[ -/]*[@-~]|\u009B[0-?]*[ -/]*[@-~]|\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u009D[^\u0007\u009C]*(?:\u0007|\u009C)|\u001B[PX^_][^\u001B]*\u001B\\|[\u0090\u0098\u009E\u009F][^\u009C]*\u009C|\u001B[@-Z\\-_])/g,Kj=/Process exited with code (\d+)/;function Yj({wsRef:e,terminalRef:t,fitAddonRef:r,selectedProjectRef:n,selectedSessionRef:a,initialCommandRef:i,isPlainShellRef:o,onProcessCompleteRef:l,isInitialized:c,autoConnect:d,closeSocket:u,clearTerminalScreen:p,setAuthUrl:f,onOutputRef:m}){const[g,b]=h.useState(!1),[x,y]=h.useState(!1),v=h.useRef(!1),w=h.useRef(!1),k=h.useCallback(_=>{if(!o.current||!l.current)return;const D=_.replace(Wj,"");if(D.includes("Process exited with code 0")){l.current(0);return}const T=D.match(Kj);if(!T)return;const R=Number.parseInt(T[1],10);!Number.isNaN(R)&&R!==0&&l.current(R)},[o,l]),E=h.useCallback(_=>{const N=Vj(_);if(!N){console.error("[Shell] Error handling WebSocket message:",_);return}if(N.type==="output"){const D=typeof N.data=="string"?N.data:"";k(D),t.current?.write(D),m?.current?.();return}if(N.type==="auth_url"||N.type==="url_open"){const D=typeof N.url=="string"?N.url:"";D&&f(D)}},[k,m,f,t]),S=h.useCallback((_=!1)=>{if(!(v.current&&!_||x||g))try{const N=qj();if(!N){v.current=!1,y(!1);return}v.current=!0;const D=new WebSocket(N);e.current=D,D.onopen=()=>{b(!0),y(!1),v.current=!1,f(""),window.setTimeout(()=>{const T=t.current,R=r.current,C=n.current;!T||!R||!C||(R.fit(),Ri(D,{type:"init",projectPath:C.fullPath||C.path||"",sessionId:o.current?null:a.current?.id||null,hasSession:o.current?!1:!!a.current,provider:o.current?"plain-shell":a.current?.__provider||localStorage.getItem("selected-provider")||"claude",cols:T.cols,rows:T.rows,initialCommand:i.current,isPlainShell:o.current}))},O4)},D.onmessage=T=>{const R=typeof T.data=="string"?T.data:String(T.data??"");E(R)},D.onclose=()=>{b(!1),y(!1),v.current=!1,p()},D.onerror=()=>{b(!1),y(!1),v.current=!1}}catch{b(!1),y(!1),v.current=!1}},[p,r,E,i,g,x,o,n,a,f,t,e]),j=h.useCallback(()=>{!c||g||x||v.current||(w.current=!1,v.current=!0,y(!0),S(!0))},[S,g,x,c]),A=h.useCallback((_=!0)=>{_&&(w.current=!0),u(),p(),b(!1),y(!1),v.current=!1,f("")},[p,u,f]);return h.useEffect(()=>{!d||w.current||!c||x||g||j()},[d,j,g,x,c]),{isConnected:g,isConnecting:x,closeSocket:u,connectToShell:j,disconnectFromShell:A}}var Zj=y_(),Nu={exports:{}},Av;function Xj(){return Av||(Av=1,function(e,t){(function(r,n){e.exports=n()})(self,()=>(()=>{var r={6:(o,l)=>{function c(u){try{const p=new URL(u),f=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return u.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(l,"__esModule",{value:!0}),l.LinkComputer=l.WebLinkProvider=void 0,l.WebLinkProvider=class{constructor(u,p,f,m={}){this._terminal=u,this._regex=p,this._handler=f,this._options=m}provideLinks(u,p){const f=d.computeLink(u,this._regex,this._terminal,this._handler);p(this._addCallbacks(f))}_addCallbacks(u){return u.map(p=>(p.leave=this._options.leave,p.hover=(f,m)=>{if(this._options.hover){const{range:g}=p;this._options.hover(f,m,g)}},p))}};class d{static computeLink(p,f,m,g){const b=new RegExp(f.source,(f.flags||"")+"g"),[x,y]=d._getWindowedLineStrings(p-1,m),v=x.join("");let w;const k=[];for(;w=b.exec(v);){const E=w[0];if(!c(E))continue;const[S,j]=d._mapStrIdx(m,y,0,w.index),[A,_]=d._mapStrIdx(m,S,j,E.length);if(S===-1||j===-1||A===-1||_===-1)continue;const N={start:{x:j+1,y:S+1},end:{x:_,y:A+1}};k.push({range:N,text:E,activate:g})}return k}static _getWindowedLineStrings(p,f){let m,g=p,b=p,x=0,y="";const v=[];if(m=f.buffer.active.getLine(p)){const w=m.translateToString(!0);if(m.isWrapped&&w[0]!==" "){for(x=0;(m=f.buffer.active.getLine(--g))&&x<2048&&(y=m.translateToString(!0),x+=y.length,v.push(y),m.isWrapped&&y.indexOf(" ")===-1););v.reverse()}for(v.push(w),x=0;(m=f.buffer.active.getLine(++b))&&m.isWrapped&&x<2048&&(y=m.translateToString(!0),x+=y.length,v.push(y),y.indexOf(" ")===-1););}return[v,g]}static _mapStrIdx(p,f,m,g){const b=p.buffer.active,x=b.getNullCell();let y=m;for(;g;){const v=b.getLine(f);if(!v)return[-1,-1];for(let w=y;w<v.length;++w){v.getCell(w,x);const k=x.getChars();if(x.getWidth()&&(g-=k.length||1,w===v.length-1&&k==="")){const E=b.getLine(f+1);E&&E.isWrapped&&(E.getCell(0,x),x.getWidth()===2&&(g+=1))}if(g<0)return[f,w]}f++,y=0}return[f,y]}}l.LinkComputer=d}},n={};function a(o){var l=n[o];if(l!==void 0)return l.exports;var c=n[o]={exports:{}};return r[o](c,c.exports,a),c.exports}var i={};return(()=>{var o=i;Object.defineProperty(o,"__esModule",{value:!0}),o.WebLinksAddon=void 0;const l=a(6),c=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function d(u,p){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}o.WebLinksAddon=class{constructor(u=d,p={}){this._handler=u,this._options=p}activate(u){this._terminal=u;const p=this._options,f=p.urlRegex||c;this._linkProvider=this._terminal.registerLinkProvider(new l.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),i})())}(Nu)),Nu.exports}var Jj=Xj(),Qj=v_(),eI=w_();function M4(e){return typeof e=="string"&&/\bcodex\s+login\b/i.test(e)}function tI(e,t){return M4(e)?L4:t}function rI(e){return e?e.__provider==="cursor"?e.name||"Untitled Session":e.summary||"New Session":null}const _v="shell-xterm-focus-style",nI=`
9
+ */var xv;function sj(){if(xv)return Cu;xv=1;var e=h_();function t(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function l(p,f){var m=f(),g=n({inst:{value:m,getSnapshot:f}}),b=g[0].inst,x=g[1];return i(function(){b.value=m,b.getSnapshot=f,c(b)&&x({inst:b})},[p,m,f]),a(function(){return c(b)&&x({inst:b}),p(function(){c(b)&&x({inst:b})})},[p]),o(m),m}function c(p){var f=p.getSnapshot;p=p.value;try{var m=f();return!r(p,m)}catch{return!0}}function d(p,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return Cu.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Cu}var yv;function oj(){return yv||(yv=1,Eu.exports=sj()),Eu.exports}var lj=oj();const cj=(e,t)=>{if(Bi(t))return t;if(Y_(t)&&Bi(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const r=e[e.length-1];return typeof r=="function"?"":r}return e},dj={t:cj,ready:!1},uj=()=>()=>{},Re=(e,t={})=>{const{i18n:r}=t,{i18n:n,defaultNS:a}=h.useContext(k4)||{},i=r||n||nj();i&&!i.reportNamespaces&&(i.reportNamespaces=new ij),i||Sm(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=h.useMemo(()=>({...tj(),...i?.options?.react,...t}),[i,t]),{useSuspense:l,keyPrefix:c}=o,d=e||a||i?.options?.defaultNS,u=Bi(d)?[d]:d||["translation"],p=h.useMemo(()=>u,u);i?.reportNamespaces?.addUsedNamespaces?.(p);const f=h.useRef(0),m=h.useCallback(_=>{if(!i)return uj;const{bindI18n:N,bindI18nStore:D}=o,T=()=>{f.current+=1,_()};return N&&i.on(N,T),D&&i.store.on(D,T),()=>{N&&N.split(" ").forEach(R=>i.off(R,T)),D&&D.split(" ").forEach(R=>i.store.off(R,T))}},[i,o]),g=h.useRef(),b=h.useCallback(()=>{if(!i)return dj;const _=!!(i.isInitialized||i.initializedStoreOnce)&&p.every(P=>K_(P,i,o)),N=t.lng||i.language,D=f.current,T=g.current;if(T&&T.ready===_&&T.lng===N&&T.keyPrefix===c&&T.revision===D)return T;const C={t:i.getFixedT(N,o.nsMode==="fallback"?p:p[0],c),ready:_,lng:N,keyPrefix:c,revision:D};return g.current=C,C},[i,p,c,o,t.lng]),[x,y]=h.useState(0),{t:v,ready:w}=lj.useSyncExternalStore(m,b,b);h.useEffect(()=>{if(i&&!w&&!l){const _=()=>y(N=>N+1);t.lng?bv(i,t.lng,p,_):Em(i,p,_)}},[i,t.lng,p,w,l,x]);const k=i||{},E=h.useRef(null),S=h.useRef(),j=_=>{const N=Object.getOwnPropertyDescriptors(_);N.__original&&delete N.__original;const D=Object.create(Object.getPrototypeOf(_),N);if(!Object.prototype.hasOwnProperty.call(D,"__original"))try{Object.defineProperty(D,"__original",{value:_,writable:!1,enumerable:!1,configurable:!1})}catch{}return D},A=h.useMemo(()=>{const _=k,N=_?.language;let D=_;_&&(E.current&&E.current.__original===_?S.current!==N?(D=j(_),E.current=D,S.current=N):D=E.current:(D=j(_),E.current=D,S.current=N));const T=!w&&!l?(...C)=>(Sm(i,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),v(...C)):v,R=[T,D,w];return R.t=T,R.i18n=D,R.ready=w,R},[v,k,w,k.resolvedLanguage,k.language,k.languages]);if(i&&l&&!w)throw new Promise(_=>{const N=()=>_();t.lng?bv(i,t.lng,p,N):Em(i,p,N)});return A};function pj({i18n:e,defaultNS:t,children:r}){const n=h.useMemo(()=>({i18n:e,defaultNS:t}),[e,t]);return h.createElement(k4.Provider,{value:n},r)}const S4="pixcode.theme.accent",vv="pixcode.theme.customLight",wv="pixcode.theme.customDark",E4="#059669",C4="#10b981",el=[{id:"emerald",label:"Emerald",light:"#059669",dark:"#10b981"},{id:"vscode",label:"VS Code",light:"#007acc",dark:"#007acc",darkBackground:"215 28% 7%",darkCard:"215 25% 10%",darkMuted:"215 18% 16%"},{id:"blue",label:"Blue",light:"#2563eb",dark:"#60a5fa"},{id:"violet",label:"Violet",light:"#7c3aed",dark:"#a78bfa"},{id:"amber",label:"Amber",light:"#d97706",dark:"#f59e0b"},{id:"rose",label:"Rose",light:"#e11d48",dark:"#fb7185"},{id:"custom",label:"Custom",light:E4,dark:C4}],mj="emerald";function hj(e){return typeof e=="string"&&el.some(t=>t.id===e)}function fj(){const e=localStorage.getItem(S4);return hj(e)?e:mj}function kv(e,t){const r=localStorage.getItem(e);return r&&/^#[0-9a-fA-F]{6}$/.test(r)?r:t}function gj(e){const t=e.replace("#",""),r=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255,i=Math.max(r,n,a),o=Math.min(r,n,a);let l=0,c=0;const d=(i+o)/2;if(i!==o){const u=i-o;c=d>.5?u/(2-i-o):u/(i+o),i===r?l=(n-a)/u+(n<a?6:0):i===n?l=(a-r)/u+2:l=(r-n)/u+4,l/=6}return`${Math.round(l*360)} ${Math.round(c*100)}% ${Math.round(d*100)}%`}function bj(e){const t=e.replace("#",""),r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return(.2126*r+.7152*n+.0722*a)/255>.58?"160 18% 6%":"210 40% 98%"}function xj(e,t,r,n,a){const i=el.find(c=>c.id===t)??el[0],o=t==="custom"?r?a:n:r?i.dark:i.light,l=gj(o);return e.style.setProperty("--primary",l),e.style.setProperty("--ring",l),e.style.setProperty("--primary-foreground",bj(o)),e.style.setProperty("--nav-tab-glow",`${l} / ${r?"0.25":"0.18"}`),e.style.setProperty("--nav-tab-ring",`${l} / ${r?"0.15":"0.10"}`),e.style.setProperty("--nav-input-focus-ring",`${l} / ${r?"0.25":"0.22"}`),r&&i.darkBackground?(e.style.setProperty("--background",i.darkBackground),e.style.setProperty("--card",i.darkCard??i.darkBackground),e.style.setProperty("--popover",i.darkCard??i.darkBackground),e.style.setProperty("--muted",i.darkMuted??i.darkCard??i.darkBackground),e.style.setProperty("--secondary",i.darkMuted??i.darkCard??i.darkBackground),e.style.setProperty("--accent",i.darkMuted??i.darkCard??i.darkBackground)):["--background","--card","--popover","--muted","--secondary","--accent"].forEach(c=>{e.style.removeProperty(c)}),o}const N4=h.createContext(),Ra=()=>{const e=h.useContext(N4);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e},yj=({children:e})=>{const[t,r]=h.useState(()=>{const g=localStorage.getItem("theme");return g?g==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1}),[n,a]=h.useState(fj),[i,o]=h.useState(()=>kv(vv,E4)),[l,c]=h.useState(()=>kv(wv,C4));h.useEffect(()=>{const g=xj(document.documentElement,n,t,i,l);if(t){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const b=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');b&&b.setAttribute("content","black-translucent");const x=document.querySelector('meta[name="theme-color"]');x&&x.setAttribute("content",g)}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const b=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');b&&b.setAttribute("content","default");const x=document.querySelector('meta[name="theme-color"]');x&&x.setAttribute("content",g)}},[n,l,i,t]),h.useEffect(()=>{if(!window.matchMedia)return;const g=window.matchMedia("(prefers-color-scheme: dark)"),b=x=>{localStorage.getItem("theme")||r(x.matches)};return g.addEventListener("change",b),()=>g.removeEventListener("change",b)},[]);const m={isDarkMode:t,toggleDarkMode:()=>{r(g=>!g)},accentTheme:n,setAccentTheme:g=>{a(g),localStorage.setItem(S4,g)},customLightAccent:i,setCustomLightAccent:g=>{o(g),localStorage.setItem(vv,g)},customDarkAccent:l,setCustomDarkAccent:g=>{c(g),localStorage.setItem(wv,g)}};return s.jsx(N4.Provider,{value:m,children:e})},vj=!1,wj={name:"default",displayName:"default",fullPath:"",path:""},we=(e,t={})=>{const r=localStorage.getItem("auth-token"),n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),r&&(n.Authorization=`Bearer ${r}`),fetch(e,{...t,headers:{...n,...t.headers}}).then(a=>{const i=a.headers.get("X-Refreshed-Token");return i&&localStorage.setItem("auth-token",i),a})},lt={auth:{status:()=>fetch("/api/auth/status"),connectionMode:()=>fetch("/api/auth/connection-mode"),updateConnectionMode:e=>fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>we("/api/auth/user"),logout:()=>we("/api/auth/logout",{method:"POST"})},publicApiManifest:()=>we("/api/public/manifest"),diagnostics:()=>we("/api/diagnostics"),refreshDiagnostics:()=>we("/api/diagnostics/refresh",{method:"POST"}),remoteConnection:()=>we("/api/remote/config"),updateRemoteConnection:e=>we("/api/remote/config",{method:"PUT",body:JSON.stringify(e)}),projects:()=>we("/api/projects"),sessions:(e,t=5,r=0)=>we(`/api/projects/${e}/sessions?limit=${t}&offset=${r}`),unifiedSessionMessages:(e,t="claude",{projectName:r="",projectPath:n="",limit:a=null,offset:i=0}={})=>{const o=new URLSearchParams;o.append("provider",t),r&&o.append("projectName",r),n&&o.append("projectPath",n),a!==null&&(o.append("limit",String(a)),o.append("offset",String(i)));const l=o.toString();return we(`/api/sessions/${encodeURIComponent(e)}/messages${l?`?${l}`:""}`)},renameProject:(e,t)=>we(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>we(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),renameSession:(e,t,r)=>we(`/api/sessions/${e}/rename`,{method:"PUT",body:JSON.stringify({summary:t,provider:r})}),deleteCodexSession:e=>we(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteGeminiSession:e=>we(`/api/gemini/sessions/${e}`,{method:"DELETE"}),deleteQwenSession:e=>we(`/api/qwen/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1,r=!1)=>{const n=new URLSearchParams;t&&n.set("force","true"),r&&n.set("deleteData","true");const a=n.toString();return we(`/api/projects/${e}${a?`?${a}`:""}`,{method:"DELETE"})},searchConversationsUrl:(e,t=50)=>{const r=localStorage.getItem("auth-token"),n=new URLSearchParams({q:e,limit:String(t)});return r&&n.set("token",r),`/api/search/conversations?${n.toString()}`},createWorkspace:e=>we("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),quickStartProject:()=>we("/api/projects/quick-start",{method:"POST",body:"{}"}),readFile:(e,t)=>we(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),readFileBlob:(e,t)=>we(`/api/projects/${e}/files/content?path=${encodeURIComponent(t)}`),saveFile:(e,t,r)=>we(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:r})}),getFiles:(e,t={})=>we(`/api/projects/${e}/files`,t),createFile:(e,{path:t,type:r,name:n})=>we(`/api/projects/${e}/files/create`,{method:"POST",body:JSON.stringify({path:t,type:r,name:n})}),renameFile:(e,{oldPath:t,newName:r})=>we(`/api/projects/${e}/files/rename`,{method:"PUT",body:JSON.stringify({oldPath:t,newName:r})}),deleteFile:(e,{path:t,type:r})=>we(`/api/projects/${e}/files`,{method:"DELETE",body:JSON.stringify({path:t,type:r})}),uploadFiles:(e,t)=>we(`/api/projects/${e}/files/upload`,{method:"POST",body:t,headers:{}}),taskmaster:{init:e=>we(`/api/taskmaster/init/${e}`,{method:"POST"}),addTask:(e,{prompt:t,title:r,description:n,priority:a,dependencies:i})=>we(`/api/taskmaster/add-task/${e}`,{method:"POST",body:JSON.stringify({prompt:t,title:r,description:n,priority:a,dependencies:i})}),parsePRD:(e,{fileName:t,numTasks:r,append:n})=>we(`/api/taskmaster/parse-prd/${e}`,{method:"POST",body:JSON.stringify({fileName:t,numTasks:r,append:n})}),getTemplates:()=>we("/api/taskmaster/prd-templates"),applyTemplate:(e,{templateId:t,fileName:r,customizations:n})=>we(`/api/taskmaster/apply-template/${e}`,{method:"POST",body:JSON.stringify({templateId:t,fileName:r,customizations:n})}),updateTask:(e,t,r)=>we(`/api/taskmaster/update-task/${e}/${t}`,{method:"PUT",body:JSON.stringify(r)})},browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),we(`/api/browse-filesystem?${t}`)},createFolder:e=>we("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),user:{gitConfig:()=>we("/api/user/git-config"),updateGitConfig:(e,t)=>we("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:e,gitEmail:t})}),onboardingStatus:()=>we("/api/user/onboarding-status"),completeOnboarding:()=>we("/api/user/complete-onboarding",{method:"POST"})},get:e=>we(`/api${e}`),post:(e,t)=>we(`/api${e}`,{method:"POST",...t instanceof FormData?{body:t}:{body:JSON.stringify(t)}}),put:(e,t)=>we(`/api${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:(e,t={})=>we(`/api${e}`,{method:"DELETE",...t})},Id="auth-token",bi={authStatusCheckFailed:"Failed to check authentication status",loginFailed:"Login failed",registrationFailed:"Registration failed",networkError:"Network error. Please try again."};async function uo(e){try{return await e.json()}catch{return null}}function Sv(e,t){return e?e.error??e.message??t:t}const T4=h.createContext(null),kj=()=>localStorage.getItem(Id),Sj=e=>{localStorage.setItem(Id,e)},Ej=()=>{localStorage.removeItem(Id)};function Hi(){const e=h.useContext(T4);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Cj({children:e}){const[t,r]=h.useState(null),[n,a]=h.useState(()=>kj()),[i,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState(!0),[p,f]=h.useState(null),m=h.useCallback((S,j)=>{r(S),a(j),Sj(j)},[]),g=h.useCallback(()=>{r(null),a(null),Ej()},[]),b=h.useCallback(async()=>{try{const S=await lt.user.onboardingStatus();if(!S.ok)return;const j=await uo(S);u(!!j?.hasCompletedOnboarding)}catch(S){console.error("Error checking onboarding status:",S),u(!0)}},[]),x=h.useCallback(async()=>{await b()},[b]),y=h.useCallback(async()=>{try{o(!0),f(null);const S=await lt.auth.status();if((await uo(S))?.needsSetup){c(!0);return}if(c(!1),!n)return;const A=await lt.auth.user();if(!A.ok){g();return}const _=await uo(A);if(!_?.user){g();return}r(_.user),await b()}catch(S){console.error("[Auth] Auth status check failed:",S),f(bi.authStatusCheckFailed)}finally{o(!1)}},[b,g,n]);h.useEffect(()=>{y()},[y,b]);const v=h.useCallback(async(S,j)=>{try{f(null);const A=await lt.auth.login(S,j),_=await uo(A);if(!A.ok||!_?.token||!_.user){const N=Sv(_,bi.loginFailed);return f(N),{success:!1,error:N}}return m(_.user,_.token),c(!1),await b(),{success:!0}}catch(A){return console.error("Login error:",A),f(bi.networkError),{success:!1,error:bi.networkError}}},[b,m]),w=h.useCallback(async(S,j)=>{try{f(null);const A=await lt.auth.register(S,j),_=await uo(A);if(!A.ok||!_?.token||!_.user){const N=Sv(_,bi.registrationFailed);return f(N),{success:!1,error:N}}return m(_.user,_.token),c(!1),await b(),{success:!0}}catch(A){return console.error("Registration error:",A),f(bi.networkError),{success:!1,error:bi.networkError}}},[b,m]),k=h.useCallback(()=>{const S=n;g(),S&&lt.auth.logout().catch(j=>{console.error("Logout endpoint error:",j)})},[g,n]),E=h.useMemo(()=>({user:t,token:n,isLoading:i,needsSetup:l,hasCompletedOnboarding:d,error:p,login:v,register:w,logout:k,refreshOnboardingStatus:x}),[p,d,i,v,k,l,x,w,n,t]);return s.jsx(T4.Provider,{value:E,children:e})}const Nj="pixcode.notification.once.",A4="pixcode.notificationPreferences.v1",Tj={action_required:"actionRequired",stop:"stop",error:"error",update:"updates",updates:"updates"};function Aj(e="updates"){try{const t=JSON.parse(localStorage.getItem(A4)??"null");return t?.channels?.desktop===!1?!1:t?.events?.[Tj[e]||e]!==!1}catch{return!0}}function rs(e){try{localStorage.setItem(A4,JSON.stringify(e))}catch{}}async function _4({key:e,title:t,body:r,tag:n,data:a}){return j4({key:e,title:t,body:r,event:"updates",tag:n,data:a})}async function j4({key:e,title:t,body:r,event:n="updates",tag:a,data:i}){if(typeof window>"u"||!Aj(n))return!1;const o=`${Nj}${e}`;try{if(localStorage.getItem(o))return!1}catch{}try{if(await window.pixcodeDesktop?.notify({title:t,body:r,event:n,tag:a,data:i})){try{localStorage.setItem(o,new Date().toISOString())}catch{}return!0}}catch(c){console.warn("Desktop notification bridge failed:",c)}if(!("Notification"in window)||Notification.permission!=="granted")return!1;const l={body:r,icon:"/logo-256.png",badge:"/logo-128.png",tag:a,data:i,renotify:!!a};try{const c="serviceWorker"in navigator?await navigator.serviceWorker.ready.catch(()=>null):null;c?.showNotification?await c.showNotification(t,l):new Notification(t,l);try{localStorage.setItem(o,new Date().toISOString())}catch{}return!0}catch(c){return console.warn("Local notification failed:",c),!1}}const I4={claude:"npm install -g @anthropic-ai/claude-code",cursor:"curl https://cursor.com/install -fsSL | bash",codex:"npm install -g @openai/codex",gemini:"npm install -g @google/gemini-cli",qwen:"npm install -g @qwen-code/qwen-code",opencode:"npm install -g opencode-ai"},tl={claude:"Claude Code",cursor:"Cursor CLI",codex:"OpenAI Codex",gemini:"Gemini CLI",qwen:"Qwen Code",opencode:"OpenCode"},R4=["claude","cursor","codex","gemini","qwen","opencode"],Ev={claude:"/api/providers/claude/auth/status",cursor:"/api/providers/cursor/auth/status",codex:"/api/providers/codex/auth/status",gemini:"/api/providers/gemini/auth/status",qwen:"/api/providers/qwen/auth/status",opencode:"/api/providers/opencode/auth/status"},Cv=(e=!0)=>({claude:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},cursor:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},codex:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},gemini:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},qwen:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null},opencode:{authenticated:!1,installed:null,email:null,method:null,error:null,loading:e,checkedAt:null}}),_j="Failed to check authentication status",jj="Unknown error",D4="pixcode.providerAuthStatus.cache.v2",Tc=1440*60*1e3,Ij=3600*1e3;let Nv=0;const Rj=e=>e instanceof Error?e.message:jj,Dj=(e,t=null)=>({authenticated:!!e.authenticated,installed:typeof e.installed=="boolean"?e.installed:null,email:e.email??null,method:e.method??null,error:e.error??t,loading:!1,checkedAt:e.checkedAt??new Date().toISOString(),installedVersion:e.installedVersion??null,latestVersion:e.latestVersion??null,updateAvailable:!!e.updateAvailable,versionCheckSkipped:e.versionCheckSkipped??null,fromCache:!!e.fromCache});function Nm(){try{const e=JSON.parse(localStorage.getItem(D4)??"null");return!e||typeof e.savedAt!="number"||!e.statuses?null:e}catch{return null}}function Lj(e){try{localStorage.setItem(D4,JSON.stringify({savedAt:Date.now(),statuses:e}))}catch{}}function Oj(e){const t=Nm(),r=Cv(!1);return t&&Date.now()-t.savedAt<Tc?Object.fromEntries(R4.map(n=>[n,{...r[n],...t.statuses[n],loading:!1,fromCache:!0}])):Cv(e)}function Tv(e,t){if(!t.updateAvailable||!t.latestVersion)return;const r=tl[e]??e,n=t.installedVersion?` ${t.installedVersion}`:"";_4({key:`cli-update:${e}:${t.latestVersion}`,title:`${r} update available`,body:`${r}${n} can update to ${t.latestVersion}.`,tag:`pixcode-cli-update:${e}`,data:{type:"cli-update",provider:e,latestVersion:t.latestVersion}})}function r0({initialLoading:e=!0}={}){const[t,r]=h.useState(()=>Oj(e)),n=h.useCallback(l=>{r(c=>({...c,[l]:{...c[l],loading:!0,error:null}}))},[]),a=h.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]),i=h.useCallback(async(l,c={})=>{const d=Nm(),u=d?.statuses?.[l];if(!c.force&&d&&u&&Date.now()-d.savedAt<Tc){const p={...u,loading:!1,fromCache:!0};a(l,p),Tv(l,p);return}n(l);try{const p=c.force?`${Ev[l]}?refresh=1`:Ev[l],f=await we(p,{cache:"no-store"});if(!f.ok){a(l,{authenticated:!1,installed:null,email:null,method:null,loading:!1,error:_j});return}const m=await f.json(),g=Dj(m.data);Tv(l,g),r(b=>{const x={...b,[l]:g};return Lj(x),x})}catch(p){console.error(`Error checking ${l} auth status:`,p),a(l,{authenticated:!1,installed:null,email:null,method:null,loading:!1,error:Rj(p)})}},[n,a]),o=h.useCallback(async(l=R4,c={})=>{await Promise.all(l.map(d=>i(d,c)))},[i]);return h.useEffect(()=>{const l=window.setInterval(()=>{const c=Date.now();if(c-Nv<Tc)return;const d=Nm();d&&c-d.savedAt<Tc||(Nv=c,o())},Ij);return()=>window.clearInterval(l)},[o]),{providerAuthStatus:t,setProviderAuthStatus:r,checkProviderAuthStatus:i,refreshProviderAuthStatuses:o}}const L4="https://auth.openai.com/codex/device",Mj=200,O4=100,Pj=50,Fj=500,zj=20,Bj=15,$j=5,Uj=2,Gj={cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selectionBackground:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}};function Hj(e){if(!e||typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(t)}return r}async function Sn(e){if(!e)return!1;let t=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{t=!1}return t||(t=Hj(e)),t}function qj(){const e=window.location.protocol==="https:"?"wss:":"ws:",t=localStorage.getItem("auth-token");return t?`${e}//${window.location.host}/shell?token=${encodeURIComponent(t)}`:(console.error("No authentication token found for Shell WebSocket connection"),null)}function Vj(e){try{return JSON.parse(e)}catch{return null}}function Ri(e,t){e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}const Wj=/(?:\u001B\[[0-?]*[ -/]*[@-~]|\u009B[0-?]*[ -/]*[@-~]|\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u009D[^\u0007\u009C]*(?:\u0007|\u009C)|\u001B[PX^_][^\u001B]*\u001B\\|[\u0090\u0098\u009E\u009F][^\u009C]*\u009C|\u001B[@-Z\\-_])/g,Kj=/Process exited with code (\d+)/;function Yj({wsRef:e,terminalRef:t,fitAddonRef:r,selectedProjectRef:n,selectedSessionRef:a,initialCommandRef:i,isPlainShellRef:o,onProcessCompleteRef:l,isInitialized:c,autoConnect:d,closeSocket:u,clearTerminalScreen:p,setAuthUrl:f,onOutputRef:m}){const[g,b]=h.useState(!1),[x,y]=h.useState(!1),v=h.useRef(!1),w=h.useRef(!1),k=h.useCallback(_=>{if(!o.current||!l.current)return;const D=_.replace(Wj,"");if(D.includes("Process exited with code 0")){l.current(0);return}const T=D.match(Kj);if(!T)return;const R=Number.parseInt(T[1],10);!Number.isNaN(R)&&R!==0&&l.current(R)},[o,l]),E=h.useCallback(_=>{const N=Vj(_);if(!N){console.error("[Shell] Error handling WebSocket message:",_);return}if(N.type==="output"){const D=typeof N.data=="string"?N.data:"";k(D),t.current?.write(D),m?.current?.();return}if(N.type==="auth_url"||N.type==="url_open"){const D=typeof N.url=="string"?N.url:"";D&&f(D)}},[k,m,f,t]),S=h.useCallback((_=!1)=>{if(!(v.current&&!_||x||g))try{const N=qj();if(!N){v.current=!1,y(!1);return}v.current=!0;const D=new WebSocket(N);e.current=D,D.onopen=()=>{b(!0),y(!1),v.current=!1,f(""),window.setTimeout(()=>{const T=t.current,R=r.current,C=n.current;!T||!R||!C||(R.fit(),Ri(D,{type:"init",projectPath:C.fullPath||C.path||"",sessionId:o.current?null:a.current?.id||null,hasSession:o.current?!1:!!a.current,provider:o.current?"plain-shell":a.current?.__provider||localStorage.getItem("selected-provider")||"claude",cols:T.cols,rows:T.rows,initialCommand:i.current,isPlainShell:o.current}))},O4)},D.onmessage=T=>{const R=typeof T.data=="string"?T.data:String(T.data??"");E(R)},D.onclose=()=>{b(!1),y(!1),v.current=!1,p()},D.onerror=()=>{b(!1),y(!1),v.current=!1}}catch{b(!1),y(!1),v.current=!1}},[p,r,E,i,g,x,o,n,a,f,t,e]),j=h.useCallback(()=>{!c||g||x||v.current||(w.current=!1,v.current=!0,y(!0),S(!0))},[S,g,x,c]),A=h.useCallback((_=!0)=>{_&&(w.current=!0),u(),p(),b(!1),y(!1),v.current=!1,f("")},[p,u,f]);return h.useEffect(()=>{!d||w.current||!c||x||g||j()},[d,j,g,x,c]),{isConnected:g,isConnecting:x,closeSocket:u,connectToShell:j,disconnectFromShell:A}}var Zj=y_(),Nu={exports:{}},Av;function Xj(){return Av||(Av=1,function(e,t){(function(r,n){e.exports=n()})(self,()=>(()=>{var r={6:(o,l)=>{function c(u){try{const p=new URL(u),f=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return u.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(l,"__esModule",{value:!0}),l.LinkComputer=l.WebLinkProvider=void 0,l.WebLinkProvider=class{constructor(u,p,f,m={}){this._terminal=u,this._regex=p,this._handler=f,this._options=m}provideLinks(u,p){const f=d.computeLink(u,this._regex,this._terminal,this._handler);p(this._addCallbacks(f))}_addCallbacks(u){return u.map(p=>(p.leave=this._options.leave,p.hover=(f,m)=>{if(this._options.hover){const{range:g}=p;this._options.hover(f,m,g)}},p))}};class d{static computeLink(p,f,m,g){const b=new RegExp(f.source,(f.flags||"")+"g"),[x,y]=d._getWindowedLineStrings(p-1,m),v=x.join("");let w;const k=[];for(;w=b.exec(v);){const E=w[0];if(!c(E))continue;const[S,j]=d._mapStrIdx(m,y,0,w.index),[A,_]=d._mapStrIdx(m,S,j,E.length);if(S===-1||j===-1||A===-1||_===-1)continue;const N={start:{x:j+1,y:S+1},end:{x:_,y:A+1}};k.push({range:N,text:E,activate:g})}return k}static _getWindowedLineStrings(p,f){let m,g=p,b=p,x=0,y="";const v=[];if(m=f.buffer.active.getLine(p)){const w=m.translateToString(!0);if(m.isWrapped&&w[0]!==" "){for(x=0;(m=f.buffer.active.getLine(--g))&&x<2048&&(y=m.translateToString(!0),x+=y.length,v.push(y),m.isWrapped&&y.indexOf(" ")===-1););v.reverse()}for(v.push(w),x=0;(m=f.buffer.active.getLine(++b))&&m.isWrapped&&x<2048&&(y=m.translateToString(!0),x+=y.length,v.push(y),y.indexOf(" ")===-1););}return[v,g]}static _mapStrIdx(p,f,m,g){const b=p.buffer.active,x=b.getNullCell();let y=m;for(;g;){const v=b.getLine(f);if(!v)return[-1,-1];for(let w=y;w<v.length;++w){v.getCell(w,x);const k=x.getChars();if(x.getWidth()&&(g-=k.length||1,w===v.length-1&&k==="")){const E=b.getLine(f+1);E&&E.isWrapped&&(E.getCell(0,x),x.getWidth()===2&&(g+=1))}if(g<0)return[f,w]}f++,y=0}return[f,y]}}l.LinkComputer=d}},n={};function a(o){var l=n[o];if(l!==void 0)return l.exports;var c=n[o]={exports:{}};return r[o](c,c.exports,a),c.exports}var i={};return(()=>{var o=i;Object.defineProperty(o,"__esModule",{value:!0}),o.WebLinksAddon=void 0;const l=a(6),c=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function d(u,p){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}o.WebLinksAddon=class{constructor(u=d,p={}){this._handler=u,this._options=p}activate(u){this._terminal=u;const p=this._options,f=p.urlRegex||c;this._linkProvider=this._terminal.registerLinkProvider(new l.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),i})())}(Nu)),Nu.exports}var Jj=Xj(),Qj=v_(),eI=w_();function M4(e){return typeof e=="string"&&/\bcodex\s+login\b/i.test(e)}function tI(e,t){return M4(e)?L4:t}function rI(e){return e?e.__provider==="cursor"?e.name||"Untitled Session":e.summary||"New Session":null}const _v="shell-xterm-focus-style",nI=`
10
10
  .xterm .xterm-screen {
11
11
  outline: none !important;
12
12
  }
@@ -226,7 +226,7 @@ import{j as s,a as d4,R as Xh,o as Jh,_ as Y6,b as Z6,m as u4,E as kn,T as p4,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 U9=[["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"}]],G9=ft("workflow",U9),a0=F4,Y4=_I,Iv=CI,H9=PI,q9=gI,i0=wI,V9=P4,Mr=$4,W9=b7,s0=u7,En=m7,K9=f7,In=SI,Jn=P4,Wc=TI,Z4=yI,Y9=s7,Z9=l7,X4=II,Tt=z4,nr=z4,Rd=OI,J4=DI,X9=T8,ga=H7,Tr=V7,Qt=a7,ya=r7,Q4=p8,an=Z8,J9=H4,Q9=H4,Kc=YI,Dd=w7,eE=y7,Ld=U4,Go=N7,rl=M7,$t=F7,Ln=a8,va=e8,ti=r8,eD=L8,tD=d8,nl=b8,o0=H8,rD=zI,Od=XI,nD=uR,aD=n0,iD=n0,Tm=I8,sD=s8,oD=J7,lD=tR,cD=U8,dD=S8,tE=_8,Am=n0,rE=M8,Ut=F8,vr=mR,uD=B7,wa=w8,bt=q4,_m=q4,l0=iR,c0=qI,pD=GI,jm=$I,mD=U7,Qn=B4,hD=B4,fD=fR,nE=bR,al=QI,aE=E7,qi=Z7,d0=K7,ri=l8,iE=U4,u0=G4,gD=G4,sE=f8,bn=y8,p0=C8,oE=R7,lE=cR,bD=B8,m0=K8,xD=V8,Lt=A7,yD=pI,cE=L7,ka=Q8,Ns=nR,h0=oR,Br=j7,f0=WI,vD=TR,El=DR,g0=W4,wD=W4,Zr=g9,Im=x9,kD=v9,ns=CR,as=_R,SD=IR,_o=OR,Ts=PR,Rv=UR,jo=HR,po=KR,ED=ZR,dE=l9,Rm=JR,mo=r9,ho=e9,Dv=a9,fo=s9,Dm=d9,CD=p9,Lm=h9,vs=E9,Io=N9,Pa=A9,is=j9,ND=R9,Om=L9,TD=P9,go=$9,ea=G9,il=BR,uE=VR,AD=k9,_D=z9,jD=[{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"}],ID={up:Y4,down:a0,left:q9,right:i0},bo=e=>e.preventDefault(),Lv="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",RD="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",Tu="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 Ov({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Re("settings"),[i,o]=h.useState(!1),[l,c]=h.useState(!1),d=h.useCallback(m=>{Ri(e.current,{type:"input",data:m})},[e]),u=h.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=h.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&d(m)}catch{}},[d]),f=h.useCallback(m=>{let g=m;if(i&&m.length===1){const b=m.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&m.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:bo,onClick:()=>{p()},disabled:!r,className:Tu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(Dd,{className:"h-4 w-4"})}),jD.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?i:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:bo,onClick:b,disabled:!r,className:g?RD:Lv,children:m.label},m.id)}if(m.type==="arrow"){const g=ID[m.icon];return s.jsx("button",{type:"button",onPointerDown:bo,onClick:()=>d(m.sequence),disabled:!r,className:Tu,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:bo,onClick:()=>f(m.sequence),disabled:!r,className:Lv,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:bo,onClick:u,disabled:!r,className:Tu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(V9,{className:"h-4 w-4"})})]})})}function pE({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}=Re("chat"),[d,u]=h.useState(!1),[p,f]=h.useState(null),m=h.useRef(null),g=h.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:k,authUrl:E,authUrlVersion:S,connectToShell:j,disconnectFromShell:A,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:N}=sI({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),D=h.useCallback(()=>{const $=x.current;if(!$)return;const z=$.buffer.active,ne=z.baseY+z.cursorY,Q=Math.min(z.baseY+z.length-1,ne+10),ge=Math.max(0,ne-zj),ae=[];for(let Se=ge;Se<=Q;Se++){const ze=z.getLine(Se);ze&&ae.push(ze.translateToString().trimEnd())}let pe=-1;for(let Se=ae.length-1;Se>=0;Se--)if(/esc to cancel/i.test(ae[Se])||/enter to select/i.test(ae[Se])){pe=Se;break}if(pe===-1){f(null);return}const de=new Map,fe=Math.max(0,pe-Bj);for(let Se=pe-1;Se>=fe;Se--){const ze=ae[Se].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(ze){const M=ze[1],ue=ze[2].trim();parseInt(M,10)<=$j&&ue.length>0&&!de.has(M)&&de.set(M,ue)}}const ve=[];for(let Se=1;Se<=de.size&&de.has(String(Se));Se++)ve.push({number:String(Se),label:de.get(String(Se))});f(ve.length>=Uj?ve:null)},[x]),T=h.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(D,Fj)},[D]);h.useEffect(()=>{g.current=T},[T]),h.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),f(null))},[v]),h.useEffect(()=>{if(!l||!w||!v)return;const $=()=>{x.current?.focus()},z=window.requestAnimationFrame($),ne=window.setTimeout($,0);return()=>{window.cancelAnimationFrame(z),window.clearTimeout(ne)}},[l,v,w,x]);const R=h.useCallback($=>{Ri(y.current,{type:"input",data:$})},[y]),C=h.useMemo(()=>rI(t),[t]),P=h.useMemo(()=>C?C.slice(0,30):null,[C]),H=h.useMemo(()=>C?C.slice(0,50):null,[C]),F=h.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},Mj)},[]);if(!e)return s.jsx(lI,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(dI,{terminalContainerRef:b,authUrl:E,authUrlVersion:S,initialCommand:r,isConnected:v,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:N}),s.jsx(Ov,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const U=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:H}):c("shell.startSession"),G=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?k?"connecting":v?null:"connect":"loading",q=O==="connecting"?G:U;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(cI,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:P,onDisconnect:A,onRestart:F,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"}}),O&&s.jsx(oI,{mode:O,description:q,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:$=>$.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map($=>s.jsxs("button",{type:"button",onClick:()=>{R($.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:`${$.number}. ${$.label}`,children:[$.number,". ",$.label]},$.number)),s.jsx("button",{type:"button",onClick:()=>{R("\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(Ov,{wsRef:y,terminalRef:x,isConnected:v})]})}function DD({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 LD({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 mE({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[m,g]=h.useState(!1),b=n!==null?n:r!==null,x=h.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(LD,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(pE,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:i})})]}):s.jsx(DD,{className:d})}const OD=(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"),MD={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 Mv({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 PD({provider:e}){const[t,r]=h.useState(""),[n,a]=h.useState(!1),[i,o]=h.useState("idle"),[l,c]=h.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await we(`/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(nr,{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(Qt,{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 FD({provider:e,onSaved:t}){const r=MD[e],[n,a]=h.useState(""),[i,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState("idle"),[p,f]=h.useState(null);h.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await we("/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 m=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await we(`/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(gD,{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(In,{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 m(),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(nr,{className:"h-4 w-4 animate-spin"}):s.jsx(Qt,{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 hE({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:i=!1}){const{t:o}=Re("common"),l=r!=="cursor",[c,d]=h.useState(l?"apiKey":"browser");h.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=h.useMemo(()=>`${tl[r]??r} Login`,[r]);if(!e)return null;const p=OD(r,a),f=m=>n?.(m);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(bt,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(Mv,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(Mv,{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(mE,{project:wj,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(PD,{provider:r})})]}):s.jsx(FD,{provider:r,onSaved:()=>f(0)})})]})})}const zD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),BD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},$D=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},UD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),GD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:r,alt:"OpenCode",className:e})},HD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function lr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx($D,{className:t}):e==="codex"?s.jsx(BD,{className:t}):e==="gemini"?s.jsx(UD,{className:t}):e==="qwen"?s.jsx(HD,{className:t}):e==="opencode"?s.jsx(GD,{className:t}):s.jsx(zD,{className:t})}function qD({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(lr,{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(Qt,{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 VD=[{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 WD({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:VD.map(r=>s.jsx(qD,{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 KD({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(Zr,{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(fD,{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(mD,{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 Pv=[{title:"Git Configuration",icon:Zr,required:!0},{title:"Connect Agents",icon:Z4,required:!1},{title:"Task System",icon:o0,required:!1}];function YD({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:Pv.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(Qt,{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<Pv.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 ZD=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 XD({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=h.useState(null),[i,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState([]),[p,f]=h.useState(""),m=h.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=h.useMemo(()=>!e||g,[e,g]);h.useEffect(()=>{r(x)},[r,x]);const y=h.useCallback(async()=>{o(!0),f("");try{const w=await we("/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)}},[]);h.useEffect(()=>(y(),()=>{m.current?.close(),m.current=null}),[y]);const v=h.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await we("/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 E=localStorage.getItem(Id),S=E?`?token=${encodeURIComponent(E)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(k.jobId)}/stream${S}`);m.current=j,j.addEventListener("log",A=>{const _=JSON.parse(A.data);u(N=>[...N,_].slice(-80))}),j.addEventListener("done",A=>{const _=JSON.parse(A.data);if(j.close(),m.current=null,c(!1),!_.success){f(_.error||_.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),m.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(ya,{className:"h-5 w-5 text-green-600"}):s.jsx(Br,{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:ZD(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(nr,{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 Fv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,zv=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function JD({onComplete:e}){const[t,r]=h.useState(0),[n,a]=h.useState(""),[i,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState(""),[p,f]=h.useState(null),[m,g]=h.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=h.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=r0(),k=h.useRef(void 0),E=h.useCallback(async()=>{try{const T=await we("/api/user/git-config");if(!T.ok)return;const R=await T.json();R.gitName&&a(R.gitName),R.gitEmail&&o(R.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);h.useEffect(()=>{E(),w()},[E,w]),h.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)},A=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(!Fv.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await we("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:i})});if(!T.ok){const R=await zv(T,"Failed to save git configuration");throw new Error(R)}r(R=>R+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},_=()=>{u(""),r(T=>T-1)},N=async()=>{if(m&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(m));const T=await we("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const R=await zv(T,"Failed to complete onboarding");throw new Error(R)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},D=t===0?!!(n.trim()&&i.trim()&&Fv.test(i)):t===2?!m||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(YD,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(KD,{gitName:n,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?s.jsx(WD,{providerStatuses:y,onOpenProviderLogin:S}):s.jsx(XD,{enabled:m,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:_,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(s0,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<2?s.jsx("button",{onClick:A,disabled:!D||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(nr,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(En,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:N,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(nr,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Qt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(hE,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const QD=["0s","0.1s","0.2s"];function eL(){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(Qn,{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:QD.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 fE({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 Ti({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 gE({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(Qn,{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 tL={username:"",password:""};function rL(){const{t:e}=Re("auth"),{login:t}=Hi(),[r,n]=h.useState(tL),[a,i]=h.useState(""),[o,l]=h.useState(!1),c=h.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=h.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(gE,{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(Ti,{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(Ti,{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(fE,{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 nL={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function aL(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 iL(){const{register:e}=Hi(),[t,r]=h.useState(nL),[n,a]=h.useState(""),[i,o]=h.useState(!1),l=h.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=h.useCallback(async d=>{d.preventDefault(),a("");const u=aL(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 m=await p.json().catch(()=>null);a(m?.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(gE,{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(Ti,{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(Ti,{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(Ti,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(Ti,{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(Ti,{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(fE,{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 sL({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=Hi();return r?s.jsx(eL,{}):n?s.jsx(iL,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(JD,{onComplete:i}):s.jsx(rL,{})}const bE=h.createContext(null),xE=()=>{const e=h.useContext(bE);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},oL=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},lL=()=>{const e=h.useRef(null),t=h.useRef(!1),r=h.useRef(!1),[n,a]=h.useState(null),[i,o]=h.useState(!1),l=h.useRef(null),{token:c}=Hi(),d=h.useCallback(()=>{if(!t.current)try{const f=oL(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(f);m.onopen=()=>{o(!0),e.current=m,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},m.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},m.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);h.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=h.useCallback(f=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return h.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:i}),[u,n,i])},cL=({children:e})=>{const t=lL();return s.jsx(bE.Provider,{value:t,children:e})},yE=h.createContext(null);function dL(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Bv(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 uL(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function pL(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Ys(){const e=h.useContext(yE);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function mL({children:e}){const{latestMessage:t}=xE(),{user:r,token:n,isLoading:a}=Hi(),[i,o]=h.useState([]),[l,c]=h.useState(null),[d,u]=h.useState(null),[p,f]=h.useState(null),[m,g]=h.useState([]),[b,x]=h.useState(null),[y,v]=h.useState(!1),[w,k]=h.useState(!1),[E,S]=h.useState(!1),[j,A]=h.useState(null),_=h.useRef(null);h.useEffect(()=>{_.current=l?.name??null},[l?.name]);const N=h.useCallback(()=>{A(null)},[]),D=h.useCallback((F,U)=>{console.error(`TaskMaster ${F} error:`,U),A(dL(F,U))},[]),T=h.useCallback(F=>{const U=F?Bv(F):null;c(U),u(U?.taskmaster??null),g([]),x(null)},[]),R=h.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),N();const F=await lt.get("/projects");if(!F.ok)throw new Error(`Failed to fetch projects: ${F.status}`);const U=await F.json(),O=(Array.isArray(U)?U:[]).map(z=>Bv(z));o(O);const q=_.current;if(!q)return;const $=O.find(z=>z.name===q)??null;c($),u($?.taskmaster??null)}catch(F){D("load projects",F)}finally{v(!1)}},[N,D,n,r]),C=h.useCallback(async()=>{const F=l?.name;if(!F||!r||!n){g([]),x(null);return}try{k(!0),N();const U=await lt.get(`/taskmaster/tasks/${encodeURIComponent(F)}`);if(!U.ok){const q=await U.json();throw new Error(q.message??"Failed to load tasks")}const G=await U.json(),O=Array.isArray(G.tasks)?G.tasks:[];g(O),x(uL(O))}catch(U){D("load tasks",U),g([]),x(null)}finally{k(!1)}},[N,l?.name,D,n,r]),P=h.useCallback(async()=>{if(!r||!n){f(null);return}try{S(!0),N();const F=await lt.get("/mcp-utils/taskmaster-server");if(!F.ok)throw new Error(`Failed to load MCP status: ${F.status}`);const U=await F.json();f(U)}catch(F){D("check MCP server status",F),f(null)}finally{S(!1)}},[N,D,n,r]);h.useEffect(()=>{!a&&r&&n&&(R(),P())},[a,P,R,n,r]),h.useEffect(()=>{l?.name&&r&&n&&C()},[l?.name,C,n,r]),h.useEffect(()=>{const F=t;if(pL(F)){if(F.type==="taskmaster-project-updated"&&F.projectName){R();return}if(F.type==="taskmaster-tasks-updated"&&F.projectName===l?.name){C();return}F.type==="taskmaster-mcp-status-changed"&&P()}},[l?.name,t,P,R,C]);const H=h.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:j,refreshProjects:R,setCurrentProject:T,refreshTasks:C,refreshMCPStatus:P,clearError:N}),[N,l,j,y,E,w,p,b,d,i,P,R,C,T,m]);return s.jsx(yE.Provider,{value:H,children:e})}const vE=h.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Md=()=>{const e=h.useContext(vE);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},hL=({children:e})=>{const{user:t,token:r,isLoading:n}=Hi(),[a,i]=h.useState(()=>{const y=localStorage.getItem("tasks-enabled");return y!==null?JSON.parse(y):!0}),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,p]=h.useState(null),[f,m]=h.useState(!0),g=!!(t&&r);h.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]),h.useEffect(()=>{if(n)return;if(!g){p(null),l(null),d(null),m(!1);return}m(!0);let y=!1;const w=setTimeout(async()=>{try{const k=await lt.get("/taskmaster/installation-status");if(y)return;if(k.ok){const E=await k.json();if(y)return;p(E),l(E.installation?.isInstalled||!1),d(E.isReady||!1);const S=localStorage.getItem("tasks-enabled");!E.installation?.isInstalled&&!S&&i(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(k){if(y)return;console.error("Error checking TaskMaster installation:",k),l(!1),d(!1)}finally{y||m(!1)}},0);return()=>{y=!0,clearTimeout(w)}},[g,n]);const x={tasksEnabled:a,setTasksEnabled:i,toggleTasksEnabled:()=>{i(y=>!y)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f};return s.jsx(vE.Provider,{value:x,children:e})},wE=h.createContext(null);function Pd(){const e=h.useContext(wE);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function fL({children:e}){const{user:t,token:r,isLoading:n}=Hi(),[a,i]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(null),u=!!(t&&r),p=h.useCallback(async()=>{if(!u){i([]),d(null),l(!1);return}l(!0);try{const x=await we("/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]);h.useEffect(()=>{n||p()},[n,p]);const f=h.useCallback(async x=>{try{const y=await we("/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]),m=h.useCallback(async x=>{try{const y=await we(`/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=h.useCallback(async x=>{try{const y=await we(`/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=h.useCallback(async(x,y)=>{try{const v=await we(`/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(wE.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:m,updatePlugin:g,togglePlugin:b},children:e})}const $v=e=>typeof window>"u"?!1:window.innerWidth<e,Uv=()=>{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 b0(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,i]=h.useState(()=>r?$v(t):!1),[o,l]=h.useState(()=>n?Uv():!1);return h.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{i($v(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),h.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(Uv())};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 x0="pixcode.updateCheck.preferences",Mm="pixcode:update-check-settings-changed",y0=[{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}],Pm={frequency:"30m"};function Gv(e){return y0.find(t=>t.value===e.frequency)?.intervalMs??null}function kE(e){if(!e||typeof e!="object")return Pm;const t=e.frequency;return y0.some(r=>r.value===t)?{frequency:t}:Pm}function Hv(){try{const e=localStorage.getItem(x0);return kE(e?JSON.parse(e):null)}catch{return Pm}}function gL(e){const t=kE(e);localStorage.setItem(x0,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(Mm,{detail:t}))}const Au=(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},bL="1.38.1",Fm="pixcode:update-available",xL=360*60*1e3,_u=new Map;function SE(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function yL(e,t){try{const r=localStorage.getItem(SE(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 qv(e,t,r){localStorage.setItem(SE(e,t),JSON.stringify(r))}function vL(e,t){const r=`${e}/${t}`,n=_u.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(()=>{_u.delete(r)});return _u.set(r,a),a}const EE=(e,t)=>{const[r,n]=h.useState(!1),[a,i]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState("git"),[u,p]=h.useState("idle"),[f,m]=h.useState(null),[g,b]=h.useState(()=>Hv()),[x,y]=h.useState(bL),v=h.useRef(null),w=h.useCallback(E=>{gL(E),b(E)},[]);h.useEffect(()=>{const E=()=>b(Hv()),S=j=>{j.key===x0&&E()};return window.addEventListener("storage",S),window.addEventListener(Mm,E),()=>{window.removeEventListener("storage",S),window.removeEventListener(Mm,E)}},[]),h.useEffect(()=>{let E=!1;const S=async()=>{try{const _=await(await fetch("/health",{cache:"no-store"})).json();if(E)return;(_.installMode==="npm"||_.installMode==="git")&&d(_.installMode),typeof _.version=="string"&&/^\d+\.\d+\.\d+/.test(_.version)&&y(_.version)}catch{}};S();const j=()=>{S()};return window.addEventListener("focus",j),()=>{E=!0,window.removeEventListener("focus",j)}},[]),h.useEffect(()=>{if(!x)return;let E=!1;const S=(T,R,C,P)=>({updateAvailable:!!(T&&Au(T,x)>0),latestVersion:T,releaseInfo:R,currentVersion:x,checkedAt:C,status:P}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(Fm,{detail:T}))},A=(T,R,C,P="success")=>{if(!T||!R)return n(!1),i(null),l(null),m(C),S(null,null,C,P);i(T),n(Au(T,x)>0),l(R),m(C);const H=S(T,R,C,P);return j(H),H},_=async({force:T=!1}={})=>{const R=Gv(g),C=yL(e,t),P=Date.now();if(!T&&R===null)return p("idle"),A(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!T&&C?.fetchedAt&&R!==null&&P-C.fetchedAt<R)return p("success"),A(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!T&&C?.rateLimitedUntil&&C.rateLimitedUntil>P)return p("error"),A(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const H=await vL(e,t);if(E)return S(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const F=H.data;if(!H.ok)return H.status===403&&qv(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:P+Math.max(R??0,xL)}),p("error"),A(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(F.tag_name){const U=F.tag_name.replace(/^v/,""),G=Au(U,x)>0,O={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};qv(e,t,{fetchedAt:P,latestVersion:U,releaseInfo:O}),i(U),n(G),G&&_4({key:`app-update:${U}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${U}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:U,installMode:c}}),l(O),p("success"),m(P);const q=S(U,O,P,"success");return j(q),q}else return n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}catch(H){return console.error("Version check failed:",H),n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}};v.current=_,_();const N=Gv(g),D=N===null?null:window.setInterval(()=>{_()},N);return()=>{E=!0,D!==null&&window.clearInterval(D)}},[e,t,x,c,g]);const k=h.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}},Ai={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},wL=["flat","grouped"],kL=e=>typeof e=="string"&&wL.includes(e),Yc=Object.keys(Ai),SL=new Set(Yc),ju="ui-preferences:sync",EL=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Zc=(e,t,r)=>e==="historyView"?kL(t)?t:r:EL(t,r),CL=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Zc(e,n,t)}catch{return t}},NL=e=>{if(typeof window>"u")return Ai;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 Yc.reduce((a,i)=>(a[i]=Zc(i,n[i],Ai[i]),a),{...Ai})}}}catch{}return Yc.reduce((t,r)=>(t[r]=CL(r,Ai[r]),t),{...Ai})};function TL(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!SL.has(r))return e;const a=Zc(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 Yc){if(!(i in r))continue;const o=r[i],l=Zc(i,o,e[i]);a[i]!==l&&(a[i]=l,n=!0)}return n?a:e}case"reset":return{...Ai,...t.value||{}};default:return e}}function v0(e="uiPreferences"){const t=h.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=h.useReducer(TL,e,NL);return h.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(ju,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),h.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(ju,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(ju,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 AL=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},_L=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},jL=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Vv=(e,t)=>`${e}::${t}`,IL=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},RL=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},DL=/(?:^|[\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,LL=e=>{if(!e)return[];const t=new Set,r=new RegExp(DL.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]},Li=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),OL=(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"),ML=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),PL=(e,t,r)=>{const n=Li(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:OL(e,r),sessionTime:ML(e),messageCount:Number(e.messageCount||0)}},CE=(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],m=new Map;for(const g of[...r,...n,...a,...c,...p,...f])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>Li(b).getTime()-Li(g).getTime())},Wv=(e,t)=>{const r=CE(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const i=Li(a);return i>n?i:n},new Date(0))},FL=(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"?Wv(o,n).getTime()-Wv(i,n).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},zL=(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},BL=(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"},$L=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 UL({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:m}){const[g,b]=h.useState(new Set),[x,y]=h.useState(null),[v,w]=h.useState(!1),[k,E]=h.useState(""),[S,j]=h.useState({}),[A,_]=h.useState({}),[N,D]=h.useState(new Set),[T,R]=h.useState(new Date),[C,P]=h.useState("name"),[H,F]=h.useState(!1),[U,G]=h.useState({}),[O,q]=h.useState(null),[$,z]=h.useState(""),[ne,Q]=h.useState(""),[ge,ae]=h.useState(new Set),[pe,de]=h.useState(null),[fe,ve]=h.useState(null),[Se,ze]=h.useState(!1),[M,ue]=h.useState(()=>_L()),[le,Y]=h.useState(()=>IL()),[W,ee]=h.useState("projects"),[be,xe]=h.useState(null),[oe,ke]=h.useState(!1),[X,re]=h.useState(null),Z=h.useRef(null),ce=h.useRef(0),ye=h.useRef(null),De=!a&&!m;h.useEffect(()=>{const Oe=setInterval(()=>{R(new Date)},6e4);return()=>clearInterval(Oe)},[]),h.useEffect(()=>{_({}),D(new Set),G({})},[e]),h.useEffect(()=>{t&&b(Oe=>{if(Oe.has(t.name))return Oe;const We=new Set(Oe);return We.add(t.name),We})},[r,t]),h.useEffect(()=>{if(e.length>0&&!n){const Oe=new Set;e.forEach(We=>{We.sessions&&We.sessions.length>=0&&Oe.add(We.name)}),D(Oe)}},[e,n]),h.useEffect(()=>{const Oe=()=>{P(AL())};Oe();const We=tt=>{tt.key==="claude-settings"&&Oe()},yt=()=>Oe();return window.addEventListener("storage",We),window.addEventListener("pixcode:settings-changed",yt),()=>{window.removeEventListener("storage",We),window.removeEventListener("pixcode:settings-changed",yt)}},[]),h.useEffect(()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null);const Oe=ne.trim();if(W!=="conversations"||Oe.length<2){ce.current+=1,xe(null),re(null),ke(!1);return}ke(!0);const We=++ce.current;return Z.current=setTimeout(()=>{if(We!==ce.current)return;const yt=lt.searchConversationsUrl(Oe),tt=new EventSource(yt);ye.current=tt;const Ve=[];let Ne=0;tt.addEventListener("result",Ue=>{if(We!==ce.current){tt.close();return}try{const Me=JSON.parse(Ue.data);Ve.push(Me.projectResult),Ne=Me.totalMatches,xe({results:[...Ve],totalMatches:Ne,query:Oe}),re({scannedProjects:Me.scannedProjects,totalProjects:Me.totalProjects})}catch{}}),tt.addEventListener("progress",Ue=>{if(We!==ce.current){tt.close();return}try{const Me=JSON.parse(Ue.data);Ne=Me.totalMatches,re({scannedProjects:Me.scannedProjects,totalProjects:Me.totalProjects})}catch{}}),tt.addEventListener("done",()=>{if(We!==ce.current){tt.close();return}tt.close(),ye.current=null,ke(!1),re(null),Ve.length===0&&xe({results:[],totalMatches:0,query:Oe})}),tt.addEventListener("error",()=>{if(We!==ce.current){tt.close();return}tt.close(),ye.current=null,ke(!1),re(null),Ve.length===0&&xe({results:[],totalMatches:0,query:Oe})})},400),()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null)}},[ne,W]);const Ke=h.useCallback(Oe=>{b(We=>{const yt=new Set;return We.has(Oe)||yt.add(Oe),yt})},[]),Ze=h.useCallback((Oe,We)=>{c({...Oe,__projectName:We})},[c]),Nt=h.useCallback(Oe=>{ue(We=>{const yt=new Set(We);return yt.has(Oe)?yt.delete(Oe):yt.add(Oe),jL(yt),yt})},[]),et=h.useCallback(Oe=>M.has(Oe),[M]),Et=h.useCallback((Oe,We)=>{Y(yt=>{const tt=Vv(Oe,We),Ve=new Set(yt);return Ve.has(tt)?Ve.delete(tt):Ve.add(tt),RL(Ve),Ve})},[]),wt=h.useCallback((Oe,We)=>le.has(Vv(Oe,We)),[le]),at=h.useCallback(Oe=>CE(Oe,A),[A]),se=h.useMemo(()=>e.map(Oe=>{const We=U[Oe.name];return We===void 0?Oe:{...Oe,sessionMeta:{...Oe.sessionMeta,hasMore:We}}}),[U,e]),Ie=h.useMemo(()=>FL(se,C,M,A),[A,C,se,M]),Pe=h.useMemo(()=>zL(Ie,ne),[ne,Ie]),Xe=h.useCallback(Oe=>{y(Oe.name),E(Oe.displayName)},[]),st=h.useCallback(()=>{y(null),E("")},[]),kt=h.useCallback(async Oe=>{try{(await lt.renameProject(Oe,k)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(We){console.error("Error renaming project:",We)}finally{y(null),E("")}},[k]),ut=h.useCallback((Oe,We,yt,tt="claude")=>{ve({projectName:Oe,sessionId:We,sessionTitle:yt,provider:tt})},[]),Sr=h.useCallback(async()=>{if(!fe)return;const{projectName:Oe,sessionId:We,provider:yt}=fe;ve(null);try{let tt;if(yt==="codex"?tt=await lt.deleteCodexSession(We):yt==="gemini"?tt=await lt.deleteGeminiSession(We):yt==="qwen"?tt=await lt.deleteQwenSession(We):tt=await lt.deleteSession(Oe,We),tt.ok)d?.(We);else{const Ve=await tt.text();console.error("[Sidebar] Failed to delete session:",{status:tt.status,error:Ve}),alert(i("messages.deleteSessionFailed"))}}catch(tt){console.error("[Sidebar] Error deleting session:",tt),alert(i("messages.deleteSessionError"))}},[d,fe,i]),Ee=h.useCallback(Oe=>{de({project:Oe,sessionCount:at(Oe).length})},[at]),Be=h.useCallback(async(Oe=!1)=>{if(!pe)return;const{project:We,sessionCount:yt}=pe,tt=yt===0;de(null),ae(Ve=>new Set([...Ve,We.name]));try{const Ve=await lt.deleteProject(We.name,!tt,Oe);if(Ve.ok)u?.(We.name);else{const Ne=await Ve.json();alert(Ne.error||i("messages.deleteProjectFailed"))}}catch(Ve){console.error("Error deleting project:",Ve),alert(i("messages.deleteProjectError"))}finally{ae(Ve=>{const Ne=new Set(Ve);return Ne.delete(We.name),Ne})}},[pe,u,i]),qe=h.useCallback(async Oe=>{const We=U[Oe.name];if(!(!(We!==void 0?We:Oe.sessionMeta?.hasMore===!0)||S[Oe.name])){j(tt=>({...tt,[Oe.name]:!0}));try{const tt=(Oe.sessions?.length||0)+(A[Oe.name]?.length||0),Ve=await lt.sessions(Oe.name,5,tt);if(!Ve.ok)return;const Ne=await Ve.json();_(Ue=>({...Ue,[Oe.name]:[...Ue[Oe.name]||[],...Ne.sessions||[]]})),Ne.hasMore===!1&&G(Ue=>({...Ue,[Oe.name]:!1}))}catch(tt){console.error("Error loading more sessions:",tt)}finally{j(tt=>({...tt,[Oe.name]:!1}))}}},[A,S,U]),xt=h.useCallback(Oe=>{l(Oe),p(Oe)},[l,p]),_t=h.useCallback(async()=>{F(!0);try{await o()}finally{F(!1)}},[o]),mt=h.useCallback(async(Oe,We,yt,tt)=>{const Ve=yt.trim();if(!Ve){q(null),z("");return}try{const Ne=await lt.renameSession(We,Ve,tt);Ne.ok?await o():(console.error("[Sidebar] Failed to rename session:",Ne.status),alert(i("messages.renameSessionFailed")))}catch(Ne){console.error("[Sidebar] Error renaming session:",Ne),alert(i("messages.renameSessionError"))}finally{q(null),z("")}},[o,i]),fn=h.useCallback(()=>{f(!1)},[f]),Qr=h.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:De,expandedProjects:g,editingProject:x,showNewProject:v,editingName:k,loadingSessions:S,additionalSessions:A,initialSessionsLoaded:N,currentTime:T,projectSortOrder:C,isRefreshing:H,editingSession:O,editingSessionName:$,searchFilter:ne,deletingProjects:ge,deleteConfirmation:pe,sessionDeleteConfirmation:fe,showVersionModal:Se,starredProjects:M,starredSessions:le,filteredProjects:Pe,toggleProject:Ke,handleSessionClick:Ze,toggleStarProject:Nt,isProjectStarred:et,toggleStarSession:Et,isSessionStarred:wt,getProjectSessions:at,startEditing:Xe,cancelEditing:st,saveProjectName:kt,showDeleteSessionConfirmation:ut,confirmDeleteSession:Sr,requestProjectDelete:Ee,confirmDeleteProject:Be,loadMoreSessions:qe,handleProjectSelect:xt,refreshProjects:_t,updateSessionSummary:mt,collapseSidebar:fn,expandSidebar:Qr,setShowNewProject:w,setEditingName:E,setEditingSession:q,setEditingSessionName:z,searchMode:W,setSearchMode:ee,conversationResults:be,isSearching:oe,searchProgress:X,clearConversationResults:h.useCallback(()=>{ce.current+=1,ye.current&&(ye.current.close(),ye.current=null),ke(!1),re(null),xe(null)},[]),setSearchFilter:Q,setDeleteConfirmation:de,setSessionDeleteConfirmation:ve,setShowVersionModal:ze}}const GL="https://discord.gg/buxwujPNRE",HL="https://github.com/alicomert/pixcode/issues/new";function qL({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 VL({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){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":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(Z9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),s.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.settings"),title:a("actions.settings"),children:s.jsx(Lt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:HL,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":a("actions.reportIssue"),title:a("actions.reportIssue"),children:s.jsx(al,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:GL,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":a("actions.joinCommunity"),title:a("actions.joinCommunity"),children:s.jsx(qL,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&s.jsxs("button",{onClick:n,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(ka,{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 NE(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=NE(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function TE(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=NE(e))&&(n&&(n+=" "),n+=t);return n}const Kv=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yv=TE,w0=(e,t)=>r=>{var n;if(t?.variants==null)return Yv(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=Kv(u)||Kv(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,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,f]:d},[]);return Yv(e,o,c,r?.class,r?.className)},k0="-",WL=e=>{const t=YL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(k0);return l[0]===""&&l.length!==1&&l.shift(),AE(l,t)||KL(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},AE=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?AE(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(k0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Zv=/^\[(.+)\]$/,KL=e=>{if(Zv.test(e)){const t=Zv.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},YL=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)zm(r[a],n,a,t);return n},zm=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Xv(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(ZL(a)){zm(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{zm(o,Xv(t,i),r,n)})})},Xv=(e,t)=>{let r=e;return t.split(k0).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},ZL=e=>e.isThemeGetter,XL=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)}}},Bm="!",$m=":",JL=$m.length,QL=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===$m){i.push(a.slice(c,g)),c=g+JL;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=eO(u),f=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+$m,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},eO=e=>e.endsWith(Bm)?e.substring(0,e.length-1):e.startsWith(Bm)?e.substring(1):e,tO=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}},rO=e=>({cache:XL(e.cacheSize),parseClassName:QL(e),sortModifiers:tO(e),...WL(e)}),nO=/\s+/,aO=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(nO);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:m,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=m?v+Bm:v,k=w+y;if(o.includes(k))continue;o.push(k);const E=a(y,x);for(let S=0;S<E.length;++S){const j=E[S];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function iO(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=_E(t))&&(n&&(n+=" "),n+=r);return n}const _E=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=_E(e[n]))&&(r&&(r+=" "),r+=t);return r};function sO(e,...t){let r,n,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=rO(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=aO(c,r);return a(c,u),u}return function(){return i(iO.apply(null,arguments))}}const dr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},jE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,IE=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oO=/^\d+\/\d+$/,lO=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cO=/\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$/,dO=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,uO=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pO=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ss=e=>oO.test(e),pt=e=>!!e&&!Number.isNaN(Number(e)),Fa=e=>!!e&&Number.isInteger(Number(e)),Iu=e=>e.endsWith("%")&&pt(e.slice(0,-1)),ca=e=>lO.test(e),mO=()=>!0,hO=e=>cO.test(e)&&!dO.test(e),RE=()=>!1,fO=e=>uO.test(e),gO=e=>pO.test(e),bO=e=>!Ge(e)&&!He(e),xO=e=>Zs(e,OE,RE),Ge=e=>jE.test(e),xi=e=>Zs(e,ME,hO),Ru=e=>Zs(e,SO,pt),Jv=e=>Zs(e,DE,RE),yO=e=>Zs(e,LE,gO),Kl=e=>Zs(e,PE,fO),He=e=>IE.test(e),xo=e=>Xs(e,ME),vO=e=>Xs(e,EO),Qv=e=>Xs(e,DE),wO=e=>Xs(e,OE),kO=e=>Xs(e,LE),Yl=e=>Xs(e,PE,!0),Zs=(e,t,r)=>{const n=jE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Xs=(e,t,r=!1)=>{const n=IE.exec(e);return n?n[1]?t(n[1]):r:!1},DE=e=>e==="position"||e==="percentage",LE=e=>e==="image"||e==="url",OE=e=>e==="length"||e==="size"||e==="bg-size",ME=e=>e==="length",SO=e=>e==="number",EO=e=>e==="family-name",PE=e=>e==="shadow",CO=()=>{const e=dr("color"),t=dr("font"),r=dr("text"),n=dr("font-weight"),a=dr("tracking"),i=dr("leading"),o=dr("breakpoint"),l=dr("container"),c=dr("spacing"),d=dr("radius"),u=dr("shadow"),p=dr("inset-shadow"),f=dr("text-shadow"),m=dr("drop-shadow"),g=dr("blur"),b=dr("perspective"),x=dr("aspect"),y=dr("ease"),v=dr("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"],E=()=>[...k(),He,Ge],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],A=()=>[He,Ge,c],_=()=>[ss,"full","auto",...A()],N=()=>[Fa,"none","subgrid",He,Ge],D=()=>["auto",{span:["full",Fa,He,Ge]},Fa,He,Ge],T=()=>[Fa,"auto",He,Ge],R=()=>["auto","min","max","fr",He,Ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...A()],F=()=>[ss,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],U=()=>[e,He,Ge],G=()=>[...k(),Qv,Jv,{position:[He,Ge]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",wO,xO,{size:[He,Ge]}],$=()=>[Iu,xo,xi],z=()=>["","none","full",d,He,Ge],ne=()=>["",pt,xo,xi],Q=()=>["solid","dashed","dotted","double"],ge=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[pt,Iu,Qv,Jv],pe=()=>["","none",g,He,Ge],de=()=>["none",pt,He,Ge],fe=()=>["none",pt,He,Ge],ve=()=>[pt,He,Ge],Se=()=>[ss,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ca],breakpoint:[ca],color:[mO],container:[ca],"drop-shadow":[ca],ease:["in","out","in-out"],font:[bO],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ca],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ca],shadow:[ca],spacing:["px",pt],text:[ca],"text-shadow":[ca],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ss,Ge,He,x]}],container:["container"],columns:[{columns:[pt,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:E()}],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:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{start:_()}],end:[{end:_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[Fa,"auto",He,Ge]}],basis:[{basis:[ss,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pt,ss,"auto","initial","none",Ge]}],grow:[{grow:["",pt,He,Ge]}],shrink:[{shrink:["",pt,He,Ge]}],order:[{order:[Fa,"first","last","none",He,Ge]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:D()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",r,xo,xi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,He,Ru]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Iu,Ge]}],"font-family":[{font:[vO,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":[pt,"none",He,Ru]}],leading:[{leading:[i,...A()]}],"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:U()}],"text-color":[{text:U()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:[pt,"from-font","auto",He,xi]}],"text-decoration-color":[{decoration:U()}],"underline-offset":[{"underline-offset":[pt,"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:A()}],"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:G()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fa,He,Ge],radial:["",He,Ge],conic:[Fa,He,Ge]},kO,yO]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Q(),"hidden","none"]}],"divide-style":[{divide:[...Q(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...Q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pt,He,Ge]}],"outline-w":[{outline:["",pt,xo,xi]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",u,Yl,Kl]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",p,Yl,Kl]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[pt,xi]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",f,Yl,Kl]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[pt,He,Ge]}],"mix-blend":[{"mix-blend":[...ge(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ge()}],"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":[pt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"mask-image-radial":[{"mask-radial":[He,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":[pt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ge]}],filter:[{filter:["","none",He,Ge]}],blur:[{blur:pe()}],brightness:[{brightness:[pt,He,Ge]}],contrast:[{contrast:[pt,He,Ge]}],"drop-shadow":[{"drop-shadow":["","none",m,Yl,Kl]}],"drop-shadow-color":[{"drop-shadow":U()}],grayscale:[{grayscale:["",pt,He,Ge]}],"hue-rotate":[{"hue-rotate":[pt,He,Ge]}],invert:[{invert:["",pt,He,Ge]}],saturate:[{saturate:[pt,He,Ge]}],sepia:[{sepia:["",pt,He,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ge]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[pt,He,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[pt,He,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pt,He,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pt,He,Ge]}],"backdrop-invert":[{"backdrop-invert":["",pt,He,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[pt,He,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[pt,He,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",pt,He,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"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:[pt,"initial",He,Ge]}],ease:[{ease:["linear","initial",y,He,Ge]}],delay:[{delay:[pt,He,Ge]}],animate:[{animate:["none",v,He,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,He,Ge]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:de()}],"rotate-x":[{"rotate-x":de()}],"rotate-y":[{"rotate-y":de()}],"rotate-z":[{"rotate-z":de()}],scale:[{scale:fe()}],"scale-x":[{"scale-x":fe()}],"scale-y":[{"scale-y":fe()}],"scale-z":[{"scale-z":fe()}],"scale-3d":["scale-3d"],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[He,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"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":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"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",...U()]}],"stroke-w":[{stroke:[pt,xo,xi,Ru]}],stroke:[{stroke:["none",...U()]}],"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"]}},NO=sO(CO);function me(...e){return NO(TE(e))}function TO(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const AO=w0("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"}}),FE=h.forwardRef(({className:e,variant:t,...r},n)=>s.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:me(AO({variant:t}),e),...r}));FE.displayName="Alert";const _O=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-title",className:me("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));_O.displayName="AlertTitle";const jO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-description",className:me("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));jO.displayName="AlertDescription";const IO=w0("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 or({className:e,variant:t,...r}){return s.jsx("div",{className:me(IO({variant:t}),e),...r})}const RO=w0("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"}}),je=h.forwardRef(({className:e,variant:t,size:r,...n},a)=>s.jsx("button",{className:me(RO({variant:t,size:r,className:e})),ref:a,...n}));je.displayName="Button";const zE=h.createContext(null),BE=()=>{const e=h.useContext(zE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},$E=({className:e,approval:t="pending",children:r,...n})=>{const a=h.useMemo(()=>({approval:t}),[t]);return s.jsx(zE.Provider,{value:a,children:s.jsx(FE,{className:me("flex flex-col gap-2",e),...n,children:r})})};$E.displayName="Confirmation";const UE=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:me("text-muted-foreground inline text-sm",e),...t});UE.displayName="ConfirmationTitle";const GE=({children:e})=>{const{approval:t}=BE();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};GE.displayName="ConfirmationRequest";const HE=({className:e,...t})=>{const{approval:r}=BE();return r!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:me("flex items-center justify-end gap-2 self-end",e),...t})};HE.displayName="ConfirmationActions";const Ac=({variant:e="default",...t})=>s.jsx(je,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Ac.displayName="ConfirmationAction";const qE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));qE.displayName="Card";const VE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("flex flex-col space-y-1.5 p-4",e),...t}));VE.displayName="CardHeader";const WE=h.forwardRef(({className:e,...t},r)=>s.jsx("h3",{ref:r,className:me("font-semibold leading-none tracking-tight",e),...t}));WE.displayName="CardTitle";const DO=h.forwardRef(({className:e,...t},r)=>s.jsx("p",{ref:r,className:me("text-sm text-muted-foreground",e),...t}));DO.displayName="CardDescription";const KE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("p-4 pt-0",e),...t}));KE.displayName="CardContent";const YE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("flex items-center p-4 pt-0",e),...t}));YE.displayName="CardFooter";const LO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("ml-auto shrink-0",e),...t}));LO.displayName="CardAction";const ZE=h.createContext(null);function XE(){const e=h.useContext(ZE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const ni=h.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...i},o)=>{const[l,c]=h.useState(e),d=t!==void 0,u=d?t:l,p=h.useCallback(m=>{d||c(m),r?.(m)},[d,r]),f=h.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(ZE.Provider,{value:f,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...i,children:a})})});ni.displayName="Collapsible";const Sa=h.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:i,onOpenChange:o}=XE(),l=h.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})});Sa.displayName="CollapsibleTrigger";const ai=h.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=XE();return s.jsx("div",{ref:n,"data-state":a?"open":"closed",className:me("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})})});ai.displayName="CollapsibleContent";const JE=h.createContext(null);function S0(){const e=h.useContext(JE);if(!e)throw new Error("Command components must be used within <Command>");return e}const QE=h.forwardRef(({className:e,children:t,...r},n)=>{const[a,i]=h.useState(""),o=h.useRef(new Map),[l,c]=h.useState(0),d=h.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=h.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=h.useCallback((v,w)=>{const k=o.current.get(v);k&&Object.assign(k,w)},[]),f=h.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[k,E]of o.current)(!v||E.value.includes(v))&&w.add(k);return w},[a,l]),m=h.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=h.useState(null);h.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=h.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=m;if(w.length===0)return;if(v.key==="Enter"){w.find(_=>_.id===g)?.onSelect();return}const k=w.findIndex(A=>A.id===g);let E;v.key==="ArrowDown"?E=k<w.length-1?k+1:0:E=k>0?k-1:w.length-1;const S=w[E].id;b(S),w[E].element?.scrollIntoView({block:"nearest"})},[m,g]),y=h.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(JE.Provider,{value:y,children:s.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:me("flex flex-col",e),onKeyDown:x,...r,children:t})})});QE.displayName="Command";const e3=h.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:i}=S0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(wa,{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:me("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})]})});e3.displayName="CommandInput";const t3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,role:"listbox",className:me("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));t3.displayName="CommandList";const r3=h.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=S0();return!n||a.size>0?null:s.jsx("div",{ref:r,className:me("py-6 text-center text-sm text-muted-foreground",e),...t})});r3.displayName="CommandEmpty";const n3=h.forwardRef(({className:e,heading:t,children:r,...n},a)=>s.jsxs("div",{ref:a,className:me("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]}));n3.displayName="CommandGroup";const a3=h.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}=S0(),m=h.useId(),g=h.useRef(null),b=t||(typeof a=="string"?a:"");h.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,p]),h.useEffect(()=>{f(m,{onSelect:r||(()=>{})})},[m,r,f]);const x=h.useCallback(v=>{g.current=v,f(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,f,o]);if(!l.has(m))return null;const y=c===m;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:me("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!==m&&d(m)},onClick:()=>!n&&r?.(),...i,children:a})});a3.displayName="CommandItem";const OO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("-mx-1 h-px bg-border",e),...t}));OO.displayName="CommandSeparator";function Um({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=Ra(),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:me("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:me("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(p0,{className:"h-3 w-3 text-primary"}):s.jsx(h0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const i3=h.createContext(null);function s3(){const e=h.useContext(i3);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const o3=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,i]=h.useState(r),o=h.useRef(null),l=e!==void 0,c=l?e:a,d=h.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=h.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(i3.Provider,{value:u,children:n})},MO=h.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:i,triggerRef:o}=s3(),l=h.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(r&&h.isValidElement(t)){const c=t;return h.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})});MO.displayName="DialogTrigger";const ew='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',E0=h.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=s3(),d=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),h.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),r?.(),l(!1);return}if(m.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(ew));if(g.length===0)return;const b=g[0],x=g[g.length-1];m.shiftKey&&document.activeElement===b?(m.preventDefault(),x.focus()):!m.shiftKey&&document.activeElement===x&&(m.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]),h.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(ew)?.focus()})},[o]),o?_d.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:me("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});E0.displayName="DialogContent";const C0=h.forwardRef(({className:e,...t},r)=>s.jsx("h2",{ref:r,className:me("sr-only",e),...t}));C0.displayName="DialogTitle";const It=h.forwardRef(({className:e,type:t,...r},n)=>s.jsx("input",{type:t,className:me("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}));It.displayName="Input";const N0=h.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>s.jsx("div",{className:me("relative overflow-hidden",e),...n,children:s.jsx("div",{ref:a,className:me("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));N0.displayName="ScrollArea";const Xc=h.memo(({children:e,className:t,as:r="span"})=>s.jsx(r,{className:me("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}));Xc.displayName="Shimmer";const l3=h.createContext(null),PO=()=>{const e=h.useContext(l3);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},FO=1e3,zO=1e3,Gm=h.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]=h.useState(c),f=r!==void 0,m=f?r:u,g=h.useCallback(S=>{f||p(S),a?.(S)},[f,a]),[b,x]=h.useState(i),y=h.useRef(t),[v,w]=h.useState(!1),k=h.useRef(null);h.useEffect(()=>{i!==void 0&&x(i)},[i]),h.useEffect(()=>{t?(y.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/zO)),k.current=null)},[t]),h.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),h.useEffect(()=>{if(y.current&&!t&&m&&!v){const S=setTimeout(()=>{g(!1),w(!0)},FO);return()=>clearTimeout(S)}},[t,m,g,v]);const E=h.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return s.jsx(l3.Provider,{value:E,children:s.jsx(ni,{open:m,onOpenChange:g,className:me("not-prose",e),...l,children:o})})});Gm.displayName="Reasoning";const BO=(e,t)=>e||t===0?s.jsx(Xc,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Hm=h.memo(({className:e,children:t,getThinkingMessage:r=BO,...n})=>{const{isStreaming:a,isOpen:i,duration:o}=PO();return s.jsx(Sa,{className:me("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(wD,{className:"h-4 w-4"}),r(a,o),s.jsx($4,{className:me("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Hm.displayName="ReasoningTrigger";const qm=h.memo(({className:e,children:t,...r})=>s.jsx(ai,{className:me("mt-4 text-sm text-muted-foreground",e),...r,children:t}));qm.displayName="ReasoningContent";function $O(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 Vn({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[i,o]=h.useState(!1),l=h.useRef(null),c=h.useRef(!1),d=h.useRef(null),u=h.useRef(null),[p,f]=h.useState(null),m=h.useCallback(()=>{const w=d.current;if(!w)return;const k=w.getBoundingClientRect(),E=8,S={position:"fixed",zIndex:9999};switch(r){case"bottom":S.left=k.left+k.width/2,S.top=k.bottom+E,S.transform="translateX(-50%)";break;case"left":S.left=k.left-E,S.top=k.top+k.height/2,S.transform="translate(-100%, -50%)";break;case"right":S.left=k.right+E,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-E,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 h.useEffect(()=>()=>{g()},[]),h.useEffect(()=>{if(!i||typeof document>"u")return;const w=k=>{const E=k.target;E instanceof Node&&d.current?.contains(E)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),h.useEffect(()=>{if(!i){f(null);return}const w=window.requestAnimationFrame(m),k=()=>m();return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[i,m]),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"&&_d.createPortal(s.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:me("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:me("absolute w-0 h-0 border-4 border-transparent",$O(r))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const c3=h.createContext(null),d3=h.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const i=h.useMemo(()=>({status:t}),[t]);return s.jsx(c3.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:me("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})})});d3.displayName="PromptInput";const u3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:me("px-3 pt-3",e),...t}));u3.displayName="PromptInputHeader";const p3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:me("relative",e),...t}));p3.displayName="PromptInputBody";const m3=h.forwardRef(({className:e,...t},r)=>s.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:me("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}));m3.displayName="PromptInputTextarea";const h3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:me("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));h3.displayName="PromptInputFooter";const f3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:me("flex items-center gap-1",e),...t}));f3.displayName="PromptInputTools";const _c=h.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const i=s.jsx(je,{ref:a,type:"button",variant:"ghost",size:"icon",className:me("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?s.jsx(Vn,{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});_c.displayName="PromptInputButton";const g3=h.forwardRef(({className:e,status:t,children:r,...n},a)=>{const i=h.useContext(c3),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(je,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:me("h-8 w-8 rounded-lg",e),...n,children:r??(l?s.jsx(l0,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(X9,{className:"h-4 w-4"}))})});g3.displayName="PromptInputSubmit";function T0({children:e,className:t}){return s.jsx("div",{className:me("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function A0({isActive:e,onClick:t,children:r,className:n}){return s.jsx("button",{onClick:t,className:me("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 b3=h.createContext(null);function x3(){const e=h.useContext(b3);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const y3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:me("space-y-0.5",e),...t}));y3.displayName="Queue";const v3=h.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const i=h.useMemo(()=>({status:e}),[e]);return s.jsx(b3.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:me("flex items-start gap-2 py-0.5",t),...n,children:r})})});v3.displayName="QueueItem";const w3=h.forwardRef(({className:e,...t},r)=>{const{status:n}=x3();return s.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:me("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})})]})});w3.displayName="QueueItemIndicator";const k3=h.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=x3();return s.jsx("div",{ref:n,"data-slot":"queue-item-content",className:me("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})});k3.displayName="QueueItemContent";const tw="https://github.com/alicomert/pixcode/issues/new",UO="https://github.com/alicomert/pixcode",rw="https://discord.gg/buxwujPNRE";function nw({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 GO({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onShowSettings:i,t:o}){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(Iv,{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:o("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(Iv,{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:o("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:tw,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(al,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:rw,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(nw,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),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:i,children:[s.jsx(Lt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:UO,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",o("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:tw,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(al,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:rw,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(nw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),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:i,children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Lt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const aw="PIXCODE_GITHUB_STARS",iw="PIXCODE_HIDE_GITHUB_STAR",HO=3600*1e3,qO=(e,t)=>{const[r,n]=h.useState(null),[a,i]=h.useState(()=>{try{return localStorage.getItem(iw)==="true"}catch{return!1}});h.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(aw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<HO){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(aw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=h.useCallback(()=>{i(!0);try{localStorage.setItem(iw,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},VO="https://github.com/alicomert/pixcode";function WO({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 KO(){const{formattedCount:e,isDismissed:t,dismiss:r}=qO("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:VO,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(WO,{className:"h-3.5 w-3.5"}),s.jsx(Ns,{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(bt,{className:"h-2.5 w-2.5"})})]})}function sw({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:me(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(nl,{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:me(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(rD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function YO({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:m,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(je,{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(Tt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(je,{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(Ut,{className:"h-4 w-4"})}),s.jsx(je,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:m,title:x("tooltips.hideSidebar"),children:s.jsx(Y9,{className:"h-4 w-4"})})]})]}),s.jsx(KO,{}),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(ka,{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(sw,{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:me("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(Ln,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:me("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(Qn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(wa,{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(It,{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(bt,{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(Tt,{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(ti,{className:"h-4 w-4"})})]})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(sw,{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:me("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(Ln,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:me("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(Qn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(wa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(It,{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(bt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const ZO=160,ow=180;function S3({actions:e,className:t,triggerLabel:r}){const[n,a]=h.useState(!1),[i,o]=h.useState(null),l=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-ZO;p<8&&(p=8);let f=u.bottom+4;f+ow>window.innerHeight&&(f=Math.max(8,u.top-4-ow)),o({top:f,left:p})},[n]),h.useEffect(()=>{if(!n)return;const u=m=>{const g=m.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=m=>{m.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:me("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(uD,{className:"h-3.5 w-3.5"})}),n&&i&&_d.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:me("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,m=e[p-1],g=p>0&&u.danger&&!m?.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:me("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 lw={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},XO={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},JO=e=>e==="fully-configured"?{icon:ya,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:Lt,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:ga,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:bt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function QO({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=JO(e),i=a.icon;return n?s.jsxs("div",{className:me("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:lw[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:me("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,XO[t],r),title:a.title,children:s.jsx(i,{className:me(lw[t],a.colorClassName)})})}const eM=(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 cw({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:i,className:o}){const l=d=>s.jsx(Ns,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:iD,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:vr,onClick:a,danger:!0}),s.jsx(S3,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const tM={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},dw={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 E3({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:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=PL(t,n,x),v=r?.id===t.id,w=a===t.id,k=t.__provider,E=tM[k]??k,S=dw[k]??dw.claude,j=LL(y.sessionName),A=()=>{m(e),g(t,e.name)},_=()=>{p(e.name,t.id,i,k)},N=()=>{b(e.name,t.id,y.sessionName,k)},D=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),R=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:me("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",S),children:[s.jsx(lr,{provider:k,className:"h-2.5 w-2.5"}),E]}),s.jsx("span",{className:"text-muted-foreground/80",children:eM(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(F=>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:[".",F]},F))]}),C=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:F=>c(F.target.value),onKeyDown:F=>{F.stopPropagation(),F.key==="Enter"?_():F.key==="Escape"&&u()},onClick:F=>F.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),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:F=>{F.stopPropagation(),_()},title:x("tooltips.save"),children:s.jsx(Qt,{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:F=>{F.stopPropagation(),u()},title:x("tooltips.cancel"),children:s.jsx(bt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),P=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:me("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:A,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:me("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(lr,{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})]}),R]}),s.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:s.jsx(cw,{isStarred:o,canDelete:!y.isCursorSession,onRename:D,onToggleStar:T,onDelete:N,t:x,className:"!opacity-100"})})]})})}),H=s.jsxs("div",{className:me("group/item relative hidden md:block"),children:[s.jsxs(je,{variant:"ghost",className:me("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:me("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(lr,{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})]}),R]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:s.jsx(cw,{isStarred:o,canDelete:!y.isCursorSession,onRename:D,onToggleStar:T,onDelete:N,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[P,H]})}const rM=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function nM(){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 aM({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:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:k,t:E}){const[S,j]=h.useState([]);if(h.useEffect(()=>{if(!t)return;let N=!1;const D=async()=>{const R=await we(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!R.ok)return;const C=await R.json();N||j((C.runs??[]).slice(0,5))};D();const T=window.setInterval(()=>{D()},15e3);return()=>{N=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const A=r.length>0,_=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(Ut,{className:"h-3 w-3"}),E("sessions.newSession")]})}),s.jsxs(je,{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(Ut,{className:"h-3 w-3"}),E("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(ea,{className:"h-3 w-3"}),E("orchestration.section")]}),S.map(N=>{const D=[...new Set(N.nodeRuns.map(T=>rM(T.adapterId)).filter(Boolean))];return s.jsx("button",{type:"button",onClick:()=>k?.(e,N.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(ea,{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:N.input||E("orchestration.fallbackTitle")}),s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[D.slice(0,4).map(T=>s.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:s.jsx(lr,{provider:T,className:"h-3 w-3"})},T)),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:E(`common:orchestration.status.${N.status}`,{defaultValue:N.status})})]})]})]})},N.id)})]}),a?!A&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:E("sessions.noSessions")})}):r.map(N=>s.jsx(E3,{project:e,session:N,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,N.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:E},N.id)):s.jsx(nM,{}),A&&_&&s.jsx(je,{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"}),E("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Mr,{className:"h-3 w-3"}),E("sessions.showMore")]})})]})}const iM=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function sM({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:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:k,onToggleStarSession:E,onStartEditingProject:S,onCancelEditingProject:j,onSaveProjectName:A,onDeleteProject:_,onSessionSelect:N,onDeleteSession:D,onLoadMoreSessions:T,onNewSession:R,onOpenOrchestration:C,onEditingSessionNameChange:P,onStartEditingSession:H,onCancelEditingSession:F,onSaveEditingSession:U,t:G}){const O=t?.name===e.name,q=o===e.name,$=e.sessionMeta?.hasMore===!0,z=iM(c,$),ne=`${z} session${c.length===1?"":"s"}`,Q=BL(e,b),ge=()=>v(e.name),ae=()=>k(e.name),pe=()=>{A(e.name)},de=()=>{t?.name!==e.name&&w(e),ge()};return s.jsxs("div",{className:me("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:me("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",O&&"bg-primary/5 border-primary/20",i&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ge,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:me("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?s.jsx(va,{className:"h-4 w-4 text-primary"}):s.jsx(Ln,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:q?s.jsx("input",{type:"text",value:l,onChange:fe=>y(fe.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:G("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:fe=>fe.stopPropagation(),onKeyDown:fe=>{fe.key==="Enter"&&pe(),fe.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(QO,{status:Q,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:ne})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:q?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:fe=>{fe.stopPropagation(),pe()},children:s.jsx(Qt,{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:fe=>{fe.stopPropagation(),j()},children:s.jsx(bt,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:me("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:fe=>{fe.stopPropagation(),ae()},title:G(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(Ns,{className:me("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:fe=>{fe.stopPropagation(),_(e)},children:s.jsx(vr,{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:fe=>{fe.stopPropagation(),S(e)},children:s.jsx(Tm,{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(Mr,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(En,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(je,{variant:"ghost",className:me("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",O&&"bg-accent text-accent-foreground",i&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:de,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?s.jsx(va,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Ln,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:q?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:fe=>y(fe.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:G("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:fe=>{fe.key==="Enter"&&pe(),fe.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:[z,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:q?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:fe=>{fe.stopPropagation(),pe()},children:s.jsx(Qt,{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:fe=>{fe.stopPropagation(),j()},children:s.jsx(bt,{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:fe=>{fe.stopPropagation(),ae()},title:G("tooltips.removeFromFavorites"),children:s.jsx(Ns,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(S3,{triggerLabel:G("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:G("actions.rename"),icon:Tm,onClick:()=>S(e)},{id:"star",label:G(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Ns,onClick:ae},{id:"delete",label:G("actions.delete",{defaultValue:"Delete"}),icon:vr,onClick:()=>_(e),danger:!0}]}),n?s.jsx(Mr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(En,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(aM,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:P,onStartEditingSession:H,onCancelEditingSession:F,onSaveEditingSession:U,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:N,onDeleteSession:D,onLoadMoreSessions:T,onNewSession:R,onOpenOrchestration:C,t:G})]})}function C3({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(Ln,{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(wa,{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 oM({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:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:k,onToggleProject:E,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:A,onStartEditingProject:_,onCancelEditingProject:N,onSaveProjectName:D,onDeleteProject:T,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:P,onNewSession:H,onOpenOrchestration:F,onEditingSessionNameChange:U,onStartEditingSession:G,onCancelEditingSession:O,onSaveEditingSession:q,t:$}){const z=s.jsx(C3,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:$});h.useEffect(()=>{let de="Pixcode";const fe=r?.displayName?.trim();fe&&(de=`${fe} - ${de}`),document.title=de},[r]);const ne=!a&&e.length>0&&t.length>0,Q=de=>de.source==="history"||de.autoDiscovered===!0&&de.isManuallyAdded!==!0,ge=t.filter(de=>!Q(de)),ae=t.filter(de=>Q(de)),pe=de=>s.jsx(sM,{project:de,selectedProject:r,selectedSession:n,isExpanded:o.has(de.name),isDeleting:g.has(de.name),isStarred:v(de.name),editingProject:l,editingName:c,sessions:y(de),initialSessionsLoaded:u.has(de.name),isLoadingSessions:!!d[de.name],currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:k,onToggleProject:E,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:A,onStartEditingProject:_,onCancelEditingProject:N,onSaveProjectName:D,onDeleteProject:T,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:P,onNewSession:H,onOpenOrchestration:F,onEditingSessionNameChange:U,onStartEditingSession:G,onCancelEditingSession:O,onSaveEditingSession:q,t:$},de.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ne?s.jsxs(s.Fragment,{children:[ge.map(de=>pe(de)),ae.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:$("projects.detectedFromHistory")}),ae.map(de=>pe(de))]})]}):z})}function ua(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N3(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
229
+ */const U9=[["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"}]],G9=ft("workflow",U9),a0=F4,Y4=_I,Iv=CI,H9=PI,q9=gI,i0=wI,V9=P4,Mr=$4,W9=b7,s0=u7,En=m7,K9=f7,In=SI,Jn=P4,Wc=TI,Z4=yI,Y9=s7,Z9=l7,X4=II,Tt=z4,nr=z4,Rd=OI,J4=DI,X9=T8,ga=H7,Tr=V7,Qt=a7,ya=r7,Q4=p8,an=Z8,J9=H4,Q9=H4,Kc=YI,Dd=w7,eE=y7,Ld=U4,Go=N7,rl=M7,$t=F7,Ln=a8,va=e8,ti=r8,eD=L8,tD=d8,nl=b8,o0=H8,rD=zI,Od=XI,nD=uR,aD=n0,iD=n0,Tm=I8,sD=s8,oD=J7,lD=tR,cD=U8,dD=S8,tE=_8,Am=n0,rE=M8,Ut=F8,vr=mR,uD=B7,wa=w8,bt=q4,_m=q4,l0=iR,c0=qI,pD=GI,jm=$I,mD=U7,Qn=B4,hD=B4,fD=fR,nE=bR,al=QI,aE=E7,qi=Z7,d0=K7,ri=l8,iE=U4,u0=G4,gD=G4,sE=f8,bn=y8,p0=C8,oE=R7,lE=cR,bD=B8,m0=K8,xD=V8,Lt=A7,yD=pI,cE=L7,ka=Q8,Ns=nR,h0=oR,Br=j7,f0=WI,vD=TR,El=DR,g0=W4,wD=W4,Zr=g9,Im=x9,kD=v9,ns=CR,as=_R,SD=IR,_o=OR,Ts=PR,Rv=UR,jo=HR,po=KR,ED=ZR,dE=l9,Rm=JR,mo=r9,ho=e9,Dv=a9,fo=s9,Dm=d9,CD=p9,Lm=h9,vs=E9,Io=N9,Pa=A9,is=j9,ND=R9,Om=L9,TD=P9,go=$9,ea=G9,il=BR,uE=VR,AD=k9,_D=z9,jD=[{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"}],ID={up:Y4,down:a0,left:q9,right:i0},bo=e=>e.preventDefault(),Lv="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",RD="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",Tu="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 Ov({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Re("settings"),[i,o]=h.useState(!1),[l,c]=h.useState(!1),d=h.useCallback(m=>{Ri(e.current,{type:"input",data:m})},[e]),u=h.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=h.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&d(m)}catch{}},[d]),f=h.useCallback(m=>{let g=m;if(i&&m.length===1){const b=m.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&m.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:bo,onClick:()=>{p()},disabled:!r,className:Tu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(Dd,{className:"h-4 w-4"})}),jD.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?i:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:bo,onClick:b,disabled:!r,className:g?RD:Lv,children:m.label},m.id)}if(m.type==="arrow"){const g=ID[m.icon];return s.jsx("button",{type:"button",onPointerDown:bo,onClick:()=>d(m.sequence),disabled:!r,className:Tu,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:bo,onClick:()=>f(m.sequence),disabled:!r,className:Lv,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:bo,onClick:u,disabled:!r,className:Tu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(V9,{className:"h-4 w-4"})})]})})}function pE({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}=Re("chat"),[d,u]=h.useState(!1),[p,f]=h.useState(null),m=h.useRef(null),g=h.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:k,authUrl:E,authUrlVersion:S,connectToShell:j,disconnectFromShell:A,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:N}=sI({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),D=h.useCallback(()=>{const $=x.current;if(!$)return;const z=$.buffer.active,ne=z.baseY+z.cursorY,Q=Math.min(z.baseY+z.length-1,ne+10),ge=Math.max(0,ne-zj),ae=[];for(let Se=ge;Se<=Q;Se++){const ze=z.getLine(Se);ze&&ae.push(ze.translateToString().trimEnd())}let pe=-1;for(let Se=ae.length-1;Se>=0;Se--)if(/esc to cancel/i.test(ae[Se])||/enter to select/i.test(ae[Se])){pe=Se;break}if(pe===-1){f(null);return}const de=new Map,fe=Math.max(0,pe-Bj);for(let Se=pe-1;Se>=fe;Se--){const ze=ae[Se].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(ze){const M=ze[1],ue=ze[2].trim();parseInt(M,10)<=$j&&ue.length>0&&!de.has(M)&&de.set(M,ue)}}const ve=[];for(let Se=1;Se<=de.size&&de.has(String(Se));Se++)ve.push({number:String(Se),label:de.get(String(Se))});f(ve.length>=Uj?ve:null)},[x]),T=h.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(D,Fj)},[D]);h.useEffect(()=>{g.current=T},[T]),h.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),f(null))},[v]),h.useEffect(()=>{if(!l||!w||!v)return;const $=()=>{x.current?.focus()},z=window.requestAnimationFrame($),ne=window.setTimeout($,0);return()=>{window.cancelAnimationFrame(z),window.clearTimeout(ne)}},[l,v,w,x]);const R=h.useCallback($=>{Ri(y.current,{type:"input",data:$})},[y]),C=h.useMemo(()=>rI(t),[t]),P=h.useMemo(()=>C?C.slice(0,30):null,[C]),H=h.useMemo(()=>C?C.slice(0,50):null,[C]),F=h.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},Mj)},[]);if(!e)return s.jsx(lI,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(dI,{terminalContainerRef:b,authUrl:E,authUrlVersion:S,initialCommand:r,isConnected:v,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:N}),s.jsx(Ov,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const U=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:H}):c("shell.startSession"),G=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?k?"connecting":v?null:"connect":"loading",q=O==="connecting"?G:U;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(cI,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:P,onDisconnect:A,onRestart:F,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"}}),O&&s.jsx(oI,{mode:O,description:q,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:$=>$.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map($=>s.jsxs("button",{type:"button",onClick:()=>{R($.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:`${$.number}. ${$.label}`,children:[$.number,". ",$.label]},$.number)),s.jsx("button",{type:"button",onClick:()=>{R("\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(Ov,{wsRef:y,terminalRef:x,isConnected:v})]})}function DD({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 LD({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 mE({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[m,g]=h.useState(!1),b=n!==null?n:r!==null,x=h.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(LD,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(pE,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:i})})]}):s.jsx(DD,{className:d})}const OD=(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"),MD={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 Mv({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 PD({provider:e}){const[t,r]=h.useState(""),[n,a]=h.useState(!1),[i,o]=h.useState("idle"),[l,c]=h.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await we(`/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(nr,{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(Qt,{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 FD({provider:e,onSaved:t}){const r=MD[e],[n,a]=h.useState(""),[i,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState("idle"),[p,f]=h.useState(null);h.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await we("/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 m=async()=>{const g=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await we(`/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(gD,{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(In,{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 m(),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(nr,{className:"h-4 w-4 animate-spin"}):s.jsx(Qt,{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 hE({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:i=!1}){const{t:o}=Re("common"),l=r!=="cursor",[c,d]=h.useState(l?"apiKey":"browser");h.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=h.useMemo(()=>`${tl[r]??r} Login`,[r]);if(!e)return null;const p=OD(r,a),f=m=>n?.(m);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(bt,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(Mv,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(Mv,{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(mE,{project:wj,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(PD,{provider:r})})]}):s.jsx(FD,{provider:r,onSaved:()=>f(0)})})]})})}const zD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),BD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},$D=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},UD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),GD=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ra(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:r,alt:"OpenCode",className:e})},HD=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function lr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx($D,{className:t}):e==="codex"?s.jsx(BD,{className:t}):e==="gemini"?s.jsx(UD,{className:t}):e==="qwen"?s.jsx(HD,{className:t}):e==="opencode"?s.jsx(GD,{className:t}):s.jsx(zD,{className:t})}function qD({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(lr,{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(Qt,{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 VD=[{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 WD({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:VD.map(r=>s.jsx(qD,{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 KD({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(Zr,{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(fD,{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(mD,{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 Pv=[{title:"Git Configuration",icon:Zr,required:!0},{title:"Connect Agents",icon:Z4,required:!1},{title:"Task System",icon:o0,required:!1}];function YD({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:Pv.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(Qt,{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<Pv.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 ZD=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 XD({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=h.useState(null),[i,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState([]),[p,f]=h.useState(""),m=h.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=h.useMemo(()=>!e||g,[e,g]);h.useEffect(()=>{r(x)},[r,x]);const y=h.useCallback(async()=>{o(!0),f("");try{const w=await we("/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)}},[]);h.useEffect(()=>(y(),()=>{m.current?.close(),m.current=null}),[y]);const v=h.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await we("/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 E=localStorage.getItem(Id),S=E?`?token=${encodeURIComponent(E)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(k.jobId)}/stream${S}`);m.current=j,j.addEventListener("log",A=>{const _=JSON.parse(A.data);u(N=>[...N,_].slice(-80))}),j.addEventListener("done",A=>{const _=JSON.parse(A.data);if(j.close(),m.current=null,c(!1),!_.success){f(_.error||_.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),m.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(ya,{className:"h-5 w-5 text-green-600"}):s.jsx(Br,{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:ZD(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(nr,{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 Fv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,zv=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function JD({onComplete:e}){const[t,r]=h.useState(0),[n,a]=h.useState(""),[i,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState(""),[p,f]=h.useState(null),[m,g]=h.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=h.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=r0(),k=h.useRef(void 0),E=h.useCallback(async()=>{try{const T=await we("/api/user/git-config");if(!T.ok)return;const R=await T.json();R.gitName&&a(R.gitName),R.gitEmail&&o(R.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);h.useEffect(()=>{E(),w()},[E,w]),h.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)},A=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(!Fv.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await we("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:i})});if(!T.ok){const R=await zv(T,"Failed to save git configuration");throw new Error(R)}r(R=>R+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},_=()=>{u(""),r(T=>T-1)},N=async()=>{if(m&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(m));const T=await we("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const R=await zv(T,"Failed to complete onboarding");throw new Error(R)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},D=t===0?!!(n.trim()&&i.trim()&&Fv.test(i)):t===2?!m||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(YD,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(KD,{gitName:n,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?s.jsx(WD,{providerStatuses:y,onOpenProviderLogin:S}):s.jsx(XD,{enabled:m,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:_,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(s0,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<2?s.jsx("button",{onClick:A,disabled:!D||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(nr,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(En,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:N,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(nr,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Qt,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(hE,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const QD=["0s","0.1s","0.2s"];function eL(){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(Qn,{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:QD.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 fE({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 Ti({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 gE({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(Qn,{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 tL={username:"",password:""};function rL(){const{t:e}=Re("auth"),{login:t}=Hi(),[r,n]=h.useState(tL),[a,i]=h.useState(""),[o,l]=h.useState(!1),c=h.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=h.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(gE,{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(Ti,{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(Ti,{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(fE,{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 nL={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function aL(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 iL(){const{register:e}=Hi(),[t,r]=h.useState(nL),[n,a]=h.useState(""),[i,o]=h.useState(!1),l=h.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=h.useCallback(async d=>{d.preventDefault(),a("");const u=aL(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 m=await p.json().catch(()=>null);a(m?.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(gE,{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(Ti,{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(Ti,{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(Ti,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(Ti,{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(Ti,{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(fE,{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 sL({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=Hi();return r?s.jsx(eL,{}):n?s.jsx(iL,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(JD,{onComplete:i}):s.jsx(rL,{})}const bE=h.createContext(null),xE=()=>{const e=h.useContext(bE);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},oL=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},lL=()=>{const e=h.useRef(null),t=h.useRef(!1),r=h.useRef(!1),[n,a]=h.useState(null),[i,o]=h.useState(!1),l=h.useRef(null),{token:c}=Hi(),d=h.useCallback(()=>{if(!t.current)try{const f=oL(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(f);m.onopen=()=>{o(!0),e.current=m,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.current=!0},m.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},m.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||d()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(f){console.error("Error creating WebSocket connection:",f)}},[c]);h.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=h.useCallback(f=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return h.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:i}),[u,n,i])},cL=({children:e})=>{const t=lL();return s.jsx(bE.Provider,{value:t,children:e})},yE=h.createContext(null);function dL(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Bv(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 uL(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function pL(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Ys(){const e=h.useContext(yE);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function mL({children:e}){const{latestMessage:t}=xE(),{user:r,token:n,isLoading:a}=Hi(),[i,o]=h.useState([]),[l,c]=h.useState(null),[d,u]=h.useState(null),[p,f]=h.useState(null),[m,g]=h.useState([]),[b,x]=h.useState(null),[y,v]=h.useState(!1),[w,k]=h.useState(!1),[E,S]=h.useState(!1),[j,A]=h.useState(null),_=h.useRef(null);h.useEffect(()=>{_.current=l?.name??null},[l?.name]);const N=h.useCallback(()=>{A(null)},[]),D=h.useCallback((F,U)=>{console.error(`TaskMaster ${F} error:`,U),A(dL(F,U))},[]),T=h.useCallback(F=>{const U=F?Bv(F):null;c(U),u(U?.taskmaster??null),g([]),x(null)},[]),R=h.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),N();const F=await lt.get("/projects");if(!F.ok)throw new Error(`Failed to fetch projects: ${F.status}`);const U=await F.json(),O=(Array.isArray(U)?U:[]).map(z=>Bv(z));o(O);const q=_.current;if(!q)return;const $=O.find(z=>z.name===q)??null;c($),u($?.taskmaster??null)}catch(F){D("load projects",F)}finally{v(!1)}},[N,D,n,r]),C=h.useCallback(async()=>{const F=l?.name;if(!F||!r||!n){g([]),x(null);return}try{k(!0),N();const U=await lt.get(`/taskmaster/tasks/${encodeURIComponent(F)}`);if(!U.ok){const q=await U.json();throw new Error(q.message??"Failed to load tasks")}const G=await U.json(),O=Array.isArray(G.tasks)?G.tasks:[];g(O),x(uL(O))}catch(U){D("load tasks",U),g([]),x(null)}finally{k(!1)}},[N,l?.name,D,n,r]),P=h.useCallback(async()=>{if(!r||!n){f(null);return}try{S(!0),N();const F=await lt.get("/mcp-utils/taskmaster-server");if(!F.ok)throw new Error(`Failed to load MCP status: ${F.status}`);const U=await F.json();f(U)}catch(F){D("check MCP server status",F),f(null)}finally{S(!1)}},[N,D,n,r]);h.useEffect(()=>{!a&&r&&n&&(R(),P())},[a,P,R,n,r]),h.useEffect(()=>{l?.name&&r&&n&&C()},[l?.name,C,n,r]),h.useEffect(()=>{const F=t;if(pL(F)){if(F.type==="taskmaster-project-updated"&&F.projectName){R();return}if(F.type==="taskmaster-tasks-updated"&&F.projectName===l?.name){C();return}F.type==="taskmaster-mcp-status-changed"&&P()}},[l?.name,t,P,R,C]);const H=h.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:j,refreshProjects:R,setCurrentProject:T,refreshTasks:C,refreshMCPStatus:P,clearError:N}),[N,l,j,y,E,w,p,b,d,i,P,R,C,T,m]);return s.jsx(yE.Provider,{value:H,children:e})}const vE=h.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Md=()=>{const e=h.useContext(vE);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},hL=({children:e})=>{const{user:t,token:r,isLoading:n}=Hi(),[a,i]=h.useState(()=>{const y=localStorage.getItem("tasks-enabled");return y!==null?JSON.parse(y):!0}),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,p]=h.useState(null),[f,m]=h.useState(!0),g=!!(t&&r);h.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]),h.useEffect(()=>{if(n)return;if(!g){p(null),l(null),d(null),m(!1);return}m(!0);let y=!1;const w=setTimeout(async()=>{try{const k=await lt.get("/taskmaster/installation-status");if(y)return;if(k.ok){const E=await k.json();if(y)return;p(E),l(E.installation?.isInstalled||!1),d(E.isReady||!1);const S=localStorage.getItem("tasks-enabled");!E.installation?.isInstalled&&!S&&i(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(k){if(y)return;console.error("Error checking TaskMaster installation:",k),l(!1),d(!1)}finally{y||m(!1)}},0);return()=>{y=!0,clearTimeout(w)}},[g,n]);const x={tasksEnabled:a,setTasksEnabled:i,toggleTasksEnabled:()=>{i(y=>!y)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f};return s.jsx(vE.Provider,{value:x,children:e})},wE=h.createContext(null);function Pd(){const e=h.useContext(wE);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function fL({children:e}){const{user:t,token:r,isLoading:n}=Hi(),[a,i]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(null),u=!!(t&&r),p=h.useCallback(async()=>{if(!u){i([]),d(null),l(!1);return}l(!0);try{const x=await we("/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]);h.useEffect(()=>{n||p()},[n,p]);const f=h.useCallback(async x=>{try{const y=await we("/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]),m=h.useCallback(async x=>{try{const y=await we(`/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=h.useCallback(async x=>{try{const y=await we(`/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=h.useCallback(async(x,y)=>{try{const v=await we(`/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(wE.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:m,updatePlugin:g,togglePlugin:b},children:e})}const $v=e=>typeof window>"u"?!1:window.innerWidth<e,Uv=()=>{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 b0(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,i]=h.useState(()=>r?$v(t):!1),[o,l]=h.useState(()=>n?Uv():!1);return h.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{i($v(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),h.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(Uv())};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 x0="pixcode.updateCheck.preferences",Mm="pixcode:update-check-settings-changed",y0=[{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}],Pm={frequency:"30m"};function Gv(e){return y0.find(t=>t.value===e.frequency)?.intervalMs??null}function kE(e){if(!e||typeof e!="object")return Pm;const t=e.frequency;return y0.some(r=>r.value===t)?{frequency:t}:Pm}function Hv(){try{const e=localStorage.getItem(x0);return kE(e?JSON.parse(e):null)}catch{return Pm}}function gL(e){const t=kE(e);localStorage.setItem(x0,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(Mm,{detail:t}))}const Au=(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},bL="1.38.2",Fm="pixcode:update-available",xL=360*60*1e3,_u=new Map;function SE(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function yL(e,t){try{const r=localStorage.getItem(SE(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 qv(e,t,r){localStorage.setItem(SE(e,t),JSON.stringify(r))}function vL(e,t){const r=`${e}/${t}`,n=_u.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(()=>{_u.delete(r)});return _u.set(r,a),a}const EE=(e,t)=>{const[r,n]=h.useState(!1),[a,i]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState("git"),[u,p]=h.useState("idle"),[f,m]=h.useState(null),[g,b]=h.useState(()=>Hv()),[x,y]=h.useState(bL),v=h.useRef(null),w=h.useCallback(E=>{gL(E),b(E)},[]);h.useEffect(()=>{const E=()=>b(Hv()),S=j=>{j.key===x0&&E()};return window.addEventListener("storage",S),window.addEventListener(Mm,E),()=>{window.removeEventListener("storage",S),window.removeEventListener(Mm,E)}},[]),h.useEffect(()=>{let E=!1;const S=async()=>{try{const _=await(await fetch("/health",{cache:"no-store"})).json();if(E)return;(_.installMode==="npm"||_.installMode==="git")&&d(_.installMode),typeof _.version=="string"&&/^\d+\.\d+\.\d+/.test(_.version)&&y(_.version)}catch{}};S();const j=()=>{S()};return window.addEventListener("focus",j),()=>{E=!0,window.removeEventListener("focus",j)}},[]),h.useEffect(()=>{if(!x)return;let E=!1;const S=(T,R,C,P)=>({updateAvailable:!!(T&&Au(T,x)>0),latestVersion:T,releaseInfo:R,currentVersion:x,checkedAt:C,status:P}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(Fm,{detail:T}))},A=(T,R,C,P="success")=>{if(!T||!R)return n(!1),i(null),l(null),m(C),S(null,null,C,P);i(T),n(Au(T,x)>0),l(R),m(C);const H=S(T,R,C,P);return j(H),H},_=async({force:T=!1}={})=>{const R=Gv(g),C=yL(e,t),P=Date.now();if(!T&&R===null)return p("idle"),A(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");if(!T&&C?.fetchedAt&&R!==null&&P-C.fetchedAt<R)return p("success"),A(C.latestVersion,C.releaseInfo,C.fetchedAt,"success");if(!T&&C?.rateLimitedUntil&&C.rateLimitedUntil>P)return p("error"),A(C.latestVersion,C.releaseInfo,C.fetchedAt,"error");try{p("checking");const H=await vL(e,t);if(E)return S(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"idle");const F=H.data;if(!H.ok)return H.status===403&&qv(e,t,{fetchedAt:C?.fetchedAt??null,latestVersion:C?.latestVersion??null,releaseInfo:C?.releaseInfo??null,rateLimitedUntil:P+Math.max(R??0,xL)}),p("error"),A(C?.latestVersion??null,C?.releaseInfo??null,C?.fetchedAt??null,"error");if(F.tag_name){const U=F.tag_name.replace(/^v/,""),G=Au(U,x)>0,O={title:F.name||F.tag_name,body:F.body||"",htmlUrl:F.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:F.published_at||""};qv(e,t,{fetchedAt:P,latestVersion:U,releaseInfo:O}),i(U),n(G),G&&_4({key:`app-update:${U}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${U}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:U,installMode:c}}),l(O),p("success"),m(P);const q=S(U,O,P,"success");return j(q),q}else return n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}catch(H){return console.error("Version check failed:",H),n(!1),i(null),l(null),p("error"),S(null,null,null,"error")}};v.current=_,_();const N=Gv(g),D=N===null?null:window.setInterval(()=>{_()},N);return()=>{E=!0,D!==null&&window.clearInterval(D)}},[e,t,x,c,g]);const k=h.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}},Ai={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},wL=["flat","grouped"],kL=e=>typeof e=="string"&&wL.includes(e),Yc=Object.keys(Ai),SL=new Set(Yc),ju="ui-preferences:sync",EL=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Zc=(e,t,r)=>e==="historyView"?kL(t)?t:r:EL(t,r),CL=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Zc(e,n,t)}catch{return t}},NL=e=>{if(typeof window>"u")return Ai;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 Yc.reduce((a,i)=>(a[i]=Zc(i,n[i],Ai[i]),a),{...Ai})}}}catch{}return Yc.reduce((t,r)=>(t[r]=CL(r,Ai[r]),t),{...Ai})};function TL(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!SL.has(r))return e;const a=Zc(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 Yc){if(!(i in r))continue;const o=r[i],l=Zc(i,o,e[i]);a[i]!==l&&(a[i]=l,n=!0)}return n?a:e}case"reset":return{...Ai,...t.value||{}};default:return e}}function v0(e="uiPreferences"){const t=h.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=h.useReducer(TL,e,NL);return h.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(ju,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),h.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(ju,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(ju,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 AL=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},_L=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},jL=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Vv=(e,t)=>`${e}::${t}`,IL=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},RL=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},DL=/(?:^|[\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,LL=e=>{if(!e)return[];const t=new Set,r=new RegExp(DL.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]},Li=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),OL=(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"),ML=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),PL=(e,t,r)=>{const n=Li(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:OL(e,r),sessionTime:ML(e),messageCount:Number(e.messageCount||0)}},CE=(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],m=new Map;for(const g of[...r,...n,...a,...c,...p,...f])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>Li(b).getTime()-Li(g).getTime())},Wv=(e,t)=>{const r=CE(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const i=Li(a);return i>n?i:n},new Date(0))},FL=(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"?Wv(o,n).getTime()-Wv(i,n).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},zL=(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},BL=(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"},$L=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 UL({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:m}){const[g,b]=h.useState(new Set),[x,y]=h.useState(null),[v,w]=h.useState(!1),[k,E]=h.useState(""),[S,j]=h.useState({}),[A,_]=h.useState({}),[N,D]=h.useState(new Set),[T,R]=h.useState(new Date),[C,P]=h.useState("name"),[H,F]=h.useState(!1),[U,G]=h.useState({}),[O,q]=h.useState(null),[$,z]=h.useState(""),[ne,Q]=h.useState(""),[ge,ae]=h.useState(new Set),[pe,de]=h.useState(null),[fe,ve]=h.useState(null),[Se,ze]=h.useState(!1),[M,ue]=h.useState(()=>_L()),[le,Y]=h.useState(()=>IL()),[W,ee]=h.useState("projects"),[be,xe]=h.useState(null),[oe,ke]=h.useState(!1),[X,re]=h.useState(null),Z=h.useRef(null),ce=h.useRef(0),ye=h.useRef(null),De=!a&&!m;h.useEffect(()=>{const Oe=setInterval(()=>{R(new Date)},6e4);return()=>clearInterval(Oe)},[]),h.useEffect(()=>{_({}),D(new Set),G({})},[e]),h.useEffect(()=>{t&&b(Oe=>{if(Oe.has(t.name))return Oe;const We=new Set(Oe);return We.add(t.name),We})},[r,t]),h.useEffect(()=>{if(e.length>0&&!n){const Oe=new Set;e.forEach(We=>{We.sessions&&We.sessions.length>=0&&Oe.add(We.name)}),D(Oe)}},[e,n]),h.useEffect(()=>{const Oe=()=>{P(AL())};Oe();const We=tt=>{tt.key==="claude-settings"&&Oe()},yt=()=>Oe();return window.addEventListener("storage",We),window.addEventListener("pixcode:settings-changed",yt),()=>{window.removeEventListener("storage",We),window.removeEventListener("pixcode:settings-changed",yt)}},[]),h.useEffect(()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null);const Oe=ne.trim();if(W!=="conversations"||Oe.length<2){ce.current+=1,xe(null),re(null),ke(!1);return}ke(!0);const We=++ce.current;return Z.current=setTimeout(()=>{if(We!==ce.current)return;const yt=lt.searchConversationsUrl(Oe),tt=new EventSource(yt);ye.current=tt;const Ve=[];let Ne=0;tt.addEventListener("result",Ue=>{if(We!==ce.current){tt.close();return}try{const Me=JSON.parse(Ue.data);Ve.push(Me.projectResult),Ne=Me.totalMatches,xe({results:[...Ve],totalMatches:Ne,query:Oe}),re({scannedProjects:Me.scannedProjects,totalProjects:Me.totalProjects})}catch{}}),tt.addEventListener("progress",Ue=>{if(We!==ce.current){tt.close();return}try{const Me=JSON.parse(Ue.data);Ne=Me.totalMatches,re({scannedProjects:Me.scannedProjects,totalProjects:Me.totalProjects})}catch{}}),tt.addEventListener("done",()=>{if(We!==ce.current){tt.close();return}tt.close(),ye.current=null,ke(!1),re(null),Ve.length===0&&xe({results:[],totalMatches:0,query:Oe})}),tt.addEventListener("error",()=>{if(We!==ce.current){tt.close();return}tt.close(),ye.current=null,ke(!1),re(null),Ve.length===0&&xe({results:[],totalMatches:0,query:Oe})})},400),()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null)}},[ne,W]);const Ke=h.useCallback(Oe=>{b(We=>{const yt=new Set;return We.has(Oe)||yt.add(Oe),yt})},[]),Ze=h.useCallback((Oe,We)=>{c({...Oe,__projectName:We})},[c]),Nt=h.useCallback(Oe=>{ue(We=>{const yt=new Set(We);return yt.has(Oe)?yt.delete(Oe):yt.add(Oe),jL(yt),yt})},[]),et=h.useCallback(Oe=>M.has(Oe),[M]),Et=h.useCallback((Oe,We)=>{Y(yt=>{const tt=Vv(Oe,We),Ve=new Set(yt);return Ve.has(tt)?Ve.delete(tt):Ve.add(tt),RL(Ve),Ve})},[]),wt=h.useCallback((Oe,We)=>le.has(Vv(Oe,We)),[le]),at=h.useCallback(Oe=>CE(Oe,A),[A]),se=h.useMemo(()=>e.map(Oe=>{const We=U[Oe.name];return We===void 0?Oe:{...Oe,sessionMeta:{...Oe.sessionMeta,hasMore:We}}}),[U,e]),Ie=h.useMemo(()=>FL(se,C,M,A),[A,C,se,M]),Pe=h.useMemo(()=>zL(Ie,ne),[ne,Ie]),Xe=h.useCallback(Oe=>{y(Oe.name),E(Oe.displayName)},[]),st=h.useCallback(()=>{y(null),E("")},[]),kt=h.useCallback(async Oe=>{try{(await lt.renameProject(Oe,k)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(We){console.error("Error renaming project:",We)}finally{y(null),E("")}},[k]),ut=h.useCallback((Oe,We,yt,tt="claude")=>{ve({projectName:Oe,sessionId:We,sessionTitle:yt,provider:tt})},[]),Sr=h.useCallback(async()=>{if(!fe)return;const{projectName:Oe,sessionId:We,provider:yt}=fe;ve(null);try{let tt;if(yt==="codex"?tt=await lt.deleteCodexSession(We):yt==="gemini"?tt=await lt.deleteGeminiSession(We):yt==="qwen"?tt=await lt.deleteQwenSession(We):tt=await lt.deleteSession(Oe,We),tt.ok)d?.(We);else{const Ve=await tt.text();console.error("[Sidebar] Failed to delete session:",{status:tt.status,error:Ve}),alert(i("messages.deleteSessionFailed"))}}catch(tt){console.error("[Sidebar] Error deleting session:",tt),alert(i("messages.deleteSessionError"))}},[d,fe,i]),Ee=h.useCallback(Oe=>{de({project:Oe,sessionCount:at(Oe).length})},[at]),Be=h.useCallback(async(Oe=!1)=>{if(!pe)return;const{project:We,sessionCount:yt}=pe,tt=yt===0;de(null),ae(Ve=>new Set([...Ve,We.name]));try{const Ve=await lt.deleteProject(We.name,!tt,Oe);if(Ve.ok)u?.(We.name);else{const Ne=await Ve.json();alert(Ne.error||i("messages.deleteProjectFailed"))}}catch(Ve){console.error("Error deleting project:",Ve),alert(i("messages.deleteProjectError"))}finally{ae(Ve=>{const Ne=new Set(Ve);return Ne.delete(We.name),Ne})}},[pe,u,i]),qe=h.useCallback(async Oe=>{const We=U[Oe.name];if(!(!(We!==void 0?We:Oe.sessionMeta?.hasMore===!0)||S[Oe.name])){j(tt=>({...tt,[Oe.name]:!0}));try{const tt=(Oe.sessions?.length||0)+(A[Oe.name]?.length||0),Ve=await lt.sessions(Oe.name,5,tt);if(!Ve.ok)return;const Ne=await Ve.json();_(Ue=>({...Ue,[Oe.name]:[...Ue[Oe.name]||[],...Ne.sessions||[]]})),Ne.hasMore===!1&&G(Ue=>({...Ue,[Oe.name]:!1}))}catch(tt){console.error("Error loading more sessions:",tt)}finally{j(tt=>({...tt,[Oe.name]:!1}))}}},[A,S,U]),xt=h.useCallback(Oe=>{l(Oe),p(Oe)},[l,p]),_t=h.useCallback(async()=>{F(!0);try{await o()}finally{F(!1)}},[o]),mt=h.useCallback(async(Oe,We,yt,tt)=>{const Ve=yt.trim();if(!Ve){q(null),z("");return}try{const Ne=await lt.renameSession(We,Ve,tt);Ne.ok?await o():(console.error("[Sidebar] Failed to rename session:",Ne.status),alert(i("messages.renameSessionFailed")))}catch(Ne){console.error("[Sidebar] Error renaming session:",Ne),alert(i("messages.renameSessionError"))}finally{q(null),z("")}},[o,i]),fn=h.useCallback(()=>{f(!1)},[f]),Qr=h.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:De,expandedProjects:g,editingProject:x,showNewProject:v,editingName:k,loadingSessions:S,additionalSessions:A,initialSessionsLoaded:N,currentTime:T,projectSortOrder:C,isRefreshing:H,editingSession:O,editingSessionName:$,searchFilter:ne,deletingProjects:ge,deleteConfirmation:pe,sessionDeleteConfirmation:fe,showVersionModal:Se,starredProjects:M,starredSessions:le,filteredProjects:Pe,toggleProject:Ke,handleSessionClick:Ze,toggleStarProject:Nt,isProjectStarred:et,toggleStarSession:Et,isSessionStarred:wt,getProjectSessions:at,startEditing:Xe,cancelEditing:st,saveProjectName:kt,showDeleteSessionConfirmation:ut,confirmDeleteSession:Sr,requestProjectDelete:Ee,confirmDeleteProject:Be,loadMoreSessions:qe,handleProjectSelect:xt,refreshProjects:_t,updateSessionSummary:mt,collapseSidebar:fn,expandSidebar:Qr,setShowNewProject:w,setEditingName:E,setEditingSession:q,setEditingSessionName:z,searchMode:W,setSearchMode:ee,conversationResults:be,isSearching:oe,searchProgress:X,clearConversationResults:h.useCallback(()=>{ce.current+=1,ye.current&&(ye.current.close(),ye.current=null),ke(!1),re(null),xe(null)},[]),setSearchFilter:Q,setDeleteConfirmation:de,setSessionDeleteConfirmation:ve,setShowVersionModal:ze}}const GL="https://discord.gg/buxwujPNRE",HL="https://github.com/alicomert/pixcode/issues/new";function qL({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 VL({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){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":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(Z9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),s.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.settings"),title:a("actions.settings"),children:s.jsx(Lt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:HL,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":a("actions.reportIssue"),title:a("actions.reportIssue"),children:s.jsx(al,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:GL,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":a("actions.joinCommunity"),title:a("actions.joinCommunity"),children:s.jsx(qL,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&s.jsxs("button",{onClick:n,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(ka,{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 NE(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=NE(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function TE(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=NE(e))&&(n&&(n+=" "),n+=t);return n}const Kv=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yv=TE,w0=(e,t)=>r=>{var n;if(t?.variants==null)return Yv(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=Kv(u)||Kv(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,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,f]:d},[]);return Yv(e,o,c,r?.class,r?.className)},k0="-",WL=e=>{const t=YL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(k0);return l[0]===""&&l.length!==1&&l.shift(),AE(l,t)||KL(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},AE=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?AE(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(k0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Zv=/^\[(.+)\]$/,KL=e=>{if(Zv.test(e)){const t=Zv.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},YL=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)zm(r[a],n,a,t);return n},zm=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Xv(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(ZL(a)){zm(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{zm(o,Xv(t,i),r,n)})})},Xv=(e,t)=>{let r=e;return t.split(k0).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},ZL=e=>e.isThemeGetter,XL=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)}}},Bm="!",$m=":",JL=$m.length,QL=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===$m){i.push(a.slice(c,g)),c=g+JL;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=eO(u),f=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+$m,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},eO=e=>e.endsWith(Bm)?e.substring(0,e.length-1):e.startsWith(Bm)?e.substring(1):e,tO=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}},rO=e=>({cache:XL(e.cacheSize),parseClassName:QL(e),sortModifiers:tO(e),...WL(e)}),nO=/\s+/,aO=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(nO);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:m,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=m?v+Bm:v,k=w+y;if(o.includes(k))continue;o.push(k);const E=a(y,x);for(let S=0;S<E.length;++S){const j=E[S];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function iO(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=_E(t))&&(n&&(n+=" "),n+=r);return n}const _E=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=_E(e[n]))&&(r&&(r+=" "),r+=t);return r};function sO(e,...t){let r,n,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=rO(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=aO(c,r);return a(c,u),u}return function(){return i(iO.apply(null,arguments))}}const dr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},jE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,IE=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oO=/^\d+\/\d+$/,lO=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cO=/\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$/,dO=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,uO=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pO=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ss=e=>oO.test(e),pt=e=>!!e&&!Number.isNaN(Number(e)),Fa=e=>!!e&&Number.isInteger(Number(e)),Iu=e=>e.endsWith("%")&&pt(e.slice(0,-1)),ca=e=>lO.test(e),mO=()=>!0,hO=e=>cO.test(e)&&!dO.test(e),RE=()=>!1,fO=e=>uO.test(e),gO=e=>pO.test(e),bO=e=>!Ge(e)&&!He(e),xO=e=>Zs(e,OE,RE),Ge=e=>jE.test(e),xi=e=>Zs(e,ME,hO),Ru=e=>Zs(e,SO,pt),Jv=e=>Zs(e,DE,RE),yO=e=>Zs(e,LE,gO),Kl=e=>Zs(e,PE,fO),He=e=>IE.test(e),xo=e=>Xs(e,ME),vO=e=>Xs(e,EO),Qv=e=>Xs(e,DE),wO=e=>Xs(e,OE),kO=e=>Xs(e,LE),Yl=e=>Xs(e,PE,!0),Zs=(e,t,r)=>{const n=jE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Xs=(e,t,r=!1)=>{const n=IE.exec(e);return n?n[1]?t(n[1]):r:!1},DE=e=>e==="position"||e==="percentage",LE=e=>e==="image"||e==="url",OE=e=>e==="length"||e==="size"||e==="bg-size",ME=e=>e==="length",SO=e=>e==="number",EO=e=>e==="family-name",PE=e=>e==="shadow",CO=()=>{const e=dr("color"),t=dr("font"),r=dr("text"),n=dr("font-weight"),a=dr("tracking"),i=dr("leading"),o=dr("breakpoint"),l=dr("container"),c=dr("spacing"),d=dr("radius"),u=dr("shadow"),p=dr("inset-shadow"),f=dr("text-shadow"),m=dr("drop-shadow"),g=dr("blur"),b=dr("perspective"),x=dr("aspect"),y=dr("ease"),v=dr("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"],E=()=>[...k(),He,Ge],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],A=()=>[He,Ge,c],_=()=>[ss,"full","auto",...A()],N=()=>[Fa,"none","subgrid",He,Ge],D=()=>["auto",{span:["full",Fa,He,Ge]},Fa,He,Ge],T=()=>[Fa,"auto",He,Ge],R=()=>["auto","min","max","fr",He,Ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...A()],F=()=>[ss,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],U=()=>[e,He,Ge],G=()=>[...k(),Qv,Jv,{position:[He,Ge]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",wO,xO,{size:[He,Ge]}],$=()=>[Iu,xo,xi],z=()=>["","none","full",d,He,Ge],ne=()=>["",pt,xo,xi],Q=()=>["solid","dashed","dotted","double"],ge=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[pt,Iu,Qv,Jv],pe=()=>["","none",g,He,Ge],de=()=>["none",pt,He,Ge],fe=()=>["none",pt,He,Ge],ve=()=>[pt,He,Ge],Se=()=>[ss,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ca],breakpoint:[ca],color:[mO],container:[ca],"drop-shadow":[ca],ease:["in","out","in-out"],font:[bO],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ca],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ca],shadow:[ca],spacing:["px",pt],text:[ca],"text-shadow":[ca],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ss,Ge,He,x]}],container:["container"],columns:[{columns:[pt,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:E()}],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:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{start:_()}],end:[{end:_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[Fa,"auto",He,Ge]}],basis:[{basis:[ss,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pt,ss,"auto","initial","none",Ge]}],grow:[{grow:["",pt,He,Ge]}],shrink:[{shrink:["",pt,He,Ge]}],order:[{order:[Fa,"first","last","none",He,Ge]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:D()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",r,xo,xi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,He,Ru]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Iu,Ge]}],"font-family":[{font:[vO,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":[pt,"none",He,Ru]}],leading:[{leading:[i,...A()]}],"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:U()}],"text-color":[{text:U()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:[pt,"from-font","auto",He,xi]}],"text-decoration-color":[{decoration:U()}],"underline-offset":[{"underline-offset":[pt,"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:A()}],"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:G()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fa,He,Ge],radial:["",He,Ge],conic:[Fa,He,Ge]},kO,yO]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Q(),"hidden","none"]}],"divide-style":[{divide:[...Q(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...Q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pt,He,Ge]}],"outline-w":[{outline:["",pt,xo,xi]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",u,Yl,Kl]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",p,Yl,Kl]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[pt,xi]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",f,Yl,Kl]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[pt,He,Ge]}],"mix-blend":[{"mix-blend":[...ge(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ge()}],"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":[pt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"mask-image-radial":[{"mask-radial":[He,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":[pt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ge]}],filter:[{filter:["","none",He,Ge]}],blur:[{blur:pe()}],brightness:[{brightness:[pt,He,Ge]}],contrast:[{contrast:[pt,He,Ge]}],"drop-shadow":[{"drop-shadow":["","none",m,Yl,Kl]}],"drop-shadow-color":[{"drop-shadow":U()}],grayscale:[{grayscale:["",pt,He,Ge]}],"hue-rotate":[{"hue-rotate":[pt,He,Ge]}],invert:[{invert:["",pt,He,Ge]}],saturate:[{saturate:[pt,He,Ge]}],sepia:[{sepia:["",pt,He,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ge]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[pt,He,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[pt,He,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pt,He,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pt,He,Ge]}],"backdrop-invert":[{"backdrop-invert":["",pt,He,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[pt,He,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[pt,He,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",pt,He,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"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:[pt,"initial",He,Ge]}],ease:[{ease:["linear","initial",y,He,Ge]}],delay:[{delay:[pt,He,Ge]}],animate:[{animate:["none",v,He,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,He,Ge]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:de()}],"rotate-x":[{"rotate-x":de()}],"rotate-y":[{"rotate-y":de()}],"rotate-z":[{"rotate-z":de()}],scale:[{scale:fe()}],"scale-x":[{"scale-x":fe()}],"scale-y":[{"scale-y":fe()}],"scale-z":[{"scale-z":fe()}],"scale-3d":["scale-3d"],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[He,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"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":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"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",...U()]}],"stroke-w":[{stroke:[pt,xo,xi,Ru]}],stroke:[{stroke:["none",...U()]}],"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"]}},NO=sO(CO);function me(...e){return NO(TE(e))}function TO(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const AO=w0("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"}}),FE=h.forwardRef(({className:e,variant:t,...r},n)=>s.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:me(AO({variant:t}),e),...r}));FE.displayName="Alert";const _O=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-title",className:me("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));_O.displayName="AlertTitle";const jO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"alert-description",className:me("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));jO.displayName="AlertDescription";const IO=w0("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 or({className:e,variant:t,...r}){return s.jsx("div",{className:me(IO({variant:t}),e),...r})}const RO=w0("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"}}),je=h.forwardRef(({className:e,variant:t,size:r,...n},a)=>s.jsx("button",{className:me(RO({variant:t,size:r,className:e})),ref:a,...n}));je.displayName="Button";const zE=h.createContext(null),BE=()=>{const e=h.useContext(zE);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},$E=({className:e,approval:t="pending",children:r,...n})=>{const a=h.useMemo(()=>({approval:t}),[t]);return s.jsx(zE.Provider,{value:a,children:s.jsx(FE,{className:me("flex flex-col gap-2",e),...n,children:r})})};$E.displayName="Confirmation";const UE=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:me("text-muted-foreground inline text-sm",e),...t});UE.displayName="ConfirmationTitle";const GE=({children:e})=>{const{approval:t}=BE();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};GE.displayName="ConfirmationRequest";const HE=({className:e,...t})=>{const{approval:r}=BE();return r!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:me("flex items-center justify-end gap-2 self-end",e),...t})};HE.displayName="ConfirmationActions";const Ac=({variant:e="default",...t})=>s.jsx(je,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Ac.displayName="ConfirmationAction";const qE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));qE.displayName="Card";const VE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("flex flex-col space-y-1.5 p-4",e),...t}));VE.displayName="CardHeader";const WE=h.forwardRef(({className:e,...t},r)=>s.jsx("h3",{ref:r,className:me("font-semibold leading-none tracking-tight",e),...t}));WE.displayName="CardTitle";const DO=h.forwardRef(({className:e,...t},r)=>s.jsx("p",{ref:r,className:me("text-sm text-muted-foreground",e),...t}));DO.displayName="CardDescription";const KE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("p-4 pt-0",e),...t}));KE.displayName="CardContent";const YE=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("flex items-center p-4 pt-0",e),...t}));YE.displayName="CardFooter";const LO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("ml-auto shrink-0",e),...t}));LO.displayName="CardAction";const ZE=h.createContext(null);function XE(){const e=h.useContext(ZE);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const ni=h.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...i},o)=>{const[l,c]=h.useState(e),d=t!==void 0,u=d?t:l,p=h.useCallback(m=>{d||c(m),r?.(m)},[d,r]),f=h.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(ZE.Provider,{value:f,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...i,children:a})})});ni.displayName="Collapsible";const Sa=h.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:i,onOpenChange:o}=XE(),l=h.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})});Sa.displayName="CollapsibleTrigger";const ai=h.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=XE();return s.jsx("div",{ref:n,"data-state":a?"open":"closed",className:me("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})})});ai.displayName="CollapsibleContent";const JE=h.createContext(null);function S0(){const e=h.useContext(JE);if(!e)throw new Error("Command components must be used within <Command>");return e}const QE=h.forwardRef(({className:e,children:t,...r},n)=>{const[a,i]=h.useState(""),o=h.useRef(new Map),[l,c]=h.useState(0),d=h.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=h.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=h.useCallback((v,w)=>{const k=o.current.get(v);k&&Object.assign(k,w)},[]),f=h.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[k,E]of o.current)(!v||E.value.includes(v))&&w.add(k);return w},[a,l]),m=h.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=h.useState(null);h.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=h.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=m;if(w.length===0)return;if(v.key==="Enter"){w.find(_=>_.id===g)?.onSelect();return}const k=w.findIndex(A=>A.id===g);let E;v.key==="ArrowDown"?E=k<w.length-1?k+1:0:E=k>0?k-1:w.length-1;const S=w[E].id;b(S),w[E].element?.scrollIntoView({block:"nearest"})},[m,g]),y=h.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(JE.Provider,{value:y,children:s.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:me("flex flex-col",e),onKeyDown:x,...r,children:t})})});QE.displayName="Command";const e3=h.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:i}=S0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(wa,{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:me("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})]})});e3.displayName="CommandInput";const t3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,role:"listbox",className:me("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));t3.displayName="CommandList";const r3=h.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=S0();return!n||a.size>0?null:s.jsx("div",{ref:r,className:me("py-6 text-center text-sm text-muted-foreground",e),...t})});r3.displayName="CommandEmpty";const n3=h.forwardRef(({className:e,heading:t,children:r,...n},a)=>s.jsxs("div",{ref:a,className:me("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]}));n3.displayName="CommandGroup";const a3=h.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}=S0(),m=h.useId(),g=h.useRef(null),b=t||(typeof a=="string"?a:"");h.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,p]),h.useEffect(()=>{f(m,{onSelect:r||(()=>{})})},[m,r,f]);const x=h.useCallback(v=>{g.current=v,f(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,f,o]);if(!l.has(m))return null;const y=c===m;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:me("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!==m&&d(m)},onClick:()=>!n&&r?.(),...i,children:a})});a3.displayName="CommandItem";const OO=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:me("-mx-1 h-px bg-border",e),...t}));OO.displayName="CommandSeparator";function Um({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=Ra(),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:me("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:me("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(p0,{className:"h-3 w-3 text-primary"}):s.jsx(h0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const i3=h.createContext(null);function s3(){const e=h.useContext(i3);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const o3=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,i]=h.useState(r),o=h.useRef(null),l=e!==void 0,c=l?e:a,d=h.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=h.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(i3.Provider,{value:u,children:n})},MO=h.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:i,triggerRef:o}=s3(),l=h.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(r&&h.isValidElement(t)){const c=t;return h.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})});MO.displayName="DialogTrigger";const ew='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',E0=h.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=s3(),d=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),h.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),r?.(),l(!1);return}if(m.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(ew));if(g.length===0)return;const b=g[0],x=g[g.length-1];m.shiftKey&&document.activeElement===b?(m.preventDefault(),x.focus()):!m.shiftKey&&document.activeElement===x&&(m.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]),h.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(ew)?.focus()})},[o]),o?_d.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:me("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});E0.displayName="DialogContent";const C0=h.forwardRef(({className:e,...t},r)=>s.jsx("h2",{ref:r,className:me("sr-only",e),...t}));C0.displayName="DialogTitle";const It=h.forwardRef(({className:e,type:t,...r},n)=>s.jsx("input",{type:t,className:me("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}));It.displayName="Input";const N0=h.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>s.jsx("div",{className:me("relative overflow-hidden",e),...n,children:s.jsx("div",{ref:a,className:me("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));N0.displayName="ScrollArea";const Xc=h.memo(({children:e,className:t,as:r="span"})=>s.jsx(r,{className:me("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}));Xc.displayName="Shimmer";const l3=h.createContext(null),PO=()=>{const e=h.useContext(l3);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},FO=1e3,zO=1e3,Gm=h.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]=h.useState(c),f=r!==void 0,m=f?r:u,g=h.useCallback(S=>{f||p(S),a?.(S)},[f,a]),[b,x]=h.useState(i),y=h.useRef(t),[v,w]=h.useState(!1),k=h.useRef(null);h.useEffect(()=>{i!==void 0&&x(i)},[i]),h.useEffect(()=>{t?(y.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(x(Math.ceil((Date.now()-k.current)/zO)),k.current=null)},[t]),h.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),h.useEffect(()=>{if(y.current&&!t&&m&&!v){const S=setTimeout(()=>{g(!1),w(!0)},FO);return()=>clearTimeout(S)}},[t,m,g,v]);const E=h.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return s.jsx(l3.Provider,{value:E,children:s.jsx(ni,{open:m,onOpenChange:g,className:me("not-prose",e),...l,children:o})})});Gm.displayName="Reasoning";const BO=(e,t)=>e||t===0?s.jsx(Xc,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Hm=h.memo(({className:e,children:t,getThinkingMessage:r=BO,...n})=>{const{isStreaming:a,isOpen:i,duration:o}=PO();return s.jsx(Sa,{className:me("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(wD,{className:"h-4 w-4"}),r(a,o),s.jsx($4,{className:me("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Hm.displayName="ReasoningTrigger";const qm=h.memo(({className:e,children:t,...r})=>s.jsx(ai,{className:me("mt-4 text-sm text-muted-foreground",e),...r,children:t}));qm.displayName="ReasoningContent";function $O(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 Vn({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[i,o]=h.useState(!1),l=h.useRef(null),c=h.useRef(!1),d=h.useRef(null),u=h.useRef(null),[p,f]=h.useState(null),m=h.useCallback(()=>{const w=d.current;if(!w)return;const k=w.getBoundingClientRect(),E=8,S={position:"fixed",zIndex:9999};switch(r){case"bottom":S.left=k.left+k.width/2,S.top=k.bottom+E,S.transform="translateX(-50%)";break;case"left":S.left=k.left-E,S.top=k.top+k.height/2,S.transform="translate(-100%, -50%)";break;case"right":S.left=k.right+E,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-E,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 h.useEffect(()=>()=>{g()},[]),h.useEffect(()=>{if(!i||typeof document>"u")return;const w=k=>{const E=k.target;E instanceof Node&&d.current?.contains(E)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),h.useEffect(()=>{if(!i){f(null);return}const w=window.requestAnimationFrame(m),k=()=>m();return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[i,m]),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"&&_d.createPortal(s.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:me("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:me("absolute w-0 h-0 border-4 border-transparent",$O(r))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const c3=h.createContext(null),d3=h.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const i=h.useMemo(()=>({status:t}),[t]);return s.jsx(c3.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:me("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})})});d3.displayName="PromptInput";const u3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:me("px-3 pt-3",e),...t}));u3.displayName="PromptInputHeader";const p3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:me("relative",e),...t}));p3.displayName="PromptInputBody";const m3=h.forwardRef(({className:e,...t},r)=>s.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:me("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}));m3.displayName="PromptInputTextarea";const h3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:me("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));h3.displayName="PromptInputFooter";const f3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:me("flex items-center gap-1",e),...t}));f3.displayName="PromptInputTools";const _c=h.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const i=s.jsx(je,{ref:a,type:"button",variant:"ghost",size:"icon",className:me("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?s.jsx(Vn,{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});_c.displayName="PromptInputButton";const g3=h.forwardRef(({className:e,status:t,children:r,...n},a)=>{const i=h.useContext(c3),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(je,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:me("h-8 w-8 rounded-lg",e),...n,children:r??(l?s.jsx(l0,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(X9,{className:"h-4 w-4"}))})});g3.displayName="PromptInputSubmit";function T0({children:e,className:t}){return s.jsx("div",{className:me("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function A0({isActive:e,onClick:t,children:r,className:n}){return s.jsx("button",{onClick:t,className:me("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 b3=h.createContext(null);function x3(){const e=h.useContext(b3);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const y3=h.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:me("space-y-0.5",e),...t}));y3.displayName="Queue";const v3=h.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const i=h.useMemo(()=>({status:e}),[e]);return s.jsx(b3.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:me("flex items-start gap-2 py-0.5",t),...n,children:r})})});v3.displayName="QueueItem";const w3=h.forwardRef(({className:e,...t},r)=>{const{status:n}=x3();return s.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:me("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})})]})});w3.displayName="QueueItemIndicator";const k3=h.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=x3();return s.jsx("div",{ref:n,"data-slot":"queue-item-content",className:me("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})});k3.displayName="QueueItemContent";const tw="https://github.com/alicomert/pixcode/issues/new",UO="https://github.com/alicomert/pixcode",rw="https://discord.gg/buxwujPNRE";function nw({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 GO({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onShowSettings:i,t:o}){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(Iv,{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:o("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(Iv,{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:o("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:tw,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(al,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:rw,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(nw,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),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:i,children:[s.jsx(Lt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:UO,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",o("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:tw,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(al,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:rw,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(nw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),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:i,children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Lt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const aw="PIXCODE_GITHUB_STARS",iw="PIXCODE_HIDE_GITHUB_STAR",HO=3600*1e3,qO=(e,t)=>{const[r,n]=h.useState(null),[a,i]=h.useState(()=>{try{return localStorage.getItem(iw)==="true"}catch{return!1}});h.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(aw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<HO){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(aw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=h.useCallback(()=>{i(!0);try{localStorage.setItem(iw,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},VO="https://github.com/alicomert/pixcode";function WO({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 KO(){const{formattedCount:e,isDismissed:t,dismiss:r}=qO("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:VO,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(WO,{className:"h-3.5 w-3.5"}),s.jsx(Ns,{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(bt,{className:"h-2.5 w-2.5"})})]})}function sw({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:me(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(nl,{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:me(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(rD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function YO({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:m,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(je,{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(Tt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(je,{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(Ut,{className:"h-4 w-4"})}),s.jsx(je,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:m,title:x("tooltips.hideSidebar"),children:s.jsx(Y9,{className:"h-4 w-4"})})]})]}),s.jsx(KO,{}),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(ka,{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(sw,{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:me("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(Ln,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:me("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(Qn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(wa,{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(It,{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(bt,{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(Tt,{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(ti,{className:"h-4 w-4"})})]})]}),n>0&&!r&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(sw,{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:me("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(Ln,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:me("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(Qn,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(wa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(It,{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(bt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const ZO=160,ow=180;function S3({actions:e,className:t,triggerLabel:r}){const[n,a]=h.useState(!1),[i,o]=h.useState(null),l=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-ZO;p<8&&(p=8);let f=u.bottom+4;f+ow>window.innerHeight&&(f=Math.max(8,u.top-4-ow)),o({top:f,left:p})},[n]),h.useEffect(()=>{if(!n)return;const u=m=>{const g=m.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=m=>{m.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:me("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(uD,{className:"h-3.5 w-3.5"})}),n&&i&&_d.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:me("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,m=e[p-1],g=p>0&&u.danger&&!m?.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:me("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 lw={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},XO={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},JO=e=>e==="fully-configured"?{icon:ya,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:Lt,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:ga,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:bt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function QO({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=JO(e),i=a.icon;return n?s.jsxs("div",{className:me("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:lw[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:me("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,XO[t],r),title:a.title,children:s.jsx(i,{className:me(lw[t],a.colorClassName)})})}const eM=(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 cw({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:i,className:o}){const l=d=>s.jsx(Ns,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:iD,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:vr,onClick:a,danger:!0}),s.jsx(S3,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const tM={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},dw={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 E3({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:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=PL(t,n,x),v=r?.id===t.id,w=a===t.id,k=t.__provider,E=tM[k]??k,S=dw[k]??dw.claude,j=LL(y.sessionName),A=()=>{m(e),g(t,e.name)},_=()=>{p(e.name,t.id,i,k)},N=()=>{b(e.name,t.id,y.sessionName,k)},D=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),R=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:me("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",S),children:[s.jsx(lr,{provider:k,className:"h-2.5 w-2.5"}),E]}),s.jsx("span",{className:"text-muted-foreground/80",children:eM(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(F=>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:[".",F]},F))]}),C=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:F=>c(F.target.value),onKeyDown:F=>{F.stopPropagation(),F.key==="Enter"?_():F.key==="Escape"&&u()},onClick:F=>F.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),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:F=>{F.stopPropagation(),_()},title:x("tooltips.save"),children:s.jsx(Qt,{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:F=>{F.stopPropagation(),u()},title:x("tooltips.cancel"),children:s.jsx(bt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),P=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:me("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:A,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:me("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(lr,{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})]}),R]}),s.jsx("div",{className:"flex-shrink-0",onClick:F=>F.stopPropagation(),children:s.jsx(cw,{isStarred:o,canDelete:!y.isCursorSession,onRename:D,onToggleStar:T,onDelete:N,t:x,className:"!opacity-100"})})]})})}),H=s.jsxs("div",{className:me("group/item relative hidden md:block"),children:[s.jsxs(je,{variant:"ghost",className:me("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:me("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(lr,{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})]}),R]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:F=>F.stopPropagation(),children:s.jsx(cw,{isStarred:o,canDelete:!y.isCursorSession,onRename:D,onToggleStar:T,onDelete:N,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[P,H]})}const rM=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function nM(){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 aM({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:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:k,t:E}){const[S,j]=h.useState([]);if(h.useEffect(()=>{if(!t)return;let N=!1;const D=async()=>{const R=await we(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!R.ok)return;const C=await R.json();N||j((C.runs??[]).slice(0,5))};D();const T=window.setInterval(()=>{D()},15e3);return()=>{N=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const A=r.length>0,_=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(Ut,{className:"h-3 w-3"}),E("sessions.newSession")]})}),s.jsxs(je,{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(Ut,{className:"h-3 w-3"}),E("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(ea,{className:"h-3 w-3"}),E("orchestration.section")]}),S.map(N=>{const D=[...new Set(N.nodeRuns.map(T=>rM(T.adapterId)).filter(Boolean))];return s.jsx("button",{type:"button",onClick:()=>k?.(e,N.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(ea,{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:N.input||E("orchestration.fallbackTitle")}),s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[D.slice(0,4).map(T=>s.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:s.jsx(lr,{provider:T,className:"h-3 w-3"})},T)),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:E(`common:orchestration.status.${N.status}`,{defaultValue:N.status})})]})]})]})},N.id)})]}),a?!A&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:E("sessions.noSessions")})}):r.map(N=>s.jsx(E3,{project:e,session:N,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,N.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:E},N.id)):s.jsx(nM,{}),A&&_&&s.jsx(je,{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"}),E("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Mr,{className:"h-3 w-3"}),E("sessions.showMore")]})})]})}const iM=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function sM({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:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:k,onToggleStarSession:E,onStartEditingProject:S,onCancelEditingProject:j,onSaveProjectName:A,onDeleteProject:_,onSessionSelect:N,onDeleteSession:D,onLoadMoreSessions:T,onNewSession:R,onOpenOrchestration:C,onEditingSessionNameChange:P,onStartEditingSession:H,onCancelEditingSession:F,onSaveEditingSession:U,t:G}){const O=t?.name===e.name,q=o===e.name,$=e.sessionMeta?.hasMore===!0,z=iM(c,$),ne=`${z} session${c.length===1?"":"s"}`,Q=BL(e,b),ge=()=>v(e.name),ae=()=>k(e.name),pe=()=>{A(e.name)},de=()=>{t?.name!==e.name&&w(e),ge()};return s.jsxs("div",{className:me("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:me("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",O&&"bg-primary/5 border-primary/20",i&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ge,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:me("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?s.jsx(va,{className:"h-4 w-4 text-primary"}):s.jsx(Ln,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:q?s.jsx("input",{type:"text",value:l,onChange:fe=>y(fe.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:G("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:fe=>fe.stopPropagation(),onKeyDown:fe=>{fe.key==="Enter"&&pe(),fe.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(QO,{status:Q,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:ne})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:q?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:fe=>{fe.stopPropagation(),pe()},children:s.jsx(Qt,{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:fe=>{fe.stopPropagation(),j()},children:s.jsx(bt,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:me("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:fe=>{fe.stopPropagation(),ae()},title:G(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(Ns,{className:me("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:fe=>{fe.stopPropagation(),_(e)},children:s.jsx(vr,{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:fe=>{fe.stopPropagation(),S(e)},children:s.jsx(Tm,{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(Mr,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(En,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(je,{variant:"ghost",className:me("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",O&&"bg-accent text-accent-foreground",i&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:de,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?s.jsx(va,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Ln,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:q?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:fe=>y(fe.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:G("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:fe=>{fe.key==="Enter"&&pe(),fe.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:[z,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:q?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:fe=>{fe.stopPropagation(),pe()},children:s.jsx(Qt,{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:fe=>{fe.stopPropagation(),j()},children:s.jsx(bt,{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:fe=>{fe.stopPropagation(),ae()},title:G("tooltips.removeFromFavorites"),children:s.jsx(Ns,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(S3,{triggerLabel:G("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:G("actions.rename"),icon:Tm,onClick:()=>S(e)},{id:"star",label:G(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Ns,onClick:ae},{id:"delete",label:G("actions.delete",{defaultValue:"Delete"}),icon:vr,onClick:()=>_(e),danger:!0}]}),n?s.jsx(Mr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(En,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(aM,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:P,onStartEditingSession:H,onCancelEditingSession:F,onSaveEditingSession:U,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:N,onDeleteSession:D,onLoadMoreSessions:T,onNewSession:R,onOpenOrchestration:C,t:G})]})}function C3({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(Ln,{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(wa,{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 oM({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:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:k,onToggleProject:E,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:A,onStartEditingProject:_,onCancelEditingProject:N,onSaveProjectName:D,onDeleteProject:T,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:P,onNewSession:H,onOpenOrchestration:F,onEditingSessionNameChange:U,onStartEditingSession:G,onCancelEditingSession:O,onSaveEditingSession:q,t:$}){const z=s.jsx(C3,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:$});h.useEffect(()=>{let de="Pixcode";const fe=r?.displayName?.trim();fe&&(de=`${fe} - ${de}`),document.title=de},[r]);const ne=!a&&e.length>0&&t.length>0,Q=de=>de.source==="history"||de.autoDiscovered===!0&&de.isManuallyAdded!==!0,ge=t.filter(de=>!Q(de)),ae=t.filter(de=>Q(de)),pe=de=>s.jsx(sM,{project:de,selectedProject:r,selectedSession:n,isExpanded:o.has(de.name),isDeleting:g.has(de.name),isStarred:v(de.name),editingProject:l,editingName:c,sessions:y(de),initialSessionsLoaded:u.has(de.name),isLoadingSessions:!!d[de.name],currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:k,onToggleProject:E,onProjectSelect:S,onToggleStarProject:j,onToggleStarSession:A,onStartEditingProject:_,onCancelEditingProject:N,onSaveProjectName:D,onDeleteProject:T,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:P,onNewSession:H,onOpenOrchestration:F,onEditingSessionNameChange:U,onStartEditingSession:G,onCancelEditingSession:O,onSaveEditingSession:q,t:$},de.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ne?s.jsxs(s.Fragment,{children:[ge.map(de=>pe(de)),ae.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:$("projects.detectedFromHistory")}),ae.map(de=>pe(de))]})]}):z})}function ua(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N3(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
  *