iamfebin commited on
Commit
aa1fcca
·
1 Parent(s): c7fe97e

feat: player economy, item catalog, vault inventory, and companion gifting

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. algospaced-ui/dist/assets/{Auth-Cvp48f3L.js → Auth-DE6tOdxt.js} +1 -1
  2. algospaced-ui/dist/assets/{CardManager-CkYQqEcX.js → CardManager-oo_VDg0z.js} +1 -1
  3. algospaced-ui/dist/assets/{CreateProblemForm-DvmR15Wo.js → CreateProblemForm-Btlo_Jzs.js} +1 -1
  4. algospaced-ui/dist/assets/{FileExplorer-DC0E1wW8.js → FileExplorer-DPdHXlvq.js} +1 -1
  5. algospaced-ui/dist/assets/GitHubSyncWindow-Bv5jA_W2.js +1 -0
  6. algospaced-ui/dist/assets/GitHubSyncWindow-Xyx5vxzj.js +0 -1
  7. algospaced-ui/dist/assets/{JourneyPath-S1uJQhTl.js → JourneyPath-DzueA_V1.js} +0 -0
  8. algospaced-ui/dist/assets/{KatexRenderer-CfYwRkzO.js → KatexRenderer-NjsEFKtT.js} +1 -1
  9. algospaced-ui/dist/assets/{MarkdownRenderer-AdFp0pUP.js → MarkdownRenderer-B_9j9AKs.js} +2 -2
  10. algospaced-ui/dist/assets/{MySQLPlayground-NRQBboPp.js → MySQLPlayground-C32Btviu.js} +1 -1
  11. algospaced-ui/dist/assets/PrincessChamber-CS-4OU0n.js +1 -0
  12. algospaced-ui/dist/assets/PrincessChamber-DvQR6sQH.js +0 -1
  13. algospaced-ui/dist/assets/ProblemSpecPanel-0WaGunPO.js +4 -0
  14. algospaced-ui/dist/assets/ProblemSpecPanel-clZ38uEk.js +0 -4
  15. algospaced-ui/dist/assets/{PythonChallenge-DwlCVZ7-.js → PythonChallenge-CiLYD15D.js} +1 -1
  16. algospaced-ui/dist/assets/ReviewQueue-15B52jqH.js +5 -0
  17. algospaced-ui/dist/assets/ReviewQueue-CSzueRL_.js +0 -5
  18. algospaced-ui/dist/assets/{Settings-HgPu-LnK.js → Settings-Brys5us-.js} +1 -1
  19. algospaced-ui/dist/assets/StoreWindow-CdHQWIUq.js +1 -0
  20. algospaced-ui/dist/assets/{TerminalEmulator-o-sZq1iI.js → TerminalEmulator-B-cgsIHL.js} +1 -1
  21. algospaced-ui/dist/assets/{index-DX2cztXb.js → index-B53AvSbH.js} +0 -0
  22. algospaced-ui/dist/assets/index-BdFdjNzp.css +0 -0
  23. algospaced-ui/dist/assets/index-DeC1PAqp.css +0 -0
  24. algospaced-ui/dist/assets/{vendor-react-CDF1pnIM.js → vendor-react-oIjZMgNV.js} +0 -0
  25. algospaced-ui/dist/index.html +3 -3
  26. algospaced-ui/dist/sw.js +1 -1
  27. algospaced-ui/package.json +1 -1
  28. algospaced-ui/src/App.tsx +67 -1
  29. algospaced-ui/src/components/desktop/DesktopGadget.tsx +23 -6
  30. algospaced-ui/src/components/desktop/DesktopStartMenu.tsx +11 -3
  31. algospaced-ui/src/components/desktop/DesktopTaskbar.tsx +1 -0
  32. algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx +35 -0
  33. algospaced-ui/src/components/desktop/MobileMetroScreen.tsx +13 -0
  34. algospaced-ui/src/components/store/GiftPresentationModal.tsx +116 -0
  35. algospaced-ui/src/components/store/ItemIcon.tsx +52 -0
  36. algospaced-ui/src/components/store/ItemLoreModal.tsx +191 -0
  37. algospaced-ui/src/components/store/StoreItemCard.tsx +105 -0
  38. algospaced-ui/src/components/store/StoreWindow.tsx +521 -0
  39. algospaced-ui/src/components/store/VaultItemCard.tsx +150 -0
  40. algospaced-ui/src/components/store/giftReactions.ts +45 -0
  41. algospaced-ui/src/data/storeCatalog.ts +183 -0
  42. algospaced-ui/src/features/companion/store/useCompanionStore.ts +150 -5
  43. algospaced-ui/src/features/companion/types.ts +15 -0
  44. algospaced-ui/src/hooks/useReviewQueue.ts +5 -0
  45. algospaced-ui/src/hooks/useWallpaper.ts +26 -1
  46. algospaced-ui/src/services/storeService.ts +653 -0
  47. algospaced-ui/src/stores/useEconomyStore.ts +363 -0
  48. algospaced-ui/src/stores/useOSStore.ts +1 -0
  49. algospaced-ui/src/types/storeTypes.ts +94 -0
  50. algospaced-ui/src/types/windowTypes.ts +2 -1
algospaced-ui/dist/assets/{Auth-Cvp48f3L.js → Auth-DE6tOdxt.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Et as t,S as n,U as r,V as i,Vt as a,a as o,bt as s,j as c,q as l,zt as u}from"./vendor-react-CDF1pnIM.js";import{t as d}from"./firebaseClient-DZobvwSx.js";var f=e(a(),1),p=u();function m(){let[e,a]=(0,f.useState)(!1),[u,m]=(0,f.useState)(``),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),T=h.length>=8,E=/[A-Z]/.test(h),D=/[a-z]/.test(h),O=/[0-9]/.test(h),k=/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(h),A=h.length>0&&h===_,j=T&&E&&D&&O&&k;return(0,p.jsxs)(`div`,{className:`fixed inset-0 w-full h-full max-h-[100dvh] overflow-y-auto overscroll-contain custom-scrollbar flex flex-col items-center px-3 pt-3 pb-8 sm:px-4 sm:py-6 md:p-8 relative isolate selection:bg-highlight-pink selection:text-white`,children:[(0,p.jsx)(`div`,{className:`fixed inset-0 w-full h-full bg-cover bg-center z-0 saturate-150 contrast-125 pointer-events-none`,style:{backgroundImage:`url('/wallpapers/default.webp')`}}),(0,p.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black window-shadow z-10 flex flex-col overflow-hidden shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] relative my-auto shrink-0`,children:[(0,p.jsx)(`div`,{className:`bg-[#0ea5e9] border-b-[4px] border-ink-black px-3 sm:px-4 py-2 sm:py-2.5 flex justify-between items-center text-ink-black select-none`,children:(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined select-none text-base sm:text-xl`,style:{fontVariationSettings:`'FILL' 1`},children:`sports_esports`}),(0,p.jsx)(`span`,{className:`font-window-title text-xs sm:text-base font-bold tracking-wide`,children:`System_Setup.exe`})]})}),(0,p.jsxs)(`div`,{className:`p-4 sm:p-6 bg-[#fdf8e1] flex-1 flex flex-col`,children:[typeof window<`u`&&window.self!==window.top&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-5 p-3 sm:p-3.5 border-[3px] border-[#ea580c] bg-[#ffedd5] text-[#9a3412] text-xs font-bold font-arcade leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[`⚠️ RUNNING INSIDE IFRAME`,(0,p.jsx)(`p`,{className:`mt-1 font-sans text-[11px] font-normal text-ink-black normal-case leading-normal`,children:`If Google Sign-In popup is restricted inside Hugging Face wrapper, open the standalone link below:`}),(0,p.jsx)(`a`,{href:`https://iamfebin-algospaced-dsa.hf.space/`,target:`_top`,className:`mt-2.5 inline-block w-full text-center bg-[#ea580c] hover:bg-[#c2410c] text-white border-[2.5px] border-ink-black py-1.5 px-3 rounded-lg font-window-title text-xs font-bold transition-all shadow-[1.5px_1.5px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`OPEN FULLSCREEN / DIRECT SITE`})]}),(0,p.jsxs)(`div`,{className:`flex flex-col items-center mb-4 sm:mb-6`,children:[(0,p.jsx)(`div`,{className:`w-12 h-12 sm:w-16 sm:h-16 bg-paper-white border-[3px] border-ink-black flex items-center justify-center gadget-shadow shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] mb-2.5 sm:mb-4`,children:(0,p.jsx)(n,{className:`w-7 h-7 sm:w-9 sm:h-9 text-primary`})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold tracking-tight text-ink-black font-headline-md leading-none m-0`,children:`AlgoSpaced`}),(0,p.jsx)(`span`,{className:`text-[9px] sm:text-[10px] font-arcade bg-[#facc15] text-ink-black font-extrabold px-1.5 sm:px-2 py-0.5 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] uppercase rotate-[-3deg]`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`text-[10px] sm:text-xs font-arcade text-trash-gray mt-1.5 sm:mt-2 tracking-wide uppercase text-center`,children:`Spaced Repetition for DSA`})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 mb-4 sm:mb-6 font-arcade text-[9px] sm:text-[10px]`,children:[(0,p.jsx)(`button`,{onClick:()=>{a(!1),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-white text-slate-700 hover:bg-surface-container`:`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`}`,children:`SIGN IN`}),(0,p.jsx)(`button`,{onClick:()=>{a(!0),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`:`bg-white text-slate-700 hover:bg-surface-container`}`,children:`CREATE ACCOUNT`})]}),C&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-6 p-3 sm:p-4 border-[3px] border-ink-black text-xs font-arcade leading-relaxed ${C.type===`error`?`bg-red-100 border-red-500 text-error shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:C.type===`unverified`?`bg-amber-100 border-amber-500 text-amber-900 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-emerald-100 border-emerald-500 text-emerald-700 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}`,children:[(0,p.jsx)(`p`,{children:C.text}),C.type===`unverified`&&(0,p.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!u.trim()||!h){w({type:`error`,text:`Please enter your email and password above to resend the verification link.`});return}try{S(!0),await d.resendVerificationEmail(u.trim(),h),w({type:`success`,text:`Verification email resent to ${u.trim()}! Please check your inbox and spam folder.`})}catch(e){w({type:`error`,text:e.message||`Failed to resend verification email. Check your credentials.`})}finally{S(!1)}},disabled:x,className:`mt-3 w-full bg-amber-500 hover:bg-amber-600 text-white font-window-title text-xs font-bold py-2 px-3 border-[2px] border-ink-black rounded flex items-center justify-center gap-2 cursor-pointer shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none uppercase disabled:opacity-50`,children:[(0,p.jsx)(c,{className:`w-3.5 h-3.5 ${x?`animate-spin`:``}`}),x?`SENDING LINK...`:`RESEND VERIFICATION EMAIL`]})]}),(0,p.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),b(!0),w(null);let n=u.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){w({type:`error`,text:`Please enter a valid email address.`}),b(!1);return}if(e){if(!j){w({type:`error`,text:`Password does not meet the security criteria. Please check the requirements below.`}),b(!1);return}if(h!==_){w({type:`error`,text:`Passwords do not match. Please re-enter.`}),b(!1);return}try{await d.signUpWithEmail(n,h),w({type:`success`,text:`Registration successful! A verification link has been sent to your email. Please verify your email before logging in.`}),a(!1),g(``),v(``)}catch(e){let t=e,n=t.message||`An error occurred during registration.`;t.code===`auth/email-already-in-use`?n=`This email address is already registered. Please sign in instead.`:t.code===`auth/invalid-email`?n=`The email address format is invalid.`:t.code===`auth/weak-password`&&(n=`Firebase requires a stronger password.`),w({type:`error`,text:n})}finally{b(!1)}}else try{await d.signInWithEmail(n,h)}catch(e){let t=e;if(t.code===`auth/email-not-verified`)w({type:`unverified`,text:`Your email address is not verified yet. Please check your inbox for the activation link.`});else{let e=t.message||`An error occurred during sign in.`;t.code===`auth/invalid-credential`||t.code===`auth/user-not-found`||t.code===`auth/wrong-password`?e=`Invalid email or password. Please check your credentials.`:t.code===`auth/too-many-requests`&&(e=`Access temporarily locked due to many failed attempts. Try again later or reset password.`),w({type:`error`,text:e})}}finally{b(!1)}},className:`space-y-3 sm:space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-email`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Email Address`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(i,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-email`,type:`email`,required:!0,value:u,onChange:e=>m(e.target.value),placeholder:`name@arcade.com`,"aria-label":`Email Address`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(r,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-password`,type:`password`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`••••••••`,"aria-label":`Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-confirm-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Confirm Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(l,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-confirm-password`,type:`password`,required:!0,value:_,onChange:e=>v(e.target.value),placeholder:`••••••••`,"aria-label":`Confirm Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{className:`p-2.5 sm:p-3 bg-white border-[2px] border-ink-black rounded-lg text-[9px] sm:text-[10px] font-code-mono space-y-1 shadow-[inset_1px_1px_0px_rgba(0,0,0,0.05)]`,children:[(0,p.jsx)(`div`,{className:`font-bold font-arcade uppercase text-[8px] sm:text-[9px] text-trash-gray mb-1 sm:mb-1.5`,children:`Password Security Requirements:`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${T?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[T?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(o,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Minimum 8 characters`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${E&&D?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[E&&D?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(o,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Uppercase & lowercase letters (A-Z, a-z)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[O?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(o,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 number (0-9)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${k?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[k?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(o,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 special character (!@#$%^&*...)`})]}),_.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${A?`text-emerald-700 font-bold`:`text-red-600 font-bold`}`,children:[A?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(o,{className:`w-3 h-3 text-red-500 shrink-0 stroke-[3]`}),(0,p.jsx)(`span`,{children:A?`Passwords match`:`Passwords do not match`})]})]})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:y||e&&(!j||!A),className:`w-full bg-[#ffcc00] hover:bg-yellow-400 border-[3px] sm:border-[4px] border-ink-black rounded-xl py-2.5 sm:py-3.5 font-window-title text-sm sm:text-base text-ink-black arcade-btn cursor-pointer disabled:opacity-50 flex items-center justify-center gap-2 uppercase font-bold tracking-wide transition-all shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[y?`PROCESSING...`:e?`CREATE ACCOUNT`:`SIGN IN`,!y&&(0,p.jsx)(t,{className:`w-4 h-4 stroke-[3px]`})]})]}),(0,p.jsxs)(`div`,{className:`relative my-3.5 sm:my-5 select-none`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,p.jsx)(`div`,{className:`w-full border-t-[3px] border-ink-black border-dashed`})}),(0,p.jsx)(`div`,{className:`relative flex justify-center text-[9px] sm:text-[10px] uppercase font-arcade`,children:(0,p.jsx)(`span`,{className:`bg-[#fdf8e1] px-2 sm:px-3 text-trash-gray font-bold`,children:`OR CONTINUE WITH`})})]}),(0,p.jsxs)(`button`,{onClick:async()=>{try{b(!0),w(null),await d.signInWithGoogle()}catch(e){w({type:`error`,text:e.message||`Google Sign-In failed to initialize`}),b(!1)}},disabled:y,className:`w-full bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold py-2.5 sm:py-3 px-3 sm:px-4 rounded-xl flex items-center justify-center gap-2.5 sm:gap-3 transition-all text-[11px] sm:text-xs cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[(0,p.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,p.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,p.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,p.jsx)(`path`,{d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z`,fill:`#FBBC05`}),(0,p.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z`,fill:`#EA4335`})]}),`SIGN IN WITH GOOGLE`]}),(0,p.jsxs)(`button`,{onClick:()=>{d.enterSandbox()},disabled:y,className:`mt-2.5 sm:mt-3 w-full bg-[#10b981] hover:bg-emerald-600 text-white font-window-title py-2.5 sm:py-3 px-3 sm:px-4 border-[3px] border-ink-black rounded-xl flex items-center justify-center gap-2 cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none uppercase font-bold text-[11px] sm:text-xs`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined text-sm font-bold`,children:`sports_esports`}),`Enter Sandbox Mode (No Login)`]})]})]})]})}export{m as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,E as n,F as r,Mt as i,Qt as a,Rt as o,Xt as s,Y as c,o as l,q as u}from"./vendor-react-oIjZMgNV.js";import{t as d}from"./firebaseClient-DZobvwSx.js";var f=e(a(),1),p=s();function m(){let[e,a]=(0,f.useState)(!1),[s,m]=(0,f.useState)(``),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),T=h.length>=8,E=/[A-Z]/.test(h),D=/[a-z]/.test(h),O=/[0-9]/.test(h),k=/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(h),A=h.length>0&&h===_,j=T&&E&&D&&O&&k;return(0,p.jsxs)(`div`,{className:`fixed inset-0 w-full h-full max-h-[100dvh] overflow-y-auto overscroll-contain custom-scrollbar flex flex-col items-center px-3 pt-3 pb-8 sm:px-4 sm:py-6 md:p-8 relative isolate selection:bg-highlight-pink selection:text-white`,children:[(0,p.jsx)(`div`,{className:`fixed inset-0 w-full h-full bg-cover bg-center z-0 saturate-150 contrast-125 pointer-events-none`,style:{backgroundImage:`url('/wallpapers/default.webp')`}}),(0,p.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black window-shadow z-10 flex flex-col overflow-hidden shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] relative my-auto shrink-0`,children:[(0,p.jsx)(`div`,{className:`bg-[#0ea5e9] border-b-[4px] border-ink-black px-3 sm:px-4 py-2 sm:py-2.5 flex justify-between items-center text-ink-black select-none`,children:(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined select-none text-base sm:text-xl`,style:{fontVariationSettings:`'FILL' 1`},children:`sports_esports`}),(0,p.jsx)(`span`,{className:`font-window-title text-xs sm:text-base font-bold tracking-wide`,children:`System_Setup.exe`})]})}),(0,p.jsxs)(`div`,{className:`p-4 sm:p-6 bg-[#fdf8e1] flex-1 flex flex-col`,children:[typeof window<`u`&&window.self!==window.top&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-5 p-3 sm:p-3.5 border-[3px] border-[#ea580c] bg-[#ffedd5] text-[#9a3412] text-xs font-bold font-arcade leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[`⚠️ RUNNING INSIDE IFRAME`,(0,p.jsx)(`p`,{className:`mt-1 font-sans text-[11px] font-normal text-ink-black normal-case leading-normal`,children:`If Google Sign-In popup is restricted inside Hugging Face wrapper, open the standalone link below:`}),(0,p.jsx)(`a`,{href:`https://iamfebin-algospaced-dsa.hf.space/`,target:`_top`,className:`mt-2.5 inline-block w-full text-center bg-[#ea580c] hover:bg-[#c2410c] text-white border-[2.5px] border-ink-black py-1.5 px-3 rounded-lg font-window-title text-xs font-bold transition-all shadow-[1.5px_1.5px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`OPEN FULLSCREEN / DIRECT SITE`})]}),(0,p.jsxs)(`div`,{className:`flex flex-col items-center mb-4 sm:mb-6`,children:[(0,p.jsx)(`div`,{className:`w-12 h-12 sm:w-16 sm:h-16 bg-paper-white border-[3px] border-ink-black flex items-center justify-center gadget-shadow shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] mb-2.5 sm:mb-4`,children:(0,p.jsx)(n,{className:`w-7 h-7 sm:w-9 sm:h-9 text-primary`})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold tracking-tight text-ink-black font-headline-md leading-none m-0`,children:`AlgoSpaced`}),(0,p.jsx)(`span`,{className:`text-[9px] sm:text-[10px] font-arcade bg-[#facc15] text-ink-black font-extrabold px-1.5 sm:px-2 py-0.5 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] uppercase rotate-[-3deg]`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`text-[10px] sm:text-xs font-arcade text-trash-gray mt-1.5 sm:mt-2 tracking-wide uppercase text-center`,children:`Spaced Repetition for DSA`})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 mb-4 sm:mb-6 font-arcade text-[9px] sm:text-[10px]`,children:[(0,p.jsx)(`button`,{onClick:()=>{a(!1),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-white text-slate-700 hover:bg-surface-container`:`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`}`,children:`SIGN IN`}),(0,p.jsx)(`button`,{onClick:()=>{a(!0),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`:`bg-white text-slate-700 hover:bg-surface-container`}`,children:`CREATE ACCOUNT`})]}),C&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-6 p-3 sm:p-4 border-[3px] border-ink-black text-xs font-arcade leading-relaxed ${C.type===`error`?`bg-red-100 border-red-500 text-error shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:C.type===`unverified`?`bg-amber-100 border-amber-500 text-amber-900 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-emerald-100 border-emerald-500 text-emerald-700 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}`,children:[(0,p.jsx)(`p`,{children:C.text}),C.type===`unverified`&&(0,p.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!s.trim()||!h){w({type:`error`,text:`Please enter your email and password above to resend the verification link.`});return}try{S(!0),await d.resendVerificationEmail(s.trim(),h),w({type:`success`,text:`Verification email resent to ${s.trim()}! Please check your inbox and spam folder.`})}catch(e){w({type:`error`,text:e.message||`Failed to resend verification email. Check your credentials.`})}finally{S(!1)}},disabled:x,className:`mt-3 w-full bg-amber-500 hover:bg-amber-600 text-white font-window-title text-xs font-bold py-2 px-3 border-[2px] border-ink-black rounded flex items-center justify-center gap-2 cursor-pointer shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none uppercase disabled:opacity-50`,children:[(0,p.jsx)(r,{className:`w-3.5 h-3.5 ${x?`animate-spin`:``}`}),x?`SENDING LINK...`:`RESEND VERIFICATION EMAIL`]})]}),(0,p.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),b(!0),w(null);let n=s.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){w({type:`error`,text:`Please enter a valid email address.`}),b(!1);return}if(e){if(!j){w({type:`error`,text:`Password does not meet the security criteria. Please check the requirements below.`}),b(!1);return}if(h!==_){w({type:`error`,text:`Passwords do not match. Please re-enter.`}),b(!1);return}try{await d.signUpWithEmail(n,h),w({type:`success`,text:`Registration successful! A verification link has been sent to your email. Please verify your email before logging in.`}),a(!1),g(``),v(``)}catch(e){let t=e,n=t.message||`An error occurred during registration.`;t.code===`auth/email-already-in-use`?n=`This email address is already registered. Please sign in instead.`:t.code===`auth/invalid-email`?n=`The email address format is invalid.`:t.code===`auth/weak-password`&&(n=`Firebase requires a stronger password.`),w({type:`error`,text:n})}finally{b(!1)}}else try{await d.signInWithEmail(n,h)}catch(e){let t=e;if(t.code===`auth/email-not-verified`)w({type:`unverified`,text:`Your email address is not verified yet. Please check your inbox for the activation link.`});else{let e=t.message||`An error occurred during sign in.`;t.code===`auth/invalid-credential`||t.code===`auth/user-not-found`||t.code===`auth/wrong-password`?e=`Invalid email or password. Please check your credentials.`:t.code===`auth/too-many-requests`&&(e=`Access temporarily locked due to many failed attempts. Try again later or reset password.`),w({type:`error`,text:e})}}finally{b(!1)}},className:`space-y-3 sm:space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-email`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Email Address`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-email`,type:`email`,required:!0,value:s,onChange:e=>m(e.target.value),placeholder:`name@arcade.com`,"aria-label":`Email Address`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(c,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-password`,type:`password`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`••••••••`,"aria-label":`Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-confirm-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Confirm Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(t,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-confirm-password`,type:`password`,required:!0,value:_,onChange:e=>v(e.target.value),placeholder:`••••••••`,"aria-label":`Confirm Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{className:`p-2.5 sm:p-3 bg-white border-[2px] border-ink-black rounded-lg text-[9px] sm:text-[10px] font-code-mono space-y-1 shadow-[inset_1px_1px_0px_rgba(0,0,0,0.05)]`,children:[(0,p.jsx)(`div`,{className:`font-bold font-arcade uppercase text-[8px] sm:text-[9px] text-trash-gray mb-1 sm:mb-1.5`,children:`Password Security Requirements:`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${T?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[T?(0,p.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(l,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Minimum 8 characters`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${E&&D?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[E&&D?(0,p.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(l,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Uppercase & lowercase letters (A-Z, a-z)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[O?(0,p.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(l,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 number (0-9)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${k?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[k?(0,p.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(l,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 special character (!@#$%^&*...)`})]}),_.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${A?`text-emerald-700 font-bold`:`text-red-600 font-bold`}`,children:[A?(0,p.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(l,{className:`w-3 h-3 text-red-500 shrink-0 stroke-[3]`}),(0,p.jsx)(`span`,{children:A?`Passwords match`:`Passwords do not match`})]})]})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:y||e&&(!j||!A),className:`w-full bg-[#ffcc00] hover:bg-yellow-400 border-[3px] sm:border-[4px] border-ink-black rounded-xl py-2.5 sm:py-3.5 font-window-title text-sm sm:text-base text-ink-black arcade-btn cursor-pointer disabled:opacity-50 flex items-center justify-center gap-2 uppercase font-bold tracking-wide transition-all shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[y?`PROCESSING...`:e?`CREATE ACCOUNT`:`SIGN IN`,!y&&(0,p.jsx)(o,{className:`w-4 h-4 stroke-[3px]`})]})]}),(0,p.jsxs)(`div`,{className:`relative my-3.5 sm:my-5 select-none`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,p.jsx)(`div`,{className:`w-full border-t-[3px] border-ink-black border-dashed`})}),(0,p.jsx)(`div`,{className:`relative flex justify-center text-[9px] sm:text-[10px] uppercase font-arcade`,children:(0,p.jsx)(`span`,{className:`bg-[#fdf8e1] px-2 sm:px-3 text-trash-gray font-bold`,children:`OR CONTINUE WITH`})})]}),(0,p.jsxs)(`button`,{onClick:async()=>{try{b(!0),w(null),await d.signInWithGoogle()}catch(e){w({type:`error`,text:e.message||`Google Sign-In failed to initialize`}),b(!1)}},disabled:y,className:`w-full bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold py-2.5 sm:py-3 px-3 sm:px-4 rounded-xl flex items-center justify-center gap-2.5 sm:gap-3 transition-all text-[11px] sm:text-xs cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[(0,p.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,p.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,p.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,p.jsx)(`path`,{d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z`,fill:`#FBBC05`}),(0,p.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z`,fill:`#EA4335`})]}),`SIGN IN WITH GOOGLE`]}),(0,p.jsxs)(`button`,{onClick:()=>{d.enterSandbox()},disabled:y,className:`mt-2.5 sm:mt-3 w-full bg-[#10b981] hover:bg-emerald-600 text-white font-window-title py-2.5 sm:py-3 px-3 sm:px-4 border-[3px] border-ink-black rounded-xl flex items-center justify-center gap-2 cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none uppercase font-bold text-[11px] sm:text-xs`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined text-sm font-bold`,children:`sports_esports`}),`Enter Sandbox Mode (No Login)`]})]})]})]})}export{m as default};
algospaced-ui/dist/assets/{CardManager-CkYQqEcX.js → CardManager-oo_VDg0z.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{G as t,J as n,N as r,Tt as i,Vt as a,Z as o,_ as s,b as c,bt as l,f as u,ft as ee,i as te,it as ne,j as re,k as d,m as ie,v as ae,w as oe,y as se,zt as ce}from"./vendor-react-CDF1pnIM.js";import{s as f}from"./firebaseClient-DZobvwSx.js";import{i as le,l as p}from"./index-DX2cztXb.js";var m=e(a(),1);async function h(){try{let{data:{session:e}}=await f.auth.getSession();return e?e.access_token:`sandbox`}catch{return`sandbox`}}function g(e){return e.toLowerCase().replace(/\s*-\s*method.*$/i,``).replace(/[^a-z0-9]+/g,``)}function _(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return}return e??void 0}async function ue(){let e=await h(),t=le(),n=[];try{let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e}`}});t.ok&&(n=await t.json())}catch{n=[]}let r=new Map,i=new Map,a=new Set;for(let e of n)e.problem_number!==void 0&&e.problem_number!==null&&r.set(e.problem_number,e),i.set(g(e.name),e);let o=new Date,s=[];for(let e of t){let t=r.get(e.problem_number)||i.get(g(e.name));if(t){a.add(t.id);let n=t.next_review!==null&&t.next_review!==void 0||t.fsrs_state!==null&&t.fsrs_state!==void 0,r=t.next_review?new Date(t.next_review):null,i=n&&r!==null?r<=o:!1,c=_(t.solutions),l=_(t.examples),u=_(t.constraints);s.push({id:t.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:t.description||e.description,reference_code:t.reference_code||e.reference_solution,starter_code:t.starter_code||e.starter_code,optimal_time:t.optimal_time||e.time_complexity,optimal_space:t.optimal_space||e.space_complexity,how_to_solve:t.how_to_solve||``,examples:l&&(!Array.isArray(l)||l.length>0)?l:e.examples,constraints:u&&(!Array.isArray(u)||u.length>0)?u:e.constraints,solutions:c,leetcode_url:e.leetcode_url,is_enrolled:n,is_custom:!1,fsrs_state:t.fsrs_state??(n?0:null),fsrs_step:t.fsrs_step??0,fsrs_stability:t.fsrs_stability??0,fsrs_difficulty:t.fsrs_difficulty??0,fsrs_elapsed_days:t.fsrs_elapsed_days??0,fsrs_scheduled_days:t.fsrs_scheduled_days??0,fsrs_reps:t.fsrs_reps??0,fsrs_lapses:t.fsrs_lapses??0,next_review:t.next_review??null,last_reviewed:t.last_reviewed??null,times_correct:t.times_correct??0,total_attempts:t.total_attempts??0,is_due:i,catalogProblem:e})}else s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:e.description,reference_code:e.reference_solution,starter_code:e.starter_code,optimal_time:e.time_complexity,optimal_space:e.space_complexity,how_to_solve:``,examples:e.examples,constraints:e.constraints,leetcode_url:e.leetcode_url,is_enrolled:!1,is_custom:!1,fsrs_state:null,fsrs_step:0,fsrs_stability:0,fsrs_difficulty:0,fsrs_elapsed_days:0,fsrs_scheduled_days:0,fsrs_reps:0,fsrs_lapses:0,next_review:null,last_reviewed:null,times_correct:0,total_attempts:0,is_due:!1,catalogProblem:e})}for(let e of n)if(!a.has(e.id)){let t=e.next_review!==null&&e.next_review!==void 0||e.fsrs_state!==null&&e.fsrs_state!==void 0,n=e.next_review?new Date(e.next_review):null,r=t&&n!==null?n<=o:!1,i=_(e.solutions),a=_(e.examples)||[],c=_(e.constraints)||[];s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern||`General`,difficulty:e.difficulty||`Medium`,description:e.description||``,reference_code:e.reference_code||``,starter_code:e.starter_code||``,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,how_to_solve:e.how_to_solve||``,examples:a,constraints:c,solutions:i,is_enrolled:t,is_custom:!0,fsrs_state:e.fsrs_state??(t?0:null),fsrs_step:e.fsrs_step??0,fsrs_stability:e.fsrs_stability??0,fsrs_difficulty:e.fsrs_difficulty??0,fsrs_elapsed_days:e.fsrs_elapsed_days??0,fsrs_scheduled_days:e.fsrs_scheduled_days??0,fsrs_reps:e.fsrs_reps??0,fsrs_lapses:e.fsrs_lapses??0,next_review:e.next_review??null,last_reviewed:e.last_reviewed??null,times_correct:e.times_correct??0,total_attempts:e.total_attempts??0,is_due:r})}return s}async function v(e){if(e.length===0)return!0;let t=await h(),n=await fetch(`/api/reviews/reset`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({problem_ids:e})});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to reset reviews`}));throw Error(e.detail||`Failed to reset reviews`)}return!0}async function y(e){let t=await h(),n=await fetch(`/api/explorer/problems/${e}`,{method:`DELETE`,headers:{Authorization:`Bearer ${t}`}});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to delete problem`}));throw Error(e.detail||`Failed to delete problem`)}return!0}async function de(e){let t=0;for(let n of e)try{await y(n),t++}catch{}return t}async function b(e){return e.length===0?0:(await p(e)).enrolled_count}var x=ce();function S({onOpenQueue:e,onOpenCreateProblem:a,onOpenEditProblem:ce,onSelectProblemForReview:f,refreshTrigger:le,onRefreshExplorer:p}){let[h,g]=(0,m.useState)([]),[_,S]=(0,m.useState)(!0),[fe,C]=(0,m.useState)(null),[w,pe]=(0,m.useState)(``),[T,E]=(0,m.useState)(`all`),[D,me]=(0,m.useState)(`ALL`),[O,he]=(0,m.useState)(`ALL`),[k,ge]=(0,m.useState)(`number`),[A,j]=(0,m.useState)(`asc`),[M,N]=(0,m.useState)(new Set),[P,F]=(0,m.useState)(null),[I,L]=(0,m.useState)(`front`),[R,z]=(0,m.useState)(!1),[B,V]=(0,m.useState)(!1),[H,U]=(0,m.useState)(null),[W,G]=(0,m.useState)(`table`),K=(0,m.useCallback)(async()=>{S(!0),C(null);try{let e=await ue();g(e),e.length>0&&!P&&F(e[0].id)}catch(e){let t=e instanceof Error?e.message:`Failed to load card database`;C(t)}finally{S(!1)}},[P]);(0,m.useEffect)(()=>{K()},[K,le]);let q=(0,m.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0,a=0;for(let o of h)if(o.is_enrolled){t++,o.is_due&&e++;let n=o.fsrs_state??0;n===1?r++:n===2?i++:n===3&&a++}else n++;return{total:h.length,due:e,enrolled:t,newCards:n,learning:r,reviewing:i,relearning:a}},[h]),_e=(0,m.useMemo)(()=>{let e=new Map;for(let t of h)e.set(t.pattern,(e.get(t.pattern)||0)+1);let t=Array.from(e.entries()).map(([e,t])=>({pattern:e,count:t}));return t.sort((e,t)=>e.pattern.localeCompare(t.pattern)),t},[h]),ve=(0,m.useMemo)(()=>{let e=w.trim().toLowerCase();return h.filter(t=>{if(T===`due`&&!t.is_due||T===`enrolled`&&!t.is_enrolled||T===`new`&&t.is_enrolled||T===`learning`&&(!t.is_enrolled||t.fsrs_state!==1)||T===`reviewing`&&(!t.is_enrolled||t.fsrs_state!==2)||T===`relearning`&&(!t.is_enrolled||t.fsrs_state!==3)||D!==`ALL`&&t.pattern!==D||O!==`ALL`&&t.difficulty!==O)return!1;if(e){let n=t.problem_number?String(t.problem_number).includes(e):!1,r=t.name.toLowerCase().includes(e),i=t.pattern.toLowerCase().includes(e),a=t.difficulty.toLowerCase().includes(e);if(!n&&!r&&!i&&!a)return!1}return!0})},[h,T,D,O,w]),J=(0,m.useMemo)(()=>{let e=[...ve];return e.sort((e,t)=>{let n=0;switch(k){case`number`:n=(e.problem_number??999999)-(t.problem_number??999999);break;case`name`:n=e.name.localeCompare(t.name);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`difficulty`:{let r={Easy:1,Medium:2,Hard:3};n=(r[e.difficulty]||2)-(r[t.difficulty]||2);break}case`state`:n=(e.fsrs_state??-1)-(t.fsrs_state??-1);break;case`due`:n=(e.next_review?new Date(e.next_review).getTime():9999999999999)-(t.next_review?new Date(t.next_review).getTime():9999999999999);break;case`retention`:n=(e.total_attempts>0?e.times_correct/e.total_attempts:0)-(t.total_attempts>0?t.times_correct/t.total_attempts:0)}return A===`asc`?n:-n}),e},[ve,k,A]),Y=(0,m.useMemo)(()=>!P&&J.length>0?J[0]:h.find(e=>e.id===P)||J[0]||null,[h,P,J]),X=e=>{k===e?j(e=>e===`asc`?`desc`:`asc`):(ge(e),j(`asc`))},ye=(e,t)=>{t.stopPropagation(),N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},be=(0,m.useMemo)(()=>J.length>0&&J.every(e=>M.has(e.id)),[J,M]),xe=()=>{N(e=>{let t=new Set(e);if(be)for(let e of J)t.delete(e.id);else for(let e of J)t.add(e.id);return t})},Z=(0,m.useMemo)(()=>h.filter(e=>M.has(e.id)&&e.is_custom),[h,M]),Se=async()=>{if(Z.length!==0&&confirm(`Are you sure you want to delete ${Z.length} custom cards?`)){V(!0);try{let e=await de(Z.map(e=>e.id));U(`Deleted ${e} custom cards.`),N(e=>{let t=new Set(e);for(let e of Z)t.delete(e.id);return t}),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Batch delete failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},Ce=async()=>{let e=h.filter(e=>M.has(e.id)&&!e.is_enrolled&&e.catalogProblem);if(e.length===0){U(`No unenrolled catalog cards in current selection.`),setTimeout(()=>U(null),3e3);return}V(!0);try{let t=await b(e.map(e=>e.catalogProblem));U(`Enrolled ${t} cards into Daily Queue!`),N(new Set),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},we=async()=>{let e=h.filter(e=>M.has(e.id)&&e.is_enrolled);if(e.length===0){U(`No active cards in selection to reset.`),setTimeout(()=>U(null),3e3);return}V(!0);try{await v(e.map(e=>e.id)),U(`Reset ${e.length} cards to initial FSRS state due today!`),N(new Set),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},Te=async e=>{V(!0);try{await v([e.id]),U(`Reset #${e.problem_number??`—`} ${e.name} for FSRS!`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},Ee=async e=>{if(e.catalogProblem){V(!0);try{await b([e.catalogProblem]),U(`Enrolled #${e.problem_number??`—`} ${e.name} into review queue!`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},De=async e=>{if(confirm(`Are you sure you want to delete custom card "${e.name}"?`)){V(!0);try{await y(e.id),U(`Deleted custom card "${e.name}"`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Delete failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},Q=(0,m.useCallback)(t=>{f(t.id),e()},[f,e]),$=e=>{ce({id:e.id,name:e.name,problem_number:e.problem_number,pattern:e.pattern,difficulty:e.difficulty,description:e.description,examples:e.examples,constraints:e.constraints,optimal_time:e.optimal_time,optimal_space:e.optimal_space,starter_code:e.starter_code,reference_code:e.reference_code,how_to_solve:e.how_to_solve,solutions:e.solutions})},Oe=()=>{Y?.reference_code&&(navigator.clipboard.writeText(Y.reference_code),z(!0),setTimeout(()=>z(!1),2e3))},ke=(e,t,n)=>{if(!n)return`Not enrolled`;if(!e)return`Due now`;if(t)return`Due today`;let r=new Date(e),i=new Date,a=Math.ceil((r.getTime()-i.getTime())/864e5);return a<=1?`Tomorrow`:`In ${a}d`};return(0,m.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable||J.length===0)return;let n=J.findIndex(e=>e.id===Y?.id);if(e.key===`ArrowDown`){e.preventDefault();let t=n<J.length-1?n+1:0;F(J[t].id)}else if(e.key===`ArrowUp`){e.preventDefault();let t=n>0?n-1:J.length-1;F(J[t].id)}else e.key===` `||e.code===`Space`?(e.preventDefault(),L(e=>e===`front`?`back`:`front`)):e.key===`Enter`&&Y?.is_enrolled&&(e.preventDefault(),Q(Y))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[J,Y,Q]),(0,x.jsxs)(`div`,{className:`w-full h-full flex flex-col bg-[#fdf8e1] font-sans text-ink-black select-none overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`bg-slate-900 text-white border-b-[3px] border-ink-black px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,x.jsx)(`div`,{className:`w-8 h-8 rounded bg-sky-500 border-2 border-white flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)]`,children:(0,x.jsx)(t,{className:`w-5 h-5 text-white stroke-[2.5]`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h1`,{className:`font-arcade text-xs sm:text-sm font-bold tracking-wider text-amber-300 uppercase flex items-center gap-1.5`,children:`MANAGE FSRS`}),(0,x.jsx)(`p`,{className:`text-[10px] text-slate-300 font-mono`,children:`Browse, filter, and reschedule spaced-repetition cards`})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap text-[10px] font-mono`,children:[(0,x.jsxs)(`button`,{onClick:()=>E(`all`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`all`?`bg-sky-500 text-white font-bold`:`bg-slate-800 text-slate-300 hover:bg-slate-700`}`,children:[`Total: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.total})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`due`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`due`?`bg-rose-500 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Due Today: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.due})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`enrolled`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`enrolled`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`In Review: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.enrolled})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`learning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`learning`?`bg-amber-500 text-slate-900 font-bold`:`bg-slate-800 text-amber-300 hover:bg-slate-700`}`,children:[`Learning: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.learning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`reviewing`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`reviewing`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`Review: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.reviewing})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`relearning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`relearning`?`bg-rose-600 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Relearning: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.relearning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`new`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`new`?`bg-indigo-600 text-white font-bold`:`bg-slate-800 text-indigo-300 hover:bg-slate-700`}`,children:[`Unenrolled: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.newCards})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`button`,{onClick:a,className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black border-2 border-white rounded font-arcade text-[9px] font-bold shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(ee,{className:`w-3.5 h-3.5`}),(0,x.jsx)(`span`,{children:`ADD CARD`})]}),(0,x.jsx)(`button`,{onClick:K,disabled:_,className:`p-1 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-600 rounded cursor-pointer disabled:opacity-50`,title:`Refresh Deck`,children:(0,x.jsx)(re,{className:`w-3.5 h-3.5 ${_?`animate-spin`:``}`})})]})]}),H&&(0,x.jsxs)(`div`,{className:`bg-amber-300 border-b-2 border-ink-black px-4 py-1.5 text-xs font-bold text-ink-black flex items-center justify-between shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(c,{className:`w-4 h-4 text-amber-800`}),(0,x.jsx)(`span`,{children:H})]}),(0,x.jsx)(`button`,{onClick:()=>U(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),fe&&(0,x.jsxs)(`div`,{className:`bg-rose-100 border-b-2 border-rose-400 px-4 py-1.5 text-xs font-semibold text-rose-800 flex items-center justify-between shrink-0`,children:[(0,x.jsx)(`span`,{children:fe}),(0,x.jsx)(`button`,{onClick:()=>C(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`sm:hidden flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,x.jsxs)(`button`,{onClick:()=>G(`table`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center border-r border-ink-black ${W===`table`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`CARDS LIST (`,J.length,`)`]}),(0,x.jsxs)(`button`,{onClick:()=>G(`inspector`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center ${W===`inspector`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`INSPECTOR `,Y?`#${Y.problem_number??``}`:``]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,x.jsxs)(`aside`,{className:`w-56 bg-[#f7f0cf] border-r-[3px] border-ink-black flex flex-col shrink-0 overflow-y-auto custom-scrollbar hidden md:flex`,children:[(0,x.jsx)(`div`,{className:`p-3 border-b-2 border-ink-black/20`,children:(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,x.jsx)(o,{className:`w-3.5 h-3.5 text-amber-700`}),` DECKS & STATES`]})}),(0,x.jsxs)(`div`,{className:`p-2 space-y-1 text-xs`,children:[(0,x.jsxs)(`button`,{onClick:()=>E(`all`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`all`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📁 All Cards`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.total})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`due`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`due`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-rose-900 font-semibold`}`,children:[(0,x.jsx)(`span`,{className:`flex items-center gap-1`,children:`⏰ Due Today`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] font-bold text-rose-600`,children:q.due})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`enrolled`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`enrolled`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📥 In Review`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.enrolled})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`new`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`new`?`bg-ink-black text-sky-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🆕 Unenrolled (Catalog)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.newCards})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`learning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`learning`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🔄 Learning (State 1)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.learning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`reviewing`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`reviewing`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📈 Review (State 2)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.reviewing})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`relearning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`relearning`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🔁 Relearning (State 3)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.relearning})]})]}),(0,x.jsx)(`div`,{className:`p-3 border-t-2 border-ink-black/20`,children:(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,x.jsx)(ie,{className:`w-3.5 h-3.5 text-purple-700`}),` PATTERNS (TAGS)`]})}),(0,x.jsxs)(`div`,{className:`p-2 space-y-0.5 text-xs flex-1`,children:[(0,x.jsxs)(`button`,{onClick:()=>me(`ALL`),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors ${D===`ALL`?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`All Patterns`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:h.length})]}),_e.map(({pattern:e,count:t})=>(0,x.jsxs)(`button`,{onClick:()=>me(e),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors text-[11px] ${D===e?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black`}`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80 shrink-0 ml-1`,children:t})]},e))]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-white border-r-[3px] border-ink-black ${W===`inspector`?`hidden sm:flex`:`flex`}`,children:[(0,x.jsxs)(`div`,{className:`p-3 bg-[#fdf8e1] border-b-2 border-ink-black flex flex-wrap items-center justify-between gap-2 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,x.jsx)(oe,{className:`w-4 h-4 absolute left-2.5 top-2.5 text-slate-500`}),(0,x.jsx)(`input`,{type:`text`,value:w,onChange:e=>pe(e.target.value),placeholder:`Search by card #, title, pattern, or keyword...`,className:`w-full pl-8 pr-3 py-1.5 bg-white border-2 border-ink-black text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}),w&&(0,x.jsx)(`button`,{onClick:()=>pe(``),className:`absolute right-2.5 top-2 text-slate-400 hover:text-ink-black text-xs cursor-pointer`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`select`,{"aria-label":`Filter cards by difficulty`,value:O,onChange:e=>he(e.target.value),className:`px-2.5 py-1.5 bg-white border-2 border-ink-black text-xs font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] cursor-pointer`,children:[(0,x.jsx)(`option`,{value:`ALL`,children:`All Difficulties`}),(0,x.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,x.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,x.jsx)(`option`,{value:`Hard`,children:`Hard`})]}),(0,x.jsxs)(`span`,{className:`text-[11px] font-mono text-slate-600 font-semibold hidden lg:inline`,children:[J.length,` matching cards`]})]})]}),M.size>0&&(0,x.jsxs)(`div`,{className:`bg-sky-100 border-b-2 border-ink-black px-3 py-2 flex items-center justify-between gap-2 shrink-0 animate-in fade-in flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`span`,{className:`font-arcade text-[10px] font-bold text-sky-900 uppercase`,children:[M.size,` SELECTED`,Z.length>0&&` (${Z.length} custom)`]}),(0,x.jsx)(`button`,{onClick:()=>N(new Set),className:`text-xs text-sky-800 underline hover:text-sky-950 cursor-pointer`,children:`Clear`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`button`,{onClick:Ce,disabled:B,className:`px-3 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(te,{className:`w-3.5 h-3.5 text-amber-900`}),(0,x.jsx)(`span`,{children:`ADD TO QUEUE`})]}),(0,x.jsxs)(`button`,{onClick:we,disabled:B,className:`px-3 py-1 bg-amber-300 hover:bg-amber-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(d,{className:`w-3.5 h-3.5`}),(0,x.jsx)(`span`,{children:`RESET PROGRESS`})]}),Z.length>0&&(0,x.jsxs)(`button`,{onClick:Se,disabled:B,className:`px-3 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(u,{className:`w-3.5 h-3.5 text-rose-700`}),(0,x.jsxs)(`span`,{children:[`DELETE CUSTOM (`,Z.length,`)`]})]})]})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:(0,x.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-[#f4ebd0] border-b-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black z-10 select-none`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{className:`p-2 w-8 text-center border-r border-ink-black/20`,children:(0,x.jsx)(`button`,{onClick:xe,className:`cursor-pointer flex items-center justify-center mx-auto text-ink-black`,title:`Select all matching cards`,children:be?(0,x.jsx)(se,{className:`w-4 h-4 text-sky-700`}):(0,x.jsx)(s,{className:`w-4 h-4`})})}),(0,x.jsx)(`th`,{onClick:()=>X(`number`),className:`p-2 w-16 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`#`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`name`),className:`p-2 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`CARD TITLE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`pattern`),className:`p-2 hidden md:table-cell cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DECK / PATTERN`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`difficulty`),className:`p-2 w-20 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DIFF`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`state`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`FSRS STATE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`due`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DUE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`retention`),className:`p-2 w-20 hidden lg:table-cell cursor-pointer hover:bg-amber-200/50`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`RETENTION`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})})]})}),(0,x.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:J.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:8,className:`p-8 text-center text-trash-gray font-mono`,children:`No cards match current filter criteria.`})}):J.map(e=>{let t=M.has(e.id),n=Y?.id===e.id;return(0,x.jsxs)(`tr`,{onClick:()=>{F(e.id),G(`inspector`)},onDoubleClick:()=>{e.is_enrolled?Q(e):$(e)},className:`cursor-pointer transition-colors ${n?`bg-sky-100 font-semibold`:t?`bg-amber-50`:`hover:bg-slate-50`}`,children:[(0,x.jsx)(`td`,{className:`p-2 text-center`,onClick:t=>ye(e.id,t),children:t?(0,x.jsx)(se,{className:`w-4 h-4 text-sky-600 mx-auto`}):(0,x.jsx)(s,{className:`w-4 h-4 text-slate-400 mx-auto`})}),(0,x.jsx)(`td`,{className:`p-2 font-mono text-[11px] font-bold text-slate-700`,children:e.problem_number?`#${e.problem_number}`:`—`}),(0,x.jsx)(`td`,{className:`p-2`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`font-semibold text-ink-black truncate`,children:e.name}),e.is_custom&&(0,x.jsx)(`span`,{className:`px-1.5 py-0.2 rounded bg-purple-100 text-purple-800 border border-purple-300 text-[8px] font-bold uppercase shrink-0`,children:`CUSTOM`})]})}),(0,x.jsx)(`td`,{className:`p-2 hidden md:table-cell text-slate-600 text-[11px] truncate`,children:e.pattern}),(0,x.jsx)(`td`,{className:`p-2`,children:(0,x.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty})}),(0,x.jsx)(`td`,{className:`p-2`,children:e.is_enrolled?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] font-bold text-slate-800`,children:[(0,x.jsx)(`span`,{className:`w-2 h-2 rounded-full ${(e.fsrs_state??0)===2?`bg-emerald-500`:(e.fsrs_state??0)===1?`bg-amber-500`:(e.fsrs_state??0)===3?`bg-rose-500`:`bg-blue-500`}`}),(e.fsrs_state??0)===0?`New`:(e.fsrs_state??0)===1?`Learning`:(e.fsrs_state??0)===2?`Review`:`Relearning`]}):(0,x.jsx)(`span`,{className:`text-[10px] font-mono text-slate-400 uppercase font-semibold`,children:`Unenrolled`})}),(0,x.jsx)(`td`,{className:`p-2 font-mono text-[10px]`,children:(0,x.jsx)(`span`,{className:e.is_due?`text-rose-600 font-bold bg-rose-50 px-1 py-0.5 rounded border border-rose-200`:`text-slate-600`,children:ke(e.next_review,e.is_due,e.is_enrolled)})}),(0,x.jsx)(`td`,{className:`p-2 hidden lg:table-cell font-mono text-[10px] text-slate-600`,children:e.total_attempts>0?(0,x.jsxs)(`span`,{children:[e.times_correct,`/`,e.total_attempts,` `,(0,x.jsxs)(`span`,{className:`text-[9px] text-slate-400`,children:[`(`,Math.round(e.times_correct/e.total_attempts*100),`%)`]})]}):(0,x.jsx)(`span`,{className:`text-slate-400`,children:`—`})})]},e.id)})})]})})]}),(0,x.jsx)(`aside`,{className:`w-full sm:w-80 lg:w-96 bg-[#fdf8e1] flex flex-col shrink-0 overflow-hidden ${W===`table`?`hidden sm:flex`:`flex`}`,children:Y?(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`p-4 bg-[#f8efcd] border-b-2 border-ink-black space-y-2 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1`,children:[(0,x.jsx)(n,{className:`w-3.5 h-3.5 text-amber-700`}),` CARD INSPECTOR`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${Y.difficulty===`Easy`?`bg-emerald-600`:Y.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:Y.difficulty}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] font-bold px-1.5 py-0.5 bg-white border border-ink-black rounded`,children:Y.problem_number?`#${Y.problem_number}`:`Custom`})]})]}),(0,x.jsx)(`h3`,{className:`font-headline-md text-base font-extrabold text-ink-black leading-tight`,children:Y.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap text-[10px] font-mono text-slate-700`,children:[(0,x.jsx)(`span`,{className:`bg-purple-100 text-purple-900 px-2 py-0.5 rounded border border-purple-200 font-semibold`,children:Y.pattern}),Y.optimal_time&&(0,x.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`T: `,Y.optimal_time]}),Y.optimal_space&&(0,x.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`S: `,Y.optimal_space]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-2 flex-wrap`,children:[Y.is_enrolled?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`button`,{onClick:()=>Q(Y),className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(r,{className:`w-3 h-3 fill-ink-black`}),(0,x.jsx)(`span`,{children:`REVIEW NOW`})]}),(0,x.jsxs)(`button`,{onClick:()=>Te(Y),disabled:B,className:`px-2 py-1 bg-amber-200 hover:bg-amber-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,title:`Reset interval to initial FSRS state due today`,children:[(0,x.jsx)(d,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`RESET`})]})]}):(0,x.jsxs)(`button`,{onClick:()=>Ee(Y),disabled:B||!Y.catalogProblem,className:`px-2.5 py-1 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(ee,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`ENROLL CARD`})]}),(0,x.jsxs)(`button`,{onClick:()=>$(Y),className:`px-2 py-1 bg-white hover:bg-slate-100 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(ae,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`EDIT`})]}),Y.is_custom&&(0,x.jsxs)(`button`,{onClick:()=>De(Y),disabled:B,className:`px-2 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(u,{className:`w-3 h-3 text-rose-700`}),(0,x.jsx)(`span`,{children:`DELETE`})]})]})]}),(0,x.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,x.jsx)(`button`,{onClick:()=>L(`front`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${I===`front`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`QUESTION`}),(0,x.jsx)(`button`,{onClick:()=>L(`back`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${I===`back`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SHOW ANSWER`}),(0,x.jsx)(`button`,{onClick:()=>L(`stats`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center cursor-pointer ${I===`stats`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SRS INFO`})]}),(0,x.jsxs)(`div`,{className:`flex-1 p-4 overflow-y-auto custom-scrollbar space-y-4`,children:[I===`front`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`PROBLEM DESCRIPTION`}),(0,x.jsx)(`div`,{className:`p-3 bg-white border-2 border-ink-black text-xs font-semibold leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] whitespace-pre-wrap`,children:Y.description||`No description provided.`})]}),Y.examples&&(!Array.isArray(Y.examples)||Y.examples.length>0)&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`EXAMPLES`}),(0,x.jsx)(`div`,{className:`space-y-1.5`,children:Array.isArray(Y.examples)?Y.examples.map((e,t)=>typeof e==`string`?(0,x.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:e},t):(0,x.jsxs)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono space-y-0.5`,children:[e.input&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Input:`}),` `,e.input]}),e.output&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Output:`}),` `,e.output]}),e.explanation&&(0,x.jsx)(`div`,{className:`text-slate-500 italic text-[10px]`,children:e.explanation})]},t)):(0,x.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:String(Y.examples)})})]}),Y.constraints&&(!Array.isArray(Y.constraints)||Y.constraints.length>0)&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`CONSTRAINTS`}),(0,x.jsx)(`div`,{className:`p-2.5 bg-slate-50 border border-slate-300 text-[11px] font-mono space-y-1 text-slate-700`,children:Array.isArray(Y.constraints)?Y.constraints.map((e,t)=>(0,x.jsxs)(`div`,{children:[`• `,e]},t)):(0,x.jsxs)(`div`,{children:[`• `,String(Y.constraints)]})})]})]}),I===`back`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase`,children:`REFERENCE SOLUTION (PYTHON)`}),Y.reference_code&&(0,x.jsxs)(`button`,{onClick:Oe,className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-bold rounded flex items-center gap-1 cursor-pointer`,children:[R?(0,x.jsx)(l,{className:`w-3 h-3 text-emerald-600`}):(0,x.jsx)(ne,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:R?`COPIED!`:`COPY`})]})]}),(0,x.jsx)(`div`,{className:`relative`,children:(0,x.jsx)(`pre`,{className:`p-3 bg-slate-900 text-emerald-400 font-mono text-[11px] rounded border-2 border-ink-black overflow-x-auto shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:(0,x.jsx)(`code`,{children:Y.reference_code||`# No reference code available.`})})}),Y.how_to_solve&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`HOW TO SOLVE & STRATEGY`}),(0,x.jsx)(`div`,{className:`p-2.5 bg-white border border-slate-300 text-xs font-semibold leading-relaxed`,children:Y.how_to_solve})]})]}),I===`stats`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`FSRS REVIEW STATE`}),(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Current State`}),(0,x.jsx)(`div`,{className:`font-arcade text-base font-bold text-sky-700`,children:Y.is_enrolled?(Y.fsrs_state??0)===0?`New (0)`:(Y.fsrs_state??0)===1?`Learning (1)`:(Y.fsrs_state??0)===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Status`}),(0,x.jsx)(`div`,{className:`font-arcade text-xs font-bold text-emerald-700`,children:Y.is_due?`Due Today`:Y.is_enrolled?`Scheduled`:`Catalog New`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Stability`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.fsrs_stability===void 0?`0.0d`:`${Y.fsrs_stability.toFixed(1)}d`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Difficulty`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-amber-700`,children:Y.fsrs_difficulty===void 0?`0.0/10`:`${Y.fsrs_difficulty.toFixed(1)}/10`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Total Attempts`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.total_attempts})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Times Correct`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-emerald-600`,children:Y.times_correct})]}),(0,x.jsxs)(`div`,{className:`col-span-2 pt-1 border-t border-slate-200`,children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Retention Success Rate`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,x.jsx)(`div`,{className:`flex-1 h-3 bg-slate-200 rounded-full overflow-hidden border border-slate-300`,children:(0,x.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full`,style:{width:`${Y.total_attempts>0?Math.round(Y.times_correct/Y.total_attempts*100):0}%`}})}),(0,x.jsx)(`span`,{className:`font-mono text-xs font-bold text-slate-800`,children:Y.total_attempts>0?`${Math.round(Y.times_correct/Y.total_attempts*100)}%`:`0%`})]})]})]})]}),(0,x.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-1.5 text-xs`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`TIMESTAMPS`}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Next Review:`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.next_review?new Date(Y.next_review).toLocaleString():`Not scheduled`})]}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Last Reviewed:`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.last_reviewed?new Date(Y.last_reviewed).toLocaleString():`Never`})]})]})]})]})]}):(0,x.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6 text-center text-trash-gray font-mono text-xs`,children:`Select a card to view its Front, Back, and SRS details.`})})]})]})}export{S as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,F as n,L as r,Lt as i,Mt as a,N as o,O as s,Qt as c,S as l,Xt as u,Z as ee,a as te,at as ne,b as re,et as ie,g as ae,ht as oe,m as d,wt as se,x as ce}from"./vendor-react-oIjZMgNV.js";import{s as f}from"./firebaseClient-DZobvwSx.js";import{i as le,l as p}from"./index-B53AvSbH.js";var m=e(c(),1);async function h(){try{let{data:{session:e}}=await f.auth.getSession();return e?e.access_token:`sandbox`}catch{return`sandbox`}}function g(e){return e.toLowerCase().replace(/\s*-\s*method.*$/i,``).replace(/[^a-z0-9]+/g,``)}function _(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return}return e??void 0}async function ue(){let e=await h(),t=le(),n=[];try{let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e}`}});t.ok&&(n=await t.json())}catch{n=[]}let r=new Map,i=new Map,a=new Set;for(let e of n)e.problem_number!==void 0&&e.problem_number!==null&&r.set(e.problem_number,e),i.set(g(e.name),e);let o=new Date,s=[];for(let e of t){let t=r.get(e.problem_number)||i.get(g(e.name));if(t){a.add(t.id);let n=t.next_review!==null&&t.next_review!==void 0||t.fsrs_state!==null&&t.fsrs_state!==void 0,r=t.next_review?new Date(t.next_review):null,i=n&&r!==null?r<=o:!1,c=_(t.solutions),l=_(t.examples),u=_(t.constraints);s.push({id:t.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:t.description||e.description,reference_code:t.reference_code||e.reference_solution,starter_code:t.starter_code||e.starter_code,optimal_time:t.optimal_time||e.time_complexity,optimal_space:t.optimal_space||e.space_complexity,how_to_solve:t.how_to_solve||``,examples:l&&(!Array.isArray(l)||l.length>0)?l:e.examples,constraints:u&&(!Array.isArray(u)||u.length>0)?u:e.constraints,solutions:c,leetcode_url:e.leetcode_url,is_enrolled:n,is_custom:!1,fsrs_state:t.fsrs_state??(n?0:null),fsrs_step:t.fsrs_step??0,fsrs_stability:t.fsrs_stability??0,fsrs_difficulty:t.fsrs_difficulty??0,fsrs_elapsed_days:t.fsrs_elapsed_days??0,fsrs_scheduled_days:t.fsrs_scheduled_days??0,fsrs_reps:t.fsrs_reps??0,fsrs_lapses:t.fsrs_lapses??0,next_review:t.next_review??null,last_reviewed:t.last_reviewed??null,times_correct:t.times_correct??0,total_attempts:t.total_attempts??0,is_due:i,catalogProblem:e})}else s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:e.description,reference_code:e.reference_solution,starter_code:e.starter_code,optimal_time:e.time_complexity,optimal_space:e.space_complexity,how_to_solve:``,examples:e.examples,constraints:e.constraints,leetcode_url:e.leetcode_url,is_enrolled:!1,is_custom:!1,fsrs_state:null,fsrs_step:0,fsrs_stability:0,fsrs_difficulty:0,fsrs_elapsed_days:0,fsrs_scheduled_days:0,fsrs_reps:0,fsrs_lapses:0,next_review:null,last_reviewed:null,times_correct:0,total_attempts:0,is_due:!1,catalogProblem:e})}for(let e of n)if(!a.has(e.id)){let t=e.next_review!==null&&e.next_review!==void 0||e.fsrs_state!==null&&e.fsrs_state!==void 0,n=e.next_review?new Date(e.next_review):null,r=t&&n!==null?n<=o:!1,i=_(e.solutions),a=_(e.examples)||[],c=_(e.constraints)||[];s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern||`General`,difficulty:e.difficulty||`Medium`,description:e.description||``,reference_code:e.reference_code||``,starter_code:e.starter_code||``,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,how_to_solve:e.how_to_solve||``,examples:a,constraints:c,solutions:i,is_enrolled:t,is_custom:!0,fsrs_state:e.fsrs_state??(t?0:null),fsrs_step:e.fsrs_step??0,fsrs_stability:e.fsrs_stability??0,fsrs_difficulty:e.fsrs_difficulty??0,fsrs_elapsed_days:e.fsrs_elapsed_days??0,fsrs_scheduled_days:e.fsrs_scheduled_days??0,fsrs_reps:e.fsrs_reps??0,fsrs_lapses:e.fsrs_lapses??0,next_review:e.next_review??null,last_reviewed:e.last_reviewed??null,times_correct:e.times_correct??0,total_attempts:e.total_attempts??0,is_due:r})}return s}async function v(e){if(e.length===0)return!0;let t=await h(),n=await fetch(`/api/reviews/reset`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({problem_ids:e})});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to reset reviews`}));throw Error(e.detail||`Failed to reset reviews`)}return!0}async function y(e){let t=await h(),n=await fetch(`/api/explorer/problems/${e}`,{method:`DELETE`,headers:{Authorization:`Bearer ${t}`}});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to delete problem`}));throw Error(e.detail||`Failed to delete problem`)}return!0}async function de(e){let t=0;for(let n of e)try{await y(n),t++}catch{}return t}async function b(e){return e.length===0?0:(await p(e)).enrolled_count}var x=u();function S({onOpenQueue:e,onOpenCreateProblem:c,onOpenEditProblem:u,onSelectProblemForReview:f,refreshTrigger:le,onRefreshExplorer:p}){let[h,g]=(0,m.useState)([]),[_,S]=(0,m.useState)(!0),[fe,C]=(0,m.useState)(null),[w,pe]=(0,m.useState)(``),[T,E]=(0,m.useState)(`all`),[D,me]=(0,m.useState)(`ALL`),[O,he]=(0,m.useState)(`ALL`),[k,ge]=(0,m.useState)(`number`),[A,j]=(0,m.useState)(`asc`),[M,N]=(0,m.useState)(new Set),[P,F]=(0,m.useState)(null),[I,L]=(0,m.useState)(`front`),[R,z]=(0,m.useState)(!1),[B,V]=(0,m.useState)(!1),[H,U]=(0,m.useState)(null),[W,G]=(0,m.useState)(`table`),K=(0,m.useCallback)(async()=>{S(!0),C(null);try{let e=await ue();g(e),e.length>0&&!P&&F(e[0].id)}catch(e){let t=e instanceof Error?e.message:`Failed to load card database`;C(t)}finally{S(!1)}},[P]);(0,m.useEffect)(()=>{K()},[K,le]);let q=(0,m.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0,a=0;for(let o of h)if(o.is_enrolled){t++,o.is_due&&e++;let n=o.fsrs_state??0;n===1?r++:n===2?i++:n===3&&a++}else n++;return{total:h.length,due:e,enrolled:t,newCards:n,learning:r,reviewing:i,relearning:a}},[h]),_e=(0,m.useMemo)(()=>{let e=new Map;for(let t of h)e.set(t.pattern,(e.get(t.pattern)||0)+1);let t=Array.from(e.entries()).map(([e,t])=>({pattern:e,count:t}));return t.sort((e,t)=>e.pattern.localeCompare(t.pattern)),t},[h]),ve=(0,m.useMemo)(()=>{let e=w.trim().toLowerCase();return h.filter(t=>{if(T===`due`&&!t.is_due||T===`enrolled`&&!t.is_enrolled||T===`new`&&t.is_enrolled||T===`learning`&&(!t.is_enrolled||t.fsrs_state!==1)||T===`reviewing`&&(!t.is_enrolled||t.fsrs_state!==2)||T===`relearning`&&(!t.is_enrolled||t.fsrs_state!==3)||D!==`ALL`&&t.pattern!==D||O!==`ALL`&&t.difficulty!==O)return!1;if(e){let n=t.problem_number?String(t.problem_number).includes(e):!1,r=t.name.toLowerCase().includes(e),i=t.pattern.toLowerCase().includes(e),a=t.difficulty.toLowerCase().includes(e);if(!n&&!r&&!i&&!a)return!1}return!0})},[h,T,D,O,w]),J=(0,m.useMemo)(()=>{let e=[...ve];return e.sort((e,t)=>{let n=0;switch(k){case`number`:n=(e.problem_number??999999)-(t.problem_number??999999);break;case`name`:n=e.name.localeCompare(t.name);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`difficulty`:{let r={Easy:1,Medium:2,Hard:3};n=(r[e.difficulty]||2)-(r[t.difficulty]||2);break}case`state`:n=(e.fsrs_state??-1)-(t.fsrs_state??-1);break;case`due`:n=(e.next_review?new Date(e.next_review).getTime():9999999999999)-(t.next_review?new Date(t.next_review).getTime():9999999999999);break;case`retention`:n=(e.total_attempts>0?e.times_correct/e.total_attempts:0)-(t.total_attempts>0?t.times_correct/t.total_attempts:0)}return A===`asc`?n:-n}),e},[ve,k,A]),Y=(0,m.useMemo)(()=>!P&&J.length>0?J[0]:h.find(e=>e.id===P)||J[0]||null,[h,P,J]),X=e=>{k===e?j(e=>e===`asc`?`desc`:`asc`):(ge(e),j(`asc`))},ye=(e,t)=>{t.stopPropagation(),N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},be=(0,m.useMemo)(()=>J.length>0&&J.every(e=>M.has(e.id)),[J,M]),xe=()=>{N(e=>{let t=new Set(e);if(be)for(let e of J)t.delete(e.id);else for(let e of J)t.add(e.id);return t})},Z=(0,m.useMemo)(()=>h.filter(e=>M.has(e.id)&&e.is_custom),[h,M]),Se=async()=>{if(Z.length!==0&&confirm(`Are you sure you want to delete ${Z.length} custom cards?`)){V(!0);try{let e=await de(Z.map(e=>e.id));U(`Deleted ${e} custom cards.`),N(e=>{let t=new Set(e);for(let e of Z)t.delete(e.id);return t}),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Batch delete failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},Ce=async()=>{let e=h.filter(e=>M.has(e.id)&&!e.is_enrolled&&e.catalogProblem);if(e.length===0){U(`No unenrolled catalog cards in current selection.`),setTimeout(()=>U(null),3e3);return}V(!0);try{let t=await b(e.map(e=>e.catalogProblem));U(`Enrolled ${t} cards into Daily Queue!`),N(new Set),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},we=async()=>{let e=h.filter(e=>M.has(e.id)&&e.is_enrolled);if(e.length===0){U(`No active cards in selection to reset.`),setTimeout(()=>U(null),3e3);return}V(!0);try{await v(e.map(e=>e.id)),U(`Reset ${e.length} cards to initial FSRS state due today!`),N(new Set),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},Te=async e=>{V(!0);try{await v([e.id]),U(`Reset #${e.problem_number??`—`} ${e.name} for FSRS!`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}},Ee=async e=>{if(e.catalogProblem){V(!0);try{await b([e.catalogProblem]),U(`Enrolled #${e.problem_number??`—`} ${e.name} into review queue!`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},De=async e=>{if(confirm(`Are you sure you want to delete custom card "${e.name}"?`)){V(!0);try{await y(e.id),U(`Deleted custom card "${e.name}"`),await K(),p?.()}catch(e){let t=e instanceof Error?e.message:`Delete failed`;C(t)}finally{V(!1),setTimeout(()=>U(null),3500)}}},Q=(0,m.useCallback)(t=>{f(t.id),e()},[f,e]),$=e=>{u({id:e.id,name:e.name,problem_number:e.problem_number,pattern:e.pattern,difficulty:e.difficulty,description:e.description,examples:e.examples,constraints:e.constraints,optimal_time:e.optimal_time,optimal_space:e.optimal_space,starter_code:e.starter_code,reference_code:e.reference_code,how_to_solve:e.how_to_solve,solutions:e.solutions})},Oe=()=>{Y?.reference_code&&(navigator.clipboard.writeText(Y.reference_code),z(!0),setTimeout(()=>z(!1),2e3))},ke=(e,t,n)=>{if(!n)return`Not enrolled`;if(!e)return`Due now`;if(t)return`Due today`;let r=new Date(e),i=new Date,a=Math.ceil((r.getTime()-i.getTime())/864e5);return a<=1?`Tomorrow`:`In ${a}d`};return(0,m.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable||J.length===0)return;let n=J.findIndex(e=>e.id===Y?.id);if(e.key===`ArrowDown`){e.preventDefault();let t=n<J.length-1?n+1:0;F(J[t].id)}else if(e.key===`ArrowUp`){e.preventDefault();let t=n>0?n-1:J.length-1;F(J[t].id)}else e.key===` `||e.code===`Space`?(e.preventDefault(),L(e=>e===`front`?`back`:`front`)):e.key===`Enter`&&Y?.is_enrolled&&(e.preventDefault(),Q(Y))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[J,Y,Q]),(0,x.jsxs)(`div`,{className:`w-full h-full flex flex-col bg-[#fdf8e1] font-sans text-ink-black select-none overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`bg-slate-900 text-white border-b-[3px] border-ink-black px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,x.jsx)(`div`,{className:`w-8 h-8 rounded bg-sky-500 border-2 border-white flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)]`,children:(0,x.jsx)(ee,{className:`w-5 h-5 text-white stroke-[2.5]`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h1`,{className:`font-arcade text-xs sm:text-sm font-bold tracking-wider text-amber-300 uppercase flex items-center gap-1.5`,children:`MANAGE FSRS`}),(0,x.jsx)(`p`,{className:`text-[10px] text-slate-300 font-mono`,children:`Browse, filter, and reschedule spaced-repetition cards`})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap text-[10px] font-mono`,children:[(0,x.jsxs)(`button`,{onClick:()=>E(`all`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`all`?`bg-sky-500 text-white font-bold`:`bg-slate-800 text-slate-300 hover:bg-slate-700`}`,children:[`Total: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.total})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`due`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`due`?`bg-rose-500 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Due Today: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.due})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`enrolled`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`enrolled`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`In Review: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.enrolled})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`learning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`learning`?`bg-amber-500 text-slate-900 font-bold`:`bg-slate-800 text-amber-300 hover:bg-slate-700`}`,children:[`Learning: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.learning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`reviewing`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`reviewing`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`Review: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.reviewing})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`relearning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`relearning`?`bg-rose-600 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Relearning: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.relearning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`new`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${T===`new`?`bg-indigo-600 text-white font-bold`:`bg-slate-800 text-indigo-300 hover:bg-slate-700`}`,children:[`Unenrolled: `,(0,x.jsx)(`span`,{className:`font-bold`,children:q.newCards})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`button`,{onClick:c,className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black border-2 border-white rounded font-arcade text-[9px] font-bold shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(se,{className:`w-3.5 h-3.5`}),(0,x.jsx)(`span`,{children:`ADD CARD`})]}),(0,x.jsx)(`button`,{onClick:K,disabled:_,className:`p-1 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-600 rounded cursor-pointer disabled:opacity-50`,title:`Refresh Deck`,children:(0,x.jsx)(n,{className:`w-3.5 h-3.5 ${_?`animate-spin`:``}`})})]})]}),H&&(0,x.jsxs)(`div`,{className:`bg-amber-300 border-b-2 border-ink-black px-4 py-1.5 text-xs font-bold text-ink-black flex items-center justify-between shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(t,{className:`w-4 h-4 text-amber-800`}),(0,x.jsx)(`span`,{children:H})]}),(0,x.jsx)(`button`,{onClick:()=>U(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),fe&&(0,x.jsxs)(`div`,{className:`bg-rose-100 border-b-2 border-rose-400 px-4 py-1.5 text-xs font-semibold text-rose-800 flex items-center justify-between shrink-0`,children:[(0,x.jsx)(`span`,{children:fe}),(0,x.jsx)(`button`,{onClick:()=>C(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`sm:hidden flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,x.jsxs)(`button`,{onClick:()=>G(`table`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center border-r border-ink-black ${W===`table`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`CARDS LIST (`,J.length,`)`]}),(0,x.jsxs)(`button`,{onClick:()=>G(`inspector`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center ${W===`inspector`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`INSPECTOR `,Y?`#${Y.problem_number??``}`:``]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,x.jsxs)(`aside`,{className:`w-56 bg-[#f7f0cf] border-r-[3px] border-ink-black flex flex-col shrink-0 overflow-y-auto custom-scrollbar hidden md:flex`,children:[(0,x.jsx)(`div`,{className:`p-3 border-b-2 border-ink-black/20`,children:(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,x.jsx)(ne,{className:`w-3.5 h-3.5 text-amber-700`}),` DECKS & STATES`]})}),(0,x.jsxs)(`div`,{className:`p-2 space-y-1 text-xs`,children:[(0,x.jsxs)(`button`,{onClick:()=>E(`all`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`all`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📁 All Cards`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.total})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`due`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`due`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-rose-900 font-semibold`}`,children:[(0,x.jsx)(`span`,{className:`flex items-center gap-1`,children:`⏰ Due Today`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] font-bold text-rose-600`,children:q.due})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`enrolled`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`enrolled`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📥 In Review`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.enrolled})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`new`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`new`?`bg-ink-black text-sky-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🆕 Unenrolled (Catalog)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.newCards})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`learning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`learning`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🔄 Learning (State 1)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.learning})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`reviewing`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`reviewing`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`📈 Review (State 2)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.reviewing})]}),(0,x.jsxs)(`button`,{onClick:()=>E(`relearning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${T===`relearning`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`🔁 Relearning (State 3)`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.relearning})]})]}),(0,x.jsx)(`div`,{className:`p-3 border-t-2 border-ink-black/20`,children:(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,x.jsx)(ae,{className:`w-3.5 h-3.5 text-purple-700`}),` PATTERNS (TAGS)`]})}),(0,x.jsxs)(`div`,{className:`p-2 space-y-0.5 text-xs flex-1`,children:[(0,x.jsxs)(`button`,{onClick:()=>me(`ALL`),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors ${D===`ALL`?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black font-semibold`}`,children:[(0,x.jsx)(`span`,{children:`All Patterns`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:h.length})]}),_e.map(({pattern:e,count:t})=>(0,x.jsxs)(`button`,{onClick:()=>me(e),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors text-[11px] ${D===e?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black`}`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] opacity-80 shrink-0 ml-1`,children:t})]},e))]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-white border-r-[3px] border-ink-black ${W===`inspector`?`hidden sm:flex`:`flex`}`,children:[(0,x.jsxs)(`div`,{className:`p-3 bg-[#fdf8e1] border-b-2 border-ink-black flex flex-wrap items-center justify-between gap-2 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,x.jsx)(s,{className:`w-4 h-4 absolute left-2.5 top-2.5 text-slate-500`}),(0,x.jsx)(`input`,{type:`text`,value:w,onChange:e=>pe(e.target.value),placeholder:`Search by card #, title, pattern, or keyword...`,className:`w-full pl-8 pr-3 py-1.5 bg-white border-2 border-ink-black text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}),w&&(0,x.jsx)(`button`,{onClick:()=>pe(``),className:`absolute right-2.5 top-2 text-slate-400 hover:text-ink-black text-xs cursor-pointer`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`select`,{"aria-label":`Filter cards by difficulty`,value:O,onChange:e=>he(e.target.value),className:`px-2.5 py-1.5 bg-white border-2 border-ink-black text-xs font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] cursor-pointer`,children:[(0,x.jsx)(`option`,{value:`ALL`,children:`All Difficulties`}),(0,x.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,x.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,x.jsx)(`option`,{value:`Hard`,children:`Hard`})]}),(0,x.jsxs)(`span`,{className:`text-[11px] font-mono text-slate-600 font-semibold hidden lg:inline`,children:[J.length,` matching cards`]})]})]}),M.size>0&&(0,x.jsxs)(`div`,{className:`bg-sky-100 border-b-2 border-ink-black px-3 py-2 flex items-center justify-between gap-2 shrink-0 animate-in fade-in flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`span`,{className:`font-arcade text-[10px] font-bold text-sky-900 uppercase`,children:[M.size,` SELECTED`,Z.length>0&&` (${Z.length} custom)`]}),(0,x.jsx)(`button`,{onClick:()=>N(new Set),className:`text-xs text-sky-800 underline hover:text-sky-950 cursor-pointer`,children:`Clear`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`button`,{onClick:Ce,disabled:B,className:`px-3 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(te,{className:`w-3.5 h-3.5 text-amber-900`}),(0,x.jsx)(`span`,{children:`ADD TO QUEUE`})]}),(0,x.jsxs)(`button`,{onClick:we,disabled:B,className:`px-3 py-1 bg-amber-300 hover:bg-amber-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(o,{className:`w-3.5 h-3.5`}),(0,x.jsx)(`span`,{children:`RESET PROGRESS`})]}),Z.length>0&&(0,x.jsxs)(`button`,{onClick:Se,disabled:B,className:`px-3 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(d,{className:`w-3.5 h-3.5 text-rose-700`}),(0,x.jsxs)(`span`,{children:[`DELETE CUSTOM (`,Z.length,`)`]})]})]})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:(0,x.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-[#f4ebd0] border-b-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black z-10 select-none`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{className:`p-2 w-8 text-center border-r border-ink-black/20`,children:(0,x.jsx)(`button`,{onClick:xe,className:`cursor-pointer flex items-center justify-center mx-auto text-ink-black`,title:`Select all matching cards`,children:be?(0,x.jsx)(l,{className:`w-4 h-4 text-sky-700`}):(0,x.jsx)(re,{className:`w-4 h-4`})})}),(0,x.jsx)(`th`,{onClick:()=>X(`number`),className:`p-2 w-16 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`#`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`name`),className:`p-2 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`CARD TITLE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`pattern`),className:`p-2 hidden md:table-cell cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DECK / PATTERN`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`difficulty`),className:`p-2 w-20 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DIFF`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`state`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`FSRS STATE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`due`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`DUE`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,x.jsx)(`th`,{onClick:()=>X(`retention`),className:`p-2 w-20 hidden lg:table-cell cursor-pointer hover:bg-amber-200/50`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{children:`RETENTION`}),(0,x.jsx)(i,{className:`w-3 h-3 opacity-60`})]})})]})}),(0,x.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:J.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:8,className:`p-8 text-center text-trash-gray font-mono`,children:`No cards match current filter criteria.`})}):J.map(e=>{let t=M.has(e.id),n=Y?.id===e.id;return(0,x.jsxs)(`tr`,{onClick:()=>{F(e.id),G(`inspector`)},onDoubleClick:()=>{e.is_enrolled?Q(e):$(e)},className:`cursor-pointer transition-colors ${n?`bg-sky-100 font-semibold`:t?`bg-amber-50`:`hover:bg-slate-50`}`,children:[(0,x.jsx)(`td`,{className:`p-2 text-center`,onClick:t=>ye(e.id,t),children:t?(0,x.jsx)(l,{className:`w-4 h-4 text-sky-600 mx-auto`}):(0,x.jsx)(re,{className:`w-4 h-4 text-slate-400 mx-auto`})}),(0,x.jsx)(`td`,{className:`p-2 font-mono text-[11px] font-bold text-slate-700`,children:e.problem_number?`#${e.problem_number}`:`—`}),(0,x.jsx)(`td`,{className:`p-2`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`font-semibold text-ink-black truncate`,children:e.name}),e.is_custom&&(0,x.jsx)(`span`,{className:`px-1.5 py-0.2 rounded bg-purple-100 text-purple-800 border border-purple-300 text-[8px] font-bold uppercase shrink-0`,children:`CUSTOM`})]})}),(0,x.jsx)(`td`,{className:`p-2 hidden md:table-cell text-slate-600 text-[11px] truncate`,children:e.pattern}),(0,x.jsx)(`td`,{className:`p-2`,children:(0,x.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty})}),(0,x.jsx)(`td`,{className:`p-2`,children:e.is_enrolled?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] font-bold text-slate-800`,children:[(0,x.jsx)(`span`,{className:`w-2 h-2 rounded-full ${(e.fsrs_state??0)===2?`bg-emerald-500`:(e.fsrs_state??0)===1?`bg-amber-500`:(e.fsrs_state??0)===3?`bg-rose-500`:`bg-blue-500`}`}),(e.fsrs_state??0)===0?`New`:(e.fsrs_state??0)===1?`Learning`:(e.fsrs_state??0)===2?`Review`:`Relearning`]}):(0,x.jsx)(`span`,{className:`text-[10px] font-mono text-slate-400 uppercase font-semibold`,children:`Unenrolled`})}),(0,x.jsx)(`td`,{className:`p-2 font-mono text-[10px]`,children:(0,x.jsx)(`span`,{className:e.is_due?`text-rose-600 font-bold bg-rose-50 px-1 py-0.5 rounded border border-rose-200`:`text-slate-600`,children:ke(e.next_review,e.is_due,e.is_enrolled)})}),(0,x.jsx)(`td`,{className:`p-2 hidden lg:table-cell font-mono text-[10px] text-slate-600`,children:e.total_attempts>0?(0,x.jsxs)(`span`,{children:[e.times_correct,`/`,e.total_attempts,` `,(0,x.jsxs)(`span`,{className:`text-[9px] text-slate-400`,children:[`(`,Math.round(e.times_correct/e.total_attempts*100),`%)`]})]}):(0,x.jsx)(`span`,{className:`text-slate-400`,children:`—`})})]},e.id)})})]})})]}),(0,x.jsx)(`aside`,{className:`w-full sm:w-80 lg:w-96 bg-[#fdf8e1] flex flex-col shrink-0 overflow-hidden ${W===`table`?`hidden sm:flex`:`flex`}`,children:Y?(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`p-4 bg-[#f8efcd] border-b-2 border-ink-black space-y-2 shrink-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1`,children:[(0,x.jsx)(ie,{className:`w-3.5 h-3.5 text-amber-700`}),` CARD INSPECTOR`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${Y.difficulty===`Easy`?`bg-emerald-600`:Y.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:Y.difficulty}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] font-bold px-1.5 py-0.5 bg-white border border-ink-black rounded`,children:Y.problem_number?`#${Y.problem_number}`:`Custom`})]})]}),(0,x.jsx)(`h3`,{className:`font-headline-md text-base font-extrabold text-ink-black leading-tight`,children:Y.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap text-[10px] font-mono text-slate-700`,children:[(0,x.jsx)(`span`,{className:`bg-purple-100 text-purple-900 px-2 py-0.5 rounded border border-purple-200 font-semibold`,children:Y.pattern}),Y.optimal_time&&(0,x.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`T: `,Y.optimal_time]}),Y.optimal_space&&(0,x.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`S: `,Y.optimal_space]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-2 flex-wrap`,children:[Y.is_enrolled?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`button`,{onClick:()=>Q(Y),className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(r,{className:`w-3 h-3 fill-ink-black`}),(0,x.jsx)(`span`,{children:`REVIEW NOW`})]}),(0,x.jsxs)(`button`,{onClick:()=>Te(Y),disabled:B,className:`px-2 py-1 bg-amber-200 hover:bg-amber-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,title:`Reset interval to initial FSRS state due today`,children:[(0,x.jsx)(o,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`RESET`})]})]}):(0,x.jsxs)(`button`,{onClick:()=>Ee(Y),disabled:B||!Y.catalogProblem,className:`px-2.5 py-1 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(se,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`ENROLL CARD`})]}),(0,x.jsxs)(`button`,{onClick:()=>$(Y),className:`px-2 py-1 bg-white hover:bg-slate-100 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,x.jsx)(ce,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:`EDIT`})]}),Y.is_custom&&(0,x.jsxs)(`button`,{onClick:()=>De(Y),disabled:B,className:`px-2 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,x.jsx)(d,{className:`w-3 h-3 text-rose-700`}),(0,x.jsx)(`span`,{children:`DELETE`})]})]})]}),(0,x.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,x.jsx)(`button`,{onClick:()=>L(`front`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${I===`front`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`QUESTION`}),(0,x.jsx)(`button`,{onClick:()=>L(`back`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${I===`back`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SHOW ANSWER`}),(0,x.jsx)(`button`,{onClick:()=>L(`stats`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center cursor-pointer ${I===`stats`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SRS INFO`})]}),(0,x.jsxs)(`div`,{className:`flex-1 p-4 overflow-y-auto custom-scrollbar space-y-4`,children:[I===`front`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`PROBLEM DESCRIPTION`}),(0,x.jsx)(`div`,{className:`p-3 bg-white border-2 border-ink-black text-xs font-semibold leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] whitespace-pre-wrap`,children:Y.description||`No description provided.`})]}),Y.examples&&(!Array.isArray(Y.examples)||Y.examples.length>0)&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`EXAMPLES`}),(0,x.jsx)(`div`,{className:`space-y-1.5`,children:Array.isArray(Y.examples)?Y.examples.map((e,t)=>typeof e==`string`?(0,x.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:e},t):(0,x.jsxs)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono space-y-0.5`,children:[e.input&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Input:`}),` `,e.input]}),e.output&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Output:`}),` `,e.output]}),e.explanation&&(0,x.jsx)(`div`,{className:`text-slate-500 italic text-[10px]`,children:e.explanation})]},t)):(0,x.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:String(Y.examples)})})]}),Y.constraints&&(!Array.isArray(Y.constraints)||Y.constraints.length>0)&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`CONSTRAINTS`}),(0,x.jsx)(`div`,{className:`p-2.5 bg-slate-50 border border-slate-300 text-[11px] font-mono space-y-1 text-slate-700`,children:Array.isArray(Y.constraints)?Y.constraints.map((e,t)=>(0,x.jsxs)(`div`,{children:[`• `,e]},t)):(0,x.jsxs)(`div`,{children:[`• `,String(Y.constraints)]})})]})]}),I===`back`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase`,children:`REFERENCE SOLUTION (PYTHON)`}),Y.reference_code&&(0,x.jsxs)(`button`,{onClick:Oe,className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-bold rounded flex items-center gap-1 cursor-pointer`,children:[R?(0,x.jsx)(a,{className:`w-3 h-3 text-emerald-600`}):(0,x.jsx)(oe,{className:`w-3 h-3`}),(0,x.jsx)(`span`,{children:R?`COPIED!`:`COPY`})]})]}),(0,x.jsx)(`div`,{className:`relative`,children:(0,x.jsx)(`pre`,{className:`p-3 bg-slate-900 text-emerald-400 font-mono text-[11px] rounded border-2 border-ink-black overflow-x-auto shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:(0,x.jsx)(`code`,{children:Y.reference_code||`# No reference code available.`})})}),Y.how_to_solve&&(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`HOW TO SOLVE & STRATEGY`}),(0,x.jsx)(`div`,{className:`p-2.5 bg-white border border-slate-300 text-xs font-semibold leading-relaxed`,children:Y.how_to_solve})]})]}),I===`stats`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`FSRS REVIEW STATE`}),(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Current State`}),(0,x.jsx)(`div`,{className:`font-arcade text-base font-bold text-sky-700`,children:Y.is_enrolled?(Y.fsrs_state??0)===0?`New (0)`:(Y.fsrs_state??0)===1?`Learning (1)`:(Y.fsrs_state??0)===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Status`}),(0,x.jsx)(`div`,{className:`font-arcade text-xs font-bold text-emerald-700`,children:Y.is_due?`Due Today`:Y.is_enrolled?`Scheduled`:`Catalog New`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Stability`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.fsrs_stability===void 0?`0.0d`:`${Y.fsrs_stability.toFixed(1)}d`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Difficulty`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-amber-700`,children:Y.fsrs_difficulty===void 0?`0.0/10`:`${Y.fsrs_difficulty.toFixed(1)}/10`})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Total Attempts`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.total_attempts})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Times Correct`}),(0,x.jsx)(`div`,{className:`font-mono text-sm font-bold text-emerald-600`,children:Y.times_correct})]}),(0,x.jsxs)(`div`,{className:`col-span-2 pt-1 border-t border-slate-200`,children:[(0,x.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Retention Success Rate`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,x.jsx)(`div`,{className:`flex-1 h-3 bg-slate-200 rounded-full overflow-hidden border border-slate-300`,children:(0,x.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full`,style:{width:`${Y.total_attempts>0?Math.round(Y.times_correct/Y.total_attempts*100):0}%`}})}),(0,x.jsx)(`span`,{className:`font-mono text-xs font-bold text-slate-800`,children:Y.total_attempts>0?`${Math.round(Y.times_correct/Y.total_attempts*100)}%`:`0%`})]})]})]})]}),(0,x.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-1.5 text-xs`,children:[(0,x.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`TIMESTAMPS`}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Next Review:`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.next_review?new Date(Y.next_review).toLocaleString():`Not scheduled`})]}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Last Reviewed:`}),(0,x.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.last_reviewed?new Date(Y.last_reviewed).toLocaleString():`Never`})]})]})]})]})]}):(0,x.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6 text-center text-trash-gray font-mono text-xs`,children:`Select a card to view its Front, Back, and SRS details.`})})]})]})}export{S as default};
algospaced-ui/dist/assets/{CreateProblemForm-DvmR15Wo.js → CreateProblemForm-Btlo_Jzs.js} RENAMED
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function s(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}function c({onClose:e,onSuccess:t,initialProblem:n,mode:c=n?`edit`:`create`}){let l=c===`edit`||!!n,[u,d]=(0,i.useState)(`form`),[f,p]=(0,i.useState)(``),[ee,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(()=>{if(n?.name)return n.name;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).name||``}catch{}return``}),[_,v]=(0,i.useState)(()=>n?.problem_number!==void 0&&n?.problem_number!==null?n.problem_number:``),[y,b]=(0,i.useState)(()=>{if(n?.pattern)return n.pattern;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).pattern||``}catch{}return`Arrays & Hashing`}),[x,S]=(0,i.useState)(()=>n?.difficulty===`Easy`||n?.difficulty===`Medium`||n?.difficulty===`Hard`?n.difficulty:`Medium`),[C,w]=(0,i.useState)(()=>n?.optimal_time||`O(N)`),[T,E]=(0,i.useState)(()=>n?.optimal_space||`O(1)`),[D,O]=(0,i.useState)(()=>n?.description||``),[k,A]=(0,i.useState)(()=>n?.examples&&Array.isArray(n.examples)&&n.examples.length>0?n.examples.map(e=>typeof e==`string`?{input:e,output:``,explanation:``}:{input:String(e?.input??``),output:String(e?.output??``),explanation:e?.explanation||``}):[{input:``,output:``,explanation:``}]),[j,M]=(0,i.useState)(()=>n?.constraints?Array.isArray(n.constraints)?n.constraints.join(`
2
  `):String(n.constraints):``),[te,ne]=(0,i.useState)(()=>n?.how_to_solve||``),[N,P]=(0,i.useState)(()=>{if(n?.reference_code)return n.reference_code;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).code||``}catch{}return``}),[F,I]=(0,i.useState)(()=>{if(n?.solutions&&Array.isArray(n.solutions)&&n.solutions.length>0)return n.solutions.map((e,t)=>({id:e.id||`sol-${t+1}`,name:e.name||`Method ${t+1}`,pattern:e.pattern||n.pattern||`Arrays & Hashing`,time_complexity:e.time_complexity||n.optimal_time||`O(N)`,space_complexity:e.space_complexity||n.optimal_space||`O(1)`,code:e.code||``,explanation:e.explanation||``,is_optimal:e.is_optimal??t===0}));let e=n?.reference_code||``,t=n?.pattern||`Arrays & Hashing`;try{let n=localStorage.getItem(`algospaced_prefill_draft`);if(n){let r=JSON.parse(n);r.code&&!e&&(e=r.code),r.pattern&&!t&&(t=r.pattern)}}catch{}return[{id:`sol-1`,name:`Optimal Method`,pattern:t,time_complexity:n?.optimal_time||`O(N)`,space_complexity:n?.optimal_space||`O(1)`,code:e,explanation:n?.how_to_solve||``,is_optimal:!0}]}),[L,R]=(0,i.useState)(0),z=F[L]||F[0]||{id:`sol-1`,name:`Method 1`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!0},B=e=>{I(t=>{let n=[...t],r=L<n.length?L:0;return n[r]={...n[r],...e},e.is_optimal&&(n.forEach((e,t)=>{t!==r&&(e.is_optimal=!1)}),n[r].time_complexity&&w(n[r].time_complexity),n[r].space_complexity&&E(n[r].space_complexity),n[r].pattern&&b(n[r].pattern)),n})},re=()=>{let e=F.length+1,t={id:s(),name:`Method ${e}`,pattern:y||`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:F.length===0};I(e=>[...e,t]),R(F.length)},ie=e=>{F.length<=1||(I(t=>{let n=t.filter((t,n)=>n!==e);return n.some(e=>e.is_optimal)||(n[0].is_optimal=!0),n}),L>=F.length-1&&R(Math.max(0,F.length-2)))},[V,ae]=(0,i.useState)(!0),[H,U]=(0,i.useState)(``),[W,G]=(0,i.useState)(``),[K,q]=(0,i.useState)(!1),[J,Y]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[oe,se]=(0,i.useState)(!1);i.useEffect(()=>{l||localStorage.removeItem(`algospaced_prefill_draft`)},[l]);let Q=async()=>{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,n=localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``,i=localStorage.getItem(`algospaced_custom_ai_provider`)||`default`,a={"Content-Type":`application/json`,Authorization:`Bearer ${t}`};return i&&i!=="default"&&n&&n.trim()&&(a[`x-custom-api-key`]=n.trim(),a[`x-gemini-api-key`]=n.trim(),a[`x-ai-provider`]=i),a},ce=async()=>{if(f.trim()){m(!0),U(``);try{let e=await Q(),t=await fetch(`/api/explorer/problems/fetch-leetcode`,{method:`POST`,headers:e,body:JSON.stringify({query:f.trim()})});if(t.ok){let e=await t.json();e.problem_number!==void 0&&e.problem_number!==null&&v(e.problem_number),e.title&&g(e.title),e.difficulty&&S(e.difficulty),e.pattern&&b(e.pattern),e.optimal_time&&w(e.optimal_time),e.optimal_space&&E(e.optimal_space),e.description&&O(e.description),e.how_to_solve&&ne(e.how_to_solve),e.starter_code&&!N.trim()&&P(e.starter_code),I(t=>{let n=[...t],r={...n[L]};return e.pattern&&(r.pattern=e.pattern),e.optimal_time&&(r.time_complexity=e.optimal_time),e.optimal_space&&(r.space_complexity=e.optimal_space),e.how_to_solve&&(r.explanation=e.how_to_solve),e.starter_code&&!r.code?.trim()&&(r.code=e.starter_code),n[L]=r,n}),Array.isArray(e.examples)&&e.examples.length>0&&A(e.examples),Array.isArray(e.constraints)?M(e.constraints.join(`
3
  `)):typeof e.constraints==`string`&&M(e.constraints)}else{let e=await t.json();U(e.detail||`Failed to fetch LeetCode problem data.`)}}catch{U(`Fetch request failed due to connection error.`)}finally{m(!1)}}},le=async()=>{let e=z.code||N;if(h.trim()||e.trim()){se(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/prefill`,{method:`POST`,headers:t,body:JSON.stringify({name:h,code:e})});if(n.ok){let t=await n.json();t.problem_number!==void 0&&t.problem_number!==null&&v(t.problem_number),t.title&&!h&&g(t.title),t.pattern&&b(t.pattern),t.difficulty&&S(t.difficulty),t.optimal_time&&w(t.optimal_time),t.optimal_space&&E(t.optimal_space),t.description&&O(t.description),t.reference_code&&!e.trim()&&P(t.reference_code),I(e=>{let n=[...e],r={...n[L]};return t.pattern&&(r.pattern=t.pattern),t.optimal_time&&(r.time_complexity=t.optimal_time),t.optimal_space&&(r.space_complexity=t.optimal_space),t.reference_code&&!r.code?.trim()&&(r.code=t.reference_code),n[L]=r,n})}else{let e=await n.json();U(e.detail||`Prefill failed.`)}}catch{U(`Prefill request failed due to connection error.`)}finally{se(!1)}}},ue=async()=>{let e=z.code||N;if(!h.trim()&&!e.trim()){U(`Please enter a problem name or code first.`);return}Y(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`intuition`,title:h,code:e,description:D})});if(n.ok){let e=await n.json();e.how_to_solve&&(ne(e.how_to_solve),B({explanation:e.how_to_solve}))}else{let e=await n.json();U(e.detail||`Failed to generate intuition.`)}}catch{U(`Intuition generator failed due to connection error.`)}finally{Y(!1)}},de=async()=>{let e=z.code||N;if(!e.trim()){U(`Please enter some Python code to format.`);return}Z(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`comments`,title:h,code:e})});if(n.ok){let e=await n.json();e.formatted_code&&(P(e.formatted_code),B({code:e.formatted_code}))}else{let e=await n.json();U(e.detail||`Failed to format code.`)}}catch{U(`Code formatter failed due to connection error.`)}finally{Z(!1)}},fe=async r=>{if(r.preventDefault(),!h.trim()){U(`Problem name cannot be empty`);return}q(!0),U(``),G(``);try{let r=await Q(),i=j.split(`
4
  `).map(e=>e.trim()).filter(Boolean),a=F.find(e=>e.is_optimal)||F[0],o=a?.pattern||y.trim()||`General`,s=a?.code||N,c=a?.explanation||te,u=C||a?.time_complexity||`O(N)`,d=T||a?.space_complexity||`O(1)`,f;if(l&&n){let e=n.id||(n.problem_number?String(n.problem_number):``)||h.trim();f=await fetch(`/api/explorer/problems/${encodeURIComponent(e)}`,{method:`PUT`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,solutions:F})})}else f=await fetch(`/api/explorer/problems/create`,{method:`POST`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,sync_to_gdoc:V,solutions:F})});let p=await f.json();f.ok&&(p.success||p.problem_id)?(G(l?`Problem updated successfully!`:`Problem saved and synced successfully!`),setTimeout(()=>{t(),e()},1e3)):U(p.detail||(l?`Failed to update problem.`:`Failed to create problem.`))}catch{U(`Connection timed out.`)}finally{q(!1)}},pe=()=>{A([...k,{input:``,output:``,explanation:``}])},me=e=>{k.length<=1||A(k.filter((t,n)=>n!==e))},$=(e,t,n)=>{let r=[...k];r[e]={...r[e],[t]:n},A(r)};return(0,a.jsxs)(`form`,{onSubmit:fe,className:`flex flex-col h-full bg-[#fdf8e1] text-ink-black font-sans overflow-hidden`,children:[(0,a.jsxs)(`div`,{className:`bg-[#f0e6c8] p-2.5 border-b-2 border-ink-black flex flex-col gap-2 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`font-arcade text-xs text-primary-purple`,children:`✦`}),(0,a.jsx)(`h2`,{className:`text-xs font-bold font-arcade tracking-tight uppercase`,children:l?`Edit Problem Specification`:`Problem & Note Studio`}),l&&(0,a.jsx)(`span`,{className:`text-[9px] bg-primary-purple/10 text-primary-purple font-mono px-1.5 py-0.5 rounded border border-primary-purple/30 font-bold`,children:`EDIT MODE`})]}),(0,a.jsxs)(`div`,{className:`flex border-2 border-ink-black bg-white rounded overflow-hidden shadow-[1px_1px_0px_#1E293B]`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`form`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`form`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`✏️ Editor`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`preview`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`preview`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`📄 Doc Preview`})]})]}),(0,a.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,a.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ce())},placeholder:`Paste LeetCode URL (e.g. https://leetcode.com/problems/two-sum/) or Title...`,className:`flex-1 bg-white border-2 border-ink-black px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-medium`}),(0,a.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ee||!f.trim(),className:`bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 text-ink-black font-arcade text-[9px] font-bold px-2.5 py-1.5 border-2 border-ink-black shadow-[1px_1px_0px_#1E293B] active:translate-y-0.5 cursor-pointer flex items-center gap-1 shrink-0`,children:[(0,a.jsx)(`span`,{children:`⚡`}),` `,ee?`FETCHING...`:`FETCH LEETCODE`]})]})]}),H&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`⚠️ `,H]}),W&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`✅ `,W]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-3 space-y-3`,children:u===`form`?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`grid grid-cols-12 gap-2`,children:[(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem #:`}),(0,a.jsx)(`input`,{type:`number`,value:_,onChange:e=>v(e.target.value===``?``:Number(e.target.value)),placeholder:`e.g. 1`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-6 flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Title:`}),(0,a.jsxs)(`button`,{type:`button`,onClick:le,disabled:oe||!h.trim()&&!z.code?.trim(),className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 flex items-center gap-1 cursor-pointer`,children:[(0,a.jsx)(`span`,{children:`✦`}),` `,oe?`...`:`AUTO-FILL`]})]}),(0,a.jsx)(`input`,{type:`text`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. Two Sum`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Difficulty:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`border-2 border-ink-black p-1.5 text-xs font-bold outline-none cursor-pointer ${x===`Easy`?`bg-emerald-100 text-emerald-900`:x===`Medium`?`bg-amber-100 text-amber-900`:`bg-rose-100 text-rose-900`}`,children:[(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 bg-[#f6edd2] p-2 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`⏱️`}),` Target Optimal Time:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`e.g. O(N)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`📦`}),` Target Optimal Space:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. O(1)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem Description:`}),(0,a.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),placeholder:`Given an array of integers nums and an integer target...`,className:`bg-white border-2 border-ink-black p-2 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-sans h-20 resize-y leading-relaxed`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5 bg-[#f6edd2] p-2.5 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`🧪`}),` Examples (`,k.length,`)`]}),(0,a.jsx)(`button`,{type:`button`,onClick:pe,className:`text-[9px] font-bold px-2 py-0.5 border border-ink-black bg-white hover:bg-slate-100 cursor-pointer shadow-[1px_1px_0px_#1E293B]`,children:`+ Add Example`})]}),k.map((e,t)=>(0,a.jsxs)(`div`,{className:`bg-white border border-ink-black p-2 space-y-1.5 rounded relative text-xs`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`span`,{className:`font-bold text-[10px] text-slate-500`,children:[`Example `,t+1,`:`]}),k.length>1&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>me(t),className:`text-[10px] text-red-600 hover:text-red-800 font-bold cursor-pointer`,children:`✕`})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,a.jsx)(`input`,{type:`text`,value:e.input,onChange:e=>$(t,`input`,e.target.value),placeholder:`Input: nums = [2,7,11,15], target = 9`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`}),(0,a.jsx)(`input`,{type:`text`,value:e.output,onChange:e=>$(t,`output`,e.target.value),placeholder:`Output: [0,1]`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`})]}),(0,a.jsx)(`input`,{type:`text`,value:e.explanation||``,onChange:e=>$(t,`explanation`,e.target.value),placeholder:`Explanation (Optional): Because nums[0] + nums[1] == 9, we return [0, 1].`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] outline-none w-full`})]},t))]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Constraints (1 per line):`}),(0,a.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`2 <= nums.length <= 10^4
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function s(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}function c({onClose:e,onSuccess:t,initialProblem:n,mode:c=n?`edit`:`create`}){let l=c===`edit`||!!n,[u,d]=(0,i.useState)(`form`),[f,p]=(0,i.useState)(``),[ee,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(()=>{if(n?.name)return n.name;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).name||``}catch{}return``}),[_,v]=(0,i.useState)(()=>n?.problem_number!==void 0&&n?.problem_number!==null?n.problem_number:``),[y,b]=(0,i.useState)(()=>{if(n?.pattern)return n.pattern;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).pattern||``}catch{}return`Arrays & Hashing`}),[x,S]=(0,i.useState)(()=>n?.difficulty===`Easy`||n?.difficulty===`Medium`||n?.difficulty===`Hard`?n.difficulty:`Medium`),[C,w]=(0,i.useState)(()=>n?.optimal_time||`O(N)`),[T,E]=(0,i.useState)(()=>n?.optimal_space||`O(1)`),[D,O]=(0,i.useState)(()=>n?.description||``),[k,A]=(0,i.useState)(()=>n?.examples&&Array.isArray(n.examples)&&n.examples.length>0?n.examples.map(e=>typeof e==`string`?{input:e,output:``,explanation:``}:{input:String(e?.input??``),output:String(e?.output??``),explanation:e?.explanation||``}):[{input:``,output:``,explanation:``}]),[j,M]=(0,i.useState)(()=>n?.constraints?Array.isArray(n.constraints)?n.constraints.join(`
2
  `):String(n.constraints):``),[te,ne]=(0,i.useState)(()=>n?.how_to_solve||``),[N,P]=(0,i.useState)(()=>{if(n?.reference_code)return n.reference_code;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).code||``}catch{}return``}),[F,I]=(0,i.useState)(()=>{if(n?.solutions&&Array.isArray(n.solutions)&&n.solutions.length>0)return n.solutions.map((e,t)=>({id:e.id||`sol-${t+1}`,name:e.name||`Method ${t+1}`,pattern:e.pattern||n.pattern||`Arrays & Hashing`,time_complexity:e.time_complexity||n.optimal_time||`O(N)`,space_complexity:e.space_complexity||n.optimal_space||`O(1)`,code:e.code||``,explanation:e.explanation||``,is_optimal:e.is_optimal??t===0}));let e=n?.reference_code||``,t=n?.pattern||`Arrays & Hashing`;try{let n=localStorage.getItem(`algospaced_prefill_draft`);if(n){let r=JSON.parse(n);r.code&&!e&&(e=r.code),r.pattern&&!t&&(t=r.pattern)}}catch{}return[{id:`sol-1`,name:`Optimal Method`,pattern:t,time_complexity:n?.optimal_time||`O(N)`,space_complexity:n?.optimal_space||`O(1)`,code:e,explanation:n?.how_to_solve||``,is_optimal:!0}]}),[L,R]=(0,i.useState)(0),z=F[L]||F[0]||{id:`sol-1`,name:`Method 1`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!0},B=e=>{I(t=>{let n=[...t],r=L<n.length?L:0;return n[r]={...n[r],...e},e.is_optimal&&(n.forEach((e,t)=>{t!==r&&(e.is_optimal=!1)}),n[r].time_complexity&&w(n[r].time_complexity),n[r].space_complexity&&E(n[r].space_complexity),n[r].pattern&&b(n[r].pattern)),n})},re=()=>{let e=F.length+1,t={id:s(),name:`Method ${e}`,pattern:y||`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:F.length===0};I(e=>[...e,t]),R(F.length)},ie=e=>{F.length<=1||(I(t=>{let n=t.filter((t,n)=>n!==e);return n.some(e=>e.is_optimal)||(n[0].is_optimal=!0),n}),L>=F.length-1&&R(Math.max(0,F.length-2)))},[V,ae]=(0,i.useState)(!0),[H,U]=(0,i.useState)(``),[W,G]=(0,i.useState)(``),[K,q]=(0,i.useState)(!1),[J,Y]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[oe,se]=(0,i.useState)(!1);i.useEffect(()=>{l||localStorage.removeItem(`algospaced_prefill_draft`)},[l]);let Q=async()=>{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,n=localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``,i=localStorage.getItem(`algospaced_custom_ai_provider`)||`default`,a={"Content-Type":`application/json`,Authorization:`Bearer ${t}`};return i&&i!=="default"&&n&&n.trim()&&(a[`x-custom-api-key`]=n.trim(),a[`x-gemini-api-key`]=n.trim(),a[`x-ai-provider`]=i),a},ce=async()=>{if(f.trim()){m(!0),U(``);try{let e=await Q(),t=await fetch(`/api/explorer/problems/fetch-leetcode`,{method:`POST`,headers:e,body:JSON.stringify({query:f.trim()})});if(t.ok){let e=await t.json();e.problem_number!==void 0&&e.problem_number!==null&&v(e.problem_number),e.title&&g(e.title),e.difficulty&&S(e.difficulty),e.pattern&&b(e.pattern),e.optimal_time&&w(e.optimal_time),e.optimal_space&&E(e.optimal_space),e.description&&O(e.description),e.how_to_solve&&ne(e.how_to_solve),e.starter_code&&!N.trim()&&P(e.starter_code),I(t=>{let n=[...t],r={...n[L]};return e.pattern&&(r.pattern=e.pattern),e.optimal_time&&(r.time_complexity=e.optimal_time),e.optimal_space&&(r.space_complexity=e.optimal_space),e.how_to_solve&&(r.explanation=e.how_to_solve),e.starter_code&&!r.code?.trim()&&(r.code=e.starter_code),n[L]=r,n}),Array.isArray(e.examples)&&e.examples.length>0&&A(e.examples),Array.isArray(e.constraints)?M(e.constraints.join(`
3
  `)):typeof e.constraints==`string`&&M(e.constraints)}else{let e=await t.json();U(e.detail||`Failed to fetch LeetCode problem data.`)}}catch{U(`Fetch request failed due to connection error.`)}finally{m(!1)}}},le=async()=>{let e=z.code||N;if(h.trim()||e.trim()){se(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/prefill`,{method:`POST`,headers:t,body:JSON.stringify({name:h,code:e})});if(n.ok){let t=await n.json();t.problem_number!==void 0&&t.problem_number!==null&&v(t.problem_number),t.title&&!h&&g(t.title),t.pattern&&b(t.pattern),t.difficulty&&S(t.difficulty),t.optimal_time&&w(t.optimal_time),t.optimal_space&&E(t.optimal_space),t.description&&O(t.description),t.reference_code&&!e.trim()&&P(t.reference_code),I(e=>{let n=[...e],r={...n[L]};return t.pattern&&(r.pattern=t.pattern),t.optimal_time&&(r.time_complexity=t.optimal_time),t.optimal_space&&(r.space_complexity=t.optimal_space),t.reference_code&&!r.code?.trim()&&(r.code=t.reference_code),n[L]=r,n})}else{let e=await n.json();U(e.detail||`Prefill failed.`)}}catch{U(`Prefill request failed due to connection error.`)}finally{se(!1)}}},ue=async()=>{let e=z.code||N;if(!h.trim()&&!e.trim()){U(`Please enter a problem name or code first.`);return}Y(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`intuition`,title:h,code:e,description:D})});if(n.ok){let e=await n.json();e.how_to_solve&&(ne(e.how_to_solve),B({explanation:e.how_to_solve}))}else{let e=await n.json();U(e.detail||`Failed to generate intuition.`)}}catch{U(`Intuition generator failed due to connection error.`)}finally{Y(!1)}},de=async()=>{let e=z.code||N;if(!e.trim()){U(`Please enter some Python code to format.`);return}Z(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`comments`,title:h,code:e})});if(n.ok){let e=await n.json();e.formatted_code&&(P(e.formatted_code),B({code:e.formatted_code}))}else{let e=await n.json();U(e.detail||`Failed to format code.`)}}catch{U(`Code formatter failed due to connection error.`)}finally{Z(!1)}},fe=async r=>{if(r.preventDefault(),!h.trim()){U(`Problem name cannot be empty`);return}q(!0),U(``),G(``);try{let r=await Q(),i=j.split(`
4
  `).map(e=>e.trim()).filter(Boolean),a=F.find(e=>e.is_optimal)||F[0],o=a?.pattern||y.trim()||`General`,s=a?.code||N,c=a?.explanation||te,u=C||a?.time_complexity||`O(N)`,d=T||a?.space_complexity||`O(1)`,f;if(l&&n){let e=n.id||(n.problem_number?String(n.problem_number):``)||h.trim();f=await fetch(`/api/explorer/problems/${encodeURIComponent(e)}`,{method:`PUT`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,solutions:F})})}else f=await fetch(`/api/explorer/problems/create`,{method:`POST`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,sync_to_gdoc:V,solutions:F})});let p=await f.json();f.ok&&(p.success||p.problem_id)?(G(l?`Problem updated successfully!`:`Problem saved and synced successfully!`),setTimeout(()=>{t(),e()},1e3)):U(p.detail||(l?`Failed to update problem.`:`Failed to create problem.`))}catch{U(`Connection timed out.`)}finally{q(!1)}},pe=()=>{A([...k,{input:``,output:``,explanation:``}])},me=e=>{k.length<=1||A(k.filter((t,n)=>n!==e))},$=(e,t,n)=>{let r=[...k];r[e]={...r[e],[t]:n},A(r)};return(0,a.jsxs)(`form`,{onSubmit:fe,className:`flex flex-col h-full bg-[#fdf8e1] text-ink-black font-sans overflow-hidden`,children:[(0,a.jsxs)(`div`,{className:`bg-[#f0e6c8] p-2.5 border-b-2 border-ink-black flex flex-col gap-2 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`font-arcade text-xs text-primary-purple`,children:`✦`}),(0,a.jsx)(`h2`,{className:`text-xs font-bold font-arcade tracking-tight uppercase`,children:l?`Edit Problem Specification`:`Problem & Note Studio`}),l&&(0,a.jsx)(`span`,{className:`text-[9px] bg-primary-purple/10 text-primary-purple font-mono px-1.5 py-0.5 rounded border border-primary-purple/30 font-bold`,children:`EDIT MODE`})]}),(0,a.jsxs)(`div`,{className:`flex border-2 border-ink-black bg-white rounded overflow-hidden shadow-[1px_1px_0px_#1E293B]`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`form`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`form`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`✏️ Editor`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`preview`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`preview`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`📄 Doc Preview`})]})]}),(0,a.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,a.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ce())},placeholder:`Paste LeetCode URL (e.g. https://leetcode.com/problems/two-sum/) or Title...`,className:`flex-1 bg-white border-2 border-ink-black px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-medium`}),(0,a.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ee||!f.trim(),className:`bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 text-ink-black font-arcade text-[9px] font-bold px-2.5 py-1.5 border-2 border-ink-black shadow-[1px_1px_0px_#1E293B] active:translate-y-0.5 cursor-pointer flex items-center gap-1 shrink-0`,children:[(0,a.jsx)(`span`,{children:`⚡`}),` `,ee?`FETCHING...`:`FETCH LEETCODE`]})]})]}),H&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`⚠️ `,H]}),W&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`✅ `,W]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-3 space-y-3`,children:u===`form`?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`grid grid-cols-12 gap-2`,children:[(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem #:`}),(0,a.jsx)(`input`,{type:`number`,value:_,onChange:e=>v(e.target.value===``?``:Number(e.target.value)),placeholder:`e.g. 1`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-6 flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Title:`}),(0,a.jsxs)(`button`,{type:`button`,onClick:le,disabled:oe||!h.trim()&&!z.code?.trim(),className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 flex items-center gap-1 cursor-pointer`,children:[(0,a.jsx)(`span`,{children:`✦`}),` `,oe?`...`:`AUTO-FILL`]})]}),(0,a.jsx)(`input`,{type:`text`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. Two Sum`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Difficulty:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`border-2 border-ink-black p-1.5 text-xs font-bold outline-none cursor-pointer ${x===`Easy`?`bg-emerald-100 text-emerald-900`:x===`Medium`?`bg-amber-100 text-amber-900`:`bg-rose-100 text-rose-900`}`,children:[(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 bg-[#f6edd2] p-2 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`⏱️`}),` Target Optimal Time:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`e.g. O(N)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`📦`}),` Target Optimal Space:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. O(1)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem Description:`}),(0,a.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),placeholder:`Given an array of integers nums and an integer target...`,className:`bg-white border-2 border-ink-black p-2 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-sans h-20 resize-y leading-relaxed`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5 bg-[#f6edd2] p-2.5 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`🧪`}),` Examples (`,k.length,`)`]}),(0,a.jsx)(`button`,{type:`button`,onClick:pe,className:`text-[9px] font-bold px-2 py-0.5 border border-ink-black bg-white hover:bg-slate-100 cursor-pointer shadow-[1px_1px_0px_#1E293B]`,children:`+ Add Example`})]}),k.map((e,t)=>(0,a.jsxs)(`div`,{className:`bg-white border border-ink-black p-2 space-y-1.5 rounded relative text-xs`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`span`,{className:`font-bold text-[10px] text-slate-500`,children:[`Example `,t+1,`:`]}),k.length>1&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>me(t),className:`text-[10px] text-red-600 hover:text-red-800 font-bold cursor-pointer`,children:`✕`})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,a.jsx)(`input`,{type:`text`,value:e.input,onChange:e=>$(t,`input`,e.target.value),placeholder:`Input: nums = [2,7,11,15], target = 9`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`}),(0,a.jsx)(`input`,{type:`text`,value:e.output,onChange:e=>$(t,`output`,e.target.value),placeholder:`Output: [0,1]`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`})]}),(0,a.jsx)(`input`,{type:`text`,value:e.explanation||``,onChange:e=>$(t,`explanation`,e.target.value),placeholder:`Explanation (Optional): Because nums[0] + nums[1] == 9, we return [0, 1].`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] outline-none w-full`})]},t))]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Constraints (1 per line):`}),(0,a.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`2 <= nums.length <= 10^4
algospaced-ui/dist/assets/{FileExplorer-DC0E1wW8.js → FileExplorer-DPdHXlvq.js} RENAMED
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[{name:`Retro Arcade Grid.img`,url:`/wallpapers/default.webp`,desc:`Default AlgoSpaced purple grid and pixel theme background.`},{name:`Classic Board Logo.img`,url:`/icons/computer.webp`,desc:`System info and arcade machine diagram wallpaper.`},{name:`Terminal Console Icon.img`,url:`/icons/terminal.webp`,desc:`Dark retro CRT terminal screen layout.`},{name:`Synthwave Sunset Grid.img`,url:`https://images.unsplash.com/photo-1550745165-9bc0b252726f?q=80&w=1000&auto=format&fit=crop`,desc:`Glowing neon grids and vector mountains styling.`},{name:`Matrix Code Rain.img`,url:`https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?q=80&w=1000&auto=format&fit=crop`,desc:`Falling green digital characters rain.`}];function s({onSetWallpaper:e,activeWallpaperUrl:t,onOpenCreateProblem:n,onOpenQueue:s,onOpenJourney:c,refreshTrigger:l}){let[u,d]=(0,i.useState)([`C:`]),[f,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!0),[g,_]=(0,i.useState)(null),v=i.useMemo(()=>{let e=[...o],t=localStorage.getItem(`customWallpaperUrl`),n=localStorage.getItem(`customWallpaperName`)||`Custom Wallpaper.img`;return t&&(e.some(e=>e.url===t)||e.push({name:n,url:t,desc:`User uploaded custom background wallpaper.`})),e},[t]),[y,ee]=(0,i.useState)(``),[b,te]=(0,i.useState)(`All`),[x,S]=(0,i.useState)(`All`),[C,w]=(0,i.useState)(!1),[ne,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(``),re=async e=>{let t=e.target.files;if(!t||t.length===0)return;let n=t[0];e.target.value=``,D(!0),k(``),j(``);try{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,i=new FormData;i.append(`file`,n);let a=await fetch(`/api/explorer/import`,{method:`POST`,headers:{Authorization:`Bearer ${t}`},body:i}),o=await a.json();a.ok?(j(o.message||`Problems imported successfully!`),setTimeout(()=>{q()},500),setTimeout(()=>{T(!1),j(``)},2e3)):k(o.detail||`Import failed. Verify the file format.`)}catch{k(`Import failed due to a network error.`)}finally{D(!1)}},[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)(`description`),[I,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(``),[B,V]=(0,i.useState)(``),[H,U]=(0,i.useState)(!1),[W,G]=(0,i.useState)(!1),[ie,K]=(0,i.useState)(!1),q=async()=>{h(!0);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();p(e)}}catch(e){console.error(`Failed to fetch explorer files:`,e)}finally{h(!1)}};(0,i.useEffect)(()=>{q()},[l]);let J=e=>{d([`C:`,e]),_(null)},ae=()=>{u.length>1&&(d([`C:`]),_(null))},oe=async()=>{try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/export`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`algospaced_solutions.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}}catch(e){console.error(`Failed to download solutions ZIP:`,e)}},se=async()=>{if(M){U(!0),G(!1);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;if((await fetch(`/api/explorer/problems/${M.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({name:M.name,pattern:M.pattern,difficulty:M.difficulty,reference_code:R,description:B})})).ok){G(!0),L(!1);let e=f.map(e=>e.id===M.id?{...e,reference_code:R,description:B}:e);p(e),N({...M,reference_code:R,description:B}),setTimeout(()=>G(!1),2e3)}}catch(e){console.error(`Failed to update solution code:`,e)}finally{U(!1)}}},ce=e=>{e.preventDefault(),w(!0)},le=()=>{w(!1)},ue=async e=>{e.preventDefault(),w(!1);let t=e.dataTransfer.files;if(t.length>0){let e=t[0];if(e.name.endsWith(`.py`))try{let t=await e.text(),r=e.name.replace(`.py`,``).replace(/_/g,` `).replace(/-/g,` `),i=`General`,a=`Medium`,o=t.match(/#\s*Pattern:\s*(.+)/i);o&&(i=o[1].trim());let s=t.match(/#\s*Difficulty:\s*(.+)/i);if(s){let e=s[1].trim();[`Easy`,`Medium`,`Hard`].includes(e)&&(a=e)}let c=t.split(`
2
  `),l=[];for(let e of c){let t=e.trim();if(t.startsWith(`#`)){if(t.match(/#\s*(Pattern|Difficulty|Problem|Description):/i))continue;l.push(t.replace(/^#\s*/,``))}else if(t!==``)break}let u=l.join(`
3
  `).trim();localStorage.setItem(`algospaced_prefill_draft`,JSON.stringify({name:r,pattern:i,difficulty:a,code:t,description:u})),n&&n()}catch(e){console.error(`Failed to parse uploaded script:`,e)}}},de=e=>{navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)},Y=u.length>1?u[1]:`root`,X=f.length,fe=f.filter(e=>e.reference_code&&e.reference_code.trim()).length,Z=X>0?Math.round(fe/X*100):0,Q={0:0,1:0,2:0,3:0};f.forEach(e=>{if(e.fsrs_state!==null&&e.fsrs_state!==void 0){let t=e.fsrs_state;t>=0&&t<=3&&Q[t]++}});let pe=Array.from(new Set(f.map(e=>e.pattern).filter(Boolean))),$=f.filter(e=>{let t=e.name.toLowerCase().includes(y.toLowerCase()),n=b===`All`||e.difficulty===b,r=x===`All`||e.pattern===x;return t&&n&&r});return(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-[3px] border-ink-black p-2 flex items-center justify-between shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,a.jsx)(`button`,{onClick:ae,disabled:u.length===1,className:`w-7 h-7 bg-white border-2 border-ink-black flex items-center justify-center hover:bg-slate-100 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer active:translate-y-0.5`,title:`Up One Folder`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[16px] font-bold`,children:`arrow_upward`})}),(0,a.jsx)(`div`,{className:`bg-white border-2 border-ink-black px-3 py-1 font-mono text-[10px] flex-1 max-w-[280px] truncate`,children:u.join(`\\`)})]}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold pr-2 font-mono items-center`,children:[Y===`Database_Codes`&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`button`,{onClick:()=>n&&n(),className:`text-blue-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`add_box`}),`NEW FILE`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:()=>T(!0),className:`text-indigo-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`upload`}),`IMPORT (.CSV / .DB)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:oe,className:`text-purple-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`downloadzip`}),`BACKUP (.ZIP)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`})]}),(0,a.jsx)(`span`,{className:`text-slate-500`,children:Y===`root`?`2 Folder(s)`:Y===`Database_Codes`?`${$.length} of ${f.length} item(s)`:`${v.length} image(s)`})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,a.jsxs)(`aside`,{className:`w-1/3 border-r-[3px] border-ink-black bg-[#fdf8e1] p-3 overflow-y-auto custom-scrollbar flex flex-col gap-4 shrink-0`,children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-1.5`,children:`Folders`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>d([`C:`]),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${u.length===1?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[#855400] text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`desktop_windows`}),(0,a.jsx)(`span`,{children:`C: (Root)`})]}),(0,a.jsxs)(`div`,{className:`pl-4 space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>J(`Database_Codes`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Database_Codes`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Database_Codes`})]}),(0,a.jsxs)(`button`,{onClick:()=>J(`Wallpapers`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Wallpapers`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Wallpapers`})]})]})]})]}),(0,a.jsxs)(`div`,{className:`border-t-2 border-dashed border-slate-300 pt-3`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-2`,children:`System Statistics`}),(0,a.jsxs)(`div`,{className:`space-y-3 font-sans text-[11px] font-bold text-slate-700`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,a.jsx)(`span`,{children:`CODE COMPLETION:`}),(0,a.jsxs)(`span`,{className:`font-mono text-emerald-600`,children:[Z,`%`]})]}),(0,a.jsx)(`div`,{className:`w-full h-4 bg-white border-2 border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${Z}%`},className:`h-full bg-emerald-500 border-r-2 border-ink-black transition-all duration-500`})})]}),(0,a.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] uppercase text-slate-500 block`,children:`FSRS Distribution:`}),[{state:0,label:`New`,color:`#3b82f6`},{state:1,label:`Learn`,color:`#f59e0b`},{state:2,label:`Review`,color:`#10b981`},{state:3,label:`Relearn`,color:`#ef4444`}].map(e=>{let t=Q[e.state],n=Math.max(...Object.values(Q),1),r=Math.max(8,Math.round(t/n*100));return(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(`span`,{className:`w-12 font-mono text-[10px] text-slate-400`,children:[e.label,`:`]}),(0,a.jsx)(`div`,{className:`flex-1 h-3 bg-white border border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${r}%`,backgroundColor:e.color},className:`h-full border-r border-ink-black transition-all`})}),(0,a.jsx)(`span`,{className:`w-4 text-right font-mono text-[10px] text-slate-600`,children:t})]},e.state)})]})]})]})]}),(0,a.jsxs)(`main`,{onDragOver:ce,onDragLeave:le,onDrop:ue,className:`flex-1 bg-white p-4 overflow-y-auto custom-scrollbar flex flex-col relative transition-all ${C?`bg-blue-50 border-4 border-dashed border-blue-500 m-2`:``}`,children:[C&&(0,a.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-blue-800 bg-white/80 pointer-events-none select-none z-[10] gap-2 font-sans font-bold`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl animate-bounce`,children:`upload_file`}),(0,a.jsx)(`div`,{className:`text-sm`,children:`DROP SOLUTIONS PYTHON SCRIPT (.PY) HERE`}),(0,a.jsx)(`p`,{className:`text-[10px] text-slate-400`,children:`Will load and parse file metadata for import`})]}),m?(0,a.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center font-arcade text-[8px] animate-pulse`,children:`READING SYSTEM DISK...`}):(0,a.jsxs)(a.Fragment,{children:[Y===`Database_Codes`&&(0,a.jsxs)(`div`,{className:`mb-4 bg-slate-50 border-[2px] border-ink-black p-2 flex flex-col gap-2 shrink-0 select-none`,children:[(0,a.jsx)(`div`,{className:`flex gap-2`,children:(0,a.jsxs)(`div`,{className:`flex-1 bg-white border border-slate-300 rounded px-2 py-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-slate-400 text-sm`,children:`search`}),(0,a.jsx)(`input`,{type:`text`,value:y,onChange:e=>ee(e.target.value),className:`w-full bg-transparent outline-none border-none p-0 text-[11px] focus:ring-0 font-sans`,placeholder:`Search codes by name...`})]})}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold text-slate-600`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`Diff:`}),(0,a.jsxs)(`select`,{value:b,onChange:e=>te(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer focus:ring-1 outline-none`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1 flex-1`,children:[(0,a.jsx)(`span`,{children:`Pattern:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer max-w-[120px] focus:ring-1 outline-none truncate`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),pe.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),Y===`root`&&(0,a.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,a.jsxs)(`div`,{onDoubleClick:()=>s&&s(),onClick:()=>_(`queue_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`queue_app`?`bg-green-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-grass-green border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-ink-black`,style:{fontVariationSettings:`'FILL' 1`},children:`view_list`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Daily_Queue.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Spaced Repetition Review`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>c&&c(),onClick:()=>_(`journey_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`journey_app`?`bg-blue-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-[#0ea5e9] border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-white`,style:{fontVariationSettings:`'FILL' 1`},children:`route`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Journey_Path.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`NeetCode 150 Road`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Database_Codes`),onClick:()=>_(`codes`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`codes`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Database_Codes`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Synced solution files`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Wallpapers`),onClick:()=>_(`wallpapers`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`wallpapers`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Wallpapers`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Desktop wallpaper images`})]})]}),Y===`Database_Codes`&&($.length===0?(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-slate-400 p-6 italic select-none`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl mb-1`,children:`drafts`}),`No matching files found. Drag and drop a .py script to upload/create!`]}):(0,a.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:$.map(e=>{let t=`${e.name.replace(/\s+/g,`_`)}.py`,n=g===e.id;return(0,a.jsxs)(`div`,{onClick:()=>_(e.id),onDoubleClick:()=>{N(e),z(e.reference_code||``),V(e.description||``),F(`description`),L(!1)},className:`flex flex-col items-center p-2 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none text-center ${n?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-emerald-600`,children:`article`}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] truncate w-full mt-1.5 leading-tight`,children:t}),(0,a.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase mt-0.5`,children:e.difficulty})]},e.id)})})),Y===`Wallpapers`&&(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 select-none`,children:v.map(n=>{let r=g===n.name,i=t===n.url;return(0,a.jsxs)(`div`,{onClick:()=>_(n.name),className:`border-[3px] p-2 flex flex-col cursor-pointer bg-slate-50 relative hover:bg-slate-100 ${r?`border-ink-black bg-yellow-50 shadow-[2px_2px_0_0_#1E293B]`:`border-slate-300`}`,children:[(0,a.jsxs)(`div`,{className:`aspect-video w-full border border-slate-300 overflow-hidden bg-black shrink-0 relative`,children:[(0,a.jsx)(`img`,{src:n.url,alt:n.name,className:`w-full h-full object-cover select-none`}),i&&(0,a.jsx)(`div`,{className:`absolute top-1 right-1 bg-green-500 text-white rounded-full w-5 h-5 flex items-center justify-center border border-white`,title:`Active Wallpaper`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-extrabold`,children:`check`})})]}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] mt-1.5 truncate`,children:n.name}),(0,a.jsx)(`p`,{className:`text-[8px] text-slate-400 font-sans leading-tight mt-0.5 line-clamp-2`,children:n.desc}),r&&(0,a.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n.url),localStorage.setItem(`desktopWallpaperUrl`,n.url)},className:`mt-2 w-full py-1 bg-highlight-pink text-white border-2 border-ink-black font-window-title font-bold text-[9px] hover:bg-pink-400 shadow-[1px_1px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none transition-all text-center cursor-pointer`,children:`APPLY BACKGROUND`})]},n.name)})})]})]})]}),M&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4`,children:(0,a.jsxs)(`div`,{className:`w-[90%] h-[90%] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black`,children:[(0,a.jsxs)(`div`,{className:`bg-emerald-600 text-white p-2 border-b-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`article`}),(0,a.jsxs)(`span`,{className:`font-window-title font-bold text-xs`,children:[M.name.replace(/\s+/g,`_`),`.py`]})]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-2 border-ink-black flex shrink-0 select-none`,children:[(0,a.jsx)(`button`,{onClick:()=>F(`description`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`description`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`PROBLEM DESCRIPTION`}),(0,a.jsx)(`button`,{onClick:()=>F(`code`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`code`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`CODE VIEW & EDIT`}),(0,a.jsx)(`button`,{onClick:()=>F(`properties`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`properties`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`FSRS PROPERTIES`})]}),P===`description`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,placeholder:`Enter problem description / question body here...`,spellCheck:`false`}):(0,a.jsx)(`div`,{className:`flex-1 p-4 bg-slate-900 text-[#4ADE80] font-sans text-xs leading-relaxed overflow-y-auto custom-scrollbar select-text`,children:(0,a.jsx)(`div`,{className:`whitespace-pre-wrap font-semibold`,children:M.description||`No description provided for this problem.`})}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`code`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}):(0,a.jsx)(`textarea`,{readOnly:!0,value:M.reference_code||`# Write your solution here.`,className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`properties`&&(0,a.jsxs)(`div`,{className:`flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4`,children:[(0,a.jsx)(`h3`,{className:`font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500`,children:`Card Diagnostics`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-[#0ea5e9] block`,children:`Scheduling Status`}),(0,a.jsxs)(`div`,{children:[`FSRS State: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-sky-600`,children:M.fsrs_state!==null&&M.fsrs_state!==void 0?M.fsrs_state===0?`New (0)`:M.fsrs_state===1?`Learning (1)`:M.fsrs_state===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,a.jsxs)(`div`,{children:[`Stability: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_stability===void 0?`0.0 days`:`${M.fsrs_stability.toFixed(1)} days`})]}),(0,a.jsxs)(`div`,{children:[`Difficulty: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_difficulty===void 0?`0.0/10`:`${M.fsrs_difficulty.toFixed(1)}/10`})]}),(0,a.jsxs)(`div`,{children:[`Next Review Date: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.next_review?new Date(M.next_review).toLocaleString():`N/A (Due)`})]}),(0,a.jsxs)(`div`,{children:[`Last Reviewed: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.last_reviewed?new Date(M.last_reviewed).toLocaleDateString():`Never`})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-emerald-600 block`,children:`Performance History`}),(0,a.jsxs)(`div`,{children:[`Total Attempts: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm`,children:M.total_attempts})]}),(0,a.jsxs)(`div`,{children:[`Times Correct: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-green-600`,children:M.times_correct})]}),(0,a.jsxs)(`div`,{children:[`Success Ratio: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-purple-700`,children:M.total_attempts>0?`${Math.round(M.times_correct/M.total_attempts*100)}%`:`0%`})]})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-1.5 text-xs font-semibold`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-400 block`,children:`Properties`}),(0,a.jsxs)(`div`,{children:[`File ID: `,(0,a.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:M.id})]}),(0,a.jsxs)(`div`,{children:[`Logical Pattern: `,(0,a.jsx)(`span`,{className:`text-blue-600`,children:M.pattern})]}),(0,a.jsxs)(`div`,{children:[`Difficulty Tag: `,(0,a.jsx)(`span`,{className:`uppercase`,children:M.difficulty})]})]})]}),(0,a.jsxs)(`div`,{className:`p-3 bg-slate-100 border-t-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsx)(`div`,{children:W&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold text-xs animate-pulse`,children:`✓ Solution saved!`})}),(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(P===`code`||P===`description`)&&(I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`button`,{onClick:()=>{z(M.reference_code||``),V(M.description||``),L(!1)},className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer`,children:`CANCEL`}),(0,a.jsx)(`button`,{disabled:H,onClick:se,className:`px-3 py-1.5 bg-[#4ADE80] hover:bg-emerald-400 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:H?`SAVING...`:`SAVE CHANGES`})]}):(0,a.jsxs)(`button`,{onClick:()=>L(!0),className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`edit`}),`EDIT FILE`]})),(0,a.jsxs)(`button`,{onClick:()=>de(I?R:M.reference_code),className:`px-3 py-1.5 bg-[#ffcc00] hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`content_copy`}),ie?`COPIED!`:`COPY CODE`]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`CLOSE`})]})]})]})}),ne&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4 select-none`,children:(0,a.jsxs)(`div`,{className:`w-[80%] max-w-[400px] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black font-sans`,children:[(0,a.jsxs)(`div`,{className:`bg-indigo-700 text-white p-2.5 border-b-[3px] border-ink-black flex justify-between items-center font-bold`,children:[(0,a.jsx)(`span`,{className:`font-window-title text-xs`,children:`IMPORT PROBLEMS`}),(0,a.jsx)(`button`,{onClick:()=>{T(!1),k(``),j(``)},className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`p-6 space-y-4`,children:[O&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[10px] font-mono leading-relaxed`,children:O}),A&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[10px] font-mono leading-relaxed`,children:A}),(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center border-4 border-dashed border-ink-black p-6 relative ${E?`bg-indigo-50 cursor-wait`:`bg-slate-50 hover:bg-slate-100 cursor-pointer`}`,children:[E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2 animate-bounce`,children:`cloud_upload`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-indigo-800 text-center`,children:`UPLOADING & PROCESSING...`}),(0,a.jsx)(`span`,{className:`text-[9px] text-indigo-600 mt-1 uppercase font-semibold text-center`,children:`Please wait, this might take a moment`})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2`,children:`upload_file`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-ink-black text-center`,children:`SELECT A CSV OR SQLite (.DB) FILE`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-1 uppercase font-semibold text-center`,children:`Imports problems & solution notes`})]}),(0,a.jsx)(`input`,{type:`file`,accept:`.csv,.db`,disabled:E,onChange:re,className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full disabled:cursor-wait`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-400 font-medium leading-normal space-y-1 font-sans`,children:[(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`CSV File:`}),` Must have a `,(0,a.jsx)(`code`,{children:`name`}),` column. Optional: `,(0,a.jsx)(`code`,{children:`problem_number`}),`, `,(0,a.jsx)(`code`,{children:`pattern`}),`, `,(0,a.jsx)(`code`,{children:`difficulty`}),`, `,(0,a.jsx)(`code`,{children:`optimal_time`}),`, `,(0,a.jsx)(`code`,{children:`optimal_space`}),`, `,(0,a.jsx)(`code`,{children:`reference_code`}),`, `,(0,a.jsx)(`code`,{children:`description`}),`.`]}),(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`SQLite DB File:`}),` Must be a standard database backup containing a `,(0,a.jsx)(`code`,{children:`problems`}),` table matching AlgoSpaced design.`]})]})]})]})})]})}export{s as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[{name:`Retro Arcade Grid.img`,url:`/wallpapers/default.webp`,desc:`Default AlgoSpaced purple grid and pixel theme background.`},{name:`Classic Board Logo.img`,url:`/icons/computer.webp`,desc:`System info and arcade machine diagram wallpaper.`},{name:`Terminal Console Icon.img`,url:`/icons/terminal.webp`,desc:`Dark retro CRT terminal screen layout.`},{name:`Synthwave Sunset Grid.img`,url:`https://images.unsplash.com/photo-1550745165-9bc0b252726f?q=80&w=1000&auto=format&fit=crop`,desc:`Glowing neon grids and vector mountains styling.`},{name:`Matrix Code Rain.img`,url:`https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?q=80&w=1000&auto=format&fit=crop`,desc:`Falling green digital characters rain.`}];function s({onSetWallpaper:e,activeWallpaperUrl:t,onOpenCreateProblem:n,onOpenQueue:s,onOpenJourney:c,refreshTrigger:l}){let[u,d]=(0,i.useState)([`C:`]),[f,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!0),[g,_]=(0,i.useState)(null),v=i.useMemo(()=>{let e=[...o],t=localStorage.getItem(`customWallpaperUrl`),n=localStorage.getItem(`customWallpaperName`)||`Custom Wallpaper.img`;return t&&(e.some(e=>e.url===t)||e.push({name:n,url:t,desc:`User uploaded custom background wallpaper.`})),e},[t]),[y,ee]=(0,i.useState)(``),[b,te]=(0,i.useState)(`All`),[x,S]=(0,i.useState)(`All`),[C,w]=(0,i.useState)(!1),[ne,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(``),re=async e=>{let t=e.target.files;if(!t||t.length===0)return;let n=t[0];e.target.value=``,D(!0),k(``),j(``);try{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,i=new FormData;i.append(`file`,n);let a=await fetch(`/api/explorer/import`,{method:`POST`,headers:{Authorization:`Bearer ${t}`},body:i}),o=await a.json();a.ok?(j(o.message||`Problems imported successfully!`),setTimeout(()=>{q()},500),setTimeout(()=>{T(!1),j(``)},2e3)):k(o.detail||`Import failed. Verify the file format.`)}catch{k(`Import failed due to a network error.`)}finally{D(!1)}},[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)(`description`),[I,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(``),[B,V]=(0,i.useState)(``),[H,U]=(0,i.useState)(!1),[W,G]=(0,i.useState)(!1),[ie,K]=(0,i.useState)(!1),q=async()=>{h(!0);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();p(e)}}catch(e){console.error(`Failed to fetch explorer files:`,e)}finally{h(!1)}};(0,i.useEffect)(()=>{q()},[l]);let J=e=>{d([`C:`,e]),_(null)},ae=()=>{u.length>1&&(d([`C:`]),_(null))},oe=async()=>{try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/export`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`algospaced_solutions.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}}catch(e){console.error(`Failed to download solutions ZIP:`,e)}},se=async()=>{if(M){U(!0),G(!1);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;if((await fetch(`/api/explorer/problems/${M.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({name:M.name,pattern:M.pattern,difficulty:M.difficulty,reference_code:R,description:B})})).ok){G(!0),L(!1);let e=f.map(e=>e.id===M.id?{...e,reference_code:R,description:B}:e);p(e),N({...M,reference_code:R,description:B}),setTimeout(()=>G(!1),2e3)}}catch(e){console.error(`Failed to update solution code:`,e)}finally{U(!1)}}},ce=e=>{e.preventDefault(),w(!0)},le=()=>{w(!1)},ue=async e=>{e.preventDefault(),w(!1);let t=e.dataTransfer.files;if(t.length>0){let e=t[0];if(e.name.endsWith(`.py`))try{let t=await e.text(),r=e.name.replace(`.py`,``).replace(/_/g,` `).replace(/-/g,` `),i=`General`,a=`Medium`,o=t.match(/#\s*Pattern:\s*(.+)/i);o&&(i=o[1].trim());let s=t.match(/#\s*Difficulty:\s*(.+)/i);if(s){let e=s[1].trim();[`Easy`,`Medium`,`Hard`].includes(e)&&(a=e)}let c=t.split(`
2
  `),l=[];for(let e of c){let t=e.trim();if(t.startsWith(`#`)){if(t.match(/#\s*(Pattern|Difficulty|Problem|Description):/i))continue;l.push(t.replace(/^#\s*/,``))}else if(t!==``)break}let u=l.join(`
3
  `).trim();localStorage.setItem(`algospaced_prefill_draft`,JSON.stringify({name:r,pattern:i,difficulty:a,code:t,description:u})),n&&n()}catch(e){console.error(`Failed to parse uploaded script:`,e)}}},de=e=>{navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)},Y=u.length>1?u[1]:`root`,X=f.length,fe=f.filter(e=>e.reference_code&&e.reference_code.trim()).length,Z=X>0?Math.round(fe/X*100):0,Q={0:0,1:0,2:0,3:0};f.forEach(e=>{if(e.fsrs_state!==null&&e.fsrs_state!==void 0){let t=e.fsrs_state;t>=0&&t<=3&&Q[t]++}});let pe=Array.from(new Set(f.map(e=>e.pattern).filter(Boolean))),$=f.filter(e=>{let t=e.name.toLowerCase().includes(y.toLowerCase()),n=b===`All`||e.difficulty===b,r=x===`All`||e.pattern===x;return t&&n&&r});return(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-[3px] border-ink-black p-2 flex items-center justify-between shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,a.jsx)(`button`,{onClick:ae,disabled:u.length===1,className:`w-7 h-7 bg-white border-2 border-ink-black flex items-center justify-center hover:bg-slate-100 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer active:translate-y-0.5`,title:`Up One Folder`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[16px] font-bold`,children:`arrow_upward`})}),(0,a.jsx)(`div`,{className:`bg-white border-2 border-ink-black px-3 py-1 font-mono text-[10px] flex-1 max-w-[280px] truncate`,children:u.join(`\\`)})]}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold pr-2 font-mono items-center`,children:[Y===`Database_Codes`&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`button`,{onClick:()=>n&&n(),className:`text-blue-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`add_box`}),`NEW FILE`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:()=>T(!0),className:`text-indigo-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`upload`}),`IMPORT (.CSV / .DB)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:oe,className:`text-purple-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`downloadzip`}),`BACKUP (.ZIP)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`})]}),(0,a.jsx)(`span`,{className:`text-slate-500`,children:Y===`root`?`2 Folder(s)`:Y===`Database_Codes`?`${$.length} of ${f.length} item(s)`:`${v.length} image(s)`})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,a.jsxs)(`aside`,{className:`w-1/3 border-r-[3px] border-ink-black bg-[#fdf8e1] p-3 overflow-y-auto custom-scrollbar flex flex-col gap-4 shrink-0`,children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-1.5`,children:`Folders`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>d([`C:`]),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${u.length===1?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[#855400] text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`desktop_windows`}),(0,a.jsx)(`span`,{children:`C: (Root)`})]}),(0,a.jsxs)(`div`,{className:`pl-4 space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>J(`Database_Codes`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Database_Codes`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Database_Codes`})]}),(0,a.jsxs)(`button`,{onClick:()=>J(`Wallpapers`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Wallpapers`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Wallpapers`})]})]})]})]}),(0,a.jsxs)(`div`,{className:`border-t-2 border-dashed border-slate-300 pt-3`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-2`,children:`System Statistics`}),(0,a.jsxs)(`div`,{className:`space-y-3 font-sans text-[11px] font-bold text-slate-700`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,a.jsx)(`span`,{children:`CODE COMPLETION:`}),(0,a.jsxs)(`span`,{className:`font-mono text-emerald-600`,children:[Z,`%`]})]}),(0,a.jsx)(`div`,{className:`w-full h-4 bg-white border-2 border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${Z}%`},className:`h-full bg-emerald-500 border-r-2 border-ink-black transition-all duration-500`})})]}),(0,a.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] uppercase text-slate-500 block`,children:`FSRS Distribution:`}),[{state:0,label:`New`,color:`#3b82f6`},{state:1,label:`Learn`,color:`#f59e0b`},{state:2,label:`Review`,color:`#10b981`},{state:3,label:`Relearn`,color:`#ef4444`}].map(e=>{let t=Q[e.state],n=Math.max(...Object.values(Q),1),r=Math.max(8,Math.round(t/n*100));return(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(`span`,{className:`w-12 font-mono text-[10px] text-slate-400`,children:[e.label,`:`]}),(0,a.jsx)(`div`,{className:`flex-1 h-3 bg-white border border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${r}%`,backgroundColor:e.color},className:`h-full border-r border-ink-black transition-all`})}),(0,a.jsx)(`span`,{className:`w-4 text-right font-mono text-[10px] text-slate-600`,children:t})]},e.state)})]})]})]})]}),(0,a.jsxs)(`main`,{onDragOver:ce,onDragLeave:le,onDrop:ue,className:`flex-1 bg-white p-4 overflow-y-auto custom-scrollbar flex flex-col relative transition-all ${C?`bg-blue-50 border-4 border-dashed border-blue-500 m-2`:``}`,children:[C&&(0,a.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-blue-800 bg-white/80 pointer-events-none select-none z-[10] gap-2 font-sans font-bold`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl animate-bounce`,children:`upload_file`}),(0,a.jsx)(`div`,{className:`text-sm`,children:`DROP SOLUTIONS PYTHON SCRIPT (.PY) HERE`}),(0,a.jsx)(`p`,{className:`text-[10px] text-slate-400`,children:`Will load and parse file metadata for import`})]}),m?(0,a.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center font-arcade text-[8px] animate-pulse`,children:`READING SYSTEM DISK...`}):(0,a.jsxs)(a.Fragment,{children:[Y===`Database_Codes`&&(0,a.jsxs)(`div`,{className:`mb-4 bg-slate-50 border-[2px] border-ink-black p-2 flex flex-col gap-2 shrink-0 select-none`,children:[(0,a.jsx)(`div`,{className:`flex gap-2`,children:(0,a.jsxs)(`div`,{className:`flex-1 bg-white border border-slate-300 rounded px-2 py-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-slate-400 text-sm`,children:`search`}),(0,a.jsx)(`input`,{type:`text`,value:y,onChange:e=>ee(e.target.value),className:`w-full bg-transparent outline-none border-none p-0 text-[11px] focus:ring-0 font-sans`,placeholder:`Search codes by name...`})]})}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold text-slate-600`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`Diff:`}),(0,a.jsxs)(`select`,{value:b,onChange:e=>te(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer focus:ring-1 outline-none`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1 flex-1`,children:[(0,a.jsx)(`span`,{children:`Pattern:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer max-w-[120px] focus:ring-1 outline-none truncate`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),pe.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),Y===`root`&&(0,a.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,a.jsxs)(`div`,{onDoubleClick:()=>s&&s(),onClick:()=>_(`queue_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`queue_app`?`bg-green-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-grass-green border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-ink-black`,style:{fontVariationSettings:`'FILL' 1`},children:`view_list`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Daily_Queue.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Spaced Repetition Review`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>c&&c(),onClick:()=>_(`journey_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`journey_app`?`bg-blue-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-[#0ea5e9] border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-white`,style:{fontVariationSettings:`'FILL' 1`},children:`route`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Journey_Path.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`NeetCode 150 Road`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Database_Codes`),onClick:()=>_(`codes`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`codes`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Database_Codes`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Synced solution files`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Wallpapers`),onClick:()=>_(`wallpapers`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`wallpapers`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Wallpapers`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Desktop wallpaper images`})]})]}),Y===`Database_Codes`&&($.length===0?(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-slate-400 p-6 italic select-none`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl mb-1`,children:`drafts`}),`No matching files found. Drag and drop a .py script to upload/create!`]}):(0,a.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:$.map(e=>{let t=`${e.name.replace(/\s+/g,`_`)}.py`,n=g===e.id;return(0,a.jsxs)(`div`,{onClick:()=>_(e.id),onDoubleClick:()=>{N(e),z(e.reference_code||``),V(e.description||``),F(`description`),L(!1)},className:`flex flex-col items-center p-2 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none text-center ${n?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-emerald-600`,children:`article`}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] truncate w-full mt-1.5 leading-tight`,children:t}),(0,a.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase mt-0.5`,children:e.difficulty})]},e.id)})})),Y===`Wallpapers`&&(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 select-none`,children:v.map(n=>{let r=g===n.name,i=t===n.url;return(0,a.jsxs)(`div`,{onClick:()=>_(n.name),className:`border-[3px] p-2 flex flex-col cursor-pointer bg-slate-50 relative hover:bg-slate-100 ${r?`border-ink-black bg-yellow-50 shadow-[2px_2px_0_0_#1E293B]`:`border-slate-300`}`,children:[(0,a.jsxs)(`div`,{className:`aspect-video w-full border border-slate-300 overflow-hidden bg-black shrink-0 relative`,children:[(0,a.jsx)(`img`,{src:n.url,alt:n.name,className:`w-full h-full object-cover select-none`}),i&&(0,a.jsx)(`div`,{className:`absolute top-1 right-1 bg-green-500 text-white rounded-full w-5 h-5 flex items-center justify-center border border-white`,title:`Active Wallpaper`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-extrabold`,children:`check`})})]}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] mt-1.5 truncate`,children:n.name}),(0,a.jsx)(`p`,{className:`text-[8px] text-slate-400 font-sans leading-tight mt-0.5 line-clamp-2`,children:n.desc}),r&&(0,a.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n.url),localStorage.setItem(`desktopWallpaperUrl`,n.url)},className:`mt-2 w-full py-1 bg-highlight-pink text-white border-2 border-ink-black font-window-title font-bold text-[9px] hover:bg-pink-400 shadow-[1px_1px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none transition-all text-center cursor-pointer`,children:`APPLY BACKGROUND`})]},n.name)})})]})]})]}),M&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4`,children:(0,a.jsxs)(`div`,{className:`w-[90%] h-[90%] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black`,children:[(0,a.jsxs)(`div`,{className:`bg-emerald-600 text-white p-2 border-b-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`article`}),(0,a.jsxs)(`span`,{className:`font-window-title font-bold text-xs`,children:[M.name.replace(/\s+/g,`_`),`.py`]})]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-2 border-ink-black flex shrink-0 select-none`,children:[(0,a.jsx)(`button`,{onClick:()=>F(`description`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`description`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`PROBLEM DESCRIPTION`}),(0,a.jsx)(`button`,{onClick:()=>F(`code`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`code`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`CODE VIEW & EDIT`}),(0,a.jsx)(`button`,{onClick:()=>F(`properties`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`properties`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`FSRS PROPERTIES`})]}),P===`description`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,placeholder:`Enter problem description / question body here...`,spellCheck:`false`}):(0,a.jsx)(`div`,{className:`flex-1 p-4 bg-slate-900 text-[#4ADE80] font-sans text-xs leading-relaxed overflow-y-auto custom-scrollbar select-text`,children:(0,a.jsx)(`div`,{className:`whitespace-pre-wrap font-semibold`,children:M.description||`No description provided for this problem.`})}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`code`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}):(0,a.jsx)(`textarea`,{readOnly:!0,value:M.reference_code||`# Write your solution here.`,className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`properties`&&(0,a.jsxs)(`div`,{className:`flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4`,children:[(0,a.jsx)(`h3`,{className:`font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500`,children:`Card Diagnostics`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-[#0ea5e9] block`,children:`Scheduling Status`}),(0,a.jsxs)(`div`,{children:[`FSRS State: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-sky-600`,children:M.fsrs_state!==null&&M.fsrs_state!==void 0?M.fsrs_state===0?`New (0)`:M.fsrs_state===1?`Learning (1)`:M.fsrs_state===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,a.jsxs)(`div`,{children:[`Stability: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_stability===void 0?`0.0 days`:`${M.fsrs_stability.toFixed(1)} days`})]}),(0,a.jsxs)(`div`,{children:[`Difficulty: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_difficulty===void 0?`0.0/10`:`${M.fsrs_difficulty.toFixed(1)}/10`})]}),(0,a.jsxs)(`div`,{children:[`Next Review Date: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.next_review?new Date(M.next_review).toLocaleString():`N/A (Due)`})]}),(0,a.jsxs)(`div`,{children:[`Last Reviewed: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.last_reviewed?new Date(M.last_reviewed).toLocaleDateString():`Never`})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-emerald-600 block`,children:`Performance History`}),(0,a.jsxs)(`div`,{children:[`Total Attempts: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm`,children:M.total_attempts})]}),(0,a.jsxs)(`div`,{children:[`Times Correct: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-green-600`,children:M.times_correct})]}),(0,a.jsxs)(`div`,{children:[`Success Ratio: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-purple-700`,children:M.total_attempts>0?`${Math.round(M.times_correct/M.total_attempts*100)}%`:`0%`})]})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-1.5 text-xs font-semibold`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-400 block`,children:`Properties`}),(0,a.jsxs)(`div`,{children:[`File ID: `,(0,a.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:M.id})]}),(0,a.jsxs)(`div`,{children:[`Logical Pattern: `,(0,a.jsx)(`span`,{className:`text-blue-600`,children:M.pattern})]}),(0,a.jsxs)(`div`,{children:[`Difficulty Tag: `,(0,a.jsx)(`span`,{className:`uppercase`,children:M.difficulty})]})]})]}),(0,a.jsxs)(`div`,{className:`p-3 bg-slate-100 border-t-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsx)(`div`,{children:W&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold text-xs animate-pulse`,children:`✓ Solution saved!`})}),(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(P===`code`||P===`description`)&&(I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`button`,{onClick:()=>{z(M.reference_code||``),V(M.description||``),L(!1)},className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer`,children:`CANCEL`}),(0,a.jsx)(`button`,{disabled:H,onClick:se,className:`px-3 py-1.5 bg-[#4ADE80] hover:bg-emerald-400 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:H?`SAVING...`:`SAVE CHANGES`})]}):(0,a.jsxs)(`button`,{onClick:()=>L(!0),className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`edit`}),`EDIT FILE`]})),(0,a.jsxs)(`button`,{onClick:()=>de(I?R:M.reference_code),className:`px-3 py-1.5 bg-[#ffcc00] hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`content_copy`}),ie?`COPIED!`:`COPY CODE`]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`CLOSE`})]})]})]})}),ne&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4 select-none`,children:(0,a.jsxs)(`div`,{className:`w-[80%] max-w-[400px] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black font-sans`,children:[(0,a.jsxs)(`div`,{className:`bg-indigo-700 text-white p-2.5 border-b-[3px] border-ink-black flex justify-between items-center font-bold`,children:[(0,a.jsx)(`span`,{className:`font-window-title text-xs`,children:`IMPORT PROBLEMS`}),(0,a.jsx)(`button`,{onClick:()=>{T(!1),k(``),j(``)},className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`p-6 space-y-4`,children:[O&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[10px] font-mono leading-relaxed`,children:O}),A&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[10px] font-mono leading-relaxed`,children:A}),(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center border-4 border-dashed border-ink-black p-6 relative ${E?`bg-indigo-50 cursor-wait`:`bg-slate-50 hover:bg-slate-100 cursor-pointer`}`,children:[E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2 animate-bounce`,children:`cloud_upload`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-indigo-800 text-center`,children:`UPLOADING & PROCESSING...`}),(0,a.jsx)(`span`,{className:`text-[9px] text-indigo-600 mt-1 uppercase font-semibold text-center`,children:`Please wait, this might take a moment`})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2`,children:`upload_file`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-ink-black text-center`,children:`SELECT A CSV OR SQLite (.DB) FILE`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-1 uppercase font-semibold text-center`,children:`Imports problems & solution notes`})]}),(0,a.jsx)(`input`,{type:`file`,accept:`.csv,.db`,disabled:E,onChange:re,className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full disabled:cursor-wait`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-400 font-medium leading-normal space-y-1 font-sans`,children:[(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`CSV File:`}),` Must have a `,(0,a.jsx)(`code`,{children:`name`}),` column. Optional: `,(0,a.jsx)(`code`,{children:`problem_number`}),`, `,(0,a.jsx)(`code`,{children:`pattern`}),`, `,(0,a.jsx)(`code`,{children:`difficulty`}),`, `,(0,a.jsx)(`code`,{children:`optimal_time`}),`, `,(0,a.jsx)(`code`,{children:`optimal_space`}),`, `,(0,a.jsx)(`code`,{children:`reference_code`}),`, `,(0,a.jsx)(`code`,{children:`description`}),`.`]}),(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`SQLite DB File:`}),` Must be a standard database backup containing a `,(0,a.jsx)(`code`,{children:`problems`}),` table matching AlgoSpaced design.`]})]})]})]})})]})}export{s as default};
algospaced-ui/dist/assets/GitHubSyncWindow-Bv5jA_W2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dt as t,F as n,J as r,Mt as i,Qt as a,Tt as o,Xt as s,a as c,bt as l,dt as u,ft as d,it as f,ot as p,rt as m,ut as h}from"./vendor-react-oIjZMgNV.js";import{a as g,c as _,i as v,l as y,n as b,o as x,r as S,s as C,t as w}from"./githubSyncService-x0Mm_uEl.js";var T=e(a(),1),E=s(),D=({onClose:e,currentProblem:a})=>{let[s,D]=(0,T.useState)(()=>S()),[O,k]=(0,T.useState)(()=>v()),[A,j]=(0,T.useState)(``),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),[I,L]=(0,T.useState)(!1),[R,z]=(0,T.useState)(!1),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(!1),[K,q]=(0,T.useState)(null),J=!!(s.token&&(s.username||O?.login));(0,T.useEffect)(()=>{s.token&&!O&&y(s.token).then(e=>{e.valid&&e.user&&(k(e.user),C({username:e.user.login},e.user))})},[s.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await b();k(t);let n=S();D(n);try{await g(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 y(e);if(t.valid&&t.user){k(t.user),C({token:e,username:t.user.login},t.user),D(S());try{await g(e,s.repoName,s.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(s.token){V(!0),q(null);try{let e=await g(s.token,s.repoName,s.isPrivate);C({repoName:s.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(s.token&&s.repoName){U(!0),q(null);try{let e=await _(s.token,s.repoName,s.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${s.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!a||!s.token)return;let e=a.code||a.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 t={token:s.token,repo:s.repoName,branch:s.branch,problem_number:a.problem_number,problem_name:a.name||`Algorithm Problem`,difficulty:a.difficulty||`Medium`,pattern:a.pattern||`Algorithms`,optimal_time:a.optimal_time||`O(N)`,optimal_space:a.optimal_space||`O(1)`,description:a.description||``,code:e},n=await x(t);q({type:`success`,text:`Committed ${a.name} to GitHub!`,linkUrl:n.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{C({autoCommit:e}),D(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,E.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,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.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,E.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,E.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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,E.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,E.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,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.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,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,E.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,E.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,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||s.username}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||s.username,`)`]})]}),(0,E.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,E.jsx)(p,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,E.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[s.username||O?.login,`/`,s.repoName]}),(0,E.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,s.branch,`)`]})]})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`a`,{href:`https://github.com/${s.username||O?.login}/${s.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,E.jsx)(d,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`View Repo`})]}),(0,E.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(w(),D(S()),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,E.jsx)(r,{className:`w-3 h-3`}),(0,E.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,E.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,E.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(f,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,E.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,E.jsx)(n,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(i,{className:`w-3 h-3 text-emerald-700`}),(0,E.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,E.jsx)(`input`,{type:`text`,value:s.repoName,onChange:e=>{let t=e.target.value;D(e=>({...e,repoName:t})),C({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,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,E.jsx)(`input`,{type:`text`,value:s.branch,onChange:e=>{let t=e.target.value;D(e=>({...e,branch:t})),C({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,E.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,E.jsx)(c,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,E.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,E.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:s.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,E.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,E.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,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(l,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`button`,{onClick:$,disabled:W||!a,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,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,E.jsx)(m,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),a?.problem_number&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,a.problem_number]})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:a?.name||`No active problem open in review`})]}),(0,E.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,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,E.jsx)(p,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,E.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,E.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.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,E.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,E.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,E.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,E.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,E.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(n,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,E.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,E.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,E.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,E.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,E.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,E.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,E.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,E.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,E.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,E.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,E.jsx)(`span`,{children:`Generate token with repo scope`}),(0,E.jsx)(d,{className:`w-3 h-3`})]})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.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,E.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,E.jsx)(u,{className:`w-3.5 h-3.5`}):(0,E.jsx)(h,{className:`w-3.5 h-3.5`})})]}),(0,E.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(i,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,E.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,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,E.jsx)(o,{className:`w-4 h-4 shrink-0`}):(0,E.jsx)(t,{className:`w-4 h-4 shrink-0`}),(0,E.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,E.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,E.jsx)(`span`,{children:`Open`}),(0,E.jsx)(d,{className:`w-3 h-3`})]})]})]}),(0,E.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,E.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{D as GitHubSyncWindow,D as default};
algospaced-ui/dist/assets/GitHubSyncWindow-Xyx5vxzj.js DELETED
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{H as t,Q as n,Vt as r,X as i,Y as a,bt as o,ct as s,et as c,ht as l,i as u,j as d,nt as f,pt as p,tt as m,zt as h}from"./vendor-react-CDF1pnIM.js";import{a as g,c as _,i as v,l as y,n as b,o as x,r as S,s as C,t as w}from"./githubSyncService-x0Mm_uEl.js";var T=e(r(),1),E=h(),D=({onClose:e,currentProblem:r})=>{let[h,D]=(0,T.useState)(()=>S()),[O,k]=(0,T.useState)(()=>v()),[A,j]=(0,T.useState)(``),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),[I,L]=(0,T.useState)(!1),[R,z]=(0,T.useState)(!1),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(!1),[K,q]=(0,T.useState)(null),J=!!(h.token&&(h.username||O?.login));(0,T.useEffect)(()=>{h.token&&!O&&y(h.token).then(e=>{e.valid&&e.user&&(k(e.user),C({username:e.user.login},e.user))})},[h.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await b();k(t);let n=S();D(n);try{await g(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 y(e);if(t.valid&&t.user){k(t.user),C({token:e,username:t.user.login},t.user),D(S());try{await g(e,h.repoName,h.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(h.token){V(!0),q(null);try{let e=await g(h.token,h.repoName,h.isPrivate);C({repoName:h.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(h.token&&h.repoName){U(!0),q(null);try{let e=await _(h.token,h.repoName,h.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${h.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!r||!h.token)return;let e=r.code||r.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 t={token:h.token,repo:h.repoName,branch:h.branch,problem_number:r.problem_number,problem_name:r.name||`Algorithm Problem`,difficulty:r.difficulty||`Medium`,pattern:r.pattern||`Algorithms`,optimal_time:r.optimal_time||`O(N)`,optimal_space:r.optimal_space||`O(1)`,description:r.description||``,code:e},n=await x(t);q({type:`success`,text:`Committed ${r.name} to GitHub!`,linkUrl:n.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{C({autoCommit:e}),D(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,E.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,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.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,E.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,E.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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,E.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,E.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,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.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,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,E.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,E.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,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||h.username}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||h.username,`)`]})]}),(0,E.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,E.jsx)(n,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,E.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[h.username||O?.login,`/`,h.repoName]}),(0,E.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,h.branch,`)`]})]})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`a`,{href:`https://github.com/${h.username||O?.login}/${h.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,E.jsx)(f,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`View Repo`})]}),(0,E.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(w(),D(S()),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,E.jsx)(t,{className:`w-3 h-3`}),(0,E.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,E.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,E.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(i,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,E.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,E.jsx)(d,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(o,{className:`w-3 h-3 text-emerald-700`}),(0,E.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,E.jsx)(`input`,{type:`text`,value:h.repoName,onChange:e=>{let t=e.target.value;D(e=>({...e,repoName:t})),C({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,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,E.jsx)(`input`,{type:`text`,value:h.branch,onChange:e=>{let t=e.target.value;D(e=>({...e,branch:t})),C({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,E.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,E.jsx)(u,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,E.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,E.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:h.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,E.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,E.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,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(s,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`button`,{onClick:$,disabled:W||!r,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,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,E.jsx)(d,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,E.jsx)(a,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),r?.problem_number&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,r.problem_number]})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:r?.name||`No active problem open in review`})]}),(0,E.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,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,E.jsx)(d,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,E.jsx)(n,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,E.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,E.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.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,E.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,E.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,E.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,E.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,E.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(d,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,E.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,E.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,E.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,E.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,E.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,E.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,E.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,E.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,E.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,E.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,E.jsx)(`span`,{children:`Generate token with repo scope`}),(0,E.jsx)(f,{className:`w-3 h-3`})]})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.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,E.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,E.jsx)(m,{className:`w-3.5 h-3.5`}):(0,E.jsx)(c,{className:`w-3.5 h-3.5`})})]}),(0,E.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(d,{className:`w-3.5 h-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(o,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,E.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,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,E.jsx)(p,{className:`w-4 h-4 shrink-0`}):(0,E.jsx)(l,{className:`w-4 h-4 shrink-0`}),(0,E.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,E.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,E.jsx)(`span`,{children:`Open`}),(0,E.jsx)(f,{className:`w-3 h-3`})]})]})]}),(0,E.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,E.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{D as GitHubSyncWindow,D as default};
 
 
algospaced-ui/dist/assets/{JourneyPath-S1uJQhTl.js → JourneyPath-DzueA_V1.js} RENAMED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/{KatexRenderer-CfYwRkzO.js → KatexRenderer-NjsEFKtT.js} RENAMED
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{Vt as e,zt as t}from"./vendor-react-CDF1pnIM.js";import{t as n}from"./vendor-katex-Balf574a.js";e();var r=t(),i=({math:e,displayMode:t=!1,className:i=``})=>{let a=``;try{a=n.renderToString(e.trim(),{displayMode:t,throwOnError:!1,output:`html`})}catch{a=`<span class="katex-error text-rose-600 font-mono text-[11px]">${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</span>`}return(0,r.jsx)(`span`,{className:i,dangerouslySetInnerHTML:{__html:a}})};export{i as KatexRenderer,i as default};
 
1
+ import"./rolldown-runtime-hePW80VL.js";import{Qt as e,Xt as t}from"./vendor-react-oIjZMgNV.js";import{t as n}from"./vendor-katex-Balf574a.js";e();var r=t(),i=({math:e,displayMode:t=!1,className:i=``})=>{let a=``;try{a=n.renderToString(e.trim(),{displayMode:t,throwOnError:!1,output:`html`})}catch{a=`<span class="katex-error text-rose-600 font-mono text-[11px]">${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</span>`}return(0,r.jsx)(`span`,{className:i,dangerouslySetInnerHTML:{__html:a}})};export{i as KatexRenderer,i as default};
algospaced-ui/dist/assets/{MarkdownRenderer-AdFp0pUP.js → MarkdownRenderer-B_9j9AKs.js} RENAMED
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KatexRenderer-CfYwRkzO.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-CDF1pnIM.js","assets/vendor-codemirror-By0wlJeM.js","assets/vendor-katex-Balf574a.js","assets/vendor-katex-DtkCqjBQ.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{t as r}from"./index-DX2cztXb.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-CfYwRkzO.js`),__vite__mapDeps([0,1,2,3,4,5])));function s(e){return e?e.split(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\([\s\S]*?\\\)|\$(?:\\\$|[^$\n])+?\$|`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|(?<!\*)\*[^*\n]+(?<!\*)\*|(?<!_)_[^_\n]+(?<!_)_|\[[^\]\n]+\]\([^)\n]+\))/g).map((e,t)=>{if(!e)return null;if(e.startsWith(`$$`)&&e.endsWith(`$$`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\[`)&&e.endsWith(`\\]`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\(`)&&e.endsWith(`\\)`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith(`$`)&&e.endsWith(`$`)&&e.length>=2){let n=e.slice(1,-1);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith("`")&&e.endsWith("`")&&e.length>=2)return(0,a.jsx)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] px-1.5 py-0.5 rounded text-[11px] font-mono border border-ink-black shadow-[1px_1px_0px_0px_#000]`,children:e.slice(1,-1)},t);if(e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>=4||e.startsWith(`__`)&&e.endsWith(`__`)&&e.length>=4)return(0,a.jsx)(`strong`,{className:`text-ink-black font-extrabold`,children:s(e.slice(2,-2))},t);if(e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>=2||e.startsWith(`_`)&&e.endsWith(`_`)&&e.length>=2)return(0,a.jsx)(`em`,{className:`italic text-slate-800`,children:s(e.slice(1,-1))},t);let n=e.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return n?(0,a.jsx)(`a`,{href:n[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80 font-bold`,children:n[1]},t):e}):[]}var c=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-CfYwRkzO.js`),__vite__mapDeps([0,1,2,3,4,5]))),l=({content:e,className:t=``})=>{if(!e)return null;let n=e.split(/(```[\s\S]*?```|\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\])/g);return(0,a.jsx)(`div`,{className:`markdown-content space-y-2.5 text-ink-black text-xs leading-relaxed font-sans ${t}`,children:n.map((e,t)=>{if(!e)return null;let n=e.trim();if(n.startsWith("```")&&n.endsWith("```")&&n.length>=6){let e=n.indexOf(`
3
  `),r=e===-1?``:n.slice(3,e).trim(),i=e===-1?n.slice(3,-3).trim():n.slice(e+1,-3).trimEnd();return(0,a.jsxs)(`div`,{className:`my-3 rounded-md overflow-hidden border-[2px] border-ink-black shadow-[3px_3px_0px_0px_#1E293B] bg-[#1E293B]`,children:[r&&(0,a.jsxs)(`div`,{className:`bg-slate-800 text-slate-400 px-3 py-1 text-[9px] font-arcade uppercase tracking-wider border-b border-slate-700 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:r}),(0,a.jsx)(`span`,{className:`text-[8px] opacity-70`,children:`SNIPPET`})]}),(0,a.jsx)(`pre`,{className:`p-3 overflow-x-auto font-mono text-[11px] text-[#4ADE80] leading-relaxed custom-scrollbar selection:bg-[#4ADE80] selection:text-[#1E293B]`,children:(0,a.jsx)(`code`,{children:i})})]},`code-${t}`)}if(n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4||n.startsWith(`\\[`)&&n.endsWith(`\\]`)&&n.length>=4){let e=n.slice(2,-2);return(0,a.jsx)(`div`,{className:`my-3 p-3 bg-slate-50 border-2 border-ink-black rounded overflow-x-auto text-center shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] custom-scrollbar`,children:(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:e}),children:(0,a.jsx)(c,{math:e,displayMode:!0})})},`math-${t}`)}let r=e.split(`
4
  `),o=[],l=0;for(;l<r.length;){let e=r[l],n=e.trim(),i=`${t}-${l}`;if(n===``){o.push((0,a.jsx)(`div`,{className:`h-1`},i)),l++;continue}if(n.startsWith(`|`)&&n.endsWith(`|`)&&l+1<r.length&&r[l+1].trim().startsWith(`|`)){let e=[];for(;l<r.length&&r[l].trim().startsWith(`|`)&&r[l].trim().endsWith(`|`);)e.push(r[l].trim()),l++;if(e.length>=2){let t=e[0].slice(1,-1).split(`|`).map(e=>e.trim()),n=e.slice(2).map(e=>e.slice(1,-1).split(`|`).map(e=>e.trim()));o.push((0,a.jsx)(`div`,{className:`my-3 overflow-x-auto border-2 border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-200 border-b-2 border-ink-black`,children:t.map((e,t)=>(0,a.jsx)(`th`,{className:`p-2 font-bold font-headline-md border-r last:border-r-0 border-ink-black`,children:s(e)},t))})}),(0,a.jsx)(`tbody`,{children:n.map((e,t)=>(0,a.jsx)(`tr`,{className:`border-b border-slate-300 last:border-b-0 ${t%2==1?`bg-slate-50`:`bg-white`}`,children:e.map((e,t)=>(0,a.jsx)(`td`,{className:`p-2 border-r last:border-r-0 border-slate-200 font-medium`,children:s(e)},t))},t))})]})},`table-${i}`));continue}}if(n.startsWith(`#### `)){o.push((0,a.jsx)(`h4`,{className:`text-xs font-bold text-ink-black mt-3 mb-1 font-headline-md`,children:s(n.substring(5))},i)),l++;continue}if(n.startsWith(`### `)){o.push((0,a.jsxs)(`h3`,{className:`text-xs font-bold text-primary mt-4 mb-1.5 uppercase font-arcade tracking-wide flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`w-2 h-2 bg-primary inline-block rounded-xs`}),s(n.substring(4))]},i)),l++;continue}if(n.startsWith(`## `)){o.push((0,a.jsx)(`h2`,{className:`text-sm font-extrabold text-ink-black mt-4 mb-2 font-headline-md border-b-2 border-ink-black pb-1`,children:s(n.substring(3))},i)),l++;continue}if(n.startsWith(`# `)){o.push((0,a.jsx)(`h1`,{className:`text-base font-black text-ink-black mt-5 mb-2 font-headline-md`,children:s(n.substring(2))},i)),l++;continue}if(n===`---`||n===`***`||n===`___`){o.push((0,a.jsx)(`hr`,{className:`my-3 border-t-2 border-dashed border-slate-300`},i)),l++;continue}if(e.trim().startsWith(`>`)){o.push((0,a.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-3 py-1 my-2 bg-slate-50 italic text-slate-700`,children:s(e.trim().substring(1).trim())},i)),l++;continue}if(n.startsWith(`- `)||n.startsWith(`* `)||n.startsWith(`+ `)){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-bold mt-0.5 shrink-0`,children:`•`}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(n.substring(2))})]},i)),l++;continue}let c=n.match(/^(\d+)\.\s+(.*)$/);if(c){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-arcade text-[9px] font-bold mt-1 shrink-0 px-1 py-0.2 bg-slate-100 border border-ink-black rounded-xs`,children:c[1]}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(c[2])})]},i)),l++;continue}o.push((0,a.jsx)(`p`,{className:`text-ink-black my-1 font-medium leading-relaxed`,children:s(e)},i)),l++}return(0,a.jsx)(i.Fragment,{children:o},`block-${t}`)})})};export{s as n,l as t};
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KatexRenderer-NjsEFKtT.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-oIjZMgNV.js","assets/vendor-codemirror-By0wlJeM.js","assets/vendor-katex-Balf574a.js","assets/vendor-katex-DtkCqjBQ.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{t as r}from"./index-B53AvSbH.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-NjsEFKtT.js`),__vite__mapDeps([0,1,2,3,4,5])));function s(e){return e?e.split(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\([\s\S]*?\\\)|\$(?:\\\$|[^$\n])+?\$|`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|(?<!\*)\*[^*\n]+(?<!\*)\*|(?<!_)_[^_\n]+(?<!_)_|\[[^\]\n]+\]\([^)\n]+\))/g).map((e,t)=>{if(!e)return null;if(e.startsWith(`$$`)&&e.endsWith(`$$`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\[`)&&e.endsWith(`\\]`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\(`)&&e.endsWith(`\\)`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith(`$`)&&e.endsWith(`$`)&&e.length>=2){let n=e.slice(1,-1);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith("`")&&e.endsWith("`")&&e.length>=2)return(0,a.jsx)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] px-1.5 py-0.5 rounded text-[11px] font-mono border border-ink-black shadow-[1px_1px_0px_0px_#000]`,children:e.slice(1,-1)},t);if(e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>=4||e.startsWith(`__`)&&e.endsWith(`__`)&&e.length>=4)return(0,a.jsx)(`strong`,{className:`text-ink-black font-extrabold`,children:s(e.slice(2,-2))},t);if(e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>=2||e.startsWith(`_`)&&e.endsWith(`_`)&&e.length>=2)return(0,a.jsx)(`em`,{className:`italic text-slate-800`,children:s(e.slice(1,-1))},t);let n=e.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return n?(0,a.jsx)(`a`,{href:n[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80 font-bold`,children:n[1]},t):e}):[]}var c=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-NjsEFKtT.js`),__vite__mapDeps([0,1,2,3,4,5]))),l=({content:e,className:t=``})=>{if(!e)return null;let n=e.split(/(```[\s\S]*?```|\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\])/g);return(0,a.jsx)(`div`,{className:`markdown-content space-y-2.5 text-ink-black text-xs leading-relaxed font-sans ${t}`,children:n.map((e,t)=>{if(!e)return null;let n=e.trim();if(n.startsWith("```")&&n.endsWith("```")&&n.length>=6){let e=n.indexOf(`
3
  `),r=e===-1?``:n.slice(3,e).trim(),i=e===-1?n.slice(3,-3).trim():n.slice(e+1,-3).trimEnd();return(0,a.jsxs)(`div`,{className:`my-3 rounded-md overflow-hidden border-[2px] border-ink-black shadow-[3px_3px_0px_0px_#1E293B] bg-[#1E293B]`,children:[r&&(0,a.jsxs)(`div`,{className:`bg-slate-800 text-slate-400 px-3 py-1 text-[9px] font-arcade uppercase tracking-wider border-b border-slate-700 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:r}),(0,a.jsx)(`span`,{className:`text-[8px] opacity-70`,children:`SNIPPET`})]}),(0,a.jsx)(`pre`,{className:`p-3 overflow-x-auto font-mono text-[11px] text-[#4ADE80] leading-relaxed custom-scrollbar selection:bg-[#4ADE80] selection:text-[#1E293B]`,children:(0,a.jsx)(`code`,{children:i})})]},`code-${t}`)}if(n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4||n.startsWith(`\\[`)&&n.endsWith(`\\]`)&&n.length>=4){let e=n.slice(2,-2);return(0,a.jsx)(`div`,{className:`my-3 p-3 bg-slate-50 border-2 border-ink-black rounded overflow-x-auto text-center shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] custom-scrollbar`,children:(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:e}),children:(0,a.jsx)(c,{math:e,displayMode:!0})})},`math-${t}`)}let r=e.split(`
4
  `),o=[],l=0;for(;l<r.length;){let e=r[l],n=e.trim(),i=`${t}-${l}`;if(n===``){o.push((0,a.jsx)(`div`,{className:`h-1`},i)),l++;continue}if(n.startsWith(`|`)&&n.endsWith(`|`)&&l+1<r.length&&r[l+1].trim().startsWith(`|`)){let e=[];for(;l<r.length&&r[l].trim().startsWith(`|`)&&r[l].trim().endsWith(`|`);)e.push(r[l].trim()),l++;if(e.length>=2){let t=e[0].slice(1,-1).split(`|`).map(e=>e.trim()),n=e.slice(2).map(e=>e.slice(1,-1).split(`|`).map(e=>e.trim()));o.push((0,a.jsx)(`div`,{className:`my-3 overflow-x-auto border-2 border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-200 border-b-2 border-ink-black`,children:t.map((e,t)=>(0,a.jsx)(`th`,{className:`p-2 font-bold font-headline-md border-r last:border-r-0 border-ink-black`,children:s(e)},t))})}),(0,a.jsx)(`tbody`,{children:n.map((e,t)=>(0,a.jsx)(`tr`,{className:`border-b border-slate-300 last:border-b-0 ${t%2==1?`bg-slate-50`:`bg-white`}`,children:e.map((e,t)=>(0,a.jsx)(`td`,{className:`p-2 border-r last:border-r-0 border-slate-200 font-medium`,children:s(e)},t))},t))})]})},`table-${i}`));continue}}if(n.startsWith(`#### `)){o.push((0,a.jsx)(`h4`,{className:`text-xs font-bold text-ink-black mt-3 mb-1 font-headline-md`,children:s(n.substring(5))},i)),l++;continue}if(n.startsWith(`### `)){o.push((0,a.jsxs)(`h3`,{className:`text-xs font-bold text-primary mt-4 mb-1.5 uppercase font-arcade tracking-wide flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`w-2 h-2 bg-primary inline-block rounded-xs`}),s(n.substring(4))]},i)),l++;continue}if(n.startsWith(`## `)){o.push((0,a.jsx)(`h2`,{className:`text-sm font-extrabold text-ink-black mt-4 mb-2 font-headline-md border-b-2 border-ink-black pb-1`,children:s(n.substring(3))},i)),l++;continue}if(n.startsWith(`# `)){o.push((0,a.jsx)(`h1`,{className:`text-base font-black text-ink-black mt-5 mb-2 font-headline-md`,children:s(n.substring(2))},i)),l++;continue}if(n===`---`||n===`***`||n===`___`){o.push((0,a.jsx)(`hr`,{className:`my-3 border-t-2 border-dashed border-slate-300`},i)),l++;continue}if(e.trim().startsWith(`>`)){o.push((0,a.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-3 py-1 my-2 bg-slate-50 italic text-slate-700`,children:s(e.trim().substring(1).trim())},i)),l++;continue}if(n.startsWith(`- `)||n.startsWith(`* `)||n.startsWith(`+ `)){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-bold mt-0.5 shrink-0`,children:`•`}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(n.substring(2))})]},i)),l++;continue}let c=n.match(/^(\d+)\.\s+(.*)$/);if(c){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-arcade text-[9px] font-bold mt-1 shrink-0 px-1 py-0.2 bg-slate-100 border border-ink-black rounded-xs`,children:c[1]}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(c[2])})]},i)),l++;continue}o.push((0,a.jsx)(`p`,{className:`text-ink-black my-1 font-medium leading-relaxed`,children:s(e)},i)),l++}return(0,a.jsx)(i.Fragment,{children:o},`block-${t}`)})})};export{s as n,l as t};
algospaced-ui/dist/assets/{MySQLPlayground-NRQBboPp.js → MySQLPlayground-C32Btviu.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n();function o(){let[e,t]=(0,i.useState)(null),[n,o]=(0,i.useState)(``),[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(!0),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(null),h=async()=>{u(!0),f(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();e.active?t(e):t(null)}else f(`Failed to fetch playground status.`)}catch{f(`Connection timed out.`)}finally{u(!1)}},g=async(e=!1)=>{u(!0),f(``),m(null);try{let{data:{session:n}}=await r.auth.getSession();if(!n){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/init${e?`?refresh=true`:``}`,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`}});if(i.ok){let e=await i.json();t({active:!0,title:e.title,objective:e.objective,points:e.points,schema:e.schema,challenge_type:e.challenge_type,completed:!1,total_score:e.total_score})}else f(`Failed to initialize mock database playground.`)}catch{f(`Server connection error.`)}finally{u(!1)}};return(0,i.useEffect)(()=>{h()},[]),l?(0,a.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,a.jsx)(`div`,{className:`animate-bounce mb-2`,children:`INITIALIZING SQL PLAYGROUND...`}),(0,a.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#0ea5e9] w-1/2 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,a.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,a.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px] uppercase`,children:e.challenge_type}),(0,a.jsxs)(`span`,{className:`bg-yellow-100 text-yellow-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,a.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`SOLVED`}):(0,a.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`UNSOLVED`})]}),(0,a.jsxs)(`div`,{className:`font-arcade text-[8px] text-sky-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`SCORE: `,e.total_score]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-yellow-400 bg-yellow-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,a.jsx)(`h4`,{className:`font-arcade text-[9px] text-yellow-800 mb-1`,children:`PROBLEM`}),(0,a.jsx)(`p`,{className:`font-bold text-slate-800`,children:e.objective})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`schema`}),(0,a.jsx)(`span`,{children:`SCHEMA EXPLORER (MOCK INSTANCE)`})]}),(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 max-h-[140px] overflow-y-auto custom-scrollbar font-mono text-[10px]`,children:Object.entries(e.schema).map(([e,t])=>(0,a.jsxs)(`div`,{className:`border border-slate-300 p-2 bg-slate-50`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-blue-700 border-b border-slate-200 pb-0.5 mb-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px]`,children:`table_chart`}),e]}),(0,a.jsx)(`ul`,{className:`space-y-0.5 text-slate-600 text-[9px]`,children:t.map((e,t)=>(0,a.jsxs)(`li`,{className:`flex justify-between`,children:[(0,a.jsx)(`span`,{children:e.name}),(0,a.jsx)(`span`,{className:`text-slate-400 italic text-[8px]`,children:e.type})]},t))})]},e))})]}),(0,a.jsxs)(`div`,{className:`flex flex-col min-h-[120px]`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] mb-1 tracking-wide uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm text-sky-600`,children:`terminal`}),(0,a.jsx)(`span`,{children:`Enter SQL Query:`})]}),(0,a.jsx)(`textarea`,{value:n,onChange:e=>o(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-sky-500 text-xs leading-relaxed resize-none`,placeholder:`SELECT * FROM customers WHERE score > 100;`,spellCheck:`false`})]}),(0,a.jsxs)(`div`,{className:`flex gap-3`,children:[(0,a.jsx)(`button`,{onClick:()=>g(!0),className:`flex-1 bg-white hover:bg-slate-100 text-ink-black border-[3px] border-ink-black font-bold font-window-title text-xs py-2 shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`NEW PROBLEM`}),(0,a.jsx)(`button`,{disabled:s,onClick:async()=>{if(n.trim()){c(!0),f(``),m(null);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(i.ok){let e=await i.json();e.success?(m({columns:e.columns,rows:e.rows,rowsAffected:e.rows_affected,isCorrect:e.is_correct}),e.is_correct&&t(t=>t?{...t,completed:!0,total_score:e.total_score}:null),e.schema&&t(t=>t?{...t,schema:e.schema}:null)):f(e.error)}else f(`Database server query failure.`)}catch{f(`Query connection lost.`)}finally{c(!1)}}},className:`flex-[2] bg-highlight-pink text-white font-window-title font-bold py-2 border-[3px] border-ink-black shadow-[3px_3px_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:s?`EXECUTING SQL...`:`EXECUTE SQL QUERY`})]}),d&&(0,a.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,a.jsx)(`div`,{className:`font-bold mb-1`,children:`SQL RUNTIME / SYNTAX ERROR:`}),d]}),p&&(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 flex flex-col`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:`QUERY OUTPUT BUFFER`}),p.isCorrect&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold animate-bounce text-[9px]`,children:`✓ ACCEPTED!`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-500 mb-2 font-mono`,children:[`Rows Affected: `,p.rowsAffected,` | Total Returned: `,p.rows.length]}),p.rows.length>0?(0,a.jsx)(`div`,{className:`overflow-x-auto border border-slate-300 max-h-[180px] custom-scrollbar`,children:(0,a.jsxs)(`table`,{className:`border-collapse w-full font-mono text-[9px] min-w-full`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-100 border-b border-slate-300`,children:p.columns.map((e,t)=>(0,a.jsx)(`th`,{className:`border-r border-slate-300 p-1.5 text-left font-bold text-slate-700`,children:e},t))})}),(0,a.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:p.rows.map((e,t)=>(0,a.jsx)(`tr`,{className:`hover:bg-slate-50`,children:p.columns.map((t,n)=>(0,a.jsx)(`td`,{className:`border-r border-slate-200 p-1.5 text-slate-800 whitespace-nowrap`,children:e[t]===null?(0,a.jsx)(`span`,{className:`text-slate-300 italic`,children:`NULL`}):String(e[t])},n))},t))})]})}):(0,a.jsx)(`div`,{className:`p-3 border border-dashed border-slate-300 text-center text-slate-400 italic font-sans text-xs`,children:`Query executed successfully. Result set is empty (or modification completed).`})]})]})}):(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col justify-between items-center text-center text-ink-black text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col justify-center items-center gap-4`,children:[(0,a.jsx)(`div`,{className:`w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shadow-[4px_4px_0_0_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-[#0ea5e9]`,style:{fontVariationSettings:`'FILL' 1`},children:`database`})}),(0,a.jsx)(`h3`,{className:`font-headline-md font-bold text-lg`,children:`Interactive MySQL Playground`}),(0,a.jsx)(`p`,{className:`max-w-md text-slate-600 leading-relaxed font-semibold`,children:`Practice SQL queries against realistic schema tables. Includes full support for:`}),(0,a.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2 font-mono text-[10px] text-slate-700 font-bold uppercase mt-1`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 border border-blue-400 px-2 py-0.5`,children:`SELECT / JOIN`}),(0,a.jsx)(`span`,{className:`bg-emerald-100 border border-emerald-400 px-2 py-0.5`,children:`UPDATE / DELETE`}),(0,a.jsx)(`span`,{className:`bg-purple-100 border border-purple-400 px-2 py-0.5`,children:`WINDOW FUNCTIONS`})]})]}),(0,a.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-4 flex flex-col gap-2 shrink-0`,children:(0,a.jsx)(`button`,{onClick:()=>g(!1),className:`w-full py-2.5 bg-[#0ea5e9] hover:bg-sky-400 text-white font-window-title font-bold text-xs uppercase border-[3px] border-ink-black shadow-[4px_4px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer text-center`,children:`CREATE NEW DATABASE`})})]})}export{o as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n();function o(){let[e,t]=(0,i.useState)(null),[n,o]=(0,i.useState)(``),[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(!0),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(null),h=async()=>{u(!0),f(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();e.active?t(e):t(null)}else f(`Failed to fetch playground status.`)}catch{f(`Connection timed out.`)}finally{u(!1)}},g=async(e=!1)=>{u(!0),f(``),m(null);try{let{data:{session:n}}=await r.auth.getSession();if(!n){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/init${e?`?refresh=true`:``}`,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`}});if(i.ok){let e=await i.json();t({active:!0,title:e.title,objective:e.objective,points:e.points,schema:e.schema,challenge_type:e.challenge_type,completed:!1,total_score:e.total_score})}else f(`Failed to initialize mock database playground.`)}catch{f(`Server connection error.`)}finally{u(!1)}};return(0,i.useEffect)(()=>{h()},[]),l?(0,a.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,a.jsx)(`div`,{className:`animate-bounce mb-2`,children:`INITIALIZING SQL PLAYGROUND...`}),(0,a.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#0ea5e9] w-1/2 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,a.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,a.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px] uppercase`,children:e.challenge_type}),(0,a.jsxs)(`span`,{className:`bg-yellow-100 text-yellow-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,a.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`SOLVED`}):(0,a.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`UNSOLVED`})]}),(0,a.jsxs)(`div`,{className:`font-arcade text-[8px] text-sky-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`SCORE: `,e.total_score]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-yellow-400 bg-yellow-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,a.jsx)(`h4`,{className:`font-arcade text-[9px] text-yellow-800 mb-1`,children:`PROBLEM`}),(0,a.jsx)(`p`,{className:`font-bold text-slate-800`,children:e.objective})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`schema`}),(0,a.jsx)(`span`,{children:`SCHEMA EXPLORER (MOCK INSTANCE)`})]}),(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 max-h-[140px] overflow-y-auto custom-scrollbar font-mono text-[10px]`,children:Object.entries(e.schema).map(([e,t])=>(0,a.jsxs)(`div`,{className:`border border-slate-300 p-2 bg-slate-50`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-blue-700 border-b border-slate-200 pb-0.5 mb-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px]`,children:`table_chart`}),e]}),(0,a.jsx)(`ul`,{className:`space-y-0.5 text-slate-600 text-[9px]`,children:t.map((e,t)=>(0,a.jsxs)(`li`,{className:`flex justify-between`,children:[(0,a.jsx)(`span`,{children:e.name}),(0,a.jsx)(`span`,{className:`text-slate-400 italic text-[8px]`,children:e.type})]},t))})]},e))})]}),(0,a.jsxs)(`div`,{className:`flex flex-col min-h-[120px]`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] mb-1 tracking-wide uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm text-sky-600`,children:`terminal`}),(0,a.jsx)(`span`,{children:`Enter SQL Query:`})]}),(0,a.jsx)(`textarea`,{value:n,onChange:e=>o(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-sky-500 text-xs leading-relaxed resize-none`,placeholder:`SELECT * FROM customers WHERE score > 100;`,spellCheck:`false`})]}),(0,a.jsxs)(`div`,{className:`flex gap-3`,children:[(0,a.jsx)(`button`,{onClick:()=>g(!0),className:`flex-1 bg-white hover:bg-slate-100 text-ink-black border-[3px] border-ink-black font-bold font-window-title text-xs py-2 shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`NEW PROBLEM`}),(0,a.jsx)(`button`,{disabled:s,onClick:async()=>{if(n.trim()){c(!0),f(``),m(null);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(i.ok){let e=await i.json();e.success?(m({columns:e.columns,rows:e.rows,rowsAffected:e.rows_affected,isCorrect:e.is_correct}),e.is_correct&&t(t=>t?{...t,completed:!0,total_score:e.total_score}:null),e.schema&&t(t=>t?{...t,schema:e.schema}:null)):f(e.error)}else f(`Database server query failure.`)}catch{f(`Query connection lost.`)}finally{c(!1)}}},className:`flex-[2] bg-highlight-pink text-white font-window-title font-bold py-2 border-[3px] border-ink-black shadow-[3px_3px_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:s?`EXECUTING SQL...`:`EXECUTE SQL QUERY`})]}),d&&(0,a.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,a.jsx)(`div`,{className:`font-bold mb-1`,children:`SQL RUNTIME / SYNTAX ERROR:`}),d]}),p&&(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 flex flex-col`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:`QUERY OUTPUT BUFFER`}),p.isCorrect&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold animate-bounce text-[9px]`,children:`✓ ACCEPTED!`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-500 mb-2 font-mono`,children:[`Rows Affected: `,p.rowsAffected,` | Total Returned: `,p.rows.length]}),p.rows.length>0?(0,a.jsx)(`div`,{className:`overflow-x-auto border border-slate-300 max-h-[180px] custom-scrollbar`,children:(0,a.jsxs)(`table`,{className:`border-collapse w-full font-mono text-[9px] min-w-full`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-100 border-b border-slate-300`,children:p.columns.map((e,t)=>(0,a.jsx)(`th`,{className:`border-r border-slate-300 p-1.5 text-left font-bold text-slate-700`,children:e},t))})}),(0,a.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:p.rows.map((e,t)=>(0,a.jsx)(`tr`,{className:`hover:bg-slate-50`,children:p.columns.map((t,n)=>(0,a.jsx)(`td`,{className:`border-r border-slate-200 p-1.5 text-slate-800 whitespace-nowrap`,children:e[t]===null?(0,a.jsx)(`span`,{className:`text-slate-300 italic`,children:`NULL`}):String(e[t])},n))},t))})]})}):(0,a.jsx)(`div`,{className:`p-3 border border-dashed border-slate-300 text-center text-slate-400 italic font-sans text-xs`,children:`Query executed successfully. Result set is empty (or modification completed).`})]})]})}):(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col justify-between items-center text-center text-ink-black text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col justify-center items-center gap-4`,children:[(0,a.jsx)(`div`,{className:`w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shadow-[4px_4px_0_0_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-[#0ea5e9]`,style:{fontVariationSettings:`'FILL' 1`},children:`database`})}),(0,a.jsx)(`h3`,{className:`font-headline-md font-bold text-lg`,children:`Interactive MySQL Playground`}),(0,a.jsx)(`p`,{className:`max-w-md text-slate-600 leading-relaxed font-semibold`,children:`Practice SQL queries against realistic schema tables. Includes full support for:`}),(0,a.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2 font-mono text-[10px] text-slate-700 font-bold uppercase mt-1`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 border border-blue-400 px-2 py-0.5`,children:`SELECT / JOIN`}),(0,a.jsx)(`span`,{className:`bg-emerald-100 border border-emerald-400 px-2 py-0.5`,children:`UPDATE / DELETE`}),(0,a.jsx)(`span`,{className:`bg-purple-100 border border-purple-400 px-2 py-0.5`,children:`WINDOW FUNCTIONS`})]})]}),(0,a.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-4 flex flex-col gap-2 shrink-0`,children:(0,a.jsx)(`button`,{onClick:()=>g(!1),className:`w-full py-2.5 bg-[#0ea5e9] hover:bg-sky-400 text-white font-window-title font-bold text-xs uppercase border-[3px] border-ink-black shadow-[4px_4px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer text-center`,children:`CREATE NEW DATABASE`})})]})}export{o as default};
algospaced-ui/dist/assets/PrincessChamber-CS-4OU0n.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,D as i,Ft as a,N as o,Nt as s,P as c,Qt as l,Tt as u,U as d,Xt as f,Y as p,a as m,c as h,l as g,m as _,o as v,xt as y}from"./vendor-react-oIjZMgNV.js";import{_ as b,b as x,d as S,f as C,g as w,h as T,k as E,m as D,p as O}from"./index-B53AvSbH.js";var k=t(l(),1),A={neutral:{id:`neutral`,label:`Calm`,imagePath:`/sprites/princess/neutral.webp`},smiling_warmly:{id:`smiling_warmly`,label:`Smiling Warmly`,imagePath:`/sprites/princess/smiling_warmly.webp`},excited_expression:{id:`excited_expression`,label:`Excited`,imagePath:`/sprites/princess/excited_expression.webp`},thinking_expression:{id:`thinking_expression`,label:`Thinking`,imagePath:`/sprites/princess/thinking_expression.webp`},concerned:{id:`concerned`,label:`Concerned`,imagePath:`/sprites/princess/concerned.webp`},fear:{id:`fear`,label:`Startled`,imagePath:`/sprites/princess/fear.webp`},sad_expression:{id:`sad_expression`,label:`Melancholy`,imagePath:`/sprites/princess/sad_expression.webp`}},j={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:`✨ Tower of the Elixir`}};function M(e){return e<=30?j[1]:e<=60?j[2]:e<=90?j[3]:e<=120?j[4]:e<150?j[5]:j[6]}var N=f();function P({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1,className:a=``,onClick:o}){let s=A[e]||A.smiling_warmly,c=(0,k.useMemo)(()=>M(t),[t]),l=(0,k.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/30 via-yellow-300/20 to-transparent`;case`dusk`:return`from-orange-500/30 via-purple-500/20 to-transparent`;case`night`:return`from-indigo-600/30 via-blue-500/20 to-transparent`;default:return`from-amber-300/25 via-sky-300/20 to-transparent`}},[n]);return(0,N.jsxs)(`div`,{onClick:o,className:`relative flex flex-col items-center justify-end select-none pointer-events-auto transition-transform ${a}`,children:[(0,N.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(16,c.particleCount)}).map((e,t)=>{let n=c.particleColors[t%c.particleColors.length],r=`${t*17%100}%`,i=`${7+t%5*2}s`,a=`${t*.8%4}s`,o=c.particleType===`leaves`||c.particleType===`runes`?`w-2 h-2`:`w-1.5 h-1.5`;return(0,N.jsx)(`span`,{className:`absolute rounded-full opacity-60 animate-pulse ${o}`,style:{backgroundColor:n,left:r,top:`${t*21%90}%`,boxShadow:`0 0 10px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,N.jsx)(`div`,{className:`absolute bottom-4 inset-x-0 h-48 sm:h-72 md:h-96 bg-radial ${l} blur-2xl opacity-70 pointer-events-none z-0`}),(0,N.jsxs)(`div`,{className:`relative z-10 flex flex-col items-start justify-end`,children:[r&&(0,N.jsx)(`div`,{className:`mb-2 max-w-[120px] sm:max-w-xs text-center pointer-events-none animate-in fade-in duration-300`,children:(0,N.jsxs)(`span`,{className:`text-[9px] sm:text-[10px] font-mono font-medium text-[#bfe1ff] bg-[#101e2e]/85 px-2 sm:px-2.5 py-0.5 rounded-full border border-[#3e6080]/70 shadow-md inline-flex items-center gap-1 sm:gap-1.5 backdrop-blur-xs`,children:[(0,N.jsx)(`span`,{className:`text-amber-400`,children:`⛺`}),(0,N.jsx)(`span`,{className:`truncate`,children:r})]})}),(0,N.jsx)(`div`,{className:`relative h-[28vh] sm:h-[40vh] md:h-[46vh] lg:h-[50vh] max-h-[220px] sm:max-h-[380px] md:max-h-[460px] lg:max-h-[500px] min-h-[160px] sm:min-h-[240px] md:min-h-[300px] w-auto max-w-[110px] sm:max-w-[200px] md:max-w-[270px] lg:max-w-[320px] flex items-end justify-end`,children:(0,N.jsx)(`img`,{src:s.imagePath,alt:s.label,loading:`eager`,className:`h-full w-auto max-h-[85vh] object-contain object-bottom-left drop-shadow-[0_16px_32px_rgba(0,0,0,0.55)] transition-all duration-300 ${i?`scale-[1.02] filter brightness-110 saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/smiling_warmly.webp`)?t.src.endsWith(`/sprites/princess/neutral.webp`)||(t.src=`/sprites/princess/neutral.webp`):t.src=`/sprites/princess/smiling_warmly.webp`}})})]})]})}var F=[`How is your strength holding up today?`,`Let us rest by the fire for a moment.`,`We made good progress toward the Tower today.`],I={backgroundColor:`rgba(20, 36, 54, 0.94)`,boxShadow:`0 0 0 2px #0a1420, inset 0 0 0 3px #4c7396, inset 1px 1px 0 4px #8db7dc, inset -1px -1px 0 4px #1a2c3f, inset 0 0 0 5px #0c1724, 0 10px 28px rgba(0, 0, 0, 0.75)`};function L({characterName:e,text:t,isStreaming:i=!1,isLoading:a=!1,choices:o,toolCalls:l,onSelectChoice:u,onSendMessage:f,onTypingStatusChange:p,currentFloor:m,bondTier:_,satchelCount:y=0,isMuted:b=!1,onToggleMute:x,onOpenProgress:S,onOpenSatchel:C,onOpenHistory:w,onMinimize:T,onClose:E,className:D=``,isActive:A=!0}){let[j,M]=(0,k.useState)(``),[P,L]=(0,k.useState)(!1),[R,z]=(0,k.useState)(0),[B,V]=(0,k.useState)(``),[H,U]=(0,k.useState)(!1),W=(0,k.useRef)(t),G=(0,k.useRef)(!1),K=(0,k.useRef)(null),q=(0,k.useRef)(null),J=i||P;(0,k.useEffect)(()=>{p?.(J)},[J,p]);let Y=(0,k.useMemo)(()=>{if(Array.isArray(o)&&o.length>0){let t=O(o,void 0,e);if(t.length>0)return t.slice(0,4)}return F},[o,e]),X=R<Y.length?R:0,Z=!i&&P?j:t;(0,k.useEffect)(()=>{if(i){K.current&&=(clearInterval(K.current),null),G.current=!0,W.current=t;return}if(G.current){G.current=!1,W.current=t,K.current&&=(clearInterval(K.current),null);return}if(t!==W.current&&!a){if(W.current=t,!t){K.current&&=(clearInterval(K.current),null);return}K.current&&clearInterval(K.current);let e=0,n=setInterval(()=>{e++,M(t.slice(0,e)),L(!0),e>=t.length&&(clearInterval(n),K.current=null,L(!1))},20);return K.current=n,()=>{clearInterval(n),K.current=null,L(!1)}}},[t,a,i]);let Q=(0,k.useCallback)(()=>{K.current&&=(clearInterval(K.current),null),L(!1)},[]),$=()=>{let e=B.trim();!e||a||i||(f(e),V(``))};return(0,k.useEffect)(()=>{let e=e=>{if(A){if(e.key===`Escape`&&E){e.preventDefault(),E();return}if(!H){if(e.key>=`1`&&e.key<=String(Y.length)){let t=parseInt(e.key,10)-1;Y[t]&&!a&&!i&&(e.preventDefault(),u(Y[t]));return}if(e.key===`ArrowUp`){e.preventDefault(),z(e=>(e-1+Y.length)%Y.length);return}if(e.key===`ArrowDown`){e.preventDefault(),z(e=>(e+1)%Y.length);return}if(e.key===`Enter`){!a&&!i&&Y[X]&&(e.preventDefault(),u(Y[X]));return}e.key===` `&&J&&(e.preventDefault(),Q())}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,H,Y,X,a,i,J,u,Q,E]),(0,N.jsxs)(`div`,{className:`relative flex flex-col gap-2 w-full ${D}`,children:[(0,N.jsxs)(`div`,{onClick:Q,className:`relative w-full rounded-md sm:rounded-lg text-white pt-3.5 pb-3.5 pr-3.5 pl-8 sm:pt-5 sm:pb-5 sm:pr-5 sm:pl-14 md:pl-16 lg:pl-18 flex flex-col gap-2.5 backdrop-blur-md transition-all select-none cursor-pointer`,style:I,children:[(0,N.jsxs)(`div`,{className:`absolute -top-7 right-1 flex items-center gap-1 sm:gap-1.5 z-30`,onClick:e=>e.stopPropagation(),children:[S&&(0,N.jsxs)(`button`,{type:`button`,onClick:S,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Road to the Tower (Leagues Progress)`,children:[(0,N.jsx)(s,{className:`w-3 h-3 text-amber-400`}),(0,N.jsxs)(`span`,{children:[m,`/150 Leagues`]})]}),C&&(0,N.jsxs)(`button`,{type:`button`,onClick:C,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Open Royal Satchel`,children:[(0,N.jsx)(n,{className:`w-3 h-3 text-amber-400`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Satchel`}),y>0&&(0,N.jsxs)(`span`,{className:`text-[9px] text-[#f3cb65]`,children:[`(`,y,`)`]})]}),w&&(0,N.jsxs)(`button`,{type:`button`,onClick:w,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Dialogue Transcript`,children:[(0,N.jsx)(c,{className:`w-3 h-3 text-[#8cb4db]`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Log`})]}),x&&(0,N.jsx)(`button`,{type:`button`,onClick:x,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:b?`Unmute Audio`:`Mute Audio`,children:b?(0,N.jsx)(h,{className:`w-3 h-3`}):(0,N.jsx)(g,{className:`w-3 h-3`})}),T&&(0,N.jsx)(`button`,{type:`button`,onClick:T,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:`Minimize to Taskbar`,children:(0,N.jsx)(d,{className:`w-3 h-3`})}),E&&(0,N.jsx)(`button`,{type:`button`,onClick:E,className:`p-1 bg-[#101e2e]/90 hover:bg-rose-900/70 border border-[#3e6080]/80 hover:border-rose-400 rounded text-[#8cb4db] hover:text-rose-200 transition-all cursor-pointer shadow-md`,title:`Rest by the Fire (Esc)`,children:(0,N.jsx)(v,{className:`w-3 h-3`})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsxs)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#f3cb65] tracking-wide drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]`,children:[`-`,e||`Princess Aurelia`,`-`]}),_&&(0,N.jsx)(`span`,{className:`hidden md:inline-block text-[9px] font-mono text-[#8cb4db] bg-[#101d2c]/80 border border-[#3e6080]/60 px-1.5 py-0.2 rounded uppercase tracking-wider`,children:_})]}),(0,N.jsxs)(`div`,{className:`min-h-[48px] sm:min-h-[54px] flex flex-col justify-start`,children:[a?(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs sm:text-sm font-mono text-[#8cb4db]`,children:[(0,N.jsx)(`span`,{className:`inline-block w-2 h-2 bg-[#f3cb65] rounded-full animate-ping`}),(0,N.jsxs)(`span`,{children:[e||`Princess Aurelia`,` is gathering her strength...`]})]}):(0,N.jsxs)(`div`,{className:`font-mono text-xs sm:text-sm md:text-[15px] leading-relaxed text-[#e6edf4] select-text`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,N.jsx)(`span`,{className:`text-[#f3cb65] italic font-semibold mr-1 inline-block`,children:e},t):(0,N.jsx)(`span`,{children:e},t)))(Z),J&&(0,N.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-[#f3cb65] ml-1 animate-pulse align-middle`})]}),l&&l.length>0&&!a&&(0,N.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 select-none`,children:l.map((e,t)=>(0,N.jsxs)(`span`,{className:`px-2 py-0.5 rounded bg-[#102438] border border-[#44729b] text-[10px] font-mono font-bold text-[#bfe1ff] flex items-center gap-1`,children:[(0,N.jsx)(r,{className:`w-2.5 h-2.5 text-[#f3cb65]`}),(0,N.jsxs)(`span`,{children:[`Enchantment: `,e.name]})]},t))})]}),(0,N.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,onClick:e=>e.stopPropagation(),children:Y.map((e,t)=>{let n=t+1,r=X===t;return(0,N.jsxs)(`button`,{type:`button`,disabled:a||i,onClick:()=>u(e),onMouseEnter:()=>z(t),className:`w-full sm:max-w-[90%] md:max-w-[85%] text-left flex items-center gap-2 px-2.5 py-1 rounded-xs sm:rounded-sm transition-all select-none font-mono text-xs sm:text-sm disabled:opacity-40 disabled:cursor-not-allowed ${r&&!a&&!i?`bg-[#1c3e61]/80 border border-[#4883b6]/80 shadow-[0_0_12px_rgba(72,131,182,0.25)] cursor-pointer`:`border border-transparent hover:bg-[#1c3e61]/35 cursor-pointer`}`,children:[(0,N.jsxs)(`span`,{className:`font-bold shrink-0 ${r?`text-[#e2ecf7]`:`text-[#b4c8dc]`}`,children:[n,`.`]}),(0,N.jsxs)(`span`,{className:`truncate font-medium ${r?`text-[#f3cb65]`:`text-[#dde7f2]`}`,children:[`[`,e,`]`]})]},t)})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),$()},onClick:e=>e.stopPropagation(),className:`w-full rounded-md sm:rounded-lg text-white py-2 sm:py-2.5 pr-3 sm:pr-4 pl-8 sm:pl-14 md:pl-16 lg:pl-18 flex items-center gap-2 backdrop-blur-md transition-all select-none`,style:I,children:[(0,N.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#e2ecf7] select-none pl-0.5 shrink-0`,children:`>`}),(0,N.jsxs)(`div`,{className:`flex-1 flex items-center bg-[#101e2e]/90 border border-[#3b5d7d] rounded px-2.5 py-1 focus-within:border-[#67b1ec] focus-within:ring-1 focus-within:ring-[#67b1ec]/40 shadow-inner`,children:[(0,N.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none mr-1.5 shrink-0`,children:`[`}),(0,N.jsx)(`input`,{ref:q,type:`text`,value:B,onChange:e=>V(e.target.value),onFocus:()=>U(!0),onBlur:()=>U(!1),disabled:a||i,placeholder:`Speak with ${e||`Princess Aurelia`}...`,className:`flex-1 bg-transparent border-none text-[#e2ecf7] placeholder-[#f3cb65]/70 font-mono text-xs sm:text-sm focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed`}),(0,N.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none ml-1.5 shrink-0`,children:`]`})]}),(0,N.jsxs)(`button`,{type:`submit`,disabled:a||i||!B.trim(),className:`bg-[#34597b] hover:bg-[#3f6990] active:bg-[#2b4c6e] disabled:opacity-40 disabled:cursor-not-allowed border border-[#5c8cb5] hover:border-[#8db7dc] rounded px-3 sm:px-4 py-1 text-xs sm:text-sm font-mono font-bold text-white transition-all cursor-pointer shadow-md select-none shrink-0 flex items-center`,children:[(0,N.jsx)(`span`,{className:`text-[#f3cb65]`,children:`[`}),(0,N.jsx)(`span`,{className:`text-white px-1`,children:`Send`}),(0,N.jsx)(`span`,{className:`text-[#f3cb65]`,children:`]`})]})]})]})}function R({currentFloor:e,onClose:t}){let n=w(e),r=Math.min(100,Math.round(e/150*100));return(0,N.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,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(s,{className:`w-5 h-5 text-indigo-600`}),(0,N.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Tower of the Elixir`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,N.jsx)(v,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,N.jsx)(`span`,{children:`Path Progress:`}),(0,N.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,N.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,N.jsxs)(`span`,{children:[`Progress: `,(0,N.jsxs)(`strong`,{children:[r,`%`]})]}),(0,N.jsxs)(`span`,{children:[`Distance to Tower: `,(0,N.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,N.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,N.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,N.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,N.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,N.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,N.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Plains`},{floor:60,label:`Forest`},{floor:90,label:`Caverns`},{floor:120,label:`Passes`},{floor:150,label:`The Tower`}].map(t=>{let n=e>=t.floor;return(0,N.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,N.jsx)(`span`,{children:n?`✓`:t.floor}),(0,N.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,N.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,N.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 z({unlockedLetters:e,spireChronicles:t,currentFloor:o,heroCodex:s,episodicEvents:c,recentToolTelemetry:l,onRemoveCodexItem:d,onClose:f}){let[h,g]=(0,k.useState)(`letters`),[b,x]=(0,k.useState)(e[e.length-1]||null);return(0,N.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:f,children:(0,N.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,N.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,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(n,{className:`w-5 h-5 text-amber-700`}),(0,N.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:f,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,N.jsx)(v,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>g(`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 ${h===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(n,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>g(`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 ${h===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(a,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>g(`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 ${h===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(r,{className:`w-3.5 h-3.5 text-amber-700`}),(0,N.jsx)(`span`,{children:`Codex`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[h===`letters`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=T[e],n=o>=e,r=b?.floor===e;return(0,N.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&x(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 ${n?r?`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:[n?(0,N.jsx)(`span`,{children:`📜`}):(0,N.jsx)(p,{className:`w-3 h-3`}),(0,N.jsxs)(`span`,{children:[`League `,e]})]},e)})}),b?(0,N.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,N.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[b.chapterTitle,` • League `,b.floor]}),(0,N.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:b.title})]}),(0,N.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,N.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:b.letterText})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,N.jsx)(p,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,N.jsx)(`p`,{className:`text-xs font-medium`,children:`Travel 30 leagues along the path to unlock your first missive from Aurelia.`})]})]}),h===`diary`&&(0,N.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,N.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,N.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,N.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,N.jsx)(a,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,N.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her travel journal as you journey together, rest by the fire, and cross chapter milestones.`})]})}),h===`codex`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(r,{className:`w-4 h-4 text-amber-600`}),(0,N.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,N.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,N.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:s?.heroName||`Champion`})]}),(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,N.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:s?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),s?.preferredLanguage&&(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,N.jsx)(`span`,{className:`font-bold text-ink-black`,children:s.preferredLanguage})]})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,N.jsx)(u,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Mastered Patterns (`,s?.strengths?.length||0,`)`]})]}),s?.strengths&&s.strengths.length>0?(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.strengths.map(e=>(0,N.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,d&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,N.jsx)(v,{className:`w-3 h-3`})})]},e))}):(0,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note trials you conquer along our journey.`})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,N.jsx)(i,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Nemesis Patterns (`,s?.nemesisPatterns?.length||0,`)`]})]}),s?.nemesisPatterns&&s.nemesisPatterns.length>0?(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.nemesisPatterns.map(e=>(0,N.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,d&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,N.jsx)(v,{className:`w-3 h-3`})})]},e))}):(0,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks difficult trials to help you prepare targeted drills.`})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,N.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,s?.personalNotes?.length||0,`)`]})}),s?.personalNotes&&s.personalNotes.length>0?(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:s.personalNotes.map(e=>(0,N.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,N.jsxs)(`span`,{children:[`• `,e]}),d&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,N.jsx)(_,{className:`w-3 h-3`})})]},e))}):(0,N.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.`})]}),c&&c.length>0&&(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,N.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,N.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[c.length,` events`]})]}),(0,N.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:c.slice(0,8).map(e=>(0,N.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.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,N.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,N.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,N.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,N.jsx)(m,{className:`w-3.5 h-3.5 text-amber-500`}),(0,N.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,N.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[l?.length||0,` executed`]})]}),l&&l.length>0?(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:l.slice(0,10).map((e,t)=>(0,N.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,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.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,N.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,N.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,N.jsx)(y,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,N.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,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,N.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,N.jsx)(`button`,{type:`button`,onClick:f,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 B=e({default:()=>V});function V({onClose:e,onMinimize:t,isActive:n=!0,onFocus:r,zIndex:i}){let a=D(),[s,l]=(0,k.useState)(b()),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[m,h]=(0,k.useState)(!1);(0,k.useEffect)(()=>{C.syncWithBackend(),C.triggerProactiveGreeting()},[]);let g=(0,k.useCallback)(()=>{e?e():E.getState().closeWindow(`companion`)},[e]),_=(0,k.useCallback)(()=>{t?t():E.getState().minimizeWindow(`companion`)},[t]),y=(0,k.useCallback)(()=>{r?r():E.getState().setActiveWindow(`companion`)},[r]),w=(0,k.useCallback)(()=>{let e=!s;l(e),x(e)},[s]),T=(0,k.useCallback)(()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&C.clearTranscript()},[]),A=(0,k.useCallback)(e=>{C.setIsTyping(e)},[]),j=(0,k.useMemo)(()=>[...a.transcript].reverse().find(e=>e.sender===`princess`)||a.transcript[0],[a.transcript]),M=`Welcome back to camp. How is your strength holding up today? Are you ready to continue our journey, or would you like to rest for a while?`,F=j?j.isStreaming?j.text:j.text||(a.isLoading?``:M):M,I=(0,k.useMemo)(()=>{let e=j?.choiceSuggestions&&j.choiceSuggestions.length>0?j.choiceSuggestions:[...a.transcript].reverse().find(e=>e.sender===`princess`&&e.choiceSuggestions&&e.choiceSuggestions.length>0)?.choiceSuggestions,t=O(e,a.heroCodex?.heroName||a.heroProfile?.heroName||`Champion`,a.companionSettings.name||`Princess Aurelia`);return t.length>0?t:S},[j,a.transcript,a.heroCodex?.heroName,a.heroProfile?.heroName,a.companionSettings.name]);return(0,N.jsxs)(`div`,{onClick:y,className:`fixed inset-x-0 top-0 bottom-[40px] select-none pointer-events-none overflow-hidden font-sans`,style:{zIndex:i??(n?40:30)},children:[(0,N.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-slate-950/35 via-slate-900/10 to-transparent pointer-events-none z-0`}),(0,N.jsxs)(`div`,{className:`relative w-full h-full flex flex-col justify-end pointer-events-none pb-2 sm:pb-3 px-2 sm:px-4 md:px-8`,children:[(0,N.jsxs)(`div`,{className:`relative w-full max-w-5xl lg:max-w-6xl mx-auto flex items-end justify-start pointer-events-none`,children:[(0,N.jsx)(`div`,{className:`relative z-30 shrink-0 pointer-events-auto -mr-6 sm:-mr-10 md:-mr-12 lg:-mr-14`,children:(0,N.jsx)(P,{emotion:a.activeEmotion,floor:a.currentFloor,rhythm:a.currentRhythm,activity:a.currentActivity,isLoading:a.isLoading,onClick:y})}),(0,N.jsx)(`div`,{className:`relative z-20 flex-1 min-w-0 pointer-events-auto mb-1`,children:(0,N.jsx)(L,{characterName:a.companionSettings.name||`Princess Aurelia`,emotion:a.activeEmotion,text:F,isStreaming:j?.isStreaming,isLoading:a.isLoading,choices:I,toolCalls:j?.toolCalls,onSelectChoice:e=>C.sendMessage(e),onSendMessage:e=>C.sendMessage(e),onTypingStatusChange:A,currentFloor:a.currentFloor,bondTier:a.bondTier,satchelCount:a.unlockedLetters.length,isMuted:s,onToggleMute:w,onOpenProgress:()=>d(!0),onOpenSatchel:()=>p(!0),onOpenHistory:()=>h(!0),onMinimize:_,onClose:g,isActive:n})})]}),(0,N.jsxs)(`div`,{className:`absolute bottom-1 right-3.5 pointer-events-none z-30 hidden md:flex flex-col items-center gap-0.5 opacity-65 select-none`,children:[(0,N.jsx)(`svg`,{className:`w-8 h-8 text-[#9cbcdb] drop-shadow-[0_0_6px_rgba(156,188,219,0.5)] rotate-6`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,N.jsx)(`path`,{d:`M12 2 C12 7.8 7.8 12 2 12 C7.8 12 12 16.2 12 22 C12 16.2 16.2 12 22 12 C16.2 12 12 7.8 12 2 Z`})}),(0,N.jsxs)(`div`,{className:`font-mono text-[9px] text-[#7ba4c8] tracking-tight leading-tight text-center`,children:[(0,N.jsx)(`div`,{children:`AlgoSpaced (Beta)`}),(0,N.jsx)(`div`,{children:`Build Jun24 preview`})]})]})]}),u&&(0,N.jsx)(`div`,{className:`pointer-events-auto`,children:(0,N.jsx)(R,{currentFloor:a.currentFloor,totalSolved:a.totalSolved,onClose:()=>d(!1)})}),f&&(0,N.jsx)(`div`,{className:`pointer-events-auto`,children:(0,N.jsx)(z,{unlockedLetters:a.unlockedLetters,spireChronicles:a.spireChronicles,currentFloor:a.currentFloor,heroCodex:a.heroCodex,episodicEvents:a.episodicEvents,recentToolTelemetry:a.recentToolTelemetry,onRemoveCodexItem:C.removeCodexItem,onClose:()=>p(!1)})}),m&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 pointer-events-auto`,onClick:()=>h(!1),children:(0,N.jsxs)(`div`,{className:`bg-[#142335] border-[3px] border-[#5a80a2] rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[0_16px_40px_rgba(0,0,0,0.85)] flex flex-col overflow-hidden text-white`,onClick:e=>e.stopPropagation(),style:{boxShadow:`inset 0 0 0 1px #0a1420, inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.85)`},children:[(0,N.jsxs)(`div`,{className:`bg-[#101b2a] border-b border-[#304f6f] px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(c,{className:`w-4 h-4 text-[#67b1ec]`}),(0,N.jsxs)(`h4`,{className:`font-mono font-bold text-xs sm:text-sm text-[#e6f0fa] m-0`,children:[`Dialogue Transcript (`,a.transcript.length,` turns)`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:T,className:`px-2 py-0.5 bg-rose-950/60 hover:bg-rose-900 border border-rose-700/60 rounded text-[11px] font-mono font-bold text-rose-300 hover:text-white flex items-center gap-1 cursor-pointer mr-1 transition-colors`,title:`Clear Chat History`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{children:`Clear`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`p-1 hover:bg-[#203a55] rounded text-[#8cb4db] hover:text-white cursor-pointer transition-colors`,title:`Close`,children:(0,N.jsx)(v,{className:`w-4 h-4`})})]})]}),(0,N.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5 bg-[#0e1824]/90`,children:a.transcript.map((e,t)=>(0,N.jsxs)(`div`,{className:`p-2.5 rounded-lg border font-mono text-xs max-w-[90%] shadow-md ${e.sender===`princess`?`bg-[#182c42] border-[#3e6080] text-[#e6f0fa] self-start`:`bg-[#214365] border-[#5a8bb9] text-white self-end`}`,children:[(0,N.jsx)(`div`,{className:`text-[10px] font-bold mb-1 text-[#f6d267]`,children:e.sender===`princess`?a.companionSettings.name:`Hero`}),(0,N.jsx)(`p`,{className:`font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:e.text})]},e.id||t))})]})})]})}export{B as t};
algospaced-ui/dist/assets/PrincessChamber-DvQR6sQH.js DELETED
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,Ct as i,E as a,L as o,U as s,Vt as c,a as l,b as u,c as d,f,i as p,k as m,lt as h,pt as g,s as _,xt as v,zt as y}from"./vendor-react-CDF1pnIM.js";import{_ as b,d as x,f as S,g as C,h as w,m as T,p as E,v as D,w as O}from"./index-DX2cztXb.js";var k=t(c(),1),A={neutral:{id:`neutral`,label:`Calm`,imagePath:`/sprites/princess/neutral.webp`},smiling_warmly:{id:`smiling_warmly`,label:`Smiling Warmly`,imagePath:`/sprites/princess/smiling_warmly.webp`},excited_expression:{id:`excited_expression`,label:`Excited`,imagePath:`/sprites/princess/excited_expression.webp`},thinking_expression:{id:`thinking_expression`,label:`Thinking`,imagePath:`/sprites/princess/thinking_expression.webp`},concerned:{id:`concerned`,label:`Concerned`,imagePath:`/sprites/princess/concerned.webp`},fear:{id:`fear`,label:`Startled`,imagePath:`/sprites/princess/fear.webp`},sad_expression:{id:`sad_expression`,label:`Melancholy`,imagePath:`/sprites/princess/sad_expression.webp`}},j={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:`✨ Tower of the Elixir`}};function M(e){return e<=30?j[1]:e<=60?j[2]:e<=90?j[3]:e<=120?j[4]:e<150?j[5]:j[6]}var N=y();function P({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1,className:a=``,onClick:o}){let s=A[e]||A.smiling_warmly,c=(0,k.useMemo)(()=>M(t),[t]),l=(0,k.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/30 via-yellow-300/20 to-transparent`;case`dusk`:return`from-orange-500/30 via-purple-500/20 to-transparent`;case`night`:return`from-indigo-600/30 via-blue-500/20 to-transparent`;default:return`from-amber-300/25 via-sky-300/20 to-transparent`}},[n]);return(0,N.jsxs)(`div`,{onClick:o,className:`relative flex flex-col items-center justify-end select-none pointer-events-auto transition-transform ${a}`,children:[(0,N.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(16,c.particleCount)}).map((e,t)=>{let n=c.particleColors[t%c.particleColors.length],r=`${t*17%100}%`,i=`${7+t%5*2}s`,a=`${t*.8%4}s`,o=c.particleType===`leaves`||c.particleType===`runes`?`w-2 h-2`:`w-1.5 h-1.5`;return(0,N.jsx)(`span`,{className:`absolute rounded-full opacity-60 animate-pulse ${o}`,style:{backgroundColor:n,left:r,top:`${t*21%90}%`,boxShadow:`0 0 10px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,N.jsx)(`div`,{className:`absolute bottom-4 inset-x-0 h-48 sm:h-72 md:h-96 bg-radial ${l} blur-2xl opacity-70 pointer-events-none z-0`}),(0,N.jsxs)(`div`,{className:`relative z-10 flex flex-col items-start justify-end`,children:[r&&(0,N.jsx)(`div`,{className:`mb-2 max-w-[120px] sm:max-w-xs text-center pointer-events-none animate-in fade-in duration-300`,children:(0,N.jsxs)(`span`,{className:`text-[9px] sm:text-[10px] font-mono font-medium text-[#bfe1ff] bg-[#101e2e]/85 px-2 sm:px-2.5 py-0.5 rounded-full border border-[#3e6080]/70 shadow-md inline-flex items-center gap-1 sm:gap-1.5 backdrop-blur-xs`,children:[(0,N.jsx)(`span`,{className:`text-amber-400`,children:`⛺`}),(0,N.jsx)(`span`,{className:`truncate`,children:r})]})}),(0,N.jsx)(`div`,{className:`relative h-[28vh] sm:h-[40vh] md:h-[46vh] lg:h-[50vh] max-h-[220px] sm:max-h-[380px] md:max-h-[460px] lg:max-h-[500px] min-h-[160px] sm:min-h-[240px] md:min-h-[300px] w-auto max-w-[110px] sm:max-w-[200px] md:max-w-[270px] lg:max-w-[320px] flex items-end justify-end`,children:(0,N.jsx)(`img`,{src:s.imagePath,alt:s.label,loading:`eager`,className:`h-full w-auto max-h-[85vh] object-contain object-bottom-left drop-shadow-[0_16px_32px_rgba(0,0,0,0.55)] transition-all duration-300 ${i?`scale-[1.02] filter brightness-110 saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/smiling_warmly.webp`)?t.src.endsWith(`/sprites/princess/neutral.webp`)||(t.src=`/sprites/princess/neutral.webp`):t.src=`/sprites/princess/smiling_warmly.webp`}})})]})]})}var F=[`How is your strength holding up today?`,`Let us rest by the fire for a moment.`,`We made good progress toward the Tower today.`],I={backgroundColor:`rgba(20, 36, 54, 0.94)`,boxShadow:`0 0 0 2px #0a1420, inset 0 0 0 3px #4c7396, inset 1px 1px 0 4px #8db7dc, inset -1px -1px 0 4px #1a2c3f, inset 0 0 0 5px #0c1724, 0 10px 28px rgba(0, 0, 0, 0.75)`};function L({characterName:e,text:t,isStreaming:r=!1,isLoading:i=!1,choices:s,toolCalls:c,onSelectChoice:f,onSendMessage:p,onTypingStatusChange:m,currentFloor:h,bondTier:g,satchelCount:y=0,isMuted:b=!1,onToggleMute:x,onOpenProgress:S,onOpenSatchel:C,onOpenHistory:w,onMinimize:T,onClose:D,className:O=``,isActive:A=!0}){let[j,M]=(0,k.useState)(``),[P,L]=(0,k.useState)(!1),[R,z]=(0,k.useState)(0),[B,V]=(0,k.useState)(``),[H,U]=(0,k.useState)(!1),W=(0,k.useRef)(t),G=(0,k.useRef)(!1),K=(0,k.useRef)(null),q=(0,k.useRef)(null),J=r||P;(0,k.useEffect)(()=>{m?.(J)},[J,m]);let Y=(0,k.useMemo)(()=>{if(Array.isArray(s)&&s.length>0){let t=E(s,void 0,e);if(t.length>0)return t.slice(0,4)}return F},[s,e]),X=R<Y.length?R:0,Z=!r&&P?j:t;(0,k.useEffect)(()=>{if(r){K.current&&=(clearInterval(K.current),null),G.current=!0,W.current=t;return}if(G.current){G.current=!1,W.current=t,K.current&&=(clearInterval(K.current),null);return}if(t!==W.current&&!i){if(W.current=t,!t){K.current&&=(clearInterval(K.current),null);return}K.current&&clearInterval(K.current);let e=0,n=setInterval(()=>{e++,M(t.slice(0,e)),L(!0),e>=t.length&&(clearInterval(n),K.current=null,L(!1))},20);return K.current=n,()=>{clearInterval(n),K.current=null,L(!1)}}},[t,i,r]);let Q=(0,k.useCallback)(()=>{K.current&&=(clearInterval(K.current),null),L(!1)},[]),$=()=>{let e=B.trim();!e||i||r||(p(e),V(``))};return(0,k.useEffect)(()=>{let e=e=>{if(A){if(e.key===`Escape`&&D){e.preventDefault(),D();return}if(!H){if(e.key>=`1`&&e.key<=String(Y.length)){let t=parseInt(e.key,10)-1;Y[t]&&!i&&!r&&(e.preventDefault(),f(Y[t]));return}if(e.key===`ArrowUp`){e.preventDefault(),z(e=>(e-1+Y.length)%Y.length);return}if(e.key===`ArrowDown`){e.preventDefault(),z(e=>(e+1)%Y.length);return}if(e.key===`Enter`){!i&&!r&&Y[X]&&(e.preventDefault(),f(Y[X]));return}e.key===` `&&J&&(e.preventDefault(),Q())}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,H,Y,X,i,r,J,f,Q,D]),(0,N.jsxs)(`div`,{className:`relative flex flex-col gap-2 w-full ${O}`,children:[(0,N.jsxs)(`div`,{onClick:Q,className:`relative w-full rounded-md sm:rounded-lg text-white pt-3.5 pb-3.5 pr-3.5 pl-8 sm:pt-5 sm:pb-5 sm:pr-5 sm:pl-14 md:pl-16 lg:pl-18 flex flex-col gap-2.5 backdrop-blur-md transition-all select-none cursor-pointer`,style:I,children:[(0,N.jsxs)(`div`,{className:`absolute -top-7 right-1 flex items-center gap-1 sm:gap-1.5 z-30`,onClick:e=>e.stopPropagation(),children:[S&&(0,N.jsxs)(`button`,{type:`button`,onClick:S,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Road to the Tower (Leagues Progress)`,children:[(0,N.jsx)(v,{className:`w-3 h-3 text-amber-400`}),(0,N.jsxs)(`span`,{children:[h,`/150 Leagues`]})]}),C&&(0,N.jsxs)(`button`,{type:`button`,onClick:C,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Open Royal Satchel`,children:[(0,N.jsx)(a,{className:`w-3 h-3 text-amber-400`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Satchel`}),y>0&&(0,N.jsxs)(`span`,{className:`text-[9px] text-[#f3cb65]`,children:[`(`,y,`)`]})]}),w&&(0,N.jsxs)(`button`,{type:`button`,onClick:w,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Dialogue Transcript`,children:[(0,N.jsx)(n,{className:`w-3 h-3 text-[#8cb4db]`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Log`})]}),x&&(0,N.jsx)(`button`,{type:`button`,onClick:x,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:b?`Unmute Audio`:`Mute Audio`,children:b?(0,N.jsx)(_,{className:`w-3 h-3`}):(0,N.jsx)(d,{className:`w-3 h-3`})}),T&&(0,N.jsx)(`button`,{type:`button`,onClick:T,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:`Minimize to Taskbar`,children:(0,N.jsx)(o,{className:`w-3 h-3`})}),D&&(0,N.jsx)(`button`,{type:`button`,onClick:D,className:`p-1 bg-[#101e2e]/90 hover:bg-rose-900/70 border border-[#3e6080]/80 hover:border-rose-400 rounded text-[#8cb4db] hover:text-rose-200 transition-all cursor-pointer shadow-md`,title:`Rest by the Fire (Esc)`,children:(0,N.jsx)(l,{className:`w-3 h-3`})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsxs)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#f3cb65] tracking-wide drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]`,children:[`-`,e||`Princess Aurelia`,`-`]}),g&&(0,N.jsx)(`span`,{className:`hidden md:inline-block text-[9px] font-mono text-[#8cb4db] bg-[#101d2c]/80 border border-[#3e6080]/60 px-1.5 py-0.2 rounded uppercase tracking-wider`,children:g})]}),(0,N.jsxs)(`div`,{className:`min-h-[48px] sm:min-h-[54px] flex flex-col justify-start`,children:[i?(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs sm:text-sm font-mono text-[#8cb4db]`,children:[(0,N.jsx)(`span`,{className:`inline-block w-2 h-2 bg-[#f3cb65] rounded-full animate-ping`}),(0,N.jsxs)(`span`,{children:[e||`Princess Aurelia`,` is gathering her strength...`]})]}):(0,N.jsxs)(`div`,{className:`font-mono text-xs sm:text-sm md:text-[15px] leading-relaxed text-[#e6edf4] select-text`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,N.jsx)(`span`,{className:`text-[#f3cb65] italic font-semibold mr-1 inline-block`,children:e},t):(0,N.jsx)(`span`,{children:e},t)))(Z),J&&(0,N.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-[#f3cb65] ml-1 animate-pulse align-middle`})]}),c&&c.length>0&&!i&&(0,N.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 select-none`,children:c.map((e,t)=>(0,N.jsxs)(`span`,{className:`px-2 py-0.5 rounded bg-[#102438] border border-[#44729b] text-[10px] font-mono font-bold text-[#bfe1ff] flex items-center gap-1`,children:[(0,N.jsx)(u,{className:`w-2.5 h-2.5 text-[#f3cb65]`}),(0,N.jsxs)(`span`,{children:[`Enchantment: `,e.name]})]},t))})]}),(0,N.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,onClick:e=>e.stopPropagation(),children:Y.map((e,t)=>{let n=t+1,a=X===t;return(0,N.jsxs)(`button`,{type:`button`,disabled:i||r,onClick:()=>f(e),onMouseEnter:()=>z(t),className:`w-full sm:max-w-[90%] md:max-w-[85%] text-left flex items-center gap-2 px-2.5 py-1 rounded-xs sm:rounded-sm transition-all select-none font-mono text-xs sm:text-sm disabled:opacity-40 disabled:cursor-not-allowed ${a&&!i&&!r?`bg-[#1c3e61]/80 border border-[#4883b6]/80 shadow-[0_0_12px_rgba(72,131,182,0.25)] cursor-pointer`:`border border-transparent hover:bg-[#1c3e61]/35 cursor-pointer`}`,children:[(0,N.jsxs)(`span`,{className:`font-bold shrink-0 ${a?`text-[#e2ecf7]`:`text-[#b4c8dc]`}`,children:[n,`.`]}),(0,N.jsxs)(`span`,{className:`truncate font-medium ${a?`text-[#f3cb65]`:`text-[#dde7f2]`}`,children:[`[`,e,`]`]})]},t)})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),$()},onClick:e=>e.stopPropagation(),className:`w-full rounded-md sm:rounded-lg text-white py-2 sm:py-2.5 pr-3 sm:pr-4 pl-8 sm:pl-14 md:pl-16 lg:pl-18 flex items-center gap-2 backdrop-blur-md transition-all select-none`,style:I,children:[(0,N.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#e2ecf7] select-none pl-0.5 shrink-0`,children:`>`}),(0,N.jsxs)(`div`,{className:`flex-1 flex items-center bg-[#101e2e]/90 border border-[#3b5d7d] rounded px-2.5 py-1 focus-within:border-[#67b1ec] focus-within:ring-1 focus-within:ring-[#67b1ec]/40 shadow-inner`,children:[(0,N.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none mr-1.5 shrink-0`,children:`[`}),(0,N.jsx)(`input`,{ref:q,type:`text`,value:B,onChange:e=>V(e.target.value),onFocus:()=>U(!0),onBlur:()=>U(!1),disabled:i||r,placeholder:`Speak with ${e||`Princess Aurelia`}...`,className:`flex-1 bg-transparent border-none text-[#e2ecf7] placeholder-[#f3cb65]/70 font-mono text-xs sm:text-sm focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed`}),(0,N.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none ml-1.5 shrink-0`,children:`]`})]}),(0,N.jsxs)(`button`,{type:`submit`,disabled:i||r||!B.trim(),className:`bg-[#34597b] hover:bg-[#3f6990] active:bg-[#2b4c6e] disabled:opacity-40 disabled:cursor-not-allowed border border-[#5c8cb5] hover:border-[#8db7dc] rounded px-3 sm:px-4 py-1 text-xs sm:text-sm font-mono font-bold text-white transition-all cursor-pointer shadow-md select-none shrink-0 flex items-center`,children:[(0,N.jsx)(`span`,{className:`text-[#f3cb65]`,children:`[`}),(0,N.jsx)(`span`,{className:`text-white px-1`,children:`Send`}),(0,N.jsx)(`span`,{className:`text-[#f3cb65]`,children:`]`})]})]})]})}function R({currentFloor:e,onClose:t}){let n=C(e),r=Math.min(100,Math.round(e/150*100));return(0,N.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,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(v,{className:`w-5 h-5 text-indigo-600`}),(0,N.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Tower of the Elixir`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,N.jsx)(l,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,N.jsx)(`span`,{children:`Path Progress:`}),(0,N.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,N.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,N.jsxs)(`span`,{children:[`Progress: `,(0,N.jsxs)(`strong`,{children:[r,`%`]})]}),(0,N.jsxs)(`span`,{children:[`Distance to Tower: `,(0,N.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,N.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,N.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,N.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,N.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,N.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,N.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Plains`},{floor:60,label:`Forest`},{floor:90,label:`Caverns`},{floor:120,label:`Passes`},{floor:150,label:`The Tower`}].map(t=>{let n=e>=t.floor;return(0,N.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,N.jsx)(`span`,{children:n?`✓`:t.floor}),(0,N.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,N.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,N.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 z({unlockedLetters:e,spireChronicles:t,currentFloor:n,heroCodex:o,episodicEvents:c,recentToolTelemetry:d,onRemoveCodexItem:m,onClose:_}){let[v,y]=(0,k.useState)(`letters`),[b,x]=(0,k.useState)(e[e.length-1]||null);return(0,N.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:_,children:(0,N.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,N.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,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(a,{className:`w-5 h-5 text-amber-700`}),(0,N.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:_,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,N.jsx)(l,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>y(`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 ${v===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(a,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>y(`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 ${v===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(i,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>y(`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 ${v===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,N.jsx)(u,{className:`w-3.5 h-3.5 text-amber-700`}),(0,N.jsx)(`span`,{children:`Codex`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[v===`letters`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=w[e],r=n>=e,i=b?.floor===e;return(0,N.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&x(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,N.jsx)(`span`,{children:`📜`}):(0,N.jsx)(s,{className:`w-3 h-3`}),(0,N.jsxs)(`span`,{children:[`League `,e]})]},e)})}),b?(0,N.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,N.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[b.chapterTitle,` • League `,b.floor]}),(0,N.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:b.title})]}),(0,N.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,N.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:b.letterText})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,N.jsx)(s,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,N.jsx)(`p`,{className:`text-xs font-medium`,children:`Travel 30 leagues along the path to unlock your first missive from Aurelia.`})]})]}),v===`diary`&&(0,N.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,N.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,N.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,N.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,N.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,N.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,N.jsx)(i,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,N.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her travel journal as you journey together, rest by the fire, and cross chapter milestones.`})]})}),v===`codex`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(u,{className:`w-4 h-4 text-amber-600`}),(0,N.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,N.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,N.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:o?.heroName||`Champion`})]}),(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,N.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:o?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),o?.preferredLanguage&&(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,N.jsx)(`span`,{className:`font-bold text-ink-black`,children:o.preferredLanguage})]})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,N.jsx)(g,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Mastered Patterns (`,o?.strengths?.length||0,`)`]})]}),o?.strengths&&o.strengths.length>0?(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.strengths.map(e=>(0,N.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,m&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>m(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,N.jsx)(l,{className:`w-3 h-3`})})]},e))}):(0,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note trials you conquer along our journey.`})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,N.jsx)(r,{className:`w-3.5 h-3.5`}),(0,N.jsxs)(`span`,{children:[`Nemesis Patterns (`,o?.nemesisPatterns?.length||0,`)`]})]}),o?.nemesisPatterns&&o.nemesisPatterns.length>0?(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.nemesisPatterns.map(e=>(0,N.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,m&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>m(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,N.jsx)(l,{className:`w-3 h-3`})})]},e))}):(0,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks difficult trials to help you prepare targeted drills.`})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,N.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,o?.personalNotes?.length||0,`)`]})}),o?.personalNotes&&o.personalNotes.length>0?(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:o.personalNotes.map(e=>(0,N.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,N.jsxs)(`span`,{children:[`• `,e]}),m&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>m(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,N.jsx)(f,{className:`w-3 h-3`})})]},e))}):(0,N.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.`})]}),c&&c.length>0&&(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,N.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,N.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[c.length,` events`]})]}),(0,N.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:c.slice(0,8).map(e=>(0,N.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.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,N.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,N.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,N.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,N.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,N.jsx)(p,{className:`w-3.5 h-3.5 text-amber-500`}),(0,N.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,N.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[d?.length||0,` executed`]})]}),d&&d.length>0?(0,N.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,N.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,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.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,N.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,N.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,N.jsx)(h,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,N.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,N.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,N.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,N.jsx)(`button`,{type:`button`,onClick:_,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 B=e({default:()=>V});function V({onClose:e,onMinimize:t,isActive:r=!0,onFocus:i,zIndex:a}){let o=T(),[s,c]=(0,k.useState)(b()),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[h,g]=(0,k.useState)(!1);(0,k.useEffect)(()=>{S.syncWithBackend(),S.triggerProactiveGreeting()},[]);let _=(0,k.useCallback)(()=>{e?e():O.getState().closeWindow(`companion`)},[e]),v=(0,k.useCallback)(()=>{t?t():O.getState().minimizeWindow(`companion`)},[t]),y=(0,k.useCallback)(()=>{i?i():O.getState().setActiveWindow(`companion`)},[i]),C=(0,k.useCallback)(()=>{let e=!s;c(e),D(e)},[s]),w=(0,k.useCallback)(()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&S.clearTranscript()},[]),A=(0,k.useCallback)(e=>{S.setIsTyping(e)},[]),j=(0,k.useMemo)(()=>[...o.transcript].reverse().find(e=>e.sender===`princess`)||o.transcript[0],[o.transcript]),M=`Welcome back to camp. How is your strength holding up today? Are you ready to continue our journey, or would you like to rest for a while?`,F=j?j.isStreaming?j.text:j.text||(o.isLoading?``:M):M,I=(0,k.useMemo)(()=>{let e=j?.choiceSuggestions&&j.choiceSuggestions.length>0?j.choiceSuggestions:[...o.transcript].reverse().find(e=>e.sender===`princess`&&e.choiceSuggestions&&e.choiceSuggestions.length>0)?.choiceSuggestions,t=E(e,o.heroCodex?.heroName||o.heroProfile?.heroName||`Champion`,o.companionSettings.name||`Princess Aurelia`);return t.length>0?t:x},[j,o.transcript,o.heroCodex?.heroName,o.heroProfile?.heroName,o.companionSettings.name]);return(0,N.jsxs)(`div`,{onClick:y,className:`fixed inset-x-0 top-0 bottom-[40px] select-none pointer-events-none overflow-hidden font-sans`,style:{zIndex:a??(r?40:30)},children:[(0,N.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-slate-950/35 via-slate-900/10 to-transparent pointer-events-none z-0`}),(0,N.jsxs)(`div`,{className:`relative w-full h-full flex flex-col justify-end pointer-events-none pb-2 sm:pb-3 px-2 sm:px-4 md:px-8`,children:[(0,N.jsxs)(`div`,{className:`relative w-full max-w-5xl lg:max-w-6xl mx-auto flex items-end justify-start pointer-events-none`,children:[(0,N.jsx)(`div`,{className:`relative z-30 shrink-0 pointer-events-auto -mr-6 sm:-mr-10 md:-mr-12 lg:-mr-14`,children:(0,N.jsx)(P,{emotion:o.activeEmotion,floor:o.currentFloor,rhythm:o.currentRhythm,activity:o.currentActivity,isLoading:o.isLoading,onClick:y})}),(0,N.jsx)(`div`,{className:`relative z-20 flex-1 min-w-0 pointer-events-auto mb-1`,children:(0,N.jsx)(L,{characterName:o.companionSettings.name||`Princess Aurelia`,emotion:o.activeEmotion,text:F,isStreaming:j?.isStreaming,isLoading:o.isLoading,choices:I,toolCalls:j?.toolCalls,onSelectChoice:e=>S.sendMessage(e),onSendMessage:e=>S.sendMessage(e),onTypingStatusChange:A,currentFloor:o.currentFloor,bondTier:o.bondTier,satchelCount:o.unlockedLetters.length,isMuted:s,onToggleMute:C,onOpenProgress:()=>d(!0),onOpenSatchel:()=>p(!0),onOpenHistory:()=>g(!0),onMinimize:v,onClose:_,isActive:r})})]}),(0,N.jsxs)(`div`,{className:`absolute bottom-1 right-3.5 pointer-events-none z-30 hidden md:flex flex-col items-center gap-0.5 opacity-65 select-none`,children:[(0,N.jsx)(`svg`,{className:`w-8 h-8 text-[#9cbcdb] drop-shadow-[0_0_6px_rgba(156,188,219,0.5)] rotate-6`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,N.jsx)(`path`,{d:`M12 2 C12 7.8 7.8 12 2 12 C7.8 12 12 16.2 12 22 C12 16.2 16.2 12 22 12 C16.2 12 12 7.8 12 2 Z`})}),(0,N.jsxs)(`div`,{className:`font-mono text-[9px] text-[#7ba4c8] tracking-tight leading-tight text-center`,children:[(0,N.jsx)(`div`,{children:`AlgoSpaced (Beta)`}),(0,N.jsx)(`div`,{children:`Build Jun24 preview`})]})]})]}),u&&(0,N.jsx)(`div`,{className:`pointer-events-auto`,children:(0,N.jsx)(R,{currentFloor:o.currentFloor,totalSolved:o.totalSolved,onClose:()=>d(!1)})}),f&&(0,N.jsx)(`div`,{className:`pointer-events-auto`,children:(0,N.jsx)(z,{unlockedLetters:o.unlockedLetters,spireChronicles:o.spireChronicles,currentFloor:o.currentFloor,heroCodex:o.heroCodex,episodicEvents:o.episodicEvents,recentToolTelemetry:o.recentToolTelemetry,onRemoveCodexItem:S.removeCodexItem,onClose:()=>p(!1)})}),h&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 pointer-events-auto`,onClick:()=>g(!1),children:(0,N.jsxs)(`div`,{className:`bg-[#142335] border-[3px] border-[#5a80a2] rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[0_16px_40px_rgba(0,0,0,0.85)] flex flex-col overflow-hidden text-white`,onClick:e=>e.stopPropagation(),style:{boxShadow:`inset 0 0 0 1px #0a1420, inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.85)`},children:[(0,N.jsxs)(`div`,{className:`bg-[#101b2a] border-b border-[#304f6f] px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(n,{className:`w-4 h-4 text-[#67b1ec]`}),(0,N.jsxs)(`h4`,{className:`font-mono font-bold text-xs sm:text-sm text-[#e6f0fa] m-0`,children:[`Dialogue Transcript (`,o.transcript.length,` turns)`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:w,className:`px-2 py-0.5 bg-rose-950/60 hover:bg-rose-900 border border-rose-700/60 rounded text-[11px] font-mono font-bold text-rose-300 hover:text-white flex items-center gap-1 cursor-pointer mr-1 transition-colors`,title:`Clear Chat History`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{children:`Clear`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`p-1 hover:bg-[#203a55] rounded text-[#8cb4db] hover:text-white cursor-pointer transition-colors`,title:`Close`,children:(0,N.jsx)(l,{className:`w-4 h-4`})})]})]}),(0,N.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5 bg-[#0e1824]/90`,children:o.transcript.map((e,t)=>(0,N.jsxs)(`div`,{className:`p-2.5 rounded-lg border font-mono text-xs max-w-[90%] shadow-md ${e.sender===`princess`?`bg-[#182c42] border-[#3e6080] text-[#e6f0fa] self-start`:`bg-[#214365] border-[#5a8bb9] text-white self-end`}`,children:[(0,N.jsx)(`div`,{className:`text-[10px] font-bold mb-1 text-[#f6d267]`,children:e.sender===`princess`?o.companionSettings.name:`Hero`}),(0,N.jsx)(`p`,{className:`font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:e.text})]},e.id||t))})]})})]})}export{B as t};
 
 
algospaced-ui/dist/assets/ProblemSpecPanel-0WaGunPO.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,F as n,Ft as r,I as i,Pt as ee,Qt as a,R as o,Tt as te,Xt as s,Y as c,Z as ne,a as l,dt as u,f as d,ht as f,lt as re,m as ie,o as ae,p,ut as oe,yt as se}from"./vendor-react-oIjZMgNV.js";import{u as m}from"./index-B53AvSbH.js";import{n as h,t as g}from"./MarkdownRenderer-B_9j9AKs.js";import{n as ce}from"./ReviewQueue-15B52jqH.js";var _=e(a(),1),v=s(),y=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}var b=({leftTab:e,onSelectLeftTab:a,mobileView:s,isNarrow:b=!1,problem:x,parsed:S,userSolution:ue,officialSolution:de,effectiveReferenceCode:fe,copiedSnippet:C,onCopyText:w,saveRefError:T,aiSolutionLoading:E,aiSolutionError:D,onFetchAiSolution:pe,explainLoading:O,explainError:k,explanationText:A,onExplainCode:me,activeReview:j,onUpdateSolutions:M})=>{let[N,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(()=>x.id||x.name),[L,R]=(0,_.useState)(0),[z,B]=(0,_.useState)(!1),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)({name:``,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1}),[G,K]=(0,_.useState)(!1),[q,J]=(0,_.useState)(null),Y=x.id||x.name;F!==Y&&(I(Y),P(!1),R(0),B(!1),H(null),J(null));let X=ce(x,de,ue),Z=L<X.length?L:0,Q=X[Z];(0,_.useEffect)(()=>{if(q){let e=setTimeout(()=>J(null),3500);return()=>clearTimeout(e)}},[q]);let he=async()=>{if(!U.name.trim()){J({type:`error`,message:`Solution name cannot be empty.`});return}if(!U.code.trim()){J({type:`error`,message:`Solution code cannot be empty.`});return}K(!0),J(null);try{let e;if(V)e=X.map(e=>e.id===V?{...e,name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal}:U.is_optimal&&e.id!==V?{...e,is_optimal:!1}:e);else{let t={id:le(),name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal||X.length===0};e=t.is_optimal?[...X.map(e=>({...e,is_optimal:!1})),t]:[...X,t]}let t=e.find(e=>e.is_optimal)||e[0];x.id&&await m(x.id,e,t?.time_complexity,t?.space_complexity,x),M?.(e),J({type:`success`,message:V?`Solution updated successfully!`:`New solution added to problem dossier!`}),B(!1),H(null),R(V?Z:e.length-1)}catch(e){let t=e instanceof Error?e.message:`Failed to save solution.`;J({type:`error`,message:t})}finally{K(!1)}},ge=async e=>{if(X.length<=1){J({type:`error`,message:`Problem must have at least one solution.`});return}if(window.confirm(`Are you sure you want to remove this solution?`)){K(!0);try{let t=X.filter(t=>t.id!==e);!t.some(e=>e.is_optimal)&&t.length>0&&(t[0].is_optimal=!0);let n=t.find(e=>e.is_optimal)||t[0];x.id&&await m(x.id,t,n?.time_complexity,n?.space_complexity,x),M?.(t),R(0),J({type:`success`,message:`Solution removed successfully.`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete solution.`;J({type:`error`,message:t})}finally{K(!1)}}},$=e=>`cursor-pointer font-arcade text-[7.5px] min-[400px]:text-[8px] sm:text-[8.5px] transition-all flex items-center justify-center gap-1 sm:gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink-black select-none whitespace-nowrap shrink-0 ${e?`h-10 px-2 sm:px-2.5 bg-paper-white text-ink-black font-extrabold border-t-2 border-x-2 border-b-0 border-ink-black relative z-10 -mb-[2px] pb-[10px] shadow-[0_-2px_0_0_rgba(30,41,59,0.06)] after:content-[''] after:absolute after:-bottom-[2px] after:left-0 after:right-0 after:h-[2.5px] after:bg-paper-white after:z-10`:`h-9 px-2 sm:px-2.5 bg-[#e8e4da] text-slate-700 hover:bg-[#efece3] hover:text-ink-black font-bold border-2 border-ink-black relative z-0 mb-0`}`;return(0,v.jsxs)(`div`,{className:`w-full ${b?`flex flex-1`:`lg:w-[49%] flex`} flex-col bg-paper-white border-b-[3px] lg:border-b-0 ${b?``:`lg:border-r-[3px]`} border-ink-black overflow-hidden ${b&&s!==`spec`&&s!==`ref`?`hidden`:`flex`}`,children:[(0,v.jsxs)(`div`,{className:`shrink-0 bg-[#f4f1ea] border-b-2 border-ink-black px-1.5 sm:px-2.5 pt-2 flex items-end gap-1 relative z-10 overflow-x-auto no-scrollbar`,children:[(0,v.jsxs)(`button`,{onClick:()=>a(`spec`),className:$(e===`spec`),children:[(0,v.jsx)(re,{className:`w-3 h-3 text-purple-700 shrink-0`}),(0,v.jsx)(`span`,{children:b?`SPEC`:`SPECIFICATIONS`})]}),(0,v.jsxs)(`button`,{onClick:()=>a(`ref`),className:$(e===`ref`),children:[(0,v.jsx)(se,{className:`w-3 h-3 text-blue-700 shrink-0`}),(0,v.jsx)(`span`,{children:b?`SOL (${X.length})`:`SOLUTIONS (${X.length})`})]}),(0,v.jsxs)(`button`,{onClick:()=>a(`fsrs`),className:$(e===`fsrs`),children:[(0,v.jsx)(p,{className:`w-3 h-3 text-emerald-700 shrink-0`}),(0,v.jsx)(`span`,{className:`whitespace-nowrap`,children:b?`FSRS`:`FSRS STATS`})]})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto no-scrollbar p-4 sm:p-5 space-y-4`,children:[e===`spec`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsx)(`div`,{children:(0,v.jsx)(`h2`,{className:`text-base sm:text-lg font-extrabold text-ink-black font-headline-md leading-tight m-0 select-text`,children:x.name||`Algorithm Problem`})}),S.description&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2 flex items-center gap-1`,children:[(0,v.jsx)(r,{className:`w-3 h-3 text-primary`}),`PROBLEM DESCRIPTION`]}),(0,v.jsx)(`div`,{className:`font-sans text-xs sm:text-[13px] text-slate-800 leading-relaxed space-y-2 font-medium`,children:S.description.split(`
2
+ `).map((e,t)=>e.trim()?(0,v.jsx)(`p`,{className:`m-0 leading-relaxed whitespace-pre-wrap select-text`,children:h(e)},t):(0,v.jsx)(`div`,{className:`h-1.5`},t))})]}),S.examples.length>0&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-2.5`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(l,{className:`w-3 h-3 text-amber-500`}),`EXAMPLES (`,S.examples.length,`)`]}),(0,v.jsx)(`div`,{className:`space-y-2.5`,children:S.examples.map((e,t)=>(0,v.jsxs)(`div`,{className:`p-3 bg-slate-50 border border-slate-200 space-y-2 text-xs`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-primary`,children:[`EXAMPLE `,t+1]}),e.input&&(0,v.jsxs)(`button`,{onClick:()=>w(e.input,`ex-${t}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black text-[9px] font-arcade text-ink-black flex items-center gap-1 cursor-pointer`,title:`Copy input data`,children:[(0,v.jsx)(f,{className:`w-2.5 h-2.5`}),C===`ex-${t}`?`COPIED!`:`COPY`]})]}),e.input&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Input:`}),(0,v.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.input})]}),e.output&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Output:`}),(0,v.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.output})]}),e.explanation&&(0,v.jsxs)(`div`,{className:`text-[11px] font-sans text-slate-600 bg-white p-2 border border-slate-200`,children:[(0,v.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Explanation: `}),h(e.explanation)]})]},t))})]}),S.constraints.length>0&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,v.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2`,children:`CONSTRAINTS`}),(0,v.jsx)(`ul`,{className:`space-y-1.5 list-none m-0 p-0`,children:S.constraints.map((e,t)=>(0,v.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,v.jsx)(`span`,{className:`text-primary font-bold select-none`,children:`•`}),(0,v.jsx)(`code`,{className:`bg-slate-100 text-ink-black font-code-mono px-2 py-0.5 border border-slate-300 text-[11px] select-text`,children:e})]},t))})]})]}),N?(0,v.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,v.jsx)(l,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,v.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase`,children:`OPTIMAL TARGET:`}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,x.optimal_time||`O(N)`]}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,x.optimal_space||`O(1)`]})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>P(!1),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black font-arcade text-[8px] text-trash-gray hover:text-ink-black cursor-pointer flex items-center gap-1`,title:`Conceal target complexity`,children:[(0,v.jsx)(u,{className:`w-2.5 h-2.5`}),(0,v.jsx)(`span`,{children:`HIDE`})]})]}):(0,v.jsxs)(`div`,{className:`p-3 bg-amber-50/70 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center justify-between gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(c,{className:`w-4 h-4 text-amber-700 shrink-0`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase block`,children:`OPTIMAL COMPLEXITY TARGET`}),(0,v.jsx)(`span`,{className:`text-[10px] font-sans text-slate-600 font-semibold`,children:`Hidden to test active recall before coding`})]})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>P(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-100 border-2 border-ink-black font-arcade text-[8.5px] font-bold text-ink-black shadow-[1.5px_1.5px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,title:`Click to reveal target time and space complexity`,children:[(0,v.jsx)(oe,{className:`w-3 h-3 text-amber-700`}),(0,v.jsx)(`span`,{children:`REVEAL TARGET`})]})]})]}),e===`ref`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[q&&(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-bold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${q.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-700`:`bg-rose-100 text-rose-900 border-rose-700`}`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q.type===`success`?(0,v.jsx)(te,{className:`w-4 h-4 text-emerald-700 shrink-0`}):(0,v.jsx)(d,{className:`w-4 h-4 text-rose-700 shrink-0`}),(0,v.jsx)(`span`,{children:q.message})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>J(null),className:`text-slate-600 hover:text-ink-black cursor-pointer`,children:(0,v.jsx)(ae,{className:`w-3.5 h-3.5`})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1 p-1 bg-slate-200/90 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] overflow-x-auto no-scrollbar`,children:[X.map((e,n)=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{R(n),B(!1),H(null)},className:`py-1 px-2 rounded-full font-arcade text-[8px] font-bold flex items-center justify-center gap-1 border-2 border-ink-black transition-all cursor-pointer whitespace-nowrap shrink-0 ${Z===n&&!z&&!V?`bg-sky-600 text-white shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] -translate-y-0.5`:`bg-white text-ink-black hover:bg-sky-50 shadow-none`}`,title:e.name?`${e.name} (${e.pattern||`Algorithm`})`:`Solution ${n+1}`,children:[e.is_optimal?(0,v.jsx)(t,{className:`w-3 h-3 text-amber-300`}):(0,v.jsx)(r,{className:`w-3 h-3`}),(0,v.jsx)(`span`,{children:`Sol ${n+1}`}),e.is_optimal&&(0,v.jsx)(`span`,{className:`text-[6.5px] px-1 py-0.2 bg-amber-300 text-ink-black border border-ink-black font-extrabold rounded-full tracking-tight`,children:`OPTIMAL`})]},e.id||n)),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!0),H(null),W({name:`Method ${X.length+1}`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1})},className:`h-6 w-6 rounded-full font-arcade text-[9px] font-bold flex items-center justify-center border-2 border-ink-black cursor-pointer shrink-0 active:translate-y-0.5 transition-all shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] ${z?`bg-emerald-600 text-white`:`bg-amber-300 text-ink-black hover:bg-amber-200`}`,title:`Add another solution / method for this problem`,"aria-label":`Add Solution`,children:(0,v.jsx)(i,{className:`w-3 h-3 stroke-[2.5]`})})]}),z||V?(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(o,{className:`w-4 h-4 text-purple-700`}),(0,v.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black uppercase`,children:V?`EDIT SOLUTION`:`ADD NEW SOLUTION / METHOD`})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`text-xs font-arcade text-trash-gray hover:text-rose-600 cursor-pointer font-bold`,children:`CANCEL`})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Solution / Method Name`}),(0,v.jsx)(`input`,{type:`text`,value:U.name,onChange:e=>W({...U,name:e.target.value}),placeholder:`e.g. One-Pass Hash Map, Two Pointers`,className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Pattern / Strategy`}),(0,v.jsx)(`select`,{value:U.pattern,onChange:e=>W({...U,pattern:e.target.value}),className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`,children:y.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Time Complexity`}),(0,v.jsx)(`input`,{type:`text`,value:U.time_complexity,onChange:e=>W({...U,time_complexity:e.target.value}),placeholder:`e.g. O(N), O(N log N), O(N^2)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Space Complexity`}),(0,v.jsx)(`input`,{type:`text`,value:U.space_complexity,onChange:e=>W({...U,space_complexity:e.target.value}),placeholder:`e.g. O(1), O(N)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase`,children:`Python Reference Code`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>W({...U,code:fe}),className:`text-[8.5px] font-arcade text-sky-700 hover:underline cursor-pointer`,children:`Paste Current Code`})]}),(0,v.jsx)(`textarea`,{rows:8,value:U.code,onChange:e=>W({...U,code:e.target.value}),placeholder:`class Solution:
3
+ def solve(self, nums):
4
+ ...`,className:`w-full p-2.5 border-2 border-ink-black bg-[#1E293B] text-[#4ADE80] font-code-mono text-xs focus:outline-none no-scrollbar`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Intuition / How to Solve (Optional)`}),(0,v.jsx)(`textarea`,{rows:3,value:U.explanation,onChange:e=>W({...U,explanation:e.target.value}),placeholder:`Key insight, trade-offs, and state tracking notes...`,className:`w-full p-2 border-2 border-ink-black text-xs bg-[#fdf8e1] focus:outline-none focus:bg-white no-scrollbar`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`input`,{type:`checkbox`,id:`is_optimal_solution`,checked:U.is_optimal,onChange:e=>W({...U,is_optimal:e.target.checked}),className:`w-4 h-4 border-2 border-ink-black rounded cursor-pointer accent-emerald-600`}),(0,v.jsx)(`label`,{htmlFor:`is_optimal_solution`,className:`font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`SET AS OPTIMAL / PRIMARY APPROACH FOR THIS PROBLEM`})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t-2 border-dashed border-ink-black`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`px-3 py-1.5 bg-slate-100 hover:bg-slate-200 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`CANCEL`}),(0,v.jsxs)(`button`,{type:`button`,disabled:G,onClick:he,className:`px-4 py-1.5 bg-emerald-500 hover:bg-emerald-400 border-2 border-ink-black font-arcade text-[9px] font-bold text-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:[G&&(0,v.jsx)(n,{className:`w-3 h-3 animate-spin`}),(0,v.jsx)(`span`,{children:V?`UPDATE SOLUTION`:`SAVE SOLUTION`})]})]})]}):Q?(0,v.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pb-3 border-b border-slate-200`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap min-w-0`,children:[(0,v.jsx)(`h3`,{className:`font-headline-md font-extrabold text-sm sm:text-base text-ink-black m-0 select-text break-words`,children:Q.name||`Solution ${Z+1}`}),Q.is_optimal&&(0,v.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-300 border border-ink-black font-arcade text-[8px] font-bold text-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] shrink-0`,children:`★ OPTIMAL`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap sm:ml-auto`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase`,children:`Pattern:`}),(0,v.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-50 border border-purple-300 font-arcade text-[8.5px] text-purple-800 font-bold`,children:Q.pattern||`General Algorithm`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,Q.time_complexity||`O(N)`]}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,Q.space_complexity||`O(1)`]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{H(Q.id),B(!1),W({name:Q.name,pattern:Q.pattern,time_complexity:Q.time_complexity,space_complexity:Q.space_complexity,code:Q.code,explanation:Q.explanation||``,is_optimal:!!Q.is_optimal})},className:`px-2 py-1 bg-white hover:bg-slate-100 border border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Edit this solution`,children:[(0,v.jsx)(o,{className:`w-3 h-3 text-slate-700`}),(0,v.jsx)(`span`,{className:`hidden sm:inline`,children:`EDIT`})]}),X.length>1&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>ge(Q.id),className:`px-1.5 py-1 bg-white hover:bg-rose-50 border border-ink-black text-rose-700 font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Delete this solution`,children:(0,v.jsx)(ie,{className:`w-3 h-3`})})]})]})]}),Q.code?(0,v.jsxs)(`div`,{className:`border border-ink-black bg-[#0f172a] overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`bg-[#1e293b] px-2.5 sm:px-3 py-1.5 border-b border-ink-black flex items-center justify-between gap-1.5 flex-wrap min-w-0`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-slate-300 font-bold uppercase truncate min-w-0 flex-1`,children:b?`PYTHON 3`:`PYTHON 3 IMPLEMENTATION`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>me(Q.code,Q.pattern,Q.time_complexity,Q.space_complexity),disabled:O,className:`px-2 py-0.5 bg-purple-50 hover:bg-purple-100 text-purple-800 border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 disabled:opacity-50 active:translate-y-0.5 transition-all`,title:`Explain this solution with AI`,children:[O?(0,v.jsx)(n,{className:`w-2.5 h-2.5 animate-spin text-purple-700`}):(0,v.jsx)(t,{className:`w-2.5 h-2.5 text-purple-600`}),(0,v.jsx)(`span`,{children:`Explain✦`})]}),(0,v.jsxs)(`button`,{onClick:()=>w(Q.code,`sol-${Q.id}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 active:translate-y-0.5 transition-all`,title:`Copy solution code`,children:[(0,v.jsx)(f,{className:`w-2.5 h-2.5`}),C===`sol-${Q.id}`?`COPIED!`:`COPY`]})]})]}),(0,v.jsx)(`div`,{className:`p-3 text-xs overflow-x-auto max-h-80 no-scrollbar`,children:(0,v.jsx)(`pre`,{className:`font-code-mono text-[#4ADE80] text-[11px] leading-relaxed select-text m-0`,children:(0,v.jsx)(`code`,{children:Q.code})})})]}):(0,v.jsxs)(`div`,{className:`p-4 bg-amber-50 border border-dashed border-amber-300 text-center space-y-3`,children:[(0,v.jsx)(`p`,{className:`text-xs font-sans text-stone-700`,children:`No code implementation archived for this solution yet.`}),(0,v.jsx)(`button`,{onClick:pe,disabled:E,className:`px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2 disabled:opacity-50`,children:E?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,v.jsx)(`span`,{children:`Generating solution...`})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(t,{className:`w-3.5 h-3.5 text-amber-300`}),(0,v.jsx)(`span`,{children:`Generate solution`})]})}),D&&(0,v.jsx)(`div`,{className:`text-xs text-rose-600 font-medium`,children:D})]}),Q.explanation&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-1.5 select-text`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8.5px] text-trash-gray uppercase font-bold block`,children:`SOLUTION INTUITION & STRATEGY:`}),(0,v.jsx)(g,{content:Q.explanation})]})]}),Q.code&&(0,v.jsxs)(`div`,{className:`space-y-3`,children:[k&&(0,v.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold`,children:k}),A&&(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2 select-text`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,v.jsx)(ee,{className:`w-4 h-4 text-purple-600`}),(0,v.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:[`Gemini Code Breakdown (`,Q.name,`)`]})]}),(0,v.jsx)(`div`,{className:`max-h-96 overflow-y-auto no-scrollbar pt-1 select-text`,children:(0,v.jsx)(g,{content:A})})]})]})]}):null,T&&(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-bold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(244,63,94,1)]`,children:[(0,v.jsx)(d,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,v.jsx)(`div`,{className:`flex-1`,children:T})]})]}),e===`fsrs`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(ne,{className:`w-3 h-3 text-purple-600`}),`SPACED REPETITION PROGRESSION`]}),(0,v.jsx)(`div`,{className:`space-y-2`,children:[{state:0,label:`NEW`,color:`#3b82f6`},{state:1,label:`LEARNING`,color:`#f59e0b`},{state:2,label:`REVIEW`,color:`#10b981`},{state:3,label:`RELEARNING`,color:`#ef4444`}].map(e=>{let t=(j.fsrs_state??0)===e.state;return(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black flex items-center justify-between transition-all ${t?`bg-amber-100 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] translate-x-1 font-bold`:`bg-slate-50 opacity-70`}`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`w-5 h-5 border border-ink-black flex items-center justify-center font-arcade text-[9px] text-white font-bold`,style:{backgroundColor:e.color},children:e.state}),(0,v.jsx)(`span`,{className:`font-arcade text-[9px] text-ink-black`,children:e.label})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-2`,children:t&&(0,v.jsx)(`span`,{className:`px-1.5 py-0.5 bg-emerald-500 text-white font-arcade text-[7px] border border-ink-black font-bold`,children:`CURRENT`})})]},e.state)})})]}),(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(p,{className:`w-3 h-3 text-emerald-600`}),`PERFORMANCE METRICS`]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Total Reviews`}),(0,v.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-ink-black`,children:j.total_attempts||0})]}),(0,v.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Correct Recall`}),(0,v.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-emerald-600`,children:j.times_correct||0})]})]}),(0,v.jsxs)(`div`,{className:`text-xs font-sans text-slate-600 pt-1`,children:[`Next Due Date:`,` `,(0,v.jsx)(`span`,{className:`font-code-mono font-bold text-ink-black`,children:j.next_review?new Date(j.next_review).toLocaleDateString():`Today`})]})]})]})]})]})};export{b as ProblemSpecPanel};
algospaced-ui/dist/assets/ProblemSpecPanel-clZ38uEk.js DELETED
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Ct as n,G as ee,M as te,P as r,St as ne,U as re,Vt as i,a,b as o,d as s,et as ie,f as ae,i as c,it as l,j as u,pt as oe,st as se,tt as ce,u as d,zt as f}from"./vendor-react-CDF1pnIM.js";import{u as p}from"./index-DX2cztXb.js";import{n as m,t as h}from"./MarkdownRenderer-AdFp0pUP.js";import{n as le}from"./ReviewQueue-CSzueRL_.js";var g=e(i(),1),_=f(),ue=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function v(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}var y=({leftTab:e,onSelectLeftTab:i,mobileView:f,isNarrow:y=!1,problem:b,parsed:x,userSolution:de,officialSolution:fe,effectiveReferenceCode:S,copiedSnippet:C,onCopyText:w,saveRefError:T,aiSolutionLoading:E,aiSolutionError:D,onFetchAiSolution:O,explainLoading:k,explainError:A,explanationText:j,onExplainCode:pe,activeReview:M,onUpdateSolutions:N})=>{let[me,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(()=>b.id||b.name),[L,R]=(0,g.useState)(0),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(null),[U,W]=(0,g.useState)({name:``,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1}),[G,K]=(0,g.useState)(!1),[q,J]=(0,g.useState)(null),Y=b.id||b.name;F!==Y&&(I(Y),P(!1),R(0),B(!1),H(null),J(null));let X=le(b,fe,de),Z=L<X.length?L:0,Q=X[Z];(0,g.useEffect)(()=>{if(q){let e=setTimeout(()=>J(null),3500);return()=>clearTimeout(e)}},[q]);let he=async()=>{if(!U.name.trim()){J({type:`error`,message:`Solution name cannot be empty.`});return}if(!U.code.trim()){J({type:`error`,message:`Solution code cannot be empty.`});return}K(!0),J(null);try{let e;if(V)e=X.map(e=>e.id===V?{...e,name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal}:U.is_optimal&&e.id!==V?{...e,is_optimal:!1}:e);else{let t={id:v(),name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal||X.length===0};e=t.is_optimal?[...X.map(e=>({...e,is_optimal:!1})),t]:[...X,t]}let t=e.find(e=>e.is_optimal)||e[0];b.id&&await p(b.id,e,t?.time_complexity,t?.space_complexity,b),N?.(e),J({type:`success`,message:V?`Solution updated successfully!`:`New solution added to problem dossier!`}),B(!1),H(null),R(V?Z:e.length-1)}catch(e){let t=e instanceof Error?e.message:`Failed to save solution.`;J({type:`error`,message:t})}finally{K(!1)}},ge=async e=>{if(X.length<=1){J({type:`error`,message:`Problem must have at least one solution.`});return}if(window.confirm(`Are you sure you want to remove this solution?`)){K(!0);try{let t=X.filter(t=>t.id!==e);!t.some(e=>e.is_optimal)&&t.length>0&&(t[0].is_optimal=!0);let n=t.find(e=>e.is_optimal)||t[0];b.id&&await p(b.id,t,n?.time_complexity,n?.space_complexity,b),N?.(t),R(0),J({type:`success`,message:`Solution removed successfully.`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete solution.`;J({type:`error`,message:t})}finally{K(!1)}}},$=e=>`cursor-pointer font-arcade text-[7.5px] min-[400px]:text-[8px] sm:text-[8.5px] transition-all flex items-center justify-center gap-1 sm:gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink-black select-none whitespace-nowrap shrink-0 ${e?`h-10 px-2 sm:px-2.5 bg-paper-white text-ink-black font-extrabold border-t-2 border-x-2 border-b-0 border-ink-black relative z-10 -mb-[2px] pb-[10px] shadow-[0_-2px_0_0_rgba(30,41,59,0.06)] after:content-[''] after:absolute after:-bottom-[2px] after:left-0 after:right-0 after:h-[2.5px] after:bg-paper-white after:z-10`:`h-9 px-2 sm:px-2.5 bg-[#e8e4da] text-slate-700 hover:bg-[#efece3] hover:text-ink-black font-bold border-2 border-ink-black relative z-0 mb-0`}`;return(0,_.jsxs)(`div`,{className:`w-full ${y?`flex flex-1`:`lg:w-[49%] flex`} flex-col bg-paper-white border-b-[3px] lg:border-b-0 ${y?``:`lg:border-r-[3px]`} border-ink-black overflow-hidden ${y&&f!==`spec`&&f!==`ref`?`hidden`:`flex`}`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 bg-[#f4f1ea] border-b-2 border-ink-black px-1.5 sm:px-2.5 pt-2 flex items-end gap-1 relative z-10 overflow-x-auto no-scrollbar`,children:[(0,_.jsxs)(`button`,{onClick:()=>i(`spec`),className:$(e===`spec`),children:[(0,_.jsx)(t,{className:`w-3 h-3 text-purple-700 shrink-0`}),(0,_.jsx)(`span`,{children:y?`SPEC`:`SPECIFICATIONS`})]}),(0,_.jsxs)(`button`,{onClick:()=>i(`ref`),className:$(e===`ref`),children:[(0,_.jsx)(se,{className:`w-3 h-3 text-blue-700 shrink-0`}),(0,_.jsx)(`span`,{children:y?`SOL (${X.length})`:`SOLUTIONS (${X.length})`})]}),(0,_.jsxs)(`button`,{onClick:()=>i(`fsrs`),className:$(e===`fsrs`),children:[(0,_.jsx)(s,{className:`w-3 h-3 text-emerald-700 shrink-0`}),(0,_.jsx)(`span`,{className:`whitespace-nowrap`,children:y?`FSRS`:`FSRS STATS`})]})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto no-scrollbar p-4 sm:p-5 space-y-4`,children:[e===`spec`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsx)(`div`,{children:(0,_.jsx)(`h2`,{className:`text-base sm:text-lg font-extrabold text-ink-black font-headline-md leading-tight m-0 select-text`,children:b.name||`Algorithm Problem`})}),x.description&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2 flex items-center gap-1`,children:[(0,_.jsx)(n,{className:`w-3 h-3 text-primary`}),`PROBLEM DESCRIPTION`]}),(0,_.jsx)(`div`,{className:`font-sans text-xs sm:text-[13px] text-slate-800 leading-relaxed space-y-2 font-medium`,children:x.description.split(`
2
- `).map((e,t)=>e.trim()?(0,_.jsx)(`p`,{className:`m-0 leading-relaxed whitespace-pre-wrap select-text`,children:m(e)},t):(0,_.jsx)(`div`,{className:`h-1.5`},t))})]}),x.examples.length>0&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-2.5`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(c,{className:`w-3 h-3 text-amber-500`}),`EXAMPLES (`,x.examples.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2.5`,children:x.examples.map((e,t)=>(0,_.jsxs)(`div`,{className:`p-3 bg-slate-50 border border-slate-200 space-y-2 text-xs`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-primary`,children:[`EXAMPLE `,t+1]}),e.input&&(0,_.jsxs)(`button`,{onClick:()=>w(e.input,`ex-${t}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black text-[9px] font-arcade text-ink-black flex items-center gap-1 cursor-pointer`,title:`Copy input data`,children:[(0,_.jsx)(l,{className:`w-2.5 h-2.5`}),C===`ex-${t}`?`COPIED!`:`COPY`]})]}),e.input&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Input:`}),(0,_.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.input})]}),e.output&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Output:`}),(0,_.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.output})]}),e.explanation&&(0,_.jsxs)(`div`,{className:`text-[11px] font-sans text-slate-600 bg-white p-2 border border-slate-200`,children:[(0,_.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Explanation: `}),m(e.explanation)]})]},t))})]}),x.constraints.length>0&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,_.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2`,children:`CONSTRAINTS`}),(0,_.jsx)(`ul`,{className:`space-y-1.5 list-none m-0 p-0`,children:x.constraints.map((e,t)=>(0,_.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,_.jsx)(`span`,{className:`text-primary font-bold select-none`,children:`•`}),(0,_.jsx)(`code`,{className:`bg-slate-100 text-ink-black font-code-mono px-2 py-0.5 border border-slate-300 text-[11px] select-text`,children:e})]},t))})]})]}),me?(0,_.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex flex-wrap items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsx)(c,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,_.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase`,children:`OPTIMAL TARGET:`}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,b.optimal_time||`O(N)`]}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,b.optimal_space||`O(1)`]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>P(!1),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black font-arcade text-[8px] text-trash-gray hover:text-ink-black cursor-pointer flex items-center gap-1`,title:`Conceal target complexity`,children:[(0,_.jsx)(ce,{className:`w-2.5 h-2.5`}),(0,_.jsx)(`span`,{children:`HIDE`})]})]}):(0,_.jsxs)(`div`,{className:`p-3 bg-amber-50/70 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(re,{className:`w-4 h-4 text-amber-700 shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase block`,children:`OPTIMAL COMPLEXITY TARGET`}),(0,_.jsx)(`span`,{className:`text-[10px] font-sans text-slate-600 font-semibold`,children:`Hidden to test active recall before coding`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>P(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-100 border-2 border-ink-black font-arcade text-[8.5px] font-bold text-ink-black shadow-[1.5px_1.5px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,title:`Click to reveal target time and space complexity`,children:[(0,_.jsx)(ie,{className:`w-3 h-3 text-amber-700`}),(0,_.jsx)(`span`,{children:`REVEAL TARGET`})]})]})]}),e===`ref`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[q&&(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-bold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${q.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-700`:`bg-rose-100 text-rose-900 border-rose-700`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q.type===`success`?(0,_.jsx)(oe,{className:`w-4 h-4 text-emerald-700 shrink-0`}):(0,_.jsx)(d,{className:`w-4 h-4 text-rose-700 shrink-0`}),(0,_.jsx)(`span`,{children:q.message})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>J(null),className:`text-slate-600 hover:text-ink-black cursor-pointer`,children:(0,_.jsx)(a,{className:`w-3.5 h-3.5`})})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1 p-1 bg-slate-200/90 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] overflow-x-auto no-scrollbar`,children:[X.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{R(t),B(!1),H(null)},className:`py-1 px-2 rounded-full font-arcade text-[8px] font-bold flex items-center justify-center gap-1 border-2 border-ink-black transition-all cursor-pointer whitespace-nowrap shrink-0 ${Z===t&&!z&&!V?`bg-sky-600 text-white shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] -translate-y-0.5`:`bg-white text-ink-black hover:bg-sky-50 shadow-none`}`,title:e.name?`${e.name} (${e.pattern||`Algorithm`})`:`Solution ${t+1}`,children:[e.is_optimal?(0,_.jsx)(o,{className:`w-3 h-3 text-amber-300`}):(0,_.jsx)(n,{className:`w-3 h-3`}),(0,_.jsx)(`span`,{children:`Sol ${t+1}`}),e.is_optimal&&(0,_.jsx)(`span`,{className:`text-[6.5px] px-1 py-0.2 bg-amber-300 text-ink-black border border-ink-black font-extrabold rounded-full tracking-tight`,children:`OPTIMAL`})]},e.id||t)),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!0),H(null),W({name:`Method ${X.length+1}`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1})},className:`h-6 w-6 rounded-full font-arcade text-[9px] font-bold flex items-center justify-center border-2 border-ink-black cursor-pointer shrink-0 active:translate-y-0.5 transition-all shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] ${z?`bg-emerald-600 text-white`:`bg-amber-300 text-ink-black hover:bg-amber-200`}`,title:`Add another solution / method for this problem`,"aria-label":`Add Solution`,children:(0,_.jsx)(te,{className:`w-3 h-3 stroke-[2.5]`})})]}),z||V?(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{className:`w-4 h-4 text-purple-700`}),(0,_.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black uppercase`,children:V?`EDIT SOLUTION`:`ADD NEW SOLUTION / METHOD`})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`text-xs font-arcade text-trash-gray hover:text-rose-600 cursor-pointer font-bold`,children:`CANCEL`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Solution / Method Name`}),(0,_.jsx)(`input`,{type:`text`,value:U.name,onChange:e=>W({...U,name:e.target.value}),placeholder:`e.g. One-Pass Hash Map, Two Pointers`,className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Pattern / Strategy`}),(0,_.jsx)(`select`,{value:U.pattern,onChange:e=>W({...U,pattern:e.target.value}),className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`,children:ue.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Time Complexity`}),(0,_.jsx)(`input`,{type:`text`,value:U.time_complexity,onChange:e=>W({...U,time_complexity:e.target.value}),placeholder:`e.g. O(N), O(N log N), O(N^2)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Space Complexity`}),(0,_.jsx)(`input`,{type:`text`,value:U.space_complexity,onChange:e=>W({...U,space_complexity:e.target.value}),placeholder:`e.g. O(1), O(N)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase`,children:`Python Reference Code`}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>W({...U,code:S}),className:`text-[8.5px] font-arcade text-sky-700 hover:underline cursor-pointer`,children:`Paste Current Code`})]}),(0,_.jsx)(`textarea`,{rows:8,value:U.code,onChange:e=>W({...U,code:e.target.value}),placeholder:`class Solution:
3
- def solve(self, nums):
4
- ...`,className:`w-full p-2.5 border-2 border-ink-black bg-[#1E293B] text-[#4ADE80] font-code-mono text-xs focus:outline-none no-scrollbar`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Intuition / How to Solve (Optional)`}),(0,_.jsx)(`textarea`,{rows:3,value:U.explanation,onChange:e=>W({...U,explanation:e.target.value}),placeholder:`Key insight, trade-offs, and state tracking notes...`,className:`w-full p-2 border-2 border-ink-black text-xs bg-[#fdf8e1] focus:outline-none focus:bg-white no-scrollbar`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`checkbox`,id:`is_optimal_solution`,checked:U.is_optimal,onChange:e=>W({...U,is_optimal:e.target.checked}),className:`w-4 h-4 border-2 border-ink-black rounded cursor-pointer accent-emerald-600`}),(0,_.jsx)(`label`,{htmlFor:`is_optimal_solution`,className:`font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`SET AS OPTIMAL / PRIMARY APPROACH FOR THIS PROBLEM`})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t-2 border-dashed border-ink-black`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`px-3 py-1.5 bg-slate-100 hover:bg-slate-200 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`CANCEL`}),(0,_.jsxs)(`button`,{type:`button`,disabled:G,onClick:he,className:`px-4 py-1.5 bg-emerald-500 hover:bg-emerald-400 border-2 border-ink-black font-arcade text-[9px] font-bold text-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:[G&&(0,_.jsx)(u,{className:`w-3 h-3 animate-spin`}),(0,_.jsx)(`span`,{children:V?`UPDATE SOLUTION`:`SAVE SOLUTION`})]})]})]}):Q?(0,_.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pb-3 border-b border-slate-200`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap min-w-0`,children:[(0,_.jsx)(`h3`,{className:`font-headline-md font-extrabold text-sm sm:text-base text-ink-black m-0 select-text break-words`,children:Q.name||`Solution ${Z+1}`}),Q.is_optimal&&(0,_.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-300 border border-ink-black font-arcade text-[8px] font-bold text-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] shrink-0`,children:`★ OPTIMAL`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap sm:ml-auto`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase`,children:`Pattern:`}),(0,_.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-50 border border-purple-300 font-arcade text-[8.5px] text-purple-800 font-bold`,children:Q.pattern||`General Algorithm`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,Q.time_complexity||`O(N)`]}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,Q.space_complexity||`O(1)`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{H(Q.id),B(!1),W({name:Q.name,pattern:Q.pattern,time_complexity:Q.time_complexity,space_complexity:Q.space_complexity,code:Q.code,explanation:Q.explanation||``,is_optimal:!!Q.is_optimal})},className:`px-2 py-1 bg-white hover:bg-slate-100 border border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Edit this solution`,children:[(0,_.jsx)(r,{className:`w-3 h-3 text-slate-700`}),(0,_.jsx)(`span`,{className:`hidden sm:inline`,children:`EDIT`})]}),X.length>1&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>ge(Q.id),className:`px-1.5 py-1 bg-white hover:bg-rose-50 border border-ink-black text-rose-700 font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Delete this solution`,children:(0,_.jsx)(ae,{className:`w-3 h-3`})})]})]})]}),Q.code?(0,_.jsxs)(`div`,{className:`border border-ink-black bg-[#0f172a] overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`bg-[#1e293b] px-2.5 sm:px-3 py-1.5 border-b border-ink-black flex items-center justify-between gap-1.5 flex-wrap min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-slate-300 font-bold uppercase truncate min-w-0 flex-1`,children:y?`PYTHON 3`:`PYTHON 3 IMPLEMENTATION`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>pe(Q.code,Q.pattern,Q.time_complexity,Q.space_complexity),disabled:k,className:`px-2 py-0.5 bg-purple-50 hover:bg-purple-100 text-purple-800 border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 disabled:opacity-50 active:translate-y-0.5 transition-all`,title:`Explain this solution with AI`,children:[k?(0,_.jsx)(u,{className:`w-2.5 h-2.5 animate-spin text-purple-700`}):(0,_.jsx)(o,{className:`w-2.5 h-2.5 text-purple-600`}),(0,_.jsx)(`span`,{children:`Explain✦`})]}),(0,_.jsxs)(`button`,{onClick:()=>w(Q.code,`sol-${Q.id}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 active:translate-y-0.5 transition-all`,title:`Copy solution code`,children:[(0,_.jsx)(l,{className:`w-2.5 h-2.5`}),C===`sol-${Q.id}`?`COPIED!`:`COPY`]})]})]}),(0,_.jsx)(`div`,{className:`p-3 text-xs overflow-x-auto max-h-80 no-scrollbar`,children:(0,_.jsx)(`pre`,{className:`font-code-mono text-[#4ADE80] text-[11px] leading-relaxed select-text m-0`,children:(0,_.jsx)(`code`,{children:Q.code})})})]}):(0,_.jsxs)(`div`,{className:`p-4 bg-amber-50 border border-dashed border-amber-300 text-center space-y-3`,children:[(0,_.jsx)(`p`,{className:`text-xs font-sans text-stone-700`,children:`No code implementation archived for this solution yet.`}),(0,_.jsx)(`button`,{onClick:O,disabled:E,className:`px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2 disabled:opacity-50`,children:E?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`w-3.5 h-3.5 animate-spin`}),(0,_.jsx)(`span`,{children:`Generating solution...`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(o,{className:`w-3.5 h-3.5 text-amber-300`}),(0,_.jsx)(`span`,{children:`Generate solution`})]})}),D&&(0,_.jsx)(`div`,{className:`text-xs text-rose-600 font-medium`,children:D})]}),Q.explanation&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-1.5 select-text`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8.5px] text-trash-gray uppercase font-bold block`,children:`SOLUTION INTUITION & STRATEGY:`}),(0,_.jsx)(h,{content:Q.explanation})]})]}),Q.code&&(0,_.jsxs)(`div`,{className:`space-y-3`,children:[A&&(0,_.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold`,children:A}),j&&(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2 select-text`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,_.jsx)(ne,{className:`w-4 h-4 text-purple-600`}),(0,_.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:[`Gemini Code Breakdown (`,Q.name,`)`]})]}),(0,_.jsx)(`div`,{className:`max-h-96 overflow-y-auto no-scrollbar pt-1 select-text`,children:(0,_.jsx)(h,{content:j})})]})]})]}):null,T&&(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-bold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(244,63,94,1)]`,children:[(0,_.jsx)(d,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,_.jsx)(`div`,{className:`flex-1`,children:T})]})]}),e===`fsrs`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(ee,{className:`w-3 h-3 text-purple-600`}),`SPACED REPETITION PROGRESSION`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:[{state:0,label:`NEW`,color:`#3b82f6`},{state:1,label:`LEARNING`,color:`#f59e0b`},{state:2,label:`REVIEW`,color:`#10b981`},{state:3,label:`RELEARNING`,color:`#ef4444`}].map(e=>{let t=(M.fsrs_state??0)===e.state;return(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black flex items-center justify-between transition-all ${t?`bg-amber-100 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] translate-x-1 font-bold`:`bg-slate-50 opacity-70`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`w-5 h-5 border border-ink-black flex items-center justify-center font-arcade text-[9px] text-white font-bold`,style:{backgroundColor:e.color},children:e.state}),(0,_.jsx)(`span`,{className:`font-arcade text-[9px] text-ink-black`,children:e.label})]}),(0,_.jsx)(`div`,{className:`flex items-center gap-2`,children:t&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 bg-emerald-500 text-white font-arcade text-[7px] border border-ink-black font-bold`,children:`CURRENT`})})]},e.state)})})]}),(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(s,{className:`w-3 h-3 text-emerald-600`}),`PERFORMANCE METRICS`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Total Reviews`}),(0,_.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-ink-black`,children:M.total_attempts||0})]}),(0,_.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Correct Recall`}),(0,_.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-emerald-600`,children:M.times_correct||0})]})]}),(0,_.jsxs)(`div`,{className:`text-xs font-sans text-slate-600 pt-1`,children:[`Next Due Date:`,` `,(0,_.jsx)(`span`,{className:`font-code-mono font-bold text-ink-black`,children:M.next_review?new Date(M.next_review).toLocaleDateString():`Today`})]})]})]})]})]})};export{y as ProblemSpecPanel};
 
 
 
 
 
algospaced-ui/dist/assets/{PythonChallenge-DwlCVZ7-.js → PythonChallenge-CiLYD15D.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{t as i}from"./MarkdownRenderer-AdFp0pUP.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null),[n,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 r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/python/daily`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.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:n,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 r.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:n})});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...`:`SUBMIT SOLUTION`})}),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};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{t as i}from"./MarkdownRenderer-B_9j9AKs.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null),[n,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 r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/python/daily`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.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:n,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 r.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:n})});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...`:`SUBMIT SOLUTION`})}),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-15B52jqH.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProblemSpecPanel-0WaGunPO.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-oIjZMgNV.js","assets/vendor-codemirror-By0wlJeM.js","assets/index-B53AvSbH.js","assets/firebaseClient-DZobvwSx.js","assets/vendor-firebase-DSIO3PIf.js","assets/vendor-ui-ZXcm-2wU.js","assets/index-BdFdjNzp.css","assets/MarkdownRenderer-B_9j9AKs.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{C as n,Ct as r,F as i,Ft as a,It as o,L as s,Mt as c,N as l,Qt as u,R as d,Tt as f,Xt as p,Z as m,a as h,d as g,et as _,f as v,ft as y,gt as b,j as x,jt as S,kt as C,lt as w,m as T,ot as E,s as D,t as ee,wt as O,yt as te}from"./vendor-react-oIjZMgNV.js";import{r as k,s as A}from"./firebaseClient-DZobvwSx.js";import{c as j,f as ne,n as M,o as re,r as N,s as P,t as F,x as I}from"./index-B53AvSbH.js";import{o as L,r as ie}from"./githubSyncService-x0Mm_uEl.js";import{t as R}from"./confetti.module-Uxh4CK4s.js";import"./MarkdownRenderer-B_9j9AKs.js";import"./PrincessChamber-CS-4OU0n.js";import{A as z,C as B,I as ae,S as oe,p as se,t as ce,x as le,y as ue}from"./vendor-codemirror-By0wlJeM.js";var V=t(u(),1),H=p();function de(e){if(!e)return{description:``,examples:[],constraints:[]};let t=e.description||``,n=[],r=[];if(Array.isArray(e.examples)&&e.examples.length>0&&(n=e.examples.map(e=>typeof e==`string`?{input:e,output:``}:{input:e?.input||``,output:e?.output||``,explanation:e?.explanation||``})),Array.isArray(e.constraints)&&e.constraints.length>0?r=e.constraints.map(e=>String(e).replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean):typeof e.constraints==`string`&&e.constraints.trim()&&(r=e.constraints.split(`
3
+ `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),n.length===0||r.length===0){let e=t.search(/\bExample\s*\d*:/i),i=t.search(/\bConstraints\s*:/i),a=-1;if(e!==-1&&i!==-1?a=Math.min(e,i):e===-1?i!==-1&&(a=i):a=e,a!==-1){let e=t.substring(0,a).trim(),i=t.substring(a),o=i,s=``,c=i.search(/\bConstraints\s*:/i);if(c!==-1&&(o=i.substring(0,c).trim(),s=i.substring(c).replace(/\bConstraints\s*:/i,``).trim()),n.length===0&&o){let e=/\bExample\s*(\d*)\s*:/gi,t=[],r;for(;(r=e.exec(o))!==null;)t.push({index:r.index,text:r[0]});for(let e=0;e<t.length;e++){let r=t[e].index+t[e].text.length,i=e+1<t.length?t[e+1].index:o.length,a=o.substring(r,i).trim(),s=a.match(/Input:\s*([\s\S]+?)(?=(?:Output:|Explanation:|$))/i),c=a.match(/Output:\s*([\s\S]+?)(?=(?:Explanation:|$))/i),l=a.match(/Explanation:\s*([\s\S]+)/i),u=s?s[1].trim():``,d=c?c[1].trim():``,f=l?l[1].trim():``;u||d?n.push({input:u,output:d,explanation:f}):a&&n.push({input:a,output:``,explanation:``})}}r.length===0&&s&&(r=s.split(`
4
+ `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),(n.length>0||r.length>0)&&(t=e)}}return{description:t,examples:n,constraints:r}}function fe(e,t,n,r){let i=e=>!e||/^Method\s*\d*$/i.test(e.trim())||e.trim().toLowerCase()===`standard`,a=(e||t||`Algorithm Problem`).trim(),o=null;if(t&&a.toLowerCase().startsWith(t.toLowerCase())){let e=a.slice(t.length).trim();if(a=t,e){let t=e.match(/^[-\s]*Method\s*(\d+)\s*\((.+)\)$/i);if(t){let e=parseInt(t[1],10),n=t[2].trim();i(n)?e>1&&(o=`Method ${e}`):o=n}else{let t=e.match(/^[-\s]*Method\s*(\d+)/i);if(t){let e=parseInt(t[1],10);e>1&&(o=`Method ${e}`)}else{let t=e.match(/^[-\s]*\((.+)\)$/);if(t){let e=t[1].trim();i(e)||(o=e)}else{let t=e.match(/^[-\s]+([^-]+)$/);t&&!i(t[1])&&(o=t[1].trim())}}}}}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)\s*\((.+)\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10),n=e[3].trim();i(n)?t>1&&(o=`Method ${t}`):o=n}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}else{let e=a.match(/^(.*?)\s*\(\s*Method\s*(\d+)\s*\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}}}}let s=`General Algorithm`;return i(n)?i(r)?o&&!i(o)&&(s=o):s=r.trim():s=n.trim(),{cleanTitle:a,approachVariant:o,pattern:s}}function pe(e,t,n){if(!e)return[];if(Array.isArray(e.solutions)&&e.solutions.length>0)return e.solutions;let r=[],i=t||e.reference_code||``,a=e.pattern||`General Algorithm`,o=e.optimal_time||`O(N)`,s=e.optimal_space||`O(1)`;return(i||a)&&r.push({id:`sol-1`,name:e.approach_variant||`Optimal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:i,explanation:e.how_to_solve||``,is_optimal:!0}),n&&n.trim()&&n.trim()!==i.trim()&&r.push({id:`sol-2`,name:`Personal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:n,is_optimal:!1}),r}function U(e){if(e&&e!==`sandbox-user-id`)return e;try{let e=k();if(e?.user?.id&&e.user.id!==`sandbox-user-id`)return e.user.id}catch{}return`guest`}function me({overrideProblemId:e,refreshTrigger:t,onClearOverride:n}){let[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!0),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(()=>{try{return k()?.user?.id}catch{return}}),C=(0,V.useRef)(!1),w=(0,V.useRef)(n),T=(0,V.useRef)(!1);(0,V.useEffect)(()=>{w.current=n});let E=(0,V.useCallback)(async(t=!0)=>{t?(o(!0),m(null),c(null),g(``),C.current=!1):m(null);let n=U(x);try{if(typeof navigator<`u`&&!navigator.onLine)throw Error(`Network connection offline.`);let{data:{session:r}}=await A.auth.getSession(),a=r?r.access_token:`sandbox`;r?.user?.id&&(S(r.user.id),n=U(r.user.id));let o={Authorization:`Bearer ${a}`},s=new AbortController,l=setTimeout(()=>s.abort(),4e3),u;try{u=await fetch(`/api/reviews/due`,{headers:o,signal:s.signal})}finally{clearTimeout(l)}if(!u.ok)throw Error(`Failed to load review queue: HTTP ${u.status}`);let d=await u.json();if(Array.isArray(d)||(d=[]),e){let t=String(e).trim().toLowerCase(),n=d.findIndex(e=>{let n=e.problems;return!!(e.problem_id&&String(e.problem_id).trim().toLowerCase()===t||n?.id&&String(n.id).trim().toLowerCase()===t||n?.problem_number!==void 0&&n?.problem_number!==null&&String(n.problem_number)===t||n?.name&&n.name.trim().toLowerCase()===t)});if(n>0){let[e]=d.splice(n,1);d.unshift(e)}else if(n===-1){let t=null,n=await fetch(`/api/reviews/problems/id/${e}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}if(!t){let n=/^\d+$/.test(e),r=N(n?parseInt(e,10):void 0,e);if(r)try{let e=await j(r);if(e?.problem_id){let n=await fetch(`/api/reviews/problems/id/${e.problem_id}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}}}catch(e){console.error(`Failed to auto-activate problem for override review:`,e)}}t&&d.unshift(t)}}i(d),c(null);try{localStorage.setItem(`algospaced_review_queue_${n}`,JSON.stringify(d))}catch{}if(d&&d.length>0){if(t){let e=d[0],t=e.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=N(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(r)}}else try{let e=await fetch(`/api/journey-progress`,{headers:o});if(e.ok){let t=await e.json();v(P(new Set(t))??null)}else v(P(new Set)??null)}catch{v(P(new Set)??null)}}catch(e){console.error(`Error fetching review queue:`,e);let r=e instanceof Error?e.message:`Network error loading review queue.`,a=!1;try{let e=localStorage.getItem(`algospaced_review_queue_${n}`);if(e){let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0&&(i(n),a=!0,c(null),t)){let e=n[0],t=e.problems,r=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=N(r,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)}}}catch(e){console.warn(`Failed to parse cached review items:`,e)}a||c(r)}finally{o(!1)}},[e,x]);(0,V.useEffect)(()=>{if(T.current){T.current=!1;return}let e=!1,t=setTimeout(()=>{e||E(!0)},0);return()=>{e=!0,clearTimeout(t)}},[E,t]),(0,V.useEffect)(()=>{if(!a&&!s&&r.length===0&&!e&&!C.current){C.current=!0;try{R({particleCount:90,spread:70,origin:{y:.6}})}catch{}}},[a,s,r.length,e]);let D=(0,V.useCallback)(async t=>{if(r.length===0||l)return;let n=r[0];if(!n||!n.id)return;u(!0),f(t),m(null);let a=[...r];try{let{data:{session:r}}=await A.auth.getSession(),o=r?r.access_token:`sandbox`,s=await fetch(`/api/reviews/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify({review_id:n.id,fsrs_state:n.fsrs_state??0,fsrs_step:n.fsrs_step??0,fsrs_stability:n.fsrs_stability??0,fsrs_difficulty:n.fsrs_difficulty??0,fsrs_elapsed_days:n.fsrs_elapsed_days??0,fsrs_scheduled_days:n.fsrs_scheduled_days??0,fsrs_reps:n.fsrs_reps??0,fsrs_lapses:n.fsrs_lapses??0,last_reviewed:n.last_reviewed,rating:t})});if(s.ok){let r=t===4?35:t===3?25:t===2?15:5;I.getState().awardGold(r,`Completed review rating ${t}`);let a=n?.problems?.name||``,o=n?.problems?.pattern||``,s=`Correct`;s=t===1?`Incorrect`:t===2?`Mixed`:`Correct`,ne.addReviewEvent(s,a,o).catch(()=>{});let l=ie(),u=h.trim()||n?.problems?.reference_code||``;l.token&&l.repoName&&l.autoCommit&&u&&L({token:l.token,repo:l.repoName,branch:l.branch,problem_number:n?.problems?.problem_number,problem_name:a||`Algorithm Problem`,pattern:o||`Algorithms`,difficulty:n?.problems?.difficulty||`Medium`,optimal_time:n?.problems?.optimal_time||`O(N)`,optimal_space:n?.problems?.optimal_space||`O(1)`,description:n?.problems?.description||``,code:u}).catch(e=>{console.warn(`GitHub background auto-commit failed:`,e)}),e&&w.current&&(T.current=!0,w.current()),i(e=>{let t=e.slice(1);try{let e=U(x);localStorage.setItem(`algospaced_review_queue_${e}`,JSON.stringify(t))}catch{}if(t.length>0){let e=t[0],n=e.problems,r=n?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=N(r,n?.id||e?.problem_id,n?.name)?.starter_code||n?.starter_code||``;g(i)}else g(``);return t}),c(null),E(!1)}else{let e=await s.json().catch(()=>({}));m(e.detail||`Server returned error (${s.status}). Please try again.`),i(a)}}catch(e){console.error(`Error logging review completion:`,e);let t=e instanceof Error?e.message:`Network connection failed while logging review.`;m(t),i(a)}finally{u(!1),f(null)}},[r,l,e,E,h,x]),ee=(0,V.useCallback)(async()=>{if(_&&!y){b(!0);try{await j(_),await E()}catch(e){console.error(`Failed to activate next milestone:`,e)}finally{b(!1)}}},[_,y,E]),O=(0,V.useCallback)(()=>{let e=r[0],t=e?.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=N(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)},[r]);return{reviews:r,setReviews:i,loading:a,queueError:s,submitting:l,submittingRating:d,gradeError:p,setGradeError:m,code:h,setCode:g,nextMilestone:_,activatingMilestone:y,currentUserId:x,fetchQueue:E,handleGrade:D,handleSelectCard:(0,V.useCallback)(t=>{if(t<=0||t>=r.length||l)return;e&&w.current&&(T.current=!0,w.current());let n=r[t];if(!n)return;let a=n.problems,o=a?.problem_number??(/^\d+$/.test(n?.problem_id||``)?parseInt(n.problem_id,10):void 0),s=N(o,a?.id||n?.problem_id,a?.name)?.starter_code||a?.starter_code||``;g(s),i(e=>{let t=e.findIndex(e=>e.id&&e.id===n.id||e===n);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]})},[r,l,e]),handleActivateNextMilestone:ee,handleResetStarterCode:O}}function he(){return{sandboxRunning:M(e=>e.sandboxRunning),sandboxResults:M(e=>e.sandboxResults),sandboxError:M(e=>e.sandboxError),savingReference:M(e=>e.savingReference),savedRefSuccess:M(e=>e.savedRefSuccess),saveRefError:M(e=>e.saveRefError),handleRunSandbox:M(e=>e.handleRunSandbox),handleSaveReference:M(e=>e.handleSaveReference),resetSandbox:M(e=>e.resetSandbox)}}function ge(){return{aiLoading:M(e=>e.aiLoading),aiResult:M(e=>e.aiResult),aiError:M(e=>e.aiError),explainLoading:M(e=>e.explainLoading),explanationText:M(e=>e.explanationText),explainError:M(e=>e.explainError),aiSolutionLoading:M(e=>e.aiSolutionLoading),aiSolutionError:M(e=>e.aiSolutionError),handleAiEvaluation:M(e=>e.handleAiEvaluation),handleExplainCode:M(e=>e.handleExplainCode),handleFetchAiSolution:M(e=>e.handleFetchAiSolution),resetAiState:M(e=>e.resetAiState)}}var _e=({problem:e,totalInQueue:t,reviews:n=[],onSelectCard:r,onOpenCreateProblem:i,onOpenEditProblem:a})=>{let[o,c]=(0,V.useState)(!1),l=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return o&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]);let u=e.problem_number?`https://leetcode.com/problemset/all/?search=${e.problem_number}`:`https://leetcode.com/problemset/all/?search=${encodeURIComponent(e.name||``)}`;return(0,H.jsxs)(`div`,{className:`shrink-0 bg-paper-white border-b-[3px] border-ink-black px-2.5 sm:px-4 py-2 flex flex-wrap items-center justify-between gap-2 shadow-[0_2px_0_0_rgba(30,41,59,0.05)] relative z-40`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap min-w-0`,children:[(0,H.jsxs)(`div`,{className:`relative shrink-0`,ref:l,children:[(0,H.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`h-7 inline-flex items-center gap-1.5 px-2 sm:px-2.5 bg-amber-300 hover:bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Click to view all cards due in today's queue`,children:[(0,H.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-ping shrink-0`}),(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] font-bold text-ink-black tracking-wide whitespace-nowrap`,children:`CARD 1 OF ${t}`}),t>1&&(0,H.jsx)(S,{className:`w-3 h-3 text-ink-black transition-transform shrink-0 ${o?`rotate-180`:``}`})]}),o&&n.length>0&&(0,H.jsxs)(`div`,{className:`absolute top-9 left-0 z-50 w-64 min-[400px]:w-72 sm:w-80 bg-paper-white border-[3px] border-ink-black gadget-shadow p-3 space-y-2 max-w-[calc(100vw-32px)]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b-2 border-ink-black pb-1.5 font-arcade text-[9px] font-bold text-ink-black`,children:[(0,H.jsx)(`span`,{children:`DAILY QUEUE (${n.length} CARDS)`}),(0,H.jsx)(`button`,{onClick:()=>c(!1),className:`px-1 hover:text-rose-600 font-bold cursor-pointer`,title:`Close`,children:`✕`})]}),(0,H.jsx)(`div`,{className:`text-[7.5px] font-arcade text-trash-gray uppercase -mt-0.5`,children:`Click any card to solve it now:`}),(0,H.jsx)(`div`,{className:`max-h-60 overflow-y-auto no-scrollbar space-y-1.5 pr-1`,children:n.map((e,t)=>{let n=e.problems,i=n?.problem_number,a=i==null?void 0:re(i),{cleanTitle:o,approachVariant:l}=fe(n?.name||``,a?.name),u=l?`${o} (${l})`:o,d=t===0,f=n?.difficulty,p=f?f.toUpperCase():`EASY`,m=f===`Easy`?`bg-emerald-600 text-white`:f===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{d||r?.(t),c(!1)},className:`group w-full text-left p-2 border-2 border-ink-black text-xs flex items-center justify-between gap-2 cursor-pointer transition-all duration-150 select-none ${d?`bg-amber-100 font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-white hover:bg-amber-50 hover:translate-x-0.5 active:translate-y-0.5 active:shadow-none shadow-[2px_2px_0px_0px_rgba(30,41,59,0.25)]`}`,title:d?`Currently active card`:`Jump to #${t+1}: ${u}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate min-w-0`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] text-trash-gray shrink-0`,children:[`#`,t+1]}),i!=null&&(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] font-bold px-1 py-0.2 bg-amber-300 border border-ink-black shrink-0`,children:[`LC #`,i]}),(0,H.jsx)(`span`,{className:`truncate`,children:u})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[d?(0,H.jsx)(`span`,{className:`text-[7.5px] font-arcade font-extrabold px-1 py-0.5 bg-amber-300 text-ink-black border border-ink-black shrink-0`,children:`NOW`}):(0,H.jsx)(s,{className:`w-2.5 h-2.5 fill-ink-black text-ink-black opacity-0 group-hover:opacity-100 transition-opacity shrink-0`}),(0,H.jsx)(`span`,{className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black shrink-0 ${m}`,children:p})]})]},e.id||t)})})]})]}),e.problem_number!==void 0&&e.problem_number!==null&&(0,H.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-ink-black shrink-0 select-none whitespace-nowrap`,children:e.problem_number>0?`LC #${e.problem_number}`:`CUSTOM`}),(0,H.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] shrink-0 select-none whitespace-nowrap ${e.difficulty===`Easy`?`bg-emerald-600 text-white`:e.difficulty===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`}`,children:e.difficulty?e.difficulty.toUpperCase():`EASY`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 flex-wrap justify-end`,children:[(0,H.jsxs)(`button`,{onClick:i,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-purple-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Create or Import Problem`,children:[(0,H.jsx)(O,{className:`w-3 h-3 text-purple-600 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`ADD`})]}),a&&(0,H.jsxs)(`button`,{onClick:a,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-emerald-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Edit Problem Specification`,children:[(0,H.jsx)(d,{className:`w-3 h-3 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`EDIT`})]}),e.google_doc_url&&(0,H.jsxs)(`a`,{href:e.google_doc_url,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Open Google Doc Notes`,children:[(0,H.jsx)(`span`,{children:`DOC`}),(0,H.jsx)(y,{className:`w-2.5 h-2.5 text-primary shrink-0`})]}),(0,H.jsxs)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Search LeetCode`,children:[(0,H.jsx)(`span`,{children:`LC`}),(0,H.jsx)(y,{className:`w-2.5 h-2.5 text-amber-600 shrink-0`})]})]})]})},ve=le.mark({class:`cm-indent-dot cm-indent-dot-primary`}),W=le.mark({class:`cm-indent-dot cm-indent-dot-secondary`});function ye(e){let t=new ae;for(let{from:n,to:r}of e.visibleRanges){let i=n;for(;i<r;){let n=e.state.doc.lineAt(i),r=n.text,a=0;for(;a<r.length&&(r[a]===` `||r[a]===` `);){let e=n.from+a,i=e+1,o=a%4==0||r[a]===` `;t.add(e,i,o?ve:W),a++}i=n.to+1}}return t.finish()}var be=B.fromClass(class{decorations;constructor(e){this.decorations=ye(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=ye(e.view))}},{decorations:e=>e.decorations}),xe=oe.theme({"&":{backgroundColor:`#0c111d`,color:`#f1f5f9`,height:`100%`,fontSize:`13px`,fontFamily:`var(--font-code, "JetBrains Mono", "Fira Code", monospace)`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`,lineHeight:`1.65`},".cm-content":{caretColor:`#4ade80`,padding:`12px 0`},"&.cm-focused .cm-cursor":{borderLeftColor:`#4ade80`,borderLeftWidth:`2px`,filter:`drop-shadow(0 0 5px rgba(74, 222, 128, 0.8))`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`rgba(56, 189, 248, 0.25) !important`},".cm-gutters":{backgroundColor:`#070a12`,color:`#475569`,borderRight:`2px solid #1e293b`,paddingRight:`6px`,userSelect:`none`},".cm-activeLineGutter":{backgroundColor:`#131b2e`,color:`#38bdf8`,fontWeight:`700`},".cm-activeLine, &.cm-focused .cm-activeLine":{backgroundColor:`#0f172a !important`},".cm-line":{padding:`0 10px`},".cm-indent-dot":{position:`relative`,display:`inline-block`},".cm-indent-dot::before":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,userSelect:`none`,lineHeight:`0`,fontFamily:`monospace`},".cm-indent-dot-primary::before":{content:`"•"`,color:`#38bdf8`,fontSize:`9px`,opacity:`0.85`},".cm-indent-dot-secondary::before":{content:`"·"`,color:`#64748b`,fontSize:`11px`,opacity:`0.5`},"&.cm-focused .cm-matchingBracket, .cm-matchingBracket":{backgroundColor:`rgba(74, 222, 128, 0.2)`,outline:`1px solid #4ade80`,borderRadius:`2px`,color:`#86efac !important`},".cm-placeholder":{color:`#64748b`,fontStyle:`italic`},".cm-scroller::-webkit-scrollbar":{width:`6px`,height:`6px`},".cm-scroller::-webkit-scrollbar-track":{backgroundColor:`#070a12`},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:`#1e293b`,borderRadius:`3px`,border:`1px solid #334155`},".cm-scroller::-webkit-scrollbar-thumb:hover":{backgroundColor:`#38bdf8`}}),Se=[ce(),ue.of(` `),z.of([se]),be,xe,oe.contentAttributes.of({"aria-label":`Python Code Editor`})],G=[{id:`python`,name:`Python`,version:`3.14`}],Ce=({className:e=`w-3.5 h-3.5`})=>(0,H.jsxs)(`svg`,{viewBox:`0 0 128 128`,className:e,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M63.454 4.018c-14.775 0-23.774 6.425-23.774 18.775v13.626h24.168v3.424H30.082C17.518 39.843 8 47.962 8 63.673c0 15.65 8.358 23.486 21.056 23.486h11.905v-16.89c0-13.064 11.233-24.113 24.331-24.113h23.773V32.793c0-11.83-9.988-19.775-23.773-19.775H63.454v-9zm-9.845 7.426a3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841 3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841z`,fill:`#387eb8`}),(0,H.jsx)(`path`,{d:`M64.546 123.982c14.775 0 23.774-6.425 23.774-18.775V91.581H64.152v-3.424h33.766c12.564 0 22.082-8.119 22.082-23.83 0-15.65-8.358-23.486-21.056-23.486H87.04v16.89c0 13.064-11.234 24.113-24.332 24.113H38.934v13.363c0 11.83 9.989 19.775 23.774 19.775h1.838v9zm9.845-7.426a3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841 3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841z`,fill:`#ffe052`})]}),we=({mobileView:e,isNarrow:t=!1,isAutocompleteEnabled:a,onToggleAutocomplete:u,onResetStarterCode:d,code:p,onChangeCode:m,sandboxRunning:h,sandboxError:g,sandboxResults:b,onRunSandbox:C,savingReference:w,savedRefSuccess:D,saveRefError:O,onSaveReference:te,aiLoading:k,aiError:A,aiResult:j,onAiEvaluation:ne,optimalTime:M,optimalSpace:re,onPushToGitHub:N,pushingToGitHub:P,githubPushedUrl:F,githubPushError:I})=>{let[L,ie]=(0,V.useState)(`python`),[R,z]=(0,V.useState)(!1),B=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=e=>{B.current&&!B.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let ae=G.find(e=>e.id===L)??G[0];return(0,H.jsxs)(`div`,{className:`w-full ${t?`flex flex-1`:`lg:w-[51%] flex`} flex-col bg-[#fffdfa] overflow-y-auto no-scrollbar ${t&&e!==`code`?`hidden`:`flex`}`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 bg-[#f7f5ed] border-b-2 border-ink-black p-2 sm:px-3 flex flex-wrap items-center justify-between gap-1.5 sm:gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap`,children:[(0,H.jsxs)(`div`,{className:`relative`,ref:B,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>z(e=>!e),className:`h-7 px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 font-arcade text-[9px] font-bold text-ink-black cursor-pointer transition-all select-none`,title:`Select programming language`,"aria-expanded":R,"aria-haspopup":`listbox`,children:[(0,H.jsx)(Ce,{className:`w-3.5 h-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:ae.name}),(0,H.jsx)(S,{className:`w-3 h-3 text-ink-black transition-transform duration-150 ${R?`rotate-180`:``}`})]}),R&&(0,H.jsxs)(`div`,{className:`absolute top-full mt-1.5 left-0 z-50 w-52 bg-paper-white border-[3px] border-ink-black gadget-shadow p-1.5 space-y-1`,role:`listbox`,children:[(0,H.jsx)(`div`,{className:`px-2 py-1 text-[8px] font-arcade font-bold text-trash-gray uppercase border-b border-slate-200`,children:`SELECT LANGUAGE`}),G.map(e=>{let t=L===e.id;return(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{ie(e.id),z(!1)},className:`w-full flex items-center justify-between px-2.5 py-1.5 border-2 border-ink-black text-left transition-all cursor-pointer ${t?`bg-amber-200 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] font-bold text-ink-black`:`bg-white hover:bg-slate-100 text-slate-800`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[9px]`,children:[(0,H.jsx)(Ce,{className:`w-3.5 h-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:e.name})]}),(0,H.jsxs)(`span`,{className:`font-mono text-[8px] font-bold px-1.5 py-0.5 bg-white border border-ink-black text-slate-700 shadow-[1px_1px_0px_0px_rgba(30,41,59,0.3)]`,children:[`v`,e.version]})]},e.id)})]})]}),(0,H.jsx)(`div`,{className:`h-4 w-[2px] bg-slate-300 mx-0.5 hidden sm:block`}),(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>u(e.target.checked),className:`sr-only peer`,"aria-label":`Toggle code editor autocompletion`}),(0,H.jsx)(`div`,{className:`relative w-7 h-3.5 bg-slate-300 border border-ink-black rounded-full peer peer-checked:bg-grass-green transition-all after:content-[''] after:absolute after:top-[1px] after:left-[2px] after:bg-white after:border after:border-ink-black after:rounded-full after:h-2 after:w-2 after:transition-all peer-checked:after:translate-x-3`}),(0,H.jsx)(`span`,{className:`text-[7.5px] min-[400px]:text-[8px] font-arcade font-bold text-trash-gray peer-checked:text-ink-black whitespace-nowrap`,children:`AUTOCOMPLETE`})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,H.jsx)(`button`,{onClick:d,className:`w-7 h-7 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-ink-black flex items-center justify-center cursor-pointer transition-all`,title:`Reset to starter code`,"aria-label":`Reset to starter code`,children:(0,H.jsx)(l,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(`button`,{onClick:()=>m(``),className:`w-7 h-7 bg-white hover:bg-rose-50 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-rose-700 flex items-center justify-center cursor-pointer transition-all`,title:`Clear editor`,"aria-label":`Clear editor`,children:(0,H.jsx)(T,{className:`w-3.5 h-3.5 text-rose-600`})}),te&&(0,H.jsx)(`button`,{onClick:te,disabled:w||!p.trim(),className:`w-7 h-7 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all ${D?`bg-emerald-600 hover:bg-emerald-500 text-white`:`bg-amber-400 hover:bg-amber-300 text-ink-black`}`,title:w?`Saving solution to personal database...`:D?`Saved to personal database!`:`Overwrite saved solution with studio code`,"aria-label":`Overwrite saved solution with studio code`,children:w?(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):D?(0,H.jsx)(f,{className:`w-3.5 h-3.5 text-white`}):(0,H.jsx)(x,{className:`w-3.5 h-3.5 text-ink-black`})}),N&&(0,H.jsx)(`button`,{onClick:N,disabled:P||!p.trim(),className:`w-7 h-7 bg-[#24292e] hover:bg-black border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:P?`Pushing to GitHub...`:`Push solution to GitHub repository`,"aria-label":`Push to GitHub`,children:P?(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-yellow-300`}):(0,H.jsx)(E,{className:`w-3.5 h-3.5 text-yellow-300`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,H.jsx)(`button`,{onClick:C,disabled:h||!p.trim(),className:`w-7 h-7 bg-emerald-600 hover:bg-emerald-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:h?`Running sandbox tests...`:`Run tests in local sandbox`,"aria-label":`Run tests`,children:h?(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`}):(0,H.jsx)(s,{className:`w-3.5 h-3.5 fill-white text-white ml-0.5`})}),(0,H.jsx)(`button`,{onClick:ne,disabled:k||!p.trim(),className:`w-7 h-7 bg-purple-600 hover:bg-purple-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:k?`Evaluating code with Gemini...`:`Gemini Eval (AI code review & complexity)`,"aria-label":`Gemini Eval`,children:k?(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`}):(0,H.jsx)(n,{className:`w-3.5 h-3.5 text-amber-300`})})]})]}),(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 flex-1 flex flex-col space-y-4`,children:[(0,H.jsx)(`div`,{className:`flex-1 flex flex-col min-h-[300px] sm:min-h-[360px] border-[3px] border-ink-black shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] bg-[#0c111d] overflow-hidden`,children:(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,H.jsx)(ee,{value:p,onChange:m,placeholder:`def solve(nums):
5
+ # Write your solution from memory here...`,height:`100%`,theme:`dark`,extensions:Se,basicSetup:{autocompletion:a,lineNumbers:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0},className:`w-full h-full text-xs font-code-mono`})})}),D&&(0,H.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(f,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{children:`Successfully saved studio code as your personal reference solution!`})]}),O&&(0,H.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(v,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:O})]}),F&&(0,H.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{children:`Successfully pushed solution to your GitHub repository!`})]}),(0,H.jsxs)(`a`,{href:F,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-bold text-blue-700 hover:text-blue-900 underline flex items-center gap-1`,children:[(0,H.jsx)(`span`,{children:`View on GitHub`}),(0,H.jsx)(y,{className:`w-3 h-3`})]})]}),I&&(0,H.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(v,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:I})]}),h&&(0,H.jsxs)(`div`,{className:`p-3 border-2 border-ink-black bg-emerald-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,H.jsx)(i,{className:`w-5 h-5 text-emerald-600 animate-spin shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`Running...`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Executing against test cases...`})]})]}),g&&(0,H.jsxs)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center gap-2`,children:[(0,H.jsx)(v,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:g})]}),b&&(0,H.jsxs)(`div`,{className:`border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3.5 ${b.status===`passed`?`bg-[#f0fdf4]`:`bg-[#fff1f2]`}`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2.5 border-b-2 border-dashed border-ink-black`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,H.jsx)(`div`,{className:`w-8 h-8 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${b.status===`passed`?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:b.status===`passed`?(0,H.jsx)(c,{className:`w-5 h-5 stroke-[3]`}):(0,H.jsx)(v,{className:`w-4 h-4`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5 uppercase`,children:b.status===`passed`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`ALL TESTS PASSED`}),(0,H.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:b.status===`error`?`EXECUTION ERROR`:`TESTS FAILED`}),(0,H.jsx)(r,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,H.jsxs)(`div`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:[b.passed_count??0,` of `,b.total_tests??0,` test cases passed (`,(b.duration_ms??0).toFixed(1),`ms)`]})]})]}),b.status===`passed`&&(0,H.jsxs)(`button`,{onClick:te,disabled:w,className:`px-3 py-1.5 bg-white hover:bg-emerald-100 border-2 border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 disabled:opacity-50`,children:[w?(0,H.jsx)(i,{className:`w-3 h-3 animate-spin`}):D?(0,H.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,H.jsx)(x,{className:`w-3.5 h-3.5 text-blue-600`}),(0,H.jsx)(`span`,{children:D?`SAVED TO DB!`:`SAVE AS OFFICIAL SOLUTION`})]})]}),O&&(0,H.jsx)(`div`,{className:`p-2 border border-rose-500 bg-rose-100 text-rose-800 text-[11px] font-semibold`,children:O}),b.results&&b.results.length>0&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase font-bold block`,children:`TEST CASE BREAKDOWN:`}),(0,H.jsx)(`div`,{className:`space-y-1.5 max-h-56 overflow-y-auto custom-scrollbar`,children:b.results.map((e,t)=>(0,H.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-mono shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] ${e.passed?`bg-white`:`bg-rose-50`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between font-arcade text-[8px] mb-1`,children:[(0,H.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`CASE #`,t+1]}),(0,H.jsx)(`span`,{className:e.passed?`text-emerald-700 font-bold`:`text-rose-700 font-bold`,children:e.passed?`✓ PASSED`:`✗ FAILED`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-[10px]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Input:`}),(0,H.jsx)(`span`,{className:`font-code-mono text-ink-black font-semibold break-all`,children:JSON.stringify(e.input)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Expected:`}),(0,H.jsx)(`span`,{className:`font-code-mono text-emerald-700 font-semibold break-all`,children:JSON.stringify(e.expected)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Output:`}),(0,H.jsx)(`span`,{className:`font-code-mono font-semibold break-all ${e.passed?`text-emerald-700`:`text-rose-700`}`,children:e.output===void 0?`None`:JSON.stringify(e.output)})]})]}),e.error&&(0,H.jsx)(`div`,{className:`mt-1.5 p-1.5 bg-rose-100 text-rose-900 text-[10px] font-mono border border-rose-300 break-all`,children:e.error})]},t))})]}),b.error&&(0,H.jsx)(`div`,{className:`p-3 bg-[#1E293B] text-rose-400 font-code-mono text-[11px] border-2 border-ink-black overflow-x-auto whitespace-pre-wrap select-text`,children:b.error}),b.status===`passed`&&(0,H.jsx)(`div`,{className:`p-2 bg-emerald-100/70 border border-emerald-300 text-emerald-900 text-xs flex items-center justify-between`,children:(0,H.jsx)(`span`,{className:`font-sans font-medium`,children:`✨ All unit tests passed. Rate your recall below.`})})]}),k&&(0,H.jsxs)(`div`,{className:`p-4 border-2 border-ink-black bg-amber-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,H.jsx)(i,{className:`w-6 h-6 text-purple-600 animate-spin shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`ANALYZING...`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Checking edge cases, bounds, and Big-O efficiency against optimal constraints...`})]})]}),A&&(0,H.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:A}),j&&(0,H.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-[#fefce8] p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b-2 border-dashed border-ink-black`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`w-9 h-9 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${j.is_correct?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:j.is_correct?(0,H.jsx)(c,{className:`w-5 h-5 stroke-[3]`}):(0,H.jsx)(o,{className:`w-5 h-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5`,children:j.is_correct?(0,H.jsxs)(H.Fragment,{children:[`STATUS: PASSED`,(0,H.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,H.jsxs)(H.Fragment,{children:[`STATUS: FAILED`,(0,H.jsx)(r,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,H.jsx)(`span`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:j.is_correct?`Algorithm matches expected logic and patterns.`:`Bugs or edge-case failures detected.`})]})]}),(0,H.jsx)(`span`,{className:`font-arcade text-[9px] px-2 py-1 border-2 border-ink-black uppercase font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${j.is_correct?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:j.is_correct?`CORRECT`:`INCORRECT`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Time Complexity`}),(0,H.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,H.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:j.detected_complexity?.time||`N/A`}),(0,H.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,M||`O(N)`,`)`]})]})]}),(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Space Complexity`}),(0,H.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,H.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:j.detected_complexity?.space||`N/A`}),(0,H.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,re||`O(1)`,`)`]})]})]})]}),j.bugs&&j.bugs.length>0&&(0,H.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black space-y-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] text-rose-600 uppercase font-bold block flex items-center gap-1`,children:[(0,H.jsx)(v,{className:`w-3 h-3 text-rose-500`}),`TRACES & EDGE CASE ISSUES:`]}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-xs text-slate-800 space-y-1 font-semibold pl-1`,children:j.bugs.map((e,t)=>(0,H.jsx)(`li`,{className:`leading-relaxed select-text`,children:e},t))})]}),j.key_suggestion&&(0,H.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black space-y-1 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-700 uppercase font-bold block flex items-center gap-1`,children:[(0,H.jsx)(n,{className:`w-3 h-3 text-amber-500`}),`TIP:`]}),(0,H.jsx)(`p`,{className:`text-xs text-slate-800 font-medium leading-relaxed m-0 select-text`,children:j.key_suggestion})]}),(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-dashed border-ink-black flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-bold text-ink-black flex items-center gap-1.5`,children:[(0,H.jsx)(_,{className:`w-4 h-4 text-primary`}),`Recommendation:`]}),(0,H.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-purple-700`,children:j.is_correct?`Rate your recall below.`:`Review issues and rate recall below.`})]})]})]})]})},Te=({gradeError:e,onDismissGradeError:t,submitting:n,submittingRating:r,onGrade:a})=>(0,H.jsx)(`div`,{className:`shrink-0 bg-[#f8f5eb] border-t-[3px] border-ink-black p-2 sm:p-3 flex flex-col items-stretch gap-1.5 sm:gap-2 shadow-[0_-3px_0_0_rgba(30,41,59,0.08)]`,children:(0,H.jsxs)(`div`,{className:`w-full flex flex-col`,children:[e&&(0,H.jsxs)(`div`,{className:`p-2.5 mb-2 bg-red-100 border-2 border-red-500 text-red-800 text-xs font-semibold shadow-[2px_2px_0px_0px_#1E293B] flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(v,{className:`w-4 h-4 text-red-600 shrink-0`}),e]}),(0,H.jsx)(`button`,{onClick:t,className:`text-red-900 font-bold hover:underline cursor-pointer ml-2 text-xs`,children:`Dismiss`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 sm:gap-2.5 w-full`,children:[(0,H.jsx)(`button`,{onClick:()=>a(1),disabled:n,className:`flex-1 min-w-0 bg-[#dc2626] hover:bg-[#b91c1c] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-white flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 1 on keyboard`,children:r===1?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/20 rounded shrink-0`,children:`1`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Again`})]})}),(0,H.jsx)(`button`,{onClick:()=>a(2),disabled:n,className:`flex-1 min-w-0 bg-[#ff9933] hover:bg-[#ff8000] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 2 on keyboard`,children:r===2?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`2`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Hard`})]})}),(0,H.jsx)(`button`,{onClick:()=>a(3),disabled:n,className:`flex-1 min-w-0 bg-[#4ade80] hover:bg-[#22c55e] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 3 on keyboard`,children:r===3?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`3`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Good`})]})}),(0,H.jsx)(`button`,{onClick:()=>a(4),disabled:n,className:`flex-1 min-w-0 bg-[#60a5fa] hover:bg-[#3b82f6] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 4 on keyboard`,children:r===4?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`4`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Easy`})]})})]})]})}),Ee=({nextMilestone:e,activatingMilestone:t,onActivateNextMilestone:r,onOpenCardManager:a,onOpenJourney:o,onOpenCreateProblem:s,onOpenWindow:u,overrideProblemId:d,onClearOverride:f})=>(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-lg bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,H.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-grass-green via-amber-300 to-highlight-pink`}),(0,H.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,H.jsx)(`div`,{className:`w-20 h-20 bg-amber-300 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-3deg] hover:rotate-0 transition-transform`,children:(0,H.jsx)(g,{className:`w-10 h-10 text-ink-black stroke-[2.5]`})}),(0,H.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-grass-green border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] text-ink-black font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`100% DONE`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-1 bg-emerald-100 border-2 border-ink-black text-emerald-800 font-arcade text-[9px] font-bold`,children:[(0,H.jsx)(c,{className:`w-3 h-3 stroke-[3]`}),` ALL CARDS COMPLETED FOR TODAY`]}),(0,H.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`You're all caught up for today. Keep it up.`}),(0,H.jsx)(`p`,{className:`text-xs sm:text-sm font-sans text-trash-gray max-w-md mx-auto leading-relaxed font-semibold`,children:`All reviews for today are finished. Next reviews are scheduled for tomorrow.`})]}),e&&(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-br from-amber-50 to-orange-50 border-[3px] border-ink-black gadget-shadow text-left space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-800 uppercase tracking-wider flex items-center gap-1.5`,children:[(0,H.jsx)(b,{className:`w-3.5 h-3.5 text-amber-600`}),`NEXT UNEXPLORED MILESTONE`]}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] font-bold px-2 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20`,children:[`LC #`,e.problem_number]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black truncate`,children:e.name}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,H.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty}),(0,H.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] bg-purple-100 text-purple-800 border border-purple-300 font-bold`,children:e.pattern}),(0,H.jsxs)(`span`,{className:`text-[11px] font-code-mono text-slate-600`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]}),(0,H.jsx)(`button`,{onClick:r,disabled:t,className:`px-4 py-2.5 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center justify-center gap-1.5 disabled:opacity-50`,children:t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`}),(0,H.jsx)(`span`,{children:`ACTIVATING...`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(n,{className:`w-3.5 h-3.5 text-amber-700`}),(0,H.jsx)(`span`,{children:`ACTIVATE & REVIEW NOW`})]})})]})]}),(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-r from-sky-100 via-sky-200 to-indigo-100 border-[3px] border-ink-black gadget-shadow text-left flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-sky-900 uppercase flex items-center gap-1.5`,children:[(0,H.jsx)(h,{className:`w-3.5 h-3.5 text-sky-700`}),`DECK BROWSER & CARD MANAGER`]}),(0,H.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Want to Manage or Reschedule Cards?`}),(0,H.jsx)(`p`,{className:`font-sans text-xs text-trash-gray font-semibold max-w-md`,children:`Browse your full 150-card curriculum, reschedule intervals, or enroll new topics in the Anki-style Card Manager.`})]}),(0,H.jsxs)(`button`,{onClick:()=>{a?a():u?.(`cardManager`)},className:`px-4 py-2.5 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center gap-1.5`,children:[(0,H.jsx)(h,{className:`w-3.5 h-3.5 text-sky-950`}),(0,H.jsx)(`span`,{children:`OPEN CARD MANAGER`})]})]}),(0,H.jsxs)(`div`,{className:`border-t-[3px] border-dashed border-ink-black pt-5 space-y-3`,children:[(0,H.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold text-left`,children:`CONTINUE PRACTICING:`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2.5`,children:[(0,H.jsxs)(`button`,{onClick:o,className:`p-3 bg-amber-100 hover:bg-amber-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(b,{className:`w-4 h-4 text-amber-600`}),(0,H.jsx)(C,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Journey Trail`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`150 Curated nodes`})]})]}),(0,H.jsxs)(`button`,{onClick:s,className:`p-3 bg-purple-100 hover:bg-purple-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(O,{className:`w-4 h-4 text-purple-700`}),(0,H.jsx)(C,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Add Problem`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`New LeetCode entry`})]})]}),(0,H.jsxs)(`button`,{onClick:()=>u?.(`companion`),className:`p-3 bg-yellow-100 hover:bg-yellow-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`material-symbols-outlined text-amber-600 text-lg`,children:`fireplace`}),(0,H.jsx)(C,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Princess Camp`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Rest with Aurelia`})]})]}),(0,H.jsxs)(`button`,{onClick:()=>{a?a():u?.(`cardManager`)},className:`p-3 bg-cyan-100 hover:bg-cyan-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(m,{className:`w-4 h-4 text-cyan-700`}),(0,H.jsx)(C,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Card Manager`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Anki Deck Browser`})]})]})]})]}),d&&f&&(0,H.jsxs)(`button`,{onClick:f,className:`mt-3 bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold px-4 py-2 text-xs uppercase tracking-wide shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2`,children:[(0,H.jsx)(l,{className:`w-3.5 h-3.5`}),` Return to Scheduled Queue`]})]})}),De=e({default:()=>ke}),Oe=(0,V.lazy)(()=>F(()=>import(`./ProblemSpecPanel-0WaGunPO.js`).then(e=>({default:e.ProblemSpecPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function ke({overrideProblemId:e,onClearOverride:t,onOpenWindow:n,onOpenJourney:r,onOpenCreateProblem:o,onOpenEditProblem:s,onOpenCardManager:c,refreshTrigger:u}){let[d,f]=(0,V.useState)(null),p=d!==null&&d<780,[m,h]=(0,V.useState)(`spec`),[g,_]=(0,V.useState)(`spec`),[y,b]=(0,V.useState)(null),x=(0,V.useCallback)(e=>{e&&(f(e.clientWidth),new ResizeObserver(e=>{for(let t of e)f(t.contentRect.width)}).observe(e))},[]),[S,C]=(0,V.useState)(()=>localStorage.getItem(`isAutocompleteEnabled`)!==`false`),{reviews:T,setReviews:E,loading:ee,queueError:O,submitting:k,submittingRating:A,gradeError:j,setGradeError:ne,code:M,setCode:re,nextMilestone:P,activatingMilestone:F,fetchQueue:I,handleGrade:R,handleSelectCard:z,handleActivateNextMilestone:B,handleResetStarterCode:ae}=me({overrideProblemId:e,refreshTrigger:u,onClearOverride:t}),{sandboxRunning:oe,sandboxResults:se,sandboxError:ce,savingReference:le,savedRefSuccess:ue,saveRefError:pe,handleRunSandbox:U,handleSaveReference:ve,resetSandbox:W}=he(),{aiLoading:ye,aiResult:be,aiError:xe,explainLoading:Se,explanationText:G,explainError:Ce,aiSolutionLoading:De,aiSolutionError:ke,handleAiEvaluation:Ae,handleExplainCode:je,handleFetchAiSolution:Me,resetAiState:K}=ge(),[Ne,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)(null),[Le,q]=(0,V.useState)(null),Re=(0,V.useCallback)(async()=>{if(T.length===0)return;let e=T[0]?.problems||{},t=M.trim()||e.reference_code||``;if(!t){q(`Please write or save code before pushing to GitHub.`),setTimeout(()=>q(null),4e3);return}let r=ie();if(!r.token){n&&n(`github`);return}Pe(!0),q(null),Ie(null);try{let n=await L({token:r.token,repo:r.repoName,branch:r.branch,problem_number:e.problem_number,problem_name:e.name||`Algorithm Problem`,pattern:e.pattern||`Algorithms`,difficulty:e.difficulty||`Medium`,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,description:e.description||``,code:t});Ie(n.html_url),setTimeout(()=>Ie(null),8e3)}catch(e){q(e.message||`Failed to push solution to GitHub.`),setTimeout(()=>q(null),5e3)}finally{Pe(!1)}},[T,M,n]),J=T[0]?.id||T[0]?.problem_id,ze=(0,V.useRef)(void 0);(0,V.useEffect)(()=>{J&&ze.current!==J&&(ze.current=J,K(),W())},[J,K,W]);let Y=(0,V.useCallback)(e=>{K(),W(),R(e)},[R,K,W]),Be=(0,V.useCallback)(e=>{K(),W(),z(e)},[z,K,W]);(0,V.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.cm-editor`)||t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable||T.length===0||k||(e.key===`1`?(e.preventDefault(),Y(1)):e.key===`2`?(e.preventDefault(),Y(2)):e.key===`3`?(e.preventDefault(),Y(3)):e.key===`4`&&(e.preventDefault(),Y(4)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Y,T.length,k]);let Ve=(e,t)=>{navigator.clipboard.writeText(e),b(t),setTimeout(()=>b(null),1800)},He=(0,V.useCallback)(()=>{r?r():n?.(`journey`)},[r,n]),Ue=(0,V.useCallback)(()=>{o?o():n?.(`createProblem`)},[o,n]),We=(0,V.useCallback)(e=>{E(t=>{if(t.length===0)return t;let n=[...t],r=n[0];return r&&r.problems&&(r.problems={...r.problems,solutions:e}),n})},[E]);if(ee)return(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] text-ink-black`,children:(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-8 bg-paper-white border-[3px] border-ink-black gadget-shadow text-center max-w-xs`,children:[(0,H.jsx)(`div`,{className:`w-12 h-12 bg-amber-200 border-2 border-ink-black flex items-center justify-center animate-spin`,children:(0,H.jsx)(i,{className:`w-6 h-6 text-ink-black`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-arcade text-xs text-ink-black uppercase tracking-wider font-bold`,children:`LOADING QUEUE`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray mt-1 font-semibold`,children:`Fetching scheduled FSRS review cards...`})]})]})});if(O&&T.length===0)return(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,H.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-red-500 via-amber-400 to-red-500`}),(0,H.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,H.jsx)(`div`,{className:`w-20 h-20 bg-rose-200 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-2deg]`,children:(0,H.jsx)(D,{className:`w-10 h-10 text-rose-700 stroke-[2.5]`})}),(0,H.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-rose-500 text-white border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`OFFLINE`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 bg-rose-100 border-2 border-ink-black text-rose-800 font-arcade text-[9px] font-bold`,children:[(0,H.jsx)(v,{className:`w-3.5 h-3.5 stroke-[2.5] text-rose-600`}),` CONNECTION ERROR`]}),(0,H.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`Queue Unavailable`}),(0,H.jsx)(`p`,{className:`font-sans text-xs sm:text-sm text-trash-gray font-semibold leading-relaxed max-w-sm mx-auto`,children:`Unable to reach the server to fetch your scheduled review cards. Check your connection or retry below.`})]}),(0,H.jsxs)(`div`,{className:`pt-2 flex flex-col sm:flex-row gap-3 justify-center items-center`,children:[(0,H.jsxs)(`button`,{onClick:()=>void I(!0),className:`w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:[(0,H.jsx)(l,{className:`w-4 h-4`}),(0,H.jsx)(`span`,{children:`RETRY CONNECTION`})]}),(r||n)&&(0,H.jsx)(`button`,{onClick:He,className:`w-full sm:w-auto px-5 py-2.5 bg-paper-white hover:bg-warm-sand-bg border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:(0,H.jsx)(`span`,{children:`OPEN JOURNEY MAP`})})]})]})});if(T.length===0)return(0,H.jsx)(Ee,{nextMilestone:P,activatingMilestone:F,onActivateNextMilestone:B,onOpenCardManager:c||(()=>n?.(`cardManager`)),onOpenJourney:He,onOpenCreateProblem:Ue,onOpenWindow:n,overrideProblemId:e,onClearOverride:t});let X=T[0],Z=X?.problems,Ge=Z?.problem_number??(/^\d+$/.test(X?.problem_id||``)?parseInt(X.problem_id,10):void 0),Q=N(Ge,Z?.id||X?.problem_id,Z?.name),{cleanTitle:Ke,approachVariant:qe,pattern:Je}=fe(Z?.name,Q?.name,Z?.pattern,Q?.pattern),$={...Q,...Z,id:Z?.id||Q?.id||X?.problem_id,name:Ke,problem_number:Z?.problem_number??Q?.problem_number,pattern:Je,approach_variant:qe,difficulty:Z?.difficulty||Q?.difficulty||`Medium`,reference_code:Z?.reference_code||Q?.reference_solution||``,starter_code:Q?.starter_code||Z?.starter_code||``,description:Z?.description||Q?.description||``,optimal_time:Z?.optimal_time||Q?.time_complexity||`O(N)`,optimal_space:Z?.optimal_space||Q?.space_complexity||`O(1)`,examples:Z?.examples&&Z.examples.length>0?Z.examples:Q?.examples,constraints:Z?.constraints||Q?.constraints,how_to_solve:Z?.how_to_solve||``,solutions:Z?.solutions&&Z.solutions.length>0?Z.solutions:Q?.solutions},Ye=de({...Q,...$,examples:$.examples&&$.examples.length>0?$.examples:Q?.examples,constraints:$.constraints&&(Array.isArray($.constraints)?$.constraints.length>0:$.constraints)?$.constraints:Q?.constraints}),Xe=Q?.reference_solution||``,Ze=Z?.reference_code||``,Qe=Ze&&(!Xe||Ze.trim()!==Xe.trim())?Ze:``,$e=Qe||Xe||Ze||``;return(0,H.jsxs)(`div`,{ref:x,className:`w-full h-full bg-[#fdf8e1] flex flex-col overflow-hidden select-none`,children:[(0,H.jsx)(_e,{problem:$,totalInQueue:T.length,reviews:T,overrideProblemId:e,onSelectCard:Be,onOpenCreateProblem:Ue,onOpenEditProblem:()=>{s?s($):n?.(`editProblem`)}}),(0,H.jsxs)(`div`,{className:`${p?`flex`:`hidden`} shrink-0 bg-amber-100 border-b-[3px] border-ink-black px-2.5 sm:px-3 py-1.5 gap-1.5 sm:gap-2 overflow-x-auto no-scrollbar`,children:[(0,H.jsxs)(`button`,{onClick:()=>{_(`spec`),h(`spec`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${g===`spec`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(w,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`SPEC`})]}),(0,H.jsxs)(`button`,{onClick:()=>_(`code`),className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${g===`code`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(te,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`CODE STUDIO`})]}),(0,H.jsxs)(`button`,{onClick:()=>{_(`ref`),h(`ref`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${g===`ref`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`SOLUTION`})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 flex ${p?`flex-col`:`flex-row`} overflow-hidden min-h-0`,children:[(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 bg-paper-white ${p?`h-64`:`border-r-[4px] border-ink-black`} font-sans text-xs text-trash-gray select-none`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-arcade text-[10px] text-ink-black`,children:[(0,H.jsx)(i,{className:`w-4 h-4 animate-spin text-[#0ea5e9]`}),(0,H.jsx)(`span`,{children:`Loading Problem Spec...`})]})}),children:(0,H.jsx)(Oe,{leftTab:m,onSelectLeftTab:e=>{h(e),e===`ref`?_(`ref`):e===`spec`&&_(`spec`)},mobileView:g,isNarrow:p,problem:$,parsed:Ye,userSolution:Qe,officialSolution:Xe,effectiveReferenceCode:$e,copiedSnippet:y,onCopyText:Ve,saveRefError:pe,aiSolutionLoading:De,aiSolutionError:ke,onFetchAiSolution:()=>Me(X,e=>{E(t=>t.map((t,n)=>n===0?{...t,problems:{...$||{},...t.problems||{},reference_code:e}}:t))}),explainLoading:Se,explainError:Ce,explanationText:G,onExplainCode:(e,t,n,r)=>je(X,e,t,n,r),activeReview:X,onUpdateSolutions:We,onEditProblem:()=>{s?s($):n?.(`editProblem`)}})}),(0,H.jsx)(we,{mobileView:g,isNarrow:p,isAutocompleteEnabled:S,onToggleAutocomplete:e=>{C(e),localStorage.setItem(`isAutocompleteEnabled`,String(e))},onResetStarterCode:ae,code:M,onChangeCode:re,sandboxRunning:oe,sandboxError:ce,sandboxResults:se,onRunSandbox:()=>U(X,M),savingReference:le,savedRefSuccess:ue,saveRefError:pe,onSaveReference:()=>ve(X,M,(e,t)=>{E(n=>n.map((n,r)=>r===0?{...n,problem_id:t||n.problem_id,problems:{...$||{},...n.problems||{},id:t||n.problems?.id||n.problem_id,reference_code:e}}:n))}),aiLoading:ye,aiError:xe,aiResult:be,onAiEvaluation:()=>Ae(X,M),optimalTime:$.optimal_time||`O(N)`,optimalSpace:$.optimal_space||`O(1)`,onPushToGitHub:Re,pushingToGitHub:Ne,githubPushedUrl:Fe,githubPushError:Le})]}),(0,H.jsx)(Te,{gradeError:j,onDismissGradeError:()=>ne(null),submitting:k,submittingRating:A,onGrade:Y})]})}export{ke as default,pe as n,De as t};
algospaced-ui/dist/assets/ReviewQueue-CSzueRL_.js DELETED
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProblemSpecPanel-clZ38uEk.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-CDF1pnIM.js","assets/vendor-codemirror-By0wlJeM.js","assets/index-DX2cztXb.js","assets/firebaseClient-DZobvwSx.js","assets/vendor-firebase-DSIO3PIf.js","assets/vendor-ui-ZXcm-2wU.js","assets/index-DeC1PAqp.css","assets/MarkdownRenderer-AdFp0pUP.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,Ct as r,D as i,G as a,J as o,N as s,P as c,Q as l,Vt as u,_t as d,at as f,b as p,bt as m,dt as h,f as g,ft as _,i as v,j as y,k as b,l as x,nt as S,o as C,pt as w,st as T,t as E,u as D,wt as O,yt as k,zt as A}from"./vendor-react-CDF1pnIM.js";import{r as j,s as M}from"./firebaseClient-DZobvwSx.js";import{c as N,f as ee,n as P,o as te,r as F,s as I,t as ne}from"./index-DX2cztXb.js";import{o as re,r as ie}from"./githubSyncService-x0Mm_uEl.js";import{t as ae}from"./confetti.module-Uxh4CK4s.js";import"./MarkdownRenderer-AdFp0pUP.js";import"./PrincessChamber-DvQR6sQH.js";import{A as L,C as R,I as z,S as B,p as oe,t as se,x as ce,y as le}from"./vendor-codemirror-By0wlJeM.js";var V=t(u(),1),H=A();function ue(e){if(!e)return{description:``,examples:[],constraints:[]};let t=e.description||``,n=[],r=[];if(Array.isArray(e.examples)&&e.examples.length>0&&(n=e.examples.map(e=>typeof e==`string`?{input:e,output:``}:{input:e?.input||``,output:e?.output||``,explanation:e?.explanation||``})),Array.isArray(e.constraints)&&e.constraints.length>0?r=e.constraints.map(e=>String(e).replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean):typeof e.constraints==`string`&&e.constraints.trim()&&(r=e.constraints.split(`
3
- `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),n.length===0||r.length===0){let e=t.search(/\bExample\s*\d*:/i),i=t.search(/\bConstraints\s*:/i),a=-1;if(e!==-1&&i!==-1?a=Math.min(e,i):e===-1?i!==-1&&(a=i):a=e,a!==-1){let e=t.substring(0,a).trim(),i=t.substring(a),o=i,s=``,c=i.search(/\bConstraints\s*:/i);if(c!==-1&&(o=i.substring(0,c).trim(),s=i.substring(c).replace(/\bConstraints\s*:/i,``).trim()),n.length===0&&o){let e=/\bExample\s*(\d*)\s*:/gi,t=[],r;for(;(r=e.exec(o))!==null;)t.push({index:r.index,text:r[0]});for(let e=0;e<t.length;e++){let r=t[e].index+t[e].text.length,i=e+1<t.length?t[e+1].index:o.length,a=o.substring(r,i).trim(),s=a.match(/Input:\s*([\s\S]+?)(?=(?:Output:|Explanation:|$))/i),c=a.match(/Output:\s*([\s\S]+?)(?=(?:Explanation:|$))/i),l=a.match(/Explanation:\s*([\s\S]+)/i),u=s?s[1].trim():``,d=c?c[1].trim():``,f=l?l[1].trim():``;u||d?n.push({input:u,output:d,explanation:f}):a&&n.push({input:a,output:``,explanation:``})}}r.length===0&&s&&(r=s.split(`
4
- `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),(n.length>0||r.length>0)&&(t=e)}}return{description:t,examples:n,constraints:r}}function de(e,t,n,r){let i=e=>!e||/^Method\s*\d*$/i.test(e.trim())||e.trim().toLowerCase()===`standard`,a=(e||t||`Algorithm Problem`).trim(),o=null;if(t&&a.toLowerCase().startsWith(t.toLowerCase())){let e=a.slice(t.length).trim();if(a=t,e){let t=e.match(/^[-\s]*Method\s*(\d+)\s*\((.+)\)$/i);if(t){let e=parseInt(t[1],10),n=t[2].trim();i(n)?e>1&&(o=`Method ${e}`):o=n}else{let t=e.match(/^[-\s]*Method\s*(\d+)/i);if(t){let e=parseInt(t[1],10);e>1&&(o=`Method ${e}`)}else{let t=e.match(/^[-\s]*\((.+)\)$/);if(t){let e=t[1].trim();i(e)||(o=e)}else{let t=e.match(/^[-\s]+([^-]+)$/);t&&!i(t[1])&&(o=t[1].trim())}}}}}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)\s*\((.+)\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10),n=e[3].trim();i(n)?t>1&&(o=`Method ${t}`):o=n}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}else{let e=a.match(/^(.*?)\s*\(\s*Method\s*(\d+)\s*\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}}}}let s=`General Algorithm`;return i(n)?i(r)?o&&!i(o)&&(s=o):s=r.trim():s=n.trim(),{cleanTitle:a,approachVariant:o,pattern:s}}function fe(e,t,n){if(!e)return[];if(Array.isArray(e.solutions)&&e.solutions.length>0)return e.solutions;let r=[],i=t||e.reference_code||``,a=e.pattern||`General Algorithm`,o=e.optimal_time||`O(N)`,s=e.optimal_space||`O(1)`;return(i||a)&&r.push({id:`sol-1`,name:e.approach_variant||`Optimal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:i,explanation:e.how_to_solve||``,is_optimal:!0}),n&&n.trim()&&n.trim()!==i.trim()&&r.push({id:`sol-2`,name:`Personal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:n,is_optimal:!1}),r}function U(e){if(e&&e!==`sandbox-user-id`)return e;try{let e=j();if(e?.user?.id&&e.user.id!==`sandbox-user-id`)return e.user.id}catch{}return`guest`}function pe({overrideProblemId:e,refreshTrigger:t,onClearOverride:n}){let[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!0),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(()=>{try{return j()?.user?.id}catch{return}}),C=(0,V.useRef)(!1),w=(0,V.useRef)(n),T=(0,V.useRef)(!1);(0,V.useEffect)(()=>{w.current=n});let E=(0,V.useCallback)(async(t=!0)=>{t?(o(!0),m(null),c(null),g(``),C.current=!1):m(null);let n=U(x);try{if(typeof navigator<`u`&&!navigator.onLine)throw Error(`Network connection offline.`);let{data:{session:r}}=await M.auth.getSession(),a=r?r.access_token:`sandbox`;r?.user?.id&&(S(r.user.id),n=U(r.user.id));let o={Authorization:`Bearer ${a}`},s=new AbortController,l=setTimeout(()=>s.abort(),4e3),u;try{u=await fetch(`/api/reviews/due`,{headers:o,signal:s.signal})}finally{clearTimeout(l)}if(!u.ok)throw Error(`Failed to load review queue: HTTP ${u.status}`);let d=await u.json();if(Array.isArray(d)||(d=[]),e){let t=String(e).trim().toLowerCase(),n=d.findIndex(e=>{let n=e.problems;return!!(e.problem_id&&String(e.problem_id).trim().toLowerCase()===t||n?.id&&String(n.id).trim().toLowerCase()===t||n?.problem_number!==void 0&&n?.problem_number!==null&&String(n.problem_number)===t||n?.name&&n.name.trim().toLowerCase()===t)});if(n>0){let[e]=d.splice(n,1);d.unshift(e)}else if(n===-1){let t=null,n=await fetch(`/api/reviews/problems/id/${e}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}if(!t){let n=/^\d+$/.test(e),r=F(n?parseInt(e,10):void 0,e);if(r)try{let e=await N(r);if(e?.problem_id){let n=await fetch(`/api/reviews/problems/id/${e.problem_id}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}}}catch(e){console.error(`Failed to auto-activate problem for override review:`,e)}}t&&d.unshift(t)}}i(d),c(null);try{localStorage.setItem(`algospaced_review_queue_${n}`,JSON.stringify(d))}catch{}if(d&&d.length>0){if(t){let e=d[0],t=e.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=F(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(r)}}else try{let e=await fetch(`/api/journey-progress`,{headers:o});if(e.ok){let t=await e.json();v(I(new Set(t))??null)}else v(I(new Set)??null)}catch{v(I(new Set)??null)}}catch(e){console.error(`Error fetching review queue:`,e);let r=e instanceof Error?e.message:`Network error loading review queue.`,a=!1;try{let e=localStorage.getItem(`algospaced_review_queue_${n}`);if(e){let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0&&(i(n),a=!0,c(null),t)){let e=n[0],t=e.problems,r=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(r,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)}}}catch(e){console.warn(`Failed to parse cached review items:`,e)}a||c(r)}finally{o(!1)}},[e,x]);(0,V.useEffect)(()=>{if(T.current){T.current=!1;return}let e=!1,t=setTimeout(()=>{e||E(!0)},0);return()=>{e=!0,clearTimeout(t)}},[E,t]),(0,V.useEffect)(()=>{if(!a&&!s&&r.length===0&&!e&&!C.current){C.current=!0;try{ae({particleCount:90,spread:70,origin:{y:.6}})}catch{}}},[a,s,r.length,e]);let D=(0,V.useCallback)(async t=>{if(r.length===0||l)return;let n=r[0];if(!n||!n.id)return;u(!0),f(t),m(null);let a=[...r];try{let{data:{session:r}}=await M.auth.getSession(),o=r?r.access_token:`sandbox`,s=await fetch(`/api/reviews/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify({review_id:n.id,fsrs_state:n.fsrs_state??0,fsrs_step:n.fsrs_step??0,fsrs_stability:n.fsrs_stability??0,fsrs_difficulty:n.fsrs_difficulty??0,fsrs_elapsed_days:n.fsrs_elapsed_days??0,fsrs_scheduled_days:n.fsrs_scheduled_days??0,fsrs_reps:n.fsrs_reps??0,fsrs_lapses:n.fsrs_lapses??0,last_reviewed:n.last_reviewed,rating:t})});if(s.ok){let r=n?.problems?.name||``,a=n?.problems?.pattern||``,o=`Correct`;o=t===1?`Incorrect`:t===2?`Mixed`:`Correct`,ee.addReviewEvent(o,r,a).catch(()=>{});let s=ie(),l=h.trim()||n?.problems?.reference_code||``;s.token&&s.repoName&&s.autoCommit&&l&&re({token:s.token,repo:s.repoName,branch:s.branch,problem_number:n?.problems?.problem_number,problem_name:r||`Algorithm Problem`,pattern:a||`Algorithms`,difficulty:n?.problems?.difficulty||`Medium`,optimal_time:n?.problems?.optimal_time||`O(N)`,optimal_space:n?.problems?.optimal_space||`O(1)`,description:n?.problems?.description||``,code:l}).catch(e=>{console.warn(`GitHub background auto-commit failed:`,e)}),e&&w.current&&(T.current=!0,w.current()),i(e=>{let t=e.slice(1);try{let e=U(x);localStorage.setItem(`algospaced_review_queue_${e}`,JSON.stringify(t))}catch{}if(t.length>0){let e=t[0],n=e.problems,r=n?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(r,n?.id||e?.problem_id,n?.name)?.starter_code||n?.starter_code||``;g(i)}else g(``);return t}),c(null),E(!1)}else{let e=await s.json().catch(()=>({}));m(e.detail||`Server returned error (${s.status}). Please try again.`),i(a)}}catch(e){console.error(`Error logging review completion:`,e);let t=e instanceof Error?e.message:`Network connection failed while logging review.`;m(t),i(a)}finally{u(!1),f(null)}},[r,l,e,E,h,x]),O=(0,V.useCallback)(async()=>{if(_&&!y){b(!0);try{await N(_),await E()}catch(e){console.error(`Failed to activate next milestone:`,e)}finally{b(!1)}}},[_,y,E]),k=(0,V.useCallback)(()=>{let e=r[0],t=e?.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)},[r]);return{reviews:r,setReviews:i,loading:a,queueError:s,submitting:l,submittingRating:d,gradeError:p,setGradeError:m,code:h,setCode:g,nextMilestone:_,activatingMilestone:y,currentUserId:x,fetchQueue:E,handleGrade:D,handleSelectCard:(0,V.useCallback)(t=>{if(t<=0||t>=r.length||l)return;e&&w.current&&(T.current=!0,w.current());let n=r[t];if(!n)return;let a=n.problems,o=a?.problem_number??(/^\d+$/.test(n?.problem_id||``)?parseInt(n.problem_id,10):void 0),s=F(o,a?.id||n?.problem_id,a?.name)?.starter_code||a?.starter_code||``;g(s),i(e=>{let t=e.findIndex(e=>e.id&&e.id===n.id||e===n);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]})},[r,l,e]),handleActivateNextMilestone:O,handleResetStarterCode:k}}function me(){return{sandboxRunning:P(e=>e.sandboxRunning),sandboxResults:P(e=>e.sandboxResults),sandboxError:P(e=>e.sandboxError),savingReference:P(e=>e.savingReference),savedRefSuccess:P(e=>e.savedRefSuccess),saveRefError:P(e=>e.saveRefError),handleRunSandbox:P(e=>e.handleRunSandbox),handleSaveReference:P(e=>e.handleSaveReference),resetSandbox:P(e=>e.resetSandbox)}}function he(){return{aiLoading:P(e=>e.aiLoading),aiResult:P(e=>e.aiResult),aiError:P(e=>e.aiError),explainLoading:P(e=>e.explainLoading),explanationText:P(e=>e.explanationText),explainError:P(e=>e.explainError),aiSolutionLoading:P(e=>e.aiSolutionLoading),aiSolutionError:P(e=>e.aiSolutionError),handleAiEvaluation:P(e=>e.handleAiEvaluation),handleExplainCode:P(e=>e.handleExplainCode),handleFetchAiSolution:P(e=>e.handleFetchAiSolution),resetAiState:P(e=>e.resetAiState)}}var ge=({problem:e,totalInQueue:t,reviews:n=[],onSelectCard:r,onOpenCreateProblem:i,onOpenEditProblem:a})=>{let[o,l]=(0,V.useState)(!1),u=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&l(!1)},t=e=>{e.key===`Escape`&&l(!1)};return o&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]);let d=e.problem_number?`https://leetcode.com/problemset/all/?search=${e.problem_number}`:`https://leetcode.com/problemset/all/?search=${encodeURIComponent(e.name||``)}`;return(0,H.jsxs)(`div`,{className:`shrink-0 bg-paper-white border-b-[3px] border-ink-black px-2.5 sm:px-4 py-2 flex flex-wrap items-center justify-between gap-2 shadow-[0_2px_0_0_rgba(30,41,59,0.05)] relative z-40`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap min-w-0`,children:[(0,H.jsxs)(`div`,{className:`relative shrink-0`,ref:u,children:[(0,H.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`h-7 inline-flex items-center gap-1.5 px-2 sm:px-2.5 bg-amber-300 hover:bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Click to view all cards due in today's queue`,children:[(0,H.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-ping shrink-0`}),(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] font-bold text-ink-black tracking-wide whitespace-nowrap`,children:`CARD 1 OF ${t}`}),t>1&&(0,H.jsx)(k,{className:`w-3 h-3 text-ink-black transition-transform shrink-0 ${o?`rotate-180`:``}`})]}),o&&n.length>0&&(0,H.jsxs)(`div`,{className:`absolute top-9 left-0 z-50 w-64 min-[400px]:w-72 sm:w-80 bg-paper-white border-[3px] border-ink-black gadget-shadow p-3 space-y-2 max-w-[calc(100vw-32px)]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b-2 border-ink-black pb-1.5 font-arcade text-[9px] font-bold text-ink-black`,children:[(0,H.jsx)(`span`,{children:`DAILY QUEUE (${n.length} CARDS)`}),(0,H.jsx)(`button`,{onClick:()=>l(!1),className:`px-1 hover:text-rose-600 font-bold cursor-pointer`,title:`Close`,children:`✕`})]}),(0,H.jsx)(`div`,{className:`text-[7.5px] font-arcade text-trash-gray uppercase -mt-0.5`,children:`Click any card to solve it now:`}),(0,H.jsx)(`div`,{className:`max-h-60 overflow-y-auto no-scrollbar space-y-1.5 pr-1`,children:n.map((e,t)=>{let n=e.problems,i=n?.problem_number,a=i==null?void 0:te(i),{cleanTitle:o,approachVariant:c}=de(n?.name||``,a?.name),u=c?`${o} (${c})`:o,d=t===0,f=n?.difficulty,p=f?f.toUpperCase():`EASY`,m=f===`Easy`?`bg-emerald-600 text-white`:f===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{d||r?.(t),l(!1)},className:`group w-full text-left p-2 border-2 border-ink-black text-xs flex items-center justify-between gap-2 cursor-pointer transition-all duration-150 select-none ${d?`bg-amber-100 font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-white hover:bg-amber-50 hover:translate-x-0.5 active:translate-y-0.5 active:shadow-none shadow-[2px_2px_0px_0px_rgba(30,41,59,0.25)]`}`,title:d?`Currently active card`:`Jump to #${t+1}: ${u}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate min-w-0`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] text-trash-gray shrink-0`,children:[`#`,t+1]}),i!=null&&(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] font-bold px-1 py-0.2 bg-amber-300 border border-ink-black shrink-0`,children:[`LC #`,i]}),(0,H.jsx)(`span`,{className:`truncate`,children:u})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[d?(0,H.jsx)(`span`,{className:`text-[7.5px] font-arcade font-extrabold px-1 py-0.5 bg-amber-300 text-ink-black border border-ink-black shrink-0`,children:`NOW`}):(0,H.jsx)(s,{className:`w-2.5 h-2.5 fill-ink-black text-ink-black opacity-0 group-hover:opacity-100 transition-opacity shrink-0`}),(0,H.jsx)(`span`,{className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black shrink-0 ${m}`,children:p})]})]},e.id||t)})})]})]}),e.problem_number!==void 0&&e.problem_number!==null&&(0,H.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-ink-black shrink-0 select-none whitespace-nowrap`,children:e.problem_number>0?`LC #${e.problem_number}`:`CUSTOM`}),(0,H.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] shrink-0 select-none whitespace-nowrap ${e.difficulty===`Easy`?`bg-emerald-600 text-white`:e.difficulty===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`}`,children:e.difficulty?e.difficulty.toUpperCase():`EASY`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 flex-wrap justify-end`,children:[(0,H.jsxs)(`button`,{onClick:i,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-purple-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Create or Import Problem`,children:[(0,H.jsx)(_,{className:`w-3 h-3 text-purple-600 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`ADD`})]}),a&&(0,H.jsxs)(`button`,{onClick:a,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-emerald-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Edit Problem Specification`,children:[(0,H.jsx)(c,{className:`w-3 h-3 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`EDIT`})]}),e.google_doc_url&&(0,H.jsxs)(`a`,{href:e.google_doc_url,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Open Google Doc Notes`,children:[(0,H.jsx)(`span`,{children:`DOC`}),(0,H.jsx)(S,{className:`w-2.5 h-2.5 text-primary shrink-0`})]}),(0,H.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Search LeetCode`,children:[(0,H.jsx)(`span`,{children:`LC`}),(0,H.jsx)(S,{className:`w-2.5 h-2.5 text-amber-600 shrink-0`})]})]})]})},_e=ce.mark({class:`cm-indent-dot cm-indent-dot-primary`}),ve=ce.mark({class:`cm-indent-dot cm-indent-dot-secondary`});function W(e){let t=new z;for(let{from:n,to:r}of e.visibleRanges){let i=n;for(;i<r;){let n=e.state.doc.lineAt(i),r=n.text,a=0;for(;a<r.length&&(r[a]===` `||r[a]===` `);){let e=n.from+a,i=e+1,o=a%4==0||r[a]===` `;t.add(e,i,o?_e:ve),a++}i=n.to+1}}return t.finish()}var ye=R.fromClass(class{decorations;constructor(e){this.decorations=W(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=W(e.view))}},{decorations:e=>e.decorations}),be=B.theme({"&":{backgroundColor:`#0c111d`,color:`#f1f5f9`,height:`100%`,fontSize:`13px`,fontFamily:`var(--font-code, "JetBrains Mono", "Fira Code", monospace)`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`,lineHeight:`1.65`},".cm-content":{caretColor:`#4ade80`,padding:`12px 0`},"&.cm-focused .cm-cursor":{borderLeftColor:`#4ade80`,borderLeftWidth:`2px`,filter:`drop-shadow(0 0 5px rgba(74, 222, 128, 0.8))`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`rgba(56, 189, 248, 0.25) !important`},".cm-gutters":{backgroundColor:`#070a12`,color:`#475569`,borderRight:`2px solid #1e293b`,paddingRight:`6px`,userSelect:`none`},".cm-activeLineGutter":{backgroundColor:`#131b2e`,color:`#38bdf8`,fontWeight:`700`},".cm-activeLine, &.cm-focused .cm-activeLine":{backgroundColor:`#0f172a !important`},".cm-line":{padding:`0 10px`},".cm-indent-dot":{position:`relative`,display:`inline-block`},".cm-indent-dot::before":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,userSelect:`none`,lineHeight:`0`,fontFamily:`monospace`},".cm-indent-dot-primary::before":{content:`"•"`,color:`#38bdf8`,fontSize:`9px`,opacity:`0.85`},".cm-indent-dot-secondary::before":{content:`"·"`,color:`#64748b`,fontSize:`11px`,opacity:`0.5`},"&.cm-focused .cm-matchingBracket, .cm-matchingBracket":{backgroundColor:`rgba(74, 222, 128, 0.2)`,outline:`1px solid #4ade80`,borderRadius:`2px`,color:`#86efac !important`},".cm-placeholder":{color:`#64748b`,fontStyle:`italic`},".cm-scroller::-webkit-scrollbar":{width:`6px`,height:`6px`},".cm-scroller::-webkit-scrollbar-track":{backgroundColor:`#070a12`},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:`#1e293b`,borderRadius:`3px`,border:`1px solid #334155`},".cm-scroller::-webkit-scrollbar-thumb:hover":{backgroundColor:`#38bdf8`}}),xe=[se(),le.of(` `),L.of([oe]),ye,be,B.contentAttributes.of({"aria-label":`Python Code Editor`})],G=[{id:`python`,name:`Python`,version:`3.14`}],Se=({className:e=`w-3.5 h-3.5`})=>(0,H.jsxs)(`svg`,{viewBox:`0 0 128 128`,className:e,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M63.454 4.018c-14.775 0-23.774 6.425-23.774 18.775v13.626h24.168v3.424H30.082C17.518 39.843 8 47.962 8 63.673c0 15.65 8.358 23.486 21.056 23.486h11.905v-16.89c0-13.064 11.233-24.113 24.331-24.113h23.773V32.793c0-11.83-9.988-19.775-23.773-19.775H63.454v-9zm-9.845 7.426a3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841 3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841z`,fill:`#387eb8`}),(0,H.jsx)(`path`,{d:`M64.546 123.982c14.775 0 23.774-6.425 23.774-18.775V91.581H64.152v-3.424h33.766c12.564 0 22.082-8.119 22.082-23.83 0-15.65-8.358-23.486-21.056-23.486H87.04v16.89c0 13.064-11.234 24.113-24.332 24.113H38.934v13.363c0 11.83 9.989 19.775 23.774 19.775h1.838v9zm9.845-7.426a3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841 3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841z`,fill:`#ffe052`})]}),Ce=({mobileView:e,isNarrow:t=!1,isAutocompleteEnabled:n,onToggleAutocomplete:r,onResetStarterCode:a,code:c,onChangeCode:u,sandboxRunning:d,sandboxError:f,sandboxResults:_,onRunSandbox:v,savingReference:x,savedRefSuccess:C,saveRefError:T,onSaveReference:A,aiLoading:j,aiError:M,aiResult:N,onAiEvaluation:ee,optimalTime:P,optimalSpace:te,onPushToGitHub:F,pushingToGitHub:I,githubPushedUrl:ne,githubPushError:re})=>{let[ie,ae]=(0,V.useState)(`python`),[L,R]=(0,V.useState)(!1),z=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=e=>{z.current&&!z.current.contains(e.target)&&R(!1)},t=e=>{e.key===`Escape`&&R(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let B=G.find(e=>e.id===ie)??G[0];return(0,H.jsxs)(`div`,{className:`w-full ${t?`flex flex-1`:`lg:w-[51%] flex`} flex-col bg-[#fffdfa] overflow-y-auto no-scrollbar ${t&&e!==`code`?`hidden`:`flex`}`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 bg-[#f7f5ed] border-b-2 border-ink-black p-2 sm:px-3 flex flex-wrap items-center justify-between gap-1.5 sm:gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap`,children:[(0,H.jsxs)(`div`,{className:`relative`,ref:z,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`h-7 px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 font-arcade text-[9px] font-bold text-ink-black cursor-pointer transition-all select-none`,title:`Select programming language`,"aria-expanded":L,"aria-haspopup":`listbox`,children:[(0,H.jsx)(Se,{className:`w-3.5 h-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:B.name}),(0,H.jsx)(k,{className:`w-3 h-3 text-ink-black transition-transform duration-150 ${L?`rotate-180`:``}`})]}),L&&(0,H.jsxs)(`div`,{className:`absolute top-full mt-1.5 left-0 z-50 w-52 bg-paper-white border-[3px] border-ink-black gadget-shadow p-1.5 space-y-1`,role:`listbox`,children:[(0,H.jsx)(`div`,{className:`px-2 py-1 text-[8px] font-arcade font-bold text-trash-gray uppercase border-b border-slate-200`,children:`SELECT LANGUAGE`}),G.map(e=>{let t=ie===e.id;return(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{ae(e.id),R(!1)},className:`w-full flex items-center justify-between px-2.5 py-1.5 border-2 border-ink-black text-left transition-all cursor-pointer ${t?`bg-amber-200 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] font-bold text-ink-black`:`bg-white hover:bg-slate-100 text-slate-800`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[9px]`,children:[(0,H.jsx)(Se,{className:`w-3.5 h-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:e.name})]}),(0,H.jsxs)(`span`,{className:`font-mono text-[8px] font-bold px-1.5 py-0.5 bg-white border border-ink-black text-slate-700 shadow-[1px_1px_0px_0px_rgba(30,41,59,0.3)]`,children:[`v`,e.version]})]},e.id)})]})]}),(0,H.jsx)(`div`,{className:`h-4 w-[2px] bg-slate-300 mx-0.5 hidden sm:block`}),(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),className:`sr-only peer`,"aria-label":`Toggle code editor autocompletion`}),(0,H.jsx)(`div`,{className:`relative w-7 h-3.5 bg-slate-300 border border-ink-black rounded-full peer peer-checked:bg-grass-green transition-all after:content-[''] after:absolute after:top-[1px] after:left-[2px] after:bg-white after:border after:border-ink-black after:rounded-full after:h-2 after:w-2 after:transition-all peer-checked:after:translate-x-3`}),(0,H.jsx)(`span`,{className:`text-[7.5px] min-[400px]:text-[8px] font-arcade font-bold text-trash-gray peer-checked:text-ink-black whitespace-nowrap`,children:`AUTOCOMPLETE`})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,H.jsx)(`button`,{onClick:a,className:`w-7 h-7 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-ink-black flex items-center justify-center cursor-pointer transition-all`,title:`Reset to starter code`,"aria-label":`Reset to starter code`,children:(0,H.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(`button`,{onClick:()=>u(``),className:`w-7 h-7 bg-white hover:bg-rose-50 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-rose-700 flex items-center justify-center cursor-pointer transition-all`,title:`Clear editor`,"aria-label":`Clear editor`,children:(0,H.jsx)(g,{className:`w-3.5 h-3.5 text-rose-600`})}),A&&(0,H.jsx)(`button`,{onClick:A,disabled:x||!c.trim(),className:`w-7 h-7 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all ${C?`bg-emerald-600 hover:bg-emerald-500 text-white`:`bg-amber-400 hover:bg-amber-300 text-ink-black`}`,title:x?`Saving solution to personal database...`:C?`Saved to personal database!`:`Overwrite saved solution with studio code`,"aria-label":`Overwrite saved solution with studio code`,children:x?(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):C?(0,H.jsx)(w,{className:`w-3.5 h-3.5 text-white`}):(0,H.jsx)(i,{className:`w-3.5 h-3.5 text-ink-black`})}),F&&(0,H.jsx)(`button`,{onClick:F,disabled:I||!c.trim(),className:`w-7 h-7 bg-[#24292e] hover:bg-black border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:I?`Pushing to GitHub...`:`Push solution to GitHub repository`,"aria-label":`Push to GitHub`,children:I?(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin text-yellow-300`}):(0,H.jsx)(l,{className:`w-3.5 h-3.5 text-yellow-300`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,H.jsx)(`button`,{onClick:v,disabled:d||!c.trim(),className:`w-7 h-7 bg-emerald-600 hover:bg-emerald-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:d?`Running sandbox tests...`:`Run tests in local sandbox`,"aria-label":`Run tests`,children:d?(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin`}):(0,H.jsx)(s,{className:`w-3.5 h-3.5 fill-white text-white ml-0.5`})}),(0,H.jsx)(`button`,{onClick:ee,disabled:j||!c.trim(),className:`w-7 h-7 bg-purple-600 hover:bg-purple-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:j?`Evaluating code with Gemini...`:`Gemini Eval (AI code review & complexity)`,"aria-label":`Gemini Eval`,children:j?(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin`}):(0,H.jsx)(p,{className:`w-3.5 h-3.5 text-amber-300`})})]})]}),(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 flex-1 flex flex-col space-y-4`,children:[(0,H.jsx)(`div`,{className:`flex-1 flex flex-col min-h-[300px] sm:min-h-[360px] border-[3px] border-ink-black shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] bg-[#0c111d] overflow-hidden`,children:(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,H.jsx)(E,{value:c,onChange:u,placeholder:`def solve(nums):
5
- # Write your solution from memory here...`,height:`100%`,theme:`dark`,extensions:xe,basicSetup:{autocompletion:n,lineNumbers:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0},className:`w-full h-full text-xs font-code-mono`})})}),C&&(0,H.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(w,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{children:`Successfully saved studio code as your personal reference solution!`})]}),T&&(0,H.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(D,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:T})]}),ne&&(0,H.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(w,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,H.jsx)(`span`,{children:`Successfully pushed solution to your GitHub repository!`})]}),(0,H.jsxs)(`a`,{href:ne,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-bold text-blue-700 hover:text-blue-900 underline flex items-center gap-1`,children:[(0,H.jsx)(`span`,{children:`View on GitHub`}),(0,H.jsx)(S,{className:`w-3 h-3`})]})]}),re&&(0,H.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(D,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:re})]}),d&&(0,H.jsxs)(`div`,{className:`p-3 border-2 border-ink-black bg-emerald-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,H.jsx)(y,{className:`w-5 h-5 text-emerald-600 animate-spin shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`Running...`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Executing against test cases...`})]})]}),f&&(0,H.jsxs)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center gap-2`,children:[(0,H.jsx)(D,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,H.jsx)(`span`,{children:f})]}),_&&(0,H.jsxs)(`div`,{className:`border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3.5 ${_.status===`passed`?`bg-[#f0fdf4]`:`bg-[#fff1f2]`}`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2.5 border-b-2 border-dashed border-ink-black`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,H.jsx)(`div`,{className:`w-8 h-8 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${_.status===`passed`?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:_.status===`passed`?(0,H.jsx)(m,{className:`w-5 h-5 stroke-[3]`}):(0,H.jsx)(D,{className:`w-4 h-4`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5 uppercase`,children:_.status===`passed`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`ALL TESTS PASSED`}),(0,H.jsx)(w,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:_.status===`error`?`EXECUTION ERROR`:`TESTS FAILED`}),(0,H.jsx)(h,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,H.jsxs)(`div`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:[_.passed_count??0,` of `,_.total_tests??0,` test cases passed (`,(_.duration_ms??0).toFixed(1),`ms)`]})]})]}),_.status===`passed`&&(0,H.jsxs)(`button`,{onClick:A,disabled:x,className:`px-3 py-1.5 bg-white hover:bg-emerald-100 border-2 border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 disabled:opacity-50`,children:[x?(0,H.jsx)(y,{className:`w-3 h-3 animate-spin`}):C?(0,H.jsx)(w,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,H.jsx)(i,{className:`w-3.5 h-3.5 text-blue-600`}),(0,H.jsx)(`span`,{children:C?`SAVED TO DB!`:`SAVE AS OFFICIAL SOLUTION`})]})]}),T&&(0,H.jsx)(`div`,{className:`p-2 border border-rose-500 bg-rose-100 text-rose-800 text-[11px] font-semibold`,children:T}),_.results&&_.results.length>0&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase font-bold block`,children:`TEST CASE BREAKDOWN:`}),(0,H.jsx)(`div`,{className:`space-y-1.5 max-h-56 overflow-y-auto custom-scrollbar`,children:_.results.map((e,t)=>(0,H.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-mono shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] ${e.passed?`bg-white`:`bg-rose-50`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between font-arcade text-[8px] mb-1`,children:[(0,H.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`CASE #`,t+1]}),(0,H.jsx)(`span`,{className:e.passed?`text-emerald-700 font-bold`:`text-rose-700 font-bold`,children:e.passed?`✓ PASSED`:`✗ FAILED`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-[10px]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Input:`}),(0,H.jsx)(`span`,{className:`font-code-mono text-ink-black font-semibold break-all`,children:JSON.stringify(e.input)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Expected:`}),(0,H.jsx)(`span`,{className:`font-code-mono text-emerald-700 font-semibold break-all`,children:JSON.stringify(e.expected)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-slate-500 block`,children:`Output:`}),(0,H.jsx)(`span`,{className:`font-code-mono font-semibold break-all ${e.passed?`text-emerald-700`:`text-rose-700`}`,children:e.output===void 0?`None`:JSON.stringify(e.output)})]})]}),e.error&&(0,H.jsx)(`div`,{className:`mt-1.5 p-1.5 bg-rose-100 text-rose-900 text-[10px] font-mono border border-rose-300 break-all`,children:e.error})]},t))})]}),_.error&&(0,H.jsx)(`div`,{className:`p-3 bg-[#1E293B] text-rose-400 font-code-mono text-[11px] border-2 border-ink-black overflow-x-auto whitespace-pre-wrap select-text`,children:_.error}),_.status===`passed`&&(0,H.jsx)(`div`,{className:`p-2 bg-emerald-100/70 border border-emerald-300 text-emerald-900 text-xs flex items-center justify-between`,children:(0,H.jsx)(`span`,{className:`font-sans font-medium`,children:`✨ All unit tests passed. Rate your recall below.`})})]}),j&&(0,H.jsxs)(`div`,{className:`p-4 border-2 border-ink-black bg-amber-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,H.jsx)(y,{className:`w-6 h-6 text-purple-600 animate-spin shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`ANALYZING...`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Checking edge cases, bounds, and Big-O efficiency against optimal constraints...`})]})]}),M&&(0,H.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:M}),N&&(0,H.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-[#fefce8] p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b-2 border-dashed border-ink-black`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`w-9 h-9 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${N.is_correct?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:N.is_correct?(0,H.jsx)(m,{className:`w-5 h-5 stroke-[3]`}):(0,H.jsx)(O,{className:`w-5 h-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5`,children:N.is_correct?(0,H.jsxs)(H.Fragment,{children:[`STATUS: PASSED`,(0,H.jsx)(w,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,H.jsxs)(H.Fragment,{children:[`STATUS: FAILED`,(0,H.jsx)(h,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,H.jsx)(`span`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:N.is_correct?`Algorithm matches expected logic and patterns.`:`Bugs or edge-case failures detected.`})]})]}),(0,H.jsx)(`span`,{className:`font-arcade text-[9px] px-2 py-1 border-2 border-ink-black uppercase font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${N.is_correct?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:N.is_correct?`CORRECT`:`INCORRECT`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Time Complexity`}),(0,H.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,H.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:N.detected_complexity?.time||`N/A`}),(0,H.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,P||`O(N)`,`)`]})]})]}),(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Space Complexity`}),(0,H.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,H.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:N.detected_complexity?.space||`N/A`}),(0,H.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,te||`O(1)`,`)`]})]})]})]}),N.bugs&&N.bugs.length>0&&(0,H.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black space-y-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] text-rose-600 uppercase font-bold block flex items-center gap-1`,children:[(0,H.jsx)(D,{className:`w-3 h-3 text-rose-500`}),`TRACES & EDGE CASE ISSUES:`]}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-xs text-slate-800 space-y-1 font-semibold pl-1`,children:N.bugs.map((e,t)=>(0,H.jsx)(`li`,{className:`leading-relaxed select-text`,children:e},t))})]}),N.key_suggestion&&(0,H.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black space-y-1 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-700 uppercase font-bold block flex items-center gap-1`,children:[(0,H.jsx)(p,{className:`w-3 h-3 text-amber-500`}),`TIP:`]}),(0,H.jsx)(`p`,{className:`text-xs text-slate-800 font-medium leading-relaxed m-0 select-text`,children:N.key_suggestion})]}),(0,H.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-dashed border-ink-black flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-bold text-ink-black flex items-center gap-1.5`,children:[(0,H.jsx)(o,{className:`w-4 h-4 text-primary`}),`Recommendation:`]}),(0,H.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-purple-700`,children:N.is_correct?`Rate your recall below.`:`Review issues and rate recall below.`})]})]})]})]})},we=({gradeError:e,onDismissGradeError:t,submitting:n,submittingRating:r,onGrade:i})=>(0,H.jsx)(`div`,{className:`shrink-0 bg-[#f8f5eb] border-t-[3px] border-ink-black p-2 sm:p-3 flex flex-col items-stretch gap-1.5 sm:gap-2 shadow-[0_-3px_0_0_rgba(30,41,59,0.08)]`,children:(0,H.jsxs)(`div`,{className:`w-full flex flex-col`,children:[e&&(0,H.jsxs)(`div`,{className:`p-2.5 mb-2 bg-red-100 border-2 border-red-500 text-red-800 text-xs font-semibold shadow-[2px_2px_0px_0px_#1E293B] flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(D,{className:`w-4 h-4 text-red-600 shrink-0`}),e]}),(0,H.jsx)(`button`,{onClick:t,className:`text-red-900 font-bold hover:underline cursor-pointer ml-2 text-xs`,children:`Dismiss`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 sm:gap-2.5 w-full`,children:[(0,H.jsx)(`button`,{onClick:()=>i(1),disabled:n,className:`flex-1 min-w-0 bg-[#dc2626] hover:bg-[#b91c1c] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-white flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 1 on keyboard`,children:r===1?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/20 rounded shrink-0`,children:`1`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Again`})]})}),(0,H.jsx)(`button`,{onClick:()=>i(2),disabled:n,className:`flex-1 min-w-0 bg-[#ff9933] hover:bg-[#ff8000] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 2 on keyboard`,children:r===2?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`2`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Hard`})]})}),(0,H.jsx)(`button`,{onClick:()=>i(3),disabled:n,className:`flex-1 min-w-0 bg-[#4ade80] hover:bg-[#22c55e] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 3 on keyboard`,children:r===3?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`3`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Good`})]})}),(0,H.jsx)(`button`,{onClick:()=>i(4),disabled:n,className:`flex-1 min-w-0 bg-[#60a5fa] hover:bg-[#3b82f6] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 4 on keyboard`,children:r===4?(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,H.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,H.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`4`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Easy`})]})})]})]})}),Te=({nextMilestone:e,activatingMilestone:t,onActivateNextMilestone:n,onOpenCardManager:r,onOpenJourney:i,onOpenCreateProblem:o,onOpenWindow:s,overrideProblemId:c,onClearOverride:l})=>(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-lg bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,H.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-grass-green via-amber-300 to-highlight-pink`}),(0,H.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,H.jsx)(`div`,{className:`w-20 h-20 bg-amber-300 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-3deg] hover:rotate-0 transition-transform`,children:(0,H.jsx)(x,{className:`w-10 h-10 text-ink-black stroke-[2.5]`})}),(0,H.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-grass-green border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] text-ink-black font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`100% DONE`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-1 bg-emerald-100 border-2 border-ink-black text-emerald-800 font-arcade text-[9px] font-bold`,children:[(0,H.jsx)(m,{className:`w-3 h-3 stroke-[3]`}),` ALL CARDS COMPLETED FOR TODAY`]}),(0,H.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`You're all caught up for today. Keep it up.`}),(0,H.jsx)(`p`,{className:`text-xs sm:text-sm font-sans text-trash-gray max-w-md mx-auto leading-relaxed font-semibold`,children:`All reviews for today are finished. Next reviews are scheduled for tomorrow.`})]}),e&&(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-br from-amber-50 to-orange-50 border-[3px] border-ink-black gadget-shadow text-left space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-800 uppercase tracking-wider flex items-center gap-1.5`,children:[(0,H.jsx)(f,{className:`w-3.5 h-3.5 text-amber-600`}),`NEXT UNEXPLORED MILESTONE`]}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] font-bold px-2 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20`,children:[`LC #`,e.problem_number]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black truncate`,children:e.name}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,H.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty}),(0,H.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] bg-purple-100 text-purple-800 border border-purple-300 font-bold`,children:e.pattern}),(0,H.jsxs)(`span`,{className:`text-[11px] font-code-mono text-slate-600`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]}),(0,H.jsx)(`button`,{onClick:n,disabled:t,className:`px-4 py-2.5 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center justify-center gap-1.5 disabled:opacity-50`,children:t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(y,{className:`w-3.5 h-3.5 animate-spin`}),(0,H.jsx)(`span`,{children:`ACTIVATING...`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(p,{className:`w-3.5 h-3.5 text-amber-700`}),(0,H.jsx)(`span`,{children:`ACTIVATE & REVIEW NOW`})]})})]})]}),(0,H.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-r from-sky-100 via-sky-200 to-indigo-100 border-[3px] border-ink-black gadget-shadow text-left flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-sky-900 uppercase flex items-center gap-1.5`,children:[(0,H.jsx)(v,{className:`w-3.5 h-3.5 text-sky-700`}),`DECK BROWSER & CARD MANAGER`]}),(0,H.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Want to Manage or Reschedule Cards?`}),(0,H.jsx)(`p`,{className:`font-sans text-xs text-trash-gray font-semibold max-w-md`,children:`Browse your full 150-card curriculum, reschedule intervals, or enroll new topics in the Anki-style Card Manager.`})]}),(0,H.jsxs)(`button`,{onClick:()=>{r?r():s?.(`cardManager`)},className:`px-4 py-2.5 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center gap-1.5`,children:[(0,H.jsx)(v,{className:`w-3.5 h-3.5 text-sky-950`}),(0,H.jsx)(`span`,{children:`OPEN CARD MANAGER`})]})]}),(0,H.jsxs)(`div`,{className:`border-t-[3px] border-dashed border-ink-black pt-5 space-y-3`,children:[(0,H.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold text-left`,children:`CONTINUE PRACTICING:`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2.5`,children:[(0,H.jsxs)(`button`,{onClick:i,className:`p-3 bg-amber-100 hover:bg-amber-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(f,{className:`w-4 h-4 text-amber-600`}),(0,H.jsx)(d,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Journey Trail`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`150 Curated nodes`})]})]}),(0,H.jsxs)(`button`,{onClick:o,className:`p-3 bg-purple-100 hover:bg-purple-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(_,{className:`w-4 h-4 text-purple-700`}),(0,H.jsx)(d,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Add Problem`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`New LeetCode entry`})]})]}),(0,H.jsxs)(`button`,{onClick:()=>s?.(`companion`),className:`p-3 bg-yellow-100 hover:bg-yellow-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`material-symbols-outlined text-amber-600 text-lg`,children:`fireplace`}),(0,H.jsx)(d,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Princess Camp`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Rest with Aurelia`})]})]}),(0,H.jsxs)(`button`,{onClick:()=>{r?r():s?.(`cardManager`)},className:`p-3 bg-cyan-100 hover:bg-cyan-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(a,{className:`w-4 h-4 text-cyan-700`}),(0,H.jsx)(d,{className:`w-3 h-3 text-ink-black`})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Card Manager`}),(0,H.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Anki Deck Browser`})]})]})]})]}),c&&l&&(0,H.jsxs)(`button`,{onClick:l,className:`mt-3 bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold px-4 py-2 text-xs uppercase tracking-wide shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2`,children:[(0,H.jsx)(b,{className:`w-3.5 h-3.5`}),` Return to Scheduled Queue`]})]})}),Ee=e({default:()=>Oe}),De=(0,V.lazy)(()=>ne(()=>import(`./ProblemSpecPanel-clZ38uEk.js`).then(e=>({default:e.ProblemSpecPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function Oe({overrideProblemId:e,onClearOverride:t,onOpenWindow:i,onOpenJourney:a,onOpenCreateProblem:o,onOpenEditProblem:s,onOpenCardManager:c,refreshTrigger:l}){let[u,d]=(0,V.useState)(null),f=u!==null&&u<780,[p,m]=(0,V.useState)(`spec`),[h,g]=(0,V.useState)(`spec`),[_,v]=(0,V.useState)(null),x=(0,V.useCallback)(e=>{e&&(d(e.clientWidth),new ResizeObserver(e=>{for(let t of e)d(t.contentRect.width)}).observe(e))},[]),[S,w]=(0,V.useState)(()=>localStorage.getItem(`isAutocompleteEnabled`)!==`false`),{reviews:E,setReviews:O,loading:k,queueError:A,submitting:j,submittingRating:M,gradeError:N,setGradeError:ee,code:P,setCode:te,nextMilestone:I,activatingMilestone:ne,fetchQueue:ae,handleGrade:L,handleSelectCard:R,handleActivateNextMilestone:z,handleResetStarterCode:B}=pe({overrideProblemId:e,refreshTrigger:l,onClearOverride:t}),{sandboxRunning:oe,sandboxResults:se,sandboxError:ce,savingReference:le,savedRefSuccess:fe,saveRefError:U,handleRunSandbox:_e,handleSaveReference:ve,resetSandbox:W}=me(),{aiLoading:ye,aiResult:be,aiError:xe,explainLoading:G,explanationText:Se,explainError:Ee,aiSolutionLoading:Oe,aiSolutionError:ke,handleAiEvaluation:Ae,handleExplainCode:je,handleFetchAiSolution:Me,resetAiState:K}=he(),[Ne,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)(null),[Le,q]=(0,V.useState)(null),Re=(0,V.useCallback)(async()=>{if(E.length===0)return;let e=E[0]?.problems||{},t=P.trim()||e.reference_code||``;if(!t){q(`Please write or save code before pushing to GitHub.`),setTimeout(()=>q(null),4e3);return}let n=ie();if(!n.token){i&&i(`github`);return}Pe(!0),q(null),Ie(null);try{let r=await re({token:n.token,repo:n.repoName,branch:n.branch,problem_number:e.problem_number,problem_name:e.name||`Algorithm Problem`,pattern:e.pattern||`Algorithms`,difficulty:e.difficulty||`Medium`,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,description:e.description||``,code:t});Ie(r.html_url),setTimeout(()=>Ie(null),8e3)}catch(e){q(e.message||`Failed to push solution to GitHub.`),setTimeout(()=>q(null),5e3)}finally{Pe(!1)}},[E,P,i]),ze=E[0]?.id||E[0]?.problem_id,Be=(0,V.useRef)(void 0);(0,V.useEffect)(()=>{ze&&Be.current!==ze&&(Be.current=ze,K(),W())},[ze,K,W]);let J=(0,V.useCallback)(e=>{K(),W(),L(e)},[L,K,W]),Ve=(0,V.useCallback)(e=>{K(),W(),R(e)},[R,K,W]);(0,V.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.cm-editor`)||t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable||E.length===0||j||(e.key===`1`?(e.preventDefault(),J(1)):e.key===`2`?(e.preventDefault(),J(2)):e.key===`3`?(e.preventDefault(),J(3)):e.key===`4`&&(e.preventDefault(),J(4)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[J,E.length,j]);let He=(e,t)=>{navigator.clipboard.writeText(e),v(t),setTimeout(()=>v(null),1800)},Ue=(0,V.useCallback)(()=>{a?a():i?.(`journey`)},[a,i]),We=(0,V.useCallback)(()=>{o?o():i?.(`createProblem`)},[o,i]),Ge=(0,V.useCallback)(e=>{O(t=>{if(t.length===0)return t;let n=[...t],r=n[0];return r&&r.problems&&(r.problems={...r.problems,solutions:e}),n})},[O]);if(k)return(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] text-ink-black`,children:(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-8 bg-paper-white border-[3px] border-ink-black gadget-shadow text-center max-w-xs`,children:[(0,H.jsx)(`div`,{className:`w-12 h-12 bg-amber-200 border-2 border-ink-black flex items-center justify-center animate-spin`,children:(0,H.jsx)(y,{className:`w-6 h-6 text-ink-black`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-arcade text-xs text-ink-black uppercase tracking-wider font-bold`,children:`LOADING QUEUE`}),(0,H.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray mt-1 font-semibold`,children:`Fetching scheduled FSRS review cards...`})]})]})});if(A&&E.length===0)return(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,H.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-red-500 via-amber-400 to-red-500`}),(0,H.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,H.jsx)(`div`,{className:`w-20 h-20 bg-rose-200 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-2deg]`,children:(0,H.jsx)(C,{className:`w-10 h-10 text-rose-700 stroke-[2.5]`})}),(0,H.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-rose-500 text-white border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`OFFLINE`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 bg-rose-100 border-2 border-ink-black text-rose-800 font-arcade text-[9px] font-bold`,children:[(0,H.jsx)(D,{className:`w-3.5 h-3.5 stroke-[2.5] text-rose-600`}),` CONNECTION ERROR`]}),(0,H.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`Queue Unavailable`}),(0,H.jsx)(`p`,{className:`font-sans text-xs sm:text-sm text-trash-gray font-semibold leading-relaxed max-w-sm mx-auto`,children:`Unable to reach the server to fetch your scheduled review cards. Check your connection or retry below.`})]}),(0,H.jsxs)(`div`,{className:`pt-2 flex flex-col sm:flex-row gap-3 justify-center items-center`,children:[(0,H.jsxs)(`button`,{onClick:()=>void ae(!0),className:`w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:[(0,H.jsx)(b,{className:`w-4 h-4`}),(0,H.jsx)(`span`,{children:`RETRY CONNECTION`})]}),(a||i)&&(0,H.jsx)(`button`,{onClick:Ue,className:`w-full sm:w-auto px-5 py-2.5 bg-paper-white hover:bg-warm-sand-bg border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:(0,H.jsx)(`span`,{children:`OPEN JOURNEY MAP`})})]})]})});if(E.length===0)return(0,H.jsx)(Te,{nextMilestone:I,activatingMilestone:ne,onActivateNextMilestone:z,onOpenCardManager:c||(()=>i?.(`cardManager`)),onOpenJourney:Ue,onOpenCreateProblem:We,onOpenWindow:i,overrideProblemId:e,onClearOverride:t});let Y=E[0],X=Y?.problems,Ke=X?.problem_number??(/^\d+$/.test(Y?.problem_id||``)?parseInt(Y.problem_id,10):void 0),Z=F(Ke,X?.id||Y?.problem_id,X?.name),{cleanTitle:qe,approachVariant:Je,pattern:Ye}=de(X?.name,Z?.name,X?.pattern,Z?.pattern),Q={...Z,...X,id:X?.id||Z?.id||Y?.problem_id,name:qe,problem_number:X?.problem_number??Z?.problem_number,pattern:Ye,approach_variant:Je,difficulty:X?.difficulty||Z?.difficulty||`Medium`,reference_code:X?.reference_code||Z?.reference_solution||``,starter_code:Z?.starter_code||X?.starter_code||``,description:X?.description||Z?.description||``,optimal_time:X?.optimal_time||Z?.time_complexity||`O(N)`,optimal_space:X?.optimal_space||Z?.space_complexity||`O(1)`,examples:X?.examples&&X.examples.length>0?X.examples:Z?.examples,constraints:X?.constraints||Z?.constraints,how_to_solve:X?.how_to_solve||``,solutions:X?.solutions&&X.solutions.length>0?X.solutions:Z?.solutions},Xe=ue({...Z,...Q,examples:Q.examples&&Q.examples.length>0?Q.examples:Z?.examples,constraints:Q.constraints&&(Array.isArray(Q.constraints)?Q.constraints.length>0:Q.constraints)?Q.constraints:Z?.constraints}),Ze=Z?.reference_solution||``,$=X?.reference_code||``,Qe=$&&(!Ze||$.trim()!==Ze.trim())?$:``,$e=Qe||Ze||$||``;return(0,H.jsxs)(`div`,{ref:x,className:`w-full h-full bg-[#fdf8e1] flex flex-col overflow-hidden select-none`,children:[(0,H.jsx)(ge,{problem:Q,totalInQueue:E.length,reviews:E,overrideProblemId:e,onSelectCard:Ve,onOpenCreateProblem:We,onOpenEditProblem:()=>{s?s(Q):i?.(`editProblem`)}}),(0,H.jsxs)(`div`,{className:`${f?`flex`:`hidden`} shrink-0 bg-amber-100 border-b-[3px] border-ink-black px-2.5 sm:px-3 py-1.5 gap-1.5 sm:gap-2 overflow-x-auto no-scrollbar`,children:[(0,H.jsxs)(`button`,{onClick:()=>{g(`spec`),m(`spec`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${h===`spec`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(n,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`SPEC`})]}),(0,H.jsxs)(`button`,{onClick:()=>g(`code`),className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${h===`code`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(T,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`CODE STUDIO`})]}),(0,H.jsxs)(`button`,{onClick:()=>{g(`ref`),m(`ref`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${h===`ref`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,H.jsx)(r,{className:`w-3 h-3 shrink-0`}),(0,H.jsx)(`span`,{children:`SOLUTION`})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 flex ${f?`flex-col`:`flex-row`} overflow-hidden min-h-0`,children:[(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 bg-paper-white ${f?`h-64`:`border-r-[4px] border-ink-black`} font-sans text-xs text-trash-gray select-none`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-arcade text-[10px] text-ink-black`,children:[(0,H.jsx)(y,{className:`w-4 h-4 animate-spin text-[#0ea5e9]`}),(0,H.jsx)(`span`,{children:`Loading Problem Spec...`})]})}),children:(0,H.jsx)(De,{leftTab:p,onSelectLeftTab:e=>{m(e),e===`ref`?g(`ref`):e===`spec`&&g(`spec`)},mobileView:h,isNarrow:f,problem:Q,parsed:Xe,userSolution:Qe,officialSolution:Ze,effectiveReferenceCode:$e,copiedSnippet:_,onCopyText:He,saveRefError:U,aiSolutionLoading:Oe,aiSolutionError:ke,onFetchAiSolution:()=>Me(Y,e=>{O(t=>t.map((t,n)=>n===0?{...t,problems:{...Q||{},...t.problems||{},reference_code:e}}:t))}),explainLoading:G,explainError:Ee,explanationText:Se,onExplainCode:(e,t,n,r)=>je(Y,e,t,n,r),activeReview:Y,onUpdateSolutions:Ge,onEditProblem:()=>{s?s(Q):i?.(`editProblem`)}})}),(0,H.jsx)(Ce,{mobileView:h,isNarrow:f,isAutocompleteEnabled:S,onToggleAutocomplete:e=>{w(e),localStorage.setItem(`isAutocompleteEnabled`,String(e))},onResetStarterCode:B,code:P,onChangeCode:te,sandboxRunning:oe,sandboxError:ce,sandboxResults:se,onRunSandbox:()=>_e(Y,P),savingReference:le,savedRefSuccess:fe,saveRefError:U,onSaveReference:()=>ve(Y,P,(e,t)=>{O(n=>n.map((n,r)=>r===0?{...n,problem_id:t||n.problem_id,problems:{...Q||{},...n.problems||{},id:t||n.problems?.id||n.problem_id,reference_code:e}}:n))}),aiLoading:ye,aiError:xe,aiResult:be,onAiEvaluation:()=>Ae(Y,P),optimalTime:Q.optimal_time||`O(N)`,optimalSpace:Q.optimal_space||`O(1)`,onPushToGitHub:Re,pushingToGitHub:Ne,githubPushedUrl:Fe,githubPushError:Le})]}),(0,H.jsx)(we,{gradeError:N,onDismissGradeError:()=>ee(null),submitting:j,submittingRating:M,onGrade:J})]})}export{Oe as default,fe as n,Ee as t};
 
 
 
 
 
 
algospaced-ui/dist/assets/{Settings-HgPu-LnK.js → Settings-Brys5us-.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{D as t,J as n,K as r,Q as i,S as a,Vt as o,b as s,et as c,ht as l,i as u,j as d,k as f,nt as p,ot as m,pt as h,rt as g,tt as _,u as v,zt as y}from"./vendor-react-CDF1pnIM.js";import{C as b,S as x,b as S,v as C,x as w,y as ee}from"./index-DX2cztXb.js";import{a as te,i as ne,n as re,r as T,s as E,t as D}from"./githubSyncService-x0Mm_uEl.js";var O=e(o(),1),k=y(),A=[{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 j(){let[e,o]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[y,j]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[I,L]=(0,O.useState)(()=>ee()),[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(()=>S().currentFloor),[H,U]=(0,O.useState)(()=>T()),[W,G]=(0,O.useState)(()=>ne()),[K,q]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(y.trim()&&e!=="default"),Q=e!=="default"&&!y.trim(),$=A.find(t=>t.id===e),ie=e=>{o(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=y.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`),j(``),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`),j(``),o(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{x(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(b),x(b),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 journey progress back to 0 leagues?`)){let e=w();V(e.currentFloor),z({type:`info`,text:`Journey progress reset to 0 leagues.`}),setTimeout(()=>z(null),3e3)}},de=async()=>{q(!0),Y(null);try{let{token:e,user:t}=await re();G(t);let n=T();U(n);try{await te(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(T()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{E({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,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,k.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,k.jsx)(r,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Z?(0,k.jsx)(u,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,k.jsx)(l,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,k.jsx)(g,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,k.jsxs)(`span`,{children:[`Active:`,` `,Z?`${e.toUpperCase()} (Custom Key)`:Q?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,k.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,k.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,k.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,k.jsxs)(`div`,{children:[(0,k.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,k.jsx)(g,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:A.map(t=>{let n=e===t.id;return(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,k.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,k.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,k.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,k.jsx)(v,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,k.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,k.jsx)(`i`,{children:`limited`}),`)`]}),(0,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.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,k.jsx)(r,{className:`w-3.5 h-3.5 text-ink-black`}),$?.name,` API Key`]}),$?.portalUrl&&(0,k.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,k.jsx)(`span`,{children:`Get API Key`}),(0,k.jsx)(p,{className:`w-3 h-3`})]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:M?`text`:`password`,value:y,onChange:e=>j(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,k.jsx)(`button`,{type:`button`,onClick:()=>N(!M),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:M?`Hide API key`:`Show API key`,children:M?(0,k.jsx)(_,{className:`w-3.5 h-3.5`}):(0,k.jsx)(c,{className:`w-3.5 h-3.5`})})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,k.jsx)(a,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,k.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,k.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,k.jsx)(t,{className:`w-3.5 h-3.5`}),`Save Key`]}),y&&(0,k.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,k.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,k.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,k.jsx)(l,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(n,{className:`w-3.5 h-3.5 shrink-0`}),P.text]}),e!=="default"&&(0,k.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,k.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,k.jsx)(f,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,k.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,k.jsx)(i,{className:`w-4 h-4 text-white`})}),(0,k.jsxs)(`div`,{children:[(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[W?.avatar_url&&(0,k.jsx)(`img`,{src:W.avatar_url,alt:W.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,W?.login||H.username]}),(0,k.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[H.username,`/`,H.repoName,` (`,H.branch,`)`]})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(p,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:`View Repo`})]}),(0,k.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,k.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,k.jsx)(`input`,{type:`checkbox`,checked:H.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,k.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,H.repoName,` whenever you grade a review card.`]})]})]})]}):(0,k.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,k.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,k.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,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(d,{className:`w-3.5 h-3.5 animate-spin`}),(0,k.jsx)(`span`,{children:`CONNECTING...`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,k.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),J&&(0,k.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,k.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,k.jsx)(l,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(n,{className:`w-3.5 h-3.5 shrink-0`}),J.text]})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(s,{className:`w-4 h-4 text-ink-black`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & Journey Settings`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Princess Persona, Journey Break Reminders & 8-bit RPG Audio`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:I.enabled?`Enabled`:`Disabled`}),(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,k.jsx)(m,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,k.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,k.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,k.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,k.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,k.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,k.jsx)(`textarea`,{rows:2,value:I.backstory,onChange:e=>L(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, traveling companions, and quest for the Elixir of Life...`,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,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Audio chimes & fanfare`})]})]}),(0,k.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,k.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,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(t,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,k.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,k.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,k.jsx)(f,{className:`w-3 h-3 text-rose-500`}),(0,k.jsxs)(`span`,{children:[`Reset Journey (`,B,`/150 Leagues)`]})]})]}),R&&(0,k.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,k.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}),R.text]})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(n,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Groq Cloud`}),(0,k.jsx)(p,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Google AI Studio`}),(0,k.jsx)(p,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`OpenRouter`}),(0,k.jsx)(p,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{j as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Dt as n,E as r,F as i,N as a,Q as o,Qt as s,Tt as c,Xt as l,a as u,dt as d,et as f,f as p,ft as m,j as h,mt as g,ot as _,ut as v,vt as ee}from"./vendor-react-oIjZMgNV.js";import{D as y,E as te,O as b,T as x,b as ne,w as S}from"./index-B53AvSbH.js";import{a as re,i as C,n as w,r as T,s as E,t as D}from"./githubSyncService-x0Mm_uEl.js";var O=e(s(),1),k=l(),A=[{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 j(){let[e,s]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[l,j]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[I,L]=(0,O.useState)(()=>S()),[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(()=>x().currentFloor),[H,U]=(0,O.useState)(()=>T()),[W,G]=(0,O.useState)(()=>C()),[K,q]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(l.trim()&&e!=="default"),Q=e!=="default"&&!l.trim(),$=A.find(t=>t.id===e),ie=e=>{s(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=l.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`),j(``),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`),j(``),s(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{y(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(b),y(b),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 journey progress back to 0 leagues?`)){let e=te();V(e.currentFloor),z({type:`info`,text:`Journey progress reset to 0 leagues.`}),setTimeout(()=>z(null),3e3)}},de=async()=>{q(!0),Y(null);try{let{token:e,user:t}=await w();G(t);let n=T();U(n);try{await re(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(T()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{E({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,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,k.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,k.jsx)(o,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Z?(0,k.jsx)(u,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,k.jsx)(n,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,k.jsx)(g,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,k.jsxs)(`span`,{children:[`Active:`,` `,Z?`${e.toUpperCase()} (Custom Key)`:Q?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,k.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,k.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,k.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,k.jsxs)(`div`,{children:[(0,k.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,k.jsx)(g,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:A.map(t=>{let n=e===t.id;return(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,k.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,k.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,k.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,k.jsx)(p,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,k.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,k.jsx)(`i`,{children:`limited`}),`)`]}),(0,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.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,k.jsx)(o,{className:`w-3.5 h-3.5 text-ink-black`}),$?.name,` API Key`]}),$?.portalUrl&&(0,k.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,k.jsx)(`span`,{children:`Get API Key`}),(0,k.jsx)(m,{className:`w-3 h-3`})]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:M?`text`:`password`,value:l,onChange:e=>j(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,k.jsx)(`button`,{type:`button`,onClick:()=>N(!M),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:M?`Hide API key`:`Show API key`,children:M?(0,k.jsx)(d,{className:`w-3.5 h-3.5`}):(0,k.jsx)(v,{className:`w-3.5 h-3.5`})})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,k.jsx)(r,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,k.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,k.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,k.jsx)(h,{className:`w-3.5 h-3.5`}),`Save Key`]}),l&&(0,k.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,k.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,k.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,k.jsx)(n,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),P.text]}),e!=="default"&&(0,k.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,k.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,k.jsx)(a,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,k.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,k.jsx)(_,{className:`w-4 h-4 text-white`})}),(0,k.jsxs)(`div`,{children:[(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[W?.avatar_url&&(0,k.jsx)(`img`,{src:W.avatar_url,alt:W.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,W?.login||H.username]}),(0,k.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[H.username,`/`,H.repoName,` (`,H.branch,`)`]})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(m,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:`View Repo`})]}),(0,k.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,k.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,k.jsx)(`input`,{type:`checkbox`,checked:H.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,k.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,H.repoName,` whenever you grade a review card.`]})]})]})]}):(0,k.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,k.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,k.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,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`}),(0,k.jsx)(`span`,{children:`CONNECTING...`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(_,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,k.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),J&&(0,k.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,k.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,k.jsx)(n,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),J.text]})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(t,{className:`w-4 h-4 text-ink-black`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & Journey Settings`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Princess Persona, Journey Break Reminders & 8-bit RPG Audio`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:I.enabled?`Enabled`:`Disabled`}),(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,k.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,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,k.jsx)(ee,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,k.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,k.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,k.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,k.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,k.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,k.jsx)(`textarea`,{rows:2,value:I.backstory,onChange:e=>L(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, traveling companions, and quest for the Elixir of Life...`,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,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,k.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,k.jsx)(`input`,{type:`checkbox`,checked:I.soundEnabled,onChange:e=>{let t=e.target.checked;L(e=>({...e,soundEnabled:t})),ne(!t)},className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Audio chimes & fanfare`})]})]}),(0,k.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,k.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,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.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,k.jsx)(h,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,k.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,k.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,k.jsx)(a,{className:`w-3 h-3 text-rose-500`}),(0,k.jsxs)(`span`,{children:[`Reset Journey (`,B,`/150 Leagues)`]})]})]}),R&&(0,k.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,k.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}),R.text]})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(f,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Groq Cloud`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Google AI Studio`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`OpenRouter`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{j as default};
algospaced-ui/dist/assets/StoreWindow-CdHQWIUq.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,C as n,D as r,Dt as i,Mt as a,Nt as o,Qt as s,T as c,Tt as l,V as u,Xt as d,_t as f,ct as p,mt as m,nt as h,o as g,pt as _,st as v,tt as y,u as b,ut as x,v as S,z as C}from"./vendor-react-oIjZMgNV.js";import{C as w,S as T,f as E,m as D,v as O,x as k,y as A}from"./index-B53AvSbH.js";import{t as j}from"./confetti.module-Uxh4CK4s.js";var M=e(s(),1),N=d(),P=({name:e,className:i=`w-6 h-6`})=>{switch(e){case`ShieldAlert`:return(0,N.jsx)(r,{className:i});case`Scroll`:return(0,N.jsx)(t,{className:i});case`Sparkles`:return(0,N.jsx)(n,{className:i});case`Flame`:return(0,N.jsx)(p,{className:i});case`Tv`:return(0,N.jsx)(b,{className:i});case`Cpu`:return(0,N.jsx)(m,{className:i});case`Image`:return(0,N.jsx)(y,{className:i});case`Flower2`:return(0,N.jsx)(v,{className:i});case`Heart`:return(0,N.jsx)(h,{className:i});case`Music`:return(0,N.jsx)(u,{className:i});case`Crown`:return(0,N.jsx)(_,{className:i});case`Coins`:return(0,N.jsx)(f,{className:i});default:return(0,N.jsx)(C,{className:i})}},F=({item:e,playerGold:t,isPurchasing:n,onPurchase:r,onInspect:i})=>{let a=t>=e.price,o=e.category===`consumable`?`bg-emerald-100 text-emerald-800 border-emerald-700`:e.category===`cosmetic`?`bg-purple-100 text-purple-800 border-purple-700`:`bg-amber-100 text-amber-900 border-amber-700`,s=e.category===`consumable`?`Consumable`:e.category===`cosmetic`?`Cosmetic`:`Companion Gift`;return(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-lg p-4 shadow-[4px_4px_0px_0px_#1E293B] flex flex-col justify-between hover:translate-x-[-1px] hover:translate-y-[-1px] hover:shadow-[5px_5px_0px_0px_#1E293B] transition-all`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-3`,children:[(0,N.jsx)(`span`,{className:`font-arcade text-[8px] px-2 py-0.5 border rounded uppercase font-bold tracking-wider ${o}`,children:s}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`p-1 hover:bg-amber-100 text-slate-600 hover:text-ink-black rounded transition-colors cursor-pointer`,title:`Inspect lore and mechanics`,children:(0,N.jsx)(x,{className:`w-3.5 h-3.5`})})]}),(0,N.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,N.jsx)(`div`,{className:`w-12 h-12 bg-white border-[2px] border-ink-black rounded flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,N.jsx)(P,{name:e.icon,className:`w-6 h-6 text-amber-700`})}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h4`,{onClick:()=>i(e),className:`font-headline-md font-bold text-sm text-ink-black leading-snug cursor-pointer hover:text-amber-800 truncate`,title:e.name,children:e.name}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5 text-amber-800 font-arcade text-xs font-bold`,children:[(0,N.jsx)(f,{className:`w-3.5 h-3.5 text-amber-500 fill-amber-500`}),(0,N.jsxs)(`span`,{children:[e.price,`g`]})]})]})]}),(0,N.jsxs)(`p`,{className:`font-serif italic text-xs text-slate-600 line-clamp-2 mb-4 leading-relaxed`,children:[`“`,e.lore,`”`]})]}),(0,N.jsx)(`div`,{className:`pt-2 border-t border-ink-black/10 flex items-center justify-between gap-2`,children:(0,N.jsx)(`button`,{type:`button`,disabled:!a||n,onClick:()=>r(e),className:`w-full font-arcade text-[10px] py-2 px-3 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all uppercase tracking-wider font-bold ${a?`bg-amber-400 hover:bg-amber-300 text-ink-black cursor-pointer`:`bg-slate-200 text-slate-400 border-slate-400 shadow-none cursor-not-allowed`}`,title:a?`Buy for ${e.price}g`:`Need ${e.price-t} more gold to buy`,children:n?`Purchasing...`:a?`Purchase`:`Insufficient Gold`})})]})},I=({inventoryItem:e,catalogItem:t,isLoading:i,onConsume:o,onEquip:s,onPresentGift:c,onInspect:l})=>{let u=!!e.is_equipped,d=t.category===`consumable`?`bg-emerald-100 text-emerald-800 border-emerald-700`:t.category===`cosmetic`?`bg-purple-100 text-purple-800 border-purple-700`:`bg-amber-100 text-amber-900 border-amber-700`,f=t.category===`consumable`?`Consumable`:t.category===`cosmetic`?`Cosmetic`:`Companion Gift`;return(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] rounded-lg p-4 shadow-[4px_4px_0px_0px_#1E293B] flex flex-col justify-between transition-all ${u?`border-purple-600 bg-purple-50/40 ring-2 ring-purple-500/40`:`border-ink-black`}`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`font-arcade text-[8px] px-2 py-0.5 border rounded uppercase font-bold tracking-wider ${d}`,children:f}),u&&(0,N.jsxs)(`span`,{className:`font-arcade text-[8px] bg-purple-600 text-white px-1.5 py-0.5 rounded border border-purple-800 font-bold uppercase tracking-wider flex items-center gap-0.5`,children:[(0,N.jsx)(a,{className:`w-2.5 h-2.5`}),`Equipped`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.quantity>1&&(0,N.jsxs)(`span`,{className:`font-arcade text-[9px] bg-ink-black text-amber-300 px-2 py-0.5 rounded border border-amber-400 font-extrabold shadow-[1px_1px_0_0_#1E293B]`,children:[`x`,e.quantity]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(t,e),className:`p-1 hover:bg-amber-100 text-slate-600 hover:text-ink-black rounded transition-colors cursor-pointer`,title:`Inspect item lore`,children:(0,N.jsx)(x,{className:`w-3.5 h-3.5`})})]})]}),(0,N.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,N.jsx)(`div`,{className:`w-12 h-12 bg-white border-[2px] border-ink-black rounded flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,N.jsx)(P,{name:t.icon,className:`w-6 h-6 text-amber-700`})}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h4`,{onClick:()=>l(t,e),className:`font-headline-md font-bold text-sm text-ink-black leading-snug cursor-pointer hover:text-amber-800 truncate`,title:t.name,children:t.name}),(0,N.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono`,children:[`Count: `,e.quantity]})]})]}),(0,N.jsxs)(`p`,{className:`font-serif italic text-xs text-slate-600 line-clamp-2 mb-4 leading-relaxed`,children:[`“`,t.lore,`”`]})]}),(0,N.jsxs)(`div`,{className:`pt-2 border-t border-ink-black/10 flex items-center gap-2`,children:[t.category===`consumable`&&(0,N.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(t),className:`w-full font-arcade text-[10px] py-2 px-3 bg-grass-green hover:bg-emerald-400 text-ink-black border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5`,children:[(0,N.jsx)(r,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{children:i?`Consuming...`:`Consume`})]}),t.category===`cosmetic`&&(0,N.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>s(t,!u),className:`w-full font-arcade text-[10px] py-2 px-3 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5 ${u?`bg-slate-700 hover:bg-slate-800 text-white`:`bg-purple-500 hover:bg-purple-600 text-white`}`,children:[(0,N.jsx)(n,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{children:i?`Updating...`:u?`Unequip`:`Equip`})]}),t.category===`companion_gift`&&(0,N.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>c(t),className:`w-full font-arcade text-[10px] py-2 px-3 bg-rose-500 hover:bg-rose-600 text-white border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5`,children:[(0,N.jsx)(h,{className:`w-3 h-3 fill-white`}),(0,N.jsx)(`span`,{children:i?`Presenting...`:`Present Gift`})]})]})]})},L=({item:e,ownedQuantity:t=0,playerGold:r,isEquipped:i=!1,onClose:a,onPurchase:o,onAction:s,actionLabel:c,isActionLoading:l=!1})=>{let u=r>=e.price,d=e.category===`consumable`?`bg-emerald-100 text-emerald-800 border-emerald-800`:e.category===`cosmetic`?`bg-purple-100 text-purple-800 border-purple-800`:`bg-amber-100 text-amber-900 border-amber-800`,p=e.category===`consumable`?`Study Consumable`:e.category===`cosmetic`?`Desktop Cosmetic`:`Companion Gift`;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 bg-ink-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-150 select-none`,onClick:a,children:(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-lg max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(n,{className:`w-4 h-4 text-amber-600`}),(0,N.jsx)(`span`,{className:`font-arcade text-xs text-ink-black font-bold uppercase tracking-wider`,children:`Item Artifact Lore`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:a,className:`p-1 hover:bg-slate-200 rounded text-ink-black cursor-pointer transition-colors`,title:`Close`,children:(0,N.jsx)(g,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`p-5 flex flex-col gap-4 overflow-y-auto max-h-[70vh] custom-scrollbar`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4 bg-amber-50/80 p-3 rounded-lg border-2 border-amber-200/80`,children:[(0,N.jsx)(`div`,{className:`w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,N.jsx)(P,{name:e.icon,className:`w-8 h-8 text-amber-700`})}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1 overflow-hidden`,children:[(0,N.jsx)(`span`,{className:`font-arcade text-[9px] px-2 py-0.5 border w-fit rounded uppercase tracking-wider ${d}`,children:p}),(0,N.jsx)(`h3`,{className:`font-headline-md font-bold text-lg text-ink-black leading-tight`,children:e.name}),t>0&&(0,N.jsxs)(`span`,{className:`text-xs font-arcade text-slate-700 font-bold`,children:[`In Satchel: x`,t,i&&` (EQUIPPED)`]})]})]}),(0,N.jsxs)(`div`,{className:`bg-amber-100/40 p-3.5 border-l-4 border-amber-600 rounded-r`,children:[(0,N.jsx)(`h4`,{className:`font-arcade text-[9px] text-amber-900 uppercase tracking-wider mb-1 font-bold`,children:`Lore Inscription`}),(0,N.jsxs)(`p`,{className:`font-serif italic text-sm text-slate-800 leading-relaxed`,children:[`“`,e.lore,`”`]})]}),(0,N.jsxs)(`div`,{className:`bg-white p-3 border-2 border-ink-black/20 rounded`,children:[(0,N.jsx)(`h4`,{className:`font-arcade text-[9px] text-slate-600 uppercase tracking-wider mb-1.5 font-bold`,children:`System Effect & Mechanics`}),(0,N.jsxs)(`div`,{className:`text-xs font-sans text-slate-700 space-y-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`font-semibold text-ink-black`,children:`Effect Classification:`}),(0,N.jsx)(`span`,{className:`font-mono text-[11px] bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:e.effect_type})]}),(0,N.jsxs)(`div`,{className:`text-slate-600 mt-1`,children:[e.effect_type===`streak_freeze`&&(0,N.jsx)(`span`,{children:`Grants protection against broken daily streaks if a study day is missed.`}),e.effect_type===`hint_scroll`&&(0,N.jsx)(`span`,{children:`Unravels algorithmic intuition and optimal patterns for difficult challenges.`}),e.effect_type===`focus_boost`&&(0,N.jsx)(`span`,{children:`Enhances cognitive composure and grants bonus rewards on study reviews.`}),e.effect_type===`crt_theme`&&(0,N.jsx)(`span`,{children:`Overlays an authentic retro CRT scanline shader with phosphor bloom.`}),e.effect_type===`palette_theme`&&(0,N.jsx)(`span`,{children:`Transforms window styling and color palette to a distinct fantasy theme.`}),e.effect_type===`wallpaper`&&(0,N.jsx)(`span`,{children:`Applies celestial Spire landscape art as desktop background wallpaper.`}),e.effect_type===`aurelia_gift`&&(0,N.jsx)(`span`,{children:`Present to Princess Aurelia to deepen your bond, unlock intimate lore, and heal her spirit.`})]})]})]}),(0,N.jsxs)(`div`,{className:`mt-2 pt-3 border-t-2 border-ink-black/10 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-sm font-bold text-amber-800`,children:[(0,N.jsx)(f,{className:`w-4 h-4 text-amber-500 fill-amber-500`}),(0,N.jsxs)(`span`,{children:[e.price,`g`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&(0,N.jsx)(`button`,{type:`button`,disabled:!u||l,onClick:()=>o(e),className:`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all ${u?`bg-amber-400 hover:bg-amber-300 text-ink-black cursor-pointer font-bold`:`bg-slate-200 text-slate-400 border-slate-400 shadow-none cursor-not-allowed`}`,title:u?`Purchase Item`:`Need ${e.price-r} more gold`,children:l?`Purchasing...`:u?`Purchase (${e.price}g)`:`Insufficient Gold`}),s&&c&&(0,N.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>s(e),className:`font-arcade text-xs px-3.5 py-2 bg-grass-green hover:bg-emerald-400 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold transition-all`,children:l?`Processing...`:c})]})]})]})]})})},R=({giftItem:e,reaction:t,onClose:r,onOpenCompanion:i})=>{let a=D(),s=a.bondTier,c=a.bondPoints;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 bg-ink-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-200 select-none`,onClick:r,children:(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[4px] border-ink-black rounded-xl max-w-lg w-full shadow-[8px_8px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`bg-gradient-to-r from-amber-400 via-rose-300 to-amber-300 border-b-[3px] border-ink-black px-4 py-2.5 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(h,{className:`w-5 h-5 text-rose-600 fill-rose-600 animate-pulse`}),(0,N.jsx)(`span`,{className:`font-arcade text-xs text-ink-black font-extrabold uppercase tracking-wide`,children:t.title})]}),(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`p-1 hover:bg-white/50 rounded text-ink-black cursor-pointer transition-colors`,title:`Close`,children:(0,N.jsx)(g,{className:`w-4 h-4`})})]}),(0,N.jsxs)(`div`,{className:`p-5 flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4 bg-amber-100/60 p-3.5 rounded-lg border-2 border-amber-300`,children:[(0,N.jsx)(`div`,{className:`w-20 h-20 border-[3px] border-ink-black rounded overflow-hidden bg-amber-50 shadow-[3px_3px_0px_0px_#1E293B] shrink-0`,children:(0,N.jsx)(`img`,{src:`/sprites/princess/${t.emotion}.webp`,alt:`Princess Aurelia`,className:`w-full h-full object-cover object-top`})}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-arcade font-bold text-rose-700 flex-wrap`,children:[(0,N.jsx)(n,{className:`w-3.5 h-3.5 text-rose-600 fill-rose-600`}),(0,N.jsxs)(`span`,{children:[`+`,t.bondBonus,` Companion Bond`]}),(0,N.jsx)(`span`,{className:`text-slate-400 font-normal`,children:`|`}),(0,N.jsxs)(`span`,{className:`bg-rose-100 text-rose-800 px-2 py-0.5 rounded border border-rose-300 text-[10px] uppercase tracking-wide`,children:[`Tier: `,s,` (`,c,` pts)`]})]}),(0,N.jsx)(`h3`,{className:`font-headline-md font-bold text-lg text-ink-black`,children:`Princess Aurelia`}),(0,N.jsxs)(`p`,{className:`text-xs text-slate-600 font-sans`,children:[`Received with gratitude: `,(0,N.jsx)(`strong`,{className:`text-ink-black`,children:e.name})]})]})]}),(0,N.jsxs)(`div`,{className:`bg-white p-4 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_rgba(0,0,0,0.1)]`,children:[(0,N.jsx)(`h4`,{className:`font-arcade text-[9px] text-amber-800 uppercase tracking-wider mb-2 font-bold flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{children:`Aurelia Speaks`})}),(0,N.jsx)(`p`,{className:`font-serif italic text-sm text-ink-black leading-relaxed`,children:t.dialogue})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`font-arcade text-xs px-4 py-2 bg-paper-white hover:bg-slate-200 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold`,children:`Continue`}),i&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{r(),i()},className:`font-arcade text-xs px-4 py-2 bg-[#f59e0b] hover:bg-amber-400 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold flex items-center gap-1.5`,children:[(0,N.jsx)(o,{className:`w-3.5 h-3.5`}),(0,N.jsx)(`span`,{children:`Visit Aurelia`})]})]})]})]})})},z={emotion:`smiling_warmly`,title:`Gift Presented`,bondBonus:10,dialogue:`Aurelia receives your token of companionship with shining eyes and genuine gratitude.`},B={gift_starflower_tea:{emotion:`smiling_warmly`,title:`Starflower Tea Presented`,bondBonus:15,dialogue:`Aurelia cradles the warm steaming cup in both hands, breathing in the herbal aroma... 'Thank you, my friend. The starflower warmth eases the tightness in my chest and banishes the mountain chill.'`},gift_silk_shawl:{emotion:`smiling_warmly`,title:`Silver Shawl Presented`,bondBonus:30,dialogue:`Aurelia softly drapes the delicate silver-stitched shawl around her shoulders... 'It is so gentle and warm. Wrapped in this, I feel shielded and safe on the trail.'`},gift_music_box:{emotion:`excited_expression`,title:`Celestial Music Box Bestowed`,bondBonus:60,dialogue:`Aurelia winds the small brass key with glistening eyes as the delicate chimes ring out... 'This melody... my mother used to hum this in the royal rose gardens. You have returned a piece of my home to me.'`},gift_elixir_pendant:{emotion:`excited_expression`,title:`Soulbound Pendant Entrusted`,bondBonus:100,dialogue:`Aurelia gazes at the glowing Elixir pendant in disbelief, tears shining in her eyes... 'The Elixir... you would entrust such a holy treasure to me? Our fates are bound together now, my champion. Until the Spire's peak!'`}},V=({onClose:e,onOpenCompanion:t})=>{let r=k(e=>Math.max(0,e.gold??0)),a=k(e=>Math.max(0,e.lifetimeEarned??0)),o=k(e=>e.inventory??[]),s=k(e=>e.purchaseItem),u=k(e=>e.consumeItem),d=k(e=>e.equipItem),[p,m]=(0,M.useState)(`storefront`),[h,_]=(0,M.useState)(`all`),[v,y]=(0,M.useState)(`all`),[b,x]=(0,M.useState)(null),[D,P]=(0,M.useState)(null),[V,H]=(0,M.useState)(null),[U,W]=(0,M.useState)([]),G=(0,M.useCallback)((e,t=`info`)=>{let n=`toast_${Date.now()}_${Math.random().toString(36).substring(2,6)}`;W(r=>[...r.slice(-2),{id:n,message:e,type:t}]),setTimeout(()=>{W(e=>e.filter(e=>e.id!==n))},4e3)},[]),K=(0,M.useCallback)(e=>{W(t=>t.filter(t=>t.id!==e))},[]),ee=(0,M.useMemo)(()=>h===`all`?T:T.filter(e=>e.category===h),[h]),q=(0,M.useMemo)(()=>o.map(e=>({invItem:e,catalog:w[e.item_id]})).filter(e=>!!e.catalog),[o]),J=(0,M.useMemo)(()=>v===`all`?q:q.filter(e=>e.catalog.category===v),[q,v]),Y=(0,M.useMemo)(()=>o.reduce((e,t)=>e+(t.quantity||0),0),[o]),X=(0,M.useCallback)(async e=>{if(r<e.price){G(`Insufficient Gold. You need ${e.price-r} more gold to acquire this item.`,`error`);return}x(e.id);try{await s(e.id,1),A();try{j({particleCount:45,spread:60,origin:{y:.65}})}catch{}G(`Acquired ${e.name}! Added to Adventurer's Vault.`,`success`),D?.item.id===e.id&&P(null)}catch(e){let t=e instanceof Error?e.message:`Purchase failed. Your gold balance remains intact.`;G(t,`error`)}finally{x(null)}},[r,s,G,D]),Z=(0,M.useCallback)(async e=>{x(e.id);try{let t=await u(e.id);A(),G(`Consumed ${e.name}! Effect active. (Remaining: x${t.remaining_quantity})`,`success`),D?.item.id===e.id&&P(null)}catch(t){let n=t instanceof Error?t.message:`Failed to consume ${e.name}.`;G(n,`error`)}finally{x(null)}},[u,G,D]),Q=(0,M.useCallback)(async(e,t)=>{x(e.id);try{await d(e.id,t),A(),G(t?`Equipped ${e.name}!`:`Unequipped ${e.name}.`,`success`),D?.item.id===e.id&&P(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update cosmetic state.`;G(t,`error`)}finally{x(null)}},[d,G,D]),$=(0,M.useCallback)(async e=>{x(e.id);try{await u(e.id);let t=B[e.id]||z;E.presentGift({id:e.id,name:e.name,price:e.price,effect_payload:e.effect_payload}),O();try{j({particleCount:60,spread:70,origin:{y:.6}})}catch{}H({item:e,reaction:t}),D?.item.id===e.id&&P(null)}catch(t){let n=t instanceof Error?t.message:`Failed to present ${e.name} to Aurelia.`;G(n,`error`)}finally{x(null)}},[u,G,D]);return(0,N.jsxs)(`div`,{className:`w-full h-full bg-[#fbf7ee] flex flex-col overflow-hidden text-ink-black select-none`,children:[(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-b-[3px] border-ink-black px-4 py-3 shrink-0 flex flex-wrap items-center justify-between gap-3 shadow-[0_2px_4px_rgba(0,0,0,0.05)]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>m(`storefront`),className:`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-2 cursor-pointer uppercase font-bold ${p===`storefront`?`bg-amber-400 text-ink-black ring-2 ring-amber-500/50`:`bg-paper-white text-slate-700 hover:bg-amber-100/60`}`,children:[(0,N.jsx)(S,{className:`w-4 h-4 text-amber-800`}),(0,N.jsx)(`span`,{children:`Store`})]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>m(`vault`),className:`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-2 cursor-pointer uppercase font-bold ${p===`vault`?`bg-amber-400 text-ink-black ring-2 ring-amber-500/50`:`bg-paper-white text-slate-700 hover:bg-amber-100/60`}`,children:[(0,N.jsx)(C,{className:`w-4 h-4 text-amber-800`}),(0,N.jsx)(`span`,{children:`Adventurer's Vault`}),Y>0&&(0,N.jsx)(`span`,{className:`font-arcade text-[9px] bg-ink-black text-amber-300 px-1.5 py-0.5 rounded font-extrabold ml-0.5`,children:Y})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 bg-amber-100/70 border-[2px] border-ink-black px-3.5 py-1.5 rounded shadow-[2px_2px_0px_0px_#1E293B]`,title:`Gold: ${r} (Lifetime: ${a})`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-xs font-bold text-amber-900`,children:[(0,N.jsx)(f,{className:`w-4 h-4 text-amber-500 fill-amber-500`}),(0,N.jsxs)(`span`,{children:[r,`g`]})]}),(0,N.jsx)(`div`,{className:`h-3 w-[1px] bg-amber-300`}),(0,N.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-800 uppercase font-semibold`,children:[`Lifetime: `,a,`g`]})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-4 md:p-6 flex flex-col gap-5`,children:[p===`storefront`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap pb-1 border-b border-ink-black/10`,children:[(0,N.jsx)(`span`,{className:`font-arcade text-[9px] text-slate-600 uppercase font-bold mr-1`,children:`Filter:`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(`all`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${h===`all`?`bg-ink-black text-amber-300 shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-slate-700 hover:bg-amber-100/50`}`,children:`All Goods (12)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(`consumable`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${h===`consumable`?`bg-emerald-700 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-emerald-800 hover:bg-emerald-50`}`,children:`Consumables (4)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(`cosmetic`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${h===`cosmetic`?`bg-purple-700 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-purple-800 hover:bg-purple-50`}`,children:`Cosmetics (4)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(`companion_gift`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${h===`companion_gift`?`bg-amber-600 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-amber-900 hover:bg-amber-50`}`,children:`Gifts for Aurelia (4)`})]}),(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:ee.map(e=>(0,N.jsx)(F,{item:e,playerGold:r,isPurchasing:b===e.id,onPurchase:X,onInspect:e=>P({item:e})},e.id))})]}),p===`vault`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap pb-1 border-b border-ink-black/10`,children:[(0,N.jsx)(`span`,{className:`font-arcade text-[9px] text-slate-600 uppercase font-bold mr-1`,children:`Filter:`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y(`all`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${v===`all`?`bg-ink-black text-amber-300 shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-slate-700 hover:bg-amber-100/50`}`,children:`All Satchel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y(`consumable`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${v===`consumable`?`bg-emerald-700 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-emerald-800 hover:bg-emerald-50`}`,children:`Consumables`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y(`cosmetic`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${v===`cosmetic`?`bg-purple-700 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-purple-800 hover:bg-purple-50`}`,children:`Cosmetics`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y(`companion_gift`),className:`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${v===`companion_gift`?`bg-amber-600 text-white shadow-[2px_2px_0px_0px_#1E293B]`:`bg-white text-amber-900 hover:bg-amber-50`}`,children:`Gifts`})]}),J.length===0?(0,N.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-dashed border-ink-black/40 rounded-xl p-8 flex flex-col items-center justify-center text-center gap-3 my-6`,children:[(0,N.jsx)(`div`,{className:`w-16 h-16 bg-amber-100/80 border-[2px] border-ink-black rounded-full flex items-center justify-center text-amber-800 mb-1`,children:(0,N.jsx)(c,{className:`w-8 h-8`})}),(0,N.jsx)(`h4`,{className:`font-headline-md font-bold text-lg text-ink-black`,children:`Your satchel is empty. Visit the store to acquire items!`}),(0,N.jsx)(`p`,{className:`font-serif italic text-sm text-slate-600 max-w-sm`,children:`Complete daily reviews and coding challenges to earn gold coins, then browse the store.`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>m(`storefront`),className:`mt-2 font-arcade text-xs px-4 py-2.5 bg-amber-400 hover:bg-amber-300 text-ink-black border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider`,children:`Browse Emporium`})]}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:J.map(({invItem:e,catalog:t})=>(0,N.jsx)(I,{inventoryItem:e,catalogItem:t,isLoading:b===t.id,onConsume:Z,onEquip:Q,onPresentGift:$,onInspect:(e,t)=>P({item:e,inventoryItem:t})},e.item_id))})]})]}),U.length>0&&(0,N.jsx)(`div`,{className:`absolute bottom-4 right-4 z-40 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:U.map(e=>(0,N.jsxs)(`div`,{className:`pointer-events-auto p-3 border-[2px] border-ink-black rounded shadow-[3px_3px_0px_0px_#1E293B] flex items-start justify-between gap-2 text-xs font-sans animate-in slide-in-from-bottom-2 duration-150 ${e.type===`success`?`bg-emerald-100 text-emerald-950 border-emerald-900`:e.type===`error`?`bg-rose-100 text-rose-950 border-rose-900`:`bg-amber-100 text-amber-950 border-amber-900`}`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type===`success`?(0,N.jsx)(l,{className:`w-4 h-4 text-emerald-700 shrink-0`}):e.type===`error`?(0,N.jsx)(i,{className:`w-4 h-4 text-rose-700 shrink-0`}):(0,N.jsx)(n,{className:`w-4 h-4 text-amber-700 shrink-0`}),(0,N.jsx)(`span`,{className:`font-semibold`,children:e.message})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>K(e.id),className:`p-0.5 hover:bg-black/10 rounded cursor-pointer shrink-0`,children:(0,N.jsx)(g,{className:`w-3.5 h-3.5`})})]},e.id))}),D&&(0,N.jsx)(L,{item:D.item,ownedQuantity:D.inventoryItem?.quantity,playerGold:r,isEquipped:D.inventoryItem?.is_equipped,isActionLoading:b===D.item.id,onClose:()=>P(null),onPurchase:p===`storefront`?X:void 0,onAction:p===`vault`&&D.inventoryItem?e=>{e.category===`consumable`?Z(e):e.category===`cosmetic`?Q(e,!D.inventoryItem?.is_equipped):e.category===`companion_gift`&&$(e)}:void 0,actionLabel:D.item.category===`consumable`?`Consume`:D.item.category===`cosmetic`?D.inventoryItem?.is_equipped?`Unequip`:`Equip`:`Present Gift`}),V&&(0,N.jsx)(R,{giftItem:V.item,reaction:V.reaction,onClose:()=>H(null),onOpenCompanion:t})]})};export{V as StoreWindow,V as default};
algospaced-ui/dist/assets/{TerminalEmulator-o-sZq1iI.js → TerminalEmulator-B-cgsIHL.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Vt as t,zt as n}from"./vendor-react-CDF1pnIM.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{n as i}from"./index-DX2cztXb.js";var a=e(t(),1),o=n();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[n,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)},[n]);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 n=>{let a=n.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 review 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 r.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 r.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 fsrs_cards partition...`);try{let{data:{session:e}}=await r.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();if(e.length===0)u.push(`Queue status: CLEAR! 0 cards due.`);else{let t={0:`New`,1:`Learning`,2:`Review`,3:`Relearning`};u.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number??`?`}: ${e.problems?.name??`Unknown`} (${t[e.fsrs_state??0]??`New`})`))}}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 r.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 r.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`),n=t===-1?``:a.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!n){u.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}u.push(`Running query: ${n}`),e(`mysql`);try{let{data:{session:e}}=await r.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:n})});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:n.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};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Qt as t,Xt as n}from"./vendor-react-oIjZMgNV.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{n as i}from"./index-B53AvSbH.js";var a=e(t(),1),o=n();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[n,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)},[n]);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 n=>{let a=n.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 review 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 r.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 r.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 fsrs_cards partition...`);try{let{data:{session:e}}=await r.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();if(e.length===0)u.push(`Queue status: CLEAR! 0 cards due.`);else{let t={0:`New`,1:`Learning`,2:`Review`,3:`Relearning`};u.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number??`?`}: ${e.problems?.name??`Unknown`} (${t[e.fsrs_state??0]??`New`})`))}}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 r.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 r.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`),n=t===-1?``:a.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!n){u.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}u.push(`Running query: ${n}`),e(`mysql`);try{let{data:{session:e}}=await r.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:n})});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:n.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/{index-DX2cztXb.js → index-B53AvSbH.js} RENAMED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/index-BdFdjNzp.css ADDED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/index-DeC1PAqp.css DELETED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/{vendor-react-CDF1pnIM.js → vendor-react-oIjZMgNV.js} RENAMED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/index.html CHANGED
@@ -21,14 +21,14 @@
21
  rel="stylesheet"
22
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&amp;family=Be+Vietnam+Pro:wght@500;700&amp;family=Courier+Prime:wght@400;700&amp;family=Press+Start+2P&amp;family=Cinzel:wght@500;700;900&amp;family=Cinzel+Decorative:wght@700;900&amp;family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&amp;family=Kalam:wght@400;700&amp;display=swap"
23
  />
24
- <script type="module" crossorigin src="/assets/index-DX2cztXb.js"></script>
25
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-By0wlJeM.js">
27
- <link rel="modulepreload" crossorigin href="/assets/vendor-react-CDF1pnIM.js">
28
  <link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DSIO3PIf.js">
29
  <link rel="modulepreload" crossorigin href="/assets/firebaseClient-DZobvwSx.js">
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-ui-ZXcm-2wU.js">
31
- <link rel="stylesheet" crossorigin href="/assets/index-DeC1PAqp.css">
32
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
33
 
34
  <body>
 
21
  rel="stylesheet"
22
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&amp;family=Be+Vietnam+Pro:wght@500;700&amp;family=Courier+Prime:wght@400;700&amp;family=Press+Start+2P&amp;family=Cinzel:wght@500;700;900&amp;family=Cinzel+Decorative:wght@700;900&amp;family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&amp;family=Kalam:wght@400;700&amp;display=swap"
23
  />
24
+ <script type="module" crossorigin src="/assets/index-B53AvSbH.js"></script>
25
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-By0wlJeM.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/vendor-react-oIjZMgNV.js">
28
  <link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DSIO3PIf.js">
29
  <link rel="modulepreload" crossorigin href="/assets/firebaseClient-DZobvwSx.js">
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-ui-ZXcm-2wU.js">
31
+ <link rel="stylesheet" crossorigin href="/assets/index-BdFdjNzp.css">
32
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
33
 
34
  <body>
algospaced-ui/dist/sw.js CHANGED
@@ -1 +1 @@
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 o=s=>l(s,i),t={module:{uri:i},exports:u,require:o};e[i]=Promise.all(r.map(s=>t[s]||o(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:"loader.css",revision:"fe561cfc0908978c7b17dcf5d0ce1075"},{url:"loader-init.js",revision:"3d0342fa97370ec97880bb98818cd608"},{url:"index.html",revision:"365534c203f1fc3b747c989300b754a2"},{url:"assets/vendor-ui-ZXcm-2wU.js",revision:null},{url:"assets/vendor-react-CDF1pnIM.js",revision:null},{url:"assets/vendor-katex-DtkCqjBQ.css",revision:null},{url:"assets/vendor-katex-Balf574a.js",revision:null},{url:"assets/vendor-firebase-DSIO3PIf.js",revision:null},{url:"assets/vendor-codemirror-By0wlJeM.js",revision:null},{url:"assets/TerminalEmulator-o-sZq1iI.js",revision:null},{url:"assets/Settings-HgPu-LnK.js",revision:null},{url:"assets/rolldown-runtime-hePW80VL.js",revision:null},{url:"assets/ReviewQueue-CSzueRL_.js",revision:null},{url:"assets/PythonChallenge-DwlCVZ7-.js",revision:null},{url:"assets/ProblemSpecPanel-clZ38uEk.js",revision:null},{url:"assets/PrincessChamber-DvQR6sQH.js",revision:null},{url:"assets/MySQLPlayground-NRQBboPp.js",revision:null},{url:"assets/MarkdownRenderer-AdFp0pUP.js",revision:null},{url:"assets/KatexRenderer-CfYwRkzO.js",revision:null},{url:"assets/JourneyPath-S1uJQhTl.js",revision:null},{url:"assets/index-DX2cztXb.js",revision:null},{url:"assets/index-DeC1PAqp.css",revision:null},{url:"assets/GitHubSyncWindow-Xyx5vxzj.js",revision:null},{url:"assets/githubSyncService-x0Mm_uEl.js",revision:null},{url:"assets/firebaseClient-DZobvwSx.js",revision:null},{url:"assets/FileExplorer-DC0E1wW8.js",revision:null},{url:"assets/CreateProblemForm-DvmR15Wo.js",revision:null},{url:"assets/confetti.module-Uxh4CK4s.js",revision:null},{url:"assets/CardManager-CkYQqEcX.js",revision:null},{url:"assets/Auth-Cvp48f3L.js",revision:null},{url:"manifest.webmanifest",revision:"7c8ff056d2e188c868d851bcb349e28e"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
 
1
+ if(!self.define){let s,e={};const r=(r,l)=>(r=new URL(r+".js",l).href,e[r]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=r,s.onload=e,document.head.appendChild(s)}else s=r,importScripts(r),e()}).then(()=>{let s=e[r];if(!s)throw new Error(`Module ${r} didn’t register its module`);return s}));self.define=(l,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const o=s=>r(s,i),t={module:{uri:i},exports:u,require:o};e[i]=Promise.all(l.map(s=>t[s]||o(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:"loader.css",revision:"fe561cfc0908978c7b17dcf5d0ce1075"},{url:"loader-init.js",revision:"3d0342fa97370ec97880bb98818cd608"},{url:"index.html",revision:"9e84c924df98aa84b9f779b21cc7b05c"},{url:"assets/vendor-ui-ZXcm-2wU.js",revision:null},{url:"assets/vendor-react-oIjZMgNV.js",revision:null},{url:"assets/vendor-katex-DtkCqjBQ.css",revision:null},{url:"assets/vendor-katex-Balf574a.js",revision:null},{url:"assets/vendor-firebase-DSIO3PIf.js",revision:null},{url:"assets/vendor-codemirror-By0wlJeM.js",revision:null},{url:"assets/TerminalEmulator-B-cgsIHL.js",revision:null},{url:"assets/StoreWindow-CdHQWIUq.js",revision:null},{url:"assets/Settings-Brys5us-.js",revision:null},{url:"assets/rolldown-runtime-hePW80VL.js",revision:null},{url:"assets/ReviewQueue-15B52jqH.js",revision:null},{url:"assets/PythonChallenge-CiLYD15D.js",revision:null},{url:"assets/ProblemSpecPanel-0WaGunPO.js",revision:null},{url:"assets/PrincessChamber-CS-4OU0n.js",revision:null},{url:"assets/MySQLPlayground-C32Btviu.js",revision:null},{url:"assets/MarkdownRenderer-B_9j9AKs.js",revision:null},{url:"assets/KatexRenderer-NjsEFKtT.js",revision:null},{url:"assets/JourneyPath-DzueA_V1.js",revision:null},{url:"assets/index-BdFdjNzp.css",revision:null},{url:"assets/index-B53AvSbH.js",revision:null},{url:"assets/GitHubSyncWindow-Bv5jA_W2.js",revision:null},{url:"assets/githubSyncService-x0Mm_uEl.js",revision:null},{url:"assets/firebaseClient-DZobvwSx.js",revision:null},{url:"assets/FileExplorer-DPdHXlvq.js",revision:null},{url:"assets/CreateProblemForm-Btlo_Jzs.js",revision:null},{url:"assets/confetti.module-Uxh4CK4s.js",revision:null},{url:"assets/CardManager-oo_VDg0z.js",revision:null},{url:"assets/Auth-DE6tOdxt.js",revision:null},{url:"manifest.webmanifest",revision:"7c8ff056d2e188c868d851bcb349e28e"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
algospaced-ui/package.json CHANGED
@@ -8,7 +8,7 @@
8
  "build": "node node_modules/typescript7/bin/tsc -b && vite build",
9
  "typecheck": "node node_modules/typescript7/bin/tsc -b",
10
  "lint": "eslint .",
11
- "test": "node --experimental-strip-types --test tests/offlineAuth.test.mjs tests/offlineReviewQueue.test.mjs tests/cardManager.test.mjs tests/companionChoices.test.mjs tests/companionNotificationDialogue.test.mjs",
12
  "preview": "vite preview"
13
  },
14
  "dependencies": {
 
8
  "build": "node node_modules/typescript7/bin/tsc -b && vite build",
9
  "typecheck": "node node_modules/typescript7/bin/tsc -b",
10
  "lint": "eslint .",
11
+ "test": "node --experimental-strip-types --test tests/offlineAuth.test.mjs tests/offlineReviewQueue.test.mjs tests/cardManager.test.mjs tests/companionChoices.test.mjs tests/companionNotificationDialogue.test.mjs tests/storeInventory.test.mjs tests/storeWindowUI.test.mjs",
12
  "preview": "vite preview"
13
  },
14
  "dependencies": {
algospaced-ui/src/App.tsx CHANGED
@@ -13,6 +13,8 @@ import { DesktopGadget } from './components/desktop/DesktopGadget';
13
  import { DesktopTaskbar } from './components/desktop/DesktopTaskbar';
14
  import { MobileMetroScreen } from './components/desktop/MobileMetroScreen';
15
  import { DesktopWindowContainer } from './components/desktop/DesktopWindowContainer';
 
 
16
 
17
  export default function App() {
18
  const [user, setUser] = useState<AuthUser | null>(() => authService.getInitialUser());
@@ -57,6 +59,39 @@ export default function App() {
57
  setCompanionDialogueEvent
58
  } = useCompanionEvents(user, openWindow);
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  const handleCloseDialogue = useCallback(() => {
61
  setCompanionDialogueEvent(null);
62
  }, [setCompanionDialogueEvent]);
@@ -234,6 +269,17 @@ export default function App() {
234
  badgeShadowColor: '#fde047',
235
  action: () => openWindow('companion')
236
  },
 
 
 
 
 
 
 
 
 
 
 
237
  {
238
  id: 'settings',
239
  label: <>API CONFIG</>,
@@ -261,10 +307,30 @@ export default function App() {
261
  <main
262
  role="main"
263
  aria-label="Desktop Workspace"
 
264
  onContextMenu={handleContextMenu}
265
  onClick={closeContextMenu}
266
- className="w-screen h-screen m-0 p-0 relative isolate font-sans text-ink-black overflow-hidden select-none"
 
 
 
 
 
267
  >
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  {/* Background Wallpaper image */}
269
  <div
270
  className="absolute inset-0 w-full h-full bg-cover bg-center z-0 pointer-events-none saturate-150 contrast-125 transition-all duration-300"
 
13
  import { DesktopTaskbar } from './components/desktop/DesktopTaskbar';
14
  import { MobileMetroScreen } from './components/desktop/MobileMetroScreen';
15
  import { DesktopWindowContainer } from './components/desktop/DesktopWindowContainer';
16
+ import { useEconomyStore } from './stores/useEconomyStore';
17
+ import { STORE_CATALOG_MAP } from './data/storeCatalog';
18
 
19
  export default function App() {
20
  const [user, setUser] = useState<AuthUser | null>(() => authService.getInitialUser());
 
59
  setCompanionDialogueEvent
60
  } = useCompanionEvents(user, openWindow);
61
 
62
+ // Active Cosmetics OS State
63
+ const inventory = useEconomyStore(s => s.inventory ?? []);
64
+
65
+ const equippedCrt = useMemo(() => {
66
+ return inventory.find(
67
+ i =>
68
+ i.is_equipped &&
69
+ (i.item_id === 'cosmetic_crt_scanlines' ||
70
+ i.item_id === 'crt_phosphor_matrix' ||
71
+ i.item_id === 'crt_amber_phosphor' ||
72
+ STORE_CATALOG_MAP[i.item_id]?.effect_type === 'crt_theme')
73
+ );
74
+ }, [inventory]);
75
+
76
+ const equippedTheme = useMemo(() => {
77
+ return inventory.find(
78
+ i =>
79
+ i.is_equipped &&
80
+ (i.item_id.startsWith('cosmetic_theme_') ||
81
+ i.item_id.startsWith('theme_') ||
82
+ STORE_CATALOG_MAP[i.item_id]?.effect_type === 'palette_theme')
83
+ );
84
+ }, [inventory]);
85
+
86
+ const activeThemeId = useMemo(() => {
87
+ if (!equippedTheme) return undefined;
88
+ const cat = STORE_CATALOG_MAP[equippedTheme.item_id];
89
+ return (
90
+ (cat?.effect_payload?.theme_id as string) ||
91
+ (equippedTheme.item_id.includes('amber') ? 'amber' : 'cyber')
92
+ );
93
+ }, [equippedTheme]);
94
+
95
  const handleCloseDialogue = useCallback(() => {
96
  setCompanionDialogueEvent(null);
97
  }, [setCompanionDialogueEvent]);
 
269
  badgeShadowColor: '#fde047',
270
  action: () => openWindow('companion')
271
  },
272
+ {
273
+ id: 'store',
274
+ label: (
275
+ <>
276
+ STORE
277
+ </>
278
+ ),
279
+ icon: 'storefront',
280
+ badgeShadowColor: '#f59e0b',
281
+ action: () => openWindow('store')
282
+ },
283
  {
284
  id: 'settings',
285
  label: <>API CONFIG</>,
 
307
  <main
308
  role="main"
309
  aria-label="Desktop Workspace"
310
+ data-desktop-theme={activeThemeId}
311
  onContextMenu={handleContextMenu}
312
  onClick={closeContextMenu}
313
+ className={`w-screen h-screen m-0 p-0 relative isolate font-sans text-ink-black overflow-hidden select-none ${activeThemeId === 'amber'
314
+ ? 'theme-amber bg-amber-950/20'
315
+ : activeThemeId === 'cyber'
316
+ ? 'theme-cyber bg-purple-950/20'
317
+ : ''
318
+ }`}
319
  >
320
+ {/* Retro CRT Scanlines & Phosphor Glow Overlay */}
321
+ {equippedCrt && (
322
+ <div
323
+ data-testid="crt-overlay"
324
+ className="crt-scanlines-active fixed inset-0 pointer-events-none z-[9990] mix-blend-overlay"
325
+ style={{
326
+ background:
327
+ 'linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 255, 0, 0.03))',
328
+ backgroundSize: '100% 3px, 6px 100%'
329
+ }}
330
+ aria-hidden="true"
331
+ />
332
+ )}
333
+
334
  {/* Background Wallpaper image */}
335
  <div
336
  className="absolute inset-0 w-full h-full bg-cover bg-center z-0 pointer-events-none saturate-150 contrast-125 transition-all duration-300"
algospaced-ui/src/components/desktop/DesktopGadget.tsx CHANGED
@@ -1,5 +1,7 @@
1
  import React from 'react';
 
2
  import type { StreakInfo } from '../../types/windowTypes';
 
3
 
4
  interface DesktopGadgetProps {
5
  isMobile: boolean;
@@ -12,8 +14,14 @@ export const DesktopGadget: React.FC<DesktopGadgetProps> = ({
12
  username,
13
  streak
14
  }) => {
 
 
 
15
  if (isMobile) return null;
16
 
 
 
 
17
  return (
18
  <>
19
  {/* System Gadget Widget (Top Right) */}
@@ -29,13 +37,22 @@ export const DesktopGadget: React.FC<DesktopGadgetProps> = ({
29
  src="/icons/avatar.webp"
30
  />
31
  </div>
32
- <div className="overflow-hidden">
33
  <div className="font-headline-md text-sm font-bold text-ink-black truncate">{username}</div>
34
- <div className="flex items-center gap-1 text-red-700 mt-1 select-none font-bold">
35
- <span className="material-symbols-outlined text-sm" style={{ fontVariationSettings: "'FILL' 1" }}>
36
- local_fire_department
37
- </span>
38
- <span className="font-arcade text-[7px]">{streak?.current_streak ?? 0} DAY STREAK</span>
 
 
 
 
 
 
 
 
 
39
  </div>
40
  </div>
41
  </div>
 
1
  import React from 'react';
2
+ import { Coins } from 'lucide-react';
3
  import type { StreakInfo } from '../../types/windowTypes';
4
+ import { useEconomyStore } from '../../stores/useEconomyStore';
5
 
6
  interface DesktopGadgetProps {
7
  isMobile: boolean;
 
14
  username,
15
  streak
16
  }) => {
17
+ const gold = useEconomyStore(state => state.gold);
18
+ const lifetimeEarned = useEconomyStore(state => state.lifetimeEarned);
19
+
20
  if (isMobile) return null;
21
 
22
+ const displayGold = Math.max(0, gold || 0);
23
+ const displayLifetime = Math.max(0, lifetimeEarned || 0);
24
+
25
  return (
26
  <>
27
  {/* System Gadget Widget (Top Right) */}
 
37
  src="/icons/avatar.webp"
38
  />
39
  </div>
40
+ <div className="overflow-hidden flex-1">
41
  <div className="font-headline-md text-sm font-bold text-ink-black truncate">{username}</div>
42
+ <div className="flex items-center gap-2.5 mt-1 select-none font-bold">
43
+ <div className="flex items-center gap-1 text-red-700">
44
+ <span className="material-symbols-outlined text-sm" style={{ fontVariationSettings: "'FILL' 1" }}>
45
+ local_fire_department
46
+ </span>
47
+ <span className="font-arcade text-[7px]">{streak?.current_streak ?? 0} DAY STREAK</span>
48
+ </div>
49
+ <div
50
+ className="flex items-center gap-1 text-amber-700 cursor-default"
51
+ title={`Gold: ${displayGold} (Lifetime: ${displayLifetime})`}
52
+ >
53
+ <Coins className="w-3.5 h-3.5 text-amber-500 fill-amber-400 shrink-0" />
54
+ <span className="font-arcade text-[7px] text-amber-900 tracking-wide">{displayGold}g</span>
55
+ </div>
56
  </div>
57
  </div>
58
  </div>
algospaced-ui/src/components/desktop/DesktopStartMenu.tsx CHANGED
@@ -30,9 +30,8 @@ export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMen
30
  id="start-menu"
31
  style={style}
32
  {...rest}
33
- 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 ${
34
- style ? '' : 'absolute bottom-14 left-0 ml-2 mb-2'
35
- } ${className || ''}`}
36
  >
37
  <div className="flex items-center justify-between border-b-[2px] border-ink-black pb-2 mb-3">
38
  <span className="font-arcade text-[9px] font-bold text-ink-black tracking-wider">ALGOSPACED OS</span>
@@ -113,6 +112,15 @@ export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMen
113
  </span>
114
  Auri
115
  </button>
 
 
 
 
 
 
 
 
 
116
  <button
117
  onClick={() => onOpenWindow('python')}
118
  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"
 
30
  id="start-menu"
31
  style={style}
32
  {...rest}
33
+ 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 ${style ? '' : 'absolute bottom-14 left-0 ml-2 mb-2'
34
+ } ${className || ''}`}
 
35
  >
36
  <div className="flex items-center justify-between border-b-[2px] border-ink-black pb-2 mb-3">
37
  <span className="font-arcade text-[9px] font-bold text-ink-black tracking-wider">ALGOSPACED OS</span>
 
112
  </span>
113
  Auri
114
  </button>
115
+ <button
116
+ onClick={() => onOpenWindow('store')}
117
+ 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"
118
+ >
119
+ <span className="material-symbols-outlined text-lg text-amber-600" style={{ fontVariationSettings: "'FILL' 1" }}>
120
+ storefront
121
+ </span>
122
+ STORE
123
+ </button>
124
  <button
125
  onClick={() => onOpenWindow('python')}
126
  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"
algospaced-ui/src/components/desktop/DesktopTaskbar.tsx CHANGED
@@ -38,6 +38,7 @@ const TASKBAR_ITEMS: TaskbarItemDef[] = [
38
  { id: 'python', title: 'Python Challenge', shortTitle: 'Python', icon: 'sports_esports' },
39
  { id: 'mysql', title: 'MySQL Playground', shortTitle: 'SQL', icon: 'database' },
40
  { id: 'companion', title: 'Auri', shortTitle: 'Auri', icon: 'castle', color: '#d97706' },
 
41
  { id: 'settings', title: 'API Config', shortTitle: 'API', icon: 'key', color: '#10b981' },
42
  ];
43
 
 
38
  { id: 'python', title: 'Python Challenge', shortTitle: 'Python', icon: 'sports_esports' },
39
  { id: 'mysql', title: 'MySQL Playground', shortTitle: 'SQL', icon: 'database' },
40
  { id: 'companion', title: 'Auri', shortTitle: 'Auri', icon: 'castle', color: '#d97706' },
41
+ { id: 'store', title: "Store", shortTitle: 'Store', icon: 'storefront', color: '#d97706' },
42
  { id: 'settings', title: 'API Config', shortTitle: 'API', icon: 'key', color: '#10b981' },
43
  ];
44
 
algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx CHANGED
@@ -15,6 +15,7 @@ const CreateProblemForm = lazy(() => import('../CreateProblemForm'));
15
  const PrincessChamber = lazy(() => import('../../features/companion/components/PrincessChamber'));
16
  const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow'));
17
  const CardManager = lazy(() => import('../card-manager/CardManager'));
 
18
 
19
 
20
  interface DesktopWindowContainerProps {
@@ -526,6 +527,40 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
526
  </WindowShell>
527
  )}
528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  </>
530
  );
531
  };
 
15
  const PrincessChamber = lazy(() => import('../../features/companion/components/PrincessChamber'));
16
  const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow'));
17
  const CardManager = lazy(() => import('../card-manager/CardManager'));
18
+ const StoreWindow = lazy(() => import('../store/StoreWindow'));
19
 
20
 
21
  interface DesktopWindowContainerProps {
 
527
  </WindowShell>
528
  )}
529
 
530
+ {/* 13. Store Window */}
531
+ {windows.store?.isOpen && (
532
+ <WindowShell
533
+ id="store"
534
+ title="Store"
535
+ icon="storefront"
536
+ isOpen={windows.store.isOpen}
537
+ isMinimized={windows.store.isMinimized}
538
+ onClose={() => closeWindow('store')}
539
+ onMinimize={() => minimizeWindow('store')}
540
+ activeWindow={activeWindow}
541
+ setActiveWindow={setActiveWindow}
542
+ defaultWidth="940px"
543
+ defaultHeight="660px"
544
+ minWidth={460}
545
+ minHeight={380}
546
+ titleBarColor="#d97706"
547
+ isMobile={isMobile}
548
+ >
549
+ <Suspense
550
+ fallback={
551
+ <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse">
552
+ Loading Emporium.sys...
553
+ </div>
554
+ }
555
+ >
556
+ <StoreWindow
557
+ onClose={() => closeWindow('store')}
558
+ onOpenCompanion={() => openWindow('companion')}
559
+ />
560
+ </Suspense>
561
+ </WindowShell>
562
+ )}
563
+
564
  </>
565
  );
566
  };
algospaced-ui/src/components/desktop/MobileMetroScreen.tsx CHANGED
@@ -177,6 +177,19 @@ export const MobileMetroScreen: React.FC<MobileMetroScreenProps> = ({
177
  </span>
178
  </button>
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  {/* Settings / API Config Tile */}
181
  <button
182
  onClick={() => onToggleWindow('settings')}
 
177
  </span>
178
  </button>
179
 
180
+ {/* Store Tile */}
181
+ <button
182
+ onClick={() => onToggleWindow('store')}
183
+ className="bg-[#d97706] text-white border-[3px] border-ink-black p-4 flex flex-col justify-between aspect-square gadget-shadow active:translate-y-1 active:translate-x-1 active:shadow-none select-none text-left cursor-pointer transition-all"
184
+ >
185
+ <span className="material-symbols-outlined text-3xl align-top" style={{ fontVariationSettings: "'FILL' 1" }}>
186
+ storefront
187
+ </span>
188
+ <span className="font-arcade text-[8px] font-bold tracking-tight uppercase leading-tight">
189
+ STORE
190
+ </span>
191
+ </button>
192
+
193
  {/* Settings / API Config Tile */}
194
  <button
195
  onClick={() => onToggleWindow('settings')}
algospaced-ui/src/components/store/GiftPresentationModal.tsx ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { X, Heart, Sparkles, Castle } from 'lucide-react';
3
+ import type { StoreItem } from '../../types/storeTypes';
4
+ import type { GiftReactionData } from './giftReactions';
5
+ import { useCompanionStore } from '../../features/companion/store/useCompanionStore';
6
+
7
+ interface GiftPresentationModalProps {
8
+ giftItem: StoreItem;
9
+ reaction: GiftReactionData;
10
+ onClose: () => void;
11
+ onOpenCompanion?: () => void;
12
+ }
13
+
14
+ export const GiftPresentationModal: React.FC<GiftPresentationModalProps> = ({
15
+ giftItem,
16
+ reaction,
17
+ onClose,
18
+ onOpenCompanion
19
+ }) => {
20
+ const companionState = useCompanionStore();
21
+ const bondTier = companionState.bondTier;
22
+ const bondPoints = companionState.bondPoints;
23
+ return (
24
+ <div
25
+ className="fixed inset-0 z-50 bg-ink-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-200 select-none"
26
+ onClick={onClose}
27
+ >
28
+ <div
29
+ className="bg-[#FFFDF0] border-[4px] border-ink-black rounded-xl max-w-lg w-full shadow-[8px_8px_0px_0px_#1E293B] flex flex-col overflow-hidden"
30
+ onClick={e => e.stopPropagation()}
31
+ >
32
+ {/* Header */}
33
+ <div className="bg-gradient-to-r from-amber-400 via-rose-300 to-amber-300 border-b-[3px] border-ink-black px-4 py-2.5 flex items-center justify-between">
34
+ <div className="flex items-center gap-2">
35
+ <Heart className="w-5 h-5 text-rose-600 fill-rose-600 animate-pulse" />
36
+ <span className="font-arcade text-xs text-ink-black font-extrabold uppercase tracking-wide">
37
+ {reaction.title}
38
+ </span>
39
+ </div>
40
+ <button
41
+ type="button"
42
+ onClick={onClose}
43
+ className="p-1 hover:bg-white/50 rounded text-ink-black cursor-pointer transition-colors"
44
+ title="Close"
45
+ >
46
+ <X className="w-4 h-4" />
47
+ </button>
48
+ </div>
49
+
50
+ {/* Content */}
51
+ <div className="p-5 flex flex-col gap-4">
52
+ {/* Princess Portrait & Badge */}
53
+ <div className="flex items-center gap-4 bg-amber-100/60 p-3.5 rounded-lg border-2 border-amber-300">
54
+ <div className="w-20 h-20 border-[3px] border-ink-black rounded overflow-hidden bg-amber-50 shadow-[3px_3px_0px_0px_#1E293B] shrink-0">
55
+ <img
56
+ src={`/sprites/princess/${reaction.emotion}.webp`}
57
+ alt="Princess Aurelia"
58
+ className="w-full h-full object-cover object-top"
59
+ />
60
+ </div>
61
+ <div className="flex flex-col gap-1">
62
+ <div className="flex items-center gap-1.5 text-xs font-arcade font-bold text-rose-700 flex-wrap">
63
+ <Sparkles className="w-3.5 h-3.5 text-rose-600 fill-rose-600" />
64
+ <span>+{reaction.bondBonus} Companion Bond</span>
65
+ <span className="text-slate-400 font-normal">|</span>
66
+ <span className="bg-rose-100 text-rose-800 px-2 py-0.5 rounded border border-rose-300 text-[10px] uppercase tracking-wide">
67
+ Tier: {bondTier} ({bondPoints} pts)
68
+ </span>
69
+ </div>
70
+ <h3 className="font-headline-md font-bold text-lg text-ink-black">
71
+ Princess Aurelia
72
+ </h3>
73
+ <p className="text-xs text-slate-600 font-sans">
74
+ Received with gratitude: <strong className="text-ink-black">{giftItem.name}</strong>
75
+ </p>
76
+ </div>
77
+ </div>
78
+
79
+ {/* Aurelia's Response Dialogue */}
80
+ <div className="bg-white p-4 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_rgba(0,0,0,0.1)]">
81
+ <h4 className="font-arcade text-[9px] text-amber-800 uppercase tracking-wider mb-2 font-bold flex items-center gap-1.5">
82
+ <span>Aurelia Speaks</span>
83
+ </h4>
84
+ <p className="font-serif italic text-sm text-ink-black leading-relaxed">
85
+ {reaction.dialogue}
86
+ </p>
87
+ </div>
88
+
89
+ {/* Action Footer */}
90
+ <div className="flex items-center justify-end gap-3 pt-2">
91
+ <button
92
+ type="button"
93
+ onClick={onClose}
94
+ className="font-arcade text-xs px-4 py-2 bg-paper-white hover:bg-slate-200 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold"
95
+ >
96
+ Continue
97
+ </button>
98
+ {onOpenCompanion && (
99
+ <button
100
+ type="button"
101
+ onClick={() => {
102
+ onClose();
103
+ onOpenCompanion();
104
+ }}
105
+ className="font-arcade text-xs px-4 py-2 bg-[#f59e0b] hover:bg-amber-400 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold flex items-center gap-1.5"
106
+ >
107
+ <Castle className="w-3.5 h-3.5" />
108
+ <span>Visit Aurelia</span>
109
+ </button>
110
+ )}
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ );
116
+ };
algospaced-ui/src/components/store/ItemIcon.tsx ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import {
3
+ ShieldAlert,
4
+ Scroll,
5
+ Sparkles,
6
+ Flame,
7
+ Tv,
8
+ Cpu,
9
+ Image as ImageIcon,
10
+ Flower2,
11
+ Heart,
12
+ Music,
13
+ Crown,
14
+ Package,
15
+ Coins
16
+ } from 'lucide-react';
17
+
18
+ interface ItemIconProps {
19
+ name: string;
20
+ className?: string;
21
+ }
22
+
23
+ export const ItemIcon: React.FC<ItemIconProps> = ({ name, className = 'w-6 h-6' }) => {
24
+ switch (name) {
25
+ case 'ShieldAlert':
26
+ return <ShieldAlert className={className} />;
27
+ case 'Scroll':
28
+ return <Scroll className={className} />;
29
+ case 'Sparkles':
30
+ return <Sparkles className={className} />;
31
+ case 'Flame':
32
+ return <Flame className={className} />;
33
+ case 'Tv':
34
+ return <Tv className={className} />;
35
+ case 'Cpu':
36
+ return <Cpu className={className} />;
37
+ case 'Image':
38
+ return <ImageIcon className={className} />;
39
+ case 'Flower2':
40
+ return <Flower2 className={className} />;
41
+ case 'Heart':
42
+ return <Heart className={className} />;
43
+ case 'Music':
44
+ return <Music className={className} />;
45
+ case 'Crown':
46
+ return <Crown className={className} />;
47
+ case 'Coins':
48
+ return <Coins className={className} />;
49
+ default:
50
+ return <Package className={className} />;
51
+ }
52
+ };
algospaced-ui/src/components/store/ItemLoreModal.tsx ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { X, Coins, Sparkles } from 'lucide-react';
3
+ import type { StoreItem } from '../../types/storeTypes';
4
+ import { ItemIcon } from './ItemIcon';
5
+
6
+ interface ItemLoreModalProps {
7
+ item: StoreItem;
8
+ ownedQuantity?: number;
9
+ playerGold: number;
10
+ isEquipped?: boolean;
11
+ onClose: () => void;
12
+ onPurchase?: (item: StoreItem) => void;
13
+ onAction?: (item: StoreItem) => void;
14
+ actionLabel?: string;
15
+ isActionLoading?: boolean;
16
+ }
17
+
18
+ export const ItemLoreModal: React.FC<ItemLoreModalProps> = ({
19
+ item,
20
+ ownedQuantity = 0,
21
+ playerGold,
22
+ isEquipped = false,
23
+ onClose,
24
+ onPurchase,
25
+ onAction,
26
+ actionLabel,
27
+ isActionLoading = false
28
+ }) => {
29
+ const isAffordable = playerGold >= item.price;
30
+
31
+ const categoryColor =
32
+ item.category === 'consumable'
33
+ ? 'bg-emerald-100 text-emerald-800 border-emerald-800'
34
+ : item.category === 'cosmetic'
35
+ ? 'bg-purple-100 text-purple-800 border-purple-800'
36
+ : 'bg-amber-100 text-amber-900 border-amber-800';
37
+
38
+ const categoryLabel =
39
+ item.category === 'consumable'
40
+ ? 'Study Consumable'
41
+ : item.category === 'cosmetic'
42
+ ? 'Desktop Cosmetic'
43
+ : 'Companion Gift';
44
+
45
+ return (
46
+ <div
47
+ className="fixed inset-0 z-50 bg-ink-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-150 select-none"
48
+ onClick={onClose}
49
+ >
50
+ <div
51
+ className="bg-[#FFFDF0] border-[3px] border-ink-black rounded-lg max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden"
52
+ onClick={e => e.stopPropagation()}
53
+ >
54
+ {/* Header */}
55
+ <div className="bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between">
56
+ <div className="flex items-center gap-2">
57
+ <Sparkles className="w-4 h-4 text-amber-600" />
58
+ <span className="font-arcade text-xs text-ink-black font-bold uppercase tracking-wider">
59
+ Item Artifact Lore
60
+ </span>
61
+ </div>
62
+ <button
63
+ type="button"
64
+ onClick={onClose}
65
+ className="p-1 hover:bg-slate-200 rounded text-ink-black cursor-pointer transition-colors"
66
+ title="Close"
67
+ >
68
+ <X className="w-4 h-4" />
69
+ </button>
70
+ </div>
71
+
72
+ {/* Content Body */}
73
+ <div className="p-5 flex flex-col gap-4 overflow-y-auto max-h-[70vh] custom-scrollbar">
74
+ {/* Visual Showcase */}
75
+ <div className="flex items-center gap-4 bg-amber-50/80 p-3 rounded-lg border-2 border-amber-200/80">
76
+ <div className="w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]">
77
+ <ItemIcon name={item.icon} className="w-8 h-8 text-amber-700" />
78
+ </div>
79
+ <div className="flex flex-col gap-1 overflow-hidden">
80
+ <span
81
+ className={`font-arcade text-[9px] px-2 py-0.5 border w-fit rounded uppercase tracking-wider ${categoryColor}`}
82
+ >
83
+ {categoryLabel}
84
+ </span>
85
+ <h3 className="font-headline-md font-bold text-lg text-ink-black leading-tight">
86
+ {item.name}
87
+ </h3>
88
+ {ownedQuantity > 0 && (
89
+ <span className="text-xs font-arcade text-slate-700 font-bold">
90
+ In Satchel: x{ownedQuantity}
91
+ {isEquipped && ' (EQUIPPED)'}
92
+ </span>
93
+ )}
94
+ </div>
95
+ </div>
96
+
97
+ {/* Lore Inscription */}
98
+ <div className="bg-amber-100/40 p-3.5 border-l-4 border-amber-600 rounded-r">
99
+ <h4 className="font-arcade text-[9px] text-amber-900 uppercase tracking-wider mb-1 font-bold">
100
+ Lore Inscription
101
+ </h4>
102
+ <p className="font-serif italic text-sm text-slate-800 leading-relaxed">
103
+ &ldquo;{item.lore}&rdquo;
104
+ </p>
105
+ </div>
106
+
107
+ {/* System Effect Breakdown */}
108
+ <div className="bg-white p-3 border-2 border-ink-black/20 rounded">
109
+ <h4 className="font-arcade text-[9px] text-slate-600 uppercase tracking-wider mb-1.5 font-bold">
110
+ System Effect & Mechanics
111
+ </h4>
112
+ <div className="text-xs font-sans text-slate-700 space-y-1">
113
+ <div className="flex items-center justify-between">
114
+ <span className="font-semibold text-ink-black">Effect Classification:</span>
115
+ <span className="font-mono text-[11px] bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300">
116
+ {item.effect_type}
117
+ </span>
118
+ </div>
119
+ <div className="text-slate-600 mt-1">
120
+ {item.effect_type === 'streak_freeze' && (
121
+ <span>Grants protection against broken daily streaks if a study day is missed.</span>
122
+ )}
123
+ {item.effect_type === 'hint_scroll' && (
124
+ <span>Unravels algorithmic intuition and optimal patterns for difficult challenges.</span>
125
+ )}
126
+ {item.effect_type === 'focus_boost' && (
127
+ <span>Enhances cognitive composure and grants bonus rewards on study reviews.</span>
128
+ )}
129
+ {item.effect_type === 'crt_theme' && (
130
+ <span>Overlays an authentic retro CRT scanline shader with phosphor bloom.</span>
131
+ )}
132
+ {item.effect_type === 'palette_theme' && (
133
+ <span>Transforms window styling and color palette to a distinct fantasy theme.</span>
134
+ )}
135
+ {item.effect_type === 'wallpaper' && (
136
+ <span>Applies celestial Spire landscape art as desktop background wallpaper.</span>
137
+ )}
138
+ {item.effect_type === 'aurelia_gift' && (
139
+ <span>
140
+ Present to Princess Aurelia to deepen your bond, unlock intimate lore, and heal her spirit.
141
+ </span>
142
+ )}
143
+ </div>
144
+ </div>
145
+ </div>
146
+
147
+ {/* Price & Action Panel */}
148
+ <div className="mt-2 pt-3 border-t-2 border-ink-black/10 flex items-center justify-between">
149
+ <div className="flex items-center gap-1.5 font-arcade text-sm font-bold text-amber-800">
150
+ <Coins className="w-4 h-4 text-amber-500 fill-amber-500" />
151
+ <span>{item.price}g</span>
152
+ </div>
153
+
154
+ <div className="flex items-center gap-2">
155
+ {onPurchase && (
156
+ <button
157
+ type="button"
158
+ disabled={!isAffordable || isActionLoading}
159
+ onClick={() => onPurchase(item)}
160
+ className={`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all ${
161
+ !isAffordable
162
+ ? 'bg-slate-200 text-slate-400 border-slate-400 shadow-none cursor-not-allowed'
163
+ : 'bg-amber-400 hover:bg-amber-300 text-ink-black cursor-pointer font-bold'
164
+ }`}
165
+ title={!isAffordable ? `Need ${item.price - playerGold} more gold` : 'Purchase Item'}
166
+ >
167
+ {isActionLoading
168
+ ? 'Purchasing...'
169
+ : !isAffordable
170
+ ? 'Insufficient Gold'
171
+ : `Purchase (${item.price}g)`}
172
+ </button>
173
+ )}
174
+
175
+ {onAction && actionLabel && (
176
+ <button
177
+ type="button"
178
+ disabled={isActionLoading}
179
+ onClick={() => onAction(item)}
180
+ className="font-arcade text-xs px-3.5 py-2 bg-grass-green hover:bg-emerald-400 text-ink-black border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer font-bold transition-all"
181
+ >
182
+ {isActionLoading ? 'Processing...' : actionLabel}
183
+ </button>
184
+ )}
185
+ </div>
186
+ </div>
187
+ </div>
188
+ </div>
189
+ </div>
190
+ );
191
+ };
algospaced-ui/src/components/store/StoreItemCard.tsx ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { Coins, Eye } from 'lucide-react';
3
+ import type { StoreItem } from '../../types/storeTypes';
4
+ import { ItemIcon } from './ItemIcon';
5
+
6
+ interface StoreItemCardProps {
7
+ item: StoreItem;
8
+ playerGold: number;
9
+ isPurchasing: boolean;
10
+ onPurchase: (item: StoreItem) => void;
11
+ onInspect: (item: StoreItem) => void;
12
+ }
13
+
14
+ export const StoreItemCard: React.FC<StoreItemCardProps> = ({
15
+ item,
16
+ playerGold,
17
+ isPurchasing,
18
+ onPurchase,
19
+ onInspect
20
+ }) => {
21
+ const isAffordable = playerGold >= item.price;
22
+
23
+ const categoryColor =
24
+ item.category === 'consumable'
25
+ ? 'bg-emerald-100 text-emerald-800 border-emerald-700'
26
+ : item.category === 'cosmetic'
27
+ ? 'bg-purple-100 text-purple-800 border-purple-700'
28
+ : 'bg-amber-100 text-amber-900 border-amber-700';
29
+
30
+ const categoryLabel =
31
+ item.category === 'consumable'
32
+ ? 'Consumable'
33
+ : item.category === 'cosmetic'
34
+ ? 'Cosmetic'
35
+ : 'Companion Gift';
36
+
37
+ return (
38
+ <div className="bg-[#FFFDF0] border-[3px] border-ink-black rounded-lg p-4 shadow-[4px_4px_0px_0px_#1E293B] flex flex-col justify-between hover:translate-x-[-1px] hover:translate-y-[-1px] hover:shadow-[5px_5px_0px_0px_#1E293B] transition-all">
39
+ {/* Top Bar: Category & Inspect */}
40
+ <div>
41
+ <div className="flex items-center justify-between gap-2 mb-3">
42
+ <span
43
+ className={`font-arcade text-[8px] px-2 py-0.5 border rounded uppercase font-bold tracking-wider ${categoryColor}`}
44
+ >
45
+ {categoryLabel}
46
+ </span>
47
+ <button
48
+ type="button"
49
+ onClick={() => onInspect(item)}
50
+ className="p-1 hover:bg-amber-100 text-slate-600 hover:text-ink-black rounded transition-colors cursor-pointer"
51
+ title="Inspect lore and mechanics"
52
+ >
53
+ <Eye className="w-3.5 h-3.5" />
54
+ </button>
55
+ </div>
56
+
57
+ {/* Item Icon & Title */}
58
+ <div className="flex items-start gap-3 mb-3">
59
+ <div className="w-12 h-12 bg-white border-[2px] border-ink-black rounded flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]">
60
+ <ItemIcon name={item.icon} className="w-6 h-6 text-amber-700" />
61
+ </div>
62
+ <div className="min-w-0 flex-1">
63
+ <h4
64
+ onClick={() => onInspect(item)}
65
+ className="font-headline-md font-bold text-sm text-ink-black leading-snug cursor-pointer hover:text-amber-800 truncate"
66
+ title={item.name}
67
+ >
68
+ {item.name}
69
+ </h4>
70
+ <div className="flex items-center gap-1 mt-0.5 text-amber-800 font-arcade text-xs font-bold">
71
+ <Coins className="w-3.5 h-3.5 text-amber-500 fill-amber-500" />
72
+ <span>{item.price}g</span>
73
+ </div>
74
+ </div>
75
+ </div>
76
+
77
+ {/* Lore Snippet */}
78
+ <p className="font-serif italic text-xs text-slate-600 line-clamp-2 mb-4 leading-relaxed">
79
+ &ldquo;{item.lore}&rdquo;
80
+ </p>
81
+ </div>
82
+
83
+ {/* Action Footer */}
84
+ <div className="pt-2 border-t border-ink-black/10 flex items-center justify-between gap-2">
85
+ <button
86
+ type="button"
87
+ disabled={!isAffordable || isPurchasing}
88
+ onClick={() => onPurchase(item)}
89
+ className={`w-full font-arcade text-[10px] py-2 px-3 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all uppercase tracking-wider font-bold ${
90
+ !isAffordable
91
+ ? 'bg-slate-200 text-slate-400 border-slate-400 shadow-none cursor-not-allowed'
92
+ : 'bg-amber-400 hover:bg-amber-300 text-ink-black cursor-pointer'
93
+ }`}
94
+ title={!isAffordable ? `Need ${item.price - playerGold} more gold to buy` : `Buy for ${item.price}g`}
95
+ >
96
+ {isPurchasing
97
+ ? 'Purchasing...'
98
+ : !isAffordable
99
+ ? 'Insufficient Gold'
100
+ : 'Purchase'}
101
+ </button>
102
+ </div>
103
+ </div>
104
+ );
105
+ };
algospaced-ui/src/components/store/StoreWindow.tsx ADDED
@@ -0,0 +1,521 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useMemo, useCallback } from 'react';
2
+ import {
3
+ Store,
4
+ Package,
5
+ Coins,
6
+ Sparkles,
7
+ ShoppingBag,
8
+ CheckCircle2,
9
+ AlertCircle,
10
+ X
11
+ } from 'lucide-react';
12
+ import confetti from 'canvas-confetti';
13
+ import { useEconomyStore } from '../../stores/useEconomyStore';
14
+ import { STORE_CATALOG, STORE_CATALOG_MAP } from '../../data/storeCatalog';
15
+ import type { StoreItem, StoreItemCategory, InventoryItem } from '../../types/storeTypes';
16
+ import { playPopupChime, playLevelUpFanfare } from '../../utils/rpgAudio';
17
+ import { companionStore } from '../../features/companion/store/useCompanionStore';
18
+ import { StoreItemCard } from './StoreItemCard';
19
+ import { VaultItemCard } from './VaultItemCard';
20
+ import { ItemLoreModal } from './ItemLoreModal';
21
+ import { GiftPresentationModal } from './GiftPresentationModal';
22
+ import { AURELIA_GIFT_REACTIONS, DEFAULT_GIFT_REACTION, type GiftReactionData } from './giftReactions';
23
+
24
+ export interface StoreWindowProps {
25
+ onClose?: () => void;
26
+ onOpenCompanion?: () => void;
27
+ }
28
+
29
+ type MainTab = 'storefront' | 'vault';
30
+ type FilterCategory = 'all' | StoreItemCategory;
31
+
32
+ interface ToastNotification {
33
+ id: string;
34
+ type: 'success' | 'error' | 'info';
35
+ message: string;
36
+ }
37
+
38
+ export const StoreWindow: React.FC<StoreWindowProps> = ({ onClose: _onClose, onOpenCompanion }) => {
39
+ // Store subscriptions
40
+ const gold = useEconomyStore(s => Math.max(0, s.gold ?? 0));
41
+ const lifetimeEarned = useEconomyStore(s => Math.max(0, s.lifetimeEarned ?? 0));
42
+ const inventory = useEconomyStore(s => s.inventory ?? []);
43
+ const purchaseItem = useEconomyStore(s => s.purchaseItem);
44
+ const consumeItem = useEconomyStore(s => s.consumeItem);
45
+ const equipItem = useEconomyStore(s => s.equipItem);
46
+
47
+ // Local UI state
48
+ const [activeTab, setActiveTab] = useState<MainTab>('storefront');
49
+ const [storeCategory, setStoreCategory] = useState<FilterCategory>('all');
50
+ const [vaultCategory, setVaultCategory] = useState<FilterCategory>('all');
51
+ const [loadingItemId, setLoadingItemId] = useState<string | null>(null);
52
+ const [inspectItem, setInspectItem] = useState<{
53
+ item: StoreItem;
54
+ inventoryItem?: InventoryItem;
55
+ } | null>(null);
56
+ const [giftCelebration, setGiftCelebration] = useState<{
57
+ item: StoreItem;
58
+ reaction: GiftReactionData;
59
+ } | null>(null);
60
+ const [toasts, setToasts] = useState<ToastNotification[]>([]);
61
+
62
+ // Toast notification helper
63
+ const addToast = useCallback((message: string, type: 'success' | 'error' | 'info' = 'info') => {
64
+ const id = `toast_${Date.now()}_${Math.random().toString(36).substring(2, 6)}`;
65
+ setToasts(prev => [...prev.slice(-2), { id, message, type }]);
66
+ setTimeout(() => {
67
+ setToasts(prev => prev.filter(t => t.id !== id));
68
+ }, 4000);
69
+ }, []);
70
+
71
+ const removeToast = useCallback((id: string) => {
72
+ setToasts(prev => prev.filter(t => t.id !== id));
73
+ }, []);
74
+
75
+ // Filtered Catalog Items for Storefront
76
+ const filteredCatalog = useMemo(() => {
77
+ if (storeCategory === 'all') return STORE_CATALOG;
78
+ return STORE_CATALOG.filter(item => item.category === storeCategory);
79
+ }, [storeCategory]);
80
+
81
+ // Enriched Inventory Items for Vault
82
+ const enrichedInventory = useMemo(() => {
83
+ return inventory
84
+ .map(invItem => ({
85
+ invItem,
86
+ catalog: STORE_CATALOG_MAP[invItem.item_id]
87
+ }))
88
+ .filter((entry): entry is { invItem: InventoryItem; catalog: StoreItem } => !!entry.catalog);
89
+ }, [inventory]);
90
+
91
+ // Filtered Inventory Items for Vault
92
+ const filteredInventory = useMemo(() => {
93
+ if (vaultCategory === 'all') return enrichedInventory;
94
+ return enrichedInventory.filter(entry => entry.catalog.category === vaultCategory);
95
+ }, [enrichedInventory, vaultCategory]);
96
+
97
+ // Total items count in inventory
98
+ const totalInventoryCount = useMemo(() => {
99
+ return inventory.reduce((acc, curr) => acc + (curr.quantity || 0), 0);
100
+ }, [inventory]);
101
+
102
+ // Purchase Handler
103
+ const handlePurchase = useCallback(
104
+ async (item: StoreItem) => {
105
+ if (gold < item.price) {
106
+ addToast(`Insufficient Gold. You need ${item.price - gold} more gold to acquire this item.`, 'error');
107
+ return;
108
+ }
109
+
110
+ setLoadingItemId(item.id);
111
+ try {
112
+ await purchaseItem(item.id, 1);
113
+
114
+ // Celebratory feedback
115
+ playPopupChime();
116
+ try {
117
+ confetti({
118
+ particleCount: 45,
119
+ spread: 60,
120
+ origin: { y: 0.65 }
121
+ });
122
+ } catch {
123
+ // safe fallback if canvas is unavailable
124
+ }
125
+
126
+ addToast(`Acquired ${item.name}! Added to Adventurer's Vault.`, 'success');
127
+ if (inspectItem?.item.id === item.id) {
128
+ setInspectItem(null);
129
+ }
130
+ } catch (err) {
131
+ const msg = err instanceof Error ? err.message : 'Purchase failed. Your gold balance remains intact.';
132
+ addToast(msg, 'error');
133
+ } finally {
134
+ setLoadingItemId(null);
135
+ }
136
+ },
137
+ [gold, purchaseItem, addToast, inspectItem]
138
+ );
139
+
140
+ // Consume Handler
141
+ const handleConsume = useCallback(
142
+ async (item: StoreItem) => {
143
+ setLoadingItemId(item.id);
144
+ try {
145
+ const res = await consumeItem(item.id);
146
+ playPopupChime();
147
+ addToast(`Consumed ${item.name}! Effect active. (Remaining: x${res.remaining_quantity})`, 'success');
148
+ if (inspectItem?.item.id === item.id) {
149
+ setInspectItem(null);
150
+ }
151
+ } catch (err) {
152
+ const msg = err instanceof Error ? err.message : `Failed to consume ${item.name}.`;
153
+ addToast(msg, 'error');
154
+ } finally {
155
+ setLoadingItemId(null);
156
+ }
157
+ },
158
+ [consumeItem, addToast, inspectItem]
159
+ );
160
+
161
+ // Equip / Unequip Cosmetic Handler
162
+ const handleEquip = useCallback(
163
+ async (item: StoreItem, isEquipping: boolean) => {
164
+ setLoadingItemId(item.id);
165
+ try {
166
+ await equipItem(item.id, isEquipping);
167
+ playPopupChime();
168
+ addToast(
169
+ isEquipping ? `Equipped ${item.name}!` : `Unequipped ${item.name}.`,
170
+ 'success'
171
+ );
172
+ if (inspectItem?.item.id === item.id) {
173
+ setInspectItem(null);
174
+ }
175
+ } catch (err) {
176
+ const msg = err instanceof Error ? err.message : `Failed to update cosmetic state.`;
177
+ addToast(msg, 'error');
178
+ } finally {
179
+ setLoadingItemId(null);
180
+ }
181
+ },
182
+ [equipItem, addToast, inspectItem]
183
+ );
184
+
185
+ // Present Gift to Aurelia Handler
186
+ const handlePresentGift = useCallback(
187
+ async (item: StoreItem) => {
188
+ setLoadingItemId(item.id);
189
+ try {
190
+ // Consume 1 unit from inventory
191
+ await consumeItem(item.id);
192
+
193
+ const reaction = AURELIA_GIFT_REACTIONS[item.id] || DEFAULT_GIFT_REACTION;
194
+
195
+ // Update Princess Companion state via genuine companionStore.presentGift
196
+ companionStore.presentGift({
197
+ id: item.id,
198
+ name: item.name,
199
+ price: item.price,
200
+ effect_payload: item.effect_payload
201
+ });
202
+
203
+ // Audio & Visual Fanfare
204
+ playLevelUpFanfare();
205
+ try {
206
+ confetti({
207
+ particleCount: 60,
208
+ spread: 70,
209
+ origin: { y: 0.6 }
210
+ });
211
+ } catch {
212
+ // safe fallback
213
+ }
214
+
215
+ // Display celebration dialogue modal
216
+ setGiftCelebration({ item, reaction });
217
+ if (inspectItem?.item.id === item.id) {
218
+ setInspectItem(null);
219
+ }
220
+ } catch (err) {
221
+ const msg = err instanceof Error ? err.message : `Failed to present ${item.name} to Aurelia.`;
222
+ addToast(msg, 'error');
223
+ } finally {
224
+ setLoadingItemId(null);
225
+ }
226
+ },
227
+ [consumeItem, addToast, inspectItem]
228
+ );
229
+
230
+ return (
231
+ <div className="w-full h-full bg-[#fbf7ee] flex flex-col overflow-hidden text-ink-black select-none">
232
+ {/* Top Banner & Header Bar */}
233
+ <div className="bg-[#FFFDF0] border-b-[3px] border-ink-black px-4 py-3 shrink-0 flex flex-wrap items-center justify-between gap-3 shadow-[0_2px_4px_rgba(0,0,0,0.05)]">
234
+ {/* Navigation Tabs */}
235
+ <div className="flex items-center gap-2">
236
+ <button
237
+ type="button"
238
+ onClick={() => setActiveTab('storefront')}
239
+ className={`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-2 cursor-pointer uppercase font-bold ${activeTab === 'storefront'
240
+ ? 'bg-amber-400 text-ink-black ring-2 ring-amber-500/50'
241
+ : 'bg-paper-white text-slate-700 hover:bg-amber-100/60'
242
+ }`}
243
+ >
244
+ <Store className="w-4 h-4 text-amber-800" />
245
+ <span>Store</span>
246
+ </button>
247
+
248
+ <button
249
+ type="button"
250
+ onClick={() => setActiveTab('vault')}
251
+ className={`font-arcade text-xs px-3.5 py-2 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all flex items-center gap-2 cursor-pointer uppercase font-bold ${activeTab === 'vault'
252
+ ? 'bg-amber-400 text-ink-black ring-2 ring-amber-500/50'
253
+ : 'bg-paper-white text-slate-700 hover:bg-amber-100/60'
254
+ }`}
255
+ >
256
+ <Package className="w-4 h-4 text-amber-800" />
257
+ <span>Adventurer&apos;s Vault</span>
258
+ {totalInventoryCount > 0 && (
259
+ <span className="font-arcade text-[9px] bg-ink-black text-amber-300 px-1.5 py-0.5 rounded font-extrabold ml-0.5">
260
+ {totalInventoryCount}
261
+ </span>
262
+ )}
263
+ </button>
264
+ </div>
265
+
266
+ {/* Live Gold Counter Widget */}
267
+ <div
268
+ className="flex items-center gap-3 bg-amber-100/70 border-[2px] border-ink-black px-3.5 py-1.5 rounded shadow-[2px_2px_0px_0px_#1E293B]"
269
+ title={`Gold: ${gold} (Lifetime: ${lifetimeEarned})`}
270
+ >
271
+ <div className="flex items-center gap-1.5 font-arcade text-xs font-bold text-amber-900">
272
+ <Coins className="w-4 h-4 text-amber-500 fill-amber-500" />
273
+ <span>{gold}g</span>
274
+ </div>
275
+ <div className="h-3 w-[1px] bg-amber-300" />
276
+ <span className="font-arcade text-[8px] text-amber-800 uppercase font-semibold">
277
+ Lifetime: {lifetimeEarned}g
278
+ </span>
279
+ </div>
280
+ </div>
281
+
282
+ {/* Main Content Area */}
283
+ <div className="flex-1 overflow-y-auto custom-scrollbar p-4 md:p-6 flex flex-col gap-5">
284
+ {/* Storefront View */}
285
+ {activeTab === 'storefront' && (
286
+ <div className="flex flex-col gap-4">
287
+ {/* Category Filter Pills */}
288
+ <div className="flex items-center gap-2 flex-wrap pb-1 border-b border-ink-black/10">
289
+ <span className="font-arcade text-[9px] text-slate-600 uppercase font-bold mr-1">
290
+ Filter:
291
+ </span>
292
+ <button
293
+ type="button"
294
+ onClick={() => setStoreCategory('all')}
295
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${storeCategory === 'all'
296
+ ? 'bg-ink-black text-amber-300 shadow-[2px_2px_0px_0px_#1E293B]'
297
+ : 'bg-white text-slate-700 hover:bg-amber-100/50'
298
+ }`}
299
+ >
300
+ All Goods (12)
301
+ </button>
302
+ <button
303
+ type="button"
304
+ onClick={() => setStoreCategory('consumable')}
305
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${storeCategory === 'consumable'
306
+ ? 'bg-emerald-700 text-white shadow-[2px_2px_0px_0px_#1E293B]'
307
+ : 'bg-white text-emerald-800 hover:bg-emerald-50'
308
+ }`}
309
+ >
310
+ Consumables (4)
311
+ </button>
312
+ <button
313
+ type="button"
314
+ onClick={() => setStoreCategory('cosmetic')}
315
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${storeCategory === 'cosmetic'
316
+ ? 'bg-purple-700 text-white shadow-[2px_2px_0px_0px_#1E293B]'
317
+ : 'bg-white text-purple-800 hover:bg-purple-50'
318
+ }`}
319
+ >
320
+ Cosmetics (4)
321
+ </button>
322
+ <button
323
+ type="button"
324
+ onClick={() => setStoreCategory('companion_gift')}
325
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${storeCategory === 'companion_gift'
326
+ ? 'bg-amber-600 text-white shadow-[2px_2px_0px_0px_#1E293B]'
327
+ : 'bg-white text-amber-900 hover:bg-amber-50'
328
+ }`}
329
+ >
330
+ Gifts for Aurelia (4)
331
+ </button>
332
+ </div>
333
+
334
+ {/* Catalog Grid */}
335
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
336
+ {filteredCatalog.map(item => (
337
+ <StoreItemCard
338
+ key={item.id}
339
+ item={item}
340
+ playerGold={gold}
341
+ isPurchasing={loadingItemId === item.id}
342
+ onPurchase={handlePurchase}
343
+ onInspect={it => setInspectItem({ item: it })}
344
+ />
345
+ ))}
346
+ </div>
347
+ </div>
348
+ )}
349
+
350
+ {/* Adventurer's Vault View */}
351
+ {activeTab === 'vault' && (
352
+ <div className="flex flex-col gap-4">
353
+ {/* Category Filter Pills */}
354
+ <div className="flex items-center gap-2 flex-wrap pb-1 border-b border-ink-black/10">
355
+ <span className="font-arcade text-[9px] text-slate-600 uppercase font-bold mr-1">
356
+ Filter:
357
+ </span>
358
+ <button
359
+ type="button"
360
+ onClick={() => setVaultCategory('all')}
361
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${vaultCategory === 'all'
362
+ ? 'bg-ink-black text-amber-300 shadow-[2px_2px_0px_0px_#1E293B]'
363
+ : 'bg-white text-slate-700 hover:bg-amber-100/50'
364
+ }`}
365
+ >
366
+ All Satchel
367
+ </button>
368
+ <button
369
+ type="button"
370
+ onClick={() => setVaultCategory('consumable')}
371
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${vaultCategory === 'consumable'
372
+ ? 'bg-emerald-700 text-white shadow-[2px_2px_0px_0px_#1E293B]'
373
+ : 'bg-white text-emerald-800 hover:bg-emerald-50'
374
+ }`}
375
+ >
376
+ Consumables
377
+ </button>
378
+ <button
379
+ type="button"
380
+ onClick={() => setVaultCategory('cosmetic')}
381
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${vaultCategory === 'cosmetic'
382
+ ? 'bg-purple-700 text-white shadow-[2px_2px_0px_0px_#1E293B]'
383
+ : 'bg-white text-purple-800 hover:bg-purple-50'
384
+ }`}
385
+ >
386
+ Cosmetics
387
+ </button>
388
+ <button
389
+ type="button"
390
+ onClick={() => setVaultCategory('companion_gift')}
391
+ className={`font-arcade text-[10px] px-3 py-1 border-[2px] border-ink-black rounded cursor-pointer transition-all uppercase font-bold ${vaultCategory === 'companion_gift'
392
+ ? 'bg-amber-600 text-white shadow-[2px_2px_0px_0px_#1E293B]'
393
+ : 'bg-white text-amber-900 hover:bg-amber-50'
394
+ }`}
395
+ >
396
+ Gifts
397
+ </button>
398
+ </div>
399
+
400
+ {/* Empty State */}
401
+ {filteredInventory.length === 0 ? (
402
+ <div className="bg-[#FFFDF0] border-[3px] border-dashed border-ink-black/40 rounded-xl p-8 flex flex-col items-center justify-center text-center gap-3 my-6">
403
+ <div className="w-16 h-16 bg-amber-100/80 border-[2px] border-ink-black rounded-full flex items-center justify-center text-amber-800 mb-1">
404
+ <ShoppingBag className="w-8 h-8" />
405
+ </div>
406
+ <h4 className="font-headline-md font-bold text-lg text-ink-black">
407
+ Your satchel is empty. Visit the store to acquire items!
408
+ </h4>
409
+ <p className="font-serif italic text-sm text-slate-600 max-w-sm">
410
+ Complete daily reviews and coding challenges to earn gold coins, then browse the store.
411
+ </p>
412
+ <button
413
+ type="button"
414
+ onClick={() => setActiveTab('storefront')}
415
+ className="mt-2 font-arcade text-xs px-4 py-2.5 bg-amber-400 hover:bg-amber-300 text-ink-black border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider"
416
+ >
417
+ Browse Emporium
418
+ </button>
419
+ </div>
420
+ ) : (
421
+ /* Vault Grid */
422
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
423
+ {filteredInventory.map(({ invItem, catalog }) => (
424
+ <VaultItemCard
425
+ key={invItem.item_id}
426
+ inventoryItem={invItem}
427
+ catalogItem={catalog}
428
+ isLoading={loadingItemId === catalog.id}
429
+ onConsume={handleConsume}
430
+ onEquip={handleEquip}
431
+ onPresentGift={handlePresentGift}
432
+ onInspect={(cat, inv) => setInspectItem({ item: cat, inventoryItem: inv })}
433
+ />
434
+ ))}
435
+ </div>
436
+ )}
437
+ </div>
438
+ )}
439
+ </div>
440
+
441
+ {/* Floating Toast Alerts */}
442
+ {toasts.length > 0 && (
443
+ <div className="absolute bottom-4 right-4 z-40 flex flex-col gap-2 max-w-sm w-full pointer-events-none">
444
+ {toasts.map(toast => (
445
+ <div
446
+ key={toast.id}
447
+ className={`pointer-events-auto p-3 border-[2px] border-ink-black rounded shadow-[3px_3px_0px_0px_#1E293B] flex items-start justify-between gap-2 text-xs font-sans animate-in slide-in-from-bottom-2 duration-150 ${toast.type === 'success'
448
+ ? 'bg-emerald-100 text-emerald-950 border-emerald-900'
449
+ : toast.type === 'error'
450
+ ? 'bg-rose-100 text-rose-950 border-rose-900'
451
+ : 'bg-amber-100 text-amber-950 border-amber-900'
452
+ }`}
453
+ >
454
+ <div className="flex items-center gap-2">
455
+ {toast.type === 'success' ? (
456
+ <CheckCircle2 className="w-4 h-4 text-emerald-700 shrink-0" />
457
+ ) : toast.type === 'error' ? (
458
+ <AlertCircle className="w-4 h-4 text-rose-700 shrink-0" />
459
+ ) : (
460
+ <Sparkles className="w-4 h-4 text-amber-700 shrink-0" />
461
+ )}
462
+ <span className="font-semibold">{toast.message}</span>
463
+ </div>
464
+ <button
465
+ type="button"
466
+ onClick={() => removeToast(toast.id)}
467
+ className="p-0.5 hover:bg-black/10 rounded cursor-pointer shrink-0"
468
+ >
469
+ <X className="w-3.5 h-3.5" />
470
+ </button>
471
+ </div>
472
+ ))}
473
+ </div>
474
+ )}
475
+
476
+ {/* Item Lore Inspection Modal */}
477
+ {inspectItem && (
478
+ <ItemLoreModal
479
+ item={inspectItem.item}
480
+ ownedQuantity={inspectItem.inventoryItem?.quantity}
481
+ playerGold={gold}
482
+ isEquipped={inspectItem.inventoryItem?.is_equipped}
483
+ isActionLoading={loadingItemId === inspectItem.item.id}
484
+ onClose={() => setInspectItem(null)}
485
+ onPurchase={activeTab === 'storefront' ? handlePurchase : undefined}
486
+ onAction={
487
+ activeTab === 'vault' && inspectItem.inventoryItem
488
+ ? it => {
489
+ if (it.category === 'consumable') handleConsume(it);
490
+ else if (it.category === 'cosmetic')
491
+ handleEquip(it, !inspectItem.inventoryItem?.is_equipped);
492
+ else if (it.category === 'companion_gift') handlePresentGift(it);
493
+ }
494
+ : undefined
495
+ }
496
+ actionLabel={
497
+ inspectItem.item.category === 'consumable'
498
+ ? 'Consume'
499
+ : inspectItem.item.category === 'cosmetic'
500
+ ? inspectItem.inventoryItem?.is_equipped
501
+ ? 'Unequip'
502
+ : 'Equip'
503
+ : 'Present Gift'
504
+ }
505
+ />
506
+ )}
507
+
508
+ {/* Gift Celebration Dialogue Modal */}
509
+ {giftCelebration && (
510
+ <GiftPresentationModal
511
+ giftItem={giftCelebration.item}
512
+ reaction={giftCelebration.reaction}
513
+ onClose={() => setGiftCelebration(null)}
514
+ onOpenCompanion={onOpenCompanion}
515
+ />
516
+ )}
517
+ </div>
518
+ );
519
+ };
520
+
521
+ export default StoreWindow;
algospaced-ui/src/components/store/VaultItemCard.tsx ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { Eye, Check, Heart, Sparkles, ShieldAlert } from 'lucide-react';
3
+ import type { InventoryItem, StoreItem } from '../../types/storeTypes';
4
+ import { ItemIcon } from './ItemIcon';
5
+
6
+ interface VaultItemCardProps {
7
+ inventoryItem: InventoryItem;
8
+ catalogItem: StoreItem;
9
+ isLoading: boolean;
10
+ onConsume: (catalogItem: StoreItem) => void;
11
+ onEquip: (catalogItem: StoreItem, isEquipped: boolean) => void;
12
+ onPresentGift: (catalogItem: StoreItem) => void;
13
+ onInspect: (catalogItem: StoreItem, inventoryItem: InventoryItem) => void;
14
+ }
15
+
16
+ export const VaultItemCard: React.FC<VaultItemCardProps> = ({
17
+ inventoryItem,
18
+ catalogItem,
19
+ isLoading,
20
+ onConsume,
21
+ onEquip,
22
+ onPresentGift,
23
+ onInspect
24
+ }) => {
25
+ const isEquipped = !!inventoryItem.is_equipped;
26
+
27
+ const categoryColor =
28
+ catalogItem.category === 'consumable'
29
+ ? 'bg-emerald-100 text-emerald-800 border-emerald-700'
30
+ : catalogItem.category === 'cosmetic'
31
+ ? 'bg-purple-100 text-purple-800 border-purple-700'
32
+ : 'bg-amber-100 text-amber-900 border-amber-700';
33
+
34
+ const categoryLabel =
35
+ catalogItem.category === 'consumable'
36
+ ? 'Consumable'
37
+ : catalogItem.category === 'cosmetic'
38
+ ? 'Cosmetic'
39
+ : 'Companion Gift';
40
+
41
+ return (
42
+ <div
43
+ className={`bg-[#FFFDF0] border-[3px] rounded-lg p-4 shadow-[4px_4px_0px_0px_#1E293B] flex flex-col justify-between transition-all ${
44
+ isEquipped ? 'border-purple-600 bg-purple-50/40 ring-2 ring-purple-500/40' : 'border-ink-black'
45
+ }`}
46
+ >
47
+ <div>
48
+ {/* Top Header: Category, Quantity Badge, Inspect */}
49
+ <div className="flex items-center justify-between gap-2 mb-3">
50
+ <div className="flex items-center gap-1.5">
51
+ <span
52
+ className={`font-arcade text-[8px] px-2 py-0.5 border rounded uppercase font-bold tracking-wider ${categoryColor}`}
53
+ >
54
+ {categoryLabel}
55
+ </span>
56
+ {isEquipped && (
57
+ <span className="font-arcade text-[8px] bg-purple-600 text-white px-1.5 py-0.5 rounded border border-purple-800 font-bold uppercase tracking-wider flex items-center gap-0.5">
58
+ <Check className="w-2.5 h-2.5" />
59
+ Equipped
60
+ </span>
61
+ )}
62
+ </div>
63
+
64
+ <div className="flex items-center gap-1.5">
65
+ {inventoryItem.quantity > 1 && (
66
+ <span className="font-arcade text-[9px] bg-ink-black text-amber-300 px-2 py-0.5 rounded border border-amber-400 font-extrabold shadow-[1px_1px_0_0_#1E293B]">
67
+ x{inventoryItem.quantity}
68
+ </span>
69
+ )}
70
+ <button
71
+ type="button"
72
+ onClick={() => onInspect(catalogItem, inventoryItem)}
73
+ className="p-1 hover:bg-amber-100 text-slate-600 hover:text-ink-black rounded transition-colors cursor-pointer"
74
+ title="Inspect item lore"
75
+ >
76
+ <Eye className="w-3.5 h-3.5" />
77
+ </button>
78
+ </div>
79
+ </div>
80
+
81
+ {/* Item Icon & Title */}
82
+ <div className="flex items-start gap-3 mb-3">
83
+ <div className="w-12 h-12 bg-white border-[2px] border-ink-black rounded flex items-center justify-center shrink-0 shadow-[2px_2px_0px_0px_#1E293B]">
84
+ <ItemIcon name={catalogItem.icon} className="w-6 h-6 text-amber-700" />
85
+ </div>
86
+ <div className="min-w-0 flex-1">
87
+ <h4
88
+ onClick={() => onInspect(catalogItem, inventoryItem)}
89
+ className="font-headline-md font-bold text-sm text-ink-black leading-snug cursor-pointer hover:text-amber-800 truncate"
90
+ title={catalogItem.name}
91
+ >
92
+ {catalogItem.name}
93
+ </h4>
94
+ <span className="text-[11px] text-slate-600 font-mono">
95
+ Count: {inventoryItem.quantity}
96
+ </span>
97
+ </div>
98
+ </div>
99
+
100
+ {/* Lore Snippet */}
101
+ <p className="font-serif italic text-xs text-slate-600 line-clamp-2 mb-4 leading-relaxed">
102
+ &ldquo;{catalogItem.lore}&rdquo;
103
+ </p>
104
+ </div>
105
+
106
+ {/* Context-Sensitive Action Buttons */}
107
+ <div className="pt-2 border-t border-ink-black/10 flex items-center gap-2">
108
+ {catalogItem.category === 'consumable' && (
109
+ <button
110
+ type="button"
111
+ disabled={isLoading}
112
+ onClick={() => onConsume(catalogItem)}
113
+ className="w-full font-arcade text-[10px] py-2 px-3 bg-grass-green hover:bg-emerald-400 text-ink-black border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5"
114
+ >
115
+ <ShieldAlert className="w-3 h-3" />
116
+ <span>{isLoading ? 'Consuming...' : 'Consume'}</span>
117
+ </button>
118
+ )}
119
+
120
+ {catalogItem.category === 'cosmetic' && (
121
+ <button
122
+ type="button"
123
+ disabled={isLoading}
124
+ onClick={() => onEquip(catalogItem, !isEquipped)}
125
+ className={`w-full font-arcade text-[10px] py-2 px-3 border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5 ${
126
+ isEquipped
127
+ ? 'bg-slate-700 hover:bg-slate-800 text-white'
128
+ : 'bg-purple-500 hover:bg-purple-600 text-white'
129
+ }`}
130
+ >
131
+ <Sparkles className="w-3 h-3" />
132
+ <span>{isLoading ? 'Updating...' : isEquipped ? 'Unequip' : 'Equip'}</span>
133
+ </button>
134
+ )}
135
+
136
+ {catalogItem.category === 'companion_gift' && (
137
+ <button
138
+ type="button"
139
+ disabled={isLoading}
140
+ onClick={() => onPresentGift(catalogItem)}
141
+ className="w-full font-arcade text-[10px] py-2 px-3 bg-rose-500 hover:bg-rose-600 text-white border-[2px] border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase font-bold tracking-wider transition-all flex items-center justify-center gap-1.5"
142
+ >
143
+ <Heart className="w-3 h-3 fill-white" />
144
+ <span>{isLoading ? 'Presenting...' : 'Present Gift'}</span>
145
+ </button>
146
+ )}
147
+ </div>
148
+ </div>
149
+ );
150
+ };
algospaced-ui/src/components/store/giftReactions.ts ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface GiftReactionData {
2
+ emotion: 'smiling_warmly' | 'excited_expression';
3
+ title: string;
4
+ dialogue: string;
5
+ bondBonus: number;
6
+ }
7
+
8
+ export const DEFAULT_GIFT_REACTION: GiftReactionData = {
9
+ emotion: 'smiling_warmly',
10
+ title: 'Gift Presented',
11
+ bondBonus: 10,
12
+ dialogue:
13
+ "Aurelia receives your token of companionship with shining eyes and genuine gratitude."
14
+ };
15
+
16
+ export const AURELIA_GIFT_REACTIONS: Record<string, GiftReactionData> = {
17
+ gift_starflower_tea: {
18
+ emotion: 'smiling_warmly',
19
+ title: 'Starflower Tea Presented',
20
+ bondBonus: 15,
21
+ dialogue:
22
+ "Aurelia cradles the warm steaming cup in both hands, breathing in the herbal aroma... 'Thank you, my friend. The starflower warmth eases the tightness in my chest and banishes the mountain chill.'"
23
+ },
24
+ gift_silk_shawl: {
25
+ emotion: 'smiling_warmly',
26
+ title: 'Silver Shawl Presented',
27
+ bondBonus: 30,
28
+ dialogue:
29
+ "Aurelia softly drapes the delicate silver-stitched shawl around her shoulders... 'It is so gentle and warm. Wrapped in this, I feel shielded and safe on the trail.'"
30
+ },
31
+ gift_music_box: {
32
+ emotion: 'excited_expression',
33
+ title: 'Celestial Music Box Bestowed',
34
+ bondBonus: 60,
35
+ dialogue:
36
+ "Aurelia winds the small brass key with glistening eyes as the delicate chimes ring out... 'This melody... my mother used to hum this in the royal rose gardens. You have returned a piece of my home to me.'"
37
+ },
38
+ gift_elixir_pendant: {
39
+ emotion: 'excited_expression',
40
+ title: 'Soulbound Pendant Entrusted',
41
+ bondBonus: 100,
42
+ dialogue:
43
+ "Aurelia gazes at the glowing Elixir pendant in disbelief, tears shining in her eyes... 'The Elixir... you would entrust such a holy treasure to me? Our fates are bound together now, my champion. Until the Spire's peak!'"
44
+ }
45
+ };
algospaced-ui/src/data/storeCatalog.ts ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { StoreItem } from '../types/storeTypes';
2
+
3
+ /**
4
+ * Authoritative 12-item catalog for AlgoSpaced OS ("Merchant's Emporium").
5
+ * Partitioned evenly into 3 categories: Study Consumables, Desktop Cosmetics, and Companion Gifts.
6
+ */
7
+ export const STORE_CATALOG: StoreItem[] = [
8
+ // 1. Study Consumables
9
+ {
10
+ id: 'consumable_streak_freeze',
11
+ name: 'Elixir of Frozen Time',
12
+ category: 'consumable',
13
+ price: 150,
14
+ lore: 'A crystalline phial filled with the enchanted sands of Chronos, arresting the relentless march of time when darkness falls.',
15
+ icon: 'ShieldAlert',
16
+ effect_type: 'streak_freeze',
17
+ effect_payload: { freeze_charges: 1 }
18
+ },
19
+ {
20
+ id: 'consumable_hint_scroll',
21
+ name: "Archivist's Hint Scroll",
22
+ category: 'consumable',
23
+ price: 75,
24
+ lore: 'An illuminated vellum scroll penned by royal archivists, unravelling algorithmic intuition and pattern landmarks.',
25
+ icon: 'Scroll',
26
+ effect_type: 'hint_scroll',
27
+ effect_payload: { hint_tokens: 1 }
28
+ },
29
+ {
30
+ id: 'consumable_focus_draught',
31
+ name: 'Potion of Keen Insight',
32
+ category: 'consumable',
33
+ price: 100,
34
+ lore: 'A sparkling azure potion that heightens mental acuity and doubles gold earned on your next 3 completed review cards.',
35
+ icon: 'Sparkles',
36
+ effect_type: 'focus_boost',
37
+ effect_payload: { multiplier: 2, reviews_remaining: 3 }
38
+ },
39
+ {
40
+ id: 'consumable_campfire_stew',
41
+ name: "Hearty Wayfarer's Stew",
42
+ category: 'consumable',
43
+ price: 50,
44
+ lore: 'A steaming bowl of herbal root stew prepared over the campfire coals, dispelling mental fatigue and restoring composure.',
45
+ icon: 'Flame',
46
+ effect_type: 'focus_boost',
47
+ effect_payload: { fatigue_reset: true }
48
+ },
49
+
50
+ // 2. Desktop Cosmetics
51
+ {
52
+ id: 'cosmetic_crt_scanlines',
53
+ name: 'Arcade CRT Phosphor Shader',
54
+ category: 'cosmetic',
55
+ price: 200,
56
+ lore: 'A retro cathode-ray raster filter with nostalgic scanlines, curved CRT edge vignette, and vintage phosphor bloom.',
57
+ icon: 'Tv',
58
+ effect_type: 'crt_theme',
59
+ effect_payload: { overlay_class: 'crt-scanlines-active' }
60
+ },
61
+ {
62
+ id: 'cosmetic_theme_amber',
63
+ name: 'Amber Campfire Theme',
64
+ category: 'cosmetic',
65
+ price: 250,
66
+ lore: 'A cozy UI palette featuring warm ember golds, toasted parchment backgrounds, and rustic brass window borders.',
67
+ icon: 'Flame',
68
+ effect_type: 'palette_theme',
69
+ effect_payload: { theme_id: 'amber' }
70
+ },
71
+ {
72
+ id: 'cosmetic_theme_cyber',
73
+ name: 'Synthwave Spire Theme',
74
+ category: 'cosmetic',
75
+ price: 300,
76
+ lore: 'Electric neon magenta and cyan hues inspired by the luminous power conduits pulsing beneath the ancient tower.',
77
+ icon: 'Cpu',
78
+ effect_type: 'palette_theme',
79
+ effect_payload: { theme_id: 'cyber' }
80
+ },
81
+ {
82
+ id: 'cosmetic_wallpaper_sanctuary',
83
+ name: 'Sanctuary of the Elixir',
84
+ category: 'cosmetic',
85
+ price: 350,
86
+ lore: 'A high-resolution landscape of the distant Ancient Tower glowing beneath the celestial northern aurora.',
87
+ icon: 'Image',
88
+ effect_type: 'wallpaper',
89
+ effect_payload: { wallpaper_url: '/wallpapers/sanctuary_spire.webp' }
90
+ },
91
+
92
+ // 3. Companion Gifts
93
+ {
94
+ id: 'gift_starflower_tea',
95
+ name: 'Soothing Starflower Tea',
96
+ category: 'companion_gift',
97
+ price: 80,
98
+ lore: 'Delicate white alpine blossoms harvested from mountain ridges, brewed into a soothing remedy that cools high fevers.',
99
+ icon: 'Flower2',
100
+ effect_type: 'aurelia_gift',
101
+ effect_payload: { bond_points: 15, emotion: 'smiling_warmly' }
102
+ },
103
+ {
104
+ id: 'gift_silk_shawl',
105
+ name: 'Embroidered Silver Shawl',
106
+ category: 'companion_gift',
107
+ price: 150,
108
+ lore: 'A lightweight yet luxuriously warm shawl woven from palace silk and lined with silver thread to fend off freezing winds.',
109
+ icon: 'Shirt',
110
+ effect_type: 'aurelia_gift',
111
+ effect_payload: { bond_points: 30, emotion: 'smiling_warmly' }
112
+ },
113
+ {
114
+ id: 'gift_music_box',
115
+ name: 'Celestial Music Box',
116
+ category: 'companion_gift',
117
+ price: 300,
118
+ lore: 'A miniature brass music box that softly plays the lullaby of her childhood palace gardens.',
119
+ icon: 'Music',
120
+ effect_type: 'aurelia_gift',
121
+ effect_payload: { bond_points: 60, emotion: 'excited_expression' }
122
+ },
123
+ {
124
+ id: 'gift_elixir_pendant',
125
+ name: 'Glimmer of the Sanctuary',
126
+ category: 'companion_gift',
127
+ price: 500,
128
+ lore: 'A carved crystalline teardrop imbued with starlight that brings radiant hope for her cure.',
129
+ icon: 'Gem',
130
+ effect_type: 'aurelia_gift',
131
+ effect_payload: { bond_points: 100, emotion: 'excited_expression' }
132
+ }
133
+ ];
134
+
135
+ export const STORE_CATALOG_MAP: Record<string, StoreItem> = STORE_CATALOG.reduce<Record<string, StoreItem>>(
136
+ (acc, item) => {
137
+ acc[item.id] = item;
138
+ return acc;
139
+ },
140
+ {}
141
+ );
142
+
143
+ // Catalog aliases matching backend routers/store.py
144
+ const STORE_ALIASES: Record<string, string> = {
145
+ streak_freeze: 'consumable_streak_freeze',
146
+ hint_scroll: 'consumable_hint_scroll',
147
+ focus_potion: 'consumable_focus_draught',
148
+ focus_draught: 'consumable_focus_draught',
149
+ coffee_brew: 'consumable_campfire_stew',
150
+ campfire_stew: 'consumable_campfire_stew',
151
+ crt_amber_phosphor: 'cosmetic_crt_scanlines',
152
+ crt_scanlines: 'cosmetic_crt_scanlines',
153
+ theme_amber: 'cosmetic_theme_amber',
154
+ theme_cyber: 'cosmetic_theme_cyber',
155
+ theme_fantasy_dungeon: 'cosmetic_theme_cyber',
156
+ wallpaper_royal_library: 'cosmetic_wallpaper_sanctuary',
157
+ wallpaper_celestial_citadel: 'cosmetic_wallpaper_sanctuary',
158
+ wallpaper_sanctuary: 'cosmetic_wallpaper_sanctuary',
159
+ gift_royal_tea: 'gift_starflower_tea',
160
+ starflower_tea: 'gift_starflower_tea',
161
+ gift_quill: 'gift_silk_shawl',
162
+ silk_shawl: 'gift_silk_shawl',
163
+ music_box: 'gift_music_box',
164
+ gift_celestial_globe: 'gift_elixir_pendant',
165
+ elixir_pendant: 'gift_elixir_pendant'
166
+ };
167
+
168
+ for (const [aliasKey, targetId] of Object.entries(STORE_ALIASES)) {
169
+ if (STORE_CATALOG_MAP[targetId] && !STORE_CATALOG_MAP[aliasKey]) {
170
+ STORE_CATALOG_MAP[aliasKey] = STORE_CATALOG_MAP[targetId];
171
+ }
172
+ }
173
+
174
+ export function getStoreItem(id: string): StoreItem | undefined {
175
+ return STORE_CATALOG_MAP[id];
176
+ }
177
+
178
+ export function filterCatalogByCategory(category: string): StoreItem[] {
179
+ if (!category || category === 'all') {
180
+ return STORE_CATALOG;
181
+ }
182
+ return STORE_CATALOG.filter(item => item.category === category);
183
+ }
algospaced-ui/src/features/companion/store/useCompanionStore.ts CHANGED
@@ -44,6 +44,7 @@ export interface CompanionStoreState {
44
  unlockedMilestones: number[];
45
  unlockedLetters: MilestoneLetter[];
46
  spireChronicles: DiaryEntry[];
 
47
  bondTier: BondTier;
48
  currentRhythm: TowerRhythmState;
49
  currentActivity: string;
@@ -197,9 +198,9 @@ export function retrieveEpisodicMemories(
197
  return retrievedSummaries;
198
  }
199
 
200
- function calculateBondTier(messageCount: number): BondTier {
201
- if (messageCount >= 50) return 'Soulbound Confidante';
202
- if (messageCount >= 10) return 'Trusted Ally';
203
  return 'Acquaintance';
204
  }
205
 
@@ -317,6 +318,7 @@ function loadInitialState(): CompanionStoreState {
317
  })
318
  : [defaultInitialTurn];
319
  const userMessageCount = transcript.filter((t: ChatTurn) => t.sender === 'user').length;
 
320
 
321
  return {
322
  transcript,
@@ -337,7 +339,8 @@ function loadInitialState(): CompanionStoreState {
337
  unlockedMilestones: Array.isArray(parsed.unlockedMilestones) ? parsed.unlockedMilestones : [0],
338
  unlockedLetters: Array.isArray(parsed.unlockedLetters) ? parsed.unlockedLetters : [],
339
  spireChronicles: Array.isArray(parsed.spireChronicles) ? parsed.spireChronicles : [],
340
- bondTier: calculateBondTier(userMessageCount),
 
341
  currentRhythm: rhythm.state,
342
  currentActivity: rhythm.activity,
343
  companionSettings: { ...DEFAULT_SETTINGS, ...(parsed.companionSettings || {}) },
@@ -364,6 +367,7 @@ function loadInitialState(): CompanionStoreState {
364
  unlockedMilestones: [0],
365
  unlockedLetters: [],
366
  spireChronicles: [],
 
367
  bondTier: 'Acquaintance',
368
  currentRhythm: rhythm.state,
369
  currentActivity: rhythm.activity,
@@ -391,6 +395,7 @@ function emitChange() {
391
  unlockedMilestones: currentState.unlockedMilestones,
392
  unlockedLetters: currentState.unlockedLetters,
393
  spireChronicles: currentState.spireChronicles.slice(-30),
 
394
  companionSettings: currentState.companionSettings,
395
  recentToolTelemetry: (currentState.recentToolTelemetry || []).slice(-30),
396
  };
@@ -543,7 +548,7 @@ export const companionStore = {
543
 
544
  const newTranscript = [...currentState.transcript, userTurn];
545
  const userMessageCount = newTranscript.filter((t) => t.sender === 'user').length;
546
- const newBondTier = calculateBondTier(userMessageCount);
547
 
548
  const streamingTurnId = `princess-${Date.now()}`;
549
  const streamingPrincessTurn: ChatTurn = {
@@ -982,6 +987,146 @@ export const companionStore = {
982
  console.warn('[CompanionStore] Sync with backend journey failed:', err);
983
  }
984
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
  };
986
 
987
  /**
 
44
  unlockedMilestones: number[];
45
  unlockedLetters: MilestoneLetter[];
46
  spireChronicles: DiaryEntry[];
47
+ bondPoints: number;
48
  bondTier: BondTier;
49
  currentRhythm: TowerRhythmState;
50
  currentActivity: string;
 
198
  return retrievedSummaries;
199
  }
200
 
201
+ export function calculateBondTier(bondPoints: number = 0, messageCount: number = 0): BondTier {
202
+ if (bondPoints >= 100 || messageCount >= 50) return 'Soulbound Confidante';
203
+ if (bondPoints >= 40 || messageCount >= 10) return 'Trusted Ally';
204
  return 'Acquaintance';
205
  }
206
 
 
318
  })
319
  : [defaultInitialTurn];
320
  const userMessageCount = transcript.filter((t: ChatTurn) => t.sender === 'user').length;
321
+ const bondPoints = Number(parsed.bondPoints ?? 0);
322
 
323
  return {
324
  transcript,
 
339
  unlockedMilestones: Array.isArray(parsed.unlockedMilestones) ? parsed.unlockedMilestones : [0],
340
  unlockedLetters: Array.isArray(parsed.unlockedLetters) ? parsed.unlockedLetters : [],
341
  spireChronicles: Array.isArray(parsed.spireChronicles) ? parsed.spireChronicles : [],
342
+ bondPoints,
343
+ bondTier: calculateBondTier(bondPoints, userMessageCount),
344
  currentRhythm: rhythm.state,
345
  currentActivity: rhythm.activity,
346
  companionSettings: { ...DEFAULT_SETTINGS, ...(parsed.companionSettings || {}) },
 
367
  unlockedMilestones: [0],
368
  unlockedLetters: [],
369
  spireChronicles: [],
370
+ bondPoints: 0,
371
  bondTier: 'Acquaintance',
372
  currentRhythm: rhythm.state,
373
  currentActivity: rhythm.activity,
 
395
  unlockedMilestones: currentState.unlockedMilestones,
396
  unlockedLetters: currentState.unlockedLetters,
397
  spireChronicles: currentState.spireChronicles.slice(-30),
398
+ bondPoints: currentState.bondPoints,
399
  companionSettings: currentState.companionSettings,
400
  recentToolTelemetry: (currentState.recentToolTelemetry || []).slice(-30),
401
  };
 
548
 
549
  const newTranscript = [...currentState.transcript, userTurn];
550
  const userMessageCount = newTranscript.filter((t) => t.sender === 'user').length;
551
+ const newBondTier = calculateBondTier(currentState.bondPoints, userMessageCount);
552
 
553
  const streamingTurnId = `princess-${Date.now()}`;
554
  const streamingPrincessTurn: ChatTurn = {
 
987
  console.warn('[CompanionStore] Sync with backend journey failed:', err);
988
  }
989
  },
990
+
991
+ /**
992
+ * Presents a gift to Princess Aurelia, adding bond points, updating bond tier,
993
+ * setting emotion, and adding grateful dialogue and memory events.
994
+ */
995
+ presentGift: (giftItem: {
996
+ id: string;
997
+ name: string;
998
+ price?: number;
999
+ effect_payload?: Record<string, unknown>;
1000
+ }) => {
1001
+ // 1. Determine bond points to add
1002
+ let bondBonus: number;
1003
+ if (giftItem.effect_payload?.bond_points && typeof giftItem.effect_payload.bond_points === 'number') {
1004
+ bondBonus = giftItem.effect_payload.bond_points;
1005
+ } else {
1006
+ const GIFT_MATRIX: Record<string, number> = {
1007
+ gift_starflower_tea: 15,
1008
+ starflower_tea: 15,
1009
+ gift_silk_shawl: 30,
1010
+ silk_shawl: 30,
1011
+ gift_music_box: 60,
1012
+ music_box: 60,
1013
+ gift_elixir_pendant: 100,
1014
+ elixir_pendant: 100,
1015
+ };
1016
+ bondBonus = GIFT_MATRIX[giftItem.id] || 10;
1017
+ }
1018
+
1019
+ // 2. Determine emotion & appreciation dialogue
1020
+ const DIALOGUE_MATRIX: Record<string, { emotion: PrincessEmotion; dialogue: string }> = {
1021
+ gift_starflower_tea: {
1022
+ emotion: 'smiling_warmly',
1023
+ dialogue:
1024
+ "Aurelia cradles the warm steaming cup in both hands, breathing in the herbal aroma... 'Thank you, my friend. The starflower warmth eases the tightness in my chest and banishes the mountain chill. Your thoughtfulness gives me strength for the miles ahead.'",
1025
+ },
1026
+ starflower_tea: {
1027
+ emotion: 'smiling_warmly',
1028
+ dialogue:
1029
+ "Aurelia cradles the warm steaming cup in both hands, breathing in the herbal aroma... 'Thank you, my friend. The starflower warmth eases the tightness in my chest and banishes the mountain chill. Your thoughtfulness gives me strength for the miles ahead.'",
1030
+ },
1031
+ gift_silk_shawl: {
1032
+ emotion: 'smiling_warmly',
1033
+ dialogue:
1034
+ "Aurelia softly drapes the delicate silver-stitched shawl around her shoulders... 'It is so gentle and warm. The northern winds felt biting today, but wrapped in this, I feel shielded and safe. Thank you for always watching over me on this trail.'",
1035
+ },
1036
+ silk_shawl: {
1037
+ emotion: 'smiling_warmly',
1038
+ dialogue:
1039
+ "Aurelia softly drapes the delicate silver-stitched shawl around her shoulders... 'It is so gentle and warm. The northern winds felt biting today, but wrapped in this, I feel shielded and safe. Thank you for always watching over me on this trail.'",
1040
+ },
1041
+ gift_music_box: {
1042
+ emotion: 'excited_expression',
1043
+ dialogue:
1044
+ "Aurelia winds the small brass key with glistening eyes as the delicate chimes ring out... 'This melody... my mother used to hum this in the royal rose gardens when I was small. I thought that melody was lost forever. You have returned a piece of my home to me.'",
1045
+ },
1046
+ music_box: {
1047
+ emotion: 'excited_expression',
1048
+ dialogue:
1049
+ "Aurelia winds the small brass key with glistening eyes as the delicate chimes ring out... 'This melody... my mother used to hum this in the royal rose gardens when I was small. I thought that melody was lost forever. You have returned a piece of my home to me.'",
1050
+ },
1051
+ gift_elixir_pendant: {
1052
+ emotion: 'excited_expression',
1053
+ dialogue:
1054
+ "The crystal teardrop pulses with a soft celestial glow against her palm... 'A fragment of the Sanctuary itself! Feeling its radiance, I know in my heart we will reach the Tower and find the Elixir in time. Whatever trials await us, I am honored to journey at your side, my dearest companion.'",
1055
+ },
1056
+ elixir_pendant: {
1057
+ emotion: 'excited_expression',
1058
+ dialogue:
1059
+ "The crystal teardrop pulses with a soft celestial glow against her palm... 'A fragment of the Sanctuary itself! Feeling its radiance, I know in my heart we will reach the Tower and find the Elixir in time. Whatever trials await us, I am honored to journey at your side, my dearest companion.'",
1060
+ },
1061
+ };
1062
+
1063
+ const reaction = DIALOGUE_MATRIX[giftItem.id] || {
1064
+ emotion: (giftItem.effect_payload?.emotion as PrincessEmotion) || 'smiling_warmly',
1065
+ dialogue: `Aurelia smiles warmly and receives ${giftItem.name} with deep gratitude: 'Thank you for your kindness, my champion. Having your support keeps hope alive on this road.'`,
1066
+ };
1067
+
1068
+ const newBondPoints = currentState.bondPoints + bondBonus;
1069
+ const userMessageCount = currentState.transcript.filter((t) => t.sender === 'user').length;
1070
+ const newBondTier = calculateBondTier(newBondPoints, userMessageCount);
1071
+
1072
+ // 3. Add appreciative thank-you ChatTurn to transcript
1073
+ const thankYouTurn: ChatTurn = {
1074
+ id: `gift-turn-${Date.now()}`,
1075
+ sender: 'princess',
1076
+ text: reaction.dialogue,
1077
+ emotion: reaction.emotion,
1078
+ timestamp: Date.now(),
1079
+ provider: 'Companion Gift Offering',
1080
+ choiceSuggestions: [
1081
+ 'You deserve this and so much more, Aurelia.',
1082
+ 'We will reach the Ancient Tower together.',
1083
+ 'Drink some warm tea and rest a moment.',
1084
+ ],
1085
+ };
1086
+
1087
+ // 4. Record episodic event node
1088
+ const episodicNode: EpisodicEventNode = {
1089
+ id: `ev-gift-${Date.now()}`,
1090
+ timestamp: Date.now(),
1091
+ eventType: 'personal_share',
1092
+ title: `Gift Bestowed: ${giftItem.name}`,
1093
+ description: `Presented ${giftItem.name} to Princess Aurelia (+${bondBonus} Bond). She was deeply touched: "${reaction.dialogue.slice(0, 80)}..."`,
1094
+ emotionalTone: reaction.emotion,
1095
+ };
1096
+
1097
+ // 5. Add to Diary Entry in chronicles
1098
+ const diaryEntry: DiaryEntry = {
1099
+ id: `diary-gift-${Date.now()}`,
1100
+ timestamp: Date.now(),
1101
+ floor: currentState.currentFloor,
1102
+ text: `Gift received: ${giftItem.name}. "${reaction.dialogue}"`,
1103
+ };
1104
+
1105
+ updateState({
1106
+ bondPoints: newBondPoints,
1107
+ bondTier: newBondTier,
1108
+ activeEmotion: reaction.emotion,
1109
+ transcript: [...currentState.transcript, thankYouTurn],
1110
+ episodicEvents: [episodicNode, ...currentState.episodicEvents].slice(0, 40),
1111
+ spireChronicles: [diaryEntry, ...currentState.spireChronicles],
1112
+ });
1113
+
1114
+ return {
1115
+ success: true,
1116
+ appreciationDialogue: reaction.dialogue,
1117
+ bondPointsAdded: bondBonus,
1118
+ newBondTier,
1119
+ newBondPoints,
1120
+ };
1121
+ },
1122
+
1123
+ /**
1124
+ * Resets companion state back to initial defaults (used for testing and session resets).
1125
+ */
1126
+ reset: () => {
1127
+ currentState = loadInitialState();
1128
+ emitChange();
1129
+ },
1130
  };
1131
 
1132
  /**
algospaced-ui/src/features/companion/types.ts CHANGED
@@ -179,3 +179,18 @@ export interface CompanionTelemetryStats {
179
  recent_events: CompanionTelemetryRecord[];
180
  }
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  recent_events: CompanionTelemetryRecord[];
180
  }
181
 
182
+ export interface GiftItemInput {
183
+ id: string;
184
+ name: string;
185
+ price?: number;
186
+ effect_payload?: Record<string, unknown>;
187
+ }
188
+
189
+ export interface PresentGiftResult {
190
+ success: boolean;
191
+ appreciationDialogue: string;
192
+ bondPointsAdded: number;
193
+ newBondTier: BondTier;
194
+ newBondPoints: number;
195
+ }
196
+
algospaced-ui/src/hooks/useReviewQueue.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
  import { activateCatalogProblem } from '../services/reviewService';
11
  import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
12
  import type { ReviewItem } from '../types/reviewTypes';
 
13
 
14
  function getEffectiveUid(currentUid?: string): string {
15
  if (currentUid && currentUid !== 'sandbox-user-id') {
@@ -328,6 +329,10 @@ export function useReviewQueue({
328
  });
329
 
330
  if (res.ok) {
 
 
 
 
331
  // Trigger Princess Companion reaction & tower floor advance
332
  const probName = activeReview?.problems?.name || '';
333
  const probPattern = activeReview?.problems?.pattern || '';
 
10
  import { activateCatalogProblem } from '../services/reviewService';
11
  import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
12
  import type { ReviewItem } from '../types/reviewTypes';
13
+ import { useEconomyStore } from '../stores/useEconomyStore';
14
 
15
  function getEffectiveUid(currentUid?: string): string {
16
  if (currentUid && currentUid !== 'sandbox-user-id') {
 
329
  });
330
 
331
  if (res.ok) {
332
+ // Award player gold based on rating: +5g Again (1), +15g Hard (2), +25g Good (3), +35g Easy (4)
333
+ const goldAward = rating === 4 ? 35 : rating === 3 ? 25 : rating === 2 ? 15 : 5;
334
+ useEconomyStore.getState().awardGold(goldAward, `Completed review rating ${rating}`);
335
+
336
  // Trigger Princess Companion reaction & tower floor advance
337
  const probName = activeReview?.problems?.name || '';
338
  const probPattern = activeReview?.problems?.pattern || '';
algospaced-ui/src/hooks/useWallpaper.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { useState, useCallback } from 'react';
 
 
2
 
3
  const DEFAULT_WALLPAPER = '/wallpapers/default.webp';
4
 
@@ -12,6 +14,29 @@ export function useWallpaper() {
12
  return saved;
13
  });
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  const compressAndSaveWallpaper = useCallback((file: File) => {
16
  const reader = new FileReader();
17
  reader.onload = (event) => {
 
1
+ import { useState, useCallback, useEffect } from 'react';
2
+ import { useEconomyStore } from '../stores/useEconomyStore';
3
+ import { STORE_CATALOG_MAP } from '../data/storeCatalog';
4
 
5
  const DEFAULT_WALLPAPER = '/wallpapers/default.webp';
6
 
 
14
  return saved;
15
  });
16
 
17
+ // Synchronize with equipped cosmetic wallpaper in economy store
18
+ const inventory = useEconomyStore((s) => s.inventory ?? []);
19
+ const equippedWallpaper = inventory.find(
20
+ (i) =>
21
+ i.is_equipped &&
22
+ (i.item_id === 'cosmetic_wallpaper_sanctuary' ||
23
+ i.item_id.startsWith('wallpaper_') ||
24
+ STORE_CATALOG_MAP[i.item_id]?.effect_type === 'wallpaper')
25
+ );
26
+
27
+ useEffect(() => {
28
+ if (equippedWallpaper) {
29
+ const catalogItem = STORE_CATALOG_MAP[equippedWallpaper.item_id];
30
+ const targetUrl =
31
+ (catalogItem?.effect_payload?.wallpaper_url as string) ||
32
+ '/wallpapers/sanctuary_spire.webp';
33
+ if (targetUrl && targetUrl !== wallpaperUrl) {
34
+ setWallpaperUrl(targetUrl);
35
+ localStorage.setItem('desktopWallpaperUrl', targetUrl);
36
+ }
37
+ }
38
+ }, [equippedWallpaper, wallpaperUrl]);
39
+
40
  const compressAndSaveWallpaper = useCallback((file: File) => {
41
  const reader = new FileReader();
42
  reader.onload = (event) => {
algospaced-ui/src/services/storeService.ts ADDED
@@ -0,0 +1,653 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Store & Inventory API Service for AlgoSpaced OS.
3
+ * Communicates with backend `/api/store/*`, `/api/currency`, and `/api/inventory/*` endpoints
4
+ * with dual-mode offline/guest persistence fallback via localStorage.
5
+ */
6
+
7
+ import { supabase, getStoredSession } from '../firebaseClient';
8
+ import { STORE_CATALOG, STORE_CATALOG_MAP } from '../data/storeCatalog';
9
+ import type {
10
+ PlayerCurrency,
11
+ StoreItem,
12
+ InventoryItem,
13
+ StoreTransaction,
14
+ PurchaseItemResponse,
15
+ UseItemResponse,
16
+ EquipItemResponse
17
+ } from '../types/storeTypes';
18
+
19
+ const API_BASE = import.meta.env.VITE_API_BASE_URL || '';
20
+
21
+ const GOLD_STORAGE_PREFIX = 'algospaced_player_gold_';
22
+ const INVENTORY_STORAGE_PREFIX = 'algospaced_player_inventory_';
23
+ const TX_STORAGE_PREFIX = 'algospaced_store_transactions_';
24
+
25
+ export function getEffectiveUid(): string {
26
+ try {
27
+ const session = getStoredSession();
28
+ if (session?.user?.id && session.user.id !== 'sandbox-user-id') {
29
+ return session.user.id;
30
+ }
31
+ } catch {
32
+ // Graceful fallback
33
+ }
34
+ return 'guest';
35
+ }
36
+
37
+ async function getAuthToken(): Promise<string> {
38
+ try {
39
+ const {
40
+ data: { session }
41
+ } = await supabase.auth.getSession();
42
+ return session ? session.access_token : 'sandbox';
43
+ } catch {
44
+ return 'sandbox';
45
+ }
46
+ }
47
+
48
+ // ============================================================================
49
+ // Local Storage Persistence Helpers (Guest / Offline Mode)
50
+ // ============================================================================
51
+
52
+ export function loadLocalCurrency(userId = getEffectiveUid()): PlayerCurrency {
53
+ const key = `${GOLD_STORAGE_PREFIX}${userId}`;
54
+ try {
55
+ const raw = localStorage.getItem(key);
56
+ if (raw) {
57
+ const parsed = JSON.parse(raw) as Partial<PlayerCurrency>;
58
+ return {
59
+ gold: Math.max(0, parsed.gold ?? 0),
60
+ lifetime_earned: Math.max(0, parsed.lifetime_earned ?? 0),
61
+ updated_at: parsed.updated_at || new Date().toISOString()
62
+ };
63
+ }
64
+ } catch {
65
+ // fallback
66
+ }
67
+ return {
68
+ gold: 0,
69
+ lifetime_earned: 0,
70
+ updated_at: new Date().toISOString()
71
+ };
72
+ }
73
+
74
+ export function saveLocalCurrency(currency: PlayerCurrency, userId = getEffectiveUid()): void {
75
+ const key = `${GOLD_STORAGE_PREFIX}${userId}`;
76
+ try {
77
+ localStorage.setItem(key, JSON.stringify(currency));
78
+ } catch {
79
+ // fallback
80
+ }
81
+ }
82
+
83
+ export function loadLocalInventory(userId = getEffectiveUid()): InventoryItem[] {
84
+ const key = `${INVENTORY_STORAGE_PREFIX}${userId}`;
85
+ try {
86
+ const raw = localStorage.getItem(key);
87
+ if (raw) {
88
+ const items = JSON.parse(raw);
89
+ if (Array.isArray(items)) {
90
+ return items as InventoryItem[];
91
+ }
92
+ }
93
+ } catch {
94
+ // fallback
95
+ }
96
+ return [];
97
+ }
98
+
99
+ export function saveLocalInventory(items: InventoryItem[], userId = getEffectiveUid()): void {
100
+ const key = `${INVENTORY_STORAGE_PREFIX}${userId}`;
101
+ try {
102
+ localStorage.setItem(key, JSON.stringify(items));
103
+ } catch {
104
+ // fallback
105
+ }
106
+ }
107
+
108
+ export function loadLocalTransactions(userId = getEffectiveUid()): StoreTransaction[] {
109
+ const key = `${TX_STORAGE_PREFIX}${userId}`;
110
+ try {
111
+ const raw = localStorage.getItem(key);
112
+ if (raw) {
113
+ const txs = JSON.parse(raw);
114
+ if (Array.isArray(txs)) {
115
+ return txs as StoreTransaction[];
116
+ }
117
+ }
118
+ } catch {
119
+ // fallback
120
+ }
121
+ return [];
122
+ }
123
+
124
+ export function saveLocalTransactions(txs: StoreTransaction[], userId = getEffectiveUid()): void {
125
+ const key = `${TX_STORAGE_PREFIX}${userId}`;
126
+ try {
127
+ localStorage.setItem(key, JSON.stringify(txs));
128
+ } catch {
129
+ // fallback
130
+ }
131
+ }
132
+
133
+ // ============================================================================
134
+ // Store API Operations
135
+ // ============================================================================
136
+
137
+ /**
138
+ * Fetches the current player gold balance and lifetime earnings.
139
+ */
140
+ export async function fetchCurrency(): Promise<PlayerCurrency> {
141
+ const uid = getEffectiveUid();
142
+ if (typeof navigator !== 'undefined' && !navigator.onLine) {
143
+ return loadLocalCurrency(uid);
144
+ }
145
+
146
+ try {
147
+ const token = await getAuthToken();
148
+ const abortCtrl = new AbortController();
149
+ const timer = setTimeout(() => abortCtrl.abort(), 4000);
150
+
151
+ let res: Response;
152
+ try {
153
+ res = await fetch(`${API_BASE}/api/currency`, {
154
+ headers: { Authorization: `Bearer ${token}` },
155
+ signal: abortCtrl.signal
156
+ });
157
+ } finally {
158
+ clearTimeout(timer);
159
+ }
160
+
161
+ if (!res.ok) {
162
+ throw new Error(`Failed to fetch currency: HTTP ${res.status}`);
163
+ }
164
+
165
+ const data: PlayerCurrency = await res.json();
166
+ saveLocalCurrency(data, uid);
167
+ return data;
168
+ } catch (err) {
169
+ console.warn('Currency fetch failed or offline; using local cache:', err);
170
+ return loadLocalCurrency(uid);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Fetches the canonical store catalog.
176
+ */
177
+ export async function fetchStoreItems(): Promise<StoreItem[]> {
178
+ if (typeof navigator !== 'undefined' && !navigator.onLine) {
179
+ return STORE_CATALOG;
180
+ }
181
+
182
+ try {
183
+ const token = await getAuthToken();
184
+ const abortCtrl = new AbortController();
185
+ const timer = setTimeout(() => abortCtrl.abort(), 4000);
186
+
187
+ let res: Response;
188
+ try {
189
+ res = await fetch(`${API_BASE}/api/store/items`, {
190
+ headers: { Authorization: `Bearer ${token}` },
191
+ signal: abortCtrl.signal
192
+ });
193
+ } finally {
194
+ clearTimeout(timer);
195
+ }
196
+
197
+ if (res.ok) {
198
+ const data: StoreItem[] = await res.json();
199
+ if (Array.isArray(data) && data.length > 0) {
200
+ return data;
201
+ }
202
+ }
203
+ } catch (err) {
204
+ console.warn('Failed to fetch remote store catalog; using canonical catalog:', err);
205
+ }
206
+
207
+ return STORE_CATALOG;
208
+ }
209
+
210
+ /**
211
+ * Fetches the player's owned inventory item stacks.
212
+ */
213
+ export async function fetchInventory(): Promise<InventoryItem[]> {
214
+ const uid = getEffectiveUid();
215
+ if (typeof navigator !== 'undefined' && !navigator.onLine) {
216
+ return loadLocalInventory(uid);
217
+ }
218
+
219
+ try {
220
+ const token = await getAuthToken();
221
+ const abortCtrl = new AbortController();
222
+ const timer = setTimeout(() => abortCtrl.abort(), 4000);
223
+
224
+ let res: Response;
225
+ try {
226
+ res = await fetch(`${API_BASE}/api/inventory`, {
227
+ headers: { Authorization: `Bearer ${token}` },
228
+ signal: abortCtrl.signal
229
+ });
230
+ } finally {
231
+ clearTimeout(timer);
232
+ }
233
+
234
+ if (!res.ok) {
235
+ throw new Error(`Failed to fetch inventory: HTTP ${res.status}`);
236
+ }
237
+
238
+ const data: InventoryItem[] = await res.json();
239
+ saveLocalInventory(data, uid);
240
+ return data;
241
+ } catch (err) {
242
+ console.warn('Inventory fetch failed or offline; using local cache:', err);
243
+ return loadLocalInventory(uid);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Atomically purchases an item from the store.
249
+ */
250
+ export async function purchaseStoreItem(
251
+ itemId: string,
252
+ quantity = 1
253
+ ): Promise<PurchaseItemResponse> {
254
+ if (quantity <= 0 || !Number.isInteger(quantity)) {
255
+ throw new Error('Purchase quantity must be a positive integer.');
256
+ }
257
+
258
+ const catalogItem = STORE_CATALOG_MAP[itemId];
259
+ if (!catalogItem) {
260
+ throw new Error(`Item ${itemId} not found in store catalog.`);
261
+ }
262
+
263
+ const uid = getEffectiveUid();
264
+ const totalPrice = catalogItem.price * quantity;
265
+
266
+ // Attempt backend API call if online
267
+ if (typeof navigator === 'undefined' || navigator.onLine) {
268
+ try {
269
+ const token = await getAuthToken();
270
+ const abortCtrl = new AbortController();
271
+ const timer = setTimeout(() => abortCtrl.abort(), 5000);
272
+
273
+ let res: Response;
274
+ try {
275
+ res = await fetch(`${API_BASE}/api/store/purchase`, {
276
+ method: 'POST',
277
+ headers: {
278
+ 'Content-Type': 'application/json',
279
+ Authorization: `Bearer ${token}`
280
+ },
281
+ body: JSON.stringify({ item_id: itemId, quantity }),
282
+ signal: abortCtrl.signal
283
+ });
284
+ } finally {
285
+ clearTimeout(timer);
286
+ }
287
+
288
+ if (res.ok) {
289
+ const responseData: PurchaseItemResponse = await res.json();
290
+ // Sync local cache with authoritative backend result
291
+ const cur = loadLocalCurrency(uid);
292
+ saveLocalCurrency(
293
+ {
294
+ ...cur,
295
+ gold: responseData.new_balance,
296
+ updated_at: new Date().toISOString()
297
+ },
298
+ uid
299
+ );
300
+
301
+ const inv = loadLocalInventory(uid);
302
+ const exIdx = inv.findIndex(i => i.item_id === itemId);
303
+ if (exIdx >= 0) {
304
+ inv[exIdx] = responseData.inventory_item;
305
+ } else {
306
+ inv.push(responseData.inventory_item);
307
+ }
308
+ saveLocalInventory(inv, uid);
309
+
310
+ // Append to local transaction log
311
+ const txs = loadLocalTransactions(uid);
312
+ txs.unshift({
313
+ id: `tx_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
314
+ user_id: uid,
315
+ item_id: itemId,
316
+ item_name: catalogItem.name,
317
+ price: catalogItem.price,
318
+ quantity,
319
+ total_price: totalPrice,
320
+ balance_after: responseData.new_balance,
321
+ status: 'completed',
322
+ timestamp: new Date().toISOString()
323
+ });
324
+ saveLocalTransactions(txs, uid);
325
+
326
+ return responseData;
327
+ }
328
+
329
+ // If backend returned error response (e.g. 400 Insufficient Funds), propagate error verbatim
330
+ const errJson = (await res.json().catch(() => ({}))) as { detail?: string };
331
+ throw new Error(errJson.detail || 'Insufficient gold balance to purchase item.');
332
+ } catch (networkOrApiErr) {
333
+ if (
334
+ networkOrApiErr instanceof Error &&
335
+ (networkOrApiErr.message.includes('Insufficient gold balance') ||
336
+ networkOrApiErr.message.includes('not found') ||
337
+ networkOrApiErr.message.includes('positive integer'))
338
+ ) {
339
+ throw networkOrApiErr;
340
+ }
341
+ console.warn('Backend purchase call failed; proceeding with offline local transaction fallback:', networkOrApiErr);
342
+ }
343
+ }
344
+
345
+ // Offline / Sandbox Fallback Atomic Transaction
346
+ const localCur = loadLocalCurrency(uid);
347
+ if (localCur.gold < totalPrice) {
348
+ throw new Error(
349
+ `Insufficient gold balance to purchase item. Required: ${totalPrice}, Available: ${localCur.gold}`
350
+ );
351
+ }
352
+
353
+ // Deduct gold
354
+ const updatedGold: PlayerCurrency = {
355
+ ...localCur,
356
+ gold: localCur.gold - totalPrice,
357
+ updated_at: new Date().toISOString()
358
+ };
359
+
360
+ // Credit inventory
361
+ const inventory = loadLocalInventory(uid);
362
+ const existingIdx = inventory.findIndex(item => item.item_id === itemId);
363
+ const now = new Date().toISOString();
364
+
365
+ let updatedInventoryItem: InventoryItem;
366
+ if (existingIdx >= 0) {
367
+ inventory[existingIdx].quantity += quantity;
368
+ inventory[existingIdx].updated_at = now;
369
+ updatedInventoryItem = inventory[existingIdx];
370
+ } else {
371
+ updatedInventoryItem = {
372
+ item_id: itemId,
373
+ quantity,
374
+ is_equipped: false,
375
+ acquired_at: now,
376
+ updated_at: now
377
+ };
378
+ inventory.push(updatedInventoryItem);
379
+ }
380
+
381
+ saveLocalCurrency(updatedGold, uid);
382
+ saveLocalInventory(inventory, uid);
383
+
384
+ // Append transaction
385
+ const txs = loadLocalTransactions(uid);
386
+ txs.unshift({
387
+ id: `tx_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
388
+ user_id: uid,
389
+ item_id: itemId,
390
+ item_name: catalogItem.name,
391
+ price: catalogItem.price,
392
+ quantity,
393
+ total_price: totalPrice,
394
+ balance_after: updatedGold.gold,
395
+ status: 'completed',
396
+ timestamp: now
397
+ });
398
+ saveLocalTransactions(txs, uid);
399
+
400
+ return {
401
+ success: true,
402
+ item: catalogItem,
403
+ new_balance: updatedGold.gold,
404
+ inventory_item: updatedInventoryItem
405
+ };
406
+ }
407
+
408
+ /**
409
+ * Consumes an inventory item (consumable or gift).
410
+ */
411
+ export async function consumeInventoryItem(itemId: string): Promise<UseItemResponse> {
412
+ const uid = getEffectiveUid();
413
+ const catalogItem = STORE_CATALOG_MAP[itemId];
414
+
415
+ if (!catalogItem) {
416
+ throw new Error(`Store item '${itemId}' not found.`);
417
+ }
418
+
419
+ if (catalogItem.category === 'cosmetic') {
420
+ throw new Error(`Item '${itemId}' is a cosmetic and cannot be consumed. Use equip instead.`);
421
+ }
422
+
423
+ // Attempt backend API call if online
424
+ if (typeof navigator === 'undefined' || navigator.onLine) {
425
+ try {
426
+ const token = await getAuthToken();
427
+ const abortCtrl = new AbortController();
428
+ const timer = setTimeout(() => abortCtrl.abort(), 5000);
429
+
430
+ let res: Response;
431
+ try {
432
+ res = await fetch(`${API_BASE}/api/inventory/use`, {
433
+ method: 'POST',
434
+ headers: {
435
+ 'Content-Type': 'application/json',
436
+ Authorization: `Bearer ${token}`
437
+ },
438
+ body: JSON.stringify({ item_id: itemId }),
439
+ signal: abortCtrl.signal
440
+ });
441
+ } finally {
442
+ clearTimeout(timer);
443
+ }
444
+
445
+ if (res.ok) {
446
+ const responseData: UseItemResponse = await res.json();
447
+ // Update local inventory
448
+ const inv = loadLocalInventory(uid);
449
+ const exIdx = inv.findIndex(i => i.item_id === itemId);
450
+ if (exIdx >= 0) {
451
+ if (responseData.remaining_quantity <= 0) {
452
+ inv.splice(exIdx, 1);
453
+ } else {
454
+ inv[exIdx].quantity = responseData.remaining_quantity;
455
+ inv[exIdx].updated_at = new Date().toISOString();
456
+ }
457
+ saveLocalInventory(inv, uid);
458
+ }
459
+ return responseData;
460
+ }
461
+
462
+ const errJson = (await res.json().catch(() => ({}))) as { detail?: string };
463
+ throw new Error(errJson.detail || `Item '${itemId}' is not available in inventory.`);
464
+ } catch (networkOrApiErr) {
465
+ if (
466
+ networkOrApiErr instanceof Error &&
467
+ (networkOrApiErr.message.includes('not available in inventory') ||
468
+ networkOrApiErr.message.includes('not found') ||
469
+ networkOrApiErr.message.includes('cannot be consumed'))
470
+ ) {
471
+ throw networkOrApiErr;
472
+ }
473
+ console.warn('Backend item use failed; proceeding with offline local consumption:', networkOrApiErr);
474
+ }
475
+ }
476
+
477
+ // Local Offline Consumption
478
+ const inventory = loadLocalInventory(uid);
479
+ const existingIdx = inventory.findIndex(item => item.item_id === itemId);
480
+
481
+ if (existingIdx === -1 || inventory[existingIdx].quantity <= 0) {
482
+ throw new Error(`Item ${itemId} is not available in inventory.`);
483
+ }
484
+
485
+ inventory[existingIdx].quantity -= 1;
486
+ const remaining = inventory[existingIdx].quantity;
487
+
488
+ if (remaining === 0) {
489
+ inventory.splice(existingIdx, 1);
490
+ } else {
491
+ inventory[existingIdx].updated_at = new Date().toISOString();
492
+ }
493
+
494
+ saveLocalInventory(inventory, uid);
495
+
496
+ return {
497
+ success: true,
498
+ effect_applied: catalogItem.effect_type,
499
+ remaining_quantity: remaining,
500
+ details: catalogItem.effect_payload
501
+ };
502
+ }
503
+
504
+ export const useInventoryItem = consumeInventoryItem;
505
+
506
+ /**
507
+ * Equips or unequips a cosmetic item in inventory.
508
+ */
509
+ export async function equipInventoryItem(
510
+ itemId: string,
511
+ isEquipped = true
512
+ ): Promise<EquipItemResponse> {
513
+ const uid = getEffectiveUid();
514
+ const catalogItem = STORE_CATALOG_MAP[itemId];
515
+
516
+ if (!catalogItem) {
517
+ throw new Error(`Store item '${itemId}' not found.`);
518
+ }
519
+
520
+ if (catalogItem.category !== 'cosmetic') {
521
+ throw new Error(`Item '${itemId}' is not a cosmetic item and cannot be equipped.`);
522
+ }
523
+
524
+ // Attempt backend API call if online
525
+ if (typeof navigator === 'undefined' || navigator.onLine) {
526
+ try {
527
+ const token = await getAuthToken();
528
+ const abortCtrl = new AbortController();
529
+ const timer = setTimeout(() => abortCtrl.abort(), 5000);
530
+
531
+ let res: Response;
532
+ try {
533
+ res = await fetch(`${API_BASE}/api/inventory/equip`, {
534
+ method: 'POST',
535
+ headers: {
536
+ 'Content-Type': 'application/json',
537
+ Authorization: `Bearer ${token}`
538
+ },
539
+ body: JSON.stringify({ item_id: itemId, is_equipped: isEquipped }),
540
+ signal: abortCtrl.signal
541
+ });
542
+ } finally {
543
+ clearTimeout(timer);
544
+ }
545
+
546
+ if (res.ok) {
547
+ const responseData: EquipItemResponse = await res.json();
548
+ // Update local inventory
549
+ const inv = loadLocalInventory(uid);
550
+ const item = inv.find(i => i.item_id === itemId);
551
+ if (item) {
552
+ if (responseData.is_equipped) {
553
+ for (const other of inv) {
554
+ const otherCat = STORE_CATALOG_MAP[other.item_id];
555
+ if (
556
+ otherCat &&
557
+ otherCat.effect_type === catalogItem.effect_type &&
558
+ other.item_id !== itemId
559
+ ) {
560
+ other.is_equipped = false;
561
+ }
562
+ }
563
+ }
564
+ item.is_equipped = responseData.is_equipped;
565
+ item.updated_at = new Date().toISOString();
566
+ saveLocalInventory(inv, uid);
567
+ }
568
+ return responseData;
569
+ }
570
+
571
+ const errJson = (await res.json().catch(() => ({}))) as { detail?: string };
572
+ throw new Error(errJson.detail || `Item '${itemId}' is not in your inventory.`);
573
+ } catch (networkOrApiErr) {
574
+ if (
575
+ networkOrApiErr instanceof Error &&
576
+ (networkOrApiErr.message.includes('not in your inventory') ||
577
+ networkOrApiErr.message.includes('not owned in inventory') ||
578
+ networkOrApiErr.message.includes('cannot be equipped'))
579
+ ) {
580
+ throw networkOrApiErr;
581
+ }
582
+ console.warn('Backend item equip failed; proceeding with offline local equip:', networkOrApiErr);
583
+ }
584
+ }
585
+
586
+ // Local Offline Equip
587
+ const inventory = loadLocalInventory(uid);
588
+ const item = inventory.find(i => i.item_id === itemId);
589
+
590
+ if (!item) {
591
+ throw new Error(`Cosmetic item ${itemId} is not owned in inventory.`);
592
+ }
593
+
594
+ if (isEquipped) {
595
+ for (const inv of inventory) {
596
+ const otherCat = STORE_CATALOG_MAP[inv.item_id];
597
+ if (
598
+ otherCat &&
599
+ otherCat.effect_type === catalogItem.effect_type &&
600
+ inv.item_id !== itemId
601
+ ) {
602
+ inv.is_equipped = false;
603
+ }
604
+ }
605
+ }
606
+
607
+ item.is_equipped = isEquipped;
608
+ item.updated_at = new Date().toISOString();
609
+ saveLocalInventory(inventory, uid);
610
+
611
+ return {
612
+ success: true,
613
+ item_id: itemId,
614
+ is_equipped: isEquipped
615
+ };
616
+ }
617
+
618
+ /**
619
+ * Fetches the user's chronological store transaction history.
620
+ */
621
+ export async function fetchTransactions(): Promise<StoreTransaction[]> {
622
+ const uid = getEffectiveUid();
623
+ if (typeof navigator !== 'undefined' && !navigator.onLine) {
624
+ return loadLocalTransactions(uid);
625
+ }
626
+
627
+ try {
628
+ const token = await getAuthToken();
629
+ const abortCtrl = new AbortController();
630
+ const timer = setTimeout(() => abortCtrl.abort(), 4000);
631
+
632
+ let res: Response;
633
+ try {
634
+ res = await fetch(`${API_BASE}/api/store/transactions`, {
635
+ headers: { Authorization: `Bearer ${token}` },
636
+ signal: abortCtrl.signal
637
+ });
638
+ } finally {
639
+ clearTimeout(timer);
640
+ }
641
+
642
+ if (!res.ok) {
643
+ throw new Error(`Failed to fetch transactions: HTTP ${res.status}`);
644
+ }
645
+
646
+ const data: StoreTransaction[] = await res.json();
647
+ saveLocalTransactions(data, uid);
648
+ return data;
649
+ } catch (err) {
650
+ console.warn('Transactions fetch failed or offline; using local cache:', err);
651
+ return loadLocalTransactions(uid);
652
+ }
653
+ }
algospaced-ui/src/stores/useEconomyStore.ts ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Economy & Inventory Store for AlgoSpaced OS.
3
+ * Manages player gold balance, lifetime earned currency, inventory item stacks,
4
+ * store purchase transactions, and item equip/consumption states.
5
+ * Persists locally via Zustand `persist` middleware with key `'algospaced_economy_state_v1'`.
6
+ */
7
+
8
+ import { create } from 'zustand';
9
+ import { persist } from 'zustand/middleware';
10
+ import { STORE_CATALOG_MAP } from '../data/storeCatalog';
11
+ import * as storeService from '../services/storeService';
12
+ import {
13
+ fetchCurrency,
14
+ fetchInventory,
15
+ fetchTransactions,
16
+ purchaseStoreItem,
17
+ equipInventoryItem,
18
+ loadLocalCurrency,
19
+ saveLocalCurrency,
20
+ loadLocalInventory,
21
+ loadLocalTransactions,
22
+ getEffectiveUid
23
+ } from '../services/storeService';
24
+
25
+ // Ensure elixir_frozen_time alias is mapped to consumable_streak_freeze
26
+ if (!STORE_CATALOG_MAP['elixir_frozen_time'] && STORE_CATALOG_MAP['consumable_streak_freeze']) {
27
+ STORE_CATALOG_MAP['elixir_frozen_time'] = STORE_CATALOG_MAP['consumable_streak_freeze'];
28
+ }
29
+ import type {
30
+ InventoryItem,
31
+ StoreTransaction,
32
+ PurchaseItemResponse,
33
+ UseItemResponse,
34
+ EquipItemResponse
35
+ } from '../types/storeTypes';
36
+
37
+ export interface EconomyStoreState {
38
+ gold: number;
39
+ lifetimeEarned: number;
40
+ inventory: InventoryItem[];
41
+ transactions: StoreTransaction[];
42
+ isLoading: boolean;
43
+ error: string | null;
44
+
45
+ // Actions
46
+ awardGold: (amount: number, reason?: string) => void;
47
+ purchaseItem: (itemId: string, quantity?: number) => Promise<PurchaseItemResponse>;
48
+ consumeItem: (itemId: string) => Promise<UseItemResponse>;
49
+ equipItem: (itemId: string, isEquipped: boolean) => Promise<EquipItemResponse>;
50
+ refreshEconomy: () => Promise<void>;
51
+ setError: (error: string | null) => void;
52
+ clearError: () => void;
53
+ reset: () => void;
54
+ }
55
+
56
+ const initialCurrency = loadLocalCurrency();
57
+ const initialInventory = loadLocalInventory();
58
+ const initialTransactions = loadLocalTransactions();
59
+
60
+ export const useEconomyStore = create<EconomyStoreState>()(
61
+ persist(
62
+ (set, get) => ({
63
+ gold: initialCurrency.gold,
64
+ lifetimeEarned: initialCurrency.lifetime_earned,
65
+ inventory: initialInventory,
66
+ transactions: initialTransactions,
67
+ isLoading: false,
68
+ error: null,
69
+
70
+ awardGold: (amount: number, _reason?: string) => {
71
+ if (amount <= 0) return;
72
+ set(state => {
73
+ const nextGold = state.gold + amount;
74
+ const nextLifetime = state.lifetimeEarned + amount;
75
+ const nowIso = new Date().toISOString();
76
+
77
+ // Keep localStorage keys synchronized for multi-mode persistence
78
+ try {
79
+ const uid = getEffectiveUid();
80
+ saveLocalCurrency(
81
+ {
82
+ gold: nextGold,
83
+ lifetime_earned: nextLifetime,
84
+ updated_at: nowIso
85
+ },
86
+ uid
87
+ );
88
+ } catch {
89
+ // safe fallback
90
+ }
91
+
92
+ return {
93
+ gold: nextGold,
94
+ lifetimeEarned: nextLifetime,
95
+ error: null
96
+ };
97
+ });
98
+ },
99
+
100
+ purchaseItem: async (itemId: string, quantity = 1): Promise<PurchaseItemResponse> => {
101
+ if (quantity <= 0 || !Number.isInteger(quantity)) {
102
+ const err = new Error('Purchase quantity must be a positive integer.');
103
+ set({ error: err.message });
104
+ throw err;
105
+ }
106
+
107
+ const catalogItem = STORE_CATALOG_MAP[itemId];
108
+ if (!catalogItem) {
109
+ const err = new Error(`Item ${itemId} not found in store catalog.`);
110
+ set({ error: err.message });
111
+ throw err;
112
+ }
113
+
114
+ const totalPrice = catalogItem.price * quantity;
115
+ const currentGold = get().gold;
116
+
117
+ // Atomic check: If balance is insufficient, fail with zero state mutations
118
+ if (currentGold < totalPrice) {
119
+ const errMsg = 'Insufficient gold balance to purchase item.';
120
+ set({ error: errMsg });
121
+ throw new Error(errMsg);
122
+ }
123
+
124
+ set({ isLoading: true });
125
+ try {
126
+ const response = await purchaseStoreItem(itemId, quantity);
127
+ set(state => {
128
+ const nextInv = [...state.inventory];
129
+ const exIdx = nextInv.findIndex(i => i.item_id === itemId);
130
+ if (exIdx >= 0) {
131
+ nextInv[exIdx] = response.inventory_item;
132
+ } else {
133
+ nextInv.push(response.inventory_item);
134
+ }
135
+
136
+ const newTx: StoreTransaction = {
137
+ id: `tx_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
138
+ user_id: getEffectiveUid(),
139
+ item_id: itemId,
140
+ item_name: catalogItem.name,
141
+ price: catalogItem.price,
142
+ quantity,
143
+ total_price: totalPrice,
144
+ balance_after: response.new_balance,
145
+ status: 'completed',
146
+ timestamp: new Date().toISOString()
147
+ };
148
+
149
+ return {
150
+ gold: response.new_balance,
151
+ inventory: nextInv,
152
+ transactions: [newTx, ...state.transactions],
153
+ error: null
154
+ };
155
+ });
156
+
157
+ return response;
158
+ } catch (err) {
159
+ const msg = err instanceof Error ? err.message : 'Failed to complete store purchase.';
160
+ set({ error: msg });
161
+ throw err;
162
+ } finally {
163
+ set({ isLoading: false });
164
+ }
165
+ },
166
+
167
+ consumeItem: async (itemId: string): Promise<UseItemResponse> => {
168
+ const currentInv = get().inventory;
169
+ let targetId = itemId;
170
+ let existingIdx = currentInv.findIndex(i => i.item_id === targetId);
171
+ if (existingIdx === -1) {
172
+ if (itemId === 'elixir_frozen_time') {
173
+ targetId = 'consumable_streak_freeze';
174
+ } else if (itemId === 'consumable_streak_freeze') {
175
+ targetId = 'elixir_frozen_time';
176
+ }
177
+ existingIdx = currentInv.findIndex(i => i.item_id === targetId);
178
+ }
179
+
180
+ if (existingIdx === -1 || currentInv[existingIdx].quantity <= 0) {
181
+ const err = new Error(`Item ${itemId} is not available in inventory.`);
182
+ set({ error: err.message });
183
+ throw err;
184
+ }
185
+
186
+ set({ isLoading: true });
187
+ try {
188
+ // Invoke storeService.useInventoryItem (supporting both direct and aliased IDs)
189
+ let res: UseItemResponse;
190
+ try {
191
+ res = await storeService.useInventoryItem(itemId);
192
+ } catch (firstErr) {
193
+ if (targetId !== itemId) {
194
+ res = await storeService.useInventoryItem(targetId);
195
+ } else {
196
+ throw firstErr;
197
+ }
198
+ }
199
+
200
+ // Update local inventory state
201
+ set(state => {
202
+ const nextInv = [...state.inventory];
203
+ const idx = nextInv.findIndex(i => i.item_id === targetId || i.item_id === itemId);
204
+ if (idx >= 0) {
205
+ if (res.remaining_quantity <= 0) {
206
+ nextInv.splice(idx, 1);
207
+ } else {
208
+ nextInv[idx] = {
209
+ ...nextInv[idx],
210
+ quantity: res.remaining_quantity,
211
+ updated_at: new Date().toISOString()
212
+ };
213
+ }
214
+ }
215
+ return { inventory: nextInv, error: null };
216
+ });
217
+
218
+ // Consumable Streak Freeze Effect:
219
+ // Store streak freeze charge in localStorage['algospaced_streak_shield'] for persistent protection
220
+ if (
221
+ res.effect_applied === 'streak_freeze' ||
222
+ itemId === 'elixir_frozen_time' ||
223
+ targetId === 'consumable_streak_freeze'
224
+ ) {
225
+ try {
226
+ const raw = localStorage.getItem('algospaced_streak_shield');
227
+ const currentShield = raw ? parseInt(raw, 10) || 0 : 0;
228
+ const chargesToAdd = (res.details?.freeze_charges as number) || 1;
229
+ const newShield = currentShield + chargesToAdd;
230
+ localStorage.setItem('algospaced_streak_shield', String(newShield));
231
+ } catch {
232
+ // safe fallback
233
+ }
234
+
235
+ // Dispatch toast notification event confirming active streak freeze protection
236
+ if (typeof window !== 'undefined') {
237
+ window.dispatchEvent(
238
+ new CustomEvent('toast:show', {
239
+ detail: {
240
+ message: 'Elixir of Frozen Time consumed! Streak freeze protection is active.',
241
+ type: 'success'
242
+ }
243
+ })
244
+ );
245
+ window.dispatchEvent(
246
+ new CustomEvent('algospaced:streak_freeze_activated', {
247
+ detail: {
248
+ charges: 1
249
+ }
250
+ })
251
+ );
252
+ }
253
+ }
254
+
255
+ return res;
256
+ } catch (err) {
257
+ const msg = err instanceof Error ? err.message : `Failed to consume item ${itemId}.`;
258
+ set({ error: msg });
259
+ throw err;
260
+ } finally {
261
+ set({ isLoading: false });
262
+ }
263
+ },
264
+
265
+ equipItem: async (itemId: string, isEquipped: boolean): Promise<EquipItemResponse> => {
266
+ const currentInv = get().inventory;
267
+ const item = currentInv.find(i => i.item_id === itemId);
268
+ if (!item) {
269
+ const err = new Error(`Cosmetic item ${itemId} is not owned in inventory.`);
270
+ set({ error: err.message });
271
+ throw err;
272
+ }
273
+
274
+ const catalogItem = STORE_CATALOG_MAP[itemId];
275
+ if (!catalogItem || catalogItem.category !== 'cosmetic') {
276
+ const err = new Error(`Item ${itemId} is not a valid cosmetic.`);
277
+ set({ error: err.message });
278
+ throw err;
279
+ }
280
+
281
+ set({ isLoading: true });
282
+ try {
283
+ const res = await equipInventoryItem(itemId, isEquipped);
284
+ set(state => {
285
+ const nextInv = state.inventory.map(invItem => {
286
+ if (invItem.item_id === itemId) {
287
+ return {
288
+ ...invItem,
289
+ is_equipped: isEquipped,
290
+ updated_at: new Date().toISOString()
291
+ };
292
+ }
293
+ // If equipping, unequip others of same effect type
294
+ if (isEquipped) {
295
+ const otherCat = STORE_CATALOG_MAP[invItem.item_id];
296
+ if (otherCat && otherCat.effect_type === catalogItem.effect_type) {
297
+ return {
298
+ ...invItem,
299
+ is_equipped: false,
300
+ updated_at: new Date().toISOString()
301
+ };
302
+ }
303
+ }
304
+ return invItem;
305
+ });
306
+ return { inventory: nextInv, error: null };
307
+ });
308
+ return res;
309
+ } catch (err) {
310
+ const msg = err instanceof Error ? err.message : `Failed to update equip status for ${itemId}.`;
311
+ set({ error: msg });
312
+ throw err;
313
+ } finally {
314
+ set({ isLoading: false });
315
+ }
316
+ },
317
+
318
+ refreshEconomy: async () => {
319
+ set({ isLoading: true });
320
+ try {
321
+ const [currency, inventory, transactions] = await Promise.all([
322
+ fetchCurrency(),
323
+ fetchInventory(),
324
+ fetchTransactions()
325
+ ]);
326
+ set({
327
+ gold: currency.gold,
328
+ lifetimeEarned: currency.lifetime_earned,
329
+ inventory,
330
+ transactions,
331
+ isLoading: false,
332
+ error: null
333
+ });
334
+ } catch (err) {
335
+ const msg = err instanceof Error ? err.message : 'Failed to refresh economy.';
336
+ set({ error: msg, isLoading: false });
337
+ }
338
+ },
339
+
340
+ setError: (error: string | null) => set({ error }),
341
+ clearError: () => set({ error: null }),
342
+ reset: () => {
343
+ set({
344
+ gold: 0,
345
+ lifetimeEarned: 0,
346
+ inventory: [],
347
+ transactions: [],
348
+ isLoading: false,
349
+ error: null
350
+ });
351
+ }
352
+ }),
353
+ {
354
+ name: 'algospaced_economy_state_v1',
355
+ partialize: state => ({
356
+ gold: state.gold,
357
+ lifetimeEarned: state.lifetimeEarned,
358
+ inventory: state.inventory,
359
+ transactions: state.transactions
360
+ })
361
+ }
362
+ )
363
+ );
algospaced-ui/src/stores/useOSStore.ts CHANGED
@@ -17,6 +17,7 @@ const INITIAL_WINDOWS: WindowsMap = {
17
  editProblem: { isOpen: false, isMinimized: false },
18
  companion: { isOpen: false, isMinimized: false },
19
  cardManager: { isOpen: false, isMinimized: false },
 
20
  };
21
 
22
  export interface WindowPosition {
 
17
  editProblem: { isOpen: false, isMinimized: false },
18
  companion: { isOpen: false, isMinimized: false },
19
  cardManager: { isOpen: false, isMinimized: false },
20
+ store: { isOpen: false, isMinimized: false },
21
  };
22
 
23
  export interface WindowPosition {
algospaced-ui/src/types/storeTypes.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Store & Inventory Type Definitions for AlgoSpaced OS.
3
+ * Strict contract symmetry with backend Pydantic models in `routers/store.py`.
4
+ */
5
+
6
+ export type StoreItemCategory = 'consumable' | 'cosmetic' | 'companion_gift';
7
+
8
+ export type StoreItemEffectType =
9
+ | 'streak_freeze'
10
+ | 'hint_scroll'
11
+ | 'focus_boost'
12
+ | 'wallpaper'
13
+ | 'crt_theme'
14
+ | 'palette_theme'
15
+ | 'aurelia_gift';
16
+
17
+ export interface PlayerCurrency {
18
+ gold: number;
19
+ lifetime_earned: number;
20
+ updated_at: string;
21
+ }
22
+
23
+ export interface StoreItem {
24
+ id: string;
25
+ name: string;
26
+ category: StoreItemCategory;
27
+ price: number;
28
+ lore: string;
29
+ icon: string;
30
+ effect_type: StoreItemEffectType;
31
+ effect_payload: Record<string, unknown>;
32
+ }
33
+
34
+ export interface InventoryItem {
35
+ item_id: string;
36
+ quantity: number;
37
+ is_equipped?: boolean;
38
+ acquired_at: string;
39
+ updated_at: string;
40
+ }
41
+
42
+ export interface StoreTransaction {
43
+ id: string;
44
+ user_id: string;
45
+ item_id: string;
46
+ item_name: string;
47
+ price: number;
48
+ quantity: number;
49
+ total_price: number;
50
+ balance_after: number;
51
+ status: 'completed' | 'failed';
52
+ timestamp: string;
53
+ }
54
+
55
+ export interface PurchaseItemRequest {
56
+ item_id: string;
57
+ quantity?: number;
58
+ }
59
+
60
+ export interface PurchaseItemResponse {
61
+ success: boolean;
62
+ item: StoreItem;
63
+ new_balance: number;
64
+ inventory_item: InventoryItem;
65
+ }
66
+
67
+ export interface UseItemRequest {
68
+ item_id: string;
69
+ }
70
+
71
+ export interface UseItemResponse {
72
+ success: boolean;
73
+ effect_applied: string;
74
+ remaining_quantity: number;
75
+ details: Record<string, unknown>;
76
+ }
77
+
78
+ export interface EquipItemRequest {
79
+ item_id: string;
80
+ is_equipped?: boolean;
81
+ }
82
+
83
+ export interface EquipItemResponse {
84
+ success: boolean;
85
+ item_id: string;
86
+ is_equipped: boolean;
87
+ }
88
+
89
+ /**
90
+ * Enriched inventory item combining owned item data with its store catalog specification.
91
+ */
92
+ export interface EnrichedInventoryItem extends InventoryItem {
93
+ catalog?: StoreItem;
94
+ }
algospaced-ui/src/types/windowTypes.ts CHANGED
@@ -11,7 +11,8 @@ export type WindowId =
11
  | 'createProblem'
12
  | 'editProblem'
13
  | 'companion'
14
- | 'cardManager';
 
15
 
16
  export interface WindowState {
17
  isOpen: boolean;
 
11
  | 'createProblem'
12
  | 'editProblem'
13
  | 'companion'
14
+ | 'cardManager'
15
+ | 'store';
16
 
17
  export interface WindowState {
18
  isOpen: boolean;