1import{c as G,J,E as Y,r as n,j as s,L as N,B as z,m as U}from"./index-BkeBWTNd.js";import{l as q,a as Q}from"./flashcardsResumeApi-Cm18F4Ji.js";import{d as X}from"./hskDeckSummaryState-DSg_8u5t.js";import{u as Z}from"./useResolvedDisplayMode-Trxf7pne.js";import{C as ee}from"./clock-C9riptUY.js";import{L as se}from"./list-B_KKhZIQ.js";import{R as te}from"./rotate-ccw-CJM7eno5.js";/** 2 * @license lucide-react v0.344.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ae=G("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]),R="ct_flashcards_last_resumed";function S(){try{const a=localStorage.getItem(R);return a?JSON.parse(a)||{}:{}}catch(a){return console.warn("[flashcardsResumeState] Failed to load last resumed state:",a),{}}}function re(a){try{localStorage.setItem(R,JSON.stringify(a))}catch(i){console.warn("[flashcardsResumeState] Failed to save last resumed state:",i)}}function f(a,i){const m=S();m[a]={...i,ts:Date.now()},re(m)}function y(a){try{return new Date(a).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}catch(i){return console.warn("[flashcardsResumeState] Failed to format date:",i),""}}function ue(){const a=J(),{status:i}=Y(),{displayMode:m}=Z(),u=i==="authenticated",[c,I]=n.useState(null),[g,L]=n.useState(null),[_,H]=n.useState(null),[F,v]=n.useState(!1),[$,M]=n.useState(!1),[h,W]=n.useState([]),[o,x]=n.useState({}),[P,d]=n.useState(!1);n.useEffect(()=>{try{const e=localStorage.getItem("ct_last_wordlist_id"),r=localStorage.getItem("ct_last_wordlist_name"),l=localStorage.getItem("ct_last_wordlist_mode");e&&(I(e),L(r),H(l||"simplified"));const t=S();x(t)}catch(e){console.warn("[FlashcardsHub] Failed to read from localStorage:",e)}},[]),n.useEffect(()=>{if(!u)return;(async()=>{try{const r=await q();W(r);const l=r.find(t=>t.sourceType==="ct");if(M(Q(l)),c){const t=r.find(C=>C.sourceType==="wordlist"&&C.sourceId===c);v(!!t)}else v(!1)}catch(r){console.warn("[FlashcardsHub] Failed to check resumes:",r)}})()},[u,c]);const D=()=>{if(!c)return;f("wordlist",{listId:parseInt(c,10),label:g||"Wordlist"}),x(l=>({...l,wordlist:{listId:parseInt(c,10),label:g||"Wordlist",ts:Date.now()}}));const e=_||"simplified",r=new URLSearchParams({list_id:c,characterType:e});a(`/my-words/flashcards/config?${r.toString()}`,{state:{listId:parseInt(c,10)}})},K=(e,r)=>{f("hsk",{deckId:`hsk-${e}`,label:`HSK ${e}`}),x(l=>({...l,hsk:{deckId:`hsk-${e}`,label:`HSK ${e}`,ts:Date.now()}})),a(`/flashcards/public/study?hsk=${e}&mode=${r}`)},T=()=>{d(!0)},E=()=>{d(!1),f("ct_vocab",{label:"CT Vocabulary"}),x(e=>({...e,ct_vocab:{label:"CT Vocabulary",ts:Date.now()}})),a("/flashcards/ct?resume=1")},O=()=>{d(!1),a("/flashcards/ct?start=new")},w=m==="traditional"?"traditional":"simplified",k=n.useMemo(()=>{const e=o.hsk?.deckId;if(!e||typeof e!="string")return;const r=e.match(/^hsk-(\d+)$/);return r?parseInt(r[1],10):void 0},[o.hsk?.deckId]),j=n.useMemo(()=>X(h,{mode:w,preferredPrimaryLevel:k}),[h,w,k]),b=$,p=!!(c&&F),V=j.hasAnyResume,A=[{id:"ct",title:"Chinese Track Vocabulary",description:"Practice vocabulary from course lessons.",cta:b?"Continue":"Start",icon:z,onClick:b?T:()=>a("/flashcards/ct?start=new"),color:"orange",hasResume:b},{id:"wordlists",title:"Wordlist Practice",description:"Study your saved and assigned wordlists.",cta:"Choose a wordlist",secondaryCta:p?"Resume":void 0,icon:se,onClick:()=>a("/my-words"),secondaryOnClick:p?D:void 0,lastWordlistName:g,color:"blue",hasResume:p},{id:"hsk",title:"HSK Flashcards",description:"Study Classic HSK 2.0 decks and New HSK 3.0 preview decks.",cta:"Browse HSK decks",onClick:()=>a("/flashcards/public"),icon:ae,color:"green",hskSummary:j,onResumeHsk:K,hasResume:V}],B={orange:{border:"border-orange-200",hover:"hover:border-orange-300",button:"bg-[#F37021] hover:bg-[#C94F00] text-white",icon:"text-orange-600"},blue:{border:"border-blue-200",hover:"hover:border-blue-300",button:"bg-blue-600 hover:bg-blue-700 text-white",icon:"text-blue-600"},green:{border:"border-green-200",hover:"hover:border-green-300",button:"bg-green-600 hover:bg-green-700 text-white",icon:"text-green-600"}};return s.jsx("div",{className:"min-h-screen bg-gray-50",children:s.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8 sm:px-6 lg:px-8",children:[s.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Flashcards"}),s.jsx("p",{className:"text-gray-600",children:"Choose what you want to study."})]}),u&&s.jsx(N,{to:"/flashcards/saved",className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors",children:"Saved sessions"})]}),u&&h.length>1&&s.jsx("div",{className:"mb-6 bg-blue-50 border-2 border-blue-200 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ee,{className:"w-5 h-5 text-blue-600"}),s.jsxs("p",{className:"text-sm font-medium text-gray-800",children:["You have ",h.length," saved flashcard sessions."]})]}),s.jsx(N,{to:"/flashcards/saved",className:"px-4 py-2 bg-ct-orange text-white rounded-lg text-sm font-medium hover:bg-[#C94F00] transition-colors transition-all duration-300 hover:scale-105 hover:-translate-y-1 hover:shadow-xl hover:ring-4 hover:ring-orange-200 border-2 border-transparent",children:"View saved sessions"})]})}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:A.map(e=>{const r=e.icon,l=B[e.color];return s.jsxs("div",{className:` 7 bg-white rounded-xl p-6 shadow-sm border-2 transition-all duration-300 8 ${l.border} ${l.hover} 9 hover:shadow-md cursor-pointer 10 `,onClick:e.onClick,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[s.jsx("div",{className:`flex-shrink-0 ${l.icon}`,children:s.jsx(r,{className:"w-8 h-8"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-gray-800",children:e.title}),e.hasResume&&s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-orange-50 text-orange-700 border border-orange-200",children:"Resume"})]}),s.jsx("p",{className:"text-gray-700 text-sm mb-1",children:e.description}),e.hasResume&&s.jsx("p",{className:"text-xs text-gray-500 italic",children:"Ready to continue"}),(()=>{if(e.id==="hsk"&&o.hsk){const t=y(o.hsk.ts);return s.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Last resumed: ",t,o.hsk.label&&` ⢠${o.hsk.label}`]})}if(e.id==="wordlists"&&o.wordlist){const t=y(o.wordlist.ts);return s.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Last resumed: ",t,o.wordlist.label&&` ⢠${o.wordlist.label}`]})}if(e.id==="ct"&&o.ct_vocab){const t=y(o.ct_vocab.ts);return s.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Last resumed: ",t,o.ct_vocab.label&&` ⢠${o.ct_vocab.label}`]})}return null})()]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-2 mt-4",children:[e.id==="hsk"&&e.hskSummary&&s.jsxs("div",{className:"w-full mb-2",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:"Classic HSK 2.0 progress (resume)"}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-600 mb-2",children:e.hskSummary.decks.map(t=>s.jsxs("span",{children:["Level ",t.level,": ",t.status==="completed"?"Completed":t.status==="resume"?"Resume":"Start"]},t.level))}),e.hskSummary.primaryResume&&s.jsxs("button",{onClick:t=>{t.stopPropagation(),e.onResumeHsk?.(e.hskSummary.primaryResume.level,e.hskSummary.primaryResume.mode)},className:"text-xs px-2 py-1 bg-green-100 text-green-700 rounded hover:bg-green-200 transition-colors mb-2",children:["Resume Classic Level ",e.hskSummary.primaryResume.level]})]}),s.jsxs("div",{className:"flex gap-2 w-full justify-end",children:[e.secondaryCta&&e.secondaryOnClick&&s.jsx("button",{onClick:t=>{t.stopPropagation(),e.secondaryOnClick?.()},className:` 11 px-4 py-2 rounded-lg font-medium text-sm 12 transition-all duration-300 13 hover:scale-105 hover:-translate-y-1 hover:shadow-xl 14 bg-gray-200 hover:bg-gray-300 text-gray-700 15 `,children:e.secondaryCta}),s.jsx("button",{onClick:t=>{t.stopPropagation(),e.onClick()},className:` 16 px-4 py-2 rounded-lg font-medium text-sm 17 transition-all duration-300 18 hover:scale-105 hover:-translate-y-1 hover:shadow-xl 19 ${l.button} 20 `,children:e.cta})]})]})]},e.id)})}),P&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:()=>d(!1),children:s.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-md w-full p-6",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"
20ct-choice-title","aria-describedby":"ct-choice-desc",children:[s.jsx("h2",{id:"ct-choice-title",className:"text-xl font-semibold text-gray-900 mb-2",children:"Chinese Track Vocabulary"}),s.jsx("p",{id:"ct-choice-desc",className:"text-gray-600 text-sm mb-6",children:"You have a previous session in progress. Continue where you left off or start a new session."}),s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("button",{onClick:E,className:"flex items-center justify-center gap-2 w-full px-4 py-3 rounded-lg font-medium text-white bg-[#F37021] hover:bg-[#C94F00] transition-colors",children:[s.jsx(U,{className:"w-5 h-5"}),"Continue previous session"]}),s.jsxs("button",{onClick:O,className:"flex items-center justify-center gap-2 w-full px-4 py-3 rounded-lg font-medium text-gray-700 bg-gray-100 hover:bg-gray-200 transition-colors",children:[s.jsx(te,{className:"w-5 h-5"}),"Start new session"]}),s.jsx("button",{onClick:()=>d(!1),className:"text-sm text-gray-500 hover:text-gray-700 py-2",children:"Cancel"})]})]})})]})})}export{ue as default}; 21//# sourceMappingURL=FlashcardsHubPage-BNzdE80H.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.