PageSourceSearch

https://hipragya.ai/assets/MathSolverHub-nkTzBrip.js

js hipragya.ai collected 2026-10-05 14:35:31 UTC 10,106 bytes, 1 lines download raw bytes

1import{b as Q,w as D,a as ee,r as c,j as e}from"./index-CvryZg2y.js";const M="/api/v1",se=40,y={numerical:{label:"Numerical",description:"Calculate and solve equations"},geometry:{label:"Geometry",description:"Shapes, angles, and proofs"},word_problem:{label:"Word Problems",description:"Real-world math scenarios"},proof:{label:"Proofs",description:"Mathematical proofs and logic"},diagram:{label:"Diagram",description:"Draw and analyze diagrams"}},C={easy:{label:"Easy",color:"#22c55e"},medium:{label:"Medium",color:"#f59e0b"},hard:{label:"Hard",color:"#ef4444"}},ie=f=>{const l=(f||"").toLowerCase();return l.includes("math")?"#4f46e5":l.includes("physics")?"#0ea5e9":l.includes("chemistry")?"#f59e0b":l.includes("biology")||l.includes("science")?"#10b981":l.includes("computer")||l.includes("programming")||l.includes("coding")||l.includes("informatics")?"#0891b2":l.includes("electronics")||l.includes("circuit")?"#e11d48":"#6366f1"};function ae(){const{user:f,isAuthenticated:l}=Q(),{isDark:T}=D(),k=ee(),[F,E]=c.useState(!0),[S,R]=c.useState(null),[i,z]=c.useState(null),[g,B]=c.useState(null),[x,_]=c.useState(null),[m,L]=c.useState(null),[b,w]=c.useState({}),[v,$]=c.useState({}),[N,p]=c.useState(1);c.useEffect(()=>{A()},[x,m,N]),c.useEffect(()=>{l&&U()},[l]);const A=async()=>{var s,t,n;try{E(!0);let a=`${M}/math-solver/browse`;const d=new URLSearchParams;d.append("page",String(N)),d.append("page_size",String(se)),x&&d.append("difficulty",x),m&&d.append("exercise_type",m),d.toString()&&(a+=`?${d.toString()}`);const r=await fetch(a,{credentials:"include"});if(!r.ok)throw new Error("Failed to fetch exercises");const h=await r.json();if(z(h),((s=h.subjects)==null?void 0:s.length)>0){const u=h.subjects[0];if(((t=u.courses)==null?void 0:t.length)>0){const j=u.courses[0];w({[j.id]:!0}),((n=j.chapters)==null?void 0:n.length)>0&&$({[j.chapters[0].id]:!0})}}}catch(a){console.error("Error fetching exercises:",a),R(a.message)}finally{E(!1)}},U=async()=>{try{const s=await fetch(`${M}/math-solver/stats/${f.id}`,{credentials:"include"});if(s.ok){const t=await s.json();B(t)}}catch(s){console.error("Error fetching user stats:",s)}},O=s=>{p(1),_(x===s?null:s)},W=s=>{p(1),L(m===s?null:s)},q=s=>{w(t=>({...t,[s]:!t[s]}))},G=s=>{$(t=>({...t,[s]:!t[s]}))},Y=s=>{if(!l){k("/login?redirect=/arena");return}const t=`/arena/solve/${s}`;k(t)},H=s=>{switch(s){case"completed":return e.jsx("span",{className:"status-badge completed",children:"Completed"});case"in_progress":return e.jsx("span",{className:"status-badge in-progress",children:"In Progress"});default:return null}},X=()=>{if(!(i!=null&&i.subjects))return[];const s=[];return i.subjects.forEach(t=>{var n;(n=t==null?void 0:t.courses)==null||n.forEach(a=>{a&&s.push({...a,subjectTitle:t.title,subjectIcon:t.icon})})}),s},V=()=>{var s;return(i==null?void 0:i.total)||((s=i==null?void 0:i.stats)==null?void 0:s.total_exercises)||0};if(F)return e.jsxs("div",{className:"math-solver-hub-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading exercises..."})]});if(S)return e.jsxs("div",{className:"math-solver-hub-error",children:[e.jsx("h2",{children:"Something went wrong"}),e.jsx("p",{children:S}),e.jsx("button",{onClick:A,className:"retry-btn",children:"Try Again"})]});const P=X(),Z=V();return e.jsxs("div",{className:`math-solver-hub ${T?"dark":""}`,children:[e.jsxs("div",{className:"math-solver-hub-title",children:[e.jsxs("div",{className:"title-content",children:[e.jsx("h1",{children:"Arena"}),e.jsx("p",{children:"Sharpen your skills with guided exercises and AI coaching"})]}),e.jsx("div",{className:"title-stats",children:e.jsxs("span",{className:"total-exercises",children:[Z," exercises"]})})]}),e.jsxs("div",{className:"math-solver-hub-content",children:[e.jsxs("aside",{className:"math-solver-sidebar",children:[e.jsxs("div",{className:"sidebar-section",children:[e.jsx("h3",{children:"Difficulty"}),e.jsxs("div",{className:"filter-list",children:[e.jsxs("button",{className:`filter-btn ${x?"":"active"}`,onClick:()=>{p(1),_(null)},children:[e.jsx("span",{className:"filter-dot all"}),e.jsx("span",{className:"filter-label",children:"All Levels"})]}),Object.entries(C).map(([s,t])=>{var n,a;return e.jsxs("button",{className:`filter-btn ${x===s?"active":""}`,onClick:()=>O(s),children:[e.jsx("span",{className:"filter-dot",style:{backgroundColor:t.color}}),e.jsx("span",{className:"filter-label",children:t.label}),e.jsx("span",{className:"filter-count",children:((a=(n=i==null?void 0:i.stats)==null?void 0:n.difficulty_breakdown)==null?void 0:a[s])||0})]},s)})]})]}),e.jsxs("div",{className:"sidebar-section",children:[e.jsx("h3",{children:"Exercise Type"}),e.jsxs("div",{className:"filter-list",children:[e.jsx("button",{className:`filter-btn ${m?"":"active"}`,onClick:()=>{p(1),L(null)},children:e.jsx("span",{className:"filter-label",children:"All Types"})}),Object.entries(y).map(([s,t])=>{var n,a;return e.jsxs("button",{className:`filter-btn ${m===s?"active":""}`,onClick:()=>W(s),children:[e.jsx("span",{className:"filter-label",children:t.label}),e.jsx("span",{className:"filter-count",children:((a=(n=i==null?void 0:i.stats)==null?void 0:n.exercises_by_type)==null?void 0:a[s])||0})]},s)})]})]}),f&&g&&e.jsxs("div",{className:"sidebar-section user-stats-sidebar",children:[e.jsx("h3",{children:"Your Progress"}),e.jsxs("div",{className:"mini-stats",children:[e.jsxs("div",{className:"mini-stat",children:[e.jsx("span",{className:"mini-stat-value",children:g.total_sessions_completed}),e.jsx("span",{className:"mini-stat-label",children:"Completed"})]}),e.jsxs("div",{className:"mini-stat",children:[e.jsxs("span",{className:"mini-stat-value",children:[Math.round(g.average_score),"%"]}),e.jsx("span",{className:"mini-stat-label",children:"Avg Score"})]}),e.jsxs("div",{className:"mini-stat",children:[e.jsxs("span",{className:"mini-stat-value",children:[Math.round(g.total_time_spent/60),"m"]}),e.jsx("span",{className:"mini-stat-label",children:"Time Spent"})]})]})]}),e.jsxs("div",{className:"sidebar-section ai-info",children:[e.jsx("h3",{children:"AI Assistance"}),e.jsx("p",{className:"ai-description",children:"Get real-time feedback as you work:"}),e.jsxs("ul",{className:"ai-features",children:[e.jsx("li",{children:"Periodic progress check-ins"}),e.jsx("li",{children:"Contextual hints"}
1),e.jsx("li",{children:"Step-by-step guidance"}),e.jsx("li",{children:"Voice feedback (optional)"})]})]})]}),e.jsxs("main",{className:"math-solver-main",children:[P.length>0?e.jsx("div",{className:"courses-list",children:P.map(s=>{var n,a,d;const t=((n=s.chapters)==null?void 0:n.reduce((r,h)=>{var u;return r+(((u=h.exercises)==null?void 0:u.length)||0)},0))||0;return t===0?null:e.jsxs("div",{className:"course-card",style:{borderLeft:`4px solid ${ie(s.title)}`},children:[e.jsxs("div",{className:`course-header ${b[s.id]?"expanded":""}`,onClick:()=>q(s.id),children:[e.jsx("div",{className:"course-info",children:e.jsxs("div",{className:"course-details",children:[e.jsx("h2",{className:"course-title",children:s.title}),e.jsxs("span",{className:"course-meta",children:[((a=s.chapters)==null?void 0:a.length)||0," chapters · ",t," exercises"]})]})}),e.jsx("span",{className:`expand-icon ${b[s.id]?"expanded":""}`,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),b[s.id]&&e.jsx("div",{className:"chapters-list",children:(d=s.chapters)==null?void 0:d.map(r=>{var u,j;const h=((u=r.exercises)==null?void 0:u.length)||0;return h===0?null:e.jsxs("div",{className:"chapter-card",children:[e.jsxs("div",{className:`chapter-header ${v[r.id]?"expanded":""}`,onClick:()=>G(r.id),children:[e.jsxs("div",{className:"chapter-info",children:[e.jsx("span",{className:"chapter-title",children:r.title}),e.jsxs("span",{className:"chapter-count",children:[h," exercises"]})]}),e.jsx("span",{className:`expand-icon ${v[r.id]?"expanded":""}`,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),v[r.id]&&e.jsx("div",{className:"exercises-grid",children:(j=r.exercises)==null?void 0:j.map(o=>{const J=y[o.exercise_type]||y.numerical,I=C[o.difficulty]||C.medium;return e.jsxs("div",{className:"exercise-card",children:[e.jsx("div",{className:"exercise-header",children:e.jsxs("div",{className:"exercise-badges",children:[e.jsx("span",{className:`difficulty-badge ${o.difficulty}`,style:{backgroundColor:I.color},children:I.label}),o.requires_diagram&&e.jsx("span",{className:"diagram-badge",title:"Requires drawing",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 19l7-7 3 3-7 7-3-3z"}),e.jsx("path",{d:"M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"}),e.jsx("path",{d:"M2 2l7.586 7.586"})]})})]})}),e.jsx("h4",{className:"exercise-title",children:o.title}),e.jsx("p",{className:"exercise-type",children:J.description}),e.jsxs("div",{className:"exercise-footer",children:[H(o.user_status),e.jsx("button",{className:"solve-btn",onClick:K=>{K.stopPropagation(),Y(o.exercise_id)},children:o.user_status==="in_progress"?"Continue":"Solve"})]})]},o.exercise_id)})})]},r.id)})})]},s.id)})}):e.jsxs("div",{className:"no-exercises",children:[e.jsx("h3",{children:"No exercises found"}),e.jsx("p",{children:"Try adjusting your filters or check back later for new content."})]}),(i==null?void 0:i.total)>(i==null?void 0:i.page_size)&&e.jsxs("div",{className:"browse-pagination",children:[e.jsx("button",{className:"pagination-btn",disabled:N<=1,onClick:()=>p(s=>Math.max(1,s-1)),children:"Previous"}),e.jsxs("span",{className:"pagination-status",children:["Page ",i.page||N," of ",Math.
1ceil(i.total/i.page_size)]}),e.jsx("button",{className:"pagination-btn",disabled:!i.has_more,onClick:()=>p(s=>s+1),children:"Next"})]})]})]})]})}export{ae as default};

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.