Spaces:
Running
Running
feat: Zustand OS store, headless process table, hardware gesture engine, and floating UI overlays
Browse files- algospaced-ui/dist/assets/{GitHubSyncWindow-Bkz4qSX5.js → GitHubSyncWindow-zQZqmRO1.js} +1 -1
- algospaced-ui/dist/assets/{JourneyPath-DytnV8uO.js → JourneyPath-B98APTO3.js} +0 -0
- algospaced-ui/dist/assets/{MarkdownRenderer-DcpmP1uN.js → MarkdownRenderer-O4K5H8Fp.js} +1 -1
- algospaced-ui/dist/assets/{PrincessChamber-BzhzFHRQ.js → PrincessChamber-b4TXNjIa.js} +1 -1
- algospaced-ui/dist/assets/{PythonChallenge-BP6ASjZJ.js → PythonChallenge-C3lt-s_2.js} +1 -1
- algospaced-ui/dist/assets/ReviewQueue-BwN6dLvy.js +0 -0
- algospaced-ui/dist/assets/ReviewQueue-WbUnUC1g.js +0 -0
- algospaced-ui/dist/assets/{Settings-5f8XTRov.js → Settings-Cv6B9KXE.js} +1 -1
- algospaced-ui/dist/assets/TerminalEmulator-CI1oWIOR.js +0 -1
- algospaced-ui/dist/assets/TerminalEmulator-CduzKEDa.js +1 -0
- algospaced-ui/dist/assets/{circle-alert-B3TumjQg.js → circle-alert-Of55HLBR.js} +1 -1
- algospaced-ui/dist/assets/{confetti.module-BXT-TAy0.js → confetti.module-CvdoQdWi.js} +1 -1
- algospaced-ui/dist/assets/{external-link-64ub39jt.js → external-link-BXmZLKhd.js} +1 -1
- algospaced-ui/dist/assets/{githubSyncService-B4h5nigj.js → githubSyncService-DoPH-Kso.js} +1 -1
- algospaced-ui/dist/assets/index-126irCND.css +0 -0
- algospaced-ui/dist/assets/{index-M1GCaKIP.js → index-Bz1BMWr8.js} +0 -0
- algospaced-ui/dist/assets/index-hevgUcKQ.css +0 -0
- algospaced-ui/dist/assets/{info-jE4ZFn-x.js → info-BOfHU5mV.js} +1 -1
- algospaced-ui/dist/assets/{save-zS5LwKaW.js → save-BAfjznhv.js} +1 -1
- algospaced-ui/dist/index.html +2 -2
- algospaced-ui/dist/sw.js +1 -1
- algospaced-ui/package-lock.json +112 -3
- algospaced-ui/package.json +4 -1
- algospaced-ui/src/App.tsx +5 -38
- algospaced-ui/src/components/DesktopContextMenu.tsx +163 -131
- algospaced-ui/src/components/ReviewQueue.tsx +7 -3
- algospaced-ui/src/components/TerminalEmulator.tsx +31 -3
- algospaced-ui/src/components/WindowShell.tsx +192 -102
- algospaced-ui/src/components/desktop/DesktopStartMenu.tsx +147 -131
- algospaced-ui/src/components/desktop/DesktopTaskbar.tsx +212 -183
- algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx +54 -26
- algospaced-ui/src/components/desktop/SystemTrayProcessFlyout.tsx +127 -0
- algospaced-ui/src/components/desktop/TaskbarWindowItem.tsx +187 -0
- algospaced-ui/src/hooks/useAiReviewer.ts +13 -155
- algospaced-ui/src/hooks/useSandboxRunner.ts +11 -134
- algospaced-ui/src/hooks/useWindowManager.ts +32 -71
- algospaced-ui/src/stores/useOSStore.ts +280 -0
- algospaced-ui/src/stores/useProcessStore.ts +464 -0
- algospaced-ui/src/types/osTypes.ts +20 -0
algospaced-ui/dist/assets/{GitHubSyncWindow-Bkz4qSX5.js → GitHubSyncWindow-zQZqmRO1.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import{t as r}from"./circle-alert-B3TumjQg.js";import{t as i}from"./external-link-64ub39jt.js";import{a,c as o,d as s,f as c,i as l,l as u,n as d,o as f,r as p,s as m,t as h,u as g}from"./githubSyncService-B4h5nigj.js";import{F as _,G as v,T as y,U as b,z as x}from"./index-M1GCaKIP.js";var S=v(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),C=v(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),w=v(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),T=v(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),E=t(e(),1),D=n(),O=({onClose:e,currentProblem:t})=>{let[n,v]=(0,E.useState)(()=>p()),[O,k]=(0,E.useState)(()=>l()),[A,j]=(0,E.useState)(``),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(!1),[I,L]=(0,E.useState)(!1),[R,z]=(0,E.useState)(!1),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(!1),[K,q]=(0,E.useState)(null),J=!!(n.token&&(n.username||O?.login));(0,E.useEffect)(()=>{n.token&&!O&&u(n.token).then(e=>{e.valid&&e.user&&(k(e.user),m({username:e.user.login},e.user))})},[n.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await d();k(t);let n=p();v(n);try{await a(e,n.repoName,n.isPrivate)}catch{}q({type:`success`,text:`Connected successfully to GitHub as @${t.login}!`,linkUrl:t.html_url})}catch(e){q({type:`error`,text:e.message||`GitHub OAuth authorization failed.`})}finally{L(!1)}},X=async()=>{let e=A.trim();if(!e){q({type:`error`,text:`Please enter a valid GitHub token.`});return}z(!0),q(null);try{let t=await u(e);if(t.valid&&t.user){k(t.user),m({token:e,username:t.user.login},t.user),v(p());try{await a(e,n.repoName,n.isPrivate)}catch{}j(``),N(!1),q({type:`success`,text:`Verified and connected as @${t.user.login}!`,linkUrl:t.user.html_url})}else q({type:`error`,text:t.error||`Token verification failed. Please check permissions.`})}catch(e){q({type:`error`,text:e.message||`Failed to connect with token.`})}finally{z(!1)}},Z=async()=>{if(n.token){V(!0),q(null);try{let e=await a(n.token,n.repoName,n.isPrivate);m({repoName:n.repoName}),q({type:`success`,text:e.created?`Created new repository ${e.full_name} on GitHub!`:`Connected to existing repository ${e.full_name}!`,linkUrl:e.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to initialize repository.`})}finally{V(!1)}}},Q=async()=>{if(n.token&&n.repoName){U(!0),q(null);try{let e=await o(n.token,n.repoName,n.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${n.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!t||!n.token)return;let e=t.code||t.reference_code;if(!e||!e.trim()){q({type:`error`,text:`Current problem has no code to push. Write or save code first!`});return}G(!0),q(null);try{let r={token:n.token,repo:n.repoName,branch:n.branch,problem_number:t.problem_number,problem_name:t.name||`Algorithm Problem`,difficulty:t.difficulty||`Medium`,pattern:t.pattern||`Algorithms`,optimal_time:t.optimal_time||`O(N)`,optimal_space:t.optimal_space||`O(1)`,description:t.description||``,code:e},i=await f(r);q({type:`success`,text:`Committed ${t.name} to GitHub!`,linkUrl:i.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{m({autoCommit:e}),v(t=>({...t,autoCommit:e})),q({type:`info`,text:e?`Auto-commit ENABLED: Solutions will sync automatically on submission.`:`Auto-commit DISABLED: You can still push manually any time.`})};return(0,D.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-4 sm:p-6 flex flex-col justify-between select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`w-9 h-9 bg-ink-black rounded border-2 border-ink-black flex items-center justify-center text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)]`,children:(0,D.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,D.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,D.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,D.jsx)(`span`,{className:`px-2.5 py-1 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black ${J?`bg-emerald-300 text-emerald-950`:`bg-amber-200 text-amber-950`}`,children:J?`CONNECTED`:`DISCONNECTED`})})]}),J?(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,D.jsx)(`img`,{src:O.avatar_url,alt:O.login,className:`w-10 h-10 rounded-full border-2 border-ink-black shadow-[1px_1px_0px_0px_#1E293B]`}):(0,D.jsx)(`div`,{className:`w-10 h-10 bg-slate-200 rounded-full border-2 border-ink-black flex items-center justify-center font-bold`,children:`GH`}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||n.username}),(0,D.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||n.username,`)`]})]}),(0,D.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,D.jsx)(g,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,D.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[n.username||O?.login,`/`,n.repoName]}),(0,D.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,n.branch,`)`]})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(`a`,{href:`https://github.com/${n.username||O?.login}/${n.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border-2 border-ink-black text-xs font-bold text-ink-black flex items-center gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none no-underline cursor-pointer`,children:[(0,D.jsx)(i,{className:`w-3.5 h-3.5`}),(0,D.jsx)(`span`,{children:`View Repo`})]}),(0,D.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(h(),v(p()),k(null),q({type:`info`,text:`Disconnected from GitHub.`}))},className:`px-3 py-1.5 bg-white hover:bg-rose-50 border-2 border-rose-300 text-rose-700 text-xs font-bold flex items-center gap-1 cursor-pointer transition-all`,title:`Disconnect GitHub`,children:[(0,D.jsx)(T,{className:`w-3 h-3`}),(0,D.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,D.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,D.jsx)(C,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,D.jsxs)(`button`,{onClick:Z,disabled:B,className:`px-2.5 py-1 bg-yellow-100 hover:bg-yellow-200 border border-ink-black text-[10px] font-bold text-ink-black flex items-center gap-1 cursor-pointer disabled:opacity-50 shadow-[1px_1px_0px_0px_#1E293B]`,children:[B?(0,D.jsx)(_,{className:`w-3 h-3 animate-spin`}):(0,D.jsx)(b,{className:`w-3 h-3 text-emerald-700`}),(0,D.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,D.jsx)(`input`,{type:`text`,value:n.repoName,onChange:e=>{let t=e.target.value;v(e=>({...e,repoName:t})),m({repoName:t})},placeholder:`algospaced-solutions`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,D.jsx)(`input`,{type:`text`,value:n.branch,onChange:e=>{let t=e.target.value;v(e=>({...e,branch:t})),m({branch:t})},placeholder:`main`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]})]}),(0,D.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,D.jsx)(y,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,D.jsx)(`span`,{className:`text-[10px] text-trash-gray font-medium`,children:`Automatically push code to your repo when grading a review card or saving a solution.`})]})]}),(0,D.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,D.jsx)(`div`,{className:`w-9 h-5 bg-slate-300 peer-focus:outline-none border-2 border-ink-black rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-2 after:border-ink-black after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500`})]})]})]}),(0,D.jsxs)(`div`,{className:`bg-[#fffdf0] border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,D.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,D.jsx)(S,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,D.jsxs)(`button`,{onClick:$,disabled:W||!t,className:`p-3 bg-white hover:bg-emerald-50 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,D.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,D.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,D.jsx)(w,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),t?.problem_number&&(0,D.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,t.problem_number]})]}),(0,D.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:t?.name||`No active problem open in review`})]}),(0,D.jsxs)(`button`,{onClick:Q,disabled:H,className:`p-3 bg-[#ffe24c] hover:bg-yellow-300 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,D.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,D.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,D.jsx)(g,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,D.jsx)(`span`,{className:`text-[8px] font-arcade uppercase font-bold bg-white px-1.5 py-0.5 border border-ink-black`,children:`BATCH`})]}),(0,D.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-5 sm:p-6 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] text-center space-y-4`,children:[(0,D.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,D.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,D.jsx)(`p`,{className:`text-xs text-trash-gray font-medium leading-relaxed m-0`,children:`Sync all your DSA solutions directly to your GitHub repository. Commit automatically on review completion or push anytime with 1-click.`})]}),(0,D.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,D.jsx)(`button`,{onClick:Y,disabled:I,className:`w-full sm:w-auto px-6 py-3 bg-[#24292e] hover:bg-black text-white font-bold text-xs uppercase font-headline-md border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center gap-2.5 transition-all cursor-pointer disabled:opacity-50`,children:I?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,D.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})}),(0,D.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,D.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,D.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>N(!M),className:`w-full flex items-center justify-between text-left text-xs font-bold text-ink-black font-headline-md uppercase cursor-pointer bg-transparent border-0 p-0`,children:[(0,D.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,D.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,D.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,D.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,D.jsxs)(`a`,{href:`https://github.com/settings/tokens/new?scopes=repo&description=AlgoSpaced%20Solutions%20Sync`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 font-bold flex items-center gap-1 no-underline text-[10px]`,children:[(0,D.jsx)(`span`,{children:`Generate token with repo scope`}),(0,D.jsx)(i,{className:`w-3 h-3`})]})]}),(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`input`,{type:P?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`ghp_... or github_pat_...`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-2 pl-3 pr-9 text-xs font-mono focus:outline-none focus:bg-white`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>F(!P),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-ink-black cursor-pointer bg-transparent border-0 p-1`,children:P?(0,D.jsx)(c,{className:`w-3.5 h-3.5`}):(0,D.jsx)(s,{className:`w-3.5 h-3.5`})})]}),(0,D.jsx)(`button`,{onClick:X,disabled:R||!A.trim(),className:`px-4 py-2 bg-[#ffe24c] hover:bg-yellow-300 text-ink-black font-bold text-xs uppercase border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:R?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{className:`w-3.5 h-3.5 animate-spin`}),(0,D.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(b,{className:`w-3.5 h-3.5`}),(0,D.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,D.jsxs)(`div`,{className:`p-3 border-[2px] border-ink-black text-xs font-semibold rounded flex items-center justify-between gap-2 ${K.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-600`:K.type===`error`?`bg-rose-100 text-rose-900 border-rose-600`:`bg-sky-100 text-sky-900 border-sky-600`}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,D.jsx)(x,{className:`w-4 h-4 shrink-0`}):(0,D.jsx)(r,{className:`w-4 h-4 shrink-0`}),(0,D.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,D.jsxs)(`a`,{href:K.linkUrl,target:`_blank`,rel:`noopener noreferrer`,className:`px-2 py-0.5 bg-white border border-ink-black text-[10px] font-bold text-ink-black hover:bg-slate-50 no-underline shrink-0 flex items-center gap-1`,children:[(0,D.jsx)(`span`,{children:`Open`}),(0,D.jsx)(i,{className:`w-3 h-3`})]})]})]}),(0,D.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,D.jsx)(`button`,{onClick:e,className:`px-4 py-2 bg-white hover:bg-slate-100 border-[2px] border-ink-black text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase`,children:`CLOSE`})})]})};export{O as GitHubSyncWindow,O as default};
|
|
|
|
| 1 |
+
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import{t as r}from"./circle-alert-Of55HLBR.js";import{t as i}from"./external-link-BXmZLKhd.js";import{a,c as o,d as s,f as c,i as l,l as u,n as d,o as f,r as p,s as m,t as h,u as g}from"./githubSyncService-DoPH-Kso.js";import{B as _,H as v,I as y,M as b,S as x}from"./index-Bz1BMWr8.js";var S=v(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),C=v(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),w=v(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),T=v(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),E=t(e(),1),D=n(),O=({onClose:e,currentProblem:t})=>{let[n,v]=(0,E.useState)(()=>p()),[O,k]=(0,E.useState)(()=>l()),[A,j]=(0,E.useState)(``),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(!1),[I,L]=(0,E.useState)(!1),[R,z]=(0,E.useState)(!1),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(!1),[K,q]=(0,E.useState)(null),J=!!(n.token&&(n.username||O?.login));(0,E.useEffect)(()=>{n.token&&!O&&u(n.token).then(e=>{e.valid&&e.user&&(k(e.user),m({username:e.user.login},e.user))})},[n.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await d();k(t);let n=p();v(n);try{await a(e,n.repoName,n.isPrivate)}catch{}q({type:`success`,text:`Connected successfully to GitHub as @${t.login}!`,linkUrl:t.html_url})}catch(e){q({type:`error`,text:e.message||`GitHub OAuth authorization failed.`})}finally{L(!1)}},X=async()=>{let e=A.trim();if(!e){q({type:`error`,text:`Please enter a valid GitHub token.`});return}z(!0),q(null);try{let t=await u(e);if(t.valid&&t.user){k(t.user),m({token:e,username:t.user.login},t.user),v(p());try{await a(e,n.repoName,n.isPrivate)}catch{}j(``),N(!1),q({type:`success`,text:`Verified and connected as @${t.user.login}!`,linkUrl:t.user.html_url})}else q({type:`error`,text:t.error||`Token verification failed. Please check permissions.`})}catch(e){q({type:`error`,text:e.message||`Failed to connect with token.`})}finally{z(!1)}},Z=async()=>{if(n.token){V(!0),q(null);try{let e=await a(n.token,n.repoName,n.isPrivate);m({repoName:n.repoName}),q({type:`success`,text:e.created?`Created new repository ${e.full_name} on GitHub!`:`Connected to existing repository ${e.full_name}!`,linkUrl:e.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to initialize repository.`})}finally{V(!1)}}},Q=async()=>{if(n.token&&n.repoName){U(!0),q(null);try{let e=await o(n.token,n.repoName,n.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${n.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!t||!n.token)return;let e=t.code||t.reference_code;if(!e||!e.trim()){q({type:`error`,text:`Current problem has no code to push. Write or save code first!`});return}G(!0),q(null);try{let r={token:n.token,repo:n.repoName,branch:n.branch,problem_number:t.problem_number,problem_name:t.name||`Algorithm Problem`,difficulty:t.difficulty||`Medium`,pattern:t.pattern||`Algorithms`,optimal_time:t.optimal_time||`O(N)`,optimal_space:t.optimal_space||`O(1)`,description:t.description||``,code:e},i=await f(r);q({type:`success`,text:`Committed ${t.name} to GitHub!`,linkUrl:i.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{m({autoCommit:e}),v(t=>({...t,autoCommit:e})),q({type:`info`,text:e?`Auto-commit ENABLED: Solutions will sync automatically on submission.`:`Auto-commit DISABLED: You can still push manually any time.`})};return(0,D.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-4 sm:p-6 flex flex-col justify-between select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`w-9 h-9 bg-ink-black rounded border-2 border-ink-black flex items-center justify-center text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)]`,children:(0,D.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,D.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,D.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,D.jsx)(`span`,{className:`px-2.5 py-1 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black ${J?`bg-emerald-300 text-emerald-950`:`bg-amber-200 text-amber-950`}`,children:J?`CONNECTED`:`DISCONNECTED`})})]}),J?(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,D.jsx)(`img`,{src:O.avatar_url,alt:O.login,className:`w-10 h-10 rounded-full border-2 border-ink-black shadow-[1px_1px_0px_0px_#1E293B]`}):(0,D.jsx)(`div`,{className:`w-10 h-10 bg-slate-200 rounded-full border-2 border-ink-black flex items-center justify-center font-bold`,children:`GH`}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||n.username}),(0,D.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||n.username,`)`]})]}),(0,D.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,D.jsx)(g,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,D.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[n.username||O?.login,`/`,n.repoName]}),(0,D.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,n.branch,`)`]})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(`a`,{href:`https://github.com/${n.username||O?.login}/${n.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border-2 border-ink-black text-xs font-bold text-ink-black flex items-center gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none no-underline cursor-pointer`,children:[(0,D.jsx)(i,{className:`w-3.5 h-3.5`}),(0,D.jsx)(`span`,{children:`View Repo`})]}),(0,D.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(h(),v(p()),k(null),q({type:`info`,text:`Disconnected from GitHub.`}))},className:`px-3 py-1.5 bg-white hover:bg-rose-50 border-2 border-rose-300 text-rose-700 text-xs font-bold flex items-center gap-1 cursor-pointer transition-all`,title:`Disconnect GitHub`,children:[(0,D.jsx)(T,{className:`w-3 h-3`}),(0,D.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,D.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,D.jsx)(C,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,D.jsxs)(`button`,{onClick:Z,disabled:B,className:`px-2.5 py-1 bg-yellow-100 hover:bg-yellow-200 border border-ink-black text-[10px] font-bold text-ink-black flex items-center gap-1 cursor-pointer disabled:opacity-50 shadow-[1px_1px_0px_0px_#1E293B]`,children:[B?(0,D.jsx)(b,{className:`w-3 h-3 animate-spin`}):(0,D.jsx)(_,{className:`w-3 h-3 text-emerald-700`}),(0,D.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,D.jsx)(`input`,{type:`text`,value:n.repoName,onChange:e=>{let t=e.target.value;v(e=>({...e,repoName:t})),m({repoName:t})},placeholder:`algospaced-solutions`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,D.jsx)(`input`,{type:`text`,value:n.branch,onChange:e=>{let t=e.target.value;v(e=>({...e,branch:t})),m({branch:t})},placeholder:`main`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]})]}),(0,D.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,D.jsx)(x,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,D.jsx)(`span`,{className:`text-[10px] text-trash-gray font-medium`,children:`Automatically push code to your repo when grading a review card or saving a solution.`})]})]}),(0,D.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,D.jsx)(`div`,{className:`w-9 h-5 bg-slate-300 peer-focus:outline-none border-2 border-ink-black rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-2 after:border-ink-black after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500`})]})]})]}),(0,D.jsxs)(`div`,{className:`bg-[#fffdf0] border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,D.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,D.jsx)(S,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,D.jsxs)(`button`,{onClick:$,disabled:W||!t,className:`p-3 bg-white hover:bg-emerald-50 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,D.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,D.jsx)(b,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,D.jsx)(w,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),t?.problem_number&&(0,D.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,t.problem_number]})]}),(0,D.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:t?.name||`No active problem open in review`})]}),(0,D.jsxs)(`button`,{onClick:Q,disabled:H,className:`p-3 bg-[#ffe24c] hover:bg-yellow-300 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,D.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,D.jsx)(b,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,D.jsx)(g,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,D.jsx)(`span`,{className:`text-[8px] font-arcade uppercase font-bold bg-white px-1.5 py-0.5 border border-ink-black`,children:`BATCH`})]}),(0,D.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-5 sm:p-6 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] text-center space-y-4`,children:[(0,D.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,D.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,D.jsx)(`p`,{className:`text-xs text-trash-gray font-medium leading-relaxed m-0`,children:`Sync all your DSA solutions directly to your GitHub repository. Commit automatically on review completion or push anytime with 1-click.`})]}),(0,D.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,D.jsx)(`button`,{onClick:Y,disabled:I,className:`w-full sm:w-auto px-6 py-3 bg-[#24292e] hover:bg-black text-white font-bold text-xs uppercase font-headline-md border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center gap-2.5 transition-all cursor-pointer disabled:opacity-50`,children:I?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(b,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,D.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})}),(0,D.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,D.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,D.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,D.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>N(!M),className:`w-full flex items-center justify-between text-left text-xs font-bold text-ink-black font-headline-md uppercase cursor-pointer bg-transparent border-0 p-0`,children:[(0,D.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,D.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,D.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,D.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,D.jsxs)(`a`,{href:`https://github.com/settings/tokens/new?scopes=repo&description=AlgoSpaced%20Solutions%20Sync`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 font-bold flex items-center gap-1 no-underline text-[10px]`,children:[(0,D.jsx)(`span`,{children:`Generate token with repo scope`}),(0,D.jsx)(i,{className:`w-3 h-3`})]})]}),(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`input`,{type:P?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`ghp_... or github_pat_...`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-2 pl-3 pr-9 text-xs font-mono focus:outline-none focus:bg-white`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>F(!P),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-ink-black cursor-pointer bg-transparent border-0 p-1`,children:P?(0,D.jsx)(c,{className:`w-3.5 h-3.5`}):(0,D.jsx)(s,{className:`w-3.5 h-3.5`})})]}),(0,D.jsx)(`button`,{onClick:X,disabled:R||!A.trim(),className:`px-4 py-2 bg-[#ffe24c] hover:bg-yellow-300 text-ink-black font-bold text-xs uppercase border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:R?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(b,{className:`w-3.5 h-3.5 animate-spin`}),(0,D.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(_,{className:`w-3.5 h-3.5`}),(0,D.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,D.jsxs)(`div`,{className:`p-3 border-[2px] border-ink-black text-xs font-semibold rounded flex items-center justify-between gap-2 ${K.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-600`:K.type===`error`?`bg-rose-100 text-rose-900 border-rose-600`:`bg-sky-100 text-sky-900 border-sky-600`}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,D.jsx)(y,{className:`w-4 h-4 shrink-0`}):(0,D.jsx)(r,{className:`w-4 h-4 shrink-0`}),(0,D.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,D.jsxs)(`a`,{href:K.linkUrl,target:`_blank`,rel:`noopener noreferrer`,className:`px-2 py-0.5 bg-white border border-ink-black text-[10px] font-bold text-ink-black hover:bg-slate-50 no-underline shrink-0 flex items-center gap-1`,children:[(0,D.jsx)(`span`,{children:`Open`}),(0,D.jsx)(i,{className:`w-3 h-3`})]})]})]}),(0,D.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,D.jsx)(`button`,{onClick:e,className:`px-4 py-2 bg-white hover:bg-slate-100 border-[2px] border-ink-black text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase`,children:`CLOSE`})})]})};export{O as GitHubSyncWindow,O as default};
|
algospaced-ui/dist/assets/{JourneyPath-DytnV8uO.js → JourneyPath-B98APTO3.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/{MarkdownRenderer-DcpmP1uN.js → MarkdownRenderer-O4K5H8Fp.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import"./index-
|
| 2 |
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
| 3 |
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
| 4 |
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
|
|
| 1 |
+
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import"./index-Bz1BMWr8.js";var r=t(e(),1),i=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},a=/([A-Z])/g,o=e=>e.replace(a,`-$1`).toLowerCase(),s={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},c=/[&><"']/g,l=e=>String(e).replace(c,e=>s[e]),u=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?u(e.body[0]):e:e.type===`font`?u(e.body):e,d=new Set([`mathord`,`textord`,`atom`]),f=e=>d.has(u(e).type),p=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},m={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function h(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function g(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:h(Array.isArray(e.type)?e.type[0]:e.type)}function _(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?g(r):a?a(i):i}var v=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(m)){var n=m[t];n&&_(this,t,e,n)}}reportNonstrict(e,t,n){var r=this.strict;if(typeof r==`function`&&(r=r(e,t,n)),r&&r!==`ignore`){if(r===!0||r===`error`)throw new i(`LaTeX-incompatible input and strict mode is set to 'error': `+(t+` [`+e+`]`),n);r===`warn`?typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)):typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`))}}useStrictBehavior(e,t,n){var r=this.strict;if(typeof r==`function`)try{r=r(e,t,n)}catch{r=`error`}return!r||r===`ignore`?!1:r===!0||r===`error`?!0:r===`warn`?(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)),!1):(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`)),!1)}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=p(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},y=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return te[ne[this.id]]}sub(){return te[re[this.id]]}fracNum(){return te[ie[this.id]]}fracDen(){return te[ae[this.id]]}cramp(){return te[oe[this.id]]}text(){return te[se[this.id]]}isTight(){return this.size>=2}},b=0,x=1,S=2,C=3,w=4,T=5,E=6,ee=7,te=[new y(b,0,!1),new y(x,0,!0),new y(S,1,!1),new y(C,1,!0),new y(w,2,!1),new y(T,2,!0),new y(E,3,!1),new y(ee,3,!0)],ne=[w,T,w,T,E,ee,E,ee],re=[T,T,T,T,ee,ee,ee,ee],ie=[S,C,w,T,E,ee,E,ee],ae=[C,C,T,T,ee,ee,ee,ee],oe=[x,x,C,C,T,T,ee,ee],se=[b,x,S,C,S,C,S,C],D={DISPLAY:te[b],TEXT:te[S],SCRIPT:te[w],SCRIPTSCRIPT:te[E]},ce=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function le(e){for(var t=0;t<ce.length;t++)for(var n=ce[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var ue=[];ce.forEach(e=>e.blocks.forEach(e=>ue.push(...e)));function de(e){for(var t=0;t<ue.length;t+=2)if(e>=ue[t]&&e<=ue[t+1])return!0;return!1}var O=e=>e+` `+e,fe=80,pe=function(e,t){return`M95,`+(622+e+t)+`
|
| 2 |
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
| 3 |
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
| 4 |
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
algospaced-ui/dist/assets/{PrincessChamber-BzhzFHRQ.js → PrincessChamber-b4TXNjIa.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,c as t,s as n,t as r}from"./jsx-runtime-j9uSgrFF.js";import{A as i,C as a,D as o,E as s,G as c,I as l,O as u,P as d,S as f,T as p,W as m,_ as h,b as g,j as _,v,w as y,x as b,y as x,z as S}from"./index-M1GCaKIP.js";var C=c(`castle`,[[`path`,{d:`M10 5V3`,key:`1y54qe`}],[`path`,{d:`M14 5V3`,key:`m6isi`}],[`path`,{d:`M15 21v-3a3 3 0 0 0-6 0v3`,key:`lbp5hj`}],[`path`,{d:`M18 3v8`,key:`2ollhf`}],[`path`,{d:`M18 5H6`,key:`98imr9`}],[`path`,{d:`M22 11H2`,key:`1lmjae`}],[`path`,{d:`M22 9v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9`,key:`1rly83`}],[`path`,{d:`M6 3v8`,key:`csox7g`}]]),w=c(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),T=c(`rotate-ccw-clock`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),E=c(`scroll`,[[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),D=c(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),O=c(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),k=t(e(),1),A={1:{particleType:`pollen`,particleCount:16,particleColors:[`#FDE047`,`#FEF08A`,`#86EFAC`],gradientBg:`from-[#FFFDF0] via-[#FFF9E6] to-[#FEF3C7]`,glowColor:`rgba(251, 191, 36, 0.3)`,badgeLabel:`🌾 Plains Breeze`},2:{particleType:`leaves`,particleCount:18,particleColors:[`#86EFAC`,`#4ADE80`,`#22C55E`,`#A7F3D0`],gradientBg:`from-[#F0FDF4] via-[#DCFCE7] to-[#FEF9C3]`,glowColor:`rgba(34, 197, 94, 0.3)`,badgeLabel:`🍃 Whispering Leaves`},3:{particleType:`spores`,particleCount:22,particleColors:[`#67E8F9`,`#38BDF8`,`#818CF8`,`#C084FC`],gradientBg:`from-[#F0F9FF] via-[#E0F2FE] to-[#EDE9FE]`,glowColor:`rgba(56, 189, 248, 0.35)`,badgeLabel:`✨ Crystal Spores`},4:{particleType:`snow`,particleCount:28,particleColors:[`#FFFFFF`,`#E0F2FE`,`#BAE6FD`],gradientBg:`from-[#F8FAFC] via-[#F1F5F9] to-[#E2E8F0]`,glowColor:`rgba(186, 230, 253, 0.4)`,badgeLabel:`❄️ Alpine Snowfall`},5:{particleType:`runes`,particleCount:20,particleColors:[`#E879F9`,`#C084FC`,`#A855F7`,`#F472B6`],gradientBg:`from-[#FAF5FF] via-[#F3E8FF] to-[#FCE7F3]`,glowColor:`rgba(192, 132, 252, 0.4)`,badgeLabel:`🔮 Arcane Runes`},6:{particleType:`stardust`,particleCount:35,particleColors:[`#FDE047`,`#F59E0B`,`#E11D48`,`#818CF8`],gradientBg:`from-[#FFFBEB] via-[#FEF3C7] to-[#FFE4E6]`,glowColor:`rgba(245, 158, 11, 0.5)`,badgeLabel:`👑 Spire Gates`}};function j(e){return e<=30?A[1]:e<=60?A[2]:e<=90?A[3]:e<=120?A[4]:e<150?A[5]:A[6]}var M=r();function N({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1}){let a=g[e]||g.smiling_warmly,o=(0,k.useMemo)(()=>j(t),[t]),s=(0,k.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/40 via-yellow-300/30 to-rose-300/20`;case`dusk`:return`from-orange-400/40 via-purple-400/30 to-amber-300/20`;case`night`:return`from-indigo-600/40 via-blue-500/30 to-amber-500/20`;default:return`from-amber-400/30 via-yellow-300/40 to-indigo-400/30`}},[n]);return(0,M.jsxs)(`div`,{className:`relative flex flex-col items-center justify-center my-auto w-full max-w-xl`,children:[(0,M.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(18,o.particleCount)}).map((e,t)=>{let n=o.particleColors[t%o.particleColors.length],r=`${t*19%100}%`,i=`${6+t%5*2}s`,a=`${t*.7%4}s`,s=o.particleType===`leaves`||o.particleType===`runes`?`w-2.5 h-2.5`:`w-1.5 h-1.5`;return(0,M.jsx)(`span`,{className:`absolute rounded-full opacity-65 animate-pulse ${s}`,style:{backgroundColor:n,left:r,top:`${t*23%90}%`,boxShadow:`0 0 8px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,M.jsxs)(`div`,{className:`relative group z-10`,children:[(0,M.jsx)(`div`,{className:`absolute -inset-2 bg-gradient-to-r ${s} rounded-2xl blur-md opacity-80 group-hover:opacity-100 transition duration-500`}),(0,M.jsxs)(`div`,{className:`relative w-36 h-44 sm:w-44 sm:h-52 bg-gradient-to-b from-amber-100 to-amber-200 border-[3px] border-ink-black rounded-xl overflow-hidden shadow-[4px_4px_0px_0px_#1E293B] transition-transform duration-300 flex items-center justify-center`,children:[(0,M.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-amber-700/40 pointer-events-none select-none`,children:[(0,M.jsx)(_,{className:`w-8 h-8 animate-pulse`}),(0,M.jsx)(`span`,{className:`font-arcade text-[10px] mt-2`,children:`Princess Aurelia`})]}),(0,M.jsx)(`img`,{src:a.imagePath,alt:a.label,loading:`eager`,className:`w-full h-full object-cover object-top transition-all duration-300 relative z-10 ${i?`scale-105 filter saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/neutral.png`)?t.style.display=`none`:t.src=`/sprites/princess/neutral.png`}}),(0,M.jsxs)(`div`,{className:`absolute bottom-0 inset-x-0 bg-ink-black/85 backdrop-blur-xs text-[10px] text-amber-300 py-1 px-2 font-bold uppercase tracking-wider text-center flex items-center justify-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${i?`bg-amber-400 animate-ping`:`bg-emerald-400`}`}),(0,M.jsx)(`span`,{children:i?`Pondering...`:a.label})]})]}),(0,M.jsx)(`div`,{className:`absolute -top-2 -right-2 bg-[#FFE24C] border-[2px] border-ink-black rounded-full p-1 shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,M.jsx)(_,{className:`w-3.5 h-3.5 text-amber-800`})})]}),r&&(0,M.jsx)(`div`,{className:`mt-2 text-center max-w-sm px-2`,children:(0,M.jsxs)(`span`,{className:`text-[10px] font-semibold text-slate-700 bg-white/85 px-2.5 py-0.5 rounded-full border border-ink-black/20 shadow-xs inline-flex items-center gap-1`,children:[(0,M.jsx)(`span`,{children:`🏰`}),(0,M.jsx)(`span`,{className:`truncate`,children:r})]})})]})}function P({text:e,characterName:t,emotion:n,isLoading:r=!1,isStreaming:i=!1,toolCalls:a,onTypingStatusChange:o}){let[s,c]=(0,k.useState)(e),[l,u]=(0,k.useState)(!1),d=(0,k.useRef)(null),f=(0,k.useRef)(e),p=(0,k.useRef)(0),m=(0,k.useRef)(o);(0,k.useEffect)(()=>{m.current=o},[o]);let h=g[n]||g.smiling_warmly,_=e=>{u(e),m.current?.(e)};return(0,k.useEffect)(()=>{if(i){d.current&&clearInterval(d.current),c(e),_(!0),e.length-p.current>=4&&(p.current=e.length,v(e.length)),f.current=e;return}if(e!==f.current&&!r){let t=f.current.length>0&&e.startsWith(f.current);if(f.current=e,d.current&&clearInterval(d.current),t)c(e),_(!1);else{c(``),_(!0);let t=0;d.current=setInterval(()=>{t<e.length?(t++,c(e.slice(0,t)),t%2==0&&e[t-1]!==` `&&v(t)):(d.current&&clearInterval(d.current),_(!1))},22)}}else!r&&e===f.current&&!i&&(c(e),l&&_(!1));return()=>{d.current&&clearInterval(d.current)}},[e,r,i]),(0,M.jsxs)(`div`,{onClick:()=>{l&&(d.current&&clearInterval(d.current),c(e),_(!1))},className:`w-full max-w-xl mt-3 sm:mt-4 relative bg-white border-[3px] border-ink-black rounded-xl p-3.5 sm:p-4 shadow-[4px_4px_0px_0px_#1E293B] transition-all cursor-pointer group select-text`,children:[(0,M.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 w-0 h-0 border-x-8 border-x-transparent border-b-8 border-b-ink-black pointer-events-none`}),(0,M.jsx)(`div`,{className:`absolute -top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-x-6 border-x-transparent border-b-6 border-b-white pointer-events-none`}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-amber-100 pb-1.5 mb-2 select-none`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsxs)(`span`,{className:`font-headline-md font-bold text-xs text-amber-900 flex items-center gap-1`,children:[`👑 `,t||`Princess Aurelia`]}),(0,M.jsx)(`span`,{className:`text-[9px] bg-amber-100 text-amber-800 font-bold px-1.5 py-0.2 rounded border border-amber-200`,children:h.label})]}),l&&(0,M.jsx)(`span`,{className:`text-[9px] text-trash-gray font-medium animate-pulse`,children:`Click bubble to skip`})]}),r?(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs font-medium text-trash-gray select-none`,children:[(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce`}),(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce [animation-delay:0.2s]`}),(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce [animation-delay:0.4s]`}),(0,M.jsxs)(`span`,{className:`ml-1 text-slate-600`,children:[t||`Princess Aurelia`,` is attuning the crystal relay...`]})]}):(0,M.jsxs)(`div`,{className:`text-xs sm:text-[13px] text-ink-black font-medium leading-relaxed whitespace-pre-wrap`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,M.jsx)(`span`,{className:`text-amber-700 italic font-semibold mr-1 inline-block`,children:e},t):(0,M.jsx)(`span`,{children:e},t)))(s),l&&(0,M.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-amber-500 ml-1 animate-pulse align-middle`})]}),a&&a.length>0&&!r&&(0,M.jsx)(`div`,{className:`mt-2.5 pt-2 border-t border-amber-100/80 flex flex-wrap gap-1.5 select-none`,children:a.map((e,t)=>{let n=`✨ Enchantment: ${e.name}`;return e.name===`open_app_window`&&(n=`📜 Summoned: ${e.args?.window_id||`Grimoire`}`),e.name===`set_study_timer`&&(n=`⏳ Hourglass: ${e.args?.minutes||15}m rest`),e.name===`play_ambient_sound`&&(n=`🔥 Kindled: ${e.args?.soundscape||`Soundscape`}`),e.name===`write_spire_diary`&&(n=`📖 Chronicled in Spire Diary`),(0,M.jsx)(`span`,{className:`px-2 py-0.5 rounded-full bg-indigo-50 border border-indigo-200 text-[10px] font-bold text-indigo-800 flex items-center gap-1 shadow-xs`,children:(0,M.jsx)(`span`,{children:n})},t)})})]})}var F=[{label:`💪 Solved a Tough One`,prompt:`I just solved a really tough problem! Felt so good getting all test cases to pass.`},{label:`😩 Feeling Stuck`,prompt:`I feel really stuck and discouraged today. It feels like everyone else gets this except me.`},{label:`☕ Need a Breather`,prompt:`My brain is pretty fried from practicing today. Can we just take a short breather?`},{label:`🌙 Life Beyond the Tower`,prompt:`What’s the first thing you want to do once we break the seals and get you out of that tower?`}];function I({suggestions:e,isLoading:t=!1,onSendMessage:n,placeholder:r=`Speak with Princess Aurelia...`}){let[i,a]=(0,k.useState)(``),o=()=>{let e=i.trim();e&&!t&&(n(e),a(``))},s=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())},c=Array.isArray(e)&&e.length>0;return(0,M.jsxs)(`div`,{className:`w-full flex flex-col items-center gap-2 select-none z-10`,children:[(0,M.jsx)(`div`,{className:`w-full max-w-xl flex items-center justify-center gap-1.5 flex-wrap py-1.5 px-2`,children:c?e.map((e,r)=>(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(e),disabled:t,className:`px-2.5 py-1 bg-white hover:bg-amber-100 disabled:opacity-50 border-[1.5px] border-ink-black rounded-full text-[10px] sm:text-[11px] font-bold text-slate-800 cursor-pointer shadow-[1px_1px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1`,children:[(0,M.jsx)(_,{className:`w-3 h-3 text-amber-600 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate max-w-[200px]`,children:e})]},r)):F.map((e,r)=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>n(e.prompt),disabled:t,className:`px-2.5 py-1 bg-white hover:bg-amber-100 disabled:opacity-50 border-[1.5px] border-ink-black rounded-full text-[10px] sm:text-[11px] font-bold text-slate-800 cursor-pointer shadow-[1px_1px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all`,children:e.label},r))}),(0,M.jsxs)(`div`,{className:`w-full bg-white border-t-[3px] border-ink-black p-3 sm:px-4 flex items-center gap-2 shrink-0`,children:[(0,M.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:s,disabled:t,placeholder:r,className:`flex-1 bg-[#FFFDF0] border-[2px] border-ink-black rounded-lg px-3.5 py-2 text-xs sm:text-sm font-medium text-ink-black placeholder-slate-400 focus:outline-none focus:border-amber-500 shadow-inner disabled:opacity-50`}),(0,M.jsxs)(`button`,{type:`button`,onClick:o,disabled:t||!i.trim(),className:`px-4 sm:px-5 py-2 bg-[#FFE24C] hover:bg-yellow-300 disabled:opacity-50 border-[2px] border-ink-black rounded-lg font-bold text-xs sm:text-sm text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,children:[(0,M.jsx)(D,{className:`w-3.5 h-3.5`}),(0,M.jsx)(`span`,{children:`Send`})]})]})]})}function L({currentFloor:e,onClose:t}){let n=y(e),r=Math.min(100,Math.round(e/150*100));return(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:t,children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl p-4 sm:p-5 max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col gap-3.5`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(C,{className:`w-5 h-5 text-indigo-600`}),(0,M.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Big-O Spire`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(s,{className:`w-4 h-4`})})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,M.jsx)(`span`,{children:`Path Progress:`}),(0,M.jsxs)(`span`,{className:`font-arcade bg-indigo-100 text-indigo-900 px-2 py-0.5 rounded border border-indigo-300`,children:[e,` / 150 Leagues`]})]}),(0,M.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,M.jsx)(`div`,{className:`bg-gradient-to-r from-amber-400 via-yellow-400 to-emerald-400 h-full rounded-full transition-all duration-500`,style:{width:`${r}%`}})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,M.jsxs)(`span`,{children:[`Progress: `,(0,M.jsxs)(`strong`,{children:[r,`%`]})]}),(0,M.jsxs)(`span`,{children:[`Distance to Tower: `,(0,M.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[2px] border-ink-black rounded-lg p-3 shadow-[2px_2px_0px_0px_#1E293B] flex flex-col gap-1`,children:[(0,M.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,M.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,M.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,M.jsxs)(`div`,{className:`text-[10px] text-amber-900 bg-amber-50 p-1.5 rounded border border-amber-200 italic mt-1`,children:[`📜 `,n.bgLore]})]}),(0,M.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Arrays`},{floor:60,label:`Pointers`},{floor:90,label:`Trees`},{floor:120,label:`Heaps`},{floor:150,label:`Spire`}].map(t=>{let n=e>=t.floor;return(0,M.jsxs)(`div`,{className:`flex-1 p-1.5 rounded border text-[10px] flex flex-col items-center ${n?`bg-emerald-100 border-emerald-600 text-emerald-900 font-bold`:`bg-slate-100 border-slate-300 text-slate-500`}`,children:[(0,M.jsx)(`span`,{children:n?`✓`:t.floor}),(0,M.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,M.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Done`})})]})})}function R({unlockedLetters:e,spireChronicles:t,currentFloor:n,heroCodex:r,episodicEvents:o,recentToolTelemetry:c,onRemoveCodexItem:u,onClose:d}){let[f,h]=(0,k.useState)(`letters`),[g,v]=(0,k.useState)(e[e.length-1]||null);return(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/50 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:d,children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[85%] max-h-[560px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(E,{className:`w-5 h-5 text-amber-700`}),(0,M.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:d,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(s,{className:`w-4 h-4`})})]}),(0,M.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>h(`letters`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${f===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(E,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>h(`diary`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${f===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(m,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>h(`codex`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer ${f===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(_,{className:`w-3.5 h-3.5 text-amber-700`}),(0,M.jsx)(`span`,{children:`Codex`})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[f===`letters`&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,M.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=a[e],r=n>=e,i=g?.floor===e;return(0,M.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&v(t),className:`px-3 py-1 rounded-full text-[11px] font-bold border-[1.5px] border-ink-black flex items-center gap-1 shrink-0 transition-all cursor-pointer ${r?i?`bg-[#FFE24C] text-ink-black shadow-[1.5px_1.5px_0px_0px_#1E293B]`:`bg-white hover:bg-amber-100 text-slate-800`:`opacity-40 bg-slate-200 text-slate-500 cursor-not-allowed`}`,children:[r?(0,M.jsx)(`span`,{children:`📜`}):(0,M.jsx)(l,{className:`w-3 h-3`}),(0,M.jsxs)(`span`,{children:[`League `,e]})]},e)})}),g?(0,M.jsxs)(`div`,{className:`bg-[#FFF9E6] border-[2px] border-amber-900/40 rounded-lg p-4 shadow-sm flex-1 overflow-y-auto custom-scrollbar flex flex-col select-text`,children:[(0,M.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[g.chapterTitle,` • League `,g.floor]}),(0,M.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:g.title})]}),(0,M.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,M.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:g.letterText})]}):(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,M.jsx)(l,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,M.jsx)(`p`,{className:`text-xs font-medium`,children:`Conquer 30 LeetCode problems along the path to receive your first Royal Missive from Aurelia.`})]})]}),f===`diary`&&(0,M.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,M.jsxs)(`div`,{className:`p-3 bg-white border-[1.5px] border-ink-black rounded-lg shadow-xs flex flex-col gap-1 select-text`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,M.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,M.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,M.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,M.jsx)(m,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,M.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her Spire Chronicles autonomously as you chat, rest, and cross chapter milestones.`})]})}),f===`codex`&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsx)(_,{className:`w-4 h-4 text-amber-600`}),(0,M.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,M.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,M.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:r?.heroName||`Champion`})]}),(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,M.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:r?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),r?.preferredLanguage&&(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,M.jsx)(`span`,{className:`font-bold text-ink-black`,children:r.preferredLanguage})]})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,M.jsx)(S,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Mastered Patterns (`,r?.strengths?.length||0,`)`]})]}),r?.strengths&&r.strengths.length>0?(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.strengths.map(e=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-300`,children:[e,u&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>u(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,M.jsx)(s,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note topics you conquer during your practice.`})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,M.jsx)(O,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Nemesis Patterns (`,r?.nemesisPatterns?.length||0,`)`]})]}),r?.nemesisPatterns&&r.nemesisPatterns.length>0?(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.nemesisPatterns.map(e=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-rose-50 text-rose-800 border border-rose-300`,children:[e,u&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>u(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,M.jsx)(s,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks patterns that give you trouble to help you prepare targeted drills.`})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,M.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,r?.personalNotes?.length||0,`)`]})}),r?.personalNotes&&r.personalNotes.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.personalNotes.map(e=>(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-2 bg-slate-50 border border-slate-200 rounded text-[11px] text-slate-700`,children:[(0,M.jsxs)(`span`,{children:[`• `,e]}),u&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>u(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,M.jsx)(i,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Share your background or routine with Aurelia and she will hold it in her memory.`})]}),o&&o.length>0&&(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,M.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,M.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[o.length,` events`]})]}),(0,M.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:o.slice(0,8).map(e=>(0,M.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`span`,{className:`font-bold text-ink-black uppercase text-[9px] px-1.5 py-0.5 bg-amber-200/60 rounded`,children:e.eventType.replace(`_`,` `)}),(0,M.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,M.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,M.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,M.jsx)(p,{className:`w-3.5 h-3.5 text-amber-500`}),(0,M.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,M.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[c?.length||0,` executed`]})]}),c&&c.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:c.slice(0,10).map((e,t)=>(0,M.jsxs)(`div`,{className:`text-[11px] p-2 bg-indigo-50/50 border border-indigo-100 rounded flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsxs)(`span`,{className:`font-bold text-indigo-950 font-mono text-[10px] truncate`,children:[e.tool_name,`()`]}),e.args&&Object.keys(e.args).length>0&&(0,M.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,M.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,M.jsx)(w,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,M.jsx)(`span`,{className:`px-1.5 py-0.2 text-[9px] font-bold rounded ${e.success?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:e.success?`SUCCESS`:`ERR`})]})]},t))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,M.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,M.jsx)(`button`,{type:`button`,onClick:d,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Close`})})]})})}var z=n({default:()=>B});function B(){let e=f(),[t,n]=(0,k.useState)(h()),[r,i]=(0,k.useState)(!1),[a,c]=(0,k.useState)(!1),[l,p]=(0,k.useState)(!1);(0,k.useEffect)(()=>{b.syncWithBackend(),b.triggerProactiveGreeting()},[]);let m=()=>{let e=!t;n(e),x(e)},g=()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&b.clearTranscript()},v=(0,k.useCallback)(e=>{b.setIsTyping(e)},[]),y=(0,k.useMemo)(()=>[...e.transcript].reverse().find(e=>e.sender===`princess`)||e.transcript[0],[e.transcript]);return(0,M.jsxs)(`div`,{className:`relative w-full h-full bg-gradient-to-b from-[#FFFDF0] via-[#FFF9E6] to-[#FFF3CD] flex flex-col select-none font-sans text-ink-black overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`h-12 bg-white/95 backdrop-blur-sm border-b-[3px] border-ink-black px-3 sm:px-4 flex items-center justify-between gap-2 shrink-0 shadow-sm z-20`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,M.jsx)(_,{className:`w-4 h-4 text-amber-500 shrink-0`}),(0,M.jsx)(`h3`,{className:`font-headline-md font-bold text-xs sm:text-sm text-ink-black m-0 truncate`,children:e.companionSettings.name||`Princess Aurelia`})]}),(0,M.jsx)(`span`,{className:`hidden sm:inline-flex px-2 py-0.5 rounded-full bg-amber-100 border border-amber-300 text-[10px] font-bold text-amber-900 shadow-inner shrink-0`,children:e.bondTier}),(0,M.jsx)(`span`,{className:`hidden md:inline-flex px-2 py-0.5 rounded-full bg-indigo-50 border border-indigo-200 text-[10px] font-bold text-indigo-800 shrink-0`,children:e.currentRhythm.toUpperCase()})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`px-2.5 py-1 bg-amber-100 hover:bg-amber-200 border-[2px] border-ink-black rounded font-bold text-[11px] text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1.5`,title:`View Spire Journey Progress`,children:[(0,M.jsx)(C,{className:`w-3.5 h-3.5 text-indigo-700`}),(0,M.jsxs)(`span`,{className:`font-arcade text-[9px] text-indigo-950`,children:[e.currentFloor,`/150 LC`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-50 border-[2px] border-ink-black rounded font-bold text-[11px] text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1.5`,title:`Open Royal Satchel (Missives & Diary)`,children:[(0,M.jsx)(E,{className:`w-3.5 h-3.5 text-amber-700`}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:`Satchel`}),e.unlockedLetters.length>0&&(0,M.jsx)(`span`,{className:`w-4 h-4 rounded-full bg-amber-400 text-ink-black text-[9px] font-extrabold flex items-center justify-center border border-ink-black`,children:e.unlockedLetters.length})]}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`p-1.5 bg-white hover:bg-slate-100 border-[2px] border-ink-black rounded text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all`,title:`View Transcript History`,children:(0,M.jsx)(T,{className:`w-3.5 h-3.5 text-slate-700`})}),(0,M.jsx)(`button`,{type:`button`,onClick:m,className:`p-1.5 border-[2px] border-ink-black rounded text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all ${t?`bg-slate-200 opacity-80`:`bg-[#FFE24C] hover:bg-yellow-300`}`,title:t?`Unmute Audio`:`Mute Audio`,children:t?(0,M.jsx)(o,{className:`w-3.5 h-3.5`}):(0,M.jsx)(u,{className:`w-3.5 h-3.5`})})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-start gap-3 sm:gap-4 p-3 sm:p-5 overflow-y-auto custom-scrollbar min-h-0 relative`,children:[(0,M.jsx)(N,{emotion:e.activeEmotion,floor:e.currentFloor,rhythm:e.currentRhythm,activity:e.currentActivity,isLoading:e.isLoading}),(0,M.jsx)(P,{text:y?.text||`I believe in you, champion!`,characterName:e.companionSettings.name,emotion:e.activeEmotion,isLoading:e.isLoading,isStreaming:y?.isStreaming,toolCalls:y?.toolCalls,onTypingStatusChange:v})]}),(0,M.jsx)(I,{suggestions:y?.choiceSuggestions,isLoading:e.isLoading,onSendMessage:e=>b.sendMessage(e),placeholder:`Speak with ${e.companionSettings.name||`Princess Aurelia`}...`}),r&&(0,M.jsx)(L,{currentFloor:e.currentFloor,totalSolved:e.totalSolved,onClose:()=>i(!1)}),a&&(0,M.jsx)(R,{unlockedLetters:e.unlockedLetters,spireChronicles:e.spireChronicles,currentFloor:e.currentFloor,heroCodex:e.heroCodex,episodicEvents:e.episodicEvents,recentToolTelemetry:e.recentToolTelemetry,onRemoveCodexItem:b.removeCodexItem,onClose:()=>c(!1)}),l&&(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200`,onClick:()=>p(!1),children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(T,{className:`w-4 h-4 text-ink-black`}),(0,M.jsxs)(`h4`,{className:`font-headline-md font-bold text-xs sm:text-sm text-ink-black m-0`,children:[`Dialogue Transcript (`,e.transcript.length,` turns)`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:g,className:`p-1 hover:bg-rose-100 text-rose-700 rounded text-[11px] font-bold flex items-center gap-1 cursor-pointer mr-1`,title:`Clear Chat History`,children:[(0,M.jsx)(d,{className:`w-3.5 h-3.5`}),(0,M.jsx)(`span`,{children:`Clear`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(s,{className:`w-4 h-4`})})]})]}),(0,M.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5`,children:e.transcript.map((t,n)=>(0,M.jsxs)(`div`,{className:`p-2.5 rounded-lg border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] max-w-[90%] ${t.sender===`princess`?`bg-white text-ink-black self-start`:`bg-[#FFE24C] text-ink-black self-end`}`,children:[(0,M.jsx)(`div`,{className:`text-[10px] font-bold font-headline-md mb-1 text-slate-600`,children:t.sender===`princess`?e.companionSettings.name:`Hero`}),(0,M.jsx)(`p`,{className:`text-xs font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:t.text})]},t.id||n))})]})})]})}export{z as t};
|
|
|
|
| 1 |
+
import{a as e,c as t,s as n,t as r}from"./jsx-runtime-j9uSgrFF.js";import{C as i,D as a,H as o,I as s,N as c,O as l,S as u,T as d,V as f,_ as p,b as m,g as h,h as g,j as _,m as v,v as y,w as b,x,y as S}from"./index-Bz1BMWr8.js";var C=o(`castle`,[[`path`,{d:`M10 5V3`,key:`1y54qe`}],[`path`,{d:`M14 5V3`,key:`m6isi`}],[`path`,{d:`M15 21v-3a3 3 0 0 0-6 0v3`,key:`lbp5hj`}],[`path`,{d:`M18 3v8`,key:`2ollhf`}],[`path`,{d:`M18 5H6`,key:`98imr9`}],[`path`,{d:`M22 11H2`,key:`1lmjae`}],[`path`,{d:`M22 9v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9`,key:`1rly83`}],[`path`,{d:`M6 3v8`,key:`csox7g`}]]),w=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),T=o(`rotate-ccw-clock`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),E=o(`scroll`,[[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),D=o(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),O=o(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),k=t(e(),1),A={1:{particleType:`pollen`,particleCount:16,particleColors:[`#FDE047`,`#FEF08A`,`#86EFAC`],gradientBg:`from-[#FFFDF0] via-[#FFF9E6] to-[#FEF3C7]`,glowColor:`rgba(251, 191, 36, 0.3)`,badgeLabel:`🌾 Plains Breeze`},2:{particleType:`leaves`,particleCount:18,particleColors:[`#86EFAC`,`#4ADE80`,`#22C55E`,`#A7F3D0`],gradientBg:`from-[#F0FDF4] via-[#DCFCE7] to-[#FEF9C3]`,glowColor:`rgba(34, 197, 94, 0.3)`,badgeLabel:`🍃 Whispering Leaves`},3:{particleType:`spores`,particleCount:22,particleColors:[`#67E8F9`,`#38BDF8`,`#818CF8`,`#C084FC`],gradientBg:`from-[#F0F9FF] via-[#E0F2FE] to-[#EDE9FE]`,glowColor:`rgba(56, 189, 248, 0.35)`,badgeLabel:`✨ Crystal Spores`},4:{particleType:`snow`,particleCount:28,particleColors:[`#FFFFFF`,`#E0F2FE`,`#BAE6FD`],gradientBg:`from-[#F8FAFC] via-[#F1F5F9] to-[#E2E8F0]`,glowColor:`rgba(186, 230, 253, 0.4)`,badgeLabel:`❄️ Alpine Snowfall`},5:{particleType:`runes`,particleCount:20,particleColors:[`#E879F9`,`#C084FC`,`#A855F7`,`#F472B6`],gradientBg:`from-[#FAF5FF] via-[#F3E8FF] to-[#FCE7F3]`,glowColor:`rgba(192, 132, 252, 0.4)`,badgeLabel:`🔮 Arcane Runes`},6:{particleType:`stardust`,particleCount:35,particleColors:[`#FDE047`,`#F59E0B`,`#E11D48`,`#818CF8`],gradientBg:`from-[#FFFBEB] via-[#FEF3C7] to-[#FFE4E6]`,glowColor:`rgba(245, 158, 11, 0.5)`,badgeLabel:`👑 Spire Gates`}};function j(e){return e<=30?A[1]:e<=60?A[2]:e<=90?A[3]:e<=120?A[4]:e<150?A[5]:A[6]}var M=r();function N({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1}){let a=p[e]||p.smiling_warmly,o=(0,k.useMemo)(()=>j(t),[t]),s=(0,k.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/40 via-yellow-300/30 to-rose-300/20`;case`dusk`:return`from-orange-400/40 via-purple-400/30 to-amber-300/20`;case`night`:return`from-indigo-600/40 via-blue-500/30 to-amber-500/20`;default:return`from-amber-400/30 via-yellow-300/40 to-indigo-400/30`}},[n]);return(0,M.jsxs)(`div`,{className:`relative flex flex-col items-center justify-center my-auto w-full max-w-xl`,children:[(0,M.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(18,o.particleCount)}).map((e,t)=>{let n=o.particleColors[t%o.particleColors.length],r=`${t*19%100}%`,i=`${6+t%5*2}s`,a=`${t*.7%4}s`,s=o.particleType===`leaves`||o.particleType===`runes`?`w-2.5 h-2.5`:`w-1.5 h-1.5`;return(0,M.jsx)(`span`,{className:`absolute rounded-full opacity-65 animate-pulse ${s}`,style:{backgroundColor:n,left:r,top:`${t*23%90}%`,boxShadow:`0 0 8px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,M.jsxs)(`div`,{className:`relative group z-10`,children:[(0,M.jsx)(`div`,{className:`absolute -inset-2 bg-gradient-to-r ${s} rounded-2xl blur-md opacity-80 group-hover:opacity-100 transition duration-500`}),(0,M.jsxs)(`div`,{className:`relative w-36 h-44 sm:w-44 sm:h-52 bg-gradient-to-b from-amber-100 to-amber-200 border-[3px] border-ink-black rounded-xl overflow-hidden shadow-[4px_4px_0px_0px_#1E293B] transition-transform duration-300 flex items-center justify-center`,children:[(0,M.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-amber-700/40 pointer-events-none select-none`,children:[(0,M.jsx)(l,{className:`w-8 h-8 animate-pulse`}),(0,M.jsx)(`span`,{className:`font-arcade text-[10px] mt-2`,children:`Princess Aurelia`})]}),(0,M.jsx)(`img`,{src:a.imagePath,alt:a.label,loading:`eager`,className:`w-full h-full object-cover object-top transition-all duration-300 relative z-10 ${i?`scale-105 filter saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/neutral.png`)?t.style.display=`none`:t.src=`/sprites/princess/neutral.png`}}),(0,M.jsxs)(`div`,{className:`absolute bottom-0 inset-x-0 bg-ink-black/85 backdrop-blur-xs text-[10px] text-amber-300 py-1 px-2 font-bold uppercase tracking-wider text-center flex items-center justify-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${i?`bg-amber-400 animate-ping`:`bg-emerald-400`}`}),(0,M.jsx)(`span`,{children:i?`Pondering...`:a.label})]})]}),(0,M.jsx)(`div`,{className:`absolute -top-2 -right-2 bg-[#FFE24C] border-[2px] border-ink-black rounded-full p-1 shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,M.jsx)(l,{className:`w-3.5 h-3.5 text-amber-800`})})]}),r&&(0,M.jsx)(`div`,{className:`mt-2 text-center max-w-sm px-2`,children:(0,M.jsxs)(`span`,{className:`text-[10px] font-semibold text-slate-700 bg-white/85 px-2.5 py-0.5 rounded-full border border-ink-black/20 shadow-xs inline-flex items-center gap-1`,children:[(0,M.jsx)(`span`,{children:`🏰`}),(0,M.jsx)(`span`,{className:`truncate`,children:r})]})})]})}function P({text:e,characterName:t,emotion:n,isLoading:r=!1,isStreaming:i=!1,toolCalls:a,onTypingStatusChange:o}){let[s,c]=(0,k.useState)(e),[l,u]=(0,k.useState)(!1),d=(0,k.useRef)(null),f=(0,k.useRef)(e),m=(0,k.useRef)(0),h=(0,k.useRef)(o);(0,k.useEffect)(()=>{h.current=o},[o]);let _=p[n]||p.smiling_warmly,v=e=>{u(e),h.current?.(e)};return(0,k.useEffect)(()=>{if(i){d.current&&clearInterval(d.current),c(e),v(!0),e.length-m.current>=4&&(m.current=e.length,g(e.length)),f.current=e;return}if(e!==f.current&&!r){let t=f.current.length>0&&e.startsWith(f.current);if(f.current=e,d.current&&clearInterval(d.current),t)c(e),v(!1);else{c(``),v(!0);let t=0;d.current=setInterval(()=>{t<e.length?(t++,c(e.slice(0,t)),t%2==0&&e[t-1]!==` `&&g(t)):(d.current&&clearInterval(d.current),v(!1))},22)}}else!r&&e===f.current&&!i&&(c(e),l&&v(!1));return()=>{d.current&&clearInterval(d.current)}},[e,r,i]),(0,M.jsxs)(`div`,{onClick:()=>{l&&(d.current&&clearInterval(d.current),c(e),v(!1))},className:`w-full max-w-xl mt-3 sm:mt-4 relative bg-white border-[3px] border-ink-black rounded-xl p-3.5 sm:p-4 shadow-[4px_4px_0px_0px_#1E293B] transition-all cursor-pointer group select-text`,children:[(0,M.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 w-0 h-0 border-x-8 border-x-transparent border-b-8 border-b-ink-black pointer-events-none`}),(0,M.jsx)(`div`,{className:`absolute -top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-x-6 border-x-transparent border-b-6 border-b-white pointer-events-none`}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-amber-100 pb-1.5 mb-2 select-none`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsxs)(`span`,{className:`font-headline-md font-bold text-xs text-amber-900 flex items-center gap-1`,children:[`👑 `,t||`Princess Aurelia`]}),(0,M.jsx)(`span`,{className:`text-[9px] bg-amber-100 text-amber-800 font-bold px-1.5 py-0.2 rounded border border-amber-200`,children:_.label})]}),l&&(0,M.jsx)(`span`,{className:`text-[9px] text-trash-gray font-medium animate-pulse`,children:`Click bubble to skip`})]}),r?(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs font-medium text-trash-gray select-none`,children:[(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce`}),(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce [animation-delay:0.2s]`}),(0,M.jsx)(`span`,{className:`inline-block w-2 h-2 bg-amber-500 rounded-full animate-bounce [animation-delay:0.4s]`}),(0,M.jsxs)(`span`,{className:`ml-1 text-slate-600`,children:[t||`Princess Aurelia`,` is attuning the crystal relay...`]})]}):(0,M.jsxs)(`div`,{className:`text-xs sm:text-[13px] text-ink-black font-medium leading-relaxed whitespace-pre-wrap`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,M.jsx)(`span`,{className:`text-amber-700 italic font-semibold mr-1 inline-block`,children:e},t):(0,M.jsx)(`span`,{children:e},t)))(s),l&&(0,M.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-amber-500 ml-1 animate-pulse align-middle`})]}),a&&a.length>0&&!r&&(0,M.jsx)(`div`,{className:`mt-2.5 pt-2 border-t border-amber-100/80 flex flex-wrap gap-1.5 select-none`,children:a.map((e,t)=>{let n=`✨ Enchantment: ${e.name}`;return e.name===`open_app_window`&&(n=`📜 Summoned: ${e.args?.window_id||`Grimoire`}`),e.name===`set_study_timer`&&(n=`⏳ Hourglass: ${e.args?.minutes||15}m rest`),e.name===`play_ambient_sound`&&(n=`🔥 Kindled: ${e.args?.soundscape||`Soundscape`}`),e.name===`write_spire_diary`&&(n=`📖 Chronicled in Spire Diary`),(0,M.jsx)(`span`,{className:`px-2 py-0.5 rounded-full bg-indigo-50 border border-indigo-200 text-[10px] font-bold text-indigo-800 flex items-center gap-1 shadow-xs`,children:(0,M.jsx)(`span`,{children:n})},t)})})]})}var F=[{label:`💪 Solved a Tough One`,prompt:`I just solved a really tough problem! Felt so good getting all test cases to pass.`},{label:`😩 Feeling Stuck`,prompt:`I feel really stuck and discouraged today. It feels like everyone else gets this except me.`},{label:`☕ Need a Breather`,prompt:`My brain is pretty fried from practicing today. Can we just take a short breather?`},{label:`🌙 Life Beyond the Tower`,prompt:`What’s the first thing you want to do once we break the seals and get you out of that tower?`}];function I({suggestions:e,isLoading:t=!1,onSendMessage:n,placeholder:r=`Speak with Princess Aurelia...`}){let[i,a]=(0,k.useState)(``),o=()=>{let e=i.trim();e&&!t&&(n(e),a(``))},s=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())},c=Array.isArray(e)&&e.length>0;return(0,M.jsxs)(`div`,{className:`w-full flex flex-col items-center gap-2 select-none z-10`,children:[(0,M.jsx)(`div`,{className:`w-full max-w-xl flex items-center justify-center gap-1.5 flex-wrap py-1.5 px-2`,children:c?e.map((e,r)=>(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(e),disabled:t,className:`px-2.5 py-1 bg-white hover:bg-amber-100 disabled:opacity-50 border-[1.5px] border-ink-black rounded-full text-[10px] sm:text-[11px] font-bold text-slate-800 cursor-pointer shadow-[1px_1px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1`,children:[(0,M.jsx)(l,{className:`w-3 h-3 text-amber-600 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate max-w-[200px]`,children:e})]},r)):F.map((e,r)=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>n(e.prompt),disabled:t,className:`px-2.5 py-1 bg-white hover:bg-amber-100 disabled:opacity-50 border-[1.5px] border-ink-black rounded-full text-[10px] sm:text-[11px] font-bold text-slate-800 cursor-pointer shadow-[1px_1px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all`,children:e.label},r))}),(0,M.jsxs)(`div`,{className:`w-full bg-white border-t-[3px] border-ink-black p-3 sm:px-4 flex items-center gap-2 shrink-0`,children:[(0,M.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:s,disabled:t,placeholder:r,className:`flex-1 bg-[#FFFDF0] border-[2px] border-ink-black rounded-lg px-3.5 py-2 text-xs sm:text-sm font-medium text-ink-black placeholder-slate-400 focus:outline-none focus:border-amber-500 shadow-inner disabled:opacity-50`}),(0,M.jsxs)(`button`,{type:`button`,onClick:o,disabled:t||!i.trim(),className:`px-4 sm:px-5 py-2 bg-[#FFE24C] hover:bg-yellow-300 disabled:opacity-50 border-[2px] border-ink-black rounded-lg font-bold text-xs sm:text-sm text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,children:[(0,M.jsx)(D,{className:`w-3.5 h-3.5`}),(0,M.jsx)(`span`,{children:`Send`})]})]})]})}function L({currentFloor:e,onClose:t}){let n=x(e),r=Math.min(100,Math.round(e/150*100));return(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:t,children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl p-4 sm:p-5 max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col gap-3.5`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(C,{className:`w-5 h-5 text-indigo-600`}),(0,M.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Big-O Spire`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(i,{className:`w-4 h-4`})})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,M.jsx)(`span`,{children:`Path Progress:`}),(0,M.jsxs)(`span`,{className:`font-arcade bg-indigo-100 text-indigo-900 px-2 py-0.5 rounded border border-indigo-300`,children:[e,` / 150 Leagues`]})]}),(0,M.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,M.jsx)(`div`,{className:`bg-gradient-to-r from-amber-400 via-yellow-400 to-emerald-400 h-full rounded-full transition-all duration-500`,style:{width:`${r}%`}})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,M.jsxs)(`span`,{children:[`Progress: `,(0,M.jsxs)(`strong`,{children:[r,`%`]})]}),(0,M.jsxs)(`span`,{children:[`Distance to Tower: `,(0,M.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[2px] border-ink-black rounded-lg p-3 shadow-[2px_2px_0px_0px_#1E293B] flex flex-col gap-1`,children:[(0,M.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,M.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,M.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,M.jsxs)(`div`,{className:`text-[10px] text-amber-900 bg-amber-50 p-1.5 rounded border border-amber-200 italic mt-1`,children:[`📜 `,n.bgLore]})]}),(0,M.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Arrays`},{floor:60,label:`Pointers`},{floor:90,label:`Trees`},{floor:120,label:`Heaps`},{floor:150,label:`Spire`}].map(t=>{let n=e>=t.floor;return(0,M.jsxs)(`div`,{className:`flex-1 p-1.5 rounded border text-[10px] flex flex-col items-center ${n?`bg-emerald-100 border-emerald-600 text-emerald-900 font-bold`:`bg-slate-100 border-slate-300 text-slate-500`}`,children:[(0,M.jsx)(`span`,{children:n?`✓`:t.floor}),(0,M.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,M.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Done`})})]})})}function R({unlockedLetters:e,spireChronicles:t,currentFloor:n,heroCodex:r,episodicEvents:o,recentToolTelemetry:d,onRemoveCodexItem:p,onClose:h}){let[g,_]=(0,k.useState)(`letters`),[v,y]=(0,k.useState)(e[e.length-1]||null);return(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/50 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:h,children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[85%] max-h-[560px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(E,{className:`w-5 h-5 text-amber-700`}),(0,M.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:h,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(i,{className:`w-4 h-4`})})]}),(0,M.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>_(`letters`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${g===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(E,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>_(`diary`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${g===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(f,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>_(`codex`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer ${g===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,M.jsx)(l,{className:`w-3.5 h-3.5 text-amber-700`}),(0,M.jsx)(`span`,{children:`Codex`})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[g===`letters`&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,M.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=m[e],r=n>=e,i=v?.floor===e;return(0,M.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&y(t),className:`px-3 py-1 rounded-full text-[11px] font-bold border-[1.5px] border-ink-black flex items-center gap-1 shrink-0 transition-all cursor-pointer ${r?i?`bg-[#FFE24C] text-ink-black shadow-[1.5px_1.5px_0px_0px_#1E293B]`:`bg-white hover:bg-amber-100 text-slate-800`:`opacity-40 bg-slate-200 text-slate-500 cursor-not-allowed`}`,children:[r?(0,M.jsx)(`span`,{children:`📜`}):(0,M.jsx)(c,{className:`w-3 h-3`}),(0,M.jsxs)(`span`,{children:[`League `,e]})]},e)})}),v?(0,M.jsxs)(`div`,{className:`bg-[#FFF9E6] border-[2px] border-amber-900/40 rounded-lg p-4 shadow-sm flex-1 overflow-y-auto custom-scrollbar flex flex-col select-text`,children:[(0,M.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[v.chapterTitle,` • League `,v.floor]}),(0,M.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:v.title})]}),(0,M.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,M.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:v.letterText})]}):(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,M.jsx)(c,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,M.jsx)(`p`,{className:`text-xs font-medium`,children:`Conquer 30 LeetCode problems along the path to receive your first Royal Missive from Aurelia.`})]})]}),g===`diary`&&(0,M.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,M.jsxs)(`div`,{className:`p-3 bg-white border-[1.5px] border-ink-black rounded-lg shadow-xs flex flex-col gap-1 select-text`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,M.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,M.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,M.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,M.jsx)(f,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,M.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her Spire Chronicles autonomously as you chat, rest, and cross chapter milestones.`})]})}),g===`codex`&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsx)(l,{className:`w-4 h-4 text-amber-600`}),(0,M.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,M.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,M.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:r?.heroName||`Champion`})]}),(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,M.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:r?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),r?.preferredLanguage&&(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,M.jsx)(`span`,{className:`font-bold text-ink-black`,children:r.preferredLanguage})]})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,M.jsx)(s,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Mastered Patterns (`,r?.strengths?.length||0,`)`]})]}),r?.strengths&&r.strengths.length>0?(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.strengths.map(e=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-300`,children:[e,p&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>p(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,M.jsx)(i,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note topics you conquer during your practice.`})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,M.jsx)(O,{className:`w-3.5 h-3.5`}),(0,M.jsxs)(`span`,{children:[`Nemesis Patterns (`,r?.nemesisPatterns?.length||0,`)`]})]}),r?.nemesisPatterns&&r.nemesisPatterns.length>0?(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.nemesisPatterns.map(e=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-rose-50 text-rose-800 border border-rose-300`,children:[e,p&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>p(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,M.jsx)(i,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks patterns that give you trouble to help you prepare targeted drills.`})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,M.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,r?.personalNotes?.length||0,`)`]})}),r?.personalNotes&&r.personalNotes.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.personalNotes.map(e=>(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-2 bg-slate-50 border border-slate-200 rounded text-[11px] text-slate-700`,children:[(0,M.jsxs)(`span`,{children:[`• `,e]}),p&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>p(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,M.jsx)(a,{className:`w-3 h-3`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Share your background or routine with Aurelia and she will hold it in her memory.`})]}),o&&o.length>0&&(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,M.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,M.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[o.length,` events`]})]}),(0,M.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:o.slice(0,8).map(e=>(0,M.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`span`,{className:`font-bold text-ink-black uppercase text-[9px] px-1.5 py-0.5 bg-amber-200/60 rounded`,children:e.eventType.replace(`_`,` `)}),(0,M.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,M.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,M.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,M.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,M.jsx)(u,{className:`w-3.5 h-3.5 text-amber-500`}),(0,M.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,M.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[d?.length||0,` executed`]})]}),d&&d.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:d.slice(0,10).map((e,t)=>(0,M.jsxs)(`div`,{className:`text-[11px] p-2 bg-indigo-50/50 border border-indigo-100 rounded flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsxs)(`span`,{className:`font-bold text-indigo-950 font-mono text-[10px] truncate`,children:[e.tool_name,`()`]}),e.args&&Object.keys(e.args).length>0&&(0,M.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,M.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,M.jsx)(w,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,M.jsx)(`span`,{className:`px-1.5 py-0.2 text-[9px] font-bold rounded ${e.success?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:e.success?`SUCCESS`:`ERR`})]})]},t))}):(0,M.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,M.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,M.jsx)(`button`,{type:`button`,onClick:h,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Close`})})]})})}var z=n({default:()=>B});function B(){let e=S(),[t,n]=(0,k.useState)(v()),[r,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(!1),[c,u]=(0,k.useState)(!1);(0,k.useEffect)(()=>{y.syncWithBackend(),y.triggerProactiveGreeting()},[]);let f=()=>{let e=!t;n(e),h(e)},p=()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&y.clearTranscript()},m=(0,k.useCallback)(e=>{y.setIsTyping(e)},[]),g=(0,k.useMemo)(()=>[...e.transcript].reverse().find(e=>e.sender===`princess`)||e.transcript[0],[e.transcript]);return(0,M.jsxs)(`div`,{className:`relative w-full h-full bg-gradient-to-b from-[#FFFDF0] via-[#FFF9E6] to-[#FFF3CD] flex flex-col select-none font-sans text-ink-black overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`h-12 bg-white/95 backdrop-blur-sm border-b-[3px] border-ink-black px-3 sm:px-4 flex items-center justify-between gap-2 shrink-0 shadow-sm z-20`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,M.jsx)(l,{className:`w-4 h-4 text-amber-500 shrink-0`}),(0,M.jsx)(`h3`,{className:`font-headline-md font-bold text-xs sm:text-sm text-ink-black m-0 truncate`,children:e.companionSettings.name||`Princess Aurelia`})]}),(0,M.jsx)(`span`,{className:`hidden sm:inline-flex px-2 py-0.5 rounded-full bg-amber-100 border border-amber-300 text-[10px] font-bold text-amber-900 shadow-inner shrink-0`,children:e.bondTier}),(0,M.jsx)(`span`,{className:`hidden md:inline-flex px-2 py-0.5 rounded-full bg-indigo-50 border border-indigo-200 text-[10px] font-bold text-indigo-800 shrink-0`,children:e.currentRhythm.toUpperCase()})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`px-2.5 py-1 bg-amber-100 hover:bg-amber-200 border-[2px] border-ink-black rounded font-bold text-[11px] text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1.5`,title:`View Spire Journey Progress`,children:[(0,M.jsx)(C,{className:`w-3.5 h-3.5 text-indigo-700`}),(0,M.jsxs)(`span`,{className:`font-arcade text-[9px] text-indigo-950`,children:[e.currentFloor,`/150 LC`]})]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-50 border-[2px] border-ink-black rounded font-bold text-[11px] text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-1.5`,title:`Open Royal Satchel (Missives & Diary)`,children:[(0,M.jsx)(E,{className:`w-3.5 h-3.5 text-amber-700`}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:`Satchel`}),e.unlockedLetters.length>0&&(0,M.jsx)(`span`,{className:`w-4 h-4 rounded-full bg-amber-400 text-ink-black text-[9px] font-extrabold flex items-center justify-center border border-ink-black`,children:e.unlockedLetters.length})]}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`p-1.5 bg-white hover:bg-slate-100 border-[2px] border-ink-black rounded text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all`,title:`View Transcript History`,children:(0,M.jsx)(T,{className:`w-3.5 h-3.5 text-slate-700`})}),(0,M.jsx)(`button`,{type:`button`,onClick:f,className:`p-1.5 border-[2px] border-ink-black rounded text-ink-black cursor-pointer shadow-[1.5px_1.5px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all ${t?`bg-slate-200 opacity-80`:`bg-[#FFE24C] hover:bg-yellow-300`}`,title:t?`Unmute Audio`:`Mute Audio`,children:t?(0,M.jsx)(b,{className:`w-3.5 h-3.5`}):(0,M.jsx)(d,{className:`w-3.5 h-3.5`})})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-start gap-3 sm:gap-4 p-3 sm:p-5 overflow-y-auto custom-scrollbar min-h-0 relative`,children:[(0,M.jsx)(N,{emotion:e.activeEmotion,floor:e.currentFloor,rhythm:e.currentRhythm,activity:e.currentActivity,isLoading:e.isLoading}),(0,M.jsx)(P,{text:g?.text||`I believe in you, champion!`,characterName:e.companionSettings.name,emotion:e.activeEmotion,isLoading:e.isLoading,isStreaming:g?.isStreaming,toolCalls:g?.toolCalls,onTypingStatusChange:m})]}),(0,M.jsx)(I,{suggestions:g?.choiceSuggestions,isLoading:e.isLoading,onSendMessage:e=>y.sendMessage(e),placeholder:`Speak with ${e.companionSettings.name||`Princess Aurelia`}...`}),r&&(0,M.jsx)(L,{currentFloor:e.currentFloor,totalSolved:e.totalSolved,onClose:()=>a(!1)}),o&&(0,M.jsx)(R,{unlockedLetters:e.unlockedLetters,spireChronicles:e.spireChronicles,currentFloor:e.currentFloor,heroCodex:e.heroCodex,episodicEvents:e.episodicEvents,recentToolTelemetry:e.recentToolTelemetry,onRemoveCodexItem:y.removeCodexItem,onClose:()=>s(!1)}),c&&(0,M.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200`,onClick:()=>u(!1),children:(0,M.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(T,{className:`w-4 h-4 text-ink-black`}),(0,M.jsxs)(`h4`,{className:`font-headline-md font-bold text-xs sm:text-sm text-ink-black m-0`,children:[`Dialogue Transcript (`,e.transcript.length,` turns)`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:p,className:`p-1 hover:bg-rose-100 text-rose-700 rounded text-[11px] font-bold flex items-center gap-1 cursor-pointer mr-1`,title:`Clear Chat History`,children:[(0,M.jsx)(_,{className:`w-3.5 h-3.5`}),(0,M.jsx)(`span`,{children:`Clear`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,M.jsx)(i,{className:`w-4 h-4`})})]})]}),(0,M.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5`,children:e.transcript.map((t,n)=>(0,M.jsxs)(`div`,{className:`p-2.5 rounded-lg border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] max-w-[90%] ${t.sender===`princess`?`bg-white text-ink-black self-start`:`bg-[#FFE24C] text-ink-black self-end`}`,children:[(0,M.jsx)(`div`,{className:`text-[10px] font-bold font-headline-md mb-1 text-slate-600`,children:t.sender===`princess`?e.companionSettings.name:`Hero`}),(0,M.jsx)(`p`,{className:`text-xs font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:t.text})]},t.id||n))})]})})]})}export{z as t};
|
algospaced-ui/dist/assets/{PythonChallenge-BP6ASjZJ.js → PythonChallenge-C3lt-s_2.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,c as t,i as n,t as r}from"./jsx-runtime-j9uSgrFF.js";import{t as i}from"./MarkdownRenderer-
|
|
|
|
| 1 |
+
import{a as e,c as t,i as n,t as r}from"./jsx-runtime-j9uSgrFF.js";import{t as i}from"./MarkdownRenderer-O4K5H8Fp.js";var a=t(e(),1),o=r();function s(){let[e,t]=(0,a.useState)(null),[r,s]=(0,a.useState)(``),[c,l]=(0,a.useState)(!1),[u,d]=(0,a.useState)([]),[f,p]=(0,a.useState)(``),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(0),v=async()=>{h(!0),p(``);try{let{data:{session:e}}=await n.auth.getSession();if(!e){p(`Unauthenticated session`);return}let r=await fetch(`/api/challenges/python/daily`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(r.ok){let e=await r.json();t(e),s(e.starter_code),_(e.total_score)}else p(`Failed to load challenge from server.`)}catch{p(`Connection timed out.`)}finally{h(!1)}};return(0,a.useEffect)(()=>{v()},[]),m?(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-arcade text-[10px]`,children:[(0,o.jsx)(`div`,{className:`animate-bounce mb-2`,children:`LOADING CHALLENGE...`}),(0,o.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,o.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#9d4edd] w-2/3 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,o.jsx)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm`,children:(0,o.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3`,children:[(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`span`,{className:`px-2 py-0.5 border-2 border-ink-black font-bold uppercase text-[9px] ${e.difficulty===`Easy`?`bg-green-200 text-green-800`:e.difficulty===`Medium`?`bg-yellow-200 text-yellow-800`:`bg-red-200 text-red-800`}`,children:e.difficulty}),(0,o.jsxs)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,o.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`COMPLETED`}):(0,o.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`INCOMPLETE`})]}),(0,o.jsxs)(`div`,{className:`font-arcade text-[8px] text-purple-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`TOTAL SCORE: `,g]})]}),(0,o.jsxs)(`div`,{className:`border-2 border-ink-black bg-slate-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,o.jsxs)(`h3`,{className:`font-bold border-b border-slate-300 pb-1 mb-2 uppercase tracking-wide text-primary-purple flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`description`}),`Problem: `,e.title]}),(0,o.jsx)(i,{content:e.description})]}),(0,o.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-[220px]`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,o.jsxs)(`span`,{className:`font-bold text-[10px] tracking-wide uppercase flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm text-purple-600`,children:`code`}),`Write Python Solution:`]}),(0,o.jsx)(`button`,{onClick:()=>s(e.starter_code),className:`text-[9px] underline text-blue-600 hover:text-blue-800 cursor-pointer font-sans`,children:`Reset Starter Code`})]}),(0,o.jsx)(`textarea`,{value:r,onChange:e=>s(e.target.value),className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-3 border-[3px] border-ink-black rounded outline-none focus:ring-2 focus:ring-primary-purple text-xs leading-relaxed resize-none`,placeholder:`# Write your python code here`,spellCheck:`false`})]}),(0,o.jsx)(`div`,{className:`shrink-0`,children:(0,o.jsx)(`button`,{disabled:c,onClick:async()=>{l(!0),p(``),d([]);try{let{data:{session:e}}=await n.auth.getSession();if(!e){p(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/python/submit`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({code:r})});if(i.ok){let e=await i.json();e.success?(d(e.results),e.all_passed&&(_(e.total_score),t(e=>e?{...e,completed:!0}:null))):p(e.error)}else p(`Submission failed at server host.`)}catch{p(`Network connection lost.`)}finally{l(!1)}},className:`w-full bg-highlight-pink text-white font-window-title font-bold py-2 px-4 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none hover:bg-pink-400 transition-all disabled:opacity-50 cursor-pointer text-center text-xs`,children:c?`EXECUTING TEST CASES...`:`RUN SOLUTION SUBMISSION`})}),f&&(0,o.jsxs)(`div`,{className:`border-[3px] border-red-500 bg-red-50 text-red-800 p-3 font-mono text-xs whitespace-pre-wrap`,children:[(0,o.jsx)(`div`,{className:`font-bold mb-1`,children:`COMPILER / RUNTIME ERROR:`}),f]}),u.length>0&&(0,o.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-slate-100 p-3`,children:[(0,o.jsx)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 uppercase`,children:`Test Case Executions:`}),(0,o.jsx)(`div`,{className:`space-y-1.5 font-mono text-xs`,children:u.map((e,t)=>(0,o.jsxs)(`div`,{className:`flex flex-col p-2 border border-slate-300 bg-white`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between`,children:[(0,o.jsxs)(`span`,{className:`font-bold`,children:[`Test Case `,t+1,`:`]}),(0,o.jsx)(`span`,{className:`font-bold uppercase ${e.status===`passed`?`text-green-600`:`text-red-600`}`,children:e.status})]}),(0,o.jsxs)(`div`,{className:`text-[10px] text-slate-500 mt-1`,children:[(0,o.jsxs)(`div`,{children:[`Input: `,JSON.stringify(e.input)]}),e.status===`passed`&&(0,o.jsxs)(`div`,{children:[`Output: `,JSON.stringify(e.got)]}),e.status===`failed`&&(0,o.jsxs)(`div`,{className:`text-red-700`,children:[`Expected: `,JSON.stringify(e.expected),` | Got: `,JSON.stringify(e.got)]}),e.status===`error`&&(0,o.jsxs)(`div`,{className:`text-red-700 font-semibold`,children:[`Error: `,e.error]})]})]},t))})]})]})}):(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-sans text-center gap-3`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-red-500 text-4xl`,children:`error`}),(0,o.jsx)(`div`,{className:`font-bold text-ink-black text-sm`,children:f||`No active challenge found.`}),(0,o.jsx)(`button`,{onClick:v,className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 border-[3px] border-ink-black text-xs font-bold font-window-title cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`RETRY`})]})}export{s as default};
|
algospaced-ui/dist/assets/ReviewQueue-BwN6dLvy.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/ReviewQueue-WbUnUC1g.js
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/{Settings-5f8XTRov.js → Settings-Cv6B9KXE.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import{t as r}from"./circle-alert-B3TumjQg.js";import{t as i}from"./external-link-64ub39jt.js";import{a,d as ee,f as o,i as s,n as c,r as l,s as u,t as d,u as f}from"./githubSyncService-B4h5nigj.js";import{t as p}from"./info-jE4ZFn-x.js";import{t as m}from"./save-zS5LwKaW.js";import{F as h,G as g,M as _,P as v,R as y,T as b,f as x,g as S,h as C,j as te,k as ne,m as w,p as T,y as E,z as D}from"./index-M1GCaKIP.js";var O=g(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),k=g(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),A=t(e(),1),j=n(),M=[{id:`default`,name:`Default`,desc:`Subject to Availability`},{id:`groq`,name:`Groq`,badge:`Fastest`,desc:`Llama 3.3 & Qwen`,keyPrefix:`gsk_...`,portalUrl:`https://console.groq.com/keys`},{id:`gemini`,name:`Google Gemini`,desc:`Gemini 2.5 / 3.5`,keyPrefix:`AIzaSy...`,portalUrl:`https://aistudio.google.com/app/apikey`},{id:`openrouter`,name:`OpenRouter`,desc:`Multi-Provider`,keyPrefix:`sk-or-v1-...`,portalUrl:`https://openrouter.ai/keys`}];function N(){let[e,t]=(0,A.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[n,g]=(0,A.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[N,re]=(0,A.useState)(!1),[P,F]=(0,A.useState)(null),[I,L]=(0,A.useState)(()=>x()),[R,z]=(0,A.useState)(null),[B,V]=(0,A.useState)(()=>T().currentFloor),[H,U]=(0,A.useState)(()=>l()),[W,G]=(0,A.useState)(()=>s()),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(n.trim()&&e!=="default"),Q=e!=="default"&&!n.trim(),$=M.find(t=>t.id===e),ie=e=>{t(e),localStorage.setItem(`algospaced_custom_ai_provider`,e),F(e==="default"?{type:`info`,text:`Switched to Server Default (Shared Pool).`}:{type:`info`,text:`Switched to ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3)},ae=()=>{let t=n.trim();if(!t){F({type:`error`,text:`Please enter an API key for ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3);return}localStorage.setItem(`algospaced_custom_api_key`,t),localStorage.setItem(`sandbox_gemini_api_key`,t),localStorage.setItem(`algospaced_custom_ai_provider`,e),F({type:`success`,text:`${e.toUpperCase()} API key saved successfully.`}),setTimeout(()=>F(null),3e3)},oe=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),g(``),F({type:`info`,text:`Cleared custom API key.`}),setTimeout(()=>F(null),3e3)},se=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),localStorage.setItem(`algospaced_custom_ai_provider`,`default`),g(``),t(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{C(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(S),C(S),z({type:`info`,text:`Reset companion to default settings.`}),setTimeout(()=>z(null),3e3)},ue=()=>{if(window.confirm(`Are you sure you want to reset your Spire Journey progress back to 0 problems?`)){let e=w();V(e.currentFloor),z({type:`info`,text:`Spire journey progress reset to 0 problems.`}),setTimeout(()=>z(null),3e3)}},de=async()=>{q(!0),Y(null);try{let{token:e,user:t}=await c();G(t);let n=l();U(n);try{await a(e,n.repoName,n.isPrivate)}catch{}Y({type:`success`,text:`Connected to GitHub as @${t.login}!`}),setTimeout(()=>Y(null),4e3)}catch(e){Y({type:`error`,text:e.message||`GitHub connection failed.`}),setTimeout(()=>Y(null),5e3)}finally{q(!1)}},fe=()=>{d(),U(l()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{u({autoCommit:e}),U(t=>({...t,autoCommit:e})),Y({type:`info`,text:e?`Auto-commit enabled for review submissions.`:`Auto-commit disabled.`}),setTimeout(()=>Y(null),3e3)};return(0,j.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-5 sm:p-6 flex flex-col gap-4 select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,j.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,j.jsx)(k,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,j.jsx)(`div`,{className:`px-4 py-3 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] transition-all ${Z?`bg-emerald-50`:Q?`bg-rose-50`:`bg-amber-50/70`}`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Z?(0,j.jsx)(b,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,j.jsx)(r,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,j.jsx)(O,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,j.jsxs)(`span`,{children:[`Active:`,` `,Z?`${e.toUpperCase()} (Custom Key)`:Q?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,j.jsx)(`div`,{className:`text-[10px] text-trash-gray font-medium`,children:Z?`Requests are routed directly through your personal API key.`:Q?`Enter your API key below to activate this provider.`:`Using basic, free built-in developer keys with auto-failover.`})]})]}),(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${Z?`bg-emerald-300 text-emerald-950`:Q?`bg-rose-300 text-rose-950`:`bg-amber-200 text-amber-950`}`,children:Z?`ACTIVE`:Q?`NEEDS KEY`:`LIMITED`})]})}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider mb-2 font-headline-md flex items-center gap-1.5`,children:[(0,j.jsx)(O,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,j.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:M.map(t=>{let n=e===t.id;return(0,j.jsxs)(`button`,{type:`button`,onClick:()=>ie(t.id),className:`p-2.5 border-[2px] text-left transition-all cursor-pointer flex flex-col justify-between rounded ${n?`border-ink-black bg-[#ffe24c] shadow-[2px_2px_0px_0px_#1E293B] font-bold`:`border-slate-300 bg-slate-50 hover:bg-slate-100 text-slate-700`}`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,j.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1 py-0.2 bg-orange-100 text-orange-700 rounded border border-orange-300`,children:t.badge})]}),(0,j.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,j.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,j.jsx)(ne,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,j.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,j.jsx)(`i`,{children:`limited`}),`)`]}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0 leading-relaxed`,children:`Powered by shared, basic developer keys. Because limits are shared with everyone, requests may fail. Use your own provider keys above for stable performance.`})]})]}):(0,j.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1.5`,children:[(0,j.jsx)(k,{className:`w-3.5 h-3.5 text-ink-black`}),$?.name,` API Key`]}),$?.portalUrl&&(0,j.jsxs)(`a`,{href:$.portalUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-sky-600 hover:text-sky-800 font-medium flex items-center gap-1 no-underline`,children:[(0,j.jsx)(`span`,{children:`Get API Key`}),(0,j.jsx)(i,{className:`w-3 h-3`})]})]}),(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(`input`,{type:N?`text`:`password`,value:n,onChange:e=>g(e.target.value),placeholder:`Enter ${$?.keyPrefix||`API Key`}`,className:`w-full bg-white border-[2px] border-ink-black rounded py-2 pl-3 pr-9 text-ink-black placeholder-slate-400 focus:outline-none focus:border-sky-600 text-xs font-code-mono`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>re(!N),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black cursor-pointer bg-transparent border-0 outline-none p-1`,title:N?`Hide API key`:`Show API key`,children:N?(0,j.jsx)(o,{className:`w-3.5 h-3.5`}):(0,j.jsx)(ee,{className:`w-3.5 h-3.5`})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,j.jsx)(_,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,j.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,j.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,j.jsxs)(`button`,{onClick:ae,className:`flex-1 flex items-center justify-center gap-1.5 py-2 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,j.jsx)(m,{className:`w-3.5 h-3.5`}),`Save Key`]}),n&&(0,j.jsx)(`button`,{onClick:oe,className:`px-3 py-2 border-[2px] border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 hover:text-rose-600 shadow-[2px_2px_0px_0px_rgba(0,0,0,0.05)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:`Clear Key`})]})]}),P&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${P.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:P.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[P.type===`success`?(0,j.jsx)(D,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,j.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}):(0,j.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),P.text]}),e!=="default"&&(0,j.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,j.jsxs)(`button`,{onClick:se,className:`flex items-center gap-1.5 py-1.5 px-3 border border-slate-300 bg-slate-50 hover:bg-slate-100 text-[11px] font-bold text-slate-600 hover:text-ink-black transition-all cursor-pointer rounded`,children:[(0,j.jsx)(v,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,j.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#24292e] border-[2px] border-ink-black flex items-center justify-center text-white shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,j.jsx)(f,{className:`w-4 h-4 text-white`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0 flex items-center gap-2`,children:`GitHub Solutions Sync & Auto-Commit`}),(0,j.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Sync solutions to personal GitHub repository and commit automatically on submission`})]})]}),(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${X?`bg-emerald-300 text-emerald-950`:`bg-slate-200 text-slate-800`}`,children:X?`CONNECTED`:`DISCONNECTED`})]}),X?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-3 bg-slate-50 border border-slate-200 rounded`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[W?.avatar_url&&(0,j.jsx)(`img`,{src:W.avatar_url,alt:W.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,W?.login||H.username]}),(0,j.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[H.username,`/`,H.repoName,` (`,H.branch,`)`]})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`a`,{href:`https://github.com/${H.username}/${H.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-slate-100 text-ink-black border border-slate-300 rounded no-underline flex items-center gap-1 cursor-pointer`,children:[(0,j.jsx)(i,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{children:`View Repo`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:fe,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-rose-50 text-rose-700 border border-rose-300 rounded cursor-pointer`,children:`Disconnect`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-emerald-50/50 border border-emerald-300 rounded cursor-pointer`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:H.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,H.repoName,` whenever you grade a review card.`]})]})]})]}):(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 p-3.5 bg-slate-50 border border-slate-200 rounded`,children:[(0,j.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0`,children:`Grant repository access to automatically sync your DSA problem solutions as you study.`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:de,disabled:K,className:`px-4 py-2 bg-[#24292e] hover:bg-black text-white text-xs font-bold uppercase rounded border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none flex items-center gap-2 shrink-0 cursor-pointer disabled:opacity-50`,children:K?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(h,{className:`w-3.5 h-3.5 animate-spin`}),(0,j.jsx)(`span`,{children:`CONNECTING...`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(f,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,j.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),J&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${J.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:J.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[J.type===`success`?(0,j.jsx)(D,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,j.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}):(0,j.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),J.text]})]}),(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`w-7 h-7 rounded bg-[#FFE24C] border-[2px] border-ink-black flex items-center justify-center shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,j.jsx)(te,{className:`w-4 h-4 text-ink-black`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & RPG Settings`}),(0,j.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Trapped Princess Persona, Study Break Timer & 8-bit RPG Audio`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,j.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:I.enabled?`Enabled`:`Disabled`}),(0,j.jsx)(`input`,{type:`checkbox`,checked:I.enabled,onChange:e=>L(t=>({...t,enabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,j.jsx)(`input`,{type:`text`,value:I.name,onChange:e=>L(t=>({...t,name:e.target.value})),placeholder:`e.g. Princess Aurelia`,className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600`})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,j.jsxs)(`select`,{value:I.breakIntervalMinutes,onChange:e=>L(t=>({...t,breakIntervalMinutes:Number(e.target.value)})),className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 cursor-pointer`,children:[(0,j.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,j.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,j.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,j.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,j.jsx)(`textarea`,{rows:2,value:I.backstory,onChange:e=>L(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, tone, and connection to your DSA studies...`,className:`bg-white border-[2px] border-ink-black rounded p-2.5 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 resize-y`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:I.soundEnabled,onChange:e=>{let t=e.target.checked;L(e=>({...e,soundEnabled:t})),E(!t)},className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,j.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Typewriter blips, chimes & fanfare`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:I.autoPopupEnabled,onChange:e=>L(t=>({...t,autoPopupEnabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,j.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:ce,className:`flex items-center gap-1.5 py-2 px-4 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,j.jsx)(m,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,j.jsx)(`button`,{type:`button`,onClick:le,className:`py-2 px-3 border border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 transition-all cursor-pointer rounded`,children:`Default Persona`})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:ue,className:`flex items-center gap-1 py-1.5 px-3 border border-rose-300 bg-rose-50 hover:bg-rose-100 text-rose-700 text-[11px] font-bold transition-all cursor-pointer rounded`,children:[(0,j.jsx)(v,{className:`w-3 h-3 text-rose-500`}),(0,j.jsxs)(`span`,{children:[`Reset Journey (`,B,`/150 LC)`]})]})]}),R&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${R.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[(0,j.jsx)(D,{className:`w-3.5 h-3.5 shrink-0`}),R.text]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-2.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(p,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,j.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,j.jsxs)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`Groq Cloud`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,j.jsxs)(`a`,{href:`https://aistudio.google.com/app/apikey`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`Google AI Studio`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,j.jsxs)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`OpenRouter`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{N as default};
|
|
|
|
| 1 |
+
import{a as e,c as t,t as n}from"./jsx-runtime-j9uSgrFF.js";import{t as r}from"./circle-alert-Of55HLBR.js";import{t as i}from"./external-link-BXmZLKhd.js";import{a,d as ee,f as te,i as o,n as s,r as c,s as l,t as u,u as d}from"./githubSyncService-DoPH-Kso.js";import{t as f}from"./info-BOfHU5mV.js";import{t as p}from"./save-BAfjznhv.js";import{E as m,F as h,H as g,I as _,M as v,O as y,S as b,d as x,f as S,g as C,j as w,k as ne,l as T,p as E,u as D}from"./index-Bz1BMWr8.js";var O=g(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),k=g(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),A=t(e(),1),j=n(),M=[{id:`default`,name:`Default`,desc:`Subject to Availability`},{id:`groq`,name:`Groq`,badge:`Fastest`,desc:`Llama 3.3 & Qwen`,keyPrefix:`gsk_...`,portalUrl:`https://console.groq.com/keys`},{id:`gemini`,name:`Google Gemini`,desc:`Gemini 2.5 / 3.5`,keyPrefix:`AIzaSy...`,portalUrl:`https://aistudio.google.com/app/apikey`},{id:`openrouter`,name:`OpenRouter`,desc:`Multi-Provider`,keyPrefix:`sk-or-v1-...`,portalUrl:`https://openrouter.ai/keys`}];function N(){let[e,t]=(0,A.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[n,g]=(0,A.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[N,re]=(0,A.useState)(!1),[P,F]=(0,A.useState)(null),[I,L]=(0,A.useState)(()=>T()),[R,z]=(0,A.useState)(null),[B,V]=(0,A.useState)(()=>D().currentFloor),[H,U]=(0,A.useState)(()=>c()),[W,G]=(0,A.useState)(()=>o()),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(n.trim()&&e!=="default"),Q=e!=="default"&&!n.trim(),$=M.find(t=>t.id===e),ie=e=>{t(e),localStorage.setItem(`algospaced_custom_ai_provider`,e),F(e==="default"?{type:`info`,text:`Switched to Server Default (Shared Pool).`}:{type:`info`,text:`Switched to ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3)},ae=()=>{let t=n.trim();if(!t){F({type:`error`,text:`Please enter an API key for ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3);return}localStorage.setItem(`algospaced_custom_api_key`,t),localStorage.setItem(`sandbox_gemini_api_key`,t),localStorage.setItem(`algospaced_custom_ai_provider`,e),F({type:`success`,text:`${e.toUpperCase()} API key saved successfully.`}),setTimeout(()=>F(null),3e3)},oe=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),g(``),F({type:`info`,text:`Cleared custom API key.`}),setTimeout(()=>F(null),3e3)},se=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),localStorage.setItem(`algospaced_custom_ai_provider`,`default`),g(``),t(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{S(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(E),S(E),z({type:`info`,text:`Reset companion to default settings.`}),setTimeout(()=>z(null),3e3)},ue=()=>{if(window.confirm(`Are you sure you want to reset your Spire Journey progress back to 0 problems?`)){let e=x();V(e.currentFloor),z({type:`info`,text:`Spire journey progress reset to 0 problems.`}),setTimeout(()=>z(null),3e3)}},de=async()=>{q(!0),Y(null);try{let{token:e,user:t}=await s();G(t);let n=c();U(n);try{await a(e,n.repoName,n.isPrivate)}catch{}Y({type:`success`,text:`Connected to GitHub as @${t.login}!`}),setTimeout(()=>Y(null),4e3)}catch(e){Y({type:`error`,text:e.message||`GitHub connection failed.`}),setTimeout(()=>Y(null),5e3)}finally{q(!1)}},fe=()=>{u(),U(c()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{l({autoCommit:e}),U(t=>({...t,autoCommit:e})),Y({type:`info`,text:e?`Auto-commit enabled for review submissions.`:`Auto-commit disabled.`}),setTimeout(()=>Y(null),3e3)};return(0,j.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-5 sm:p-6 flex flex-col gap-4 select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,j.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,j.jsx)(k,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,j.jsx)(`div`,{className:`px-4 py-3 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] transition-all ${Z?`bg-emerald-50`:Q?`bg-rose-50`:`bg-amber-50/70`}`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Z?(0,j.jsx)(b,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,j.jsx)(r,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,j.jsx)(O,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,j.jsxs)(`span`,{children:[`Active:`,` `,Z?`${e.toUpperCase()} (Custom Key)`:Q?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,j.jsx)(`div`,{className:`text-[10px] text-trash-gray font-medium`,children:Z?`Requests are routed directly through your personal API key.`:Q?`Enter your API key below to activate this provider.`:`Using basic, free built-in developer keys with auto-failover.`})]})]}),(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${Z?`bg-emerald-300 text-emerald-950`:Q?`bg-rose-300 text-rose-950`:`bg-amber-200 text-amber-950`}`,children:Z?`ACTIVE`:Q?`NEEDS KEY`:`LIMITED`})]})}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider mb-2 font-headline-md flex items-center gap-1.5`,children:[(0,j.jsx)(O,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,j.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:M.map(t=>{let n=e===t.id;return(0,j.jsxs)(`button`,{type:`button`,onClick:()=>ie(t.id),className:`p-2.5 border-[2px] text-left transition-all cursor-pointer flex flex-col justify-between rounded ${n?`border-ink-black bg-[#ffe24c] shadow-[2px_2px_0px_0px_#1E293B] font-bold`:`border-slate-300 bg-slate-50 hover:bg-slate-100 text-slate-700`}`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,j.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1 py-0.2 bg-orange-100 text-orange-700 rounded border border-orange-300`,children:t.badge})]}),(0,j.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,j.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,j.jsx)(m,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,j.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,j.jsx)(`i`,{children:`limited`}),`)`]}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0 leading-relaxed`,children:`Powered by shared, basic developer keys. Because limits are shared with everyone, requests may fail. Use your own provider keys above for stable performance.`})]})]}):(0,j.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1.5`,children:[(0,j.jsx)(k,{className:`w-3.5 h-3.5 text-ink-black`}),$?.name,` API Key`]}),$?.portalUrl&&(0,j.jsxs)(`a`,{href:$.portalUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-sky-600 hover:text-sky-800 font-medium flex items-center gap-1 no-underline`,children:[(0,j.jsx)(`span`,{children:`Get API Key`}),(0,j.jsx)(i,{className:`w-3 h-3`})]})]}),(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(`input`,{type:N?`text`:`password`,value:n,onChange:e=>g(e.target.value),placeholder:`Enter ${$?.keyPrefix||`API Key`}`,className:`w-full bg-white border-[2px] border-ink-black rounded py-2 pl-3 pr-9 text-ink-black placeholder-slate-400 focus:outline-none focus:border-sky-600 text-xs font-code-mono`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>re(!N),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black cursor-pointer bg-transparent border-0 outline-none p-1`,title:N?`Hide API key`:`Show API key`,children:N?(0,j.jsx)(te,{className:`w-3.5 h-3.5`}):(0,j.jsx)(ee,{className:`w-3.5 h-3.5`})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,j.jsx)(ne,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,j.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,j.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,j.jsxs)(`button`,{onClick:ae,className:`flex-1 flex items-center justify-center gap-1.5 py-2 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,j.jsx)(p,{className:`w-3.5 h-3.5`}),`Save Key`]}),n&&(0,j.jsx)(`button`,{onClick:oe,className:`px-3 py-2 border-[2px] border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 hover:text-rose-600 shadow-[2px_2px_0px_0px_rgba(0,0,0,0.05)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:`Clear Key`})]})]}),P&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${P.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:P.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[P.type===`success`?(0,j.jsx)(_,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,j.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}):(0,j.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),P.text]}),e!=="default"&&(0,j.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,j.jsxs)(`button`,{onClick:se,className:`flex items-center gap-1.5 py-1.5 px-3 border border-slate-300 bg-slate-50 hover:bg-slate-100 text-[11px] font-bold text-slate-600 hover:text-ink-black transition-all cursor-pointer rounded`,children:[(0,j.jsx)(w,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,j.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#24292e] border-[2px] border-ink-black flex items-center justify-center text-white shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,j.jsx)(d,{className:`w-4 h-4 text-white`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0 flex items-center gap-2`,children:`GitHub Solutions Sync & Auto-Commit`}),(0,j.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Sync solutions to personal GitHub repository and commit automatically on submission`})]})]}),(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${X?`bg-emerald-300 text-emerald-950`:`bg-slate-200 text-slate-800`}`,children:X?`CONNECTED`:`DISCONNECTED`})]}),X?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-3 bg-slate-50 border border-slate-200 rounded`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[W?.avatar_url&&(0,j.jsx)(`img`,{src:W.avatar_url,alt:W.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,W?.login||H.username]}),(0,j.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[H.username,`/`,H.repoName,` (`,H.branch,`)`]})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`a`,{href:`https://github.com/${H.username}/${H.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-slate-100 text-ink-black border border-slate-300 rounded no-underline flex items-center gap-1 cursor-pointer`,children:[(0,j.jsx)(i,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{children:`View Repo`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:fe,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-rose-50 text-rose-700 border border-rose-300 rounded cursor-pointer`,children:`Disconnect`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-emerald-50/50 border border-emerald-300 rounded cursor-pointer`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:H.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,H.repoName,` whenever you grade a review card.`]})]})]})]}):(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 p-3.5 bg-slate-50 border border-slate-200 rounded`,children:[(0,j.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,j.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0`,children:`Grant repository access to automatically sync your DSA problem solutions as you study.`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:de,disabled:K,className:`px-4 py-2 bg-[#24292e] hover:bg-black text-white text-xs font-bold uppercase rounded border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none flex items-center gap-2 shrink-0 cursor-pointer disabled:opacity-50`,children:K?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(v,{className:`w-3.5 h-3.5 animate-spin`}),(0,j.jsx)(`span`,{children:`CONNECTING...`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,j.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),J&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${J.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:J.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[J.type===`success`?(0,j.jsx)(_,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,j.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}):(0,j.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),J.text]})]}),(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`w-7 h-7 rounded bg-[#FFE24C] border-[2px] border-ink-black flex items-center justify-center shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,j.jsx)(y,{className:`w-4 h-4 text-ink-black`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & RPG Settings`}),(0,j.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Trapped Princess Persona, Study Break Timer & 8-bit RPG Audio`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,j.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:I.enabled?`Enabled`:`Disabled`}),(0,j.jsx)(`input`,{type:`checkbox`,checked:I.enabled,onChange:e=>L(t=>({...t,enabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,j.jsx)(`input`,{type:`text`,value:I.name,onChange:e=>L(t=>({...t,name:e.target.value})),placeholder:`e.g. Princess Aurelia`,className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600`})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,j.jsx)(h,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,j.jsxs)(`select`,{value:I.breakIntervalMinutes,onChange:e=>L(t=>({...t,breakIntervalMinutes:Number(e.target.value)})),className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 cursor-pointer`,children:[(0,j.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,j.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,j.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,j.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,j.jsx)(`textarea`,{rows:2,value:I.backstory,onChange:e=>L(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, tone, and connection to your DSA studies...`,className:`bg-white border-[2px] border-ink-black rounded p-2.5 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 resize-y`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:I.soundEnabled,onChange:e=>{let t=e.target.checked;L(e=>({...e,soundEnabled:t})),C(!t)},className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,j.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Typewriter blips, chimes & fanfare`})]})]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:I.autoPopupEnabled,onChange:e=>L(t=>({...t,autoPopupEnabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,j.jsxs)(`div`,{className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,j.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:ce,className:`flex items-center gap-1.5 py-2 px-4 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,j.jsx)(p,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,j.jsx)(`button`,{type:`button`,onClick:le,className:`py-2 px-3 border border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 transition-all cursor-pointer rounded`,children:`Default Persona`})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:ue,className:`flex items-center gap-1 py-1.5 px-3 border border-rose-300 bg-rose-50 hover:bg-rose-100 text-rose-700 text-[11px] font-bold transition-all cursor-pointer rounded`,children:[(0,j.jsx)(w,{className:`w-3 h-3 text-rose-500`}),(0,j.jsxs)(`span`,{children:[`Reset Journey (`,B,`/150 LC)`]})]})]}),R&&(0,j.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${R.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[(0,j.jsx)(_,{className:`w-3.5 h-3.5 shrink-0`}),R.text]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-2.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(f,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,j.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,j.jsxs)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`Groq Cloud`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,j.jsxs)(`a`,{href:`https://aistudio.google.com/app/apikey`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`Google AI Studio`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,j.jsxs)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,j.jsx)(`span`,{children:`OpenRouter`}),(0,j.jsx)(i,{className:`w-3 h-3 text-slate-400`})]}),(0,j.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{N as default};
|
algospaced-ui/dist/assets/TerminalEmulator-CI1oWIOR.js
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
import{a as e,c as t,i as n,t as r}from"./jsx-runtime-j9uSgrFF.js";var i=t(e(),1),a=r();function o(e,t){if(e.length===0||t.length===0)return[`Empty result set.`];let n={};e.forEach(e=>{n[e]=e.length}),t.forEach(t=>{e.forEach(e=>{let r=t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`;r.length>(n[e]||0)&&(n[e]=r.length)})});let r=`+`+e.map(e=>`-`.repeat(n[e]+2)).join(`+`)+`+`,i=[r,`|`+e.map(e=>` ${e.padEnd(n[e])} `).join(`|`)+`|`,r];return t.forEach(t=>{let r=`|`+e.map(e=>` ${(t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`).padEnd(n[e])} `).join(`|`)+`|`;i.push(r)}),i.push(r),i}function s({onOpenWindow:e,onClose:t}){let[r,s]=(0,i.useState)([`AlgoSpaced OS [Version 1.0.24-beta]`,`(c) Retro Arcade Systems. All rights reserved.`,``,`Type "help" for a list of available commands.`,``]),[c,l]=(0,i.useState)(``),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r]);let d=e=>{let t=e.trim(),n=/[^\s"']+|"([^"]*)"|'([^']*)'/g,r=[],i;for(;(i=n.exec(t))!==null;)r.push(i[1]||i[2]||i[0]);return{command:r[0]?.toLowerCase()||``,args:r.slice(1)}},f=async r=>{let i=r.trim();if(i===``){s(e=>[...e,`$`]);return}let{command:a,args:c}=d(i),l=[`$ ${i}`];switch(a){case`help`:l.push(`Available commands:`,` help - Display this documentation`,` streak - Retrieve your active Leitner combo streak metrics`,` sync - Run google drive file import sync`,` reviews - Fetch Leetcode numbers due for daily review`,` python play - Open Daily Python Challenge window`,` sql play - Open Interactive SQL Playground window`,` db init - Initialize SQL session and open playground window`,` db status - Check active SQL session objectives`,` db query [Q] - Execute query and format results inside CLI`,` open - Open window (usage: open queue | journey | system | python | db)`,` clear - Clear terminal buffer`,` exit - Close the terminal shell`);break;case`clear`:s([]);return;case`exit`:l.push(`Closing terminal session...`),setTimeout(()=>{t()},500);break;case`open`:{let t=c[0]?.toLowerCase();t===`queue`||t===`daily`||t===`reviews`?(e(`queue`),l.push(`Launching Daily Queue window...`)):t===`journey`||t===`path`||t===`map`?(e(`journey`),l.push(`Launching Journey Path window...`)):t===`system`||t===`computer`||t===`sys`?(e(`computer`),l.push(`Launching System Information window...`)):t===`python`||t===`challenge`?(e(`python`),l.push(`Launching Daily Python Challenge window...`)):t===`db`||t===`mysql`||t===`sql`?(e(`mysql`),l.push(`Launching MySQL Playground window...`)):l.push(`Usage: open [queue | journey | system | python | db]`);break}case`streak`:l.push(`Connecting to streak.sys database...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/streak`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();l.push(`Database Response:`,` Active Streak: ${e.current_streak} days`,` Max Combo: ${e.longest_streak} days`,` Last Activity: ${e.last_active_date?new Date(e.last_active_date).toLocaleDateString():`N/A`}`)}else l.push(`Error: Failed to query database endpoint`)}catch{l.push(`Error: Connection timed out`)}break;case`sync`:l.push(`Initializing Google Drive synchronization sync.exe...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/sync`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();l.push(`Sync Result: ${e.message}`)}else l.push(`Error: Sync command failed at backend host`)}catch{l.push(`Error: Cloud host unreachable`)}break;case`reviews`:l.push(`Querying leitner_cards partition...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/reviews/due`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.length===0?l.push(`Queue status: CLEAR! 0 cards due.`):l.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number}: ${e.problems?.name} (Box ${e.box_level})`))}else l.push(`Error: Failed to fetch due items`)}catch{l.push(`Error: Database connection lost`)}break;case`python`:c[0]?.toLowerCase()===`play`?(l.push(`Launching Daily Python Challenge window...`),e(`python`)):l.push(`Usage: python play`);break;case`sql`:case`mysql`:case`db`:{let t=c[0]?.toLowerCase();if(t===`play`)l.push(`Launching MySQL Playground window...`),e(`mysql`);else if(t===`init`){l.push(`Initializing MySQL Playground and launching window...`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/init?refresh=true`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();l.push(`Database Session Created: "${e.title}"`,`Objective: ${e.objective}`)}else l.push(`Error: Failed to initialize DB session on backend host.`)}catch{l.push(`Error: Server connection lost.`)}}else if(t===`status`){l.push(`Fetching SQL playground status...`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.active?l.push(`Active SQL Challenge: "${e.title}"`,`Objective: ${e.objective}`,`Status: ${e.completed?`COMPLETED (Done)`:`IN PROGRESS`}`):l.push(e.message)}else l.push(`Error: Failed to fetch DB status.`)}catch{l.push(`Error: Server timed out.`)}}else if(t===`query`){let t=i.toLowerCase().indexOf(`query`),r=t===-1?``:i.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!r){l.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}l.push(`Running query: ${r}`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){l.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:r})});if(t.ok){let e=await t.json();e.success?(l.push(`Query OK. Affected ${e.rows_affected} rows.`,...o(e.columns,e.rows)),e.is_correct&&l.push(`OBJECTIVE ACHIEVED! Congratulations.`)):l.push(`SQL Error: ${e.error}`)}else l.push(`Error: SQL execution failed.`)}catch{l.push(`Error: Database server unreachable.`)}}else l.push(`Usage: sql play | db init | db status | db query "SELECT..."`);break}default:l.push(`Command not recognized: "${a}". Type "help" for a list of available actions.`)}s(e=>[...e,...l,``])};return(0,a.jsxs)(`div`,{className:`w-full h-full bg-[#1E293B] text-[#4ADE80] font-code-mono p-4 flex flex-col overflow-hidden text-xs md:text-sm select-text`,children:[(0,a.jsx)(`div`,{ref:u,className:`flex-1 overflow-y-auto mb-2 custom-scrollbar space-y-1`,children:r.map((e,t)=>(0,a.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed min-h-[1.2em]`,children:e},t))}),(0,a.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f(c),l(``)},className:`flex items-center gap-1.5 border-t border-slate-700 pt-2 shrink-0 select-none`,children:[(0,a.jsx)(`span`,{className:`font-bold text-[#ffcc00]`,children:`$`}),(0,a.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`flex-1 bg-transparent text-[#4ADE80] outline-none border-none p-0 focus:ring-0 font-code-mono text-xs md:text-sm`,autoFocus:!0,placeholder:`Type command...`})]})]})}export{s as default};
|
|
|
|
|
|
algospaced-ui/dist/assets/TerminalEmulator-CduzKEDa.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{a as e,c as t,i as n,t as r}from"./jsx-runtime-j9uSgrFF.js";import{t as i}from"./index-Bz1BMWr8.js";var a=t(e(),1),o=r();function s(e,t){if(e.length===0||t.length===0)return[`Empty result set.`];let n={};e.forEach(e=>{n[e]=e.length}),t.forEach(t=>{e.forEach(e=>{let r=t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`;r.length>(n[e]||0)&&(n[e]=r.length)})});let r=`+`+e.map(e=>`-`.repeat(n[e]+2)).join(`+`)+`+`,i=[r,`|`+e.map(e=>` ${e.padEnd(n[e])} `).join(`|`)+`|`,r];return t.forEach(t=>{let r=`|`+e.map(e=>` ${(t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`).padEnd(n[e])} `).join(`|`)+`|`;i.push(r)}),i.push(r),i}function c({onOpenWindow:e,onClose:t}){let[r,c]=(0,a.useState)([`AlgoSpaced OS [Version 1.0.24-beta]`,`(c) Retro Arcade Systems. All rights reserved.`,``,`Type "help" for a list of available commands.`,``]),[l,u]=(0,a.useState)(``),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[r]);let f=e=>{let t=e.trim(),n=/[^\s"']+|"([^"]*)"|'([^']*)'/g,r=[],i;for(;(i=n.exec(t))!==null;)r.push(i[1]||i[2]||i[0]);return{command:r[0]?.toLowerCase()||``,args:r.slice(1)}},p=async r=>{let a=r.trim();if(a===``){c(e=>[...e,`$`]);return}let{command:o,args:l}=f(a),u=[`$ ${a}`];switch(o){case`help`:u.push(`Available commands:`,` help - Display this documentation`,` ps - Inspect OS process table (PIDs & task states)`,` streak - Retrieve your active Leitner combo streak metrics`,` sync - Run google drive file import sync`,` reviews - Fetch Leetcode numbers due for daily review`,` python play - Open Daily Python Challenge window`,` sql play - Open Interactive SQL Playground window`,` db init - Initialize SQL session and open playground window`,` db status - Check active SQL session objectives`,` db query [Q] - Execute query and format results inside CLI`,` open - Open window (usage: open queue | journey | system | python | db)`,` clear - Clear terminal buffer`,` exit - Close the terminal shell`);break;case`ps`:case`top`:{let e=Object.values(i.getState().processes);if(e.length===0)u.push(`No background processes currently in table.`);else{u.push(`AlgoSpaced OS Process Table:`);let t=s([`PID`,`APP`,`STATUS`,`NAME`],e.map(e=>({PID:e.pid.substring(0,16),APP:e.appId,STATUS:e.status.toUpperCase(),NAME:e.title.substring(0,24)})));u.push(...t)}break}case`clear`:c([]);return;case`exit`:u.push(`Closing terminal session...`),setTimeout(()=>{t()},500);break;case`open`:{let t=l[0]?.toLowerCase();t===`queue`||t===`daily`||t===`reviews`?(e(`queue`),u.push(`Launching Daily Queue window...`)):t===`journey`||t===`path`||t===`map`?(e(`journey`),u.push(`Launching Journey Path window...`)):t===`system`||t===`computer`||t===`sys`?(e(`computer`),u.push(`Launching System Information window...`)):t===`python`||t===`challenge`?(e(`python`),u.push(`Launching Daily Python Challenge window...`)):t===`db`||t===`mysql`||t===`sql`?(e(`mysql`),u.push(`Launching MySQL Playground window...`)):u.push(`Usage: open [queue | journey | system | python | db]`);break}case`streak`:u.push(`Connecting to streak.sys database...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/streak`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Response:`,` Active Streak: ${e.current_streak} days`,` Max Combo: ${e.longest_streak} days`,` Last Activity: ${e.last_active_date?new Date(e.last_active_date).toLocaleDateString():`N/A`}`)}else u.push(`Error: Failed to query database endpoint`)}catch{u.push(`Error: Connection timed out`)}break;case`sync`:u.push(`Initializing Google Drive synchronization sync.exe...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/sync`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Sync Result: ${e.message}`)}else u.push(`Error: Sync command failed at backend host`)}catch{u.push(`Error: Cloud host unreachable`)}break;case`reviews`:u.push(`Querying leitner_cards partition...`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/reviews/due`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.length===0?u.push(`Queue status: CLEAR! 0 cards due.`):u.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number??`?`}: ${e.problems?.name??`Unknown`} (Box ${e.box_level??1})`))}else u.push(`Error: Failed to fetch due items`)}catch{u.push(`Error: Database connection lost`)}break;case`python`:l[0]?.toLowerCase()===`play`?(u.push(`Launching Daily Python Challenge window...`),e(`python`)):u.push(`Usage: python play`);break;case`sql`:case`mysql`:case`db`:{let t=l[0]?.toLowerCase();if(t===`play`)u.push(`Launching MySQL Playground window...`),e(`mysql`);else if(t===`init`){u.push(`Initializing MySQL Playground and launching window...`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/init?refresh=true`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Session Created: "${e.title}"`,`Objective: ${e.objective}`)}else u.push(`Error: Failed to initialize DB session on backend host.`)}catch{u.push(`Error: Server connection lost.`)}}else if(t===`status`){u.push(`Fetching SQL playground status...`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.active?u.push(`Active SQL Challenge: "${e.title}"`,`Objective: ${e.objective}`,`Status: ${e.completed?`COMPLETED (Done)`:`IN PROGRESS`}`):u.push(e.message)}else u.push(`Error: Failed to fetch DB status.`)}catch{u.push(`Error: Server timed out.`)}}else if(t===`query`){let t=a.toLowerCase().indexOf(`query`),r=t===-1?``:a.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!r){u.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}u.push(`Running query: ${r}`),e(`mysql`);try{let{data:{session:e}}=await n.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:r})});if(t.ok){let e=await t.json();e.success?(u.push(`Query OK. Affected ${e.rows_affected} rows.`,...s(e.columns,e.rows)),e.is_correct&&u.push(`OBJECTIVE ACHIEVED! Congratulations.`)):u.push(`SQL Error: ${e.error}`)}else u.push(`Error: SQL execution failed.`)}catch{u.push(`Error: Database server unreachable.`)}}else u.push(`Usage: sql play | db init | db status | db query "SELECT..."`);break}default:u.push(`Command not recognized: "${o}". Type "help" for a list of available actions.`)}c(e=>[...e,...u,``])};return(0,o.jsxs)(`div`,{className:`w-full h-full bg-[#1E293B] text-[#4ADE80] font-code-mono p-4 flex flex-col overflow-hidden text-xs md:text-sm select-text`,children:[(0,o.jsx)(`div`,{ref:d,className:`flex-1 overflow-y-auto mb-2 custom-scrollbar space-y-1`,children:r.map((e,t)=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed min-h-[1.2em]`,children:e},t))}),(0,o.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p(l),u(``)},className:`flex items-center gap-1.5 border-t border-slate-700 pt-2 shrink-0 select-none`,children:[(0,o.jsx)(`span`,{className:`font-bold text-[#ffcc00]`,children:`$`}),(0,o.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),className:`flex-1 bg-transparent text-[#4ADE80] outline-none border-none p-0 focus:ring-0 font-code-mono text-xs md:text-sm`,autoFocus:!0,placeholder:`Type command...`})]})]})}export{c as default};
|
algospaced-ui/dist/assets/{circle-alert-B3TumjQg.js → circle-alert-Of55HLBR.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{
|
|
|
|
| 1 |
+
import{H as e}from"./index-Bz1BMWr8.js";var t=e(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]);export{t};
|
algospaced-ui/dist/assets/{confetti.module-BXT-TAy0.js → confetti.module-CvdoQdWi.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
import{
|
| 2 |
`);try{t=new Worker(URL.createObjectURL(new Blob([n])))}catch(e){return typeof console<`u`&&typeof console.warn==`function`&&console.warn(`🎊 Could not load worker`,e),null}o(t)}return t}})(),p={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:[`square`,`circle`],zIndex:100,colors:[`#26ccff`,`#a25afd`,`#ff5e7e`,`#88ff5a`,`#fcff42`,`#ffa62d`,`#ff36ff`],disableForReducedMotion:!1,scalar:1};function m(e,t){return t?t(e):e}function h(e){return e!=null}function g(e,t,n){return m(e&&h(e[t])?e[t]:p[t],n)}function _(e){return e<0?0:Math.floor(e)}function v(e,t){return Math.floor(Math.random()*(t-e))+e}function y(e){return parseInt(e,16)}function b(e){return e.map(x)}function x(e){var t=String(e).replace(/[^0-9a-f]/gi,``);return t.length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),{r:y(t.substring(0,2)),g:y(t.substring(2,4)),b:y(t.substring(4,6))}}function S(e){var t=g(e,`origin`,Object);return t.x=g(t,`x`,Number),t.y=g(t,`y`,Number),t}function C(e){e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight}function w(e){var t=e.getBoundingClientRect();e.width=t.width,e.height=t.height}function T(e){var t=document.createElement(`canvas`);return t.style.position=`fixed`,t.style.top=`0px`,t.style.left=`0px`,t.style.pointerEvents=`none`,t.style.zIndex=e,t}function E(e,t,n,r,i,a,o,s,c){e.save(),e.translate(t,n),e.rotate(a),e.scale(r,i),e.arc(0,0,1,o,s,c),e.restore()}function D(e){var t=e.angle*(Math.PI/180),n=e.spread*(Math.PI/180);return{x:e.x,y:e.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:e.startVelocity*.5+Math.random()*e.startVelocity,angle2D:-t+(.5*n-Math.random()*n),tiltAngle:(Math.random()*.5+.25)*Math.PI,color:e.color,shape:e.shape,tick:0,totalTicks:e.ticks,decay:e.decay,drift:e.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:e.gravity*3,ovalScalar:.6,scalar:e.scalar,flat:e.flat}}function O(e,t){t.x+=Math.cos(t.angle2D)*t.velocity+t.drift,t.y+=Math.sin(t.angle2D)*t.velocity+t.gravity,t.velocity*=t.decay,t.flat?(t.wobble=0,t.wobbleX=t.x+10*t.scalar,t.wobbleY=t.y+10*t.scalar,t.tiltSin=0,t.tiltCos=0,t.random=1):(t.wobble+=t.wobbleSpeed,t.wobbleX=t.x+10*t.scalar*Math.cos(t.wobble),t.wobbleY=t.y+10*t.scalar*Math.sin(t.wobble),t.tiltAngle+=.1,t.tiltSin=Math.sin(t.tiltAngle),t.tiltCos=Math.cos(t.tiltAngle),t.random=Math.random()+2);var n=t.tick++/t.totalTicks,r=t.x+t.random*t.tiltCos,i=t.y+t.random*t.tiltSin,a=t.wobbleX+t.random*t.tiltCos,s=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle=`rgba(`+t.color.r+`, `+t.color.g+`, `+t.color.b+`, `+(1-n)+`)`,e.beginPath(),o&&t.shape.type===`path`&&typeof t.shape.path==`string`&&Array.isArray(t.shape.matrix))e.fill(N(t.shape.path,t.shape.matrix,t.x,t.y,Math.abs(a-r)*.1,Math.abs(s-i)*.1,Math.PI/10*t.wobble));else if(t.shape.type===`bitmap`){var c=Math.PI/10*t.wobble,l=Math.abs(a-r)*.1,d=Math.abs(s-i)*.1,f=t.shape.bitmap.width*t.scalar,p=t.shape.bitmap.height*t.scalar,m=new DOMMatrix([Math.cos(c)*l,Math.sin(c)*l,-Math.sin(c)*d,Math.cos(c)*d,t.x,t.y]);m.multiplySelf(new DOMMatrix(t.shape.matrix));var h=e.createPattern(u.transform(t.shape.bitmap),`no-repeat`);h.setTransform(m),e.globalAlpha=1-n,e.fillStyle=h,e.fillRect(t.x-f/2,t.y-p/2,f,p),e.globalAlpha=1}else if(t.shape===`circle`)e.ellipse?e.ellipse(t.x,t.y,Math.abs(a-r)*t.ovalScalar,Math.abs(s-i)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI):E(e,t.x,t.y,Math.abs(a-r)*t.ovalScalar,Math.abs(s-i)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI);else if(t.shape===`star`)for(var g=Math.PI/2*3,_=4*t.scalar,v=8*t.scalar,y=t.x,b=t.y,x=5,S=Math.PI/x;x--;)y=t.x+Math.cos(g)*v,b=t.y+Math.sin(g)*v,e.lineTo(y,b),g+=S,y=t.x+Math.cos(g)*_,b=t.y+Math.sin(g)*_,e.lineTo(y,b),g+=S;else e.moveTo(Math.floor(t.x),Math.floor(t.y)),e.lineTo(Math.floor(t.wobbleX),Math.floor(i)),e.lineTo(Math.floor(a),Math.floor(s)),e.lineTo(Math.floor(r),Math.floor(t.wobbleY));return e.closePath(),e.fill(),t.tick<t.totalTicks}function k(e,t,n,a,o){var s=t.slice(),c=e.getContext(`2d`),f,p,m=l(function(t){function l(){f=p=null,c.clearRect(0,0,a.width,a.height),u.clear(),o(),t()}function m(){r&&(a.width!==i.width||a.height!==i.height)&&(a.width=e.width=i.width,a.height=e.height=i.height),!a.width&&!a.height&&(n(e),a.width=e.width,a.height=e.height),c.clearRect(0,0,a.width,a.height),s=s.filter(function(e){return O(c,e)}),s.length?f=d.frame(m):l()}f=d.frame(m),p=l});return{addFettis:function(e){return s=s.concat(e),m},canvas:e,promise:m,reset:function(){f&&d.cancel(f),p&&p()}}}function A(e,n){var r=!e,i=!!g(n||{},`resize`),o=!1,s=g(n,`disableForReducedMotion`,Boolean),c=a&&g(n||{},`useWorker`)?f():null,u=r?C:w,d=e&&c?!!e.__confetti_initialized:!1,p=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion)`).matches,m;function h(t,n,r){for(var i=g(t,`particleCount`,_),a=g(t,`angle`,Number),o=g(t,`spread`,Number),s=g(t,`startVelocity`,Number),c=g(t,`decay`,Number),l=g(t,`gravity`,Number),d=g(t,`drift`,Number),f=g(t,`colors`,b),p=g(t,`ticks`,Number),h=g(t,`shapes`),y=g(t,`scalar`),x=!!g(t,`flat`),C=S(t),w=i,T=[],E=e.width*C.x,O=e.height*C.y;w--;)T.push(D({x:E,y:O,angle:a,spread:o,startVelocity:s,color:f[w%f.length],shape:h[v(0,h.length)],ticks:p,decay:c,gravity:l,drift:d,scalar:y,flat:x}));return m?m.addFettis(T):(m=k(e,T,u,n,r),m.promise)}function y(n){var a=s||g(n,`disableForReducedMotion`,Boolean),f=g(n,`zIndex`,Number);if(a&&p)return l(function(e){e()});r&&m?e=m.canvas:r&&!e&&(e=T(f),document.body.appendChild(e)),i&&!d&&u(e);var _={width:e.width,height:e.height};c&&!d&&c.init(e),d=!0,c&&(e.__confetti_initialized=!0);function v(){if(c){var t={getBoundingClientRect:function(){if(!r)return e.getBoundingClientRect()}};u(t),c.postMessage({resize:{width:t.width,height:t.height}});return}_.width=_.height=null}function y(){m=null,i&&(o=!1,t.removeEventListener(`resize`,v)),r&&e&&(document.body.contains(e)&&document.body.removeChild(e),e=null,d=!1)}return i&&!o&&(o=!0,t.addEventListener(`resize`,v,!1)),c?c.fire(n,_,y):h(n,_,y)}return y.reset=function(){c&&c.reset(),m&&m.reset()},y}var j;function M(){return j||=A(null,{useWorker:!0,resize:!0}),j}function N(e,t,n,r,i,a,o){var s=new Path2D(e),c=new Path2D;c.addPath(s,new DOMMatrix(t));var l=new Path2D;return l.addPath(c,new DOMMatrix([Math.cos(o)*i,Math.sin(o)*i,-Math.sin(o)*a,Math.cos(o)*a,n,r])),l}function P(e){if(!o)throw Error(`path confetti are not supported in this browser`);var t,n;typeof e==`string`?t=e:(t=e.path,n=e.matrix);var r=new Path2D(t),i=document.createElement(`canvas`).getContext(`2d`);if(!n){for(var a=1e3,s=a,c=a,l=0,u=0,d,f,p=0;p<a;p+=2)for(var m=0;m<a;m+=2)i.isPointInPath(r,p,m,`nonzero`)&&(s=Math.min(s,p),c=Math.min(c,m),l=Math.max(l,p),u=Math.max(u,m));d=l-s,f=u-c;var h=10,g=Math.min(h/d,h/f);n=[g,0,0,g,-Math.round(d/2+s)*g,-Math.round(f/2+c)*g]}return{type:`path`,path:t,matrix:n}}function F(e){var t,n=1,r=`#000000`,i=`"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif`;typeof e==`string`?t=e:(t=e.text,n=`scalar`in e?e.scalar:n,i=`fontFamily`in e?e.fontFamily:i,r=`color`in e?e.color:r);var a=10*n,o=``+a+`px `+i,s=new OffscreenCanvas(a,a),c=s.getContext(`2d`);c.font=o;var l=c.measureText(t),u=Math.ceil(l.actualBoundingBoxRight+l.actualBoundingBoxLeft),d=Math.ceil(l.actualBoundingBoxAscent+l.actualBoundingBoxDescent),f=2,p=l.actualBoundingBoxLeft+f,m=l.actualBoundingBoxAscent+f;u+=f+f,d+=f+f,s=new OffscreenCanvas(u,d),c=s.getContext(`2d`),c.font=o,c.fillStyle=r,c.fillText(t,p,m);var h=1/n;return{type:`bitmap`,bitmap:s.transferToImageBitmap(),matrix:[h,0,0,h,-u*h/2,-d*h/2]}}n.exports=function(){return M().apply(this,arguments)},n.exports.reset=function(){M().reset()},n.exports.create=A,n.exports.shapeFromPath=P,n.exports.shapeFromText=F})((function(){return typeof window<`u`?window:typeof self<`u`?self:this||{}})(),a,!1);var o=a.exports;a.exports.create;export{t as a,n as i,i as n,r,o as t};
|
|
|
|
| 1 |
+
import{H as e}from"./index-Bz1BMWr8.js";var t=e(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),n=e(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),r=e(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),i=e(`trophy`,[[`path`,{d:`M10 14.66V17a1 1 0 0 1-1 1 2 2 0 0 0-2 2v2`,key:`pwuv1l`}],[`path`,{d:`M14 14.66V17a1 1 0 0 0 1 1 2 2 0 0 1 2 2v2`,key:`1y54w1`}],[`path`,{d:`M17.916 10H19.5A2.5 2.5 0 0 0 22 7.5V5a1 1 0 0 0-1-1h-3`,key:`e30mpu`}],[`path`,{d:`M4 22h16`,key:`57wxv0`}],[`path`,{d:`M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z`,key:`1mhfuq`}],[`path`,{d:`M6.084 10H4.5A2.5 2.5 0 0 1 2 7.5V5a1 1 0 0 1 1-1h3`,key:`i0yafy`}]]),a={};(function e(t,n,r,i){var a=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o=typeof Path2D==`function`&&typeof DOMMatrix==`function`,s=(function(){if(!t.OffscreenCanvas)return!1;try{var e=new OffscreenCanvas(1,1),n=e.getContext(`2d`);n.fillRect(0,0,1,1);var r=e.transferToImageBitmap();n.createPattern(r,`no-repeat`)}catch{return!1}return!0})();function c(){}function l(e){var r=n.exports.Promise,i=r===void 0?t.Promise:r;return typeof i==`function`?new i(e):(e(c,c),null)}var u=(function(e,t){return{transform:function(n){if(e)return n;if(t.has(n))return t.get(n);var r=new OffscreenCanvas(n.width,n.height);return r.getContext(`2d`).drawImage(n,0,0),t.set(n,r),r},clear:function(){t.clear()}}})(s,new Map),d=function(){var e,t,n={},r=0;return typeof requestAnimationFrame==`function`&&typeof cancelAnimationFrame==`function`?(e=function(e){var t=Math.random();return n[t]=requestAnimationFrame(function i(a){r===a||r+16-1<a?(r=a,delete n[t],e()):n[t]=requestAnimationFrame(i)}),t},t=function(e){n[e]&&cancelAnimationFrame(n[e])}):(e=function(e){return setTimeout(e,16)},t=function(e){return clearTimeout(e)}),{frame:e,cancel:t}}(),f=(function(){var t,n,i={};function o(e){function t(t,n){e.postMessage({options:t||{},callback:n})}e.init=function(t){var n=t.transferControlToOffscreen();e.postMessage({canvas:n},[n])},e.fire=function(r,a,o){if(n)return t(r,null),n;var s=Math.random().toString(36).slice(2);return n=l(function(a){function c(t){t.data.callback===s&&(delete i[s],e.removeEventListener(`message`,c),n=null,u.clear(),o(),a())}e.addEventListener(`message`,c),t(r,s),i[s]=c.bind(null,{data:{callback:s}})}),n},e.reset=function(){for(var t in e.postMessage({reset:!0}),i)i[t](),delete i[t]}}return function(){if(t)return t;if(!r&&a){var n=[`var CONFETTI, SIZE = {}, module = {};`,`(`+e.toString()+`)(this, module, true, SIZE);`,`onmessage = function(msg) {`,` if (msg.data.options) {`,` CONFETTI(msg.data.options).then(function () {`,` if (msg.data.callback) {`,` postMessage({ callback: msg.data.callback });`,` }`,` });`,` } else if (msg.data.reset) {`,` CONFETTI && CONFETTI.reset();`,` } else if (msg.data.resize) {`,` SIZE.width = msg.data.resize.width;`,` SIZE.height = msg.data.resize.height;`,` } else if (msg.data.canvas) {`,` SIZE.width = msg.data.canvas.width;`,` SIZE.height = msg.data.canvas.height;`,` CONFETTI = module.exports.create(msg.data.canvas);`,` }`,`}`].join(`
|
| 2 |
`);try{t=new Worker(URL.createObjectURL(new Blob([n])))}catch(e){return typeof console<`u`&&typeof console.warn==`function`&&console.warn(`🎊 Could not load worker`,e),null}o(t)}return t}})(),p={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:[`square`,`circle`],zIndex:100,colors:[`#26ccff`,`#a25afd`,`#ff5e7e`,`#88ff5a`,`#fcff42`,`#ffa62d`,`#ff36ff`],disableForReducedMotion:!1,scalar:1};function m(e,t){return t?t(e):e}function h(e){return e!=null}function g(e,t,n){return m(e&&h(e[t])?e[t]:p[t],n)}function _(e){return e<0?0:Math.floor(e)}function v(e,t){return Math.floor(Math.random()*(t-e))+e}function y(e){return parseInt(e,16)}function b(e){return e.map(x)}function x(e){var t=String(e).replace(/[^0-9a-f]/gi,``);return t.length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),{r:y(t.substring(0,2)),g:y(t.substring(2,4)),b:y(t.substring(4,6))}}function S(e){var t=g(e,`origin`,Object);return t.x=g(t,`x`,Number),t.y=g(t,`y`,Number),t}function C(e){e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight}function w(e){var t=e.getBoundingClientRect();e.width=t.width,e.height=t.height}function T(e){var t=document.createElement(`canvas`);return t.style.position=`fixed`,t.style.top=`0px`,t.style.left=`0px`,t.style.pointerEvents=`none`,t.style.zIndex=e,t}function E(e,t,n,r,i,a,o,s,c){e.save(),e.translate(t,n),e.rotate(a),e.scale(r,i),e.arc(0,0,1,o,s,c),e.restore()}function D(e){var t=e.angle*(Math.PI/180),n=e.spread*(Math.PI/180);return{x:e.x,y:e.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:e.startVelocity*.5+Math.random()*e.startVelocity,angle2D:-t+(.5*n-Math.random()*n),tiltAngle:(Math.random()*.5+.25)*Math.PI,color:e.color,shape:e.shape,tick:0,totalTicks:e.ticks,decay:e.decay,drift:e.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:e.gravity*3,ovalScalar:.6,scalar:e.scalar,flat:e.flat}}function O(e,t){t.x+=Math.cos(t.angle2D)*t.velocity+t.drift,t.y+=Math.sin(t.angle2D)*t.velocity+t.gravity,t.velocity*=t.decay,t.flat?(t.wobble=0,t.wobbleX=t.x+10*t.scalar,t.wobbleY=t.y+10*t.scalar,t.tiltSin=0,t.tiltCos=0,t.random=1):(t.wobble+=t.wobbleSpeed,t.wobbleX=t.x+10*t.scalar*Math.cos(t.wobble),t.wobbleY=t.y+10*t.scalar*Math.sin(t.wobble),t.tiltAngle+=.1,t.tiltSin=Math.sin(t.tiltAngle),t.tiltCos=Math.cos(t.tiltAngle),t.random=Math.random()+2);var n=t.tick++/t.totalTicks,r=t.x+t.random*t.tiltCos,i=t.y+t.random*t.tiltSin,a=t.wobbleX+t.random*t.tiltCos,s=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle=`rgba(`+t.color.r+`, `+t.color.g+`, `+t.color.b+`, `+(1-n)+`)`,e.beginPath(),o&&t.shape.type===`path`&&typeof t.shape.path==`string`&&Array.isArray(t.shape.matrix))e.fill(N(t.shape.path,t.shape.matrix,t.x,t.y,Math.abs(a-r)*.1,Math.abs(s-i)*.1,Math.PI/10*t.wobble));else if(t.shape.type===`bitmap`){var c=Math.PI/10*t.wobble,l=Math.abs(a-r)*.1,d=Math.abs(s-i)*.1,f=t.shape.bitmap.width*t.scalar,p=t.shape.bitmap.height*t.scalar,m=new DOMMatrix([Math.cos(c)*l,Math.sin(c)*l,-Math.sin(c)*d,Math.cos(c)*d,t.x,t.y]);m.multiplySelf(new DOMMatrix(t.shape.matrix));var h=e.createPattern(u.transform(t.shape.bitmap),`no-repeat`);h.setTransform(m),e.globalAlpha=1-n,e.fillStyle=h,e.fillRect(t.x-f/2,t.y-p/2,f,p),e.globalAlpha=1}else if(t.shape===`circle`)e.ellipse?e.ellipse(t.x,t.y,Math.abs(a-r)*t.ovalScalar,Math.abs(s-i)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI):E(e,t.x,t.y,Math.abs(a-r)*t.ovalScalar,Math.abs(s-i)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI);else if(t.shape===`star`)for(var g=Math.PI/2*3,_=4*t.scalar,v=8*t.scalar,y=t.x,b=t.y,x=5,S=Math.PI/x;x--;)y=t.x+Math.cos(g)*v,b=t.y+Math.sin(g)*v,e.lineTo(y,b),g+=S,y=t.x+Math.cos(g)*_,b=t.y+Math.sin(g)*_,e.lineTo(y,b),g+=S;else e.moveTo(Math.floor(t.x),Math.floor(t.y)),e.lineTo(Math.floor(t.wobbleX),Math.floor(i)),e.lineTo(Math.floor(a),Math.floor(s)),e.lineTo(Math.floor(r),Math.floor(t.wobbleY));return e.closePath(),e.fill(),t.tick<t.totalTicks}function k(e,t,n,a,o){var s=t.slice(),c=e.getContext(`2d`),f,p,m=l(function(t){function l(){f=p=null,c.clearRect(0,0,a.width,a.height),u.clear(),o(),t()}function m(){r&&(a.width!==i.width||a.height!==i.height)&&(a.width=e.width=i.width,a.height=e.height=i.height),!a.width&&!a.height&&(n(e),a.width=e.width,a.height=e.height),c.clearRect(0,0,a.width,a.height),s=s.filter(function(e){return O(c,e)}),s.length?f=d.frame(m):l()}f=d.frame(m),p=l});return{addFettis:function(e){return s=s.concat(e),m},canvas:e,promise:m,reset:function(){f&&d.cancel(f),p&&p()}}}function A(e,n){var r=!e,i=!!g(n||{},`resize`),o=!1,s=g(n,`disableForReducedMotion`,Boolean),c=a&&g(n||{},`useWorker`)?f():null,u=r?C:w,d=e&&c?!!e.__confetti_initialized:!1,p=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion)`).matches,m;function h(t,n,r){for(var i=g(t,`particleCount`,_),a=g(t,`angle`,Number),o=g(t,`spread`,Number),s=g(t,`startVelocity`,Number),c=g(t,`decay`,Number),l=g(t,`gravity`,Number),d=g(t,`drift`,Number),f=g(t,`colors`,b),p=g(t,`ticks`,Number),h=g(t,`shapes`),y=g(t,`scalar`),x=!!g(t,`flat`),C=S(t),w=i,T=[],E=e.width*C.x,O=e.height*C.y;w--;)T.push(D({x:E,y:O,angle:a,spread:o,startVelocity:s,color:f[w%f.length],shape:h[v(0,h.length)],ticks:p,decay:c,gravity:l,drift:d,scalar:y,flat:x}));return m?m.addFettis(T):(m=k(e,T,u,n,r),m.promise)}function y(n){var a=s||g(n,`disableForReducedMotion`,Boolean),f=g(n,`zIndex`,Number);if(a&&p)return l(function(e){e()});r&&m?e=m.canvas:r&&!e&&(e=T(f),document.body.appendChild(e)),i&&!d&&u(e);var _={width:e.width,height:e.height};c&&!d&&c.init(e),d=!0,c&&(e.__confetti_initialized=!0);function v(){if(c){var t={getBoundingClientRect:function(){if(!r)return e.getBoundingClientRect()}};u(t),c.postMessage({resize:{width:t.width,height:t.height}});return}_.width=_.height=null}function y(){m=null,i&&(o=!1,t.removeEventListener(`resize`,v)),r&&e&&(document.body.contains(e)&&document.body.removeChild(e),e=null,d=!1)}return i&&!o&&(o=!0,t.addEventListener(`resize`,v,!1)),c?c.fire(n,_,y):h(n,_,y)}return y.reset=function(){c&&c.reset(),m&&m.reset()},y}var j;function M(){return j||=A(null,{useWorker:!0,resize:!0}),j}function N(e,t,n,r,i,a,o){var s=new Path2D(e),c=new Path2D;c.addPath(s,new DOMMatrix(t));var l=new Path2D;return l.addPath(c,new DOMMatrix([Math.cos(o)*i,Math.sin(o)*i,-Math.sin(o)*a,Math.cos(o)*a,n,r])),l}function P(e){if(!o)throw Error(`path confetti are not supported in this browser`);var t,n;typeof e==`string`?t=e:(t=e.path,n=e.matrix);var r=new Path2D(t),i=document.createElement(`canvas`).getContext(`2d`);if(!n){for(var a=1e3,s=a,c=a,l=0,u=0,d,f,p=0;p<a;p+=2)for(var m=0;m<a;m+=2)i.isPointInPath(r,p,m,`nonzero`)&&(s=Math.min(s,p),c=Math.min(c,m),l=Math.max(l,p),u=Math.max(u,m));d=l-s,f=u-c;var h=10,g=Math.min(h/d,h/f);n=[g,0,0,g,-Math.round(d/2+s)*g,-Math.round(f/2+c)*g]}return{type:`path`,path:t,matrix:n}}function F(e){var t,n=1,r=`#000000`,i=`"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif`;typeof e==`string`?t=e:(t=e.text,n=`scalar`in e?e.scalar:n,i=`fontFamily`in e?e.fontFamily:i,r=`color`in e?e.color:r);var a=10*n,o=``+a+`px `+i,s=new OffscreenCanvas(a,a),c=s.getContext(`2d`);c.font=o;var l=c.measureText(t),u=Math.ceil(l.actualBoundingBoxRight+l.actualBoundingBoxLeft),d=Math.ceil(l.actualBoundingBoxAscent+l.actualBoundingBoxDescent),f=2,p=l.actualBoundingBoxLeft+f,m=l.actualBoundingBoxAscent+f;u+=f+f,d+=f+f,s=new OffscreenCanvas(u,d),c=s.getContext(`2d`),c.font=o,c.fillStyle=r,c.fillText(t,p,m);var h=1/n;return{type:`bitmap`,bitmap:s.transferToImageBitmap(),matrix:[h,0,0,h,-u*h/2,-d*h/2]}}n.exports=function(){return M().apply(this,arguments)},n.exports.reset=function(){M().reset()},n.exports.create=A,n.exports.shapeFromPath=P,n.exports.shapeFromText=F})((function(){return typeof window<`u`?window:typeof self<`u`?self:this||{}})(),a,!1);var o=a.exports;a.exports.create;export{t as a,n as i,i as n,r,o as t};
|
algospaced-ui/dist/assets/{external-link-64ub39jt.js → external-link-BXmZLKhd.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{
|
|
|
|
| 1 |
+
import{H as e}from"./index-Bz1BMWr8.js";var t=e(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);export{t};
|
algospaced-ui/dist/assets/{githubSyncService-B4h5nigj.js → githubSyncService-DoPH-Kso.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{i as e}from"./jsx-runtime-j9uSgrFF.js";import{
|
|
|
|
| 1 |
+
import{i as e}from"./jsx-runtime-j9uSgrFF.js";import{H as t}from"./index-Bz1BMWr8.js";var n=t(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),r=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),i=t(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),a={TOKEN:`algospaced_github_token`,USERNAME:`algospaced_github_username`,REPO:`algospaced_github_repo`,BRANCH:`algospaced_github_branch`,AUTOCOMMIT:`algospaced_github_autocommit`,PRIVATE:`algospaced_github_private`,AVATAR:`algospaced_github_avatar`,NAME:`algospaced_github_name`};function o(){return{token:localStorage.getItem(a.TOKEN)||``,username:localStorage.getItem(a.USERNAME)||``,repoName:localStorage.getItem(a.REPO)||`algospaced-solutions`,branch:localStorage.getItem(a.BRANCH)||`main`,autoCommit:localStorage.getItem(a.AUTOCOMMIT)!==`false`,isPrivate:localStorage.getItem(a.PRIVATE)!==`false`}}function s(){let e=localStorage.getItem(a.USERNAME);return e?{login:e,name:localStorage.getItem(a.NAME)||e,avatar_url:localStorage.getItem(a.AVATAR)||``,html_url:`https://github.com/${e}`}:null}function c(e,t){e.token!==void 0&&localStorage.setItem(a.TOKEN,e.token.trim()),e.username!==void 0&&localStorage.setItem(a.USERNAME,e.username.trim()),e.repoName!==void 0&&localStorage.setItem(a.REPO,e.repoName.trim()),e.branch!==void 0&&localStorage.setItem(a.BRANCH,e.branch.trim()),e.autoCommit!==void 0&&localStorage.setItem(a.AUTOCOMMIT,String(e.autoCommit)),e.isPrivate!==void 0&&localStorage.setItem(a.PRIVATE,String(e.isPrivate)),t&&(t.login&&localStorage.setItem(a.USERNAME,t.login),t.name&&localStorage.setItem(a.NAME,t.name),t.avatar_url&&localStorage.setItem(a.AVATAR,t.avatar_url))}function l(){Object.values(a).forEach(e=>localStorage.removeItem(e))}async function u(){let e=window.open(`/api/github/oauth/login`,`algospaced_github_oauth`,`width=600,height=750,menubar=no,toolbar=no,status=no,location=no`);if(!e)throw Error(`Popup window was blocked by your browser. Please allow popups for AlgoSpaced and try again.`);let t=await new Promise((t,n)=>{let r=null,i=()=>{window.removeEventListener(`message`,a),r!==null&&(clearInterval(r),r=null)},a=e=>{if(!e.data||typeof e.data!=`object`)return;let r=e.data;r.type===`GITHUB_OAUTH_SUCCESS`?(i(),r.token&&typeof r.token==`string`?t(r.token.trim()):n(Error(`GitHub authorization succeeded but no access token was returned.`))):r.type===`GITHUB_OAUTH_ERROR`&&(i(),n(Error(r.error||`GitHub authorization was denied or encountered an error.`)))};window.addEventListener(`message`,a),r=setInterval(()=>{e.closed&&(i(),n(Error(`GitHub authorization window was closed before completing.`)))},1e3)}),n=await d(t);if(!n.valid||!n.user)throw Error(n.error||`Failed to retrieve profile with GitHub token.`);let r=n.user;return c({token:t,username:r.login,repoName:o().repoName||`algospaced-solutions`},r),{token:t,user:r}}async function d(e){let t=await fetch(`/api/github/verify`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e.trim()})});return t.ok?await t.json():{valid:!1,error:(await t.json().catch(()=>({}))).detail||`Server returned error (${t.status})`}}async function f(e,t,n=!0){let r=await fetch(`/api/github/init-repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e.trim(),repo_name:t.trim(),private:n})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.detail||`Failed to initialize repository (${r.status})`)}return await r.json()}async function p(e){let t=await fetch(`/api/github/push-solution`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.detail||`Failed to commit solution (${t.status})`)}return await t.json()}async function m(t,n,r=`main`){let{data:{session:i}}=await e.auth.getSession(),a=i?`Bearer ${i.access_token}`:`Bearer sandbox`,o=await fetch(`/api/github/sync-all`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:a},body:JSON.stringify({token:t.trim(),repo:n.trim(),branch:r.trim()})});if(!o.ok){let e=await o.json().catch(()=>({}));throw Error(e.detail||`Sync failed (${o.status})`)}return await o.json()}export{f as a,m as c,r as d,n as f,s as i,d as l,u as n,p as o,o as r,c as s,l as t,i as u};
|
algospaced-ui/dist/assets/index-126irCND.css
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/{index-M1GCaKIP.js → index-Bz1BMWr8.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/index-hevgUcKQ.css
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/{info-jE4ZFn-x.js → info-BOfHU5mV.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{
|
|
|
|
| 1 |
+
import{H as e}from"./index-Bz1BMWr8.js";var t=e(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]);export{t};
|
algospaced-ui/dist/assets/{save-zS5LwKaW.js → save-BAfjznhv.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{
|
|
|
|
| 1 |
+
import{H as e}from"./index-Bz1BMWr8.js";var t=e(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
|
algospaced-ui/dist/index.html
CHANGED
|
@@ -13,9 +13,9 @@
|
|
| 13 |
<link
|
| 14 |
href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Be+Vietnam+Pro:wght@500;700&family=Courier+Prime:wght@400;700&family=Press+Start+2P&family=Cinzel:wght@500;700;900&family=Cinzel+Decorative:wght@700;900&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=Kalam:wght@400;700&display=swap"
|
| 15 |
rel="stylesheet" />
|
| 16 |
-
<script type="module" crossorigin src="/assets/index-
|
| 17 |
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-j9uSgrFF.js">
|
| 18 |
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
| 19 |
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
| 20 |
|
| 21 |
<body>
|
|
|
|
| 13 |
<link
|
| 14 |
href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Be+Vietnam+Pro:wght@500;700&family=Courier+Prime:wght@400;700&family=Press+Start+2P&family=Cinzel:wght@500;700;900&family=Cinzel+Decorative:wght@700;900&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=Kalam:wght@400;700&display=swap"
|
| 15 |
rel="stylesheet" />
|
| 16 |
+
<script type="module" crossorigin src="/assets/index-Bz1BMWr8.js"></script>
|
| 17 |
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-j9uSgrFF.js">
|
| 18 |
+
<link rel="stylesheet" crossorigin href="/assets/index-126irCND.css">
|
| 19 |
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
| 20 |
|
| 21 |
<body>
|
algospaced-ui/dist/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
if(!self.define){let s,e={};const
|
|
|
|
| 1 |
+
if(!self.define){let s,e={};const l=(l,r)=>(l=new URL(l+".js",r).href,e[l]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()}).then(()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s}));self.define=(r,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const t=s=>l(s,i),o={module:{uri:i},exports:u,require:t};e[i]=Promise.all(r.map(s=>o[s]||t(s))).then(s=>(n(...s),u))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"0e9673b2196b7fb0eb07311f6f80e40b"},{url:"assets/TerminalEmulator-CduzKEDa.js",revision:null},{url:"assets/Settings-Cv6B9KXE.js",revision:null},{url:"assets/save-BAfjznhv.js",revision:null},{url:"assets/ReviewQueue-BwN6dLvy.js",revision:null},{url:"assets/PythonChallenge-C3lt-s_2.js",revision:null},{url:"assets/PrincessChamber-b4TXNjIa.js",revision:null},{url:"assets/MySQLPlayground-BdJWX3_8.js",revision:null},{url:"assets/MarkdownRenderer-O4K5H8Fp.js",revision:null},{url:"assets/jsx-runtime-j9uSgrFF.js",revision:null},{url:"assets/JourneyPath-B98APTO3.js",revision:null},{url:"assets/info-BOfHU5mV.js",revision:null},{url:"assets/index-Bz1BMWr8.js",revision:null},{url:"assets/index-126irCND.css",revision:null},{url:"assets/GitHubSyncWindow-zQZqmRO1.js",revision:null},{url:"assets/githubSyncService-DoPH-Kso.js",revision:null},{url:"assets/FileExplorer-CRW7B6yJ.js",revision:null},{url:"assets/external-link-BXmZLKhd.js",revision:null},{url:"assets/CreateProblemForm-Cu_hnDPM.js",revision:null},{url:"assets/confetti.module-CvdoQdWi.js",revision:null},{url:"assets/circle-alert-Of55HLBR.js",revision:null},{url:"manifest.webmanifest",revision:"7c8ff056d2e188c868d851bcb349e28e"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
|
algospaced-ui/package-lock.json
CHANGED
|
@@ -9,14 +9,17 @@
|
|
| 9 |
"version": "0.0.0",
|
| 10 |
"dependencies": {
|
| 11 |
"@codemirror/lang-python": "^6.2.1",
|
|
|
|
| 12 |
"@types/katex": "^0.16.8",
|
| 13 |
"@uiw/react-codemirror": "^4.25.11",
|
|
|
|
| 14 |
"canvas-confetti": "^1.9.4",
|
| 15 |
"firebase": "^12.18.0",
|
| 16 |
"katex": "^0.18.5",
|
| 17 |
"lucide-react": "^1.21.0",
|
| 18 |
"react": "^19.2.6",
|
| 19 |
-
"react-dom": "^19.2.6"
|
|
|
|
| 20 |
},
|
| 21 |
"devDependencies": {
|
| 22 |
"@eslint/js": "^10.0.1",
|
|
@@ -2458,6 +2461,59 @@
|
|
| 2458 |
"integrity": "sha512-phBFwieDLvkZGYN9CE9ZFNEIoBVksprzsnCzQejCmCHtgwCXReeuRpoEGN9C4EbhONztv8NRV1tau6Rb9pONwQ==",
|
| 2459 |
"license": "Apache-2.0"
|
| 2460 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2461 |
"node_modules/@grpc/grpc-js": {
|
| 2462 |
"version": "1.9.16",
|
| 2463 |
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.16.tgz",
|
|
@@ -3818,7 +3874,7 @@
|
|
| 3818 |
"version": "19.2.18",
|
| 3819 |
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",
|
| 3820 |
"integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==",
|
| 3821 |
-
"
|
| 3822 |
"license": "MIT",
|
| 3823 |
"peer": true,
|
| 3824 |
"dependencies": {
|
|
@@ -4320,6 +4376,24 @@
|
|
| 4320 |
"react-dom": ">=17.0.0"
|
| 4321 |
}
|
| 4322 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4323 |
"node_modules/@vitejs/plugin-react": {
|
| 4324 |
"version": "6.1.1",
|
| 4325 |
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.1.tgz",
|
|
@@ -4858,7 +4932,7 @@
|
|
| 4858 |
"version": "3.2.3",
|
| 4859 |
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
| 4860 |
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
| 4861 |
-
"
|
| 4862 |
"license": "MIT"
|
| 4863 |
},
|
| 4864 |
"node_modules/data-view-buffer": {
|
|
@@ -8201,6 +8275,12 @@
|
|
| 8201 |
"url": "https://github.com/sponsors/ljharb"
|
| 8202 |
}
|
| 8203 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8204 |
"node_modules/tailwindcss": {
|
| 8205 |
"version": "4.3.3",
|
| 8206 |
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
|
@@ -9703,6 +9783,35 @@
|
|
| 9703 |
"peerDependencies": {
|
| 9704 |
"zod": "^3.25.0 || ^4.0.0"
|
| 9705 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9706 |
}
|
| 9707 |
}
|
| 9708 |
}
|
|
|
|
| 9 |
"version": "0.0.0",
|
| 10 |
"dependencies": {
|
| 11 |
"@codemirror/lang-python": "^6.2.1",
|
| 12 |
+
"@floating-ui/react": "^0.27.20",
|
| 13 |
"@types/katex": "^0.16.8",
|
| 14 |
"@uiw/react-codemirror": "^4.25.11",
|
| 15 |
+
"@use-gesture/react": "^10.3.1",
|
| 16 |
"canvas-confetti": "^1.9.4",
|
| 17 |
"firebase": "^12.18.0",
|
| 18 |
"katex": "^0.18.5",
|
| 19 |
"lucide-react": "^1.21.0",
|
| 20 |
"react": "^19.2.6",
|
| 21 |
+
"react-dom": "^19.2.6",
|
| 22 |
+
"zustand": "^5.0.15"
|
| 23 |
},
|
| 24 |
"devDependencies": {
|
| 25 |
"@eslint/js": "^10.0.1",
|
|
|
|
| 2461 |
"integrity": "sha512-phBFwieDLvkZGYN9CE9ZFNEIoBVksprzsnCzQejCmCHtgwCXReeuRpoEGN9C4EbhONztv8NRV1tau6Rb9pONwQ==",
|
| 2462 |
"license": "Apache-2.0"
|
| 2463 |
},
|
| 2464 |
+
"node_modules/@floating-ui/core": {
|
| 2465 |
+
"version": "1.8.0",
|
| 2466 |
+
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz",
|
| 2467 |
+
"integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==",
|
| 2468 |
+
"license": "MIT",
|
| 2469 |
+
"dependencies": {
|
| 2470 |
+
"@floating-ui/utils": "^0.2.12"
|
| 2471 |
+
}
|
| 2472 |
+
},
|
| 2473 |
+
"node_modules/@floating-ui/dom": {
|
| 2474 |
+
"version": "1.8.0",
|
| 2475 |
+
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz",
|
| 2476 |
+
"integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==",
|
| 2477 |
+
"license": "MIT",
|
| 2478 |
+
"dependencies": {
|
| 2479 |
+
"@floating-ui/core": "^1.8.0",
|
| 2480 |
+
"@floating-ui/utils": "^0.2.12"
|
| 2481 |
+
}
|
| 2482 |
+
},
|
| 2483 |
+
"node_modules/@floating-ui/react": {
|
| 2484 |
+
"version": "0.27.20",
|
| 2485 |
+
"resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.27.20.tgz",
|
| 2486 |
+
"integrity": "sha512-CMqMy7OaXl9W0eq1Uy7L7i2Y/anPvHmFmESd2CEw0t5YvZhcVCeo4MBevAmswRllX7Y2dEidA4ozGPunLSTQpw==",
|
| 2487 |
+
"license": "MIT",
|
| 2488 |
+
"dependencies": {
|
| 2489 |
+
"@floating-ui/react-dom": "^2.1.9",
|
| 2490 |
+
"@floating-ui/utils": "^0.2.12",
|
| 2491 |
+
"tabbable": "^6.0.0"
|
| 2492 |
+
},
|
| 2493 |
+
"peerDependencies": {
|
| 2494 |
+
"react": ">=17.0.0",
|
| 2495 |
+
"react-dom": ">=17.0.0"
|
| 2496 |
+
}
|
| 2497 |
+
},
|
| 2498 |
+
"node_modules/@floating-ui/react-dom": {
|
| 2499 |
+
"version": "2.1.9",
|
| 2500 |
+
"resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.9.tgz",
|
| 2501 |
+
"integrity": "sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==",
|
| 2502 |
+
"license": "MIT",
|
| 2503 |
+
"dependencies": {
|
| 2504 |
+
"@floating-ui/dom": "^1.8.0"
|
| 2505 |
+
},
|
| 2506 |
+
"peerDependencies": {
|
| 2507 |
+
"react": ">=16.8.0",
|
| 2508 |
+
"react-dom": ">=16.8.0"
|
| 2509 |
+
}
|
| 2510 |
+
},
|
| 2511 |
+
"node_modules/@floating-ui/utils": {
|
| 2512 |
+
"version": "0.2.12",
|
| 2513 |
+
"resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz",
|
| 2514 |
+
"integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==",
|
| 2515 |
+
"license": "MIT"
|
| 2516 |
+
},
|
| 2517 |
"node_modules/@grpc/grpc-js": {
|
| 2518 |
"version": "1.9.16",
|
| 2519 |
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.16.tgz",
|
|
|
|
| 3874 |
"version": "19.2.18",
|
| 3875 |
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",
|
| 3876 |
"integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==",
|
| 3877 |
+
"devOptional": true,
|
| 3878 |
"license": "MIT",
|
| 3879 |
"peer": true,
|
| 3880 |
"dependencies": {
|
|
|
|
| 4376 |
"react-dom": ">=17.0.0"
|
| 4377 |
}
|
| 4378 |
},
|
| 4379 |
+
"node_modules/@use-gesture/core": {
|
| 4380 |
+
"version": "10.3.1",
|
| 4381 |
+
"resolved": "https://registry.npmjs.org/@use-gesture/core/-/core-10.3.1.tgz",
|
| 4382 |
+
"integrity": "sha512-WcINiDt8WjqBdUXye25anHiNxPc0VOrlT8F6LLkU6cycrOGUDyY/yyFmsg3k8i5OLvv25llc0QC45GhR/C8llw==",
|
| 4383 |
+
"license": "MIT"
|
| 4384 |
+
},
|
| 4385 |
+
"node_modules/@use-gesture/react": {
|
| 4386 |
+
"version": "10.3.1",
|
| 4387 |
+
"resolved": "https://registry.npmjs.org/@use-gesture/react/-/react-10.3.1.tgz",
|
| 4388 |
+
"integrity": "sha512-Yy19y6O2GJq8f7CHf7L0nxL8bf4PZCPaVOCgJrusOeFHY1LvHgYXnmnXg6N5iwAnbgbZCDjo60SiM6IPJi9C5g==",
|
| 4389 |
+
"license": "MIT",
|
| 4390 |
+
"dependencies": {
|
| 4391 |
+
"@use-gesture/core": "10.3.1"
|
| 4392 |
+
},
|
| 4393 |
+
"peerDependencies": {
|
| 4394 |
+
"react": ">= 16.8.0"
|
| 4395 |
+
}
|
| 4396 |
+
},
|
| 4397 |
"node_modules/@vitejs/plugin-react": {
|
| 4398 |
"version": "6.1.1",
|
| 4399 |
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.1.tgz",
|
|
|
|
| 4932 |
"version": "3.2.3",
|
| 4933 |
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
| 4934 |
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
| 4935 |
+
"devOptional": true,
|
| 4936 |
"license": "MIT"
|
| 4937 |
},
|
| 4938 |
"node_modules/data-view-buffer": {
|
|
|
|
| 8275 |
"url": "https://github.com/sponsors/ljharb"
|
| 8276 |
}
|
| 8277 |
},
|
| 8278 |
+
"node_modules/tabbable": {
|
| 8279 |
+
"version": "6.5.0",
|
| 8280 |
+
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.5.0.tgz",
|
| 8281 |
+
"integrity": "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==",
|
| 8282 |
+
"license": "MIT"
|
| 8283 |
+
},
|
| 8284 |
"node_modules/tailwindcss": {
|
| 8285 |
"version": "4.3.3",
|
| 8286 |
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
|
|
|
| 9783 |
"peerDependencies": {
|
| 9784 |
"zod": "^3.25.0 || ^4.0.0"
|
| 9785 |
}
|
| 9786 |
+
},
|
| 9787 |
+
"node_modules/zustand": {
|
| 9788 |
+
"version": "5.0.15",
|
| 9789 |
+
"resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.15.tgz",
|
| 9790 |
+
"integrity": "sha512-MpSEjRiBkA9crSYeOUH32rJC7SVqAbm0Fqcqge/bUi2PPoLcBWKOsG+C8mevmpr8TwXHBVkChbbJiyvkE+i/3A==",
|
| 9791 |
+
"license": "MIT",
|
| 9792 |
+
"engines": {
|
| 9793 |
+
"node": ">=12.20.0"
|
| 9794 |
+
},
|
| 9795 |
+
"peerDependencies": {
|
| 9796 |
+
"@types/react": ">=18.0.0",
|
| 9797 |
+
"immer": ">=9.0.6",
|
| 9798 |
+
"react": ">=18.0.0",
|
| 9799 |
+
"use-sync-external-store": ">=1.2.0"
|
| 9800 |
+
},
|
| 9801 |
+
"peerDependenciesMeta": {
|
| 9802 |
+
"@types/react": {
|
| 9803 |
+
"optional": true
|
| 9804 |
+
},
|
| 9805 |
+
"immer": {
|
| 9806 |
+
"optional": true
|
| 9807 |
+
},
|
| 9808 |
+
"react": {
|
| 9809 |
+
"optional": true
|
| 9810 |
+
},
|
| 9811 |
+
"use-sync-external-store": {
|
| 9812 |
+
"optional": true
|
| 9813 |
+
}
|
| 9814 |
+
}
|
| 9815 |
}
|
| 9816 |
}
|
| 9817 |
}
|
algospaced-ui/package.json
CHANGED
|
@@ -11,14 +11,17 @@
|
|
| 11 |
},
|
| 12 |
"dependencies": {
|
| 13 |
"@codemirror/lang-python": "^6.2.1",
|
|
|
|
| 14 |
"@types/katex": "^0.16.8",
|
| 15 |
"@uiw/react-codemirror": "^4.25.11",
|
|
|
|
| 16 |
"canvas-confetti": "^1.9.4",
|
| 17 |
"firebase": "^12.18.0",
|
| 18 |
"katex": "^0.18.5",
|
| 19 |
"lucide-react": "^1.21.0",
|
| 20 |
"react": "^19.2.6",
|
| 21 |
-
"react-dom": "^19.2.6"
|
|
|
|
| 22 |
},
|
| 23 |
"allowScripts": {
|
| 24 |
"@firebase/util": true,
|
|
|
|
| 11 |
},
|
| 12 |
"dependencies": {
|
| 13 |
"@codemirror/lang-python": "^6.2.1",
|
| 14 |
+
"@floating-ui/react": "^0.27.20",
|
| 15 |
"@types/katex": "^0.16.8",
|
| 16 |
"@uiw/react-codemirror": "^4.25.11",
|
| 17 |
+
"@use-gesture/react": "^10.3.1",
|
| 18 |
"canvas-confetti": "^1.9.4",
|
| 19 |
"firebase": "^12.18.0",
|
| 20 |
"katex": "^0.18.5",
|
| 21 |
"lucide-react": "^1.21.0",
|
| 22 |
"react": "^19.2.6",
|
| 23 |
+
"react-dom": "^19.2.6",
|
| 24 |
+
"zustand": "^5.0.15"
|
| 25 |
},
|
| 26 |
"allowScripts": {
|
| 27 |
"@firebase/util": true,
|
algospaced-ui/src/App.tsx
CHANGED
|
@@ -11,7 +11,6 @@ import { useSystemStats } from './hooks/useSystemStats';
|
|
| 11 |
import { useWallpaper } from './hooks/useWallpaper';
|
| 12 |
import { useCompanionEvents } from './hooks/useCompanionEvents';
|
| 13 |
import { DesktopGadget } from './components/desktop/DesktopGadget';
|
| 14 |
-
import { DesktopStartMenu } from './components/desktop/DesktopStartMenu';
|
| 15 |
import { DesktopTaskbar } from './components/desktop/DesktopTaskbar';
|
| 16 |
import { MobileMetroScreen } from './components/desktop/MobileMetroScreen';
|
| 17 |
import { DesktopWindowContainer } from './components/desktop/DesktopWindowContainer';
|
|
@@ -33,19 +32,8 @@ export default function App() {
|
|
| 33 |
// Custom Domain Hooks
|
| 34 |
const closeStartMenu = useCallback(() => setIsStartOpen(false), []);
|
| 35 |
const {
|
| 36 |
-
windows,
|
| 37 |
-
activeWindow,
|
| 38 |
-
setActiveWindow,
|
| 39 |
-
overrideProblemId,
|
| 40 |
-
setOverrideProblemId,
|
| 41 |
-
editingProblem,
|
| 42 |
-
openEditProblem,
|
| 43 |
-
refreshExplorerTrigger,
|
| 44 |
openWindow,
|
| 45 |
-
closeWindow,
|
| 46 |
-
minimizeWindow,
|
| 47 |
toggleWindowMinimize,
|
| 48 |
-
handleSelectProblemForReview,
|
| 49 |
triggerRefreshExplorer,
|
| 50 |
isAnyWindowOpen
|
| 51 |
} = useWindowManager(closeStartMenu);
|
|
@@ -307,20 +295,7 @@ export default function App() {
|
|
| 307 |
|
| 308 |
{/* Floating Windows Shell Containers */}
|
| 309 |
<DesktopWindowContainer
|
| 310 |
-
windows={windows}
|
| 311 |
-
activeWindow={activeWindow}
|
| 312 |
-
setActiveWindow={setActiveWindow}
|
| 313 |
isMobile={isMobile}
|
| 314 |
-
openWindow={openWindow}
|
| 315 |
-
closeWindow={closeWindow}
|
| 316 |
-
minimizeWindow={minimizeWindow}
|
| 317 |
-
overrideProblemId={overrideProblemId}
|
| 318 |
-
setOverrideProblemId={setOverrideProblemId}
|
| 319 |
-
editingProblem={editingProblem}
|
| 320 |
-
openEditProblem={openEditProblem}
|
| 321 |
-
handleSelectProblemForReview={handleSelectProblemForReview}
|
| 322 |
-
refreshExplorerTrigger={refreshExplorerTrigger}
|
| 323 |
-
triggerRefreshExplorer={triggerRefreshExplorer}
|
| 324 |
setIsOnboardingOpen={setIsOnboardingOpen}
|
| 325 |
wallpaperUrl={wallpaperUrl}
|
| 326 |
setWallpaperUrl={setWallpaperUrl}
|
|
@@ -329,9 +304,11 @@ export default function App() {
|
|
| 329 |
triggerSync={triggerSync}
|
| 330 |
/>
|
| 331 |
|
| 332 |
-
{/* Start Menu
|
| 333 |
-
<
|
| 334 |
-
|
|
|
|
|
|
|
| 335 |
onOpenWindow={openWindow}
|
| 336 |
onOpenOnboarding={() => {
|
| 337 |
setIsStartOpen(false);
|
|
@@ -339,17 +316,7 @@ export default function App() {
|
|
| 339 |
}}
|
| 340 |
onTriggerSync={triggerSync}
|
| 341 |
onSignOut={handleSignOut}
|
| 342 |
-
/>
|
| 343 |
-
|
| 344 |
-
{/* Taskbar Bottom */}
|
| 345 |
-
<DesktopTaskbar
|
| 346 |
-
isStartOpen={isStartOpen}
|
| 347 |
-
onToggleStart={() => setIsStartOpen(prev => !prev)}
|
| 348 |
-
onCloseStart={() => setIsStartOpen(false)}
|
| 349 |
isMobile={isMobile}
|
| 350 |
-
windows={windows}
|
| 351 |
-
activeWindow={activeWindow}
|
| 352 |
-
onToggleWindow={toggleWindowMinimize}
|
| 353 |
time={time}
|
| 354 |
/>
|
| 355 |
|
|
|
|
| 11 |
import { useWallpaper } from './hooks/useWallpaper';
|
| 12 |
import { useCompanionEvents } from './hooks/useCompanionEvents';
|
| 13 |
import { DesktopGadget } from './components/desktop/DesktopGadget';
|
|
|
|
| 14 |
import { DesktopTaskbar } from './components/desktop/DesktopTaskbar';
|
| 15 |
import { MobileMetroScreen } from './components/desktop/MobileMetroScreen';
|
| 16 |
import { DesktopWindowContainer } from './components/desktop/DesktopWindowContainer';
|
|
|
|
| 32 |
// Custom Domain Hooks
|
| 33 |
const closeStartMenu = useCallback(() => setIsStartOpen(false), []);
|
| 34 |
const {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
openWindow,
|
|
|
|
|
|
|
| 36 |
toggleWindowMinimize,
|
|
|
|
| 37 |
triggerRefreshExplorer,
|
| 38 |
isAnyWindowOpen
|
| 39 |
} = useWindowManager(closeStartMenu);
|
|
|
|
| 295 |
|
| 296 |
{/* Floating Windows Shell Containers */}
|
| 297 |
<DesktopWindowContainer
|
|
|
|
|
|
|
|
|
|
| 298 |
isMobile={isMobile}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
setIsOnboardingOpen={setIsOnboardingOpen}
|
| 300 |
wallpaperUrl={wallpaperUrl}
|
| 301 |
setWallpaperUrl={setWallpaperUrl}
|
|
|
|
| 304 |
triggerSync={triggerSync}
|
| 305 |
/>
|
| 306 |
|
| 307 |
+
{/* Taskbar Bottom with Anchored Floating Start Menu via @floating-ui/react */}
|
| 308 |
+
<DesktopTaskbar
|
| 309 |
+
isStartOpen={isStartOpen}
|
| 310 |
+
onToggleStart={() => setIsStartOpen(prev => !prev)}
|
| 311 |
+
onCloseStart={() => setIsStartOpen(false)}
|
| 312 |
onOpenWindow={openWindow}
|
| 313 |
onOpenOnboarding={() => {
|
| 314 |
setIsStartOpen(false);
|
|
|
|
| 316 |
}}
|
| 317 |
onTriggerSync={triggerSync}
|
| 318 |
onSignOut={handleSignOut}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
isMobile={isMobile}
|
|
|
|
|
|
|
|
|
|
| 320 |
time={time}
|
| 321 |
/>
|
| 322 |
|
algospaced-ui/src/components/DesktopContextMenu.tsx
CHANGED
|
@@ -1,4 +1,15 @@
|
|
| 1 |
-
import { useEffect,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
interface DesktopContextMenuProps {
|
| 4 |
x: number;
|
|
@@ -27,142 +38,163 @@ export default function DesktopContextMenu({
|
|
| 27 |
onToggleFullscreen,
|
| 28 |
isFullscreen,
|
| 29 |
}: DesktopContextMenuProps) {
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
useEffect(() => {
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
onClose();
|
| 36 |
-
}
|
| 37 |
-
};
|
| 38 |
-
|
| 39 |
-
if (isOpen) {
|
| 40 |
-
window.addEventListener('mousedown', handleClickOutside);
|
| 41 |
-
window.addEventListener('scroll', onClose);
|
| 42 |
-
}
|
| 43 |
-
return () => {
|
| 44 |
-
window.removeEventListener('mousedown', handleClickOutside);
|
| 45 |
-
window.removeEventListener('scroll', onClose);
|
| 46 |
-
};
|
| 47 |
-
}, [isOpen, onClose]);
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
const menuWidth = 220;
|
| 53 |
-
const menuHeight = 320;
|
| 54 |
-
const adjustedX = Math.min(x, window.innerWidth - menuWidth - 10);
|
| 55 |
-
const adjustedY = Math.min(y, window.innerHeight - menuHeight - 60);
|
| 56 |
|
| 57 |
return (
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
<span className="font-window-title text-[11px] font-bold tracking-wider uppercase">Desktop Options</span>
|
| 65 |
-
<span className="material-symbols-outlined text-xs">desktop_windows</span>
|
| 66 |
-
</div>
|
| 67 |
-
|
| 68 |
-
{/* Icon Layout actions */}
|
| 69 |
-
<button
|
| 70 |
-
onClick={() => {
|
| 71 |
-
onAutoArrange();
|
| 72 |
-
onClose();
|
| 73 |
-
}}
|
| 74 |
-
className="px-3 py-1.5 hover:bg-[#fde047] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 75 |
-
>
|
| 76 |
-
<span className="material-symbols-outlined text-base">grid_view</span>
|
| 77 |
-
Auto Arrange Icons
|
| 78 |
-
</button>
|
| 79 |
-
|
| 80 |
-
<button
|
| 81 |
-
onClick={() => {
|
| 82 |
-
onResetLayout();
|
| 83 |
-
onClose();
|
| 84 |
-
}}
|
| 85 |
-
className="px-3 py-1.5 hover:bg-[#fde047] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 86 |
>
|
| 87 |
-
<
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
);
|
| 168 |
}
|
|
|
|
| 1 |
+
import { useEffect, useMemo } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
useFloating,
|
| 4 |
+
shift,
|
| 5 |
+
flip,
|
| 6 |
+
offset,
|
| 7 |
+
autoUpdate,
|
| 8 |
+
useDismiss,
|
| 9 |
+
useRole,
|
| 10 |
+
useInteractions,
|
| 11 |
+
FloatingPortal,
|
| 12 |
+
} from '@floating-ui/react';
|
| 13 |
|
| 14 |
interface DesktopContextMenuProps {
|
| 15 |
x: number;
|
|
|
|
| 38 |
onToggleFullscreen,
|
| 39 |
isFullscreen,
|
| 40 |
}: DesktopContextMenuProps) {
|
| 41 |
+
// Virtual reference element for cursor click coordinates
|
| 42 |
+
const virtualReference = useMemo(
|
| 43 |
+
() => ({
|
| 44 |
+
getBoundingClientRect: () => ({
|
| 45 |
+
x,
|
| 46 |
+
y,
|
| 47 |
+
top: y,
|
| 48 |
+
left: x,
|
| 49 |
+
bottom: y,
|
| 50 |
+
right: x,
|
| 51 |
+
width: 0,
|
| 52 |
+
height: 0,
|
| 53 |
+
}),
|
| 54 |
+
}),
|
| 55 |
+
[x, y]
|
| 56 |
+
);
|
| 57 |
+
|
| 58 |
+
const {
|
| 59 |
+
refs: { setReference, setFloating },
|
| 60 |
+
floatingStyles,
|
| 61 |
+
context,
|
| 62 |
+
} = useFloating({
|
| 63 |
+
open: isOpen,
|
| 64 |
+
onOpenChange: (open) => {
|
| 65 |
+
if (!open) onClose();
|
| 66 |
+
},
|
| 67 |
+
placement: 'bottom-start',
|
| 68 |
+
middleware: [
|
| 69 |
+
offset(2),
|
| 70 |
+
flip({ padding: 12 }),
|
| 71 |
+
shift({ padding: 12 }),
|
| 72 |
+
],
|
| 73 |
+
whileElementsMounted: autoUpdate,
|
| 74 |
+
});
|
| 75 |
|
| 76 |
useEffect(() => {
|
| 77 |
+
setReference(virtualReference);
|
| 78 |
+
}, [virtualReference, setReference]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
const dismiss = useDismiss(context, { outsidePress: true, escapeKey: true });
|
| 81 |
+
const role = useRole(context, { role: 'menu' });
|
| 82 |
+
const { getFloatingProps } = useInteractions([dismiss, role]);
|
| 83 |
|
| 84 |
+
if (!isOpen) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
return (
|
| 87 |
+
<FloatingPortal>
|
| 88 |
+
<div
|
| 89 |
+
ref={setFloating}
|
| 90 |
+
style={floatingStyles}
|
| 91 |
+
{...getFloatingProps()}
|
| 92 |
+
className="z-[100] w-56 bg-paper-white border-[3px] border-ink-black gadget-shadow py-1.5 flex flex-col select-none text-ink-black animate-fade-in shadow-[4px_4px_0px_0px_#1E293B]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
>
|
| 94 |
+
<div className="px-3 py-1 bg-[#0ea5e9] text-white border-b-2 border-ink-black flex items-center justify-between mb-1 -mt-1.5 -mx-0">
|
| 95 |
+
<span className="font-window-title text-[11px] font-bold tracking-wider uppercase">Desktop Options</span>
|
| 96 |
+
<span className="material-symbols-outlined text-xs">desktop_windows</span>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
{/* Icon Layout actions */}
|
| 100 |
+
<button
|
| 101 |
+
onClick={() => {
|
| 102 |
+
onAutoArrange();
|
| 103 |
+
onClose();
|
| 104 |
+
}}
|
| 105 |
+
className="px-3 py-1.5 hover:bg-[#fde047] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 106 |
+
>
|
| 107 |
+
<span className="material-symbols-outlined text-base">grid_view</span>
|
| 108 |
+
Auto Arrange Icons
|
| 109 |
+
</button>
|
| 110 |
+
|
| 111 |
+
<button
|
| 112 |
+
onClick={() => {
|
| 113 |
+
onResetLayout();
|
| 114 |
+
onClose();
|
| 115 |
+
}}
|
| 116 |
+
className="px-3 py-1.5 hover:bg-[#fde047] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 117 |
+
>
|
| 118 |
+
<span className="material-symbols-outlined text-base">restart_alt</span>
|
| 119 |
+
Reset Icon Layout
|
| 120 |
+
</button>
|
| 121 |
+
|
| 122 |
+
<div className="h-[2px] bg-ink-black/20 my-1 mx-2" />
|
| 123 |
+
|
| 124 |
+
{/* Wallpaper & View */}
|
| 125 |
+
<button
|
| 126 |
+
onClick={() => {
|
| 127 |
+
onChangeWallpaper();
|
| 128 |
+
onClose();
|
| 129 |
+
}}
|
| 130 |
+
className="px-3 py-1.5 hover:bg-[#39ff14] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 131 |
+
>
|
| 132 |
+
<span className="material-symbols-outlined text-base">wallpaper</span>
|
| 133 |
+
Change Wallpaper...
|
| 134 |
+
</button>
|
| 135 |
+
|
| 136 |
+
<button
|
| 137 |
+
onClick={() => {
|
| 138 |
+
onToggleFullscreen();
|
| 139 |
+
onClose();
|
| 140 |
+
}}
|
| 141 |
+
className="px-3 py-1.5 hover:bg-[#39ff14] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 142 |
+
>
|
| 143 |
+
<span className="material-symbols-outlined text-base">
|
| 144 |
+
{isFullscreen ? 'fullscreen_exit' : 'fullscreen'}
|
| 145 |
+
</span>
|
| 146 |
+
{isFullscreen ? 'Exit Fullscreen' : 'Enter Fullscreen'}
|
| 147 |
+
</button>
|
| 148 |
+
|
| 149 |
+
<div className="h-[2px] bg-ink-black/20 my-1 mx-2" />
|
| 150 |
+
|
| 151 |
+
{/* Quick Launchers */}
|
| 152 |
+
<button
|
| 153 |
+
onClick={() => {
|
| 154 |
+
onOpenWindow('queue');
|
| 155 |
+
onClose();
|
| 156 |
+
}}
|
| 157 |
+
className="px-3 py-1.5 hover:bg-[#4cc9f0] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 158 |
+
>
|
| 159 |
+
<span className="material-symbols-outlined text-base">view_list</span>
|
| 160 |
+
Daily Queue
|
| 161 |
+
</button>
|
| 162 |
+
|
| 163 |
+
<button
|
| 164 |
+
onClick={() => {
|
| 165 |
+
onOpenWindow('terminal');
|
| 166 |
+
onClose();
|
| 167 |
+
}}
|
| 168 |
+
className="px-3 py-1.5 hover:bg-[#4cc9f0] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 169 |
+
>
|
| 170 |
+
<span className="material-symbols-outlined text-base">terminal</span>
|
| 171 |
+
Terminal Emulator
|
| 172 |
+
</button>
|
| 173 |
+
|
| 174 |
+
<button
|
| 175 |
+
onClick={() => {
|
| 176 |
+
onOpenWindow('computer');
|
| 177 |
+
onClose();
|
| 178 |
+
}}
|
| 179 |
+
className="px-3 py-1.5 hover:bg-[#4cc9f0] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 180 |
+
>
|
| 181 |
+
<span className="material-symbols-outlined text-base">folder</span>
|
| 182 |
+
My Computer
|
| 183 |
+
</button>
|
| 184 |
+
|
| 185 |
+
<div className="h-[2px] bg-ink-black/20 my-1 mx-2" />
|
| 186 |
+
|
| 187 |
+
<button
|
| 188 |
+
onClick={() => {
|
| 189 |
+
onTriggerSync();
|
| 190 |
+
onClose();
|
| 191 |
+
}}
|
| 192 |
+
className="px-3 py-1.5 hover:bg-[#f72585] hover:text-white flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
|
| 193 |
+
>
|
| 194 |
+
<span className="material-symbols-outlined text-base">cloud_sync</span>
|
| 195 |
+
Sync with Drive
|
| 196 |
+
</button>
|
| 197 |
+
</div>
|
| 198 |
+
</FloatingPortal>
|
| 199 |
);
|
| 200 |
}
|
algospaced-ui/src/components/ReviewQueue.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { useState, useEffect, useCallback } from 'react';
|
| 2 |
import { RefreshCw, FileText, Code, BookOpen } from 'lucide-react';
|
| 3 |
import OnboardingModal from './OnboardingModal';
|
| 4 |
import { findCatalogProblem } from '../services/catalogService';
|
|
@@ -164,9 +164,13 @@ export default function ReviewQueue({
|
|
| 164 |
|
| 165 |
// Reset ephemeral evaluation, explanation, and sandbox state when moving between review cards
|
| 166 |
const currentReviewId = reviews[0]?.id || reviews[0]?.problem_id;
|
|
|
|
| 167 |
useEffect(() => {
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
| 170 |
}, [currentReviewId, resetAiState, resetSandbox]);
|
| 171 |
|
| 172 |
const handleGradeWithReset = useCallback(
|
|
|
|
| 1 |
+
import { useState, useEffect, useCallback, useRef } from 'react';
|
| 2 |
import { RefreshCw, FileText, Code, BookOpen } from 'lucide-react';
|
| 3 |
import OnboardingModal from './OnboardingModal';
|
| 4 |
import { findCatalogProblem } from '../services/catalogService';
|
|
|
|
| 164 |
|
| 165 |
// Reset ephemeral evaluation, explanation, and sandbox state when moving between review cards
|
| 166 |
const currentReviewId = reviews[0]?.id || reviews[0]?.problem_id;
|
| 167 |
+
const prevReviewIdRef = useRef<string | undefined>(undefined);
|
| 168 |
useEffect(() => {
|
| 169 |
+
if (currentReviewId && prevReviewIdRef.current !== currentReviewId) {
|
| 170 |
+
prevReviewIdRef.current = currentReviewId;
|
| 171 |
+
resetAiState();
|
| 172 |
+
resetSandbox();
|
| 173 |
+
}
|
| 174 |
}, [currentReviewId, resetAiState, resetSandbox]);
|
| 175 |
|
| 176 |
const handleGradeWithReset = useCallback(
|
algospaced-ui/src/components/TerminalEmulator.tsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
import { useState, useRef, useEffect } from 'react';
|
| 2 |
import { supabase } from '../firebaseClient';
|
| 3 |
|
|
|
|
|
|
|
| 4 |
interface TerminalEmulatorProps {
|
| 5 |
onOpenWindow: (windowId: string) => void;
|
| 6 |
onClose: () => void;
|
| 7 |
}
|
| 8 |
|
| 9 |
// Custom helper to format result rows as a clean ASCII text table
|
| 10 |
-
function formatAsciiTable(columns: string[], rows:
|
| 11 |
if (columns.length === 0 || rows.length === 0) {
|
| 12 |
return ['Empty result set.'];
|
| 13 |
}
|
|
@@ -85,13 +87,14 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
|
|
| 85 |
}
|
| 86 |
|
| 87 |
const { command, args } = tokenize(trimmed);
|
| 88 |
-
|
| 89 |
|
| 90 |
switch (command) {
|
| 91 |
case 'help':
|
| 92 |
output.push(
|
| 93 |
'Available commands:',
|
| 94 |
' help - Display this documentation',
|
|
|
|
| 95 |
' streak - Retrieve your active Leitner combo streak metrics',
|
| 96 |
' sync - Run google drive file import sync',
|
| 97 |
' reviews - Fetch Leetcode numbers due for daily review',
|
|
@@ -105,6 +108,24 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
|
|
| 105 |
' exit - Close the terminal shell'
|
| 106 |
);
|
| 107 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
case 'clear':
|
| 109 |
setHistory([]);
|
| 110 |
return;
|
|
@@ -200,9 +221,16 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
|
|
| 200 |
if (data.length === 0) {
|
| 201 |
output.push('Queue status: CLEAR! 0 cards due.');
|
| 202 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
output.push(
|
| 204 |
`Queue status: ${data.length} card(s) due:`,
|
| 205 |
-
...data.map((r
|
| 206 |
);
|
| 207 |
}
|
| 208 |
} else {
|
|
|
|
| 1 |
import { useState, useRef, useEffect } from 'react';
|
| 2 |
import { supabase } from '../firebaseClient';
|
| 3 |
|
| 4 |
+
import { useProcessStore } from '../stores/useProcessStore';
|
| 5 |
+
|
| 6 |
interface TerminalEmulatorProps {
|
| 7 |
onOpenWindow: (windowId: string) => void;
|
| 8 |
onClose: () => void;
|
| 9 |
}
|
| 10 |
|
| 11 |
// Custom helper to format result rows as a clean ASCII text table
|
| 12 |
+
function formatAsciiTable(columns: string[], rows: Record<string, unknown>[]): string[] {
|
| 13 |
if (columns.length === 0 || rows.length === 0) {
|
| 14 |
return ['Empty result set.'];
|
| 15 |
}
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
const { command, args } = tokenize(trimmed);
|
| 90 |
+
const output: string[] = [`$ ${trimmed}`];
|
| 91 |
|
| 92 |
switch (command) {
|
| 93 |
case 'help':
|
| 94 |
output.push(
|
| 95 |
'Available commands:',
|
| 96 |
' help - Display this documentation',
|
| 97 |
+
' ps - Inspect OS process table (PIDs & task states)',
|
| 98 |
' streak - Retrieve your active Leitner combo streak metrics',
|
| 99 |
' sync - Run google drive file import sync',
|
| 100 |
' reviews - Fetch Leetcode numbers due for daily review',
|
|
|
|
| 108 |
' exit - Close the terminal shell'
|
| 109 |
);
|
| 110 |
break;
|
| 111 |
+
case 'ps':
|
| 112 |
+
case 'top': {
|
| 113 |
+
const procs = Object.values(useProcessStore.getState().processes);
|
| 114 |
+
if (procs.length === 0) {
|
| 115 |
+
output.push('No background processes currently in table.');
|
| 116 |
+
} else {
|
| 117 |
+
output.push('AlgoSpaced OS Process Table:');
|
| 118 |
+
const tableRows = procs.map(p => ({
|
| 119 |
+
PID: p.pid.substring(0, 16),
|
| 120 |
+
APP: p.appId,
|
| 121 |
+
STATUS: p.status.toUpperCase(),
|
| 122 |
+
NAME: p.title.substring(0, 24)
|
| 123 |
+
}));
|
| 124 |
+
const asciiLines = formatAsciiTable(['PID', 'APP', 'STATUS', 'NAME'], tableRows);
|
| 125 |
+
output.push(...asciiLines);
|
| 126 |
+
}
|
| 127 |
+
break;
|
| 128 |
+
}
|
| 129 |
case 'clear':
|
| 130 |
setHistory([]);
|
| 131 |
return;
|
|
|
|
| 221 |
if (data.length === 0) {
|
| 222 |
output.push('Queue status: CLEAR! 0 cards due.');
|
| 223 |
} else {
|
| 224 |
+
interface DueReviewResponse {
|
| 225 |
+
problems?: {
|
| 226 |
+
problem_number?: number;
|
| 227 |
+
name?: string;
|
| 228 |
+
};
|
| 229 |
+
box_level?: number;
|
| 230 |
+
}
|
| 231 |
output.push(
|
| 232 |
`Queue status: ${data.length} card(s) due:`,
|
| 233 |
+
...(data as DueReviewResponse[]).map((r) => ` - LeetCode ${r.problems?.problem_number ?? '?'}: ${r.problems?.name ?? 'Unknown'} (Box ${r.box_level ?? 1})`)
|
| 234 |
);
|
| 235 |
}
|
| 236 |
} else {
|
algospaced-ui/src/components/WindowShell.tsx
CHANGED
|
@@ -1,15 +1,17 @@
|
|
| 1 |
-
import React, { useState, useRef, useEffect } from 'react';
|
|
|
|
| 2 |
import WindowErrorBoundary from './WindowErrorBoundary';
|
|
|
|
| 3 |
|
| 4 |
interface WindowShellProps {
|
| 5 |
id: string;
|
| 6 |
title: string;
|
| 7 |
isOpen: boolean;
|
| 8 |
isMinimized: boolean;
|
| 9 |
-
onClose: () => void;
|
| 10 |
-
onMinimize: () => void;
|
| 11 |
-
activeWindow: string;
|
| 12 |
-
setActiveWindow: (id: string) => void;
|
| 13 |
children: React.ReactNode;
|
| 14 |
icon?: string;
|
| 15 |
defaultWidth?: string;
|
|
@@ -48,136 +50,216 @@ export default function WindowShell({
|
|
| 48 |
return isNaN(num) ? 500 : num;
|
| 49 |
};
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
const [position, setPosition] = useState(() => {
|
|
|
|
|
|
|
| 52 |
if (defaultX === undefined && defaultY === undefined) {
|
| 53 |
return {
|
| 54 |
x: Math.floor(Math.random() * 40) - 20,
|
| 55 |
-
y: Math.floor(Math.random() * 40) - 20
|
| 56 |
};
|
| 57 |
}
|
| 58 |
return { x: defaultX ?? 0, y: defaultY ?? 0 };
|
| 59 |
});
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
});
|
| 64 |
|
| 65 |
const [isDragging, setIsDragging] = useState(false);
|
| 66 |
const [isResizing, setIsResizing] = useState(false);
|
| 67 |
-
const [isMaximized, setIsMaximized] = useState(false);
|
| 68 |
|
| 69 |
-
const
|
| 70 |
-
const
|
| 71 |
const windowRef = useRef<HTMLDivElement>(null);
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
if (e.button !== 0) return;
|
| 79 |
-
const target = e.target as HTMLElement;
|
| 80 |
-
if (target.closest('.window-control-btn') || target.closest('.window-resize-handle')) return;
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
e.stopPropagation();
|
| 95 |
-
e.preventDefault();
|
| 96 |
-
setActiveWindow(id);
|
| 97 |
-
setIsResizing(true);
|
| 98 |
-
resizeStart.current = {
|
| 99 |
-
width: dimensions.width,
|
| 100 |
-
height: dimensions.height,
|
| 101 |
-
x: e.clientX,
|
| 102 |
-
y: e.clientY
|
| 103 |
};
|
| 104 |
-
};
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
const deltaX = e.clientX - resizeStart.current.x;
|
| 114 |
-
const deltaY = e.clientY - resizeStart.current.y;
|
| 115 |
-
|
| 116 |
-
// Enforce minimum dimensions
|
| 117 |
-
const newWidth = Math.max(minWidth, resizeStart.current.width + deltaX);
|
| 118 |
-
const newHeight = Math.max(minHeight, resizeStart.current.height + deltaY);
|
| 119 |
-
|
| 120 |
-
setDimensions({
|
| 121 |
-
width: newWidth,
|
| 122 |
-
height: newHeight
|
| 123 |
-
});
|
| 124 |
}
|
| 125 |
-
};
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
return (
|
| 146 |
<div
|
| 147 |
ref={windowRef}
|
| 148 |
-
onMouseDown={
|
| 149 |
-
style={
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
? 'top-0 left-0 w-full h-[calc(100vh-56px)] max-w-none max-h-none border-t-0 border-x-0'
|
| 167 |
: isMaximized
|
| 168 |
? 'top-0 left-0 max-w-none max-h-none border-ink-black'
|
| 169 |
: 'top-1/2 left-1/2 max-w-[98vw] max-h-[90vh] border-ink-black'
|
| 170 |
} ${
|
| 171 |
-
isActive
|
|
|
|
|
|
|
| 172 |
}`}
|
| 173 |
>
|
| 174 |
{/* Title Bar */}
|
| 175 |
<div
|
| 176 |
-
|
|
|
|
| 177 |
style={{ backgroundColor: titleBarColor }}
|
| 178 |
-
className=
|
|
|
|
|
|
|
| 179 |
>
|
| 180 |
-
<div className="flex items-center gap-2">
|
| 181 |
{icon && (
|
| 182 |
<span className="material-symbols-outlined select-none" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 183 |
{icon}
|
|
@@ -185,24 +267,26 @@ export default function WindowShell({
|
|
| 185 |
)}
|
| 186 |
<span className="font-window-title text-sm md:text-base font-bold tracking-wide select-none">{title}</span>
|
| 187 |
</div>
|
| 188 |
-
<div className="flex gap-1.5">
|
| 189 |
{!isMobile && (
|
| 190 |
<>
|
| 191 |
<button
|
| 192 |
onClick={(e) => {
|
| 193 |
e.stopPropagation();
|
| 194 |
-
|
| 195 |
}}
|
| 196 |
className="window-control-btn w-7 h-7 bg-white text-ink-black border-[3px] border-ink-black flex items-center justify-center hover:bg-yellow-300 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
|
|
|
| 197 |
>
|
| 198 |
<span className="material-symbols-outlined text-[14px] font-bold">minimize</span>
|
| 199 |
</button>
|
| 200 |
<button
|
| 201 |
onClick={(e) => {
|
| 202 |
e.stopPropagation();
|
| 203 |
-
|
| 204 |
}}
|
| 205 |
className="window-control-btn w-7 h-7 bg-white text-ink-black border-[3px] border-ink-black flex items-center justify-center hover:bg-yellow-300 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
|
|
|
| 206 |
>
|
| 207 |
<span className="material-symbols-outlined text-[14px] font-bold">
|
| 208 |
{isMaximized ? 'filter_none' : 'crop_square'}
|
|
@@ -213,9 +297,10 @@ export default function WindowShell({
|
|
| 213 |
<button
|
| 214 |
onClick={(e) => {
|
| 215 |
e.stopPropagation();
|
| 216 |
-
|
| 217 |
}}
|
| 218 |
className="window-control-btn w-7 h-7 bg-highlight-pink text-white border-[3px] border-ink-black flex items-center justify-center hover:bg-rose-600 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
|
|
|
| 219 |
>
|
| 220 |
<span className="material-symbols-outlined text-[14px] font-bold">close</span>
|
| 221 |
</button>
|
|
@@ -223,8 +308,12 @@ export default function WindowShell({
|
|
| 223 |
</div>
|
| 224 |
|
| 225 |
{/* Window Content */}
|
| 226 |
-
<div
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
{children}
|
| 229 |
</WindowErrorBoundary>
|
| 230 |
</div>
|
|
@@ -232,8 +321,9 @@ export default function WindowShell({
|
|
| 232 |
{/* Resize Handle */}
|
| 233 |
{!isMobile && !isMaximized && (
|
| 234 |
<div
|
| 235 |
-
|
| 236 |
-
className="window-resize-handle absolute bottom-0 right-0 w-
|
|
|
|
| 237 |
>
|
| 238 |
<svg width="10" height="10" viewBox="0 0 10 10" className="text-ink-black opacity-60">
|
| 239 |
<line x1="8" y1="2" x2="2" y2="8" stroke="currentColor" strokeWidth="1.5" />
|
|
|
|
| 1 |
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
| 2 |
+
import { useDrag } from '@use-gesture/react';
|
| 3 |
import WindowErrorBoundary from './WindowErrorBoundary';
|
| 4 |
+
import { useOSStore } from '../stores/useOSStore';
|
| 5 |
|
| 6 |
interface WindowShellProps {
|
| 7 |
id: string;
|
| 8 |
title: string;
|
| 9 |
isOpen: boolean;
|
| 10 |
isMinimized: boolean;
|
| 11 |
+
onClose?: () => void;
|
| 12 |
+
onMinimize?: () => void;
|
| 13 |
+
activeWindow?: string;
|
| 14 |
+
setActiveWindow?: (id: string) => void;
|
| 15 |
children: React.ReactNode;
|
| 16 |
icon?: string;
|
| 17 |
defaultWidth?: string;
|
|
|
|
| 50 |
return isNaN(num) ? 500 : num;
|
| 51 |
};
|
| 52 |
|
| 53 |
+
const storeZIndex = useOSStore(s => s.windowZIndexes[id]);
|
| 54 |
+
const storeActiveWindow = useOSStore(s => s.activeWindow);
|
| 55 |
+
const storeCloseWindow = useOSStore(s => s.closeWindow);
|
| 56 |
+
const storeMinimizeWindow = useOSStore(s => s.minimizeWindow);
|
| 57 |
+
const storeFocusWindow = useOSStore(s => s.focusWindow);
|
| 58 |
+
const storeIsMaximized = useOSStore(s => !!s.maximizedWindows[id]);
|
| 59 |
+
|
| 60 |
+
const effectiveActiveWindow = activeWindow ?? storeActiveWindow;
|
| 61 |
+
const isActive = effectiveActiveWindow === id;
|
| 62 |
+
const effectiveZIndex = storeZIndex ?? (isActive ? 40 : 30);
|
| 63 |
+
const isMaximized = !isMobile && storeIsMaximized;
|
| 64 |
+
|
| 65 |
+
const handleClose = onClose ?? (() => storeCloseWindow(id));
|
| 66 |
+
const handleMinimize = onMinimize ?? (() => storeMinimizeWindow(id));
|
| 67 |
+
const handleFocus = useCallback(() => {
|
| 68 |
+
if (setActiveWindow) {
|
| 69 |
+
setActiveWindow(id);
|
| 70 |
+
} else {
|
| 71 |
+
storeFocusWindow(id);
|
| 72 |
+
}
|
| 73 |
+
}, [id, setActiveWindow, storeFocusWindow]);
|
| 74 |
+
|
| 75 |
+
const handleToggleMaximize = useCallback((e?: React.MouseEvent) => {
|
| 76 |
+
e?.stopPropagation();
|
| 77 |
+
useOSStore.getState().toggleMaximize(id);
|
| 78 |
+
}, [id]);
|
| 79 |
+
|
| 80 |
const [position, setPosition] = useState(() => {
|
| 81 |
+
const savedPos = useOSStore.getState().windowPositions[id];
|
| 82 |
+
if (savedPos) return savedPos;
|
| 83 |
if (defaultX === undefined && defaultY === undefined) {
|
| 84 |
return {
|
| 85 |
x: Math.floor(Math.random() * 40) - 20,
|
| 86 |
+
y: Math.floor(Math.random() * 40) - 20,
|
| 87 |
};
|
| 88 |
}
|
| 89 |
return { x: defaultX ?? 0, y: defaultY ?? 0 };
|
| 90 |
});
|
| 91 |
+
|
| 92 |
+
const [dimensions, setDimensions] = useState(() => {
|
| 93 |
+
const savedDim = useOSStore.getState().windowSizes[id];
|
| 94 |
+
if (savedDim) return savedDim;
|
| 95 |
+
return {
|
| 96 |
+
width: parseDimension(defaultWidth),
|
| 97 |
+
height: parseDimension(defaultHeight),
|
| 98 |
+
};
|
| 99 |
});
|
| 100 |
|
| 101 |
const [isDragging, setIsDragging] = useState(false);
|
| 102 |
const [isResizing, setIsResizing] = useState(false);
|
|
|
|
| 103 |
|
| 104 |
+
const latestPos = useRef(position);
|
| 105 |
+
const latestDim = useRef(dimensions);
|
| 106 |
const windowRef = useRef<HTMLDivElement>(null);
|
| 107 |
|
| 108 |
+
useEffect(() => {
|
| 109 |
+
latestPos.current = position;
|
| 110 |
+
}, [position]);
|
| 111 |
|
| 112 |
+
useEffect(() => {
|
| 113 |
+
latestDim.current = dimensions;
|
| 114 |
+
}, [dimensions]);
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
const clampPosition = useCallback((x: number, y: number, w: number, h: number) => {
|
| 117 |
+
if (typeof window === 'undefined') return { x, y };
|
| 118 |
+
const halfScreenW = window.innerWidth / 2;
|
| 119 |
+
const halfScreenH = window.innerHeight / 2;
|
| 120 |
+
const halfWinW = w / 2;
|
| 121 |
+
const halfWinH = h / 2;
|
| 122 |
+
|
| 123 |
+
// Title bar cannot go above upper screen edge
|
| 124 |
+
const minY = -halfScreenH + halfWinH;
|
| 125 |
+
// Allow dragging down but keep title bar reachable (leave 80px buffer above bottom taskbar)
|
| 126 |
+
const maxY = Math.max(minY, halfScreenH + halfWinH - 80);
|
| 127 |
+
|
| 128 |
+
// Keep at least 80px of window on screen horizontally
|
| 129 |
+
const minX = -halfScreenW - halfWinW + 80;
|
| 130 |
+
const maxX = halfScreenW + halfWinW - 80;
|
| 131 |
|
| 132 |
+
return {
|
| 133 |
+
x: Math.min(Math.max(x, minX), maxX),
|
| 134 |
+
y: Math.min(Math.max(y, minY), maxY),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
};
|
| 136 |
+
}, []);
|
| 137 |
|
| 138 |
+
// Hardware-accelerated window dragging via @use-gesture/react
|
| 139 |
+
const bindDrag = useDrag(
|
| 140 |
+
({ offset: [ox, oy], first, last, event, cancel }) => {
|
| 141 |
+
const target = event.target as HTMLElement | null;
|
| 142 |
+
if (target?.closest('.window-control-btn') || target?.closest('.window-resize-handle')) {
|
| 143 |
+
cancel();
|
| 144 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
}
|
|
|
|
| 146 |
|
| 147 |
+
if (first) {
|
| 148 |
+
handleFocus();
|
| 149 |
+
setIsDragging(true);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
const clamped = clampPosition(ox, oy, latestDim.current.width, latestDim.current.height);
|
| 153 |
+
latestPos.current = clamped;
|
| 154 |
|
| 155 |
+
// 60/120 FPS Direct DOM mutation without triggering React component re-renders
|
| 156 |
+
if (windowRef.current) {
|
| 157 |
+
windowRef.current.style.transform = `translate3d(calc(-50% + ${clamped.x}px), calc(-50% + ${clamped.y}px), 0)`;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if (last) {
|
| 161 |
+
setIsDragging(false);
|
| 162 |
+
setPosition(clamped);
|
| 163 |
+
useOSStore.getState().updateWindowPosition(id, clamped.x, clamped.y);
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
from: () => [latestPos.current.x, latestPos.current.y],
|
| 168 |
+
pointer: { capture: true },
|
| 169 |
+
enabled: !isMobile && !isMaximized,
|
| 170 |
+
eventOptions: { passive: false },
|
| 171 |
}
|
| 172 |
+
);
|
| 173 |
|
| 174 |
+
// Hardware-accelerated window resizing via @use-gesture/react
|
| 175 |
+
const bindResize = useDrag(
|
| 176 |
+
({ offset: [ow, oh], first, last, event }) => {
|
| 177 |
+
event.stopPropagation();
|
| 178 |
+
if (first) {
|
| 179 |
+
handleFocus();
|
| 180 |
+
setIsResizing(true);
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
const newWidth = Math.max(minWidth, ow);
|
| 184 |
+
const newHeight = Math.max(minHeight, oh);
|
| 185 |
+
latestDim.current = { width: newWidth, height: newHeight };
|
| 186 |
+
|
| 187 |
+
// Direct DOM mutation for resize
|
| 188 |
+
if (windowRef.current) {
|
| 189 |
+
windowRef.current.style.width = `${newWidth}px`;
|
| 190 |
+
windowRef.current.style.height = `${newHeight}px`;
|
| 191 |
+
}
|
| 192 |
|
| 193 |
+
if (last) {
|
| 194 |
+
setIsResizing(false);
|
| 195 |
+
setDimensions(latestDim.current);
|
| 196 |
+
useOSStore.getState().updateWindowSize(id, latestDim.current.width, latestDim.current.height);
|
| 197 |
+
}
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
from: () => [latestDim.current.width, latestDim.current.height],
|
| 201 |
+
pointer: { capture: true },
|
| 202 |
+
enabled: !isMobile && !isMaximized,
|
| 203 |
+
eventOptions: { passive: false },
|
| 204 |
+
}
|
| 205 |
+
);
|
| 206 |
+
|
| 207 |
+
// Keep window DOM subtree alive on minimize (display: none) to avoid destroying in-flight tasks
|
| 208 |
+
if (!isOpen) return null;
|
| 209 |
|
| 210 |
return (
|
| 211 |
<div
|
| 212 |
ref={windowRef}
|
| 213 |
+
onMouseDown={handleFocus}
|
| 214 |
+
style={
|
| 215 |
+
isMobile
|
| 216 |
+
? {
|
| 217 |
+
zIndex: effectiveZIndex,
|
| 218 |
+
display: isMinimized ? 'none' : 'flex',
|
| 219 |
+
}
|
| 220 |
+
: isMaximized
|
| 221 |
+
? {
|
| 222 |
+
width: '100vw',
|
| 223 |
+
height: 'calc(100vh - 56px)',
|
| 224 |
+
top: 0,
|
| 225 |
+
left: 0,
|
| 226 |
+
transform: 'none',
|
| 227 |
+
zIndex: effectiveZIndex,
|
| 228 |
+
display: isMinimized ? 'none' : 'flex',
|
| 229 |
+
}
|
| 230 |
+
: {
|
| 231 |
+
width: `${dimensions.width}px`,
|
| 232 |
+
height: `${dimensions.height}px`,
|
| 233 |
+
transform: `translate3d(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px), 0)`,
|
| 234 |
+
zIndex: effectiveZIndex,
|
| 235 |
+
display: isMinimized ? 'none' : 'flex',
|
| 236 |
+
willChange: isDragging || isResizing ? 'transform, width, height' : 'auto',
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
className={`absolute bg-paper-white border-[4px] flex flex-col overflow-hidden window-shadow ${
|
| 240 |
+
isDragging || isResizing ? 'transition-none' : 'transition-all duration-150'
|
| 241 |
+
} ${
|
| 242 |
+
isMobile
|
| 243 |
? 'top-0 left-0 w-full h-[calc(100vh-56px)] max-w-none max-h-none border-t-0 border-x-0'
|
| 244 |
: isMaximized
|
| 245 |
? 'top-0 left-0 max-w-none max-h-none border-ink-black'
|
| 246 |
: 'top-1/2 left-1/2 max-w-[98vw] max-h-[90vh] border-ink-black'
|
| 247 |
} ${
|
| 248 |
+
isActive
|
| 249 |
+
? 'border-ink-black shadow-[8px_8px_0px_0px_rgba(30,41,59,1)]'
|
| 250 |
+
: 'border-ink-black opacity-95 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]'
|
| 251 |
}`}
|
| 252 |
>
|
| 253 |
{/* Title Bar */}
|
| 254 |
<div
|
| 255 |
+
{...bindDrag()}
|
| 256 |
+
onDoubleClick={isMobile ? undefined : handleToggleMaximize}
|
| 257 |
style={{ backgroundColor: titleBarColor }}
|
| 258 |
+
className={`border-b-[4px] border-ink-black px-4 py-2 flex justify-between items-center text-white shrink-0 select-none touch-none ${
|
| 259 |
+
isMobile || isMaximized ? 'cursor-default' : isDragging ? 'cursor-grabbing' : 'cursor-grab'
|
| 260 |
+
}`}
|
| 261 |
>
|
| 262 |
+
<div className="flex items-center gap-2 pointer-events-none">
|
| 263 |
{icon && (
|
| 264 |
<span className="material-symbols-outlined select-none" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 265 |
{icon}
|
|
|
|
| 267 |
)}
|
| 268 |
<span className="font-window-title text-sm md:text-base font-bold tracking-wide select-none">{title}</span>
|
| 269 |
</div>
|
| 270 |
+
<div className="flex gap-1.5" onPointerDown={(e) => e.stopPropagation()}>
|
| 271 |
{!isMobile && (
|
| 272 |
<>
|
| 273 |
<button
|
| 274 |
onClick={(e) => {
|
| 275 |
e.stopPropagation();
|
| 276 |
+
handleMinimize();
|
| 277 |
}}
|
| 278 |
className="window-control-btn w-7 h-7 bg-white text-ink-black border-[3px] border-ink-black flex items-center justify-center hover:bg-yellow-300 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
| 279 |
+
title="Minimize"
|
| 280 |
>
|
| 281 |
<span className="material-symbols-outlined text-[14px] font-bold">minimize</span>
|
| 282 |
</button>
|
| 283 |
<button
|
| 284 |
onClick={(e) => {
|
| 285 |
e.stopPropagation();
|
| 286 |
+
handleToggleMaximize(e);
|
| 287 |
}}
|
| 288 |
className="window-control-btn w-7 h-7 bg-white text-ink-black border-[3px] border-ink-black flex items-center justify-center hover:bg-yellow-300 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
| 289 |
+
title={isMaximized ? 'Restore' : 'Maximize'}
|
| 290 |
>
|
| 291 |
<span className="material-symbols-outlined text-[14px] font-bold">
|
| 292 |
{isMaximized ? 'filter_none' : 'crop_square'}
|
|
|
|
| 297 |
<button
|
| 298 |
onClick={(e) => {
|
| 299 |
e.stopPropagation();
|
| 300 |
+
handleClose();
|
| 301 |
}}
|
| 302 |
className="window-control-btn w-7 h-7 bg-highlight-pink text-white border-[3px] border-ink-black flex items-center justify-center hover:bg-rose-600 active:translate-y-0.5 active:translate-x-0.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none transition-all cursor-pointer"
|
| 303 |
+
title="Close"
|
| 304 |
>
|
| 305 |
<span className="material-symbols-outlined text-[14px] font-bold">close</span>
|
| 306 |
</button>
|
|
|
|
| 308 |
</div>
|
| 309 |
|
| 310 |
{/* Window Content */}
|
| 311 |
+
<div
|
| 312 |
+
className={`flex-1 overflow-hidden relative bg-paper-white flex flex-col ${
|
| 313 |
+
isDragging || isResizing ? 'pointer-events-none select-none' : ''
|
| 314 |
+
}`}
|
| 315 |
+
>
|
| 316 |
+
<WindowErrorBoundary windowId={id} windowTitle={title} onClose={handleClose}>
|
| 317 |
{children}
|
| 318 |
</WindowErrorBoundary>
|
| 319 |
</div>
|
|
|
|
| 321 |
{/* Resize Handle */}
|
| 322 |
{!isMobile && !isMaximized && (
|
| 323 |
<div
|
| 324 |
+
{...bindResize()}
|
| 325 |
+
className="window-resize-handle absolute bottom-0 right-0 w-5 h-5 cursor-se-resize flex items-end justify-end p-0.5 select-none z-[50] touch-none"
|
| 326 |
+
title="Resize Window"
|
| 327 |
>
|
| 328 |
<svg width="10" height="10" viewBox="0 0 10 10" className="text-ink-black opacity-60">
|
| 329 |
<line x1="8" y1="2" x2="2" y2="8" stroke="currentColor" strokeWidth="1.5" />
|
algospaced-ui/src/components/desktop/DesktopStartMenu.tsx
CHANGED
|
@@ -1,144 +1,160 @@
|
|
| 1 |
import React from 'react';
|
| 2 |
|
| 3 |
-
interface DesktopStartMenuProps {
|
| 4 |
isOpen: boolean;
|
| 5 |
onOpenWindow: (id: string) => void;
|
| 6 |
onOpenOnboarding: () => void;
|
| 7 |
onTriggerSync: () => void;
|
| 8 |
onSignOut: () => void;
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
-
export const DesktopStartMenu
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 36 |
-
>
|
| 37 |
-
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 38 |
-
view_list
|
| 39 |
-
</span>
|
| 40 |
-
Daily Queue
|
| 41 |
-
</button>
|
| 42 |
-
<button
|
| 43 |
-
onClick={() => onOpenWindow('journey')}
|
| 44 |
-
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 45 |
-
>
|
| 46 |
-
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 47 |
-
route
|
| 48 |
-
</span>
|
| 49 |
-
Journey Path
|
| 50 |
-
</button>
|
| 51 |
-
<button
|
| 52 |
-
onClick={onOpenOnboarding}
|
| 53 |
-
className="w-full text-left hover:bg-amber-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 54 |
-
>
|
| 55 |
-
<span className="material-symbols-outlined text-lg text-amber-600" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 56 |
-
bolt
|
| 57 |
-
</span>
|
| 58 |
-
Fast-Track Checklist
|
| 59 |
-
</button>
|
| 60 |
-
<button
|
| 61 |
-
onClick={onTriggerSync}
|
| 62 |
-
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 63 |
-
>
|
| 64 |
-
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 65 |
-
cloud_sync
|
| 66 |
-
</span>
|
| 67 |
-
Drive Sync
|
| 68 |
-
</button>
|
| 69 |
-
<button
|
| 70 |
-
onClick={() => onOpenWindow('github')}
|
| 71 |
-
className="w-full text-left hover:bg-slate-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 72 |
-
>
|
| 73 |
-
<span className="material-symbols-outlined text-lg text-slate-800" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 74 |
-
code
|
| 75 |
-
</span>
|
| 76 |
-
GitHub Solutions
|
| 77 |
-
</button>
|
| 78 |
-
<button
|
| 79 |
-
onClick={() => onOpenWindow('terminal')}
|
| 80 |
-
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 81 |
-
>
|
| 82 |
-
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 83 |
-
terminal
|
| 84 |
-
</span>
|
| 85 |
-
Terminal
|
| 86 |
-
</button>
|
| 87 |
-
<button
|
| 88 |
-
onClick={() => onOpenWindow('computer')}
|
| 89 |
-
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 90 |
-
>
|
| 91 |
-
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 92 |
-
desktop_windows
|
| 93 |
</span>
|
| 94 |
-
|
| 95 |
-
<
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
</div>
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import React from 'react';
|
| 2 |
|
| 3 |
+
interface DesktopStartMenuProps extends React.HTMLAttributes<HTMLDivElement> {
|
| 4 |
isOpen: boolean;
|
| 5 |
onOpenWindow: (id: string) => void;
|
| 6 |
onOpenOnboarding: () => void;
|
| 7 |
onTriggerSync: () => void;
|
| 8 |
onSignOut: () => void;
|
| 9 |
+
style?: React.CSSProperties;
|
| 10 |
}
|
| 11 |
|
| 12 |
+
export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMenuProps>(
|
| 13 |
+
(
|
| 14 |
+
{
|
| 15 |
+
isOpen,
|
| 16 |
+
onOpenWindow,
|
| 17 |
+
onOpenOnboarding,
|
| 18 |
+
onTriggerSync,
|
| 19 |
+
onSignOut,
|
| 20 |
+
style,
|
| 21 |
+
className,
|
| 22 |
+
...rest
|
| 23 |
+
},
|
| 24 |
+
ref
|
| 25 |
+
) => {
|
| 26 |
+
if (!isOpen) return null;
|
| 27 |
|
| 28 |
+
return (
|
| 29 |
+
<div
|
| 30 |
+
ref={ref}
|
| 31 |
+
onClick={(e) => e.stopPropagation()}
|
| 32 |
+
id="start-menu"
|
| 33 |
+
style={style}
|
| 34 |
+
{...rest}
|
| 35 |
+
className={`w-64 bg-white border-[3px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col p-4 z-[90] select-none ${
|
| 36 |
+
style ? '' : 'absolute bottom-14 left-0 ml-2 mb-2'
|
| 37 |
+
} ${className || ''}`}
|
| 38 |
+
>
|
| 39 |
+
<div className="flex items-center justify-between border-b-[2px] border-ink-black pb-2 mb-3">
|
| 40 |
+
<span className="font-arcade text-[9px] font-bold text-ink-black tracking-wider">ALGOSPACED OS</span>
|
| 41 |
+
<span className="font-arcade text-[7px] font-extrabold bg-[#facc15] text-ink-black px-1.5 py-0.5 border-[1.5px] border-ink-black shadow-[1.5px_1.5px_0_0_#1E293B]">
|
| 42 |
+
BETA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
</span>
|
| 44 |
+
</div>
|
| 45 |
+
<div className="flex flex-col gap-2.5 font-window-title text-base font-bold">
|
| 46 |
+
<button
|
| 47 |
+
onClick={() => onOpenWindow('queue')}
|
| 48 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 49 |
+
>
|
| 50 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 51 |
+
view_list
|
| 52 |
+
</span>
|
| 53 |
+
Daily Queue
|
| 54 |
+
</button>
|
| 55 |
+
<button
|
| 56 |
+
onClick={() => onOpenWindow('journey')}
|
| 57 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 58 |
+
>
|
| 59 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 60 |
+
route
|
| 61 |
+
</span>
|
| 62 |
+
Journey Path
|
| 63 |
+
</button>
|
| 64 |
+
<button
|
| 65 |
+
onClick={onOpenOnboarding}
|
| 66 |
+
className="w-full text-left hover:bg-amber-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 67 |
+
>
|
| 68 |
+
<span className="material-symbols-outlined text-lg text-amber-600" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 69 |
+
bolt
|
| 70 |
+
</span>
|
| 71 |
+
Fast-Track Checklist
|
| 72 |
+
</button>
|
| 73 |
+
<button
|
| 74 |
+
onClick={onTriggerSync}
|
| 75 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 76 |
+
>
|
| 77 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 78 |
+
cloud_sync
|
| 79 |
+
</span>
|
| 80 |
+
Drive Sync
|
| 81 |
+
</button>
|
| 82 |
+
<button
|
| 83 |
+
onClick={() => onOpenWindow('github')}
|
| 84 |
+
className="w-full text-left hover:bg-slate-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 85 |
+
>
|
| 86 |
+
<span className="material-symbols-outlined text-lg text-slate-800" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 87 |
+
code
|
| 88 |
+
</span>
|
| 89 |
+
GitHub Solutions
|
| 90 |
+
</button>
|
| 91 |
+
<button
|
| 92 |
+
onClick={() => onOpenWindow('terminal')}
|
| 93 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 94 |
+
>
|
| 95 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 96 |
+
terminal
|
| 97 |
+
</span>
|
| 98 |
+
Terminal
|
| 99 |
+
</button>
|
| 100 |
+
<button
|
| 101 |
+
onClick={() => onOpenWindow('computer')}
|
| 102 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 103 |
+
>
|
| 104 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 105 |
+
desktop_windows
|
| 106 |
+
</span>
|
| 107 |
+
My Computer
|
| 108 |
+
</button>
|
| 109 |
+
<button
|
| 110 |
+
onClick={() => onOpenWindow('companion')}
|
| 111 |
+
className="w-full text-left hover:bg-[#ffe24c]/40 px-3 py-1.5 border-2 border-transparent hover:border-[#f59e0b] transition-colors cursor-pointer flex items-center gap-2"
|
| 112 |
+
>
|
| 113 |
+
<span className="material-symbols-outlined text-lg text-[#f59e0b]" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 114 |
+
castle
|
| 115 |
+
</span>
|
| 116 |
+
Princess Tower
|
| 117 |
+
</button>
|
| 118 |
+
<button
|
| 119 |
+
onClick={() => onOpenWindow('python')}
|
| 120 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 121 |
+
>
|
| 122 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 123 |
+
sports_esports
|
| 124 |
+
</span>
|
| 125 |
+
Python Challenge
|
| 126 |
+
</button>
|
| 127 |
+
<button
|
| 128 |
+
onClick={() => onOpenWindow('mysql')}
|
| 129 |
+
className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
|
| 130 |
+
>
|
| 131 |
+
<span className="material-symbols-outlined text-lg" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 132 |
+
database
|
| 133 |
+
</span>
|
| 134 |
+
MySQL Playground
|
| 135 |
+
</button>
|
| 136 |
+
<button
|
| 137 |
+
onClick={() => onOpenWindow('settings')}
|
| 138 |
+
className="w-full text-left hover:bg-[#10b981]/25 px-3 py-1.5 border-2 border-transparent hover:border-[#10b981] transition-colors cursor-pointer flex items-center gap-2"
|
| 139 |
+
>
|
| 140 |
+
<span className="material-symbols-outlined text-lg text-[#10b981]" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 141 |
+
key
|
| 142 |
+
</span>
|
| 143 |
+
API Configuration
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
|
| 147 |
+
<div className="mt-4 flex justify-end border-t-[3px] border-ink-black pt-4 select-none">
|
| 148 |
+
<button
|
| 149 |
+
onClick={onSignOut}
|
| 150 |
+
className="bg-highlight-pink text-white font-window-title px-4 py-2.5 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_#1E293B] active:translate-y-0.5 active:translate-x-0.5 active:shadow-none hover:bg-rose-600 transition-all cursor-pointer font-bold uppercase text-xs"
|
| 151 |
+
>
|
| 152 |
+
Shut Down
|
| 153 |
+
</button>
|
| 154 |
+
</div>
|
| 155 |
</div>
|
| 156 |
+
);
|
| 157 |
+
}
|
| 158 |
+
);
|
| 159 |
+
|
| 160 |
+
DesktopStartMenu.displayName = 'DesktopStartMenu';
|
algospaced-ui/src/components/desktop/DesktopTaskbar.tsx
CHANGED
|
@@ -1,41 +1,150 @@
|
|
| 1 |
-
import React from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import type { WindowsMap, WindowId } from '../../types/windowTypes';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
interface DesktopTaskbarProps {
|
| 5 |
-
isStartOpen: boolean;
|
| 6 |
-
onToggleStart: () => void;
|
| 7 |
-
onCloseStart: () => void;
|
| 8 |
isMobile: boolean;
|
| 9 |
-
windows: WindowsMap;
|
| 10 |
-
activeWindow: string;
|
| 11 |
-
onToggleWindow: (id: WindowId | string) => void;
|
| 12 |
time: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
export const DesktopTaskbar: React.FC<DesktopTaskbarProps> = ({
|
|
|
|
| 16 |
onToggleStart,
|
| 17 |
onCloseStart,
|
| 18 |
isMobile,
|
| 19 |
-
windows,
|
| 20 |
-
activeWindow,
|
| 21 |
-
onToggleWindow,
|
| 22 |
-
time
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
return (
|
| 25 |
<div
|
| 26 |
-
onClick={
|
| 27 |
className="fixed bottom-0 left-0 w-full z-50 flex items-center justify-between h-14 border-t-[4px] border-ink-black bg-[#0ea5e9] px-0 select-none shadow-[0_-4px_0_0_rgba(30,41,59,0.1)]"
|
| 28 |
>
|
| 29 |
<div className="flex items-center h-full overflow-x-auto custom-scrollbar">
|
| 30 |
-
{/* Start button */}
|
| 31 |
<button
|
|
|
|
|
|
|
| 32 |
onClick={(e) => {
|
| 33 |
e.stopPropagation();
|
| 34 |
-
|
| 35 |
}}
|
| 36 |
className={`h-full ${
|
| 37 |
isMobile ? 'px-3' : 'px-6'
|
| 38 |
} flex items-center gap-2 border-r-[4px] border-ink-black bg-[#39ff14] text-ink-black hover:bg-[#28e007] active:bg-[#1fb304] transition-colors shadow-[inset_-3px_-3px_0px_rgba(0,0,0,0.2),inset_3px_3px_0px_rgba(255,255,255,0.5)] font-bold cursor-pointer`}
|
|
|
|
| 39 |
>
|
| 40 |
<span className="material-symbols-outlined text-2xl font-bold" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 41 |
sports_esports
|
|
@@ -43,179 +152,99 @@ export const DesktopTaskbar: React.FC<DesktopTaskbarProps> = ({
|
|
| 43 |
<span className={`font-display-lg ${isMobile ? 'text-sm' : 'text-lg'} italic tracking-wide`}>Start</span>
|
| 44 |
</button>
|
| 45 |
|
| 46 |
-
{/*
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
?
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
>
|
| 73 |
-
<span className="material-symbols-outlined text-sm font-bold">route</span>
|
| 74 |
-
<span>{isMobile ? 'Journey' : 'Journey Path'}</span>
|
| 75 |
-
</button>
|
| 76 |
-
)}
|
| 77 |
-
|
| 78 |
-
{/* Terminal Tab */}
|
| 79 |
-
{windows.terminal.isOpen && (
|
| 80 |
-
<button
|
| 81 |
-
onClick={() => onToggleWindow('terminal')}
|
| 82 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 83 |
-
activeWindow === 'terminal' && !windows.terminal.isMinimized
|
| 84 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 85 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 86 |
-
}`}
|
| 87 |
-
>
|
| 88 |
-
<span className="material-symbols-outlined text-sm font-bold">terminal</span>
|
| 89 |
-
<span>Terminal</span>
|
| 90 |
-
</button>
|
| 91 |
-
)}
|
| 92 |
-
|
| 93 |
-
{/* Google Drive Sync Tab */}
|
| 94 |
-
{windows.sync.isOpen && (
|
| 95 |
-
<button
|
| 96 |
-
onClick={() => onToggleWindow('sync')}
|
| 97 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 98 |
-
activeWindow === 'sync' && !windows.sync.isMinimized
|
| 99 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 100 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 101 |
-
}`}
|
| 102 |
-
>
|
| 103 |
-
<span className="material-symbols-outlined text-sm font-bold">cloud_sync</span>
|
| 104 |
-
<span>{isMobile ? 'Sync' : 'Drive Sync'}</span>
|
| 105 |
-
</button>
|
| 106 |
)}
|
| 107 |
|
| 108 |
-
{/*
|
| 109 |
-
{
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
activeWindow === 'createProblem' && !windows.createProblem.isMinimized
|
| 129 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 130 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 131 |
-
}`}
|
| 132 |
-
>
|
| 133 |
-
<span className="material-symbols-outlined text-sm font-bold">note_add</span>
|
| 134 |
-
<span>{isMobile ? 'New File' : 'Create Problem'}</span>
|
| 135 |
-
</button>
|
| 136 |
-
)}
|
| 137 |
-
|
| 138 |
-
{/* Edit Problem Tab */}
|
| 139 |
-
{windows.editProblem?.isOpen && (
|
| 140 |
-
<button
|
| 141 |
-
onClick={() => onToggleWindow('editProblem')}
|
| 142 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 143 |
-
activeWindow === 'editProblem' && !windows.editProblem.isMinimized
|
| 144 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 145 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 146 |
-
}`}
|
| 147 |
-
>
|
| 148 |
-
<span className="material-symbols-outlined text-sm font-bold text-emerald-600">edit_note</span>
|
| 149 |
-
<span>{isMobile ? 'Edit' : 'Edit Problem'}</span>
|
| 150 |
-
</button>
|
| 151 |
-
)}
|
| 152 |
-
|
| 153 |
-
{/* Python Challenge Tab */}
|
| 154 |
-
{windows.python.isOpen && (
|
| 155 |
-
<button
|
| 156 |
-
onClick={() => onToggleWindow('python')}
|
| 157 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 158 |
-
activeWindow === 'python' && !windows.python.isMinimized
|
| 159 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 160 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 161 |
-
}`}
|
| 162 |
-
>
|
| 163 |
-
<span className="material-symbols-outlined text-sm font-bold">sports_esports</span>
|
| 164 |
-
<span>{isMobile ? 'Python' : 'Python Challenge'}</span>
|
| 165 |
-
</button>
|
| 166 |
-
)}
|
| 167 |
-
|
| 168 |
-
{/* MySQL Playground Tab */}
|
| 169 |
-
{windows.mysql.isOpen && (
|
| 170 |
-
<button
|
| 171 |
-
onClick={() => onToggleWindow('mysql')}
|
| 172 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 173 |
-
activeWindow === 'mysql' && !windows.mysql.isMinimized
|
| 174 |
-
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 175 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 176 |
-
}`}
|
| 177 |
-
>
|
| 178 |
-
<span className="material-symbols-outlined text-sm font-bold">database</span>
|
| 179 |
-
<span>{isMobile ? 'SQL' : 'MySQL Playground'}</span>
|
| 180 |
-
</button>
|
| 181 |
-
)}
|
| 182 |
-
|
| 183 |
-
{/* Princess Tower Tab */}
|
| 184 |
-
{windows.companion?.isOpen && (
|
| 185 |
-
<button
|
| 186 |
-
onClick={() => onToggleWindow('companion')}
|
| 187 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 188 |
-
activeWindow === 'companion' && !windows.companion.isMinimized
|
| 189 |
-
? 'bg-paper-white text-amber-700 font-extrabold translate-y-[2px]'
|
| 190 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 191 |
-
}`}
|
| 192 |
-
>
|
| 193 |
-
<span className="material-symbols-outlined text-sm font-bold text-amber-600">castle</span>
|
| 194 |
-
<span>{isMobile ? 'Princess' : 'Princess Tower'}</span>
|
| 195 |
-
</button>
|
| 196 |
-
)}
|
| 197 |
-
|
| 198 |
-
{/* API Settings Tab */}
|
| 199 |
-
{windows.settings?.isOpen && (
|
| 200 |
-
<button
|
| 201 |
-
onClick={() => onToggleWindow('settings')}
|
| 202 |
-
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 203 |
-
activeWindow === 'settings' && !windows.settings.isMinimized
|
| 204 |
-
? 'bg-paper-white text-[#10b981] font-extrabold translate-y-[2px]'
|
| 205 |
-
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 206 |
-
}`}
|
| 207 |
-
>
|
| 208 |
-
<span className="material-symbols-outlined text-sm font-bold text-[#10b981]">key</span>
|
| 209 |
-
<span>{isMobile ? 'API' : 'API Config'}</span>
|
| 210 |
-
</button>
|
| 211 |
-
)}
|
| 212 |
</div>
|
| 213 |
|
| 214 |
-
{/* System tray (wifi, clock, volume) */}
|
| 215 |
-
<div className="flex items-center h-full border-l-[4px] border-ink-black bg-[#0284c7] text-white px-4 gap-4 shadow-[inset_3px_3px_0px_rgba(0,0,0,0.2)]">
|
| 216 |
-
|
| 217 |
-
<
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
<span>{time}</span>
|
| 220 |
</div>
|
| 221 |
</div>
|
|
|
|
| 1 |
+
import React, { useState } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
useFloating,
|
| 4 |
+
offset,
|
| 5 |
+
flip,
|
| 6 |
+
shift,
|
| 7 |
+
autoUpdate,
|
| 8 |
+
useDismiss,
|
| 9 |
+
useRole,
|
| 10 |
+
useInteractions,
|
| 11 |
+
FloatingPortal,
|
| 12 |
+
} from '@floating-ui/react';
|
| 13 |
import type { WindowsMap, WindowId } from '../../types/windowTypes';
|
| 14 |
+
import { useOSStore } from '../../stores/useOSStore';
|
| 15 |
+
import { useProcessStore } from '../../stores/useProcessStore';
|
| 16 |
+
import { TaskbarWindowItem } from './TaskbarWindowItem';
|
| 17 |
+
import { SystemTrayProcessFlyout } from './SystemTrayProcessFlyout';
|
| 18 |
+
import { DesktopStartMenu } from './DesktopStartMenu';
|
| 19 |
+
|
| 20 |
+
interface TaskbarItemDef {
|
| 21 |
+
id: WindowId;
|
| 22 |
+
title: string;
|
| 23 |
+
shortTitle: string;
|
| 24 |
+
icon: string;
|
| 25 |
+
color?: string;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const TASKBAR_ITEMS: TaskbarItemDef[] = [
|
| 29 |
+
{ id: 'queue', title: 'Daily Queue', shortTitle: 'Queue', icon: 'view_list' },
|
| 30 |
+
{ id: 'journey', title: 'Journey Path', shortTitle: 'Journey', icon: 'route' },
|
| 31 |
+
{ id: 'terminal', title: 'Terminal', shortTitle: 'Terminal', icon: 'terminal' },
|
| 32 |
+
{ id: 'sync', title: 'Drive Sync', shortTitle: 'Sync', icon: 'cloud_sync' },
|
| 33 |
+
{ id: 'computer', title: 'My Computer', shortTitle: 'Comp', icon: 'desktop_windows' },
|
| 34 |
+
{ id: 'createProblem', title: 'Create Problem', shortTitle: 'New File', icon: 'note_add' },
|
| 35 |
+
{ id: 'editProblem', title: 'Edit Problem', shortTitle: 'Edit', icon: 'edit_note', color: '#059669' },
|
| 36 |
+
{ id: 'python', title: 'Python Challenge', shortTitle: 'Python', icon: 'sports_esports' },
|
| 37 |
+
{ id: 'mysql', title: 'MySQL Playground', shortTitle: 'SQL', icon: 'database' },
|
| 38 |
+
{ id: 'companion', title: 'Princess Tower', shortTitle: 'Princess', icon: 'castle', color: '#d97706' },
|
| 39 |
+
{ id: 'settings', title: 'API Config', shortTitle: 'API', icon: 'key', color: '#10b981' },
|
| 40 |
+
];
|
| 41 |
|
| 42 |
interface DesktopTaskbarProps {
|
| 43 |
+
isStartOpen?: boolean;
|
| 44 |
+
onToggleStart?: () => void;
|
| 45 |
+
onCloseStart?: () => void;
|
| 46 |
isMobile: boolean;
|
| 47 |
+
windows?: WindowsMap;
|
| 48 |
+
activeWindow?: string;
|
| 49 |
+
onToggleWindow?: (id: WindowId | string) => void;
|
| 50 |
time: string;
|
| 51 |
+
onOpenWindow?: (id: string) => void;
|
| 52 |
+
onOpenOnboarding?: () => void;
|
| 53 |
+
onTriggerSync?: () => void;
|
| 54 |
+
onSignOut?: () => void;
|
| 55 |
}
|
| 56 |
|
| 57 |
export const DesktopTaskbar: React.FC<DesktopTaskbarProps> = ({
|
| 58 |
+
isStartOpen: propsIsStartOpen,
|
| 59 |
onToggleStart,
|
| 60 |
onCloseStart,
|
| 61 |
isMobile,
|
| 62 |
+
windows: propsWindows,
|
| 63 |
+
activeWindow: propsActiveWindow,
|
| 64 |
+
onToggleWindow: propsOnToggleWindow,
|
| 65 |
+
time,
|
| 66 |
+
onOpenWindow,
|
| 67 |
+
onOpenOnboarding,
|
| 68 |
+
onTriggerSync,
|
| 69 |
+
onSignOut,
|
| 70 |
}) => {
|
| 71 |
+
const storeWindows = useOSStore(s => s.windows);
|
| 72 |
+
const storeActiveWindow = useOSStore(s => s.activeWindow);
|
| 73 |
+
const storeToggle = useOSStore(s => s.toggleWindowMinimize);
|
| 74 |
+
const storeOpenWindow = useOSStore(s => s.openWindow);
|
| 75 |
+
const processes = useProcessStore(s => s.processes);
|
| 76 |
+
|
| 77 |
+
const activeProcesses = React.useMemo(
|
| 78 |
+
() => Object.values(processes).filter(p => p.status === 'running'),
|
| 79 |
+
[processes]
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
const windows = propsWindows ?? storeWindows;
|
| 83 |
+
const activeWindow = propsActiveWindow ?? storeActiveWindow;
|
| 84 |
+
const onToggleWindow = propsOnToggleWindow ?? storeToggle;
|
| 85 |
+
|
| 86 |
+
// Start menu floating state
|
| 87 |
+
const [internalStartOpen, setInternalStartOpen] = useState(false);
|
| 88 |
+
const isStartOpen = propsIsStartOpen ?? internalStartOpen;
|
| 89 |
+
|
| 90 |
+
const handleCloseStart = () => {
|
| 91 |
+
if (onCloseStart) onCloseStart();
|
| 92 |
+
setInternalStartOpen(false);
|
| 93 |
+
};
|
| 94 |
+
|
| 95 |
+
const handleToggleStart = () => {
|
| 96 |
+
if (isStartOpen) {
|
| 97 |
+
handleCloseStart();
|
| 98 |
+
} else {
|
| 99 |
+
if (onToggleStart) onToggleStart();
|
| 100 |
+
setInternalStartOpen(true);
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
const {
|
| 105 |
+
refs: { setReference: setStartReference, setFloating: setStartFloating },
|
| 106 |
+
floatingStyles: startFloatingStyles,
|
| 107 |
+
context: startContext,
|
| 108 |
+
} = useFloating({
|
| 109 |
+
open: isStartOpen,
|
| 110 |
+
onOpenChange: (open) => {
|
| 111 |
+
if (!open) handleCloseStart();
|
| 112 |
+
},
|
| 113 |
+
placement: 'top-start',
|
| 114 |
+
middleware: [
|
| 115 |
+
offset(10),
|
| 116 |
+
flip({ padding: 8 }),
|
| 117 |
+
shift({ padding: 8 }),
|
| 118 |
+
],
|
| 119 |
+
whileElementsMounted: autoUpdate,
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
const startDismiss = useDismiss(startContext, { outsidePress: true, escapeKey: true });
|
| 123 |
+
const startRole = useRole(startContext, { role: 'menu' });
|
| 124 |
+
const { getReferenceProps: getStartRefProps, getFloatingProps: getStartFloatingProps } =
|
| 125 |
+
useInteractions([startDismiss, startRole]);
|
| 126 |
+
|
| 127 |
+
// System tray process flyout state
|
| 128 |
+
const [isProcFlyoutOpen, setIsProcFlyoutOpen] = useState(false);
|
| 129 |
+
|
| 130 |
return (
|
| 131 |
<div
|
| 132 |
+
onClick={handleCloseStart}
|
| 133 |
className="fixed bottom-0 left-0 w-full z-50 flex items-center justify-between h-14 border-t-[4px] border-ink-black bg-[#0ea5e9] px-0 select-none shadow-[0_-4px_0_0_rgba(30,41,59,0.1)]"
|
| 134 |
>
|
| 135 |
<div className="flex items-center h-full overflow-x-auto custom-scrollbar">
|
| 136 |
+
{/* Start button anchored with @floating-ui/react */}
|
| 137 |
<button
|
| 138 |
+
ref={setStartReference}
|
| 139 |
+
{...getStartRefProps()}
|
| 140 |
onClick={(e) => {
|
| 141 |
e.stopPropagation();
|
| 142 |
+
handleToggleStart();
|
| 143 |
}}
|
| 144 |
className={`h-full ${
|
| 145 |
isMobile ? 'px-3' : 'px-6'
|
| 146 |
} flex items-center gap-2 border-r-[4px] border-ink-black bg-[#39ff14] text-ink-black hover:bg-[#28e007] active:bg-[#1fb304] transition-colors shadow-[inset_-3px_-3px_0px_rgba(0,0,0,0.2),inset_3px_3px_0px_rgba(255,255,255,0.5)] font-bold cursor-pointer`}
|
| 147 |
+
title="Start Menu"
|
| 148 |
>
|
| 149 |
<span className="material-symbols-outlined text-2xl font-bold" style={{ fontVariationSettings: "'FILL' 1" }}>
|
| 150 |
sports_esports
|
|
|
|
| 152 |
<span className={`font-display-lg ${isMobile ? 'text-sm' : 'text-lg'} italic tracking-wide`}>Start</span>
|
| 153 |
</button>
|
| 154 |
|
| 155 |
+
{/* Start Menu Floating Overlay */}
|
| 156 |
+
{isStartOpen && (
|
| 157 |
+
<FloatingPortal>
|
| 158 |
+
<DesktopStartMenu
|
| 159 |
+
ref={setStartFloating}
|
| 160 |
+
style={startFloatingStyles}
|
| 161 |
+
{...getStartFloatingProps()}
|
| 162 |
+
isOpen={isStartOpen}
|
| 163 |
+
onOpenWindow={(id) => {
|
| 164 |
+
handleCloseStart();
|
| 165 |
+
if (onOpenWindow) onOpenWindow(id);
|
| 166 |
+
else storeOpenWindow(id);
|
| 167 |
+
}}
|
| 168 |
+
onOpenOnboarding={() => {
|
| 169 |
+
handleCloseStart();
|
| 170 |
+
onOpenOnboarding?.();
|
| 171 |
+
}}
|
| 172 |
+
onTriggerSync={() => {
|
| 173 |
+
handleCloseStart();
|
| 174 |
+
onTriggerSync?.();
|
| 175 |
+
}}
|
| 176 |
+
onSignOut={() => {
|
| 177 |
+
handleCloseStart();
|
| 178 |
+
onSignOut?.();
|
| 179 |
+
}}
|
| 180 |
+
/>
|
| 181 |
+
</FloatingPortal>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
)}
|
| 183 |
|
| 184 |
+
{/* Windows tabs with @floating-ui/react hover previews */}
|
| 185 |
+
{TASKBAR_ITEMS.map((item) => {
|
| 186 |
+
const win = windows[item.id];
|
| 187 |
+
if (!win?.isOpen) return null;
|
| 188 |
+
return (
|
| 189 |
+
<TaskbarWindowItem
|
| 190 |
+
key={item.id}
|
| 191 |
+
id={item.id}
|
| 192 |
+
title={item.title}
|
| 193 |
+
shortTitle={item.shortTitle}
|
| 194 |
+
icon={item.icon}
|
| 195 |
+
color={item.color}
|
| 196 |
+
isOpen={win.isOpen}
|
| 197 |
+
isMinimized={win.isMinimized}
|
| 198 |
+
isActive={activeWindow === item.id}
|
| 199 |
+
isMobile={isMobile}
|
| 200 |
+
onToggle={onToggleWindow}
|
| 201 |
+
/>
|
| 202 |
+
);
|
| 203 |
+
})}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
</div>
|
| 205 |
|
| 206 |
+
{/* System tray (process status, wifi, clock, volume) */}
|
| 207 |
+
<div className="flex items-center h-full border-l-[4px] border-ink-black bg-[#0284c7] text-white px-3 md:px-4 gap-3 md:gap-4 shadow-[inset_3px_3px_0px_rgba(0,0,0,0.2)]">
|
| 208 |
+
{/* Process Monitor badge with @floating-ui flyout */}
|
| 209 |
+
<SystemTrayProcessFlyout
|
| 210 |
+
isOpen={isProcFlyoutOpen}
|
| 211 |
+
onOpenChange={setIsProcFlyoutOpen}
|
| 212 |
+
>
|
| 213 |
+
{(ref, props) => (
|
| 214 |
+
activeProcesses.length > 0 ? (
|
| 215 |
+
<div
|
| 216 |
+
ref={ref}
|
| 217 |
+
{...props}
|
| 218 |
+
onClick={(e) => {
|
| 219 |
+
e.stopPropagation();
|
| 220 |
+
setIsProcFlyoutOpen(prev => !prev);
|
| 221 |
+
}}
|
| 222 |
+
title={`Active background processes: ${activeProcesses.map(p => p.title).join(', ')} (click to inspect)`}
|
| 223 |
+
className="flex items-center gap-1.5 bg-[#facc15] text-ink-black px-2 py-0.5 border-2 border-ink-black font-arcade text-[8px] font-bold shadow-[1px_1px_0px_0px_#1E293B] animate-pulse select-none cursor-pointer hover:bg-yellow-300"
|
| 224 |
+
>
|
| 225 |
+
<span className="material-symbols-outlined text-[12px] animate-spin">autorenew</span>
|
| 226 |
+
<span>{activeProcesses.length} PROC</span>
|
| 227 |
+
</div>
|
| 228 |
+
) : null
|
| 229 |
+
)}
|
| 230 |
+
</SystemTrayProcessFlyout>
|
| 231 |
+
|
| 232 |
+
<span
|
| 233 |
+
className="material-symbols-outlined cursor-pointer select-none text-lg hover:text-cyan-200 transition-colors"
|
| 234 |
+
title="Sound: 8-Bit Retro Audio Engine (Active)"
|
| 235 |
+
>
|
| 236 |
+
volume_up
|
| 237 |
+
</span>
|
| 238 |
+
<span
|
| 239 |
+
className="material-symbols-outlined cursor-pointer select-none text-lg hover:text-cyan-200 transition-colors"
|
| 240 |
+
title="Cloud Network: Connected to Firestore & AI Services"
|
| 241 |
+
>
|
| 242 |
+
network_wifi
|
| 243 |
+
</span>
|
| 244 |
+
<div
|
| 245 |
+
className="font-arcade text-[9px] font-bold flex flex-col items-center leading-none justify-center select-none pt-0.5 cursor-default"
|
| 246 |
+
title="System Time"
|
| 247 |
+
>
|
| 248 |
<span>{time}</span>
|
| 249 |
</div>
|
| 250 |
</div>
|
algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { lazy, Suspense, useCallback } from 'react';
|
|
| 2 |
import WindowShell from '../WindowShell';
|
| 3 |
import type { WindowsMap } from '../../types/windowTypes';
|
| 4 |
import type { ProblemItem } from '../../types/reviewTypes';
|
|
|
|
| 5 |
|
| 6 |
const ReviewQueue = lazy(() => import('../ReviewQueue'));
|
| 7 |
const JourneyPath = lazy(() => import('../JourneyPath'));
|
|
@@ -16,20 +17,20 @@ const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow'));
|
|
| 16 |
|
| 17 |
|
| 18 |
interface DesktopWindowContainerProps {
|
| 19 |
-
windows: WindowsMap;
|
| 20 |
-
activeWindow: string;
|
| 21 |
-
setActiveWindow: (id: string) => void;
|
| 22 |
isMobile: boolean;
|
| 23 |
-
openWindow: (id: string) => void;
|
| 24 |
-
closeWindow: (id: string) => void;
|
| 25 |
-
minimizeWindow: (id: string) => void;
|
| 26 |
-
overrideProblemId: string | null;
|
| 27 |
-
setOverrideProblemId: (id: string | null) => void;
|
| 28 |
-
editingProblem: ProblemItem | null;
|
| 29 |
-
openEditProblem: (problem: ProblemItem) => void;
|
| 30 |
-
handleSelectProblemForReview: (problemId: string) => void;
|
| 31 |
-
refreshExplorerTrigger: number;
|
| 32 |
-
triggerRefreshExplorer: () => void;
|
| 33 |
setIsOnboardingOpen: (open: boolean) => void;
|
| 34 |
wallpaperUrl: string;
|
| 35 |
setWallpaperUrl: (url: string) => void;
|
|
@@ -39,20 +40,20 @@ interface DesktopWindowContainerProps {
|
|
| 39 |
}
|
| 40 |
|
| 41 |
export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
|
| 42 |
-
windows,
|
| 43 |
-
activeWindow,
|
| 44 |
-
setActiveWindow,
|
| 45 |
isMobile,
|
| 46 |
-
openWindow,
|
| 47 |
-
closeWindow,
|
| 48 |
-
minimizeWindow,
|
| 49 |
-
overrideProblemId,
|
| 50 |
-
setOverrideProblemId,
|
| 51 |
-
editingProblem,
|
| 52 |
-
openEditProblem,
|
| 53 |
-
handleSelectProblemForReview,
|
| 54 |
-
refreshExplorerTrigger,
|
| 55 |
-
triggerRefreshExplorer,
|
| 56 |
setIsOnboardingOpen,
|
| 57 |
wallpaperUrl,
|
| 58 |
setWallpaperUrl,
|
|
@@ -60,6 +61,33 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
|
|
| 60 |
syncResult,
|
| 61 |
triggerSync
|
| 62 |
}) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
const handleClearOverride = useCallback(() => setOverrideProblemId(null), [setOverrideProblemId]);
|
| 64 |
const handleOpenJourney = useCallback(() => openWindow('journey'), [openWindow]);
|
| 65 |
const handleOpenCreateProblem = useCallback(() => openWindow('createProblem'), [openWindow]);
|
|
|
|
| 2 |
import WindowShell from '../WindowShell';
|
| 3 |
import type { WindowsMap } from '../../types/windowTypes';
|
| 4 |
import type { ProblemItem } from '../../types/reviewTypes';
|
| 5 |
+
import { useOSStore } from '../../stores/useOSStore';
|
| 6 |
|
| 7 |
const ReviewQueue = lazy(() => import('../ReviewQueue'));
|
| 8 |
const JourneyPath = lazy(() => import('../JourneyPath'));
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
interface DesktopWindowContainerProps {
|
| 20 |
+
windows?: WindowsMap;
|
| 21 |
+
activeWindow?: string;
|
| 22 |
+
setActiveWindow?: (id: string) => void;
|
| 23 |
isMobile: boolean;
|
| 24 |
+
openWindow?: (id: string) => void;
|
| 25 |
+
closeWindow?: (id: string) => void;
|
| 26 |
+
minimizeWindow?: (id: string) => void;
|
| 27 |
+
overrideProblemId?: string | null;
|
| 28 |
+
setOverrideProblemId?: (id: string | null) => void;
|
| 29 |
+
editingProblem?: ProblemItem | null;
|
| 30 |
+
openEditProblem?: (problem: ProblemItem) => void;
|
| 31 |
+
handleSelectProblemForReview?: (problemId: string) => void;
|
| 32 |
+
refreshExplorerTrigger?: number;
|
| 33 |
+
triggerRefreshExplorer?: () => void;
|
| 34 |
setIsOnboardingOpen: (open: boolean) => void;
|
| 35 |
wallpaperUrl: string;
|
| 36 |
setWallpaperUrl: (url: string) => void;
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
|
| 43 |
+
windows: propsWindows,
|
| 44 |
+
activeWindow: propsActiveWindow,
|
| 45 |
+
setActiveWindow: propsSetActiveWindow,
|
| 46 |
isMobile,
|
| 47 |
+
openWindow: propsOpenWindow,
|
| 48 |
+
closeWindow: propsCloseWindow,
|
| 49 |
+
minimizeWindow: propsMinimizeWindow,
|
| 50 |
+
overrideProblemId: propsOverrideProblemId,
|
| 51 |
+
setOverrideProblemId: propsSetOverrideProblemId,
|
| 52 |
+
editingProblem: propsEditingProblem,
|
| 53 |
+
openEditProblem: propsOpenEditProblem,
|
| 54 |
+
handleSelectProblemForReview: propsHandleSelectProblem,
|
| 55 |
+
refreshExplorerTrigger: propsRefreshExplorerTrigger,
|
| 56 |
+
triggerRefreshExplorer: propsTriggerRefreshExplorer,
|
| 57 |
setIsOnboardingOpen,
|
| 58 |
wallpaperUrl,
|
| 59 |
setWallpaperUrl,
|
|
|
|
| 61 |
syncResult,
|
| 62 |
triggerSync
|
| 63 |
}) => {
|
| 64 |
+
const storeWindows = useOSStore(s => s.windows);
|
| 65 |
+
const storeActiveWindow = useOSStore(s => s.activeWindow);
|
| 66 |
+
const storeSetActiveWindow = useOSStore(s => s.setActiveWindow);
|
| 67 |
+
const storeOpenWindow = useOSStore(s => s.openWindow);
|
| 68 |
+
const storeCloseWindow = useOSStore(s => s.closeWindow);
|
| 69 |
+
const storeMinimizeWindow = useOSStore(s => s.minimizeWindow);
|
| 70 |
+
const storeOverrideProblemId = useOSStore(s => s.overrideProblemId);
|
| 71 |
+
const storeSetOverrideProblemId = useOSStore(s => s.setOverrideProblemId);
|
| 72 |
+
const storeEditingProblem = useOSStore(s => s.editingProblem);
|
| 73 |
+
const storeOpenEditProblem = useOSStore(s => s.openEditProblem);
|
| 74 |
+
const storeHandleSelectProblem = useOSStore(s => s.handleSelectProblemForReview);
|
| 75 |
+
const storeRefreshTrigger = useOSStore(s => s.refreshExplorerTrigger);
|
| 76 |
+
const storeTriggerRefresh = useOSStore(s => s.triggerRefreshExplorer);
|
| 77 |
+
|
| 78 |
+
const windows = propsWindows ?? storeWindows;
|
| 79 |
+
const activeWindow = propsActiveWindow ?? storeActiveWindow;
|
| 80 |
+
const setActiveWindow = propsSetActiveWindow ?? storeSetActiveWindow;
|
| 81 |
+
const openWindow = propsOpenWindow ?? storeOpenWindow;
|
| 82 |
+
const closeWindow = propsCloseWindow ?? storeCloseWindow;
|
| 83 |
+
const minimizeWindow = propsMinimizeWindow ?? storeMinimizeWindow;
|
| 84 |
+
const overrideProblemId = propsOverrideProblemId !== undefined ? propsOverrideProblemId : storeOverrideProblemId;
|
| 85 |
+
const setOverrideProblemId = propsSetOverrideProblemId ?? storeSetOverrideProblemId;
|
| 86 |
+
const editingProblem = propsEditingProblem !== undefined ? propsEditingProblem : storeEditingProblem;
|
| 87 |
+
const openEditProblem = propsOpenEditProblem ?? storeOpenEditProblem;
|
| 88 |
+
const handleSelectProblemForReview = propsHandleSelectProblem ?? storeHandleSelectProblem;
|
| 89 |
+
const refreshExplorerTrigger = propsRefreshExplorerTrigger ?? storeRefreshTrigger;
|
| 90 |
+
const triggerRefreshExplorer = propsTriggerRefreshExplorer ?? storeTriggerRefresh;
|
| 91 |
const handleClearOverride = useCallback(() => setOverrideProblemId(null), [setOverrideProblemId]);
|
| 92 |
const handleOpenJourney = useCallback(() => openWindow('journey'), [openWindow]);
|
| 93 |
const handleOpenCreateProblem = useCallback(() => openWindow('createProblem'), [openWindow]);
|
algospaced-ui/src/components/desktop/SystemTrayProcessFlyout.tsx
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import {
|
| 3 |
+
useFloating,
|
| 4 |
+
offset,
|
| 5 |
+
flip,
|
| 6 |
+
shift,
|
| 7 |
+
autoUpdate,
|
| 8 |
+
useDismiss,
|
| 9 |
+
useRole,
|
| 10 |
+
useInteractions,
|
| 11 |
+
FloatingPortal,
|
| 12 |
+
} from '@floating-ui/react';
|
| 13 |
+
import { useProcessStore } from '../../stores/useProcessStore';
|
| 14 |
+
import { useOSStore } from '../../stores/useOSStore';
|
| 15 |
+
|
| 16 |
+
interface SystemTrayProcessFlyoutProps {
|
| 17 |
+
isOpen: boolean;
|
| 18 |
+
onOpenChange: (open: boolean) => void;
|
| 19 |
+
children: (ref: (node: HTMLElement | null) => void, props: Record<string, unknown>) => React.ReactNode;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export const SystemTrayProcessFlyout: React.FC<SystemTrayProcessFlyoutProps> = ({
|
| 23 |
+
isOpen,
|
| 24 |
+
onOpenChange,
|
| 25 |
+
children,
|
| 26 |
+
}) => {
|
| 27 |
+
const processes = useProcessStore(s => s.processes);
|
| 28 |
+
const activeProcesses = Object.values(processes).filter(p => p.status === 'running');
|
| 29 |
+
const openWindow = useOSStore(s => s.openWindow);
|
| 30 |
+
|
| 31 |
+
const {
|
| 32 |
+
refs: { setReference, setFloating },
|
| 33 |
+
floatingStyles,
|
| 34 |
+
context,
|
| 35 |
+
} = useFloating({
|
| 36 |
+
open: isOpen,
|
| 37 |
+
onOpenChange,
|
| 38 |
+
placement: 'top-end',
|
| 39 |
+
middleware: [
|
| 40 |
+
offset(10),
|
| 41 |
+
flip({ padding: 10 }),
|
| 42 |
+
shift({ padding: 10 }),
|
| 43 |
+
],
|
| 44 |
+
whileElementsMounted: autoUpdate,
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
const dismiss = useDismiss(context, { outsidePress: true, escapeKey: true });
|
| 48 |
+
const role = useRole(context, { role: 'dialog' });
|
| 49 |
+
const { getReferenceProps, getFloatingProps } = useInteractions([dismiss, role]);
|
| 50 |
+
|
| 51 |
+
return (
|
| 52 |
+
<>
|
| 53 |
+
{children(setReference, getReferenceProps())}
|
| 54 |
+
|
| 55 |
+
{isOpen && (
|
| 56 |
+
<FloatingPortal>
|
| 57 |
+
<div
|
| 58 |
+
ref={setFloating}
|
| 59 |
+
style={floatingStyles}
|
| 60 |
+
{...getFloatingProps()}
|
| 61 |
+
className="z-[90] w-80 bg-paper-white border-[3px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col p-3 select-none animate-fade-in"
|
| 62 |
+
>
|
| 63 |
+
{/* Header */}
|
| 64 |
+
<div className="flex items-center justify-between border-b-2 border-ink-black pb-2 mb-2 bg-[#0284c7] text-white px-2 py-1 -mx-3 -mt-3">
|
| 65 |
+
<div className="flex items-center gap-1.5">
|
| 66 |
+
<span className="material-symbols-outlined text-sm animate-spin">autorenew</span>
|
| 67 |
+
<span className="font-arcade text-[9px] font-bold tracking-wider">PROCESS MONITOR</span>
|
| 68 |
+
</div>
|
| 69 |
+
<span className="font-arcade text-[8px] font-bold bg-[#facc15] text-ink-black px-1.5 py-0.5 border border-ink-black">
|
| 70 |
+
{activeProcesses.length} ACTIVE
|
| 71 |
+
</span>
|
| 72 |
+
</div>
|
| 73 |
+
|
| 74 |
+
{/* Process List */}
|
| 75 |
+
<div className="flex flex-col gap-2 max-h-56 overflow-y-auto custom-scrollbar my-1">
|
| 76 |
+
{activeProcesses.length === 0 ? (
|
| 77 |
+
<div className="text-center py-4 text-xs font-window-title text-slate-500 font-bold">
|
| 78 |
+
No background processes running
|
| 79 |
+
</div>
|
| 80 |
+
) : (
|
| 81 |
+
activeProcesses.map((proc) => (
|
| 82 |
+
<div
|
| 83 |
+
key={proc.pid}
|
| 84 |
+
className="p-2 border-2 border-ink-black bg-slate-50 flex flex-col gap-1 shadow-[2px_2px_0_0_#1E293B]"
|
| 85 |
+
>
|
| 86 |
+
<div className="flex items-center justify-between">
|
| 87 |
+
<span className="font-window-title text-xs font-bold text-ink-black truncate max-w-[170px]">
|
| 88 |
+
{proc.title}
|
| 89 |
+
</span>
|
| 90 |
+
<span className="font-arcade text-[7px] font-extrabold bg-[#39ff14] text-ink-black px-1 py-0.2 border border-ink-black">
|
| 91 |
+
RUNNING
|
| 92 |
+
</span>
|
| 93 |
+
</div>
|
| 94 |
+
<div className="flex items-center justify-between font-arcade text-[8px] text-slate-500">
|
| 95 |
+
<span>TYPE: {proc.appId.toUpperCase()}</span>
|
| 96 |
+
<span>PID: {proc.pid.slice(-6)}</span>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
))
|
| 100 |
+
)}
|
| 101 |
+
</div>
|
| 102 |
+
|
| 103 |
+
{/* Footer / Terminal launcher */}
|
| 104 |
+
<div className="pt-2 border-t-2 border-ink-black/20 flex items-center justify-between gap-2 mt-1">
|
| 105 |
+
<button
|
| 106 |
+
onClick={() => {
|
| 107 |
+
onOpenChange(false);
|
| 108 |
+
openWindow('terminal');
|
| 109 |
+
}}
|
| 110 |
+
className="flex-1 py-1 px-2 bg-[#39ff14] hover:bg-[#28e007] border-2 border-ink-black text-ink-black font-window-title text-[11px] font-bold flex items-center justify-center gap-1.5 transition-colors cursor-pointer"
|
| 111 |
+
>
|
| 112 |
+
<span className="material-symbols-outlined text-xs">terminal</span>
|
| 113 |
+
Open Terminal (ps)
|
| 114 |
+
</button>
|
| 115 |
+
<button
|
| 116 |
+
onClick={() => onOpenChange(false)}
|
| 117 |
+
className="py-1 px-2.5 bg-slate-200 hover:bg-slate-300 border-2 border-ink-black text-ink-black font-window-title text-[11px] font-bold transition-colors cursor-pointer"
|
| 118 |
+
>
|
| 119 |
+
Close
|
| 120 |
+
</button>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</FloatingPortal>
|
| 124 |
+
)}
|
| 125 |
+
</>
|
| 126 |
+
);
|
| 127 |
+
};
|
algospaced-ui/src/components/desktop/TaskbarWindowItem.tsx
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
useFloating,
|
| 4 |
+
offset,
|
| 5 |
+
flip,
|
| 6 |
+
shift,
|
| 7 |
+
autoUpdate,
|
| 8 |
+
useHover,
|
| 9 |
+
useDismiss,
|
| 10 |
+
useRole,
|
| 11 |
+
useInteractions,
|
| 12 |
+
FloatingPortal,
|
| 13 |
+
} from '@floating-ui/react';
|
| 14 |
+
import type { WindowId } from '../../types/windowTypes';
|
| 15 |
+
import { useOSStore } from '../../stores/useOSStore';
|
| 16 |
+
|
| 17 |
+
interface TaskbarWindowItemProps {
|
| 18 |
+
id: WindowId | string;
|
| 19 |
+
title: string;
|
| 20 |
+
shortTitle: string;
|
| 21 |
+
icon: string;
|
| 22 |
+
isOpen: boolean;
|
| 23 |
+
isMinimized: boolean;
|
| 24 |
+
isActive: boolean;
|
| 25 |
+
isMobile: boolean;
|
| 26 |
+
color?: string;
|
| 27 |
+
onToggle: (id: WindowId | string) => void;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export const TaskbarWindowItem: React.FC<TaskbarWindowItemProps> = ({
|
| 31 |
+
id,
|
| 32 |
+
title,
|
| 33 |
+
shortTitle,
|
| 34 |
+
icon,
|
| 35 |
+
isOpen,
|
| 36 |
+
isMinimized,
|
| 37 |
+
isActive,
|
| 38 |
+
isMobile,
|
| 39 |
+
color,
|
| 40 |
+
onToggle,
|
| 41 |
+
}) => {
|
| 42 |
+
const [isHovered, setIsHovered] = useState(false);
|
| 43 |
+
const closeWindow = useOSStore(s => s.closeWindow);
|
| 44 |
+
const focusWindow = useOSStore(s => s.focusWindow);
|
| 45 |
+
const minimizeWindow = useOSStore(s => s.minimizeWindow);
|
| 46 |
+
|
| 47 |
+
const {
|
| 48 |
+
refs: { setReference, setFloating },
|
| 49 |
+
floatingStyles,
|
| 50 |
+
context,
|
| 51 |
+
} = useFloating({
|
| 52 |
+
open: isHovered && !isMobile,
|
| 53 |
+
onOpenChange: setIsHovered,
|
| 54 |
+
placement: 'top',
|
| 55 |
+
middleware: [
|
| 56 |
+
offset(10),
|
| 57 |
+
flip({ padding: 8 }),
|
| 58 |
+
shift({ padding: 8 }),
|
| 59 |
+
],
|
| 60 |
+
whileElementsMounted: autoUpdate,
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
const hover = useHover(context, {
|
| 64 |
+
delay: { open: 350, close: 150 },
|
| 65 |
+
restMs: 120,
|
| 66 |
+
enabled: !isMobile,
|
| 67 |
+
});
|
| 68 |
+
const dismiss = useDismiss(context);
|
| 69 |
+
const role = useRole(context, { role: 'tooltip' });
|
| 70 |
+
const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss, role]);
|
| 71 |
+
|
| 72 |
+
if (!isOpen) return null;
|
| 73 |
+
|
| 74 |
+
return (
|
| 75 |
+
<>
|
| 76 |
+
<button
|
| 77 |
+
ref={setReference}
|
| 78 |
+
{...getReferenceProps()}
|
| 79 |
+
onClick={() => {
|
| 80 |
+
setIsHovered(false);
|
| 81 |
+
onToggle(id);
|
| 82 |
+
}}
|
| 83 |
+
className={`h-full ${isMobile ? 'px-2 text-[10px] gap-1' : 'px-4 text-xs gap-2'} border-r-[4px] border-ink-black font-bold font-window-title cursor-pointer transition-all shadow-[inset_0px_3px_0px_rgba(255,255,255,0.8)] ${
|
| 84 |
+
isActive && !isMinimized
|
| 85 |
+
? 'bg-paper-white text-ink-black font-extrabold translate-y-[2px]'
|
| 86 |
+
: 'bg-surface-variant text-trash-gray hover:bg-white/40'
|
| 87 |
+
}`}
|
| 88 |
+
>
|
| 89 |
+
<span
|
| 90 |
+
className="material-symbols-outlined text-sm font-bold"
|
| 91 |
+
style={color ? { color } : undefined}
|
| 92 |
+
>
|
| 93 |
+
{icon}
|
| 94 |
+
</span>
|
| 95 |
+
<span style={color && isActive ? { color } : undefined}>
|
| 96 |
+
{isMobile ? shortTitle : title}
|
| 97 |
+
</span>
|
| 98 |
+
</button>
|
| 99 |
+
|
| 100 |
+
{/* Retro Arcade Window Preview Hover Card via @floating-ui/react */}
|
| 101 |
+
{isHovered && !isMobile && (
|
| 102 |
+
<FloatingPortal>
|
| 103 |
+
<div
|
| 104 |
+
ref={setFloating}
|
| 105 |
+
style={floatingStyles}
|
| 106 |
+
{...getFloatingProps()}
|
| 107 |
+
className="z-[90] w-64 bg-paper-white border-[3px] border-ink-black shadow-[4px_4px_0px_0px_#1E293B] flex flex-col p-3 select-none animate-fade-in pointer-events-auto"
|
| 108 |
+
>
|
| 109 |
+
{/* Header */}
|
| 110 |
+
<div className="flex items-center justify-between border-b-2 border-ink-black/20 pb-1.5 mb-2">
|
| 111 |
+
<div className="flex items-center gap-1.5">
|
| 112 |
+
<span className="material-symbols-outlined text-base" style={color ? { color } : undefined}>
|
| 113 |
+
{icon}
|
| 114 |
+
</span>
|
| 115 |
+
<span className="font-window-title text-xs font-bold text-ink-black truncate max-w-[140px]">
|
| 116 |
+
{title}
|
| 117 |
+
</span>
|
| 118 |
+
</div>
|
| 119 |
+
<span
|
| 120 |
+
className={`font-arcade text-[8px] font-bold px-1.5 py-0.5 border border-ink-black ${
|
| 121 |
+
isActive && !isMinimized
|
| 122 |
+
? 'bg-[#39ff14] text-ink-black'
|
| 123 |
+
: isMinimized
|
| 124 |
+
? 'bg-amber-200 text-amber-900'
|
| 125 |
+
: 'bg-slate-200 text-slate-700'
|
| 126 |
+
}`}
|
| 127 |
+
>
|
| 128 |
+
{isActive && !isMinimized ? 'ACTIVE' : isMinimized ? 'MINIMIZED' : 'BACKGROUND'}
|
| 129 |
+
</span>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
{/* Preview visual thumbnail placeholder with scanline styling */}
|
| 133 |
+
<div className="w-full h-20 bg-slate-900 border-2 border-ink-black mb-2.5 flex flex-col items-center justify-center p-2 relative overflow-hidden group">
|
| 134 |
+
<div className="absolute inset-0 opacity-15 pointer-events-none bg-[radial-gradient(#39ff14_1px,transparent_1px)] [background-size:8px_8px]" />
|
| 135 |
+
<span className="material-symbols-outlined text-3xl text-emerald-400 opacity-60 mb-1">
|
| 136 |
+
{icon}
|
| 137 |
+
</span>
|
| 138 |
+
<span className="font-arcade text-[8px] text-emerald-300 tracking-wider">
|
| 139 |
+
ALGOSPACED VIEWPORT
|
| 140 |
+
</span>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
{/* Quick Actions */}
|
| 144 |
+
<div className="flex items-center justify-between gap-1.5 pt-1 border-t border-ink-black/20">
|
| 145 |
+
<button
|
| 146 |
+
onClick={(e) => {
|
| 147 |
+
e.stopPropagation();
|
| 148 |
+
setIsHovered(false);
|
| 149 |
+
focusWindow(id as string);
|
| 150 |
+
}}
|
| 151 |
+
className="flex-1 py-1 px-2 bg-emerald-100 hover:bg-emerald-200 border-2 border-ink-black text-ink-black font-window-title text-[10px] font-bold flex items-center justify-center gap-1 transition-colors cursor-pointer"
|
| 152 |
+
title="Bring to front"
|
| 153 |
+
>
|
| 154 |
+
<span className="material-symbols-outlined text-xs">open_in_full</span>
|
| 155 |
+
Focus
|
| 156 |
+
</button>
|
| 157 |
+
|
| 158 |
+
<button
|
| 159 |
+
onClick={(e) => {
|
| 160 |
+
e.stopPropagation();
|
| 161 |
+
setIsHovered(false);
|
| 162 |
+
minimizeWindow(id as string);
|
| 163 |
+
}}
|
| 164 |
+
className="py-1 px-2 bg-amber-100 hover:bg-amber-200 border-2 border-ink-black text-ink-black font-window-title text-[10px] font-bold flex items-center justify-center transition-colors cursor-pointer"
|
| 165 |
+
title="Minimize window"
|
| 166 |
+
>
|
| 167 |
+
<span className="material-symbols-outlined text-xs">minimize</span>
|
| 168 |
+
</button>
|
| 169 |
+
|
| 170 |
+
<button
|
| 171 |
+
onClick={(e) => {
|
| 172 |
+
e.stopPropagation();
|
| 173 |
+
setIsHovered(false);
|
| 174 |
+
closeWindow(id as string);
|
| 175 |
+
}}
|
| 176 |
+
className="py-1 px-2 bg-rose-100 hover:bg-rose-200 border-2 border-ink-black text-rose-700 font-window-title text-[10px] font-bold flex items-center justify-center transition-colors cursor-pointer"
|
| 177 |
+
title="Close window"
|
| 178 |
+
>
|
| 179 |
+
<span className="material-symbols-outlined text-xs">close</span>
|
| 180 |
+
</button>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
</FloatingPortal>
|
| 184 |
+
)}
|
| 185 |
+
</>
|
| 186 |
+
);
|
| 187 |
+
};
|
algospaced-ui/src/hooks/useAiReviewer.ts
CHANGED
|
@@ -1,163 +1,21 @@
|
|
| 1 |
-
import {
|
| 2 |
-
import { supabase } from '../firebaseClient';
|
| 3 |
-
import { getOrGenerateAiSolution } from '../services/reviewService';
|
| 4 |
-
import { getCatalogProblemByNumber, getCatalogProblemById } from '../services/catalogService';
|
| 5 |
-
import type { ReviewItem, AiEvaluationResult } from '../types/reviewTypes';
|
| 6 |
|
| 7 |
export function useAiReviewer() {
|
| 8 |
-
const
|
| 9 |
-
const
|
| 10 |
-
const
|
| 11 |
|
| 12 |
-
const
|
| 13 |
-
const
|
| 14 |
-
const
|
| 15 |
|
| 16 |
-
const
|
| 17 |
-
const
|
| 18 |
|
| 19 |
-
const handleAiEvaluation =
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
setAiLoading(true);
|
| 25 |
-
setAiResult(null);
|
| 26 |
-
setAiError(null);
|
| 27 |
-
|
| 28 |
-
try {
|
| 29 |
-
const { data: { session } } = await supabase.auth.getSession();
|
| 30 |
-
const token = session ? session.access_token : 'sandbox';
|
| 31 |
-
|
| 32 |
-
const res = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/reviews/evaluate`, {
|
| 33 |
-
method: 'POST',
|
| 34 |
-
headers: {
|
| 35 |
-
'Content-Type': 'application/json',
|
| 36 |
-
'Authorization': `Bearer ${token}`
|
| 37 |
-
},
|
| 38 |
-
body: JSON.stringify({
|
| 39 |
-
problem_name: problem.name,
|
| 40 |
-
pattern: problem.pattern,
|
| 41 |
-
optimal_time: problem.optimal_time,
|
| 42 |
-
optimal_space: problem.optimal_space,
|
| 43 |
-
code: code
|
| 44 |
-
})
|
| 45 |
-
});
|
| 46 |
-
|
| 47 |
-
if (res.ok) {
|
| 48 |
-
const result = await res.json();
|
| 49 |
-
setAiResult(result);
|
| 50 |
-
} else {
|
| 51 |
-
const errorData = await res.json().catch(() => ({}));
|
| 52 |
-
setAiError(errorData.detail || 'Failed to analyze code.');
|
| 53 |
-
}
|
| 54 |
-
} catch {
|
| 55 |
-
setAiError('Connection to evaluation server failed.');
|
| 56 |
-
} finally {
|
| 57 |
-
setAiLoading(false);
|
| 58 |
-
}
|
| 59 |
-
},
|
| 60 |
-
[aiLoading]
|
| 61 |
-
);
|
| 62 |
-
|
| 63 |
-
const handleExplainCode = useCallback(
|
| 64 |
-
async (
|
| 65 |
-
activeReview: ReviewItem | undefined,
|
| 66 |
-
overrideCode?: string,
|
| 67 |
-
overridePattern?: string,
|
| 68 |
-
overrideTime?: string,
|
| 69 |
-
overrideSpace?: string
|
| 70 |
-
) => {
|
| 71 |
-
if (!activeReview || explainLoading) return;
|
| 72 |
-
const problem = activeReview.problems;
|
| 73 |
-
if (!problem) return;
|
| 74 |
-
|
| 75 |
-
const catalogProb = problem.problem_number
|
| 76 |
-
? getCatalogProblemByNumber(problem.problem_number)
|
| 77 |
-
: getCatalogProblemById(problem.id || '');
|
| 78 |
-
|
| 79 |
-
const refCode = overrideCode || problem.reference_code || catalogProb?.reference_solution;
|
| 80 |
-
if (!refCode) return;
|
| 81 |
-
|
| 82 |
-
setExplainLoading(true);
|
| 83 |
-
setExplanationText(null);
|
| 84 |
-
setExplainError(null);
|
| 85 |
-
|
| 86 |
-
try {
|
| 87 |
-
const { data: { session } } = await supabase.auth.getSession();
|
| 88 |
-
const token = session ? session.access_token : 'sandbox';
|
| 89 |
-
|
| 90 |
-
const res = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/reviews/explain`, {
|
| 91 |
-
method: 'POST',
|
| 92 |
-
headers: {
|
| 93 |
-
'Content-Type': 'application/json',
|
| 94 |
-
'Authorization': `Bearer ${token}`
|
| 95 |
-
},
|
| 96 |
-
body: JSON.stringify({
|
| 97 |
-
problem_number: problem.problem_number || catalogProb?.problem_number,
|
| 98 |
-
method: overridePattern || problem.pattern || catalogProb?.pattern,
|
| 99 |
-
code: refCode,
|
| 100 |
-
problem_name: problem.name,
|
| 101 |
-
optimal_time: overrideTime || problem.optimal_time || catalogProb?.time_complexity,
|
| 102 |
-
optimal_space: overrideSpace || problem.optimal_space || catalogProb?.space_complexity
|
| 103 |
-
})
|
| 104 |
-
});
|
| 105 |
-
|
| 106 |
-
if (res.ok) {
|
| 107 |
-
const result = await res.json();
|
| 108 |
-
setExplanationText(result.explanation);
|
| 109 |
-
} else {
|
| 110 |
-
const errorData = await res.json().catch(() => ({}));
|
| 111 |
-
setExplainError(errorData.detail || 'Failed to generate code explanation.');
|
| 112 |
-
}
|
| 113 |
-
} catch {
|
| 114 |
-
setExplainError('Connection to explanation server failed.');
|
| 115 |
-
} finally {
|
| 116 |
-
setExplainLoading(false);
|
| 117 |
-
}
|
| 118 |
-
},
|
| 119 |
-
[explainLoading]
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
const handleFetchAiSolution = useCallback(
|
| 123 |
-
async (activeReview: ReviewItem | undefined, onSolutionReceived?: (solution: string) => void) => {
|
| 124 |
-
if (!activeReview || aiSolutionLoading) return;
|
| 125 |
-
const problem = activeReview.problems;
|
| 126 |
-
const problemId = problem?.id || activeReview.problem_id;
|
| 127 |
-
const catalogProb = problem?.problem_number
|
| 128 |
-
? getCatalogProblemByNumber(problem.problem_number)
|
| 129 |
-
: getCatalogProblemById(problem?.id || '');
|
| 130 |
-
|
| 131 |
-
setAiSolutionLoading(true);
|
| 132 |
-
setAiSolutionError(null);
|
| 133 |
-
|
| 134 |
-
try {
|
| 135 |
-
const res = await getOrGenerateAiSolution({
|
| 136 |
-
problemId,
|
| 137 |
-
problemNumber: problem?.problem_number || catalogProb?.problem_number,
|
| 138 |
-
problemName: problem?.name,
|
| 139 |
-
pattern: problem?.pattern || catalogProb?.pattern
|
| 140 |
-
});
|
| 141 |
-
if (res.solution && onSolutionReceived) {
|
| 142 |
-
onSolutionReceived(res.solution);
|
| 143 |
-
}
|
| 144 |
-
} catch (err: unknown) {
|
| 145 |
-
const msg = err instanceof Error ? err.message : 'Failed to retrieve AI Grimoire solution';
|
| 146 |
-
setAiSolutionError(msg);
|
| 147 |
-
} finally {
|
| 148 |
-
setAiSolutionLoading(false);
|
| 149 |
-
}
|
| 150 |
-
},
|
| 151 |
-
[aiSolutionLoading]
|
| 152 |
-
);
|
| 153 |
-
|
| 154 |
-
const resetAiState = useCallback(() => {
|
| 155 |
-
setAiResult(null);
|
| 156 |
-
setAiError(null);
|
| 157 |
-
setExplanationText(null);
|
| 158 |
-
setExplainError(null);
|
| 159 |
-
setAiSolutionError(null);
|
| 160 |
-
}, []);
|
| 161 |
|
| 162 |
return {
|
| 163 |
aiLoading,
|
|
|
|
| 1 |
+
import { useProcessStore } from '../stores/useProcessStore';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
export function useAiReviewer() {
|
| 4 |
+
const aiLoading = useProcessStore(s => s.aiLoading);
|
| 5 |
+
const aiResult = useProcessStore(s => s.aiResult);
|
| 6 |
+
const aiError = useProcessStore(s => s.aiError);
|
| 7 |
|
| 8 |
+
const explainLoading = useProcessStore(s => s.explainLoading);
|
| 9 |
+
const explanationText = useProcessStore(s => s.explanationText);
|
| 10 |
+
const explainError = useProcessStore(s => s.explainError);
|
| 11 |
|
| 12 |
+
const aiSolutionLoading = useProcessStore(s => s.aiSolutionLoading);
|
| 13 |
+
const aiSolutionError = useProcessStore(s => s.aiSolutionError);
|
| 14 |
|
| 15 |
+
const handleAiEvaluation = useProcessStore(s => s.handleAiEvaluation);
|
| 16 |
+
const handleExplainCode = useProcessStore(s => s.handleExplainCode);
|
| 17 |
+
const handleFetchAiSolution = useProcessStore(s => s.handleFetchAiSolution);
|
| 18 |
+
const resetAiState = useProcessStore(s => s.resetAiState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
return {
|
| 21 |
aiLoading,
|
algospaced-ui/src/hooks/useSandboxRunner.ts
CHANGED
|
@@ -1,139 +1,16 @@
|
|
| 1 |
-
import {
|
| 2 |
-
import {
|
| 3 |
-
runSandboxTests,
|
| 4 |
-
saveReferenceSolution,
|
| 5 |
-
type SandboxRunResult,
|
| 6 |
-
type SaveReferenceMetadata
|
| 7 |
-
} from '../services/reviewService';
|
| 8 |
-
import { findCatalogProblem } from '../services/catalogService';
|
| 9 |
-
import type { ReviewItem } from '../types/reviewTypes';
|
| 10 |
|
| 11 |
export function useSandboxRunner() {
|
| 12 |
-
const
|
| 13 |
-
const
|
| 14 |
-
const
|
| 15 |
-
|
| 16 |
-
const
|
| 17 |
-
const
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
const
|
| 21 |
-
|
| 22 |
-
if (!activeReview || !code.trim() || sandboxRunning) return;
|
| 23 |
-
const problem = activeReview.problems;
|
| 24 |
-
const catalogProb = findCatalogProblem(
|
| 25 |
-
problem?.problem_number,
|
| 26 |
-
problem?.id || '',
|
| 27 |
-
problem?.name
|
| 28 |
-
);
|
| 29 |
-
|
| 30 |
-
const rawExamples = problem?.examples && problem.examples.length > 0
|
| 31 |
-
? problem.examples
|
| 32 |
-
: catalogProb?.examples || [];
|
| 33 |
-
|
| 34 |
-
const formattedCases = rawExamples.map((ex) => {
|
| 35 |
-
if (typeof ex === 'string') return { input: ex, expected: '' };
|
| 36 |
-
return { input: ex?.input ?? '', expected: ex?.output ?? '' };
|
| 37 |
-
});
|
| 38 |
-
|
| 39 |
-
const starterCode = catalogProb?.starter_code || problem?.starter_code;
|
| 40 |
-
const problemName = problem?.name || catalogProb?.name;
|
| 41 |
-
|
| 42 |
-
setSandboxRunning(true);
|
| 43 |
-
setSandboxResults(null);
|
| 44 |
-
setSandboxError(null);
|
| 45 |
-
setSavedRefSuccess(false);
|
| 46 |
-
|
| 47 |
-
try {
|
| 48 |
-
const res = await runSandboxTests(code, formattedCases, 4.0, starterCode, problemName);
|
| 49 |
-
setSandboxResults(res);
|
| 50 |
-
} catch (err: unknown) {
|
| 51 |
-
const msg = err instanceof Error ? err.message : 'Execution failed';
|
| 52 |
-
setSandboxError(msg);
|
| 53 |
-
} finally {
|
| 54 |
-
setSandboxRunning(false);
|
| 55 |
-
}
|
| 56 |
-
},
|
| 57 |
-
[sandboxRunning]
|
| 58 |
-
);
|
| 59 |
-
|
| 60 |
-
const handleSaveReference = useCallback(
|
| 61 |
-
async (
|
| 62 |
-
activeReview: ReviewItem | undefined,
|
| 63 |
-
code: string,
|
| 64 |
-
onSuccessUpdate?: (code: string, problemId?: string) => void
|
| 65 |
-
) => {
|
| 66 |
-
if (!activeReview || !code.trim() || savingReference) return;
|
| 67 |
-
const problem = activeReview.problems;
|
| 68 |
-
const rawProbId = problem?.id || activeReview.problem_id;
|
| 69 |
-
if (!rawProbId && !problem?.problem_number) return;
|
| 70 |
-
|
| 71 |
-
const probNum = problem?.problem_number ?? (
|
| 72 |
-
typeof activeReview.problem_id === 'number'
|
| 73 |
-
? activeReview.problem_id
|
| 74 |
-
: (/^\d+$/.test(activeReview.problem_id || '') ? parseInt(activeReview.problem_id, 10) : undefined)
|
| 75 |
-
);
|
| 76 |
-
|
| 77 |
-
const catalogProb = findCatalogProblem(
|
| 78 |
-
probNum,
|
| 79 |
-
rawProbId || activeReview.problem_id,
|
| 80 |
-
problem?.name
|
| 81 |
-
);
|
| 82 |
-
|
| 83 |
-
const rawConstraints = problem?.constraints ?? catalogProb?.constraints;
|
| 84 |
-
const formattedConstraints: string[] = Array.isArray(rawConstraints)
|
| 85 |
-
? (rawConstraints as string[])
|
| 86 |
-
: (rawConstraints ? [String(rawConstraints)] : []);
|
| 87 |
-
|
| 88 |
-
const rawExamples = (problem?.examples && problem.examples.length > 0)
|
| 89 |
-
? problem.examples
|
| 90 |
-
: catalogProb?.examples;
|
| 91 |
-
const formattedExamples = rawExamples
|
| 92 |
-
? rawExamples.map((ex: { input?: unknown; output?: unknown; explanation?: string } | string) =>
|
| 93 |
-
typeof ex === 'string'
|
| 94 |
-
? { input: ex, output: '' }
|
| 95 |
-
: { input: String(ex?.input ?? ''), output: String(ex?.output ?? ''), explanation: ex?.explanation }
|
| 96 |
-
)
|
| 97 |
-
: [];
|
| 98 |
-
|
| 99 |
-
const metadata: SaveReferenceMetadata = {
|
| 100 |
-
problem_number: probNum ?? catalogProb?.problem_number,
|
| 101 |
-
problem_name: problem?.name || catalogProb?.name,
|
| 102 |
-
pattern: problem?.pattern || catalogProb?.pattern,
|
| 103 |
-
difficulty: problem?.difficulty || catalogProb?.difficulty,
|
| 104 |
-
optimal_time: problem?.optimal_time || catalogProb?.time_complexity,
|
| 105 |
-
optimal_space: problem?.optimal_space || catalogProb?.space_complexity,
|
| 106 |
-
description: problem?.description || catalogProb?.description,
|
| 107 |
-
starter_code: catalogProb?.starter_code || problem?.starter_code,
|
| 108 |
-
examples: formattedExamples,
|
| 109 |
-
constraints: formattedConstraints,
|
| 110 |
-
};
|
| 111 |
-
|
| 112 |
-
setSavingReference(true);
|
| 113 |
-
setSaveRefError(null);
|
| 114 |
-
try {
|
| 115 |
-
const res = await saveReferenceSolution(rawProbId, code, metadata);
|
| 116 |
-
setSavedRefSuccess(true);
|
| 117 |
-
if (onSuccessUpdate) {
|
| 118 |
-
onSuccessUpdate(code, res.problem_id);
|
| 119 |
-
}
|
| 120 |
-
setTimeout(() => setSavedRefSuccess(false), 3500);
|
| 121 |
-
} catch (err: unknown) {
|
| 122 |
-
const msg = err instanceof Error ? err.message : 'Failed to save solution';
|
| 123 |
-
setSaveRefError(msg);
|
| 124 |
-
} finally {
|
| 125 |
-
setSavingReference(false);
|
| 126 |
-
}
|
| 127 |
-
},
|
| 128 |
-
[savingReference]
|
| 129 |
-
);
|
| 130 |
-
|
| 131 |
-
const resetSandbox = useCallback(() => {
|
| 132 |
-
setSandboxResults(null);
|
| 133 |
-
setSandboxError(null);
|
| 134 |
-
setSavedRefSuccess(false);
|
| 135 |
-
setSaveRefError(null);
|
| 136 |
-
}, []);
|
| 137 |
|
| 138 |
return {
|
| 139 |
sandboxRunning,
|
|
|
|
| 1 |
+
import { useProcessStore } from '../stores/useProcessStore';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
export function useSandboxRunner() {
|
| 4 |
+
const sandboxRunning = useProcessStore(s => s.sandboxRunning);
|
| 5 |
+
const sandboxResults = useProcessStore(s => s.sandboxResults);
|
| 6 |
+
const sandboxError = useProcessStore(s => s.sandboxError);
|
| 7 |
+
const savingReference = useProcessStore(s => s.savingReference);
|
| 8 |
+
const savedRefSuccess = useProcessStore(s => s.savedRefSuccess);
|
| 9 |
+
const saveRefError = useProcessStore(s => s.saveRefError);
|
| 10 |
+
|
| 11 |
+
const handleRunSandbox = useProcessStore(s => s.handleRunSandbox);
|
| 12 |
+
const handleSaveReference = useProcessStore(s => s.handleSaveReference);
|
| 13 |
+
const resetSandbox = useProcessStore(s => s.resetSandbox);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
return {
|
| 16 |
sandboxRunning,
|
algospaced-ui/src/hooks/useWindowManager.ts
CHANGED
|
@@ -1,97 +1,56 @@
|
|
| 1 |
-
import {
|
|
|
|
| 2 |
import type { WindowId, WindowsMap, WindowState } from '../types/windowTypes';
|
| 3 |
import type { ProblemItem } from '../types/reviewTypes';
|
| 4 |
|
| 5 |
-
const INITIAL_WINDOWS: WindowsMap = {
|
| 6 |
-
queue: { isOpen: true, isMinimized: false },
|
| 7 |
-
journey: { isOpen: false, isMinimized: false },
|
| 8 |
-
terminal: { isOpen: false, isMinimized: false },
|
| 9 |
-
computer: { isOpen: false, isMinimized: false },
|
| 10 |
-
sync: { isOpen: false, isMinimized: false },
|
| 11 |
-
github: { isOpen: false, isMinimized: false },
|
| 12 |
-
python: { isOpen: false, isMinimized: false },
|
| 13 |
-
mysql: { isOpen: false, isMinimized: false },
|
| 14 |
-
settings: { isOpen: false, isMinimized: false },
|
| 15 |
-
createProblem: { isOpen: false, isMinimized: false },
|
| 16 |
-
editProblem: { isOpen: false, isMinimized: false },
|
| 17 |
-
companion: { isOpen: false, isMinimized: false },
|
| 18 |
-
};
|
| 19 |
-
|
| 20 |
export function useWindowManager(onStartMenuClose?: () => void) {
|
| 21 |
-
const
|
| 22 |
-
const
|
| 23 |
-
const
|
| 24 |
-
const
|
| 25 |
-
const
|
| 26 |
|
| 27 |
const openWindow = useCallback((id: string) => {
|
| 28 |
-
|
| 29 |
-
setWindows(prev => ({
|
| 30 |
-
...prev,
|
| 31 |
-
[winId]: { isOpen: true, isMinimized: false }
|
| 32 |
-
}));
|
| 33 |
-
setActiveWindow(id);
|
| 34 |
if (onStartMenuClose) {
|
| 35 |
onStartMenuClose();
|
| 36 |
}
|
| 37 |
}, [onStartMenuClose]);
|
| 38 |
|
| 39 |
const closeWindow = useCallback((id: string) => {
|
| 40 |
-
|
| 41 |
-
setWindows(prev => {
|
| 42 |
-
const current = prev[winId] || { isOpen: false, isMinimized: false };
|
| 43 |
-
return {
|
| 44 |
-
...prev,
|
| 45 |
-
[winId]: { ...current, isOpen: false }
|
| 46 |
-
};
|
| 47 |
-
});
|
| 48 |
}, []);
|
| 49 |
|
| 50 |
const minimizeWindow = useCallback((id: string) => {
|
| 51 |
-
|
| 52 |
-
setWindows(prev => {
|
| 53 |
-
const current = prev[winId] || { isOpen: true, isMinimized: false };
|
| 54 |
-
return {
|
| 55 |
-
...prev,
|
| 56 |
-
[winId]: { ...current, isMinimized: true }
|
| 57 |
-
};
|
| 58 |
-
});
|
| 59 |
}, []);
|
| 60 |
|
| 61 |
const toggleWindowMinimize = useCallback((id: string) => {
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
const win: WindowState = prev[winId] || { isOpen: false, isMinimized: false };
|
| 65 |
-
if (win.isMinimized || !win.isOpen) {
|
| 66 |
-
setActiveWindow(id);
|
| 67 |
-
return {
|
| 68 |
-
...prev,
|
| 69 |
-
[winId]: { isOpen: true, isMinimized: false }
|
| 70 |
-
};
|
| 71 |
-
} else if (activeWindow === id) {
|
| 72 |
-
return {
|
| 73 |
-
...prev,
|
| 74 |
-
[winId]: { ...win, isMinimized: true }
|
| 75 |
-
};
|
| 76 |
-
} else {
|
| 77 |
-
setActiveWindow(id);
|
| 78 |
-
return prev;
|
| 79 |
-
}
|
| 80 |
-
});
|
| 81 |
-
}, [activeWindow]);
|
| 82 |
|
| 83 |
-
const
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
const openEditProblem = useCallback((problem: ProblemItem) => {
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
const triggerRefreshExplorer = useCallback(() => {
|
| 94 |
-
|
| 95 |
}, []);
|
| 96 |
|
| 97 |
const isAnyWindowOpen = useMemo(() => {
|
|
@@ -117,3 +76,5 @@ export function useWindowManager(onStartMenuClose?: () => void) {
|
|
| 117 |
isAnyWindowOpen
|
| 118 |
};
|
| 119 |
}
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useCallback, useMemo } from 'react';
|
| 2 |
+
import { useOSStore } from '../stores/useOSStore';
|
| 3 |
import type { WindowId, WindowsMap, WindowState } from '../types/windowTypes';
|
| 4 |
import type { ProblemItem } from '../types/reviewTypes';
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
export function useWindowManager(onStartMenuClose?: () => void) {
|
| 7 |
+
const windows = useOSStore(s => s.windows);
|
| 8 |
+
const activeWindow = useOSStore(s => s.activeWindow);
|
| 9 |
+
const overrideProblemId = useOSStore(s => s.overrideProblemId);
|
| 10 |
+
const editingProblem = useOSStore(s => s.editingProblem);
|
| 11 |
+
const refreshExplorerTrigger = useOSStore(s => s.refreshExplorerTrigger);
|
| 12 |
|
| 13 |
const openWindow = useCallback((id: string) => {
|
| 14 |
+
useOSStore.getState().openWindow(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if (onStartMenuClose) {
|
| 16 |
onStartMenuClose();
|
| 17 |
}
|
| 18 |
}, [onStartMenuClose]);
|
| 19 |
|
| 20 |
const closeWindow = useCallback((id: string) => {
|
| 21 |
+
useOSStore.getState().closeWindow(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}, []);
|
| 23 |
|
| 24 |
const minimizeWindow = useCallback((id: string) => {
|
| 25 |
+
useOSStore.getState().minimizeWindow(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}, []);
|
| 27 |
|
| 28 |
const toggleWindowMinimize = useCallback((id: string) => {
|
| 29 |
+
useOSStore.getState().toggleWindowMinimize(id);
|
| 30 |
+
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
const setActiveWindow = useCallback((id: string) => {
|
| 33 |
+
useOSStore.getState().setActiveWindow(id);
|
| 34 |
+
}, []);
|
| 35 |
+
|
| 36 |
+
const setOverrideProblemId = useCallback((id: string | null) => {
|
| 37 |
+
useOSStore.getState().setOverrideProblemId(id);
|
| 38 |
+
}, []);
|
| 39 |
+
|
| 40 |
+
const setEditingProblem = useCallback((problem: ProblemItem | null) => {
|
| 41 |
+
useOSStore.getState().setEditingProblem(problem);
|
| 42 |
+
}, []);
|
| 43 |
|
| 44 |
const openEditProblem = useCallback((problem: ProblemItem) => {
|
| 45 |
+
useOSStore.getState().openEditProblem(problem);
|
| 46 |
+
}, []);
|
| 47 |
+
|
| 48 |
+
const handleSelectProblemForReview = useCallback((problemId: string) => {
|
| 49 |
+
useOSStore.getState().handleSelectProblemForReview(problemId);
|
| 50 |
+
}, []);
|
| 51 |
|
| 52 |
const triggerRefreshExplorer = useCallback(() => {
|
| 53 |
+
useOSStore.getState().triggerRefreshExplorer();
|
| 54 |
}, []);
|
| 55 |
|
| 56 |
const isAnyWindowOpen = useMemo(() => {
|
|
|
|
| 76 |
isAnyWindowOpen
|
| 77 |
};
|
| 78 |
}
|
| 79 |
+
|
| 80 |
+
export type { WindowId, WindowsMap, WindowState };
|
algospaced-ui/src/stores/useOSStore.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { create } from 'zustand';
|
| 2 |
+
import { persist } from 'zustand/middleware';
|
| 3 |
+
import type { WindowId, WindowsMap, WindowState } from '../types/windowTypes';
|
| 4 |
+
import type { ProblemItem } from '../types/reviewTypes';
|
| 5 |
+
|
| 6 |
+
const INITIAL_WINDOWS: WindowsMap = {
|
| 7 |
+
queue: { isOpen: true, isMinimized: false },
|
| 8 |
+
journey: { isOpen: false, isMinimized: false },
|
| 9 |
+
terminal: { isOpen: false, isMinimized: false },
|
| 10 |
+
computer: { isOpen: false, isMinimized: false },
|
| 11 |
+
sync: { isOpen: false, isMinimized: false },
|
| 12 |
+
github: { isOpen: false, isMinimized: false },
|
| 13 |
+
python: { isOpen: false, isMinimized: false },
|
| 14 |
+
mysql: { isOpen: false, isMinimized: false },
|
| 15 |
+
settings: { isOpen: false, isMinimized: false },
|
| 16 |
+
createProblem: { isOpen: false, isMinimized: false },
|
| 17 |
+
editProblem: { isOpen: false, isMinimized: false },
|
| 18 |
+
companion: { isOpen: false, isMinimized: false },
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
export interface WindowPosition {
|
| 22 |
+
x: number;
|
| 23 |
+
y: number;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
export interface WindowSize {
|
| 27 |
+
width: number;
|
| 28 |
+
height: number;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export interface OSStoreState {
|
| 32 |
+
// Window states
|
| 33 |
+
windows: WindowsMap;
|
| 34 |
+
activeWindow: string;
|
| 35 |
+
windowZIndexes: Record<string, number>;
|
| 36 |
+
maxZIndex: number;
|
| 37 |
+
windowPositions: Record<string, WindowPosition>;
|
| 38 |
+
windowSizes: Record<string, WindowSize>;
|
| 39 |
+
maximizedWindows: Record<string, boolean>;
|
| 40 |
+
|
| 41 |
+
// Problem Review & Explorer orchestration
|
| 42 |
+
overrideProblemId: string | null;
|
| 43 |
+
editingProblem: ProblemItem | null;
|
| 44 |
+
refreshExplorerTrigger: number;
|
| 45 |
+
|
| 46 |
+
// Window Actions
|
| 47 |
+
openWindow: (id: WindowId | string) => void;
|
| 48 |
+
closeWindow: (id: WindowId | string) => void;
|
| 49 |
+
minimizeWindow: (id: WindowId | string) => void;
|
| 50 |
+
toggleWindowMinimize: (id: WindowId | string) => void;
|
| 51 |
+
focusWindow: (id: string) => void;
|
| 52 |
+
setActiveWindow: (id: string) => void;
|
| 53 |
+
updateWindowPosition: (id: string, x: number, y: number) => void;
|
| 54 |
+
updateWindowSize: (id: string, width: number, height: number) => void;
|
| 55 |
+
toggleMaximize: (id: string) => void;
|
| 56 |
+
resetWindowBounds: (id: string) => void;
|
| 57 |
+
|
| 58 |
+
// Problem actions
|
| 59 |
+
setOverrideProblemId: (id: string | null) => void;
|
| 60 |
+
setEditingProblem: (problem: ProblemItem | null) => void;
|
| 61 |
+
openEditProblem: (problem: ProblemItem) => void;
|
| 62 |
+
handleSelectProblemForReview: (problemId: string) => void;
|
| 63 |
+
triggerRefreshExplorer: () => void;
|
| 64 |
+
|
| 65 |
+
// Computed helper
|
| 66 |
+
isAnyWindowOpen: () => boolean;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
export const useOSStore = create<OSStoreState>()(
|
| 70 |
+
persist(
|
| 71 |
+
(set, get) => ({
|
| 72 |
+
windows: INITIAL_WINDOWS,
|
| 73 |
+
activeWindow: 'queue',
|
| 74 |
+
windowZIndexes: { queue: 40 },
|
| 75 |
+
maxZIndex: 40,
|
| 76 |
+
windowPositions: {},
|
| 77 |
+
windowSizes: {},
|
| 78 |
+
maximizedWindows: {},
|
| 79 |
+
|
| 80 |
+
overrideProblemId: null,
|
| 81 |
+
editingProblem: null,
|
| 82 |
+
refreshExplorerTrigger: 0,
|
| 83 |
+
|
| 84 |
+
openWindow: (id: WindowId | string) => {
|
| 85 |
+
const winId = id as WindowId;
|
| 86 |
+
const nextZ = get().maxZIndex + 1;
|
| 87 |
+
set(state => ({
|
| 88 |
+
windows: {
|
| 89 |
+
...state.windows,
|
| 90 |
+
[winId]: { isOpen: true, isMinimized: false }
|
| 91 |
+
},
|
| 92 |
+
activeWindow: id,
|
| 93 |
+
maxZIndex: nextZ,
|
| 94 |
+
windowZIndexes: {
|
| 95 |
+
...state.windowZIndexes,
|
| 96 |
+
[id]: nextZ
|
| 97 |
+
}
|
| 98 |
+
}));
|
| 99 |
+
},
|
| 100 |
+
|
| 101 |
+
closeWindow: (id: WindowId | string) => {
|
| 102 |
+
const winId = id as WindowId;
|
| 103 |
+
set(state => {
|
| 104 |
+
const current = state.windows[winId] || { isOpen: false, isMinimized: false };
|
| 105 |
+
const updatedWindows = {
|
| 106 |
+
...state.windows,
|
| 107 |
+
[winId]: { ...current, isOpen: false }
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
+
// If we closed the active window, shift active to the highest z-index open window
|
| 111 |
+
let nextActive = state.activeWindow;
|
| 112 |
+
if (state.activeWindow === id) {
|
| 113 |
+
const openWindows = Object.entries(updatedWindows)
|
| 114 |
+
.filter(([, w]) => w.isOpen && !w.isMinimized)
|
| 115 |
+
.sort((a, b) => (state.windowZIndexes[b[0]] || 0) - (state.windowZIndexes[a[0]] || 0));
|
| 116 |
+
nextActive = openWindows.length > 0 ? openWindows[0][0] : '';
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
return {
|
| 120 |
+
windows: updatedWindows,
|
| 121 |
+
activeWindow: nextActive
|
| 122 |
+
};
|
| 123 |
+
});
|
| 124 |
+
},
|
| 125 |
+
|
| 126 |
+
minimizeWindow: (id: WindowId | string) => {
|
| 127 |
+
const winId = id as WindowId;
|
| 128 |
+
set(state => {
|
| 129 |
+
const current = state.windows[winId] || { isOpen: true, isMinimized: false };
|
| 130 |
+
const updatedWindows = {
|
| 131 |
+
...state.windows,
|
| 132 |
+
[winId]: { ...current, isMinimized: true }
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
let nextActive = state.activeWindow;
|
| 136 |
+
if (state.activeWindow === id) {
|
| 137 |
+
const openWindows = Object.entries(updatedWindows)
|
| 138 |
+
.filter(([key, w]) => w.isOpen && !w.isMinimized && key !== id)
|
| 139 |
+
.sort((a, b) => (state.windowZIndexes[b[0]] || 0) - (state.windowZIndexes[a[0]] || 0));
|
| 140 |
+
nextActive = openWindows.length > 0 ? openWindows[0][0] : '';
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
return {
|
| 144 |
+
windows: updatedWindows,
|
| 145 |
+
activeWindow: nextActive
|
| 146 |
+
};
|
| 147 |
+
});
|
| 148 |
+
},
|
| 149 |
+
|
| 150 |
+
toggleWindowMinimize: (id: WindowId | string) => {
|
| 151 |
+
const winId = id as WindowId;
|
| 152 |
+
const state = get();
|
| 153 |
+
const win: WindowState = state.windows[winId] || { isOpen: false, isMinimized: false };
|
| 154 |
+
|
| 155 |
+
if (win.isMinimized || !win.isOpen) {
|
| 156 |
+
// Open or restore and focus
|
| 157 |
+
get().openWindow(id);
|
| 158 |
+
} else if (state.activeWindow === id) {
|
| 159 |
+
// It is already focused and open -> minimize it
|
| 160 |
+
get().minimizeWindow(id);
|
| 161 |
+
} else {
|
| 162 |
+
// It is open in background -> bring to focus
|
| 163 |
+
get().focusWindow(id);
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
|
| 167 |
+
focusWindow: (id: string) => {
|
| 168 |
+
const state = get();
|
| 169 |
+
if (state.activeWindow === id) return;
|
| 170 |
+
const nextZ = state.maxZIndex + 1;
|
| 171 |
+
set({
|
| 172 |
+
activeWindow: id,
|
| 173 |
+
maxZIndex: nextZ,
|
| 174 |
+
windowZIndexes: {
|
| 175 |
+
...state.windowZIndexes,
|
| 176 |
+
[id]: nextZ
|
| 177 |
+
}
|
| 178 |
+
});
|
| 179 |
+
},
|
| 180 |
+
|
| 181 |
+
setActiveWindow: (id: string) => {
|
| 182 |
+
get().focusWindow(id);
|
| 183 |
+
},
|
| 184 |
+
|
| 185 |
+
updateWindowPosition: (id: string, x: number, y: number) => {
|
| 186 |
+
set(state => ({
|
| 187 |
+
windowPositions: {
|
| 188 |
+
...state.windowPositions,
|
| 189 |
+
[id]: { x, y }
|
| 190 |
+
}
|
| 191 |
+
}));
|
| 192 |
+
},
|
| 193 |
+
|
| 194 |
+
updateWindowSize: (id: string, width: number, height: number) => {
|
| 195 |
+
set(state => ({
|
| 196 |
+
windowSizes: {
|
| 197 |
+
...state.windowSizes,
|
| 198 |
+
[id]: { width, height }
|
| 199 |
+
}
|
| 200 |
+
}));
|
| 201 |
+
},
|
| 202 |
+
|
| 203 |
+
toggleMaximize: (id: string) => {
|
| 204 |
+
set(state => ({
|
| 205 |
+
maximizedWindows: {
|
| 206 |
+
...state.maximizedWindows,
|
| 207 |
+
[id]: !state.maximizedWindows[id]
|
| 208 |
+
}
|
| 209 |
+
}));
|
| 210 |
+
},
|
| 211 |
+
|
| 212 |
+
resetWindowBounds: (id: string) => {
|
| 213 |
+
set(state => {
|
| 214 |
+
const restPositions = { ...state.windowPositions };
|
| 215 |
+
delete restPositions[id];
|
| 216 |
+
const restSizes = { ...state.windowSizes };
|
| 217 |
+
delete restSizes[id];
|
| 218 |
+
const restMaximized = { ...state.maximizedWindows };
|
| 219 |
+
delete restMaximized[id];
|
| 220 |
+
return {
|
| 221 |
+
windowPositions: restPositions,
|
| 222 |
+
windowSizes: restSizes,
|
| 223 |
+
maximizedWindows: restMaximized
|
| 224 |
+
};
|
| 225 |
+
});
|
| 226 |
+
},
|
| 227 |
+
|
| 228 |
+
setOverrideProblemId: (id: string | null) => {
|
| 229 |
+
set({ overrideProblemId: id });
|
| 230 |
+
},
|
| 231 |
+
|
| 232 |
+
setEditingProblem: (problem: ProblemItem | null) => {
|
| 233 |
+
set({ editingProblem: problem });
|
| 234 |
+
},
|
| 235 |
+
|
| 236 |
+
openEditProblem: (problem: ProblemItem) => {
|
| 237 |
+
set({ editingProblem: problem });
|
| 238 |
+
get().openWindow('editProblem');
|
| 239 |
+
},
|
| 240 |
+
|
| 241 |
+
handleSelectProblemForReview: (problemId: string) => {
|
| 242 |
+
set({ overrideProblemId: problemId });
|
| 243 |
+
get().openWindow('queue');
|
| 244 |
+
},
|
| 245 |
+
|
| 246 |
+
triggerRefreshExplorer: () => {
|
| 247 |
+
set(state => ({ refreshExplorerTrigger: state.refreshExplorerTrigger + 1 }));
|
| 248 |
+
},
|
| 249 |
+
|
| 250 |
+
isAnyWindowOpen: () => {
|
| 251 |
+
const state = get();
|
| 252 |
+
return Object.values(state.windows).some(w => w.isOpen && !w.isMinimized);
|
| 253 |
+
}
|
| 254 |
+
}),
|
| 255 |
+
{
|
| 256 |
+
name: 'algospaced_os_state',
|
| 257 |
+
// Only persist stable layout and open state across browser reloads
|
| 258 |
+
partialize: state => ({
|
| 259 |
+
windows: state.windows,
|
| 260 |
+
windowPositions: state.windowPositions,
|
| 261 |
+
windowSizes: state.windowSizes,
|
| 262 |
+
maximizedWindows: state.maximizedWindows
|
| 263 |
+
}),
|
| 264 |
+
// Safely merge persisted state with any newly added INITIAL_WINDOWS
|
| 265 |
+
merge: (persistedState: unknown, currentState: OSStoreState) => {
|
| 266 |
+
const typedPersisted = persistedState as Partial<OSStoreState> | undefined;
|
| 267 |
+
return {
|
| 268 |
+
...currentState,
|
| 269 |
+
windows: {
|
| 270 |
+
...currentState.windows,
|
| 271 |
+
...(typedPersisted?.windows || {})
|
| 272 |
+
},
|
| 273 |
+
windowPositions: typedPersisted?.windowPositions || currentState.windowPositions,
|
| 274 |
+
windowSizes: typedPersisted?.windowSizes || currentState.windowSizes,
|
| 275 |
+
maximizedWindows: typedPersisted?.maximizedWindows || currentState.maximizedWindows
|
| 276 |
+
};
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
)
|
| 280 |
+
);
|
algospaced-ui/src/stores/useProcessStore.ts
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { create } from 'zustand';
|
| 2 |
+
import { supabase } from '../firebaseClient';
|
| 3 |
+
import {
|
| 4 |
+
runSandboxTests,
|
| 5 |
+
saveReferenceSolution,
|
| 6 |
+
getOrGenerateAiSolution,
|
| 7 |
+
type SandboxRunResult,
|
| 8 |
+
type SaveReferenceMetadata
|
| 9 |
+
} from '../services/reviewService';
|
| 10 |
+
import {
|
| 11 |
+
findCatalogProblem,
|
| 12 |
+
getCatalogProblemByNumber,
|
| 13 |
+
getCatalogProblemById
|
| 14 |
+
} from '../services/catalogService';
|
| 15 |
+
import type { ReviewItem, AiEvaluationResult } from '../types/reviewTypes';
|
| 16 |
+
import type { ProcessAppId, ProcessStatus, OSProcess } from '../types/osTypes';
|
| 17 |
+
|
| 18 |
+
export interface ProcessStoreState {
|
| 19 |
+
// Process Table
|
| 20 |
+
processes: Record<string, OSProcess>;
|
| 21 |
+
|
| 22 |
+
// Sandbox Runner State
|
| 23 |
+
sandboxRunning: boolean;
|
| 24 |
+
sandboxResults: SandboxRunResult | null;
|
| 25 |
+
sandboxError: string | null;
|
| 26 |
+
savingReference: boolean;
|
| 27 |
+
savedRefSuccess: boolean;
|
| 28 |
+
saveRefError: string | null;
|
| 29 |
+
|
| 30 |
+
// AI Reviewer State
|
| 31 |
+
aiLoading: boolean;
|
| 32 |
+
aiResult: AiEvaluationResult | null;
|
| 33 |
+
aiError: string | null;
|
| 34 |
+
explainLoading: boolean;
|
| 35 |
+
explanationText: string | null;
|
| 36 |
+
explainError: string | null;
|
| 37 |
+
aiSolutionLoading: boolean;
|
| 38 |
+
aiSolutionError: string | null;
|
| 39 |
+
|
| 40 |
+
// Process Management Actions
|
| 41 |
+
registerProcess: (appId: ProcessAppId, title: string) => string;
|
| 42 |
+
updateProcessStatus: (pid: string, status: ProcessStatus, error?: string | null, data?: unknown) => void;
|
| 43 |
+
removeProcess: (pid: string) => void;
|
| 44 |
+
clearFinishedProcesses: () => void;
|
| 45 |
+
|
| 46 |
+
// Headless Task Runners
|
| 47 |
+
handleRunSandbox: (activeReview: ReviewItem | undefined, code: string) => Promise<void>;
|
| 48 |
+
handleSaveReference: (
|
| 49 |
+
activeReview: ReviewItem | undefined,
|
| 50 |
+
code: string,
|
| 51 |
+
onSuccessUpdate?: (code: string, problemId?: string) => void
|
| 52 |
+
) => Promise<void>;
|
| 53 |
+
resetSandbox: () => void;
|
| 54 |
+
|
| 55 |
+
handleAiEvaluation: (activeReview: ReviewItem | undefined, code: string) => Promise<void>;
|
| 56 |
+
handleExplainCode: (
|
| 57 |
+
activeReview: ReviewItem | undefined,
|
| 58 |
+
overrideCode?: string,
|
| 59 |
+
overridePattern?: string,
|
| 60 |
+
overrideTime?: string,
|
| 61 |
+
overrideSpace?: string
|
| 62 |
+
) => Promise<void>;
|
| 63 |
+
handleFetchAiSolution: (
|
| 64 |
+
activeReview: ReviewItem | undefined,
|
| 65 |
+
onSolutionReceived?: (solution: string) => void
|
| 66 |
+
) => Promise<void>;
|
| 67 |
+
resetAiState: () => void;
|
| 68 |
+
|
| 69 |
+
// Computed queries
|
| 70 |
+
getActiveProcesses: () => OSProcess[];
|
| 71 |
+
hasRunningProcesses: () => boolean;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
export const useProcessStore = create<ProcessStoreState>((set, get) => ({
|
| 75 |
+
processes: {},
|
| 76 |
+
|
| 77 |
+
sandboxRunning: false,
|
| 78 |
+
sandboxResults: null,
|
| 79 |
+
sandboxError: null,
|
| 80 |
+
savingReference: false,
|
| 81 |
+
savedRefSuccess: false,
|
| 82 |
+
saveRefError: null,
|
| 83 |
+
|
| 84 |
+
aiLoading: false,
|
| 85 |
+
aiResult: null,
|
| 86 |
+
aiError: null,
|
| 87 |
+
explainLoading: false,
|
| 88 |
+
explanationText: null,
|
| 89 |
+
explainError: null,
|
| 90 |
+
aiSolutionLoading: false,
|
| 91 |
+
aiSolutionError: null,
|
| 92 |
+
|
| 93 |
+
registerProcess: (appId: ProcessAppId, title: string): string => {
|
| 94 |
+
const pid = `${appId}-${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 6)}`;
|
| 95 |
+
const newProcess: OSProcess = {
|
| 96 |
+
pid,
|
| 97 |
+
appId,
|
| 98 |
+
title,
|
| 99 |
+
status: 'running',
|
| 100 |
+
startedAt: Date.now()
|
| 101 |
+
};
|
| 102 |
+
set(state => ({
|
| 103 |
+
processes: {
|
| 104 |
+
...state.processes,
|
| 105 |
+
[pid]: newProcess
|
| 106 |
+
}
|
| 107 |
+
}));
|
| 108 |
+
return pid;
|
| 109 |
+
},
|
| 110 |
+
|
| 111 |
+
updateProcessStatus: (pid: string, status: ProcessStatus, error?: string | null, data?: unknown) => {
|
| 112 |
+
set(state => {
|
| 113 |
+
const proc = state.processes[pid];
|
| 114 |
+
if (!proc) return state;
|
| 115 |
+
return {
|
| 116 |
+
processes: {
|
| 117 |
+
...state.processes,
|
| 118 |
+
[pid]: {
|
| 119 |
+
...proc,
|
| 120 |
+
status,
|
| 121 |
+
error: error !== undefined ? error : proc.error,
|
| 122 |
+
data: data !== undefined ? data : proc.data,
|
| 123 |
+
completedAt: status === 'success' || status === 'error' ? Date.now() : proc.completedAt
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
};
|
| 127 |
+
});
|
| 128 |
+
},
|
| 129 |
+
|
| 130 |
+
removeProcess: (pid: string) => {
|
| 131 |
+
set(state => {
|
| 132 |
+
const rest = { ...state.processes };
|
| 133 |
+
delete rest[pid];
|
| 134 |
+
return { processes: rest };
|
| 135 |
+
});
|
| 136 |
+
},
|
| 137 |
+
|
| 138 |
+
clearFinishedProcesses: () => {
|
| 139 |
+
set(state => {
|
| 140 |
+
const filtered: Record<string, OSProcess> = {};
|
| 141 |
+
Object.entries(state.processes).forEach(([pid, p]) => {
|
| 142 |
+
if (p.status === 'running') {
|
| 143 |
+
filtered[pid] = p;
|
| 144 |
+
}
|
| 145 |
+
});
|
| 146 |
+
return { processes: filtered };
|
| 147 |
+
});
|
| 148 |
+
},
|
| 149 |
+
|
| 150 |
+
// 1. Headless Sandbox Execution
|
| 151 |
+
handleRunSandbox: async (activeReview: ReviewItem | undefined, code: string) => {
|
| 152 |
+
if (!activeReview || !code.trim() || get().sandboxRunning) return;
|
| 153 |
+
|
| 154 |
+
const problem = activeReview.problems;
|
| 155 |
+
const catalogProb = findCatalogProblem(
|
| 156 |
+
problem?.problem_number,
|
| 157 |
+
problem?.id || '',
|
| 158 |
+
problem?.name
|
| 159 |
+
);
|
| 160 |
+
|
| 161 |
+
const rawExamples = problem?.examples && problem.examples.length > 0
|
| 162 |
+
? problem.examples
|
| 163 |
+
: catalogProb?.examples || [];
|
| 164 |
+
|
| 165 |
+
const formattedCases = rawExamples.map((ex) => {
|
| 166 |
+
if (typeof ex === 'string') return { input: ex, expected: '' };
|
| 167 |
+
return { input: ex?.input ?? '', expected: ex?.output ?? '' };
|
| 168 |
+
});
|
| 169 |
+
|
| 170 |
+
const starterCode = catalogProb?.starter_code || problem?.starter_code;
|
| 171 |
+
const problemName = problem?.name || catalogProb?.name || 'Problem';
|
| 172 |
+
|
| 173 |
+
const pid = get().registerProcess('sandbox-runner', `PyTest: ${problemName}`);
|
| 174 |
+
|
| 175 |
+
set({
|
| 176 |
+
sandboxRunning: true,
|
| 177 |
+
sandboxResults: null,
|
| 178 |
+
sandboxError: null,
|
| 179 |
+
savedRefSuccess: false
|
| 180 |
+
});
|
| 181 |
+
|
| 182 |
+
try {
|
| 183 |
+
const res = await runSandboxTests(code, formattedCases, 4.0, starterCode, problemName);
|
| 184 |
+
set({ sandboxResults: res });
|
| 185 |
+
get().updateProcessStatus(pid, 'success', null, res);
|
| 186 |
+
} catch (err: unknown) {
|
| 187 |
+
const msg = err instanceof Error ? err.message : 'Execution failed';
|
| 188 |
+
set({ sandboxError: msg });
|
| 189 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 190 |
+
} finally {
|
| 191 |
+
set({ sandboxRunning: false });
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
|
| 195 |
+
// 2. Headless Solution Persistence
|
| 196 |
+
handleSaveReference: async (
|
| 197 |
+
activeReview: ReviewItem | undefined,
|
| 198 |
+
code: string,
|
| 199 |
+
onSuccessUpdate?: (code: string, problemId?: string) => void
|
| 200 |
+
) => {
|
| 201 |
+
if (!activeReview || !code.trim() || get().savingReference) return;
|
| 202 |
+
const problem = activeReview.problems;
|
| 203 |
+
const rawProbId = problem?.id || activeReview.problem_id;
|
| 204 |
+
if (!rawProbId && !problem?.problem_number) return;
|
| 205 |
+
|
| 206 |
+
const probNum = problem?.problem_number ?? (
|
| 207 |
+
typeof activeReview.problem_id === 'number'
|
| 208 |
+
? activeReview.problem_id
|
| 209 |
+
: (/^\d+$/.test(activeReview.problem_id || '') ? parseInt(activeReview.problem_id, 10) : undefined)
|
| 210 |
+
);
|
| 211 |
+
|
| 212 |
+
const catalogProb = findCatalogProblem(
|
| 213 |
+
probNum,
|
| 214 |
+
rawProbId || activeReview.problem_id,
|
| 215 |
+
problem?.name
|
| 216 |
+
);
|
| 217 |
+
|
| 218 |
+
const rawConstraints = problem?.constraints ?? catalogProb?.constraints;
|
| 219 |
+
const formattedConstraints: string[] = Array.isArray(rawConstraints)
|
| 220 |
+
? (rawConstraints as string[])
|
| 221 |
+
: (rawConstraints ? [String(rawConstraints)] : []);
|
| 222 |
+
|
| 223 |
+
const rawExamples = (problem?.examples && problem.examples.length > 0)
|
| 224 |
+
? problem.examples
|
| 225 |
+
: catalogProb?.examples;
|
| 226 |
+
const formattedExamples = rawExamples
|
| 227 |
+
? rawExamples.map((ex: { input?: unknown; output?: unknown; explanation?: string } | string) =>
|
| 228 |
+
typeof ex === 'string'
|
| 229 |
+
? { input: ex, output: '' }
|
| 230 |
+
: { input: String(ex?.input ?? ''), output: String(ex?.output ?? ''), explanation: ex?.explanation }
|
| 231 |
+
)
|
| 232 |
+
: [];
|
| 233 |
+
|
| 234 |
+
const problemName = problem?.name || catalogProb?.name || 'Problem';
|
| 235 |
+
|
| 236 |
+
const metadata: SaveReferenceMetadata = {
|
| 237 |
+
problem_number: probNum ?? catalogProb?.problem_number,
|
| 238 |
+
problem_name: problemName,
|
| 239 |
+
pattern: problem?.pattern || catalogProb?.pattern,
|
| 240 |
+
difficulty: problem?.difficulty || catalogProb?.difficulty,
|
| 241 |
+
optimal_time: problem?.optimal_time || catalogProb?.time_complexity,
|
| 242 |
+
optimal_space: problem?.optimal_space || catalogProb?.space_complexity,
|
| 243 |
+
description: problem?.description || catalogProb?.description,
|
| 244 |
+
starter_code: catalogProb?.starter_code || problem?.starter_code,
|
| 245 |
+
examples: formattedExamples,
|
| 246 |
+
constraints: formattedConstraints,
|
| 247 |
+
};
|
| 248 |
+
|
| 249 |
+
const pid = get().registerProcess('sandbox-runner', `Save Ref: ${problemName}`);
|
| 250 |
+
|
| 251 |
+
set({ savingReference: true, saveRefError: null });
|
| 252 |
+
|
| 253 |
+
try {
|
| 254 |
+
const res = await saveReferenceSolution(rawProbId, code, metadata);
|
| 255 |
+
set({ savedRefSuccess: true });
|
| 256 |
+
get().updateProcessStatus(pid, 'success', null, res);
|
| 257 |
+
if (onSuccessUpdate) {
|
| 258 |
+
onSuccessUpdate(code, res.problem_id);
|
| 259 |
+
}
|
| 260 |
+
setTimeout(() => set({ savedRefSuccess: false }), 3500);
|
| 261 |
+
} catch (err: unknown) {
|
| 262 |
+
const msg = err instanceof Error ? err.message : 'Failed to save solution';
|
| 263 |
+
set({ saveRefError: msg });
|
| 264 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 265 |
+
} finally {
|
| 266 |
+
set({ savingReference: false });
|
| 267 |
+
}
|
| 268 |
+
},
|
| 269 |
+
|
| 270 |
+
resetSandbox: () => {
|
| 271 |
+
const s = get();
|
| 272 |
+
if (s.sandboxResults === null && s.sandboxError === null && !s.savedRefSuccess && s.saveRefError === null) {
|
| 273 |
+
return;
|
| 274 |
+
}
|
| 275 |
+
set({
|
| 276 |
+
sandboxResults: null,
|
| 277 |
+
sandboxError: null,
|
| 278 |
+
savedRefSuccess: false,
|
| 279 |
+
saveRefError: null
|
| 280 |
+
});
|
| 281 |
+
},
|
| 282 |
+
|
| 283 |
+
// 3. Headless AI Evaluation
|
| 284 |
+
handleAiEvaluation: async (activeReview: ReviewItem | undefined, code: string) => {
|
| 285 |
+
if (!activeReview || !code.trim() || get().aiLoading) return;
|
| 286 |
+
const problem = activeReview.problems;
|
| 287 |
+
const problemName = problem?.name || 'Problem';
|
| 288 |
+
|
| 289 |
+
const pid = get().registerProcess('ai-evaluator', `AI Review: ${problemName}`);
|
| 290 |
+
|
| 291 |
+
set({
|
| 292 |
+
aiLoading: true,
|
| 293 |
+
aiResult: null,
|
| 294 |
+
aiError: null
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
try {
|
| 298 |
+
const { data: { session } } = await supabase.auth.getSession();
|
| 299 |
+
const token = session ? session.access_token : 'sandbox';
|
| 300 |
+
|
| 301 |
+
const res = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/reviews/evaluate`, {
|
| 302 |
+
method: 'POST',
|
| 303 |
+
headers: {
|
| 304 |
+
'Content-Type': 'application/json',
|
| 305 |
+
'Authorization': `Bearer ${token}`
|
| 306 |
+
},
|
| 307 |
+
body: JSON.stringify({
|
| 308 |
+
problem_name: problem.name,
|
| 309 |
+
pattern: problem.pattern,
|
| 310 |
+
optimal_time: problem.optimal_time,
|
| 311 |
+
optimal_space: problem.optimal_space,
|
| 312 |
+
code: code
|
| 313 |
+
})
|
| 314 |
+
});
|
| 315 |
+
|
| 316 |
+
if (res.ok) {
|
| 317 |
+
const result: AiEvaluationResult = await res.json();
|
| 318 |
+
set({ aiResult: result });
|
| 319 |
+
get().updateProcessStatus(pid, 'success', null, result);
|
| 320 |
+
} else {
|
| 321 |
+
const errorData = await res.json().catch(() => ({}));
|
| 322 |
+
const msg = errorData.detail || 'Failed to analyze code.';
|
| 323 |
+
set({ aiError: msg });
|
| 324 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 325 |
+
}
|
| 326 |
+
} catch {
|
| 327 |
+
const msg = 'Connection to evaluation server failed.';
|
| 328 |
+
set({ aiError: msg });
|
| 329 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 330 |
+
} finally {
|
| 331 |
+
set({ aiLoading: false });
|
| 332 |
+
}
|
| 333 |
+
},
|
| 334 |
+
|
| 335 |
+
// 4. Headless AI Explanation
|
| 336 |
+
handleExplainCode: async (
|
| 337 |
+
activeReview: ReviewItem | undefined,
|
| 338 |
+
overrideCode?: string,
|
| 339 |
+
overridePattern?: string,
|
| 340 |
+
overrideTime?: string,
|
| 341 |
+
overrideSpace?: string
|
| 342 |
+
) => {
|
| 343 |
+
if (!activeReview || get().explainLoading) return;
|
| 344 |
+
const problem = activeReview.problems;
|
| 345 |
+
if (!problem) return;
|
| 346 |
+
|
| 347 |
+
const catalogProb = problem.problem_number
|
| 348 |
+
? getCatalogProblemByNumber(problem.problem_number)
|
| 349 |
+
: getCatalogProblemById(problem.id || '');
|
| 350 |
+
|
| 351 |
+
const refCode = overrideCode || problem.reference_code || catalogProb?.reference_solution;
|
| 352 |
+
if (!refCode) return;
|
| 353 |
+
|
| 354 |
+
const problemName = problem.name || 'Problem';
|
| 355 |
+
const pid = get().registerProcess('ai-explainer', `AI Explain: ${problemName}`);
|
| 356 |
+
|
| 357 |
+
set({
|
| 358 |
+
explainLoading: true,
|
| 359 |
+
explanationText: null,
|
| 360 |
+
explainError: null
|
| 361 |
+
});
|
| 362 |
+
|
| 363 |
+
try {
|
| 364 |
+
const { data: { session } } = await supabase.auth.getSession();
|
| 365 |
+
const token = session ? session.access_token : 'sandbox';
|
| 366 |
+
|
| 367 |
+
const res = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/reviews/explain`, {
|
| 368 |
+
method: 'POST',
|
| 369 |
+
headers: {
|
| 370 |
+
'Content-Type': 'application/json',
|
| 371 |
+
'Authorization': `Bearer ${token}`
|
| 372 |
+
},
|
| 373 |
+
body: JSON.stringify({
|
| 374 |
+
problem_number: problem.problem_number || catalogProb?.problem_number,
|
| 375 |
+
method: overridePattern || problem.pattern || catalogProb?.pattern,
|
| 376 |
+
code: refCode,
|
| 377 |
+
problem_name: problem.name,
|
| 378 |
+
optimal_time: overrideTime || problem.optimal_time || catalogProb?.time_complexity,
|
| 379 |
+
optimal_space: overrideSpace || problem.optimal_space || catalogProb?.space_complexity
|
| 380 |
+
})
|
| 381 |
+
});
|
| 382 |
+
|
| 383 |
+
if (res.ok) {
|
| 384 |
+
const result = await res.json();
|
| 385 |
+
set({ explanationText: result.explanation });
|
| 386 |
+
get().updateProcessStatus(pid, 'success', null, result);
|
| 387 |
+
} else {
|
| 388 |
+
const errorData = await res.json().catch(() => ({}));
|
| 389 |
+
const msg = errorData.detail || 'Failed to generate code explanation.';
|
| 390 |
+
set({ explainError: msg });
|
| 391 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 392 |
+
}
|
| 393 |
+
} catch {
|
| 394 |
+
const msg = 'Connection to explanation server failed.';
|
| 395 |
+
set({ explainError: msg });
|
| 396 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 397 |
+
} finally {
|
| 398 |
+
set({ explainLoading: false });
|
| 399 |
+
}
|
| 400 |
+
},
|
| 401 |
+
|
| 402 |
+
// 5. Headless AI Grimoire Solution
|
| 403 |
+
handleFetchAiSolution: async (
|
| 404 |
+
activeReview: ReviewItem | undefined,
|
| 405 |
+
onSolutionReceived?: (solution: string) => void
|
| 406 |
+
) => {
|
| 407 |
+
if (!activeReview || get().aiSolutionLoading) return;
|
| 408 |
+
const problem = activeReview.problems;
|
| 409 |
+
const problemId = problem?.id || activeReview.problem_id;
|
| 410 |
+
const catalogProb = problem?.problem_number
|
| 411 |
+
? getCatalogProblemByNumber(problem.problem_number)
|
| 412 |
+
: getCatalogProblemById(problem?.id || '');
|
| 413 |
+
|
| 414 |
+
const problemName = problem?.name || 'Problem';
|
| 415 |
+
const pid = get().registerProcess('ai-solution', `AI Grimoire: ${problemName}`);
|
| 416 |
+
|
| 417 |
+
set({
|
| 418 |
+
aiSolutionLoading: true,
|
| 419 |
+
aiSolutionError: null
|
| 420 |
+
});
|
| 421 |
+
|
| 422 |
+
try {
|
| 423 |
+
const res = await getOrGenerateAiSolution({
|
| 424 |
+
problemId,
|
| 425 |
+
problemNumber: problem?.problem_number || catalogProb?.problem_number,
|
| 426 |
+
problemName: problem?.name,
|
| 427 |
+
pattern: problem?.pattern || catalogProb?.pattern
|
| 428 |
+
});
|
| 429 |
+
if (res.solution && onSolutionReceived) {
|
| 430 |
+
onSolutionReceived(res.solution);
|
| 431 |
+
}
|
| 432 |
+
get().updateProcessStatus(pid, 'success', null, res);
|
| 433 |
+
} catch (err: unknown) {
|
| 434 |
+
const msg = err instanceof Error ? err.message : 'Failed to retrieve AI Grimoire solution';
|
| 435 |
+
set({ aiSolutionError: msg });
|
| 436 |
+
get().updateProcessStatus(pid, 'error', msg);
|
| 437 |
+
} finally {
|
| 438 |
+
set({ aiSolutionLoading: false });
|
| 439 |
+
}
|
| 440 |
+
},
|
| 441 |
+
|
| 442 |
+
resetAiState: () => {
|
| 443 |
+
const s = get();
|
| 444 |
+
if (s.aiResult === null && s.aiError === null && s.explanationText === null && s.explainError === null && s.aiSolutionError === null) {
|
| 445 |
+
return;
|
| 446 |
+
}
|
| 447 |
+
set({
|
| 448 |
+
aiResult: null,
|
| 449 |
+
aiError: null,
|
| 450 |
+
explanationText: null,
|
| 451 |
+
explainError: null,
|
| 452 |
+
aiSolutionError: null
|
| 453 |
+
});
|
| 454 |
+
},
|
| 455 |
+
|
| 456 |
+
// Computed queries
|
| 457 |
+
getActiveProcesses: () => {
|
| 458 |
+
return Object.values(get().processes).filter(p => p.status === 'running');
|
| 459 |
+
},
|
| 460 |
+
|
| 461 |
+
hasRunningProcesses: () => {
|
| 462 |
+
return Object.values(get().processes).some(p => p.status === 'running');
|
| 463 |
+
}
|
| 464 |
+
}));
|
algospaced-ui/src/types/osTypes.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type ProcessAppId =
|
| 2 |
+
| 'sandbox-runner'
|
| 3 |
+
| 'ai-evaluator'
|
| 4 |
+
| 'ai-explainer'
|
| 5 |
+
| 'ai-solution'
|
| 6 |
+
| 'drive-sync'
|
| 7 |
+
| 'github-sync';
|
| 8 |
+
|
| 9 |
+
export type ProcessStatus = 'idle' | 'running' | 'success' | 'error';
|
| 10 |
+
|
| 11 |
+
export interface OSProcess<T = unknown> {
|
| 12 |
+
pid: string;
|
| 13 |
+
appId: ProcessAppId;
|
| 14 |
+
title: string;
|
| 15 |
+
status: ProcessStatus;
|
| 16 |
+
startedAt: number;
|
| 17 |
+
completedAt?: number;
|
| 18 |
+
error?: string | null;
|
| 19 |
+
data?: T;
|
| 20 |
+
}
|