#!/usr/bin/env node
import {c,h}from'./chunk-D34YFK4M.js';import'./chunk-5TAVYPOV.js';import o from'chalk';import*as $ from'readline';import {execSync}from'child_process';import*as w from'os';function S(){try{return execSync("git config user.name",{encoding:"utf-8",timeout:3e3}).trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").slice(0,20)||"unknown"}catch{try{return w.userInfo().username}catch{return "unknown"}}}function z(s,r){return new Promise(e=>s.question(r,e))}async function x(s){let r=process.cwd(),e=c(r,s);if(e||(console.error(o.red(`
  Quiz "${s}" not found
`)),process.exit(1)),e.questions.length===0){console.log(o.yellow(`
  Quiz "${s}" has no questions.
`));return}let g=$.createInterface({input:process.stdin,output:process.stdout});console.log(o.blue(`
  ${e.title}`)),e.description&&console.log(o.gray(`  ${e.description}`)),console.log(o.gray(`  ${e.questions.length} questions \xB7 Pass: ${e.passThreshold*100}%
`));let c$1=0;for(let i=0;i<e.questions.length;i++){let n=e.questions[i];console.log(o.white(`  ${i+1}. ${n.question}`));let u=Object.keys(n.choices).sort();for(let f of u)console.log(`     ${o.cyan(f)}: ${n.choices[f]}`);let t="";for(;!u.includes(t.toUpperCase());)t=await z(g,o.gray(`  Your answer (${u.join("/")}): `)),t=t.trim().toUpperCase();t===n.correct?(c$1++,console.log(o.green("  Correct!"))):console.log(o.red(`  Wrong \u2014 correct answer: ${n.correct}`)),n.explanation&&console.log(o.gray(`  \u2192 ${n.explanation}`)),console.log();}g.close();let l=e.questions.length,a=Math.round(c$1/l*1e4)/100,p=a/100>=e.passThreshold,d=S();console.log(o.blue("  \u2500\u2500\u2500 Results \u2500\u2500\u2500")),console.log(`  Score: ${c$1}/${l} (${a}%)`),console.log(`  Pass threshold: ${e.passThreshold*100}%`),console.log(p?o.green("  PASSED"):o.red("  FAILED"));let m=`D-${new Date().toISOString().slice(0,10)}-${d}-${s.replace(/^Q-/,"")}`,q={id:m,type:"quiz",student:d,earnedAt:new Date().toISOString(),source:s,score:c$1,total:l,percentage:a,passed:p};h(r,q),console.log(o.gray(`
  Diploma saved: ${m}
`));}export{x as universityQuizCommand};