PageSourceSearch

https://code-mentor-v2.vercel.app/_next/static/chunks/1862.420e13584fa7c031.js

js code-mentor-v2.vercel.app collected 2026-10-03 05:19:37 UTC 31,202 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1862],{11862:function(e,r,t){t.r(r),t.d(r,{DemoSandbox:function(){return k}});var n=t(57437),s=t(2265),o=t(42208),a=t(64972),i=t(56272),d=t(80221),l=t(8522),c=t(45274),u=t(89227),m=t(33276),x=t(51548),p=t(30401),f=t(32489),h=t(62869),b=t(35974),g=t(8548),y=t(11546),j=t(94508);let v=[42,17,89,23,56,12],N=[{id:"binary-search",title:"Binary Search",analogy:"Think of Binary Search like looking up a word in a physical dictionary: rather than flipping page-by-page from the start, you open to the exact middle.",detail:"If your target comes alphabetically before the middle word, you eliminate the entire right half. If it comes after, you eliminate the left half. You repeat this in O(log N) steps.",question:"What is the time complexity of Binary Search on a sorted array of size N?",options:[{label:"A) O(1) constant time",isCorrect:!1},{label:"B) O(log N) logarithmic time",isCorrect:!0},{label:"C) O(N) linear time",isCorrect:!1},{label:"D) O(N\xb2) quadratic time",isCorrect:!1}],explanation:"Because the search space is halved at each comparison, the maximum number of steps is log₂(N)."},{id:"two-pointers",title:"Two Pointers",analogy:"Imagine two friends walking towards each other from opposite ends of a street until they find the exact address that adds up to their target sum.",detail:"Because the list is sorted, if the current sum is too small, you nudge the left pointer right. If too large, you nudge the right pointer left. Zero extra space needed.",question:"What is the space complexity of the classic Two Pointers technique on a sorted array?",options:[{label:"A) O(1) auxiliary space",isCorrect:!0},{label:"B) O(N) auxiliary space",isCorrect:!1},{label:"C) O(N log N) space",isCorrect:!1},{label:"D) O(2^N) space",isCorrect:!1}],explanation:"Two Pointers only requires two integer index variables (left and right), using strictly O(1) constant memory."},{id:"dynamic-programming",title:"Dynamic Programming",analogy:'If I write "1 + 1 + 1 + 1" on the board and ask what it equals, you count 4. If I write another "+ 1" at the end, you immediately say 5 because you remembered the 4 — that memory is the whole trick.',detail:"Dynamic Programming simply remembers past solutions (overlapping subproblems) so you never re-compute what you already solved.",question:"Which two key properties make a problem suitable for Dynamic Programming?",options:[{label:"A) Random access & sorted data",isCorrect:!1},{label:"B) Overlapping subproblems & optimal substructure",isCorrect:!0},{label:"C) Greedy choice & monotonic queue",isCorrect:!1},{label:"D) Amortized constant lookup & hashing",isCorrect:!1}],explanation:"Optimal substructure means optimal solutions to subproblems form the overall optimal solution; overlapping subproblems ensures memoization saves computation."}],w=[{id:"two-sum",title:"Two Sum",studentTitle:"Your Code (O(N\xb2) Brute Force)",studentBadge:"Original",studentCode:"def two_sum(nums, target):\n    # Nested loops check every pair\n    for i in range(len(nums)):\n        for j in range(i + 1, len(nums)):\n            if nums[i] + nums[j] == target:\n                return [i, j]\n    return []",optimalTitle:"AI Ideal Solution (O(N) Hash Map)",optimalBadge:"Optimal \xb7 O(N) Time \xb7 O(N) Space",optimalCode:"def two_sum(nums, target):\n    # Single pass with dictionary lookup\n    seen = {}\n    for i, num in enumerate(nums):\n        diff = target - num\n        if diff in seen:\n            return [seen[diff], i]\n        seen[num] = i\n    return []"},{id:"palindrome",title:"Valid Palindrome",studentTitle:"Your Code (O(N) Space String Reversal)",studentBadge:"Original",studentCode:"def is_palindrome(s):\n    # Allocates full filtered copy in memory\n    cleaned = ''.join(c.lower() for c in s if c.isalnum())\n    return cleaned == cleaned[::-1]",optimalTitle:"AI Ideal Solution (O(1) Space In-Place Two Pointers)",optimalBadge:"Optimal \xb7 O(N) Time \xb7 O(1) Space",optimalCode:"def is_palindrome(s):\n    l, r = 0, len(s) - 1\n    while l < r:\n        while l < r and n
1ot s[l].isalnum(): l += 1\n        while l < r and not s[r].isalnum(): r -= 1\n        if s[l].lower() != s[r].lower(): return False\n        l += 1; r -= 1\n    return True"},{id:"max-subarray",title:"Maximum Subarray",studentTitle:"Your Code (O(N\xb2) All Pairs)",studentBadge:"Original",studentCode:"def max_sub_array(nums):\n    max_sum = float('-inf')\n    for i in range(len(nums)):\n        curr = 0\n        for j in range(i, len(nums)):\n            curr += nums[j]\n            max_sum = max(max_sum, curr)\n    return max_sum",optimalTitle:"AI Ideal Solution (Kadane's Algorithm O(N))",optimalBadge:"Optimal \xb7 O(N) Time \xb7 O(1) Space",optimalCode:"def max_sub_array(nums):\n    curr_sum = max_sum = nums[0]\n    for num in nums[1:]:\n        curr_sum = max(num, curr_sum + num)\n        max_sum = max(max_sum, curr_sum)\n    return max_sum"}];function k(){let[e,r]=(0,s.useState)("sim"),[t,k]=(0,s.useState)(v),[C,S]=(0,s.useState)(0),[_,Z]=(0,s.useState)(!1),[z,T]=(0,s.useState)(0),[O,M]=(0,s.useState)(null),[P,I]=(0,s.use
1State)(!1),[A,R]=(0,s.useState)(0),[B,q]=(0,s.useState)("python"),[E,D]=(0,s.useState)('def two_sum(nums, target):\n    seen = {}\n    for i, num in enumerate(nums):\n        diff = target - num\n        if diff in seen:\n            return [seen[diff], i]\n        seen[num] = i\n    return []\n\nprint("Result:", two_sum([2, 7, 11, 15], 9))'),[F,G]=(0,s.useState)("Result: [0, 1]"),[H,J]=(0,s.useState)(null),[V,X]=(0,s.useState)(null),[Y,W]=(0,s.useState)(!1),L=(0,s.useMemo)(()=>{let e=[],r=[...t],n=r.length;for(let t=0;t<n-1;t++){let s=n-t;for(let o=0;o<n-1-t;o++){let[t,a]=[r[o],r[o+1]],i=t>a;i&&([r[o],r[o+1]]=[r[o+1],r[o]]),e.push({arr:[...r],comp:i?[o+1,o]:[o,o+1],sorted:s<n?Array.from({length:n-s},(e,r)=>s+r):[],log:i?"Comparing ".concat(t," and ").concat(a,": out of order — swapped."):"Comparing ".concat(t," and ").concat(a,": already ordered, no swap.")})}e.push({arr:[...r],comp:null,sorted:Array.from({length:t+1},(e,r)=>n-1-r),log:"".concat(Math.max(...r.slice(n-1-t))," settled in place. ").concat(t<n-2?"Pass ".concat(t+1," done."):"")})}return e.push({arr:[...r],comp:null,sorted:Array.from({length:n},(e,r)=>r),log:"All passes complete — array fully sorted."}),e},[t]),Q=L[Math.min(C,L.length-1)],K=C>=L.length-1,U=(0,s.useRef)(null);(0,s.useEffect)(()=>(_&&!K?U.current=setInterval(()=>{S(e=>e>=L.length-1?(Z(!1),e):e+1)},550):U.current&&clearInterval(U.current),()=>{U.current&&clearInterval(U.current)}),[_,K,L.length]);let $=e=>{q(e),J(null),"python"===e?D('def two_sum(nums, target):\n    seen = {}\n    for i, num in enumerate(nums):\n        diff = target - num\n        if diff in seen:\n            return [seen[diff], i]\n        seen[num] = i\n    return []\n\nprint("Result:", two_sum([2, 7, 11, 15], 9))'):D('function twoSum(nums, target) {\n  const seen = new Map();\n  for (let i = 0; i < nums.length; i++) {\n    const diff = target - nums[i];\n    if (seen.has(diff)) {\n      return [seen.get(diff), i];\n    }\n    seen.set(nums[i], i);\n  }\n  return [];\n}\n\nconsole.log("Result:", twoSum([2, 7, 11, 15], 9));'),G("Result: [0, 1]")},ee=(0,s.useRef)(0),er=async()=>{let e=++ee.current;W(!0),J(null);let r=performance.now();try{let t=await (0,g._5)(B,E);if(e!==ee.current)return;let n=Math.round(performance.now()-r);X(n),G(t.output||(t.error?"":"(no output)")),J(t.error)}catch(r){if(e!==ee.current)return;J((null==r?void 0:r.message)||String(r)),G("")}finally{e===ee.current&&W(!1)}},et=N[z],en=w[A];return(0,n.jsx)("section",{id:"demo",className:"py-16 px-4 sm:px-6 border-t border-border/40 bg-muted/10",children:(0,n.jsxs)("div",{className:"max-w-5xl mx-auto space-y-8",children:[(0,n.jsxs)("div",{className:"text-center space-y-2 max-w-xl mx-auto",children:[(0,n.jsx)("h2",{className:"text-2xl sm:text-3xl font-bold tracking-tight",children:"Try it. Right here."}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Simulations, quizzes, code runner, side-by-side diffs — all live below."})]}),(0,n.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card overflow-hidden shadow-lg",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between px-4 py-3 border-b border-border/50 bg-muted/20 gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/80 animate-pulse"}),(0,n.jsxs)("span",{className:"text-xs font-mono text-muted-foreground hidden sm:inline",children:["sim"===e&&"algorithms/bubble_sort.py","chat"===e&&"socratic/diagnostic_engine.md","diff"===e&&"solutions/two_sum.diff","runner"===e&&("python"===B?"sandbox/main.py":"sandbox/main.js")]})]}),(0,n.jsxs)("div",{role:"tablist","aria-label":"Interactive demo tabs",className:"flex flex-wrap items-center justify-center gap-1 bg-background/60 p-0.5 rounded-lg border border-border/50",children:[(0,n.jsxs)("button",{type:"button",role:"tab","aria-selected":"sim"===e,"aria-controls":"demo-panel-sim",onClick:()=>r("sim"),className:(0,j.cn)("flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-md text-xs font-medium transition-all cursor-pointer","sim"===e?"bg-foreground
1/10 text-foreground font-semibold shadow-xs":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(o.Z,{className:"w-3.5 h-3.5 shrink-0"})," ",(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"hidden sm:inline",children:"Visual "}),"Simulation"]})]}),(0,n.jsxs)("button",{type:"button",role:"tab","aria-selected":"chat"===e,"aria-controls":"demo-panel-chat",onClick:()=>r("chat"),className:(0,j.cn)("flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-md text-xs font-medium transition-all cursor-pointer","chat"===e?"bg-foreground/10 text-foreground font-semibold shadow-xs":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(a.Z,{className:"w-3.5 h-3.5 shrink-0"})," ",(0,n.jsxs)("span",{children:["AI Chat",(0,n.jsx)("span",{className:"hidden sm:inline",children:" & Quiz"})]})]}),(0,n.jsxs)("button",{type:"button",role:"tab","aria-selected":"diff"===e,"aria-controls":"demo-panel-diff",onClick:()=>r("diff"),className:(0,j.cn)("flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-md text-xs font-medium transition-all cursor-pointer","diff"===e?"bg-foreground
1/10 text-foreground font-semibold shadow-xs":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(i.Z,{className:"w-3.5 h-3.5 shrink-0"})," ",(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"hidden sm:inline",children:"Solution "}),"Diff"]})]}),(0,n.jsxs)("button",{type:"button",role:"tab","aria-selected":"runner"===e,"aria-controls":"demo-panel-runner",onClick:()=>r("runner"),className:(0,j.cn)("flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-md text-xs font-medium transition-all cursor-pointer","runner"===e?"bg-foreground/10 text-foreground font-semibold shadow-xs":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(d.Z,{className:"w-3.5 h-3.5 shrink-0"})," ",(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"hidden sm:inline",children:"In-Browser "}),"Runner"]})]})]})]}),"sim"===e&&(0,n.jsxs)("div",{id:"demo-panel-sim",role:"tabpanel",className:"p-6 space-y-6",children:[(0,n.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"font-semibold text-sm text-foreground",children:"Interactive Bubble Sort Simulation"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Click 'Next Step' or press 'Play' to watch comparisons and array swaps in real time."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,n.jsxs)(h.z,{size:"sm",variant:"outline",onClick:()=>{Z(!1),k(Array.from({length:6},()=>Math.floor(85*Math.random()+10))),S(0)},className:"h-8 text-xs gap-1 border-border/60 cursor-pointer",title:"Generate new random array",children:[(0,n.jsx)(l.Z,{className:"w-3 h-3"})," Shuffle"]}),(0,n.jsx)(h.z,{size:"sm",variant:"ghost",onClick:()=>{Z(!1),S(e=>Math.max(0,e-1))},disabled:0===C,className:"h-8 text-xs gap-1 cursor-pointer",title:"Step backward",children:(0,n.jsx)(c.Z,{className:"w-3 h-3"})}),(0,n.jsxs)(h.z,{size:"sm",variant:"outline",onClick:()=>{K&&S(0),Z(!_)},className:"h-8 text-xs gap-1 cursor-pointer",children:[_?(0,n.jsx)(u.Z,{className:"w-3 h-3"}):(0,n.jsx)(m.Z,{className:"w-3 h-3"}),_?"Pause":"Play"]}),(0,n.jsxs)(h.z,{size:"sm",onClick:()=>{Z(!1),S(e=>Math.min(e+1,L.length-1))},className:"h-8 text-xs gap-1 cursor-pointer",disabled:K,children:[(0,n.jsx)(x.Z,{className:"w-3 h-3"})," Next Step"]})]})]}),(0,n.jsxs)("div",{className:"bg-background/60 border border-border/60 rounded-xl p-6 flex flex-col items-center justify-center min-h-[260px] relative overflow-hidden shadow-inner",children:[(0,n.jsxs)("div",{className:"absolute inset-x-8 top-10 bottom-16 pointer-events-none flex flex-col justify-between opacity-15","aria-hidden":"true",children:[(0,n.jsx)("div",{className:"border-b border-dashed border-foreground flex justify-between text-[9px] font-mono",children:(0,n.jsx)("span",{className:"pr-1",children:"100%"})}),(0,n.jsx)("div",{className:"border-b border-dashed border-foreground flex justify-between text-[9px] font-mono",children:(0,n.jsx)("span",{className:"pr-1",children:"75%"})}),(0,n.jsx)("div",{className:"border-b border-dashed border-foreground flex justify-between text-[9px] font-mono",children:(0,n.jsx)("span",{className:"pr-1",children:"50%"})}),(0,n.jsx)("div",{className:"border-b border-dashed border-foreground flex justify-between text-[9px] font-mono",children:(0,n.jsx)("span",{className:"pr-1",children:"25%"})})]}),(0,n.jsx)("div",{className:"flex items-end justify-center gap-3 sm:gap-4 h-44 w-full max-w-lg relative z-10 pt-4 pb-1",children:Q.arr.map((e,r)=>{let s=Q.comp&&(Q.comp[0]===r||Q.comp[1]===r),o=Q.sorted.includes(r),a=Math.max(e/Math.max(...t,100)*100,14);return(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-end h-full gap-1.5 transition-all duration-300 max-w-[54px]",children:[(0,n.jsxs)("div",{className:(0,j.cn)("px-1.5 py-0.5 rounded text-[11px] font-mono font-bold transition-all shadow-xs flex items-center gap-0.5 border",s?"bg-amber-500/15 text-amber-700 dark:text-amber-400 border-amber-500/50 scale-110":o?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 border-emerald-500/50 font-semibold":"bg-card text-foreground border-border/80"),children:[(0,n.jsx)("span",{children:e}),o&&(0,n.jsx)(p.Z,{className:"w-2.5 h-2.5"})]}),(0,n.jsx)("div",{style:{height:"".concat(a,"%")},className:(0,j.cn)("w-full rounded-t-md transition-all duration-300 relative overflow-hidden border shadow-md flex flex-col justify-end items-center",s?"bg-amber-500/25 border-amber-500/60 scale-[1.03]":o?"bg-emerald-500/25 border-emerald-500/60":"bg-gradient-to-t from-zinc-700 via-zinc-600 to-zinc-400 dark:from-zinc-800 dark:via-zinc-700 dark:to-zinc-500 border-zinc-500/50"),children:(0,n.jsx)("div",{className:"absolute inset-0 bg-white/5 bg-[linear-gradient(to_bottom,transparent_4px,#fff1_4px)] bg-[size:100%_8px] pointer-events-none"})}),(0,n.jsxs)("span",{className:(0,j.cn)("text-[10px] font-mono pt-0.5",s?"text-amber-600 dar
1k:text-amber-400 font-bold":o?"text-emerald-600 dark:text-emerald-400 font-medium":"text-muted-foreground/60"),children:["[",r,"]"]})]},r)})}),(0,n.jsxs)("div",{className:"mt-4 px-3.5 py-2 rounded-lg bg-card/80 border border-border/60 text-xs font-mono text-foreground flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary shrink-0"}),(0,n.jsxs)("span",{children:[(0,n.jsxs)("strong",{children:["Step ",C+1,"/",L.length,":"]})," ",Q.log]})]})]})]}),"chat"===e&&(0,n.jsxs)("div",{id:"demo-panel-chat",role:"tabpanel",className:"p-6 space-y-4",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border/40 pb-3",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Select Socratic Topic:"}),(0,n.jsx)("div",{className:"flex items-center gap-1",children:N.map((e,r)=>(0,n.jsx)("button",{type:"button",onClick:()=>{T(r),M(null),I(!1)},className:(0,j.cn)("px-2.5 py-1 rounded text-xs font-medium transition-all cursor-pointer",z===r?"bg-foreground text-background font-semibold shadow-xs":"text-muted-foreground hover:text-foreground hover:bg-muted/40"),children:e.title},e.id))})]}),(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("div",{className:"w-7 h-7 rounded-md bg-foreground
1/10 border border-foreground/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,n.jsx)(a.Z,{className:"w-4 h-4 text-foreground"})}),(0,n.jsxs)("div",{className:"space-y-2 flex-1",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"CodeMentor AI"}),(0,n.jsxs)("div",{className:"p-4 rounded-lg bg-background/60 border border-border/50 text-sm space-y-3",children:[(0,n.jsx)("p",{children:et.analogy}),(0,n.jsx)("p",{className:"text-muted-foreground text-xs leading-relaxed",children:et.detail})]}),(0,n.jsxs)("div",{className:"p-4 rounded-lg border border-border/70 bg-card space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[(0,n.jsx)(a.Z,{className:"w-3.5 h-3.5 text-foreground"})," Socratic Check: ",et.title]}),(0,n.jsx)("p",{className:"text-sm font-medium",children:et.question}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:et.options.map((e,r)=>{let t=O===r,s=e.isCorrect;return(0,n.jsxs)("button",{type:"button","aria-pressed":t,onClick:()=>{M(r),I(!0)},className:(0,j.cn)("p-2.5 rounded-md border text-left text-xs transition-all flex items-center justify-between cursor-pointer",t?s?"border-emerald-600 bg-emerald-500/10 text-foreground font-medium":"border-destructive bg-destructive/10 text-foreground font-medium":"border-border/60 hover:border-foreground
1/30 bg-background/40"),children:[(0,n.jsx)("span",{children:e.label}),t&&(0,n.jsx)("span",{"aria-live":"polite",className:"font-semibold inline-flex items-center gap-1",children:s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.Z,{className:"w-3.5 h-3.5"})," Correct"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(f.Z,{className:"w-3.5 h-3.5"})," Try again"]})})]},r)})}),P&&(0,n.jsxs)("div",{role:"status","aria-live":"polite",className:"text-xs text-muted-foreground bg-muted/20 p-2.5 rounded border border-border/30",children:[(0,n.jsx)("strong",{children:"Explanation:"})," ",et.explanation]}),(0,n.jsx)("div",{className:"pt-2 border-t border-border/30 text-[10px] font-mono text-muted-foreground",children:"Stuck? Hints cost XP — Tier 1 \xb7 5 XP, Tier 2 \xb7 10 XP, Tier 3 \xb7 15 XP"})]})]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground text-center pt-1",children:"The full tutor remembers your mastered, struggling topics and recent mistakes — and reviews resurface right before you'd forget them."})]}),"diff"===e&&(0,n.jsxs)("div",{id:"demo-panel-diff",role:"tabpanel",className:"p-6 space-y-4",children:[(0,n.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 border-b border-border/40 pb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"font-semibold text-sm text-foreground",children:"Side-by-Side Solution Diff"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Compare your submission directly with the AI's clean reference solution to spot performance differences and edge cases."})]}),(0,n.jsx)("div",{className:"flex items-center gap-1",children:w.map((e,r)=>(0,n.jsx)("button",{type:"button",onClick:()=>R(r),className:(0,j.cn)("px-2.5 py-1 rounded text-xs font-medium transition-all cursor-pointer",A===r?"bg-foreground text-background font-semibold shadow-xs":"text-muted-foreground hover:text-foreground hover:bg-muted/40"),children:e.title},e.id))})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 font-mono text-xs",children:[(0,n.jsxs)("div",{className:"border border-border/60 rounded-lg bg-background/70 overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border/40 bg-muted/20 text-muted-foreground flex items-center justify-between",children:[(0,n.jsx)("span",{children:en.studentTitle}),(0,n.jsx)(b.C,{variant:"outline",className:"text-[10px] text-muted-foreground",children:en.studentBadge})]}),(0,n.jsx)("pre",{className:"p-4 overflow-x-auto text-muted-foreground/90 leading-relaxed",children:en.studentCode})]}),(0,n.jsxs)("div",{className:"border border-border/60 rounded-lg bg-background/70 overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border/40 bg-muted/20 text-foreground flex items-center justify-between",children:[(0,n.jsx)("span",{className:"font-medium text-foreground",children:en.optimalTitle}),(0,n.jsx)(b.C,{variant:"outline",className:"text-[10px] text-emerald-700 dark:text-emerald-400 border-emerald-500/30",children:en.optimalBadge})]}),(0,n.jsx)("pre",{className:"p-4 overflow-x-auto text-foreground/90 leading-relaxed",children:en.optimalCode})]})]})]}),"runner"===e&&(0,n.jsxs)("div",{id:"demo-panel-runner",role:"tabpanel",className:"p-6 space-y-4",children:[(0,n.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"font-semibold text-sm text-foreground",children:"Live Code Execution & Error Diagnostics"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Edit any line of code below or inject errors to see real-time compiler/interpreter feedback."}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Practice submissions run on real compilers for Python, JS/TS, Java, C++, Go and more — this demo is fully in-browser."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center bg-background border border-border/60 rounded-md p-0.5",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>
1$("python"),className:(0,j.cn)("px-2.5 py-1 text-xs rounded transition-all font-mono cursor-pointer flex items-center gap-1.5","python"===B?"bg-foreground/10 text-foreground font-semibold":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(y.vD,{size:14,className:"shrink-0"})," ",(0,n.jsx)("span",{children:"Python"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>$("javascript"),className:(0,j.cn)("px-2.5 py-1 text-xs rounded transition-all font-mono cursor-pointer flex items-center gap-1.5","javascript"===B?"bg-foreground/10 text-foreground font-semibold":"text-muted-foreground hover:text-foreground"),children:[(0,n.jsx)(y.sg,{size:14,className:"shrink-0"})," ",(0,n.jsx)("span",{children:"JavaScript"})]})]}),(0,n.jsxs)(h.z,{size:"sm",onClick:er,disabled:Y,className:"h-8 text-xs gap-1.5 font-medium cursor-pointer",children:[(0,n.jsx)(m.Z,{className:"w-3 h-3"})," ",Y?"Running...":"Run Code"]})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap text-xs text-muted-foreground",children:[(0,n.jsx)("span",{children:"Quick Presets:"}),(0,n.jsx)("button",{type:"button",onClick:()=>{"python"===B?D('def is_palindrome(s):\n    cleaned = \'\'.join(c.lower() for c in s if c.isalnum())\n    return cleaned == cleaned[::-1]\n\nprint("Racecar is palindrome?", is_palindrome("Race a car"))\nprint("Radar is palindrome?", is_palindrome("radar"))'):D('function isPalindrome(s) {\n  const clean = s.toLowerCase().replace(/[^a-z0-9]/g, \'\');\n  return clean === clean.split(\'\').reverse().join(\'\');\n}\n\nconsole.log("Racecar is palindrome?", isPalindrome("Race a car"));\nconsole.log("Radar is palindrome?", isPalindrome("radar"));'),J(null),G('(Click "Run Code" to execute)')},className:"px-2 py-0.5 rounded border border-border/50 hover:border-foreground
1/30 bg-muted/20 text-[11px] cursor-pointer",children:"Palindrome Check"}),(0,n.jsx)("button",{type:"button",onClick:()=>{"python"===B?D("def fib(n):\n    if n <= 1:\n        return n\n    return fib(n - 1) + fib(n - 2)\n\nprint([fib(i) for i in range(10)])"):D("function fib(n) {\n  if (n <= 1) return n;\n  return fib(n - 1) + fib(n - 2);\n}\n\nconsole.log(Array.from({ length: 10 }, (_, i) => fib(i)));"),J(null),G('(Click "Run Code" to execute)')},className:"px-2 py-0.5 rounded border border-border/50 hover:border-foreground/30 bg-muted/20 text-[11px] cursor-pointer",children:"Fibonacci Sequence"}),(0,n.jsx)("button",{type:"button",onClick:()=>{"python"===B?D("def broken_code():\n    # This will trigger a ZeroDivisionError\n    num = 100\n    divisor = 0\n    return num / divisor\n\nprint(broken_code())"):D("function brokenCode() {\n  // This will trigger a TypeError\n  const user = null;\n  return user.profile.name;\n}\n\nconsole.log(brokenCode());"),J(null),G('(Click "Run Code" to see error output)')},className:"px-2 py-0.5 rounded border border-destructive/40 hover:border-destructive text-destructive bg-destructive/5 text-[11px] cursor-pointer",children:"Trigger Test Error"})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"border border-border/60 rounded-lg bg-background/90 overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border/40 bg-muted/20 text-xs font-mono text-muted-foreground flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),(0,n.jsx)("span",{children:"python"===B?"main.py":"main.js"})]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Editable in-place"})]}),(0,n.jsxs)("div",{className:"flex font-mono text-xs leading-relaxed",children:[(0,n.jsx)("div",{className:"select-none py-3 pl-3 pr-2 text-muted-foreground/35 text-right font-mono text-xs border-r border-border/30 bg-muted/10 shrink-0",children:E.split("\n").map((e,r)=>(0,n.jsx)("div",{children:r+1},r))}),(0,n.jsx)("textarea",{value:E,onChange:e=>D(e.target.value),rows:Math.max(8,E.split("\n").length),spellCheck:!1,className:"w-full bg-transparent p-3 font-mono text-xs text-foreground focus:outline-none resize-none leading-relaxed"})]})]}),(0,n.jsx)("div",{className:"space-y-2",children:H?(0,n.jsxs)("div",{className:"border border-destructive/50 rounded-lg bg-destructive/10 p-3 font-mono text-xs space-y-1",children:[(0,n.jsx)("div",{className:"text-destructive font-semibold flex items-center gap-1.5",children:(0,n.jsxs)("span",{children:["Execution Error (","python"===B?"Python Traceback":"JavaScript Exception","):"]})}),(0,n.jsx)("pre",{className:"text-destructive whitespace-pre-wrap text-[11px] leading-relaxed overflow-x-auto font-semibold",children:H}),(0,n.jsxs)("div",{className:"text-[10px] text-muted-foreground pt-1",children:["Fix the issue in the editor above and press ",(0,n.jsx)("strong",{children:"Run Code"})," again."]})]}):(0,n.jsxs)("div",{className:"border border-border rounded-lg bg-muted/40 p-3 font-mono text-xs space-y-1",children:[(0,n.jsxs)("div",{className:"text-muted-foreground flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(d.Z,{className:"w-3 h-3 text-emerald-600 dark:text-emerald-400"})," Console Output:"]}),null!==V&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["Executed in ",V,"ms"]})]}),(0,n.jsx)("pre",{role:"status","aria-live":"polite",className:"text-foreground whitespace-pre-wrap",children:F||"(no output)"})]})})]})]})]})]})})}r.default=k},35974:function(e,r,t){t.d(r,{C:function(){return i}});var n=t(57437);t(2265);var s=t(77712),o=t(94508);let a=(0,s.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/80",success:"border-transparent bg-success text-success-foreground hover:bg-success/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i(e){let{className:r,variant:t,...s}=e;return(0,n.jsx)("div",{className:(0,o.cn)(a({variant:t}),r),...s})}},64972:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},42208:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},56272:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},89227:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},8522:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]])},45274:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]])},51548:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]])},80221:function(e,r,t){t.d(r,{Z:function(){return n}});let n=(0,t(79205).Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])}}]);

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.