wrong-notebook 2026.11.5-3 → 2026.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/app/_global-error.html +1 -1
  5. package/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  9. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  10. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  11. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  12. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  13. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  14. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  15. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  16. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  17. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  18. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  19. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  20. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  21. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  22. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  23. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  24. package/.next/server/app/api/import/route.js.nft.json +1 -1
  25. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  26. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  27. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  28. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  29. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  30. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  31. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  32. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  33. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  34. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  35. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  36. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  37. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  38. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  39. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  40. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  41. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  42. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  43. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  44. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  45. package/.next/server/app/exams/page.js.nft.json +1 -1
  46. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  48. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  49. package/.next/server/app/page.js.nft.json +1 -1
  50. package/.next/server/app/page_client-reference-manifest.js +1 -1
  51. package/.next/server/chunks/ssr/[root-of-the-server]__09g6pf6gfjb-i._.js +3 -0
  52. package/.next/server/chunks/ssr/{[root-of-the-server]__0te5kr0_7nmrv._.js → [root-of-the-server]__1t2h6rz1x-gwk._.js} +2 -2
  53. package/.next/server/chunks/ssr/[root-of-the-server]__1vj6th0gehszy._.js +3 -0
  54. package/.next/server/chunks/ssr/_0oo8k-upgx7hb._.js +3 -0
  55. package/.next/server/chunks/ssr/_117fl8dk5qci2._.js +4 -0
  56. package/.next/server/chunks/ssr/_1x-_hs_sw5z1x._.js +3 -0
  57. package/.next/server/chunks/ssr/node_modules_1fwhuynv-5kcg._.js +3 -0
  58. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_0mr1-2rg_ae47.js → node_modules_heic-to_dist_csp_heic-to_1klwivk06jo8p.js} +1 -1
  59. package/.next/server/chunks/ssr/src_0atwwo6buvs3b._.js +3 -0
  60. package/.next/server/chunks/ssr/src_app_exams_page_tsx_17_d4_gy2i1ds._.js +1 -1
  61. package/.next/server/chunks/ssr/src_app_notebooks_[id]_add_page_tsx_179tow1ql6vc_._.js +1 -1
  62. package/.next/server/chunks/ssr/src_app_page_tsx_1chiuahujsxm1._.js +1 -1
  63. package/.next/server/chunks/ssr/src_components_image-cropper_tsx_0pcp8-ifruyx-._.js +1 -1
  64. package/.next/server/middleware-build-manifest.js +3 -3
  65. package/.next/server/pages/500.html +1 -1
  66. package/.next/server/preview-props.json +3 -3
  67. package/.next/server/server-reference-manifest.js +1 -1
  68. package/.next/server/server-reference-manifest.json +1 -1
  69. package/.next/static/chunks/0xze-7xwdgel2.js +8 -0
  70. package/.next/static/chunks/16c0c5ykflqpn.js +1 -0
  71. package/.next/static/chunks/1qb_yt4hvopfn.js +8 -0
  72. package/.next/static/chunks/1ziwji7xw98fj.js +9 -0
  73. package/.next/static/chunks/25jnmrgxyy1tx.js +1 -0
  74. package/.next/static/chunks/3_wki8y0qb28v.js +1 -0
  75. package/.next/static/chunks/{1q3saz647fqri.js → 3ios-g8cm_1vz.js} +1 -1
  76. package/package.json +1 -1
  77. package/prisma/seed.db +0 -0
  78. package/.next/server/chunks/ssr/[root-of-the-server]__0uezowk-9l0x4._.js +0 -3
  79. package/.next/server/chunks/ssr/[root-of-the-server]__12jk2bmesr4gc._.js +0 -3
  80. package/.next/server/chunks/ssr/_127aw5h992s9d._.js +0 -4
  81. package/.next/server/chunks/ssr/_1t-o815u40ng2._.js +0 -3
  82. package/.next/server/chunks/ssr/node_modules_1m0t7n1f8dlgz._.js +0 -3
  83. package/.next/server/chunks/ssr/node_modules_heic-to_dist_csp_heic-to_1m3ywmnbpcnde.js +0 -3
  84. package/.next/server/chunks/ssr/src_1nbi4yrww3r1m._.js +0 -3
  85. package/.next/static/chunks/0gu34v572tj7o.js +0 -1
  86. package/.next/static/chunks/0lnx4h7lv4ev5.js +0 -16
  87. package/.next/static/chunks/2bk5f71d5ke2y.js +0 -1
  88. package/.next/static/chunks/2lhxk-8dpncxq.js +0 -1
  89. package/.next/static/chunks/2n2hvugnmgoy3.js +0 -16
  90. package/.next/static/chunks/3_w-p8241f5rv.js +0 -1
  91. /package/.next/static/{T6hfqhqpSQ_GF78vCYl3P → vv9z38w24wHWYLUAbjtdk}/_buildManifest.js +0 -0
  92. /package/.next/static/{T6hfqhqpSQ_GF78vCYl3P → vv9z38w24wHWYLUAbjtdk}/_clientMiddlewareManifest.js +0 -0
  93. /package/.next/static/{T6hfqhqpSQ_GF78vCYl3P → vv9z38w24wHWYLUAbjtdk}/_ssgManifest.js +0 -0
@@ -1,16 +0,0 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,615568,168148,e=>{var t=e.i(456420);let s={name:"pencil-line",size:24,node:[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]};s.node;let r=(0,t.f)(s);e.s(["f",0,r],615568);var n=e.i(843476),a=e.i(271645),i=e.i(30030),l=e.i(248425),o=Object.defineProperty,u=(e,t)=>o(e,"name",{value:t,configurable:!0}),d="Progress",[c,m]=(0,i.f)(d),[f,h]=c(d),g=a.forwardRef(u(function(e,t){let{__scopeProgress:s,value:r=null,max:a,getValueLabel:i=x,...o}=e;(a||0===a)&&!v(a)&&console.error(b(`${a}`,"Progress"));let u=v(a)?a:100;null===r||j(r,u)||console.error(k(`${r}`,"Progress"));let d=j(r,u)?r:null,c=y(d)?i(d,u):void 0;return(0,n.jsx)(f,{scope:s,value:d,max:u,children:(0,n.jsx)(l.V.div,{"aria-valuemax":u,"aria-valuemin":0,"aria-valuenow":y(d)?d:void 0,"aria-valuetext":c,role:"progressbar","data-state":w(d,u),"data-value":d??void 0,"data-max":u,...o,ref:t})})},"Progress")),p=a.forwardRef(u(function(e,t){let{__scopeProgress:s,...r}=e,a=h("ProgressIndicator",s);return(0,n.jsx)(l.V.div,{"data-state":w(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})},"ProgressIndicator"));function x(e,t){return`${Math.round(e/t*100)}%`}function w(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function y(e){return"number"==typeof e}function v(e){return y(e)&&!isNaN(e)&&e>0}function j(e,t){return y(e)&&!isNaN(e)&&e<=t&&e>=0}function b(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}function k(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
2
- - a positive number
3
- - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)
4
- - \`null\` or \`undefined\` if the progress is indeterminate.
5
-
6
- Defaulting to \`null\`.`}u(x,"defaultGetValueLabel"),u(w,"getProgressState"),u(y,"isNumber"),u(v,"isValidMaxNumber"),u(j,"isValidValueNumber"),u(b,"getInvalidMaxError"),u(k,"getInvalidValueError");var N=e.i(975157);let S=a.forwardRef(({className:e,value:t,...s},r)=>(0,n.jsx)(g,{ref:r,value:t,className:(0,N.f)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...s,children:(0,n.jsx)(p,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));S.displayName=g.displayName,e.s(["f",0,S],168148)},866531,497346,183444,e=>{var t=e.i(843476),s=e.i(271645),r=e.i(632781),n=e.i(741120),a=e.i(856522),i=e.i(314381),l=e.i(3198),o=e.i(519455),u=e.i(111110),d=e.i(41931),c=e.i(294114),m=e.i(201276);function f({data:e,onChange:n}){let{t:a}=(0,u.b)(),[h,g]=(0,s.useState)(!1),[p,x]=(0,s.useState)(null),w=async()=>{if(!e.questionText.trim())return void c.c.warning(a.editor.enterQuestionFirst||"Please enter question text first");if(!e.answerText.trim())return void c.c.warning(a.geogebra.answerRequired);g(!0),x(null);try{let t=await d.k.post("/api/geogebra-analyze",{questionText:e.questionText,answerText:e.answerText,analysis:e.analysis},{timeout:18e4,recoverable:!0});t.suitable&&t.commands&&t.commands.length>0?n({geogebraCommands:JSON.stringify(t.commands)}):x(t.description||a.geogebra.notSuitable)}catch(e){m.V.error("[CorrectionEditor]","GeoGebra analysis failed",{error:e}),x(a.geogebra.analyzeFailed)}finally{g(!1)}};return e.geogebraCommands?(0,t.jsx)(l.f,{commands:e.geogebraCommands,height:350,onRegenerate:w,onDelete:async()=>n({geogebraCommands:void 0})}):e.questionText.trim()&&e.answerText.trim()?(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(i.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:a.geogebra.title})]}),(0,t.jsx)(o.f,{variant:"outline",size:"sm",onClick:w,disabled:h,children:h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.geogebra.analyzing]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.f,{className:"mr-2 h-4 w-4"}),a.geogebra.generate]})})]}),p&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:p}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:a.geogebra.hint})]}):null}var h=e.i(469937),g=e.i(28342),p=e.i(438465),x=e.i(674166),w=e.i(110204),y=e.i(967489),v=e.i(401280);function j({data:e,paperLevel:s,onChange:r}){let{t:n}=(0,u.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:n.editor.selectNotebook||"Select Notebook"}),(0,t.jsx)(p.f,{value:e.subjectId,onChange:e=>r({subjectId:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:n.questionType.label||"Question Type"}),(0,t.jsxs)(y.d,{value:e.questionType||"",onValueChange:e=>r({questionType:e===v.O?null:e}),children:[(0,t.jsx)(y.P,{children:(0,t.jsx)(y.U,{placeholder:n.questionType.notSet||"Not set"})}),(0,t.jsxs)(y.r,{children:[(0,t.jsx)(y.T,{value:v.O,children:n.questionType.clear||"Clear"}),v.V.map(e=>(0,t.jsx)(y.T,{value:e,children:n.questionType.names?.[e]||e},e))]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{htmlFor:"correction-grade-semester",children:n.editor.gradeSemester||"Grade/Semester"}),(0,t.jsx)(g.f,{id:"correction-grade-semester",value:e.gradeSemester||"",onChange:e=>r({gradeSemester:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:n.editor.paperLevel||"Paper Level"}),(0,t.jsx)(x.f,{value:s,onChange:e=>r({paperLevel:e})})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:n.difficulty.label}),(0,t.jsx)("div",{children:(0,t.jsx)(h.f,{size:"md",value:e.difficultyStars,onChange:e=>r({difficultyStars:e})})})]})]})}var b=e.i(141176),k=e.i(515288);function N({data:e,onChange:s}){let{t:r}=(0,u.b)();return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(k.v,{children:r.editor.mistakeAnalysisTitle||"Mistake Analysis"})}),(0,t.jsxs)(k.O,{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:r.editor.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(y.d,{value:e.mistakeStatus||"unknown",onValueChange:e=>s({mistakeStatus:e}),children:[(0,t.jsx)(y.P,{children:(0,t.jsx)(y.U,{})}),(0,t.jsxs)(y.r,{children:[(0,t.jsx)(y.T,{value:"not_attempted",children:r.editor.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(y.T,{value:"wrong_attempt",children:r.editor.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(y.T,{value:"unknown",children:r.editor.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:r.editor.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(b.f,{value:e.wrongAnswerText||"",onChange:t=>s({wrongAnswerText:t,mistakeStatus:t.trim()?"wrong_attempt":e.mistakeStatus}),className:"min-h-[100px] font-mono text-sm",placeholder:r.editor.wrongAnswerPlaceholder||"Leave blank if no wrong answer is visible"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:r.editor.mistakeAnalysis||"Mistake Cause Analysis"}),(0,t.jsx)(b.f,{value:e.mistakeAnalysis||"",onChange:e=>s({mistakeAnalysis:e}),className:"min-h-[140px] font-mono text-sm",placeholder:r.editor.mistakeAnalysisPlaceholder||"Explain where and why the mistake happened"})]})]})]})}var S=e.i(511445),T=e.i(149704);function A({title:e,children:s,className:r}){return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(k.v,{children:e})}),(0,t.jsx)(k.O,{className:r,children:s})]})}function I({data:e,children:s}){let{t:r}=(0,u.b)(),n={wrong_attempt:r.editor.mistakeStatuses?.wrongAttempt||"Wrong attempt",not_attempted:r.editor.mistakeStatuses?.notAttempted||"Not attempted",unknown:r.editor.mistakeStatuses?.unknown||"Unknown"};return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(A,{title:r.editor.preview?.question||"Question Preview",children:[(0,t.jsx)(S.f,{content:e.questionText}),(0,t.jsx)(T.f,{svg:e.figureSvg})]}),s,(0,t.jsx)(A,{title:r.editor.preview?.answer||"Answer Preview",children:(0,t.jsx)(S.f,{content:e.answerText})}),(0,t.jsx)(A,{title:r.editor.preview?.analysis||"Analysis Preview",children:(0,t.jsx)(S.f,{content:e.analysis})}),(0,t.jsxs)(A,{title:r.editor.preview?.mistakeAnalysis||"Mistake Analysis Preview",className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"text-muted-foreground",children:[r.editor.mistakeStatus||"Attempt Status",r.common.colon,n[e.mistakeStatus]??n.unknown]}),e.wrongAnswerText&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium mb-1",children:r.editor.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(S.f,{content:e.wrongAnswerText})]}),e.mistakeAnalysis&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium mb-1",children:r.editor.mistakeAnalysis||"Mistake Cause Analysis"}),(0,t.jsx)(S.f,{content:e.mistakeAnalysis})]})]})]})}var E=e.i(574041),$=e.i(215519),_=e.i(306831);e.i(676167);var C=e.i(597138),R=e.i(991722),M=e.i(470279),O=e.i(303163);e.s(["f",0,function({initialData:e,onSave:i,onCancel:l,imagePreview:h,initialSubjectId:g,aiTimeout:p}){let{timeZone:x}=(0,$.M)(),{t:y,language:v}=(0,u.b)(),S=e=>e.trim()?e:"",[T,A]=(0,s.useState)({...e,answerText:S(e.answerText),analysis:S(e.analysis),wrongAnswerText:e.wrongAnswerText||"",mistakeAnalysis:e.mistakeAnalysis||"",mistakeStatus:e.mistakeStatus||"unknown",subjectId:g,gradeSemester:e.gradeSemester||""}),q=(0,s.useRef)(!1),P=e=>{"gradeSemester"in e&&(q.current=!0),A(t=>({...t,...e}))},{groups:U}=(0,M.f)(),V=(()=>{if(T.paperLevel)return T.paperLevel;let e="number"==typeof T.difficultyStars&&T.difficultyStars>=4?"b":"a";return U.find(t=>t.key===e&&t.isActive)?.id||""})(),L=T.paperLevel??V,[F,H]=(0,s.useState)(!1),[G,z]=(0,s.useState)(!1),[D,Q]=(0,s.useState)(!1),[W,B]=(0,s.useState)(void 0),[J,Z]=(0,s.useState)([]);(0,s.useEffect)(()=>{d.k.get("/api/notebooks").then(Z).catch(e=>m.V.error("[CorrectionEditor]","Failed to fetch notebooks",{error:e})),d.k.get("/api/user").then(e=>{if(Q(!!e?.enableGeogebra),e){let t=function(e,t=_.J){return"ai"===e.gradeRecognitionMode?null:e.fixedGradeSemester?e.fixedGradeSemester:e.educationStage&&e.enrollmentYear?function(e,t,s=new Date,r="en",n=_.J){let a=(0,_.c)(s,n),i=a.getFullYear(),l=a.getMonth()+1,o=i-t,u="2nd";l>=9?(o+=1,u="1st"):u=l<2?"1st":"2nd";let d="zh"===r,c=d?"1st"===u?"上期":"下期":"1st"===u?"1st Semester":"2nd Semester",m=(d?{primary:["一年级","二年级","三年级","四年级","五年级","六年级"],junior_high:["初一","初二","初三"],senior_high:["高一","高二","高三"],university:["大一","大二","大三","大四"]}:{primary:["Grade 1","Grade 2","Grade 3","Grade 4","Grade 5","Grade 6"],junior_high:["Junior High Grade 1","Junior High Grade 2","Junior High Grade 3"],senior_high:["Senior High Grade 1","Senior High Grade 2","Senior High Grade 3"],university:["Freshman","Sophomore","Junior","Senior"]})[e]||[],f=`${o}`;if(f=o>0&&o<=m.length?m[o-1]:o>m.length?d?"已毕业":"Graduated":d?"学前":"Pre-school",!d)return`${f}, ${c}`;{let e="1st"===u?"上":"下";return`${f}${e}`}}(e.educationStage,e.enrollmentYear,new Date,"zh",t):null}(e,x);A(e=>e.gradeSemester||q.current?e:{...e,gradeSemester:t||""}),B(e.educationStage||void 0)}}).catch(e=>m.V.error("[CorrectionEditor]","Failed to fetch user info for grade calculation",{error:e}))},[v,x]);let X=async()=>{if(!T.questionText.trim())return void c.c.warning(y.editor.enterQuestionFirst||"Please enter question text first");H(!0);try{let e=function({questionText:e,language:t,subject:s,imagePreview:r,gradeSemester:n,subjectId:a}){let i={questionText:e,language:t,subject:s};return r&&(i.imageBase64=r),n&&(i.gradeSemester=n),a&&(i.subjectId=a),i}({questionText:T.questionText,language:v,subject:T.subject,imagePreview:h,gradeSemester:T.gradeSemester??void 0,subjectId:T.subjectId});m.V.info("[Reanswer]",e.imageBase64?"Sending image + text (image available for mistake analysis)":"Sending text only (no image available)",{timeout:p});let t=await d.k.post("/api/reanswer",e,{timeout:p||18e4,recoverable:!0});A(e=>({...e,answerText:t.answerText,analysis:t.analysis,knowledgePoints:t.knowledgePoints,wrongAnswerText:t.wrongAnswerText||"",mistakeAnalysis:t.mistakeAnalysis||"",mistakeStatus:(0,R.x)(t.mistakeStatus,t.wrongAnswerText),difficultyStars:t.difficultyStars??e.difficultyStars,questionType:t.questionType??e.questionType})),c.c.success(y.editor.reanswerSuccess||"✅ Answer and analysis updated!")}catch(r){let e,t,s;m.V.error("[CorrectionEditor]","Reanswer failed",{error:r}),c.c.error((e=(0,O.d)(r)||"",s=(t=y.errors?.reanswer||{}).default||"Reanswer failed",e.includes("AI_AUTH_ERROR")?t.authError||y.errors?.AI_AUTH_ERROR||s:e.includes("AI_CONNECTION_FAILED")?t.connectionFailed||y.errors?.AI_CONNECTION_FAILED||s:e.includes("AI_RESPONSE_ERROR")&&(t.responseError||y.errors?.AI_RESPONSE_ERROR)||s))}finally{H(!1)}},Y=async()=>{if(!T.subjectId)return void c.c.warning(y.editor.messages?.selectNotebook||"Please select a notebook");if(!G){z(!0);try{await i({...T,paperLevel:L,mistakeStatus:(0,R.x)(T.mistakeStatus,T.wrongAnswerText)})}finally{z(!1)}}},K=y.editor.placeholder||"Supports Markdown and LaTeX...",ee=(0,C.f)(J.find(e=>e.id===T.subjectId)?.name||null)||(0,C.f)(T.subject||null)||void 0;return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold",children:y.editor.title}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(o.f,{variant:"outline",onClick:l,children:y.editor.cancel}),(0,t.jsxs)(o.f,{onClick:Y,disabled:G,children:[G?(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(a.f,{className:"mr-2 h-4 w-4"}),G?y.common?.pleaseWait||"Please wait...":y.editor.save]})]})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[h&&(0,t.jsx)(k.N,{children:(0,t.jsx)(k.O,{className:"p-4",children:(0,t.jsx)("img",{src:h,alt:"Original",className:"w-full rounded-md"})})}),(0,t.jsx)(j,{data:T,paperLevel:L,onChange:P}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:y.editor.question}),(0,t.jsx)(b.f,{value:T.questionText,onChange:e=>P({questionText:e}),className:"min-h-[150px] font-mono text-sm",placeholder:K}),(0,t.jsx)(o.f,{variant:"default",size:"sm",onClick:X,disabled:F||!T.questionText.trim(),className:"w-full bg-gradient-to-r from-indigo-600 to-violet-500 hover:from-indigo-700 hover:to-violet-600 text-white font-medium",children:F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}),y.editor.reanswering||"AI solving..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.f,{className:"mr-2 h-4 w-4"}),y.editor.reanswer||"🔄 Reanswer (based on corrected question)"]})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:y.editor.reanswerHint||"💡 If the question was misrecognized, correct it and click to regenerate answer"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:y.editor.tags}),(0,t.jsx)(E.f,{value:T.knowledgePoints,onChange:e=>P({knowledgePoints:e}),placeholder:y.editor.tagsPlaceholder||"Enter knowledge tags...",enterHint:y.editor.createTagHint,subject:ee,gradeStage:W}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:y.editor.tagsHint||"💡 Tag suggestions will appear as you type"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:y.editor.answer}),(0,t.jsx)(b.f,{value:T.answerText,onChange:e=>P({answerText:e}),className:"min-h-[100px] font-mono text-sm",placeholder:K})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(w.f,{children:y.editor.analysis}),(0,t.jsx)(b.f,{value:T.analysis,onChange:e=>P({analysis:e}),className:"min-h-[200px] font-mono text-sm",placeholder:K})]}),(0,t.jsx)(N,{data:T,onChange:P})]}),(0,t.jsx)(I,{data:T,children:D&&(0,t.jsx)(f,{data:T,onChange:P})})]})]})}],866531);var q=e.i(853138),P=e.i(263676);e.s(["f",0,function({message:e,onDismiss:s}){let{t:r}=(0,u.b)();return e?(0,t.jsxs)("div",{role:"alert",className:"flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[(0,t.jsx)(q.f,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0"}),(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:e}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":r.common.close,className:"shrink-0 rounded p-1 hover:bg-destructive/10",children:(0,t.jsx)(P.X,{"aria-hidden":"true",className:"h-4 w-4"})})]}):null}],497346);var U=e.i(618566),V=e.i(707212);function L(e){return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}function F(e,t){if("string"!=typeof e||!/^(QUESTION_SAVE_|AI_)[A-Z_]+$/.test(e))return;let s=t.errors[e];return"string"==typeof s?s:void 0}e.s(["f",0,function(e){let{t}=(0,u.b)(),r=(0,U.useRouter)(),[n,a]=(0,s.useState)(null),i=async(s,n,i=!0)=>{a(null);try{let e=await s();return c.c.success(e.duplicate?t.importFlow.duplicate:t.common.messages.saveSuccess),i&&(e.duplicate?r.push(`/error-items/${e.id}`):n&&r.push(`/notebooks/${n}`)),!0}catch(r){m.V.error(e,"Save failed",{errorMessage:(0,O.d)(r)??(0,O.Z)(r)});let s=function(e,t){let s=L(e),r=L(s?.data),n="number"==typeof s?.status?s.status:void 0,a=(0,O.d)(e),i=F(a,t)??F(r?.code,t),l={400:t.errors.QUESTION_SAVE_INVALID_INPUT,401:t.errors.QUESTION_SAVE_UNAUTHORIZED,403:t.errors.QUESTION_SAVE_FORBIDDEN,408:t.errors.QUESTION_SAVE_TIMEOUT,409:t.errors.QUESTION_SAVE_CONFLICT,413:t.errors.QUESTION_SAVE_TOO_LARGE,429:t.errors.QUESTION_SAVE_RATE_LIMITED,502:t.errors.QUESTION_SAVE_SERVER_UNAVAILABLE,503:t.errors.QUESTION_SAVE_SERVER_UNAVAILABLE,504:t.errors.QUESTION_SAVE_TIMEOUT},o=i??(n?l[n]:void 0)??t.errors.QUESTION_SAVE_FAILED;!n&&(e instanceof TypeError||/fetch|network|load failed/i.test((0,O.Z)(e)))&&(o=t.errors.QUESTION_SAVE_NETWORK_ERROR);let u=L(r?.details);if("QUESTION_SAVE_GRADE_FAILED"===a){let e=F(u?.reason,t);e&&(o+=`
7
- ${e}`)}return 400===n&&(o+=(function(e,t){if(!Array.isArray(e))return[];let s={questionText:t.editor.question,answerText:t.editor.answer,analysis:t.editor.analysis,wrongAnswerText:t.editor.wrongAnswerText,mistakeAnalysis:t.editor.mistakeAnalysis,knowledgePoints:t.editor.tags,subjectId:t.editor.selectNotebook,gradeSemester:t.editor.gradeSemester,paperLevel:t.editor.paperLevel};return e.slice(0,3).flatMap(e=>{let r=L(e),n=r?.path,a=Array.isArray(n)&&"string"==typeof n[0]?s[n[0]]:void 0;if(!a)return[];let i=r?.maximum,l=t.questionSave.invalidField;return r?.code==="too_big"&&"number"==typeof i&&Number.isSafeInteger(i)&&i>=0&&(l="array"===r.origin?t.questionSave.tooMany:t.questionSave.tooLong),[l.replace("{field}",a).replace("{maximum}",String(i))]})})(r?.details,t).map(e=>`
8
- ${e}`).join("")),"string"==typeof u?.databaseCode&&/^P\d{4}$/.test(u.databaseCode)&&(o+=`
9
- ${t.questionSave.databaseCode.replace("{code}",u.databaseCode)}`),n&&(o+=` (HTTP ${n})`),o}(r,t);return a(s),(0,V.t)((0,O.d)(r))||c.c.error(s),!1}};return{saveError:n,setSaveError:a,dismissSaveError:()=>a(null),run:i}}],183444)},731335,532377,339501,e=>{var t=e.i(843476),s=e.i(399847),r=e.i(551757),n=e.i(456420);let a={name:"clock-3",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]};a.node;let i=(0,n.f)(a);var l=e.i(632781),o=e.i(615568),u=e.i(487486),d=e.i(519455),c=e.i(168148),m=e.i(111110),f=e.i(215519),h=e.i(306831);let g=["read","convert","crop","compress","upload"],p=["receive","analyze","save"];function x(e){if(!Number.isFinite(e)||e<0)return"-";if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(+(t<10))}s`;let s=Math.round(t);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`}var w=e.i(975157);let y={analyzing:50,saving:90},v={analyzing:l.f,saving:l.f,review:o.f,saved:r.f,failed:s.f};e.s(["f",0,function({task:e,now:s,onReview:r,onViewItem:n,onRetry:a,onDiscard:l}){let{t:o}=(0,m.b)(),{timeZone:j}=(0,f.M)(),b=v[e.status],k="analyzing"===e.status||"saving"===e.status,N=o.errors,S=e.error?"string"==typeof N[e.error]?N[e.error]:e.error:null,T=function(e){let t=[];for(let s of g){let r=e?.client?.[s];"number"==typeof r&&t.push({stage:s,ms:r})}for(let s of p){let r=e?.server?.[s];"number"==typeof r&&t.push({stage:s,ms:r})}return t}(e.timings),A=k&&s?s-Date.parse(e.createdAt):null;return(0,t.jsxs)("div",{className:(0,w.f)("space-y-2 rounded-lg border p-3 text-sm",e.unread&&"border-primary/50 bg-primary/5"),"data-testid":"import-task-card","data-status":e.status,children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(b,{className:(0,w.f)("mt-0.5 h-4 w-4 shrink-0",k&&"animate-spin text-primary","saved"===e.status&&"text-green-600","failed"===e.status&&"text-destructive","review"===e.status&&"text-primary")}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:o.importTasks.status[e.status]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:o.importTasks.mode[e.mode]}),e.unread&&(0,t.jsx)(u.f,{children:o.importTasks.unread})]}),k&&(0,t.jsx)(c.f,{value:y[e.status],"aria-label":o.importTasks.stageEstimate,"aria-valuetext":o.common.progress.estimated.replace("{percent}",String(y[e.status])),className:"h-1.5"}),e.excerpt&&(0,t.jsx)("p",{className:"break-words text-muted-foreground",children:e.excerpt}),"saved"===e.status&&!e.errorItemId&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o.importTasks.itemDeleted}),"saved"===e.status&&e.errorItemId&&(0,t.jsx)("p",{className:"text-xs text-green-700 dark:text-green-300",children:e.duplicate?o.importTasks.duplicateSaved:o.importTasks.savedTo.replace("{notebook}",e.notebookName||"-").replace("{id}",e.errorItemShortId||"-")}),S&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:S}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(i,{className:"h-3 w-3"}),o.importTasks.createdAt.replace("{time}",(0,h.r)(e.createdAt,"MM-dd HH:mm",j))]}),null!==A&&(0,t.jsx)("span",{children:o.importTasks.elapsed.replace("{time}",x(A))}),e.attempts>1&&(0,t.jsx)("span",{children:o.importTasks.attempts.replace("{count}",String(e.attempts))})]}),T.length>0&&(0,t.jsx)("ul",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground tabular-nums","aria-label":"timings",children:T.map(({stage:e,ms:s})=>(0,t.jsxs)("li",{children:[o.importTasks.timings[e]," ",x(s)]},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:["review"===e.status&&r&&(0,t.jsx)(d.f,{size:"sm",onClick:r,children:o.importTasks.continueReview}),"saved"===e.status&&e.errorItemId&&n&&(0,t.jsx)(d.f,{size:"sm",variant:"outline",onClick:n,children:o.importTasks.viewItem}),"failed"===e.status&&a&&(0,t.jsx)(d.f,{size:"sm",onClick:a,children:o.importTasks.retry}),"saving"!==e.status&&"saved"!==e.status&&l&&(0,t.jsx)(d.f,{size:"sm",variant:"ghost",onClick:l,children:o.importTasks.discard})]})]})}],731335);var j=e.i(618566),b=e.i(767077),k=e.i(294114),N=e.i(201276),S=e.i(127175);e.s(["f",0,function(e){let{t}=(0,m.b)(),s=(0,j.useRouter)(),r=e=>{e.unread&&(0,S.N)(e.id).catch(e=>N.V.warn("[ImportTasks]","Mark read failed",{error:e}))};return{openReview:e=>{r(e),s.push(`/import-tasks/${e.id}`)},viewItem:e=>{e.errorItemId&&(r(e),s.push(`/error-items/${e.errorItemId}`))},markRead:r,retry:async s=>{try{await (0,S.R)(s.id),k.c.info(t.importTasks.retried)}catch(e){k.c.error((0,b.f)(e,t))}e?.()},discard:async s=>{if(!await (0,k.u)(t.importTasks.discardConfirm))return!1;let r=!1;try{await (0,S.x)(s.id),k.c.success(t.importTasks.discarded),r=!0}catch(e){k.c.error((0,b.f)(e,t))}return e?.(),r}}}],532377);var T=e.i(271645);e.s(["f",0,function(e,t=1e3){let[s,r]=(0,T.useState)(()=>Date.now());return(0,T.useEffect)(()=>{if(!e)return;let s=setInterval(()=>r(Date.now()),t);return()=>clearInterval(s)},[e,t]),s}],339501)},185592,e=>{var t=e.i(843476),s=e.i(975157);e.s(["f",0,function({options:e,value:r,onChange:n,className:a}){return(0,t.jsx)("div",{className:(0,s.f)("grid gap-1 rounded-xl bg-muted p-1",a),style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},role:"tablist",children:e.map(({value:e,label:a,icon:i})=>{let l=e===r;return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":l,className:(0,s.f)("flex items-center justify-center gap-1.5 rounded-lg px-2 py-2.5 text-sm font-medium transition-all",l?"bg-card text-primary shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>n(e),children:[i&&(0,t.jsx)(i,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]},e)})})}])},499930,e=>{var t=e.i(213761);function s(e,t=.008){let r=Math.max(0,e.x-t),n=Math.max(0,e.y-t);return{x:r,y:n,width:Math.min(1,e.x+e.width+t)-r,height:Math.min(1,e.y+e.height+t)-n}}async function r(e){let t=new Image;if(t.decoding="async",t.src=e,await t.decode(),!t.naturalWidth||!t.naturalHeight)throw Error("IMAGE_EMPTY");return t}async function n(e,s){let r=function(e,t=16,s=!1){let r=Math.max(...e.map(e=>e.width)),n=0,a=e.map(e=>{let a=s?r/e.width:e.scale??1,i={x:0,y:n,width:Math.round(e.width*a),height:Math.round(e.height*a)};return n+=i.height+t,i});return{width:Math.max(...a.map(e=>e.width)),height:n-t,rects:a}}(e.map(e=>({width:e.sw,height:e.sh,scale:e.scale})),16,s),n=document.createElement("canvas");n.width=r.width,n.height=r.height;let a=n.getContext("2d");if(!a)throw Error("CANVAS_UNSUPPORTED");a.fillStyle="#ffffff",a.fillRect(0,0,n.width,n.height),e.forEach((e,t)=>{let s=r.rects[t];a.drawImage(e.source,e.sx,e.sy,e.sw,e.sh,s.x,s.y,s.width,s.height)});let i=await createImageBitmap(n);try{return await (0,t.X)({source:i,width:n.width,height:n.height})}finally{i.close()}}async function a(e,r){let a=e.naturalWidth,i=e.naturalHeight,l=r.map(e=>s(e));return 1===l.length?(0,t.X)({source:e,width:a,height:i},l[0]):n(l.map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*i),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*i))})),!1)}async function i(e){return n((await Promise.all(e.map(r))).map(e=>({source:e,sx:0,sy:0,sw:e.naturalWidth,sh:e.naturalHeight})),!0)}async function l(e,t,r){let a=e.naturalWidth,i=e.naturalHeight,l=r.width/a,o=t.map(e=>s(e)).map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*i),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*i)),scale:l}));return o.push({source:r.source,sx:0,sy:0,sw:r.width,sh:r.height}),n(o,!1)}e.s(["y",0,r,"k",0,l,"M",0,a,"v",0,i])},119472,e=>{var t=e.i(41931),s=e.i(127175);async function r(e){let t;for(let s=0;s<3;s++)try{return await e()}catch(e){if(t=e,!function(e){let t=e?.status;return void 0===t||408===t||502===t||503===t||504===t}(e)||2===s)break;await new Promise(e=>setTimeout(e,1e3*(s+1)))}throw t}async function n(e,a=(0,s.c)()){let{batch:i}=await r(()=>t.k.post("/api/import-batches",{...e,clientRequestId:a,subjectId:e.subjectId||void 0,targetSubjectId:e.targetSubjectId||void 0,paperLevel:e.paperLevel||void 0,items:e.items?.map(e=>({...e})),origin:e.origin},{timeout:12e4}));return(0,s.P)(),i}async function a(e,s={}){let r=s.image?"?include=image":"",{batch:n}=await t.k.get(`/api/import-batches/${encodeURIComponent(e)}${r}`);return n}async function i(e,s,r){let{batch:n}=await t.k.patch(`/api/import-batches/${encodeURIComponent(e)}`,{version:s,draft:r});return n}async function l(e,n,a,i){let{batch:l}=await r(()=>t.k.post(`/api/import-batches/${encodeURIComponent(e)}/start`,{version:n,images:a,analysis:i},{timeout:12e4}));return(0,s.P)(),l}async function o(e){let{batch:r}=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/retry`,{});return(0,s.P)(),r}async function u(e){let r=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/confirm-all`,{});return(0,s.P)(),r}async function d(e){await t.k.delete(`/api/import-batches/${encodeURIComponent(e)}`),(0,s.P)()}async function c(e){await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/read`,{}),(0,s.P)()}async function m(e,s,r){return t.k.post(`/api/import-batches/${encodeURIComponent(e)}/fix-text`,{items:s},{timeout:6e5,recoverable:!0,requestId:r})}e.s(["J",0,u,"n",0,function(e){return e?.status===409?e.data?.details?.batch??null:null},"v",0,n,"o",0,d,"w",0,a,"$",0,m,"f",0,c,"s",0,o,"S",0,i,"g",0,l])},25197,e=>{var t=e.i(41931);function s(e){return e.trim()?e:""}async function r(){try{return!!(await t.k.get("/api/user")).confirmBeforeImport}catch{return!1}}async function n(e,r){let n=await t.k.post("/api/error-items",{questionText:e.questionText,answerText:s(e.answerText),analysis:s(e.analysis),wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",knowledgePoints:e.knowledgePoints||[],difficultyStars:e.difficultyStars??null,recognizedGradeSemester:e.gradeSemester??null,hasFigure:e.hasFigure??!1,figureSvg:e.figureSvg??null,questionType:e.questionType??null,subjectId:r.subjectId||void 0,subjectName:r.subjectId?void 0:e.subject,originalImageUrl:r.imageUrl||"",paperLevel:r.paperLevel||void 0});return{id:n.id,shortId:n.shortId??null,subjectId:n.subjectId??null,notebookName:n.subject?.name??null,duplicate:n.duplicate}}e.i(201276),e.s(["x",0,r,"a",0,n],25197)},825624,e=>{let t=/^[\s  ]+/,s="一二三四五六七八九十",r=[{family:"dot",pattern:/^(\d{1,3})\s*(?:.|\.(?!\d))\s*/},{family:"comma",pattern:/^(\d{1,3})\s*[、,,](?!\d)\s*/},{family:"paren",pattern:/^(\d{1,3})\s*[))]\s*/},{family:"colon",pattern:/^(\d{1,3})\s*[::](?!\d)\s*/},{family:"ti",pattern:/^第\s*(\d{1,3}|[一二三四五六七八九十]{1,3})\s*题\s*[..、::]?\s*/},{family:"example",pattern:/^(?:例题?|练习|习题)\s*(\d{1,3})\s*[..、::]?\s*/},{family:"q",pattern:/^(?:Q|Question|Problem|Exercise)\s*(\d{1,3})\s*[..::)]?\s+/i},{family:"cn",pattern:/^([一二三四五六七八九十]{1,3})\s*[、..]\s*/}];function n(e){let n=e.replace(t,"");for(let{family:e,pattern:t}of r){let r=n.match(t);if(!r||n.length<=r[0].length)continue;let a=function(e){if(/^\d+$/.test(e))return Number(e);if("十"===e)return 10;let t=e.indexOf("十");return -1===t?s.indexOf(e)+1:10*(0===t?1:s.indexOf(e[0])+1)+(t===e.length-1?0:s.indexOf(e[t+1])+1)}(r[1]);if(Number.isFinite(a)&&!(a<=0))return{value:a,family:e,prefixLength:r[0].length,label:r[1]}}return null}function a(e){let s=e.split("\n"),r=s[0]?.replace(t,"")??"",a=n(r);return a&&"cn"!==a.family&&(s[0]=r.slice(a.prefixLength)),s.join("\n")}function i(e){let t=[];for(let s of e)(s||0!==t.length&&""!==t[t.length-1])&&t.push(s);for(;t.length>0&&""===t[t.length-1];)t.pop();return t.join("\n")}let l=/(姓名|班级|学号|日期|得分|分数|评分|考号|座位号|家长签字|用时|Name\s*[::_]|Class\s*[::_]|Date\s*[::_]|Score\s*[::_])|_{3,}|共\s*\d+\s*(道|题|小题)|做完|答案(见|在)|最后一页|满分\s*\d+\s*分/i,o=/(阅读|材料|短文|文章|选文|诗歌|古诗|文言文|下[面列]的?(表格|图表|统计|信息)|根据.{0,20}(回答|完成)|passage|read the|according to the)/i,u=/^(参考答案|答案与解析|答案|Answers?|Answer Key)\s*[::]?$/i,d=/^(第[一二三四五六七八九十]+(部分|大题|节)|(Part|Section)\s+[A-Z0-9IVX]+\b)/i,c=/(选择|填空|判断|计算|解答|应用|解决问题|操作|作图|阅读|写作|作文|综合|口算|听力|单项|完形|题)/,m=/(\d{1,3})\s*[~~\-—–至到]\s*(\d{1,3})\s*(?:小?题|questions?)/i,f=/(小问|小题|下列问题|以下问题|下列各题|下面各题|完成下列|回答下列|回答以下|following questions|answer the following)/i;function h(e){let t=[],s=[];for(let r of e)r?s.push(r):s.length&&(t.push(s.join("\n")),s=[]);return s.length&&t.push(s.join("\n")),t}function g(e,t=[]){let s=e.trim();return!(!s||s.length>12||/[。!?!?,,、;;::..()()【】\[\]{}]$/.test(s)||/\d/.test(s)||/[。!?!?;;,,]/.test(s))&&!!(/(篇|章|节|部分|组)$/.test(s)||/^(Part|Section)\s+[A-Z0-9]+$/i.test(s))&&(!t.length||t.some(e=>{let t=n(e);return null!==t&&1===t.value}))}function p(e,t){let s=[];for(let r=0;r<e.length;r++){let n=e[r],a=[n];for(let s=r+1;s<e.length;s++){let r=e[s],i=a[a.length-1];if(r.family!==n.family)continue;let l=1===r.value&&[...t].some(e=>e>i.line&&e<r.line);(r.value===i.value+1||l)&&a.push(r)}a.length>s.length&&(s=a)}return s}function x(e,t,s){return!!d.test(e)||!!t&&"cn"===t.family&&"cn"!==s&&null!==s&&(e.length<=40||c.test(e.slice(0,20)))}function w(e,t,s,r,n){for(let a=e-1;a>=0;a--)if(t[a]){if(n.has(a)||x(t[a],s[a],r)||g(t[a]))return t[a];break}return null}function y(e){let t=e.match(m);if(!t)return null;let s=Number(t[1]),r=Number(t[2]);return s<=r?{from:s,to:r}:null}let v={answer:/^(?:【\s*(?:参考答案|答案)\s*】|(?:参考答案|答案)\s*[::]|Answer\s*[::])\s*(.*)$/i,analysis:/^(?:【\s*(?:解析|分析|详解|解答|点评)\s*】|(?:解析|分析|详解|解答|点评)\s*[::])\s*(.*)$/,knowledge:/^(?:【\s*(?:知识点|考点)\s*】|(?:知识点|考点)\s*[::])\s*(.*)$/,difficulty:/^(?:【\s*难度\s*】|难度\s*[::])\s*(.*)$/,questionType:/^(?:【\s*题型\s*】|题型\s*[::])\s*(.*)$/,wrongAnswer:/^(?:【\s*错答\s*】|我的答案\s*[::]|学生答案\s*[::])\s*(.*)$/},j={易:1,较易:2,中等:3,较难:4,难:5};function b(e){return e.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean)}function k(e){let t={answer:[],analysis:[],knowledge:[],difficulty:[],questionType:[],wrongAnswer:[]},s=[],r=null;for(let n of e){let e=null;for(let s of Object.keys(v)){let a=n.match(v[s]);if(!a)continue;e=s,r=s;let i=a[1].trim();i&&t[s].push(i);break}e||(r&&n.trim()?t[r].push(n.trim()):s.push(n))}let n={},a=t.answer.join("\n").trim();a&&(n.answer=a);let l=t.analysis.join("\n").trim();l&&(n.analysis=l);let o=t.knowledge.flatMap(b);o.length&&(n.knowledgePoints=o);let u=t.difficulty.join(" ").trim(),d=u?function(e){let t=e.trim();if(!t)return null;let s=t.match(/^(\d{1,2})\s*(?:星|级)?$/);if(s){let e=Number(s[1]);return e>=1&&e<=5?e:null}if(/^[★☆]{1,5}$/.test(t)){let e=(t.match(/★/g)??[]).length;return e>=1?e:null}return t in j?j[t]:null}(u):null;null!==d&&(n.difficultyStars=d);let c=t.questionType.join(" ").trim();c&&(n.questionType=c);let m=t.wrongAnswer.join("\n").trim();return m&&(n.wrongAnswer=m),{text:i(s),fields:n}}let N=/^(\d{1,3})\s*[..、,,)]\s*(\S[\s\S]*)$/,S=/^(\d{1,3})\s*[~~—–-]\s*(\d{1,3})\s*[::..、]?\s*([A-Za-z]+)$/;function T(e){let t=e.trim();if(!t)return null;let s=function(e){let t=e.trim().match(S);if(!t)return null;let s=Number(t[1]),r=Number(t[2]),n=t[3];if(!Number.isFinite(s)||!Number.isFinite(r)||s<=0||r<=s||r-s+1>60)return null;let a=r-s+1;return n.length!==a?null:Array.from({length:a},(e,t)=>({label:String(s+t),text:n[t]}))}(t);if(s)return s;let r=function(e){let t=e.trim(),s=[];for(let e of t.matchAll(/(\d{1,3})\s*[..、,,;;]\s*/g)){let r=e.index??0,n=t[r+e[0].length];n&&/\d/.test(n)||s.push({index:r,label:e[1],afterIndex:r+e[0].length})}if(s.length<2)return null;for(let e=1;e<s.length;e++)if(Number(s[e].label)<=Number(s[e-1].label))return null;let r=[];for(let e=0;e<s.length;e++){let n=s[e].afterIndex,a=e+1<s.length?s[e+1].index:t.length,i=t.slice(n,a).trim().replace(/[;;]+$/,"").trim();if(!i||i.length>30||/[。!?!?]/.test(i))return null;r.push({label:s[e].label,text:i})}return r}(t);if(r)return r.map(e=>({label:e.label??"",text:e.text})).filter(e=>e.label);let n=t.match(N);if(!n)return null;let a=Number(n[1]);return!Number.isFinite(a)||a<=0?null:[{label:n[1],text:n[2].trim()}]}function A(e){let t=e.match(/^(.*?)(?:【?\s*(?:解析|分析|详解|解答|点评)\s*】?\s*[::])([\s\S]*)$/);if(t){let s=t[1].replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim(),r=t[2].trim();return r?{answer:s,analysis:r}:{answer:e.trim()}}return{answer:e.replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim()||e.trim()}}function I(e,t){let s=[],r=!1;for(let n of e){let e={value:!1},a=[];for(let s of n.split("\n")){let r=s.trim()?T(s):null;if(!r){s.trim()&&a.push(s);continue}let n=!1;for(let i of r){let r=t.find(e=>e.label===i.label);if(!r){a.push(s);break}n=!0,e.value=!0;let l=A(i.text);l.answer&&!r.answer&&(r.answer=l.answer),l.analysis&&(r.analysis=r.analysis?`${r.analysis}
10
- ${l.analysis}`:l.analysis)}!n&&!a.includes(s)&&s.trim()&&!a.includes(s)&&a.push(s)}r=r||e.value,e.value?a.length&&s.push(a.join("\n")):s.push(n)}return[s,r]}e.s(["k",0,2e3,"f",0,1e6,"S",0,60,"i",0,2e4,"J",0,function(e,s={}){let r,c,v=void 0===s.maxLength?2e4:Math.min(Math.max(s.maxLength,1e3),1e6),j=void 0===s.maxQuestions?60:Math.min(Math.max(s.maxQuestions,2),2e3),b=e.length>v,N=e.slice(0,v).replace(/\r\n?/g,"\n").split("\n").map(e=>e.replace(t,"").replace(/[\s ]+$/,"")),S=N.map(e=>e?n(e):null),E=N.length;for(let e=0;e<N.length;e++)if(u.test(N[e])){E=e;break}let $=[],_=[];for(let e=0;e<E;e++){let t=S[e];t&&("cn"===t.family?_:$).push({...t,line:e})}let C=new Set;for(let e=0;e<E;e++)(d.test(N[e])||S[e]?.family==="cn"||g(N[e],N.slice(e+1,e+5)))&&C.add(e);let R=[],M=p($,C);if(M.length<2){let e=p(_,new Set);e.length>=2&&(R=[{chain:e,sectionHeading:null}])}else R=function(e,t,s,r){if(e.length<2)return[];let n=e[0].family,a=[0];for(let t=1;t<e.length;t++)1===e[t].value&&a.push(t);if(a.length<2){let a=w(e[0].line,t,s,n,r);return null!==a?[{chain:e,sectionHeading:a}]:[]}let i=[];for(let l=0;l<a.length;l++){let o=a[l],u=l+1<a.length?a[l+1]:e.length,d=e.slice(o,u),c=0===l?w(e[0].line,t,s,n,r):function(e,t,s,r,n,a){for(let i=e+1;i<t;i++)if(s[i]&&(a.has(i)||x(s[i],r[i],n)||g(s[i])))return s[i];return null}(e[o-1].line,e[o].line,t,s,n,r);if(null===c&&l>0){i[i.length-1].chain.push(...d);continue}i.push({chain:d,sectionHeading:c})}return i.filter(e=>e.chain.length>0)}(M,N,S,C);let O=R.length?R.flatMap(e=>e.chain):M,q=i(N.slice(0,E)),P=E<N.length?h(N.slice(E)):[],U=(c=n(N[O[0]?.line??0]??""))?c.label:null,V=e=>({questions:q?[{label:U,text:q,material:null,section:null,lineRange:{from:0,to:E}}]:[],ignored:P,detected:!1,ambiguous:e,candidateCount:e?O.length:+!!q,overflow:0,tooLong:b});if(O.length<2){if(!q)return V(!1);let e=k(q.split("\n")),t=V(!1);if(t.questions.length>0&&Object.keys(e.fields).length>0&&(t.questions[0]={...t.questions[0],text:a(e.text),...e.fields}),t.questions.length>0&&P.length){let[e,s]=I(P,t.questions);t.ignored=e,s||(t.ignored=P)}return t}let L=O[0].family;if(!s.forceNumbered&&function(e,t,s,r){let n=null;for(let a=t-1;a>=0;a--)if(e[a]){n=x(e[a],r[a],s)?null:e[a];break}return!(!n||l.test(n)||m.test(n))&&("paren"===s?n.length>=15||/[。?!?!::,,;;]$/.test(n):/[::]$/.test(n)&&f.test(n))}(N,O[0].line,L,S)){let e=V(!0);if(e.questions.length>0&&q){let t=k(q.split("\n"));Object.keys(t.fields).length>0&&(e.questions[0]={...e.questions[0],text:a(t.text),...t.fields})}return e}let F=new Set(O.map(e=>e.line)),H=[],G=[],z=null,D=[],Q=[],W=(e,t)=>{for(let s of h(e))(!l.test(s)||!(s.length<80))&&(o.test(s)||s.length>=80&&/[。!?.!?;;]/.test(s))?D.push({text:s,range:y(s)}):t?H.push(s):z&&!G.some(e=>e.section===z)?z=`${z}
11
- ${s}`:H.push(s)},B=O[0].line,J=[];for(let e=0;e<B;e++)N[e]&&(x(N[e],S[e],L)||g(N[e],N.slice(e+1,e+5)))?(W(J.splice(0),!0),z=N[e],Q=[]):J.push(N[e]);W(J,!0);let Z=R.length>1,X=e=>{if(!Z)return -1;let t=0;for(let s=0;s<R.length;s++)if(e<(t+=R[s].chain.length))return s;return R.length-1};for(let e=0;e<O.length;e++){let t=O[e].line,s=e+1<O.length?O[e+1].line:E,r=X(e);if(Z&&r>=0){let e=R[r].sectionHeading;null!==e&&(z=e,Q=[])}D.length&&(Q=[...Q.filter(e=>e.range),...D],D=[]);let n=s,l=null;for(let e=t+1;e<s;e++)if(N[e]&&!F.has(e)&&x(N[e],S[e],L)){n=e,l=N[e];break}let u=N.slice(t,n),d=h(u),c=[];for(;d.length>1&&o.test(d[d.length-1].slice(0,30));)c.unshift(d.pop());let m=c.length?d.join("\n"):i(u),f=O[e].value,g=Q.filter(e=>!e.range||f>=e.range.from&&f<=e.range.to),p=k(a(m).split("\n"));for(let r of(G.push({label:O[e].label,text:p.text,material:g.length?g.map(e=>e.text).join("\n\n"):null,section:z,lineRange:{from:t,to:s},...p.fields}),c))D.push({text:r,range:y(r)});null!==l&&(z=l,Q=[],W(N.slice(n+1,s),!1))}if(Z&&P.length){let e=R.map(e=>e.sectionHeading).filter(e=>null!==e),t=P.join("\n");r=e.some(e=>t.includes(e))?function(e,t,s){let r=[],n=0,a=t.map(e=>{let t=s.slice(n,n+e.chain.length);return n+=e.chain.length,t}),i=-1;for(let n of e){let e=n.split("\n"),l=[],o=!1;for(let r of e){let e=r.trim();if(!e){l.push(r);continue}let n=t.findIndex(t=>t.sectionHeading&&e.includes(t.sectionHeading));if(n>=0){i=n;continue}let u=T(e);if(!u){l.push(r);continue}let d=i>=0?a[i]:s,c=!1;for(let e of u){let t=d.find(t=>t.label===e.label);if(!t){l.push(r);break}c=!0,o=!0;let s=A(e.text);s.answer&&!t.answer&&(t.answer=s.answer),s.analysis&&(t.analysis=t.analysis?`${t.analysis}
12
- ${s.analysis}`:s.analysis)}c||l.includes(r)||l.push(r)}o?l.length&&r.push(l.join("\n")):r.push(n)}return r}(P,R,G):P}else r=I(P,G)[0];let Y=G.slice(j);return{questions:G.slice(0,j),ignored:[...H,...r,...Y.map(e=>{var t;let s,r,n,a;return s=(t=e).text.trim(),n=(r=t.material?.trim())?`${r}
13
-
14
- ${s}`:s,a=[],(t.answer?.trim()&&a.push(`参考答案:${t.answer.trim()}`),t.analysis?.trim()&&a.push(`参考解析:${t.analysis.trim()}`),t.wrongAnswer?.trim()&&a.push(`学生作答:${t.wrongAnswer.trim()}`),a.length)?`${n}
15
-
16
- ${a.join("\n\n")}`:n})],detected:!0,ambiguous:!1,candidateCount:G.length,overflow:Y.length,tooLong:b}}])},767077,e=>{var t=e.i(303163);e.s(["f",0,function(e,s){let r=s.common?.messages?.analysisFailed||"Analysis failed, please try again",n=(0,t.d)(e);if(n){let e=s.errors??{};if(!(n in e))return n;let t=e[n];return"string"==typeof t?t:r}let a=(0,t.Z)(e);if(a.includes("fetch")||a.includes("network"))return s.errors?.AI_CONNECTION_FAILED||"网络连接失败";if("object"==typeof e&&null!==e&&"data"in e&&"string"==typeof e.data){let t="status"in e&&"number"==typeof e.status?e.status:"Error";return`${r} (${t})`}return r}])}])})();
@@ -1 +0,0 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,711241,e=>{var t=e.i(456420);let a={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};a.node;let s=(0,t.f)(a);e.s(["f",0,s],711241)},952801,e=>{var t=e.i(843476),a=e.i(271645),s=e.i(522016),l=e.i(215519),i=e.i(306831),r=e.i(226091),n=e.i(77071),c=e.i(519455),o=e.i(515288),d=e.i(912505),m=e.i(393842),u=e.i(86963),x=e.i(618566),h=e.i(632781),p=e.i(994533),g=e.i(257428),f=e.i(793479),b=e.i(110204),j=e.i(699375),v=e.i(574041),y=e.i(111110);let N=["generate","original"];function k({value:e,onChange:a}){let{t:s}=(0,y.b)();return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:s.exam.modeLabel}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1 rounded-md bg-muted p-1 sm:max-w-sm",role:"group","aria-label":s.exam.modeLabel,children:N.map(l=>(0,t.jsx)("button",{type:"button","aria-pressed":e===l,onClick:()=>a(l),className:`rounded px-2 py-1.5 text-sm transition-colors ${e===l?"bg-background shadow-sm font-medium":"text-muted-foreground"}`,children:s.exam.modes[l]},l))}),"original"===e&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s.exam.originalHint})]})}var _=e.i(41931),w=e.i(470279),C=e.i(401280);let S=["unmastered","mastered","all"],E=["least_practiced","random"],L=["easy","medium","hard","harder"];function T(){let{t:e,language:s}=(0,y.b)(),l=(0,x.useRouter)(),[i,r]=(0,a.useState)([]),[n,d]=(0,a.useState)([]),[m,u]=(0,a.useState)([]),[N,T]=(0,a.useState)([]),[O,R]=(0,a.useState)([]),[$,A]=(0,a.useState)("unmastered"),[z,M]=(0,a.useState)("least_practiced"),[F,H]=(0,a.useState)(10),[q,D]=(0,a.useState)("medium"),[P,U]=(0,a.useState)("generate"),[B,I]=(0,a.useState)(""),[K,V]=(0,a.useState)(!1),[Q,X]=(0,a.useState)(!1),[G,W]=(0,a.useState)(null),[Y,J]=(0,a.useState)(null),{groups:Z,loading:ee}=(0,w.f)();(0,a.useEffect)(()=>{_.k.get("/api/notebooks").then(e=>{r(e),1===e.length&&d([e[0].id])}).catch(()=>r([]))},[]);let et=e=>{R(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ea=async t=>{if(t.preventDefault(),0===n.length)return void W(e.exam.noNotebook);X(!0),W(null),J(null);try{let t=await _.k.post("/api/exams",{subjectIds:n,tagNames:m,paperLevelIds:N.length>0?N:void 0,questionTypes:O.length>0?O.map(e=>e===C.O?"none":e):void 0,scope:$,pickRule:z,count:F,difficulty:"original"===P?void 0:q,mode:P,title:B.trim()||void 0,language:s,parallel:K||void 0});t.papers&&t.papers.length>1?J(e.exam.parallelCreated):"PARALLEL_NOT_ENOUGH"===t.warning?J(e.exam.parallelNotEnough):"PARALLEL_B_QUOTA_EXCEEDED"===t.error&&J(e.exam.parallelQuotaExceeded),l.push(`/exams/${t.id}`)}catch(t){W("NO_SOURCE_ITEMS"===t?.data?.message?e.exam.noSource:e.common.messages?.saveFailed||"Failed"),X(!1)}},es=e.practice.difficulty;return(0,t.jsxs)(o.N,{children:[(0,t.jsx)(o.Y,{children:(0,t.jsx)(o.v,{className:"text-lg",children:e.exam.createTitle})}),(0,t.jsx)(o.O,{children:(0,t.jsxs)("form",{onSubmit:ea,className:"space-y-5",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(b.f,{children:e.exam.notebooks}),i.length>1&&(0,t.jsx)("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>d(n.length===i.length?[]:i.map(e=>e.id)),children:e.exam.selectAll})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:i.map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 rounded-md border p-2 text-sm cursor-pointer hover:bg-muted/50",children:[(0,t.jsx)(g.f,{checked:n.includes(e.id),onCheckedChange:()=>{var t;return t=e.id,void d(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}}),(0,t.jsx)("span",{className:"truncate",children:e.name}),(0,t.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:e._count?.errorItems??""})]},e.id))})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:e.exam.tags}),(0,t.jsx)(v.f,{value:m,onChange:u,placeholder:e.exam.tagsPlaceholder})]}),!ee&&Z.filter(e=>e.isActive).length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:e.filter.paperLevel}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:Z.filter(e=>e.isActive).map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void T(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:`rounded-full border px-3 py-1.5 text-sm transition-colors ${N.includes(e.id)?"border-primary bg-primary text-primary-foreground":"border-input bg-background hover:bg-muted"}`,children:e.name},e.id))})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:e.questionType.label}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[C.V.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>et(a),className:`rounded-full border px-3 py-1.5 text-sm transition-colors ${O.includes(a)?"border-primary bg-primary text-primary-foreground":"border-input bg-background hover:bg-muted"}`,children:e.questionType.names[a]||a},a)),(0,t.jsx)("button",{type:"button",onClick:()=>et(C.O),className:`rounded-full border px-3 py-1.5 text-sm transition-colors ${O.includes(C.O)?"border-primary bg-primary text-primary-foreground":"border-input bg-background hover:bg-muted"}`,children:e.questionType.notSet})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.exam.questionTypesHint})]}),(0,t.jsx)(k,{value:P,onChange:U}),(0,t.jsxs)("div",{className:`grid gap-4 ${"generate"===P?"sm:grid-cols-3":"sm:grid-cols-2"}`,children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:e.exam.scope}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-md bg-muted p-1",children:S.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>A(a),className:`rounded px-2 py-1.5 text-sm transition-colors ${$===a?"bg-background shadow-sm font-medium":"text-muted-foreground"}`,children:e.exam.scopes[a]},a))})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{htmlFor:"exam-count",children:e.exam.count}),(0,t.jsx)(f.f,{id:"exam-count",type:"number",min:1,max:50,value:F,onChange:e=>H(Math.min(50,Math.max(1,parseInt(e.target.value,10)||1)))})]}),"generate"===P&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{htmlFor:"exam-difficulty",children:e.exam.difficulty}),(0,t.jsx)("select",{id:"exam-difficulty",value:q,onChange:e=>D(e.target.value),className:"h-9 w-full rounded-md border bg-background px-3 text-sm",children:L.map(e=>(0,t.jsx)("option",{value:e,children:es[e]},e))})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{children:e.exam.pickRule}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1 rounded-md bg-muted p-1 sm:max-w-sm",children:E.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>M(a),className:`rounded px-2 py-1.5 text-sm transition-colors ${z===a?"bg-background shadow-sm font-medium":"text-muted-foreground"}`,children:e.exam.pickRules[a]},a))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.exam.pickRuleHints[z]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)(b.f,{htmlFor:"exam-parallel",children:e.exam.parallelLabel}),(0,t.jsx)(j.f,{id:"exam-parallel",checked:K,onCheckedChange:V})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.exam.parallelHint})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(b.f,{htmlFor:"exam-title",children:e.exam.titleLabel}),(0,t.jsx)(f.f,{id:"exam-title",value:B,maxLength:100,onChange:e=>I(e.target.value)})]}),G&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:G}),Y&&(0,t.jsx)("p",{className:"text-sm text-primary",children:Y}),(0,t.jsxs)(c.f,{type:"submit",disabled:Q,className:"w-full sm:w-auto",children:[Q?(0,t.jsx)(h.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(p.f,{className:"mr-2 h-4 w-4"}),Q?e.exam.creating:"original"===P?e.exam.createOriginal:e.exam.generate]})]})})]})}var O=e.i(663661),R=e.i(487486),$=e.i(35209);e.s(["default",0,function(){let{timeZone:e}=(0,l.M)(),{t:x}=(0,y.b)();(0,$.f)(x.exam.title);let[h,p]=(0,a.useState)(null),[g,f]=(0,a.useState)(!1);(0,a.useEffect)(()=>{_.k.get("/api/exams").then(e=>{p(e),0===e.length&&f(!0)}).catch(()=>p([]))},[]);let b=x.practice.difficulty;return(0,t.jsx)("main",{className:"mx-auto min-h-screen max-w-6xl px-4 py-6 md:px-8 md:py-8",children:(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(m.f,{title:x.exam.title,description:x.exam.subtitle,actions:!g&&(0,t.jsxs)(c.f,{onClick:()=>f(!0),"aria-label":x.exam.create,children:[(0,t.jsx)(n.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:x.exam.create})]})}),g&&(0,t.jsx)(T,{}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:x.exam.list}),null===h?(0,t.jsx)(u.f,{}):0===h.length?(0,t.jsx)(d.f,{icon:r.f,title:x.exam.empty,className:"py-10"}):(0,t.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:h.map(a=>(0,t.jsx)(s.default,{href:`/exams/${a.id}`,children:(0,t.jsx)(o.N,{className:"h-full rounded-2xl transition-all hover:-translate-y-0.5 hover:border-primary/40 hover:shadow-md",children:(0,t.jsxs)(o.O,{className:"space-y-2 pt-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 font-medium",children:[(0,t.jsx)(r.f,{className:"h-4 w-4 shrink-0 text-primary"}),a.title]}),(0,t.jsx)(O.f,{status:a.status,recorded:a.recordedCount>0})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:(0,i.r)(a.createdAt,"yyyy-MM-dd HH:mm",e)}),(0,t.jsx)("span",{children:x.exam.questionCount.replace("{count}",String(a.questionCount))}),(0,t.jsx)("span",{children:x.exam.scopes[a.scope]}),"original"===a.mode?(0,t.jsx)(R.f,{variant:"secondary",children:x.exam.modes.original}):(0,t.jsx)("span",{children:b[a.difficulty]||a.difficulty}),(0,t.jsx)("span",{children:a.recordedCount>0?x.exam.recorded:x.exam.notRecorded})]})]})})},a.id))})]})]})})}],952801)},663661,e=>{var t=e.i(843476),a=e.i(487486),s=e.i(111110);let l={generating:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-900",ready:"bg-indigo-100 dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-300 border-indigo-200 dark:border-indigo-900",partial:"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300 border-amber-200 dark:border-amber-900",failed:"bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300 border-red-200 dark:border-red-900",completed:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 border-green-200 dark:border-green-900"};e.s(["f",0,function({status:e,recorded:i}){let{t:r}=(0,s.b)(),n=i&&("ready"===e||"partial"===e)?"completed":e;return(0,t.jsx)(a.f,{variant:"outline",className:l[n],children:r.exam.status[n]})}])},574041,e=>{var t=e.i(843476),a=e.i(271645),s=e.i(263676),l=e.i(487486),i=e.i(793479),r=e.i(41931),n=e.i(201276);e.s(["f",0,function({value:e=[],onChange:c,placeholder:o="Enter tags...",className:d="",enterHint:m,subject:u,gradeStage:x}){let[h,p]=(0,a.useState)(""),[g,f]=(0,a.useState)([]),[b,j]=(0,a.useState)(!1),[v,y]=(0,a.useState)(0),N=(0,a.useRef)(null),k=(0,a.useRef)(null),_=(0,a.useCallback)(async t=>{try{let a=new URLSearchParams({q:t});u&&a.append("subject",u),x&&a.append("stage",x);let s=((await r.k.get(`/api/tags/suggestions?${a.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));f(s.slice(0,20)),j(s.length>0),y(0)}catch(e){n.V.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[u,x,e]);(0,a.useEffect)(()=>{h.trim()&&_(h)},[h,_]);let w=t=>{t.trim()&&!e.includes(t.trim())&&(c([...e,t.trim()]),p(""),f([]),j(!1),y(0))},C=t=>{c(e.filter(e=>e!==t))};return(0,a.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||N.current?.contains(e.target)||j(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${d}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(l.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>C(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(s.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(i.f,{ref:N,type:"text",value:h,onChange:e=>{p(e.target.value),e.target.value.trim()||(f([]),j(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),v>=0&&g[v]?w(g[v]):h.trim()&&w(h)):"ArrowDown"===t.key?(t.preventDefault(),y(e=>Math.min(e+1,g.length-1))):"ArrowUp"===t.key?(t.preventDefault(),y(e=>Math.max(e-1,0))):"Escape"===t.key?(j(!1),y(0)):"Backspace"===t.key&&!h&&e.length>0&&C(e[e.length-1])},onFocus:()=>{g.length>0&&j(!0)},placeholder:0===e.length?o:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),b&&g.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:g.map((e,a)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${a===v?"bg-accent":""}`,onClick:()=>w(e),onMouseEnter:()=>y(a),children:e},e))}),h&&!b&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:m?`${m} "${h}"`:`Press Enter to create "${h}"`})]})}])},590546,e=>{var t=e.i(843476),a=e.i(618566),s=e.i(519455),l=e.i(711241);e.s(["f",0,function({fallbackUrl:e,className:i}){let r=(0,a.useRouter)();return(0,t.jsx)(s.f,{variant:"ghost",size:"icon",onClick:()=>{r.push(e)},className:i,children:(0,t.jsx)(l.f,{className:"h-5 w-5"})})}])},912505,e=>{var t=e.i(843476),a=e.i(975157);e.s(["f",0,function({icon:e,title:s,description:l,action:i,className:r}){return(0,t.jsxs)("div",{className:(0,a.f)("flex flex-col items-center justify-center rounded-2xl border border-dashed bg-card/50 px-6 py-14 text-center",r),children:[(0,t.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-accent text-accent-foreground",children:(0,t.jsx)(e,{className:"h-7 w-7"})}),(0,t.jsx)("p",{className:"font-medium",children:s}),l&&(0,t.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:l}),i&&(0,t.jsx)("div",{className:"mt-5",children:i})]})}])},393842,e=>{var t=e.i(843476),a=e.i(590546),s=e.i(975157);e.s(["f",0,function({title:e,description:l,backHref:i,actions:r,titleAddon:n,className:c}){return(0,t.jsxs)("div",{className:(0,s.f)("flex items-start gap-3",c),children:[i&&(0,t.jsx)(a.f,{fallbackUrl:i,className:"-ml-2 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("h1",{className:"truncate text-2xl font-bold tracking-tight sm:text-3xl",children:e}),n]}),l&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground sm:text-base",children:l})]}),r&&(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r})]})}])},86963,e=>{var t=e.i(843476),a=e.i(632781);e.s(["f",0,function({label:e}){return(0,t.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,t.jsx)(a.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,t.jsx)("p",{className:"text-sm",children:e})]})}])},35209,e=>{var t=e.i(271645),a=e.i(111110);e.s(["f",0,function(...e){let{t:s}=(0,a.b)(),l=[s.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=l},[l])}])},401280,e=>{let t={single_choice:"single_choice",singlechoice:"single_choice","single choice":"single_choice","single-choice":"single_choice",multiple_choice:"multiple_choice",multiplechoice:"multiple_choice","multiple choice":"multiple_choice","multiple-choice":"multiple_choice",multichoice:"multiple_choice","multi choice":"multiple_choice",true_false:"true_false",truefalse:"true_false","true/false":"true_false","true false":"true_false","true-false":"true_false","true / false":"true_false",fill_blank:"fill_blank",fillblank:"fill_blank","fill in the blank":"fill_blank","fill-in-the-blank":"fill_blank",fillintheblank:"fill_blank",calculation:"calculation",solution:"solution",reading:"reading",cloze:"cloze",writing:"writing",other:"other",选择题:"single_choice",单项选择:"single_choice",单选:"single_choice",单选题:"single_choice",不定项:"multiple_choice",不定项选择:"multiple_choice",多项选择:"multiple_choice",多选:"multiple_choice",多选题:"multiple_choice",判断:"true_false",判断题:"true_false",是非:"true_false",是非题:"true_false",填空:"fill_blank",填空题:"fill_blank",口算:"calculation",计算:"calculation",计算题:"calculation",解答:"solution",解答题:"solution",应用:"solution",应用题:"solution",证明:"solution",证明题:"solution",简答:"solution",简答题:"solution",阅读:"reading",阅读理解:"reading",完形:"cloze",完形填空:"cloze",作文:"writing",写作:"writing",书面表达:"writing",其他:"other"};e.s(["O",0,"__none__","V",0,["single_choice","multiple_choice","true_false","fill_blank","calculation","solution","reading","cloze","writing","other"],"u",0,{single_choice:"Single Choice",multiple_choice:"Multiple Choice",true_false:"True / False",fill_blank:"Fill in the Blank",calculation:"Calculation",solution:"Solution",reading:"Reading Comprehension",cloze:"Cloze",writing:"Writing",other:"Other"},"H",0,{single_choice:"单选题",multiple_choice:"多选题",true_false:"判断题",fill_blank:"填空题",calculation:"计算题",solution:"解答题",reading:"阅读理解",cloze:"完形填空",writing:"写作",other:"其他"},"P",0,function(e){if("string"!=typeof e)return null;let a=e.trim().toLowerCase();return a?t[a]??null:null}])}])})();
@@ -1 +0,0 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,314381,3198,e=>{var t=e.i(456420);let i={name:"box",size:24,node:[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]};i.node;let n=(0,t.f)(i);e.s(["f",0,n],314381);var r=e.i(843476),a=e.i(271645),o=e.i(632781);let l={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};l.node;let s=(0,t.f)(l),c={name:"minimize-2",size:24,node:[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]};c.node;let h=(0,t.f)(c);var d=e.i(395925),u=e.i(741120),m=e.i(759659),g=e.i(519455),p=e.i(111110),f=e.i(294114),w=e.i(201276),x=e.i(113381);let y=null;function b(e,t,i){let n=e?.firstElementChild;n&&(n.style.width="100%",n.style.height=`${i}px`,t?.setSize(e?.offsetWidth||n.offsetWidth||800,i))}function v(e,t){let i=(0,x.L)(e,t);for(let e of i)w.V.warn("[GGB]","命令执行失败",{...e});return i.map(e=>e.command+":"+e.message).join("\n")||void 0}e.s(["f",0,function({commands:e,height:t=700,showToolBar:i=!1,showAlgebraInput:n=!1,showMenuBar:l=!1,className:c="",onRegenerate:C,onDelete:k}){let{t:j}=(0,p.b)(),D=(0,a.useRef)(null),M=(0,a.useRef)(null),E=(0,a.useRef)(void 0),_=(0,a.useId)(),N=(0,a.useRef)(`ggb-${_.replace(/[^a-zA-Z0-9_-]/g,"")}`),[R,S]=(0,a.useState)(!0),[L,I]=(0,a.useState)(null),[P,z]=(0,a.useState)(!0),[$,H]=(0,a.useState)(!1),[A,B]=(0,a.useState)(!1),Y=(0,a.useMemo)(()=>(0,x.i)(e),[e]);(0,a.useEffect)(()=>{if(0===Y.length)return;let e=!1,r=N.current,a=D.current;return(y||(y=new Promise((e,t)=>{if(window.GGBApplet)return void e();let i=document.createElement("script");i.src="https://www.geogebra.org/apps/deployggb.js",i.async=!0,i.onload=()=>e(),i.onerror=()=>{y=null,t(Error("Failed to load GeoGebra"))},document.head.appendChild(i)}))).then(()=>{if(e)return;let o=window.GGBApplet;if(!o){I(j.geogebra.notLoaded),S(!1);return}if(a){a.innerHTML=`<div id="${r}" style="width:100%;height:${t}px"></div>`;try{new o({appName:"classic",width:"100%",height:t,showToolBar:i,showAlgebraInput:n,showMenuBar:l,showResetIcon:!0,enableRightClick:!0,enableShiftDragZoom:!0,language:"zh",appletOnLoad:i=>{e||(M.current=i,b(a,i,t),E.current=v(i,Y),S(!1))}},!0).inject(r)}catch(t){w.V.error("[GGB]","Init failed",{error:t}),e||(I(j.geogebra.initFailed),S(!1))}}}).catch(t=>{w.V.error("[GGB]","Script load failed",{error:t}),e||(I(j.geogebra.scriptFailed),S(!1))}),()=>{e=!0;try{let e=M.current;e?.remove&&e.remove()}catch(e){w.V.warn("[GGB]","Cleanup failed",{error:e})}M.current=null,a&&(a.innerHTML="")}},[Y,i,n,l]),(0,a.useEffect)(()=>{b(D.current,M.current,P?700:t)},[P,t]);let O=(0,a.useCallback)(()=>{let e=M.current;if(e)try{e.resetConstruction(),setTimeout(()=>{M.current&&(E.current=v(M.current,Y))},300)}catch(e){w.V.warn("[GGB]","Reset failed",{error:e})}},[Y]),X=(0,a.useCallback)(async()=>{if(C&&!$){H(!0);try{await C(E.current)}finally{H(!1)}}},[C,$]),U=(0,a.useCallback)(async()=>{if(k&&!A&&await (0,f.u)(j.geogebra.confirmDelete,{destructive:!0})){B(!0);try{await k()}catch{f.c.error(j.geogebra.deleteFailed)}finally{B(!1)}}},[k,A,j]);return 0===Y.length?null:(0,r.jsxs)("div",{className:`relative rounded-lg border bg-card ${c}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b bg-muted/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:j.geogebra.title}),R&&(0,r.jsx)(o.f,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[C&&(0,r.jsxs)(g.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:X,title:j.geogebra.regenerate,disabled:$||R,children:[$?(0,r.jsx)(o.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(u.f,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:j.geogebra.regenerate})]}),k&&(0,r.jsxs)(g.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:U,title:j.geogebra.delete,disabled:A||$,children:[A?(0,r.jsx)(o.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(m.f,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:j.geogebra.delete})]}),(0,r.jsx)(g.f,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:O,title:j.geogebra.reset,disabled:R,children:(0,r.jsx)(d.f,{className:"h-3.5 w-3.5"})}),(0,r.jsx)(g.f,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>z(e=>!e),title:P?j.geogebra.shrink:j.geogebra.enlarge,children:P?(0,r.jsx)(h,{className:"h-3.5 w-3.5"}):(0,r.jsx)(s,{className:"h-3.5 w-3.5"})})]})]}),(0,r.jsx)("div",{ref:D,style:{width:"100%"}}),R&&(0,r.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80 rounded-b-lg",style:{top:37},children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,r.jsx)(o.f,{className:"h-6 w-6 animate-spin text-primary"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:j.geogebra.loading})]})}),L&&(0,r.jsx)("div",{className:"flex items-center justify-center text-sm text-destructive",style:{minHeight:t},children:L})]})}],3198)},856522,e=>{var t=e.i(456420);let i={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]};i.node;let n=(0,t.f)(i);e.s(["f",0,n],856522)},328623,e=>{var t=e.i(456420);let i={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};i.node;let n=(0,t.f)(i);e.s(["f",0,n],328623)},786563,e=>{var t=e.i(456420);let i={name:"star",size:24,node:[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]};i.node;let n=(0,t.f)(i);e.s(["f",0,n],786563)},232660,e=>{var t=e.i(271645),i={x:0,y:0,width:0,height:0,unit:"px"},n=(e,t,i)=>Math.min(Math.max(e,t),i),r=(e,t)=>e===t||e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit;function a(e,t,n){return"%"===e.unit?{...i,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/n*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/n*100:0}}function o(e,t,n){return e.unit&&"px"!==e.unit?{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*n/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*n/100:0}:{...i,...e,unit:"px"}}function l(e,t,i,n,r,a=0,o=0,s=n,c=r){let h={...e},d=Math.min(a,n),u=Math.min(o,r),m=Math.min(s,n),g=Math.min(c,r);t&&(t>1?(u=(d=o?o*t:d)/t,m=s*t):(d=(u=a?a/t:u)*t,g=c/t)),h.y<0&&(h.height=Math.max(h.height+h.y,u),h.y=0),h.x<0&&(h.width=Math.max(h.width+h.x,d),h.x=0);let p=n-(h.x+h.width);p<0&&(h.x=Math.min(h.x,n-d),h.width+=p);let f=r-(h.y+h.height);if(f<0&&(h.y=Math.min(h.y,r-u),h.height+=f),h.width<d&&(("sw"===i||"nw"==i)&&(h.x-=d-h.width),h.width=d),h.height<u&&(("nw"===i||"ne"==i)&&(h.y-=u-h.height),h.height=u),h.width>m&&(("sw"===i||"nw"==i)&&(h.x-=m-h.width),h.width=m),h.height>g&&(("nw"===i||"ne"==i)&&(h.y-=g-h.height),h.height=g),t){let e=h.width/h.height;if(e<t){let e=Math.max(h.width/t,u);("nw"===i||"ne"==i)&&(h.y-=e-h.height),h.height=e}else if(e>t){let e=Math.max(h.height*t,d);("sw"===i||"nw"==i)&&(h.x-=e-h.width),h.width=e}}return h}var s={capture:!0,passive:!1},c=0,h=class e extends t.PureComponent{static xOrds=["e","w"];static yOrds=["n","s"];static xyOrds=["nw","ne","se","sw"];static nudgeStep=1;static nudgeStepMedium=10;static nudgeStepLarge=100;static defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};get document(){return document}docMoveBound=!1;mouseDownOnCrop=!1;dragStarted=!1;evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0};componentRef=(0,t.createRef)();mediaRef=(0,t.createRef)();resizeObserver;initChangeCalled=!1;instanceId=`rc-${c++}`;state={cropIsActive:!1,newCropIsBeingDrawn:!1};getBox(){let e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};let{x:t,y:i,width:n,height:r}=e.getBoundingClientRect();return{x:t,y:i,width:n,height:r}}componentDidUpdate(e){let{crop:t,onComplete:i}=this.props;if(i&&!e.crop&&t){let{width:e,height:n}=this.getBox();e&&n&&i(o(t,e,n),a(t,e,n))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||=(this.document.addEventListener("pointermove",this.onDocPointerMove,s),this.document.addEventListener("pointerup",this.onDocPointerDone,s),this.document.addEventListener("pointercancel",this.onDocPointerDone,s),!0)}unbindDocMove(){this.docMoveBound&&=(this.document.removeEventListener("pointermove",this.onDocPointerMove,s),this.document.removeEventListener("pointerup",this.onDocPointerDone,s),this.document.removeEventListener("pointercancel",this.onDocPointerDone,s),!1)}onCropPointerDown=e=>{let{crop:t,disabled:i}=this.props,n=this.getBox();if(!t)return;let r=o(t,n.width,n.height);if(i)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let a=e.target.dataset.ord,l=e.clientX,s=e.clientY,c=r.x,h=r.y;if(a){let t=e.clientX-n.x,i=e.clientY-n.y,o=0,d=0;"ne"===a||"e"==a?(o=t-(r.x+r.width),d=i-r.y,c=r.x,h=r.y+r.height):"se"===a||"s"===a?(o=t-(r.x+r.width),d=i-(r.y+r.height),c=r.x,h=r.y):"sw"===a||"w"==a?(o=t-r.x,d=i-(r.y+r.height),c=r.x+r.width,h=r.y):("nw"===a||"n"==a)&&(o=t-r.x,d=i-r.y,c=r.x+r.width,h=r.y+r.height),l=c+n.x+o,s=h+n.y+d}this.evData={startClientX:l,startClientY:s,startCropX:c,startCropY:h,clientX:e.clientX,clientY:e.clientY,isResize:!!a,ord:a},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})};onComponentPointerDown=e=>{let{crop:t,disabled:i,locked:n,keepSelection:r,onChange:l}=this.props,s=this.getBox();if(i||n||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let c=e.clientX-s.x,h=e.clientY-s.y,d={unit:"px",x:c,y:h,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:c,startCropY:h,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(o(d,s.width,s.height),a(d,s.width,s.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})};onDocPointerMove=e=>{let t,{crop:i,disabled:n,onChange:l,onDragStart:s}=this.props,c=this.getBox();if(n||!i||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));let{evData:h}=this;h.clientX=e.clientX,h.clientY=e.clientY,r(i,t=h.isResize?this.resizeCrop():this.dragCrop())||l(o(t,c.width,c.height),a(t,c.width,c.height))};onComponentKeyDown=t=>{let{crop:i,disabled:r,onChange:l,onComplete:s}=this.props;if(r)return;let c=t.key,h=!1;if(!i)return;let d=this.getBox(),u=this.makePixelCrop(d),m=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep;if("ArrowLeft"===c?(u.x-=m,h=!0):"ArrowRight"===c?(u.x+=m,h=!0):"ArrowUp"===c?(u.y-=m,h=!0):"ArrowDown"===c&&(u.y+=m,h=!0),h){t.cancelable&&t.preventDefault(),u.x=n(u.x,0,d.width-u.width),u.y=n(u.y,0,d.height-u.height);let e=o(u,d.width,d.height),i=a(u,d.width,d.height);l(e,i),s&&s(e,i)}};onHandlerKeyDown=(t,i)=>{var n,s;let c,{aspect:h=0,crop:d,disabled:u,minWidth:m=0,minHeight:g=0,maxWidth:p,maxHeight:f,onChange:w,onComplete:x}=this.props,y=this.getBox();if(u||!d||"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.stopPropagation(),t.preventDefault();let b=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep,v=l((n=o(d,y.width,y.height),s=t.key,c={...n},"ArrowLeft"===s?"nw"===i?(c.x-=b,c.y-=b,c.width+=b,c.height+=b):"w"===i?(c.x-=b,c.width+=b):"sw"===i?(c.x-=b,c.width+=b,c.height+=b):"ne"===i?(c.y+=b,c.width-=b,c.height-=b):"e"===i?c.width-=b:"se"===i&&(c.width-=b,c.height-=b):"ArrowRight"===s&&("nw"===i?(c.x+=b,c.y+=b,c.width-=b,c.height-=b):"w"===i?(c.x+=b,c.width-=b):"sw"===i?(c.x+=b,c.width-=b,c.height-=b):"ne"===i?(c.y-=b,c.width+=b,c.height+=b):"e"===i?c.width+=b:"se"===i&&(c.width+=b,c.height+=b)),"ArrowUp"===s?"nw"===i?(c.x-=b,c.y-=b,c.width+=b,c.height+=b):"n"===i?(c.y-=b,c.height+=b):"ne"===i?(c.y-=b,c.width+=b,c.height+=b):"sw"===i?(c.x+=b,c.width-=b,c.height-=b):"s"===i?c.height-=b:"se"===i&&(c.width-=b,c.height-=b):"ArrowDown"===s&&("nw"===i?(c.x+=b,c.y+=b,c.width-=b,c.height-=b):"n"===i?(c.y+=b,c.height-=b):"ne"===i?(c.y+=b,c.width-=b,c.height-=b):"sw"===i?(c.x-=b,c.width+=b,c.height+=b):"s"===i?c.height+=b:"se"===i&&(c.width+=b,c.height+=b)),c),h,i,y.width,y.height,m,g,p,f);if(!r(d,v)){let e=a(v,y.width,y.height);w(v,e),x&&x(v,e)}};onDocPointerDone=e=>{let{crop:t,disabled:i,onComplete:n,onDragEnd:r}=this.props,l=this.getBox();this.unbindDocMove(),!(i||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),n&&n(o(t,l.width,l.height),a(t,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))};onDragFocus=()=>{this.componentRef.current?.scrollTo(0,0)};getCropStyle(){let{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){let{evData:e}=this,t=this.getBox(),i=this.makePixelCrop(t),r=e.clientX-e.startClientX,a=e.clientY-e.startClientY;return i.x=n(e.startCropX+r,0,t.width-i.width),i.y=n(e.startCropY+a,0,t.height-i.height),i}getPointRegion(e,t,i,n){let{evData:r}=this,a=r.clientX-e.x,o=r.clientY-e.y,l;return l=n&&t?"nw"===t||"n"===t||"ne"===t:o<r.startCropY,(i&&t?"nw"===t||"w"===t||"sw"===t:a<r.startCropX)?l?"nw":"sw":l?"ne":"se"}resolveMinDimensions(e,t,i=0,n=0){let r=Math.min(i,e.width),a=Math.min(n,e.height);return t&&(r||a)?t>1?r?[r,r/t]:[a*t,a]:a?[a*t,a]:[r,r/t]:[r,a]}resizeCrop(){let{evData:t}=this,{aspect:i=0,maxWidth:r,maxHeight:a}=this.props,o=this.getBox(),[s,c]=this.resolveMinDimensions(o,i,this.props.minWidth,this.props.minHeight),h=this.makePixelCrop(o),d=this.getPointRegion(o,t.ord,s,c),u=t.ord||d,m=t.clientX-t.startClientX,g=t.clientY-t.startClientY;(s&&"nw"===u||"w"===u||"sw"===u)&&(m=Math.min(m,-s)),(c&&"nw"===u||"n"===u||"ne"===u)&&(g=Math.min(g,-c));let p={unit:"px",x:0,y:0,width:0,height:0};"ne"===d?(p.x=t.startCropX,p.width=m,i?p.height=p.width/i:p.height=Math.abs(g),p.y=t.startCropY-p.height):"se"===d?(p.x=t.startCropX,p.y=t.startCropY,p.width=m,i?p.height=p.width/i:p.height=g):"sw"===d?(p.x=t.startCropX+m,p.y=t.startCropY,p.width=Math.abs(m),i?p.height=p.width/i:p.height=g):"nw"===d&&(p.x=t.startCropX+m,p.width=Math.abs(m),i?(p.height=p.width/i,p.y=t.startCropY-p.height):(p.height=Math.abs(g),p.y=t.startCropY+g));let f=l(p,i,d,o.width,o.height,s,c,r,a);return i||e.xyOrds.indexOf(u)>-1?h=f:e.xOrds.indexOf(u)>-1?(h.x=f.x,h.width=f.width):e.yOrds.indexOf(u)>-1&&(h.y=f.y,h.height=f.height),h.x=n(h.x,0,o.width-h.width),h.y=n(h.y,0,o.height-h.height),h}renderCropSelection(){let{ariaLabels:i=e.defaultProps.ariaLabels,disabled:n,locked:r,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,s=this.getCropStyle();if(l)return t.default.createElement("div",{style:s,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":i.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!n&&!r&&t.default.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":i.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":i.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":i.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":i.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":i.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":i.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":i.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":i.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),a&&t.default.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:e=>e.stopPropagation()},a(this.state)),o&&t.default.createElement(t.default.Fragment,null,t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){return o({...i,...this.props.crop||{}},e.width,e.height)}render(){let{aspect:e,children:i,circularCrop:n,className:r,crop:a,disabled:o,locked:l,style:s,ruleOfThirds:c}=this.props,{cropIsActive:h,newCropIsBeingDrawn:d}=this.state,u=a?this.renderCropSelection():null,m=((...e)=>e.filter(e=>e&&"string"==typeof e).join(" "))("ReactCrop",r,h&&"ReactCrop--active",o&&"ReactCrop--disabled",l&&"ReactCrop--locked",d&&"ReactCrop--new-crop",a&&e&&"ReactCrop--fixed-aspect",a&&n&&"ReactCrop--circular-crop",a&&c&&"ReactCrop--rule-of-thirds",!this.dragStarted&&a&&!a.width&&!a.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return t.default.createElement("div",{ref:this.componentRef,className:m,style:s},t.default.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},i),a?t.default.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},t.default.createElement("defs",null,t.default.createElement("mask",{id:`hole-${this.instanceId}`},t.default.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?t.default.createElement("ellipse",{cx:`${a.x+a.width/2}${a.unit}`,cy:`${a.y+a.height/2}${a.unit}`,rx:`${a.width/2}${a.unit}`,ry:`${a.height/2}${a.unit}`,fill:"black"}):t.default.createElement("rect",{x:`${a.x}${a.unit}`,y:`${a.y}${a.unit}`,width:`${a.width}${a.unit}`,height:`${a.height}${a.unit}`,fill:"black"}))),t.default.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,u)}};e.s(["f",0,h])},469937,e=>{var t=e.i(843476),i=e.i(786563),n=e.i(111110),r=e.i(975157);let a=[1,2,3,4,5];e.s(["f",0,function({value:e,onChange:o,disabled:l,size:s="sm",showUnrated:c=!0,className:h}){let{t:d}=(0,n.b)(),u=e??0,m="sm"===s?"h-3.5 w-3.5":"h-5 w-5",g=u?d.difficulty.starsLabel.replace("{n}",String(u)):d.difficulty.unrated;return o?(0,t.jsxs)("span",{className:(0,r.f)("inline-flex items-center gap-0.5",h),role:"group","aria-label":`${d.difficulty.label}${d.common.colon}${g}`,title:d.difficulty.clearHint,children:[a.map(e=>(0,t.jsx)("button",{type:"button",disabled:l,onClick:()=>o(e===u?null:e),"aria-label":d.difficulty.setStars.replace("{n}",String(e)),"aria-pressed":e<=u,className:"rounded p-0.5 hover:bg-muted disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(i.f,{className:(0,r.f)(m,e<=u?"fill-amber-400 text-amber-400":"text-muted-foreground/40")})},e)),!u&&c&&(0,t.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:d.difficulty.unrated})]}):u?(0,t.jsx)("span",{className:(0,r.f)("inline-flex items-center",h),role:"img","aria-label":`${d.difficulty.label}${d.common.colon}${g}`,title:g,children:a.map(e=>(0,t.jsx)(i.f,{className:(0,r.f)(m,e<=u?"fill-amber-400 text-amber-400":"text-muted-foreground/30"),"aria-hidden":!0},e))}):c?(0,t.jsx)("span",{className:(0,r.f)("text-xs text-muted-foreground",h),children:d.difficulty.unrated}):null}])},12130,e=>{var t=e.i(843476),i=e.i(271645),n=e.i(232660),r=e.i(519455),a=e.i(776639),o=e.i(263676),l=e.i(111110);async function s(e,t){let{naturalWidth:i,naturalHeight:n}=e;return Promise.all(t.map(t=>new Promise((r,a)=>{let o=document.createElement("canvas"),l=Math.round(t.x*i),s=Math.round(t.y*n);o.width=Math.max(1,Math.round(t.width*i)),o.height=Math.max(1,Math.round(t.height*n));let c=o.getContext("2d");c?(c.drawImage(e,l,s,o.width,o.height,0,0,o.width,o.height),o.toBlob(e=>e?r(e):a(Error("Canvas is empty")),"image/jpeg",.95)):a(Error("Canvas is not supported"))})))}let c={maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},h=(0,i.forwardRef)(function({imageSrc:e,regions:n,onChange:r,imageStyle:a=c,onImageLoad:s},h){let{t:d}=(0,l.b)(),u=(0,i.useRef)(null),m=(0,i.useRef)(null),[g,p]=(0,i.useState)(null),f=e=>{let t=u.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},w=()=>{g&&g.width>=.02&&g.height>=.02&&r([...n,g]),m.current=null,p(null)},x=e=>({left:`${100*e.x}%`,top:`${100*e.y}%`,width:`${100*e.width}%`,height:`${100*e.height}%`});return(0,t.jsxs)("div",{className:"relative inline-block select-none",children:[(0,t.jsx)("img",{ref:h,src:e,alt:"",draggable:!1,style:a,onLoad:s,className:"block"}),(0,t.jsxs)("div",{ref:u,className:"absolute inset-0 cursor-crosshair",style:{touchAction:"none"},onPointerDown:e=>{0===e.button&&(u.current?.setPointerCapture(e.pointerId),m.current=f(e),p(null))},onPointerMove:e=>{var t,i,n,r;let a,o,l;if(!m.current)return;let s=f(e);p((t=m.current.x,i=m.current.y,n=s.x,r=s.y,o=(a=e=>Math.min(1,Math.max(0,e)))(Math.min(t,n)),l=a(Math.min(i,r)),{x:o,y:l,width:a(Math.max(t,n))-o,height:a(Math.max(i,r))-l}))},onPointerUp:w,onPointerCancel:w,children:[n.map((e,i)=>(0,t.jsxs)("div",{className:"absolute border-2 border-sky-400 bg-sky-400/15",style:x(e),children:[(0,t.jsx)("span",{className:"absolute left-0 top-0 bg-sky-500 px-1.5 text-xs font-bold text-white",children:i+1}),(0,t.jsx)("button",{type:"button",className:"absolute -right-3 -top-3 flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-white shadow","aria-label":d.batchImport.removeRegion.replace("{index}",String(i+1)),onPointerDown:e=>e.stopPropagation(),onClick:()=>r(n.filter((e,t)=>t!==i)),children:(0,t.jsx)(o.X,{className:"h-3 w-3"})})]},i)),g&&(0,t.jsx)("div",{className:"absolute border-2 border-dashed border-yellow-300 bg-yellow-300/10",style:x(g)})]})]})});var d=e.i(456420);let u={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};u.node;let m=(0,d.f)(u),g={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};g.node;let p=(0,d.f)(g);function f({zoom:e,onZoomIn:i,onZoomOut:n,onReset:r}){let{t:a}=(0,l.b)(),o="outline-none focus-visible:ring-2 focus-visible:ring-white/70",s=`flex h-9 w-9 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 disabled:opacity-40 disabled:hover:bg-transparent ${o}`;return(0,t.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full bg-black/60 p-1 shadow-lg backdrop-blur-sm",children:[(0,t.jsx)("button",{type:"button",className:s,onClick:n,disabled:e<=1,"aria-label":a.common.cropper.zoomOut,title:a.common.cropper.zoomOut,children:(0,t.jsx)(p,{className:"h-4 w-4"})}),(0,t.jsxs)("button",{type:"button",className:`h-9 min-w-14 rounded-full px-2 text-center text-xs font-medium tabular-nums text-white hover:bg-white/20 ${o}`,onClick:r,"aria-label":a.common.cropper.resetZoom,title:a.common.cropper.resetZoom,children:[Math.round(100*e),"%"]}),(0,t.jsx)("button",{type:"button",className:s,onClick:i,disabled:e>=5,"aria-label":a.common.cropper.zoomIn,title:a.common.cropper.zoomIn,children:(0,t.jsx)(m,{className:"h-4 w-4"})})]})}var w=e.i(201276);let x={single:{maxHeight:"70vh",maxWidth:"100%",objectFit:"contain"},auto:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},multi:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"}};e.s(["f",0,function({imageSrc:e,open:o,onClose:c,onCropComplete:d,onMultiCropComplete:u,onRegionsSelected:m,allowMulti:g=!0,onAutoSplit:p,onAddPart:y,partCount:b=0}){let{t:v}=(0,l.b)(),C=/^(blob:|data:image\/)/i.test(e)?e:void 0,[k,j]=(0,i.useState)(),D=(0,i.useRef)(null),[M,E]=(0,i.useState)("single"),{containerRef:_,zoom:N,imageStyle:R,measureImage:S,zoomIn:L,zoomOut:I,reset:P}=function(e){let[t,n]=(0,i.useState)(null),r=(0,i.useRef)(null),a=(0,i.useCallback)(e=>{r.current=e,n(e)},[]),[o,l]=(0,i.useState)(1),s=(0,i.useRef)(1),[c,h]=(0,i.useState)(null),d=(0,i.useRef)(null),u=(0,i.useRef)(!1),m=(0,i.useCallback)((e,t,i)=>{let n=r.current,a=s.current,o=Math.min(5,Math.max(1,e));if(!n||o===a)return;if(1===a){let e=n.querySelector("img");e&&h(e.clientWidth)}let c=n.getBoundingClientRect(),u=(t??c.left+c.width/2)-c.left,m=(i??c.top+c.height/2)-c.top;d.current={viewX:u,viewY:m,contentX:n.scrollLeft+u,contentY:n.scrollTop+m,ratio:o/a},s.current=o,l(o)},[]);(0,i.useLayoutEffect)(()=>{let e=r.current,t=d.current;e&&t&&(e.scrollLeft=t.contentX*t.ratio-t.viewX,e.scrollTop=t.contentY*t.ratio-t.viewY,d.current=null)},[o]),(0,i.useEffect)(()=>{if(!t)return;let e=e=>{e.preventDefault(),m(s.current*Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},i=null,n=e=>{let[t,i]=[e[0],e[1]];return{distance:Math.hypot(t.clientX-i.clientX,t.clientY-i.clientY),centerX:(t.clientX+i.clientX)/2,centerY:(t.clientY+i.clientY)/2}},r=e=>{2===e.touches.length&&(i={distance:n(e.touches).distance,zoom:s.current},u.current=!0)},a=e=>{if(!i||2!==e.touches.length)return;e.preventDefault();let{distance:t,centerX:r,centerY:a}=n(e.touches);i.distance>0&&m(i.zoom*(t/i.distance),r,a)},o=e=>{e.touches.length<2&&(i=null,u.current=!1)},l=e=>{u.current&&e.stopPropagation()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",r,{passive:!0}),t.addEventListener("touchmove",a,{passive:!1}),t.addEventListener("touchend",o),t.addEventListener("touchcancel",o),t.addEventListener("pointermove",l,{capture:!0}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",r),t.removeEventListener("touchmove",a),t.removeEventListener("touchend",o),t.removeEventListener("touchcancel",o),t.removeEventListener("pointermove",l,{capture:!0})}},[t,m]);let g=(0,i.useCallback)(e=>{e&&1===s.current&&h(e.clientWidth)},[]),p=(0,i.useCallback)(()=>m(1.25*s.current),[m]),f=(0,i.useCallback)(()=>m(s.current/1.25),[m]),w=(0,i.useCallback)(()=>{s.current=1,d.current=null,l(1)},[]),x=1!==o&&c?{...e,width:c*o,height:"auto",maxWidth:"none",maxHeight:"none"}:e;return{containerRef:a,zoom:o,imageStyle:x,measureImage:g,zoomIn:p,zoomOut:f,reset:w}}(x[M]);(0,i.useEffect)(()=>{P()},[e,P]);let[z,$]=(0,i.useState)({src:e,regions:[]}),H=z.src===e?z.regions:[],A=t=>$({src:e,regions:t}),B=(0,i.useRef)(null),Y=["single",...p?["auto"]:[],...u||m&&g?["multi"]:[]],O={single:v.batchImport.singleMode,auto:v.batchImport.autoMode,multi:v.batchImport.multiMode},X=async()=>{if(0!==H.length){if(m){m(H,!0),A([]);return}if(B.current&&u)try{u(await s(B.current,H)),A([])}catch(e){w.V.error("[ImageCropper]","Multi-image crop failed",{error:e})}}},U=()=>k&&k.width>0&&k.height>0?{x:k.x/100,y:k.y/100,width:k.width/100,height:k.height/100}:{x:0,y:0,width:1,height:1},K=async()=>{let e=U();if("auto"===M&&p)return void p(e);if(m)return void m([e],!1);if(D.current&&d)try{let[t]=await s(D.current,[e]);d(t)}catch(e){w.V.error("[ImageCropper]","Crop failed",{error:e})}};return(0,t.jsx)(a.N,{open:o,onOpenChange:e=>!e&&c(),children:(0,t.jsxs)(a.d,{className:"max-w-3xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,t.jsx)(a.s,{className:"p-4 border-b shrink-0",children:(0,t.jsx)(a.F,{children:v.common.cropper?.title||"Crop Image"})}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1 bg-black",children:[(0,t.jsx)("div",{ref:_,className:"flex h-full w-full overflow-auto p-4",children:(0,t.jsx)("div",{className:"m-auto",children:"multi"===M?(0,t.jsx)(h,{ref:B,imageSrc:C,regions:H,onChange:A,imageStyle:R,onImageLoad:e=>S(e.currentTarget)}):(0,t.jsx)(n.f,{crop:k,onChange:(e,t)=>j(t),children:(0,t.jsx)("img",{ref:D,alt:"Crop me",src:C,onLoad:function(e){j({unit:"%",x:0,y:0,width:100,height:100}),S(e.currentTarget)},style:R})})})}),(0,t.jsx)("div",{className:"absolute right-3 top-3",children:(0,t.jsx)(f,{zoom:N,onZoomIn:L,onZoomOut:I,onReset:P})})]}),(0,t.jsxs)("div",{className:"p-4 border-t bg-background shrink-0 space-y-3",children:[Y.length>1&&(0,t.jsx)("div",{className:`grid gap-1 rounded-md bg-muted p-1 ${3===Y.length?"grid-cols-3 sm:w-[28rem]":"grid-cols-2 sm:w-80"}`,children:Y.map(e=>(0,t.jsx)("button",{type:"button","aria-pressed":M===e,onClick:()=>{P(),E(e)},className:`rounded px-2 py-1.5 text-sm font-medium transition-colors ${M===e?"bg-background shadow-sm":"text-muted-foreground"}`,children:O[e]},e))}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"multi"===M?`${v.batchImport.hint} ${v.batchImport.regionCount.replace("{count}",String(H.length))}`:"auto"===M?v.batchImport.autoHint:b>0?v.upload.parts.cropHint.replace("{n}",String(b+1)):v.common.cropper?.hint||"💡 Drag to adjust crop area"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:["multi"===M&&H.length>0&&(0,t.jsx)(r.f,{variant:"ghost",onClick:()=>A([]),children:v.batchImport.clear}),(0,t.jsx)(r.f,{variant:"outline",onClick:c,children:v.common.cancel||"Cancel"}),"multi"===M?(0,t.jsx)(r.f,{onClick:X,disabled:0===H.length,children:v.batchImport.start.replace("{count}",String(H.length))}):(0,t.jsxs)(t.Fragment,{children:["single"===M&&y&&(0,t.jsx)(r.f,{variant:"secondary",onClick:()=>y(U()),"data-testid":"crop-add-part",children:v.upload.parts.addNext}),(0,t.jsx)(r.f,{onClick:K,children:"auto"===M?v.batchImport.autoStart:b>0?v.upload.parts.confirm.replace("{count}",String(b+1)):v.common.confirm||"Confirm"})]})]})]})]})]})})}],12130)},141176,e=>{var t=e.i(843476),i=e.i(271645),n=e.i(456420);let r={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};r.node;let a=(0,n.f)(r);var o=e.i(772382),l=e.i(511445),s=e.i(624687),c=e.i(111110),h=e.i(975157);e.s(["f",0,function({value:e,onChange:n,className:r,...d}){let{t:u}=(0,c.b)(),[m,g]=(0,i.useState)("source"),p=(0,i.useId)(),f=[{mode:"source",label:u.markdownEditor.source,icon:a},{mode:"preview",label:u.markdownEditor.preview,icon:o.f}];return(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("div",{role:"tablist","aria-label":u.markdownEditor.modeLabel,className:"flex justify-end",children:(0,t.jsx)("div",{className:"inline-flex rounded-md border bg-muted/40 p-0.5",children:f.map(({mode:e,label:i,icon:n})=>(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":m===e,"aria-controls":p,onClick:()=>g(e),className:(0,h.f)("flex items-center gap-1 rounded px-2.5 py-1 text-xs transition-colors",m===e?"bg-background font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(n,{className:"h-3.5 w-3.5"}),i]},e))})}),(0,t.jsx)("div",{id:p,role:"tabpanel",children:"source"===m?(0,t.jsx)(s.f,{value:e,onChange:e=>n(e.target.value),className:r,...d}):(0,t.jsx)("div",{className:"min-h-24 cursor-text rounded-md border bg-muted/20 px-3 py-2",onDoubleClick:()=>g("source"),title:u.markdownEditor.doubleClickToEdit,children:e.trim()?(0,t.jsx)(l.f,{content:e}):(0,t.jsx)("p",{className:"text-sm italic text-muted-foreground",children:u.markdownEditor.empty})})})]})}],141176)},438465,674166,e=>{var t=e.i(843476),i=e.i(271645),n=e.i(967489),r=e.i(856423),a=e.i(41931),o=e.i(201276),l=e.i(111110);e.s(["f",0,function({value:e,onChange:s,className:c}){let[h,d]=(0,i.useState)([]),{t:u}=(0,l.b)();return(0,i.useEffect)(()=>{(async()=>{try{let e=await a.k.get("/api/notebooks");d(e)}catch(e){o.V.error("[NotebookSelector]","Failed to fetch notebooks",{error:e})}})()},[]),(0,t.jsxs)(n.d,{value:e,onValueChange:s,children:[(0,t.jsx)(n.P,{className:c,children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(r.f,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)(n.U,{placeholder:u.notebooks?.selector?.placeholder||"Select Notebook"})]})}),(0,t.jsx)(n.r,{children:0===h.length?(0,t.jsx)("div",{className:"p-2 text-sm text-muted-foreground text-center",children:u.notebooks?.selector?.empty||"No notebooks available"}):h.map(e=>(0,t.jsx)(n.T,{value:e.id,children:e.name},e.id))})]})}],438465);var s=e.i(470279);e.s(["f",0,function({value:e,onChange:i,disabled:r}){let{groups:a,loading:o}=(0,s.f)(),l=a.filter(e=>e.isActive);return(0,t.jsxs)(n.d,{value:e,onValueChange:i,disabled:r||o,children:[(0,t.jsx)(n.P,{children:(0,t.jsx)(n.U,{placeholder:"选择卷别"})}),(0,t.jsx)(n.r,{children:l.map(e=>(0,t.jsx)(n.T,{value:e.id,children:e.name},e.id))})]})}],674166)},149704,e=>{var t=e.i(843476),i=e.i(111110),n=e.i(398019),r=e.i(184110),a=e.i(975157);let o={left:"mr-auto",center:"mx-auto",right:"ml-auto"};e.s(["f",0,function({svg:e,scale:l,align:s,className:c}){let{t:h}=(0,i.b)();if(!e)return null;let d=(0,r.V)(l),u=(0,r.o)(s);return(0,t.jsx)("figure",{className:(0,a.f)("question-figure my-3",c),children:(0,t.jsx)("img",{src:(0,n.d)(e),alt:h.figure.alt,className:(0,a.f)(o[u],"block h-auto max-w-full rounded border bg-white p-2"),style:{..."left"===u?{marginLeft:0,marginRight:"auto"}:"right"===u?{marginLeft:"auto",marginRight:0}:{},maxHeight:360,zoom:d/100,maxWidth:`${Math.min(d,100)}%`}})})}])},574041,e=>{var t=e.i(843476),i=e.i(271645),n=e.i(263676),r=e.i(487486),a=e.i(793479),o=e.i(41931),l=e.i(201276);e.s(["f",0,function({value:e=[],onChange:s,placeholder:c="Enter tags...",className:h="",enterHint:d,subject:u,gradeStage:m}){let[g,p]=(0,i.useState)(""),[f,w]=(0,i.useState)([]),[x,y]=(0,i.useState)(!1),[b,v]=(0,i.useState)(0),C=(0,i.useRef)(null),k=(0,i.useRef)(null),j=(0,i.useCallback)(async t=>{try{let i=new URLSearchParams({q:t});u&&i.append("subject",u),m&&i.append("stage",m);let n=((await o.k.get(`/api/tags/suggestions?${i.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));w(n.slice(0,20)),y(n.length>0),v(0)}catch(e){l.V.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[u,m,e]);(0,i.useEffect)(()=>{g.trim()&&j(g)},[g,j]);let D=t=>{t.trim()&&!e.includes(t.trim())&&(s([...e,t.trim()]),p(""),w([]),y(!1),v(0))},M=t=>{s(e.filter(e=>e!==t))};return(0,i.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||C.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${h}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(r.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>M(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(n.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(a.f,{ref:C,type:"text",value:g,onChange:e=>{p(e.target.value),e.target.value.trim()||(w([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?D(f[b]):g.trim()&&D(g)):"ArrowDown"===t.key?(t.preventDefault(),v(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),v(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),v(0)):"Backspace"===t.key&&!g&&e.length>0&&M(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?c:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),x&&f.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,i)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${i===b?"bg-accent":""}`,onClick:()=>D(e),onMouseEnter:()=>v(i),children:e},e))}),g&&!x&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:d?`${d} "${g}"`:`Press Enter to create "${g}"`})]})}])},184110,e=>{let t=["left","center","right"],i="center";function n(e){return"number"==typeof e&&Number.isInteger(e)&&e>=10&&e<=200}e.s(["E",0,i,"n",0,100,"j",0,t,"a",0,200,"_",0,10,"x",0,n,"o",0,function(e){return"string"==typeof e&&t.includes(e)?e:i},"V",0,function(e){return n(e)?e:100}])},398019,e=>{e.s(["K",0,1e5,"d",0,function(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}])},213761,e=>{let t={maxLongEdge:4096,maxPixels:4915200,maxBytes:1572864,startQuality:.9,minQuality:.8};class i extends Error{code;format;constructor(e,t,i){super(e,void 0===i?void 0:{cause:i}),this.code=e,this.format=t,this.name="ImageDecodeError"}}let n=new Set(["heic","heix","heim","heis","hevc","hevx","hevm","hevs"]),r=new Set(["mif1","msf1","mif2"]),a=new Set(["avif","avis"]);function o(e,i,n=t){let r=Math.min(1,n.maxLongEdge/Math.max(e,i),Math.sqrt(n.maxPixels/Math.max(1,e*i)));return{width:Math.max(1,Math.floor(e*r)),height:Math.max(1,Math.floor(i*r)),scale:r}}async function l(e){let t,i;if("function"==typeof createImageBitmap)try{return await createImageBitmap(e,{imageOrientation:"from-image"})}catch{}let n=await (t=URL.createObjectURL(e),(i=new Image).decoding="async",new Promise((e,n)=>{i.onload=()=>e(i),i.onerror=()=>n(Error("IMAGE_ELEMENT_DECODE_FAILED")),i.src=t}).finally(()=>URL.revokeObjectURL(t)));if(!n.naturalWidth||!n.naturalHeight)throw Error("IMAGE_EMPTY");return n}async function s(t){let{heicTo:i}=await e.A(462684);return i({blob:t,type:"image/jpeg",quality:.95})}function c(e,t){return new Promise((i,n)=>{e.toBlob(e=>e?i(e):n(Error("CANVAS_EMPTY")),"image/jpeg",t)})}function h(e,t,i,n,r,a,o){let l,s=((l=document.createElement("canvas")).width=a,l.height=o,l),c=s.getContext("2d");if(!c)throw Error("CANVAS_UNSUPPORTED");return c.fillStyle="#ffffff",c.fillRect(0,0,a,o),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(e,t,i,n,r,0,0,a,o),s}async function d(e,t){var d;let u,m=performance.now(),g=await e.arrayBuffer(),p=performance.now()-m,f=function(e){let t=(t,i)=>String.fromCharCode(...e.subarray(t,i));if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])return"jpeg";if(e.length>=8&&137===e[0]&&"PNG"===t(1,4))return"png";if(e.length>=12&&"RIFF"===t(0,4)&&"WEBP"===t(8,12))return"webp";if(e.length>=6&&("GIF87a"===t(0,6)||"GIF89a"===t(0,6)))return"gif";if(e.length>=2&&"BM"===t(0,2))return"bmp";if(e.length>=12&&"ftyp"===t(4,8)){let i=Math.min(e.length,(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0||e.length),o=[t(8,12)];for(let e=16;e+4<=i;e+=4)o.push(t(e,e+4));if(o.some(e=>n.has(e)))return"heic";if(o.some(e=>a.has(e)))return"avif";if(o.some(e=>r.has(e)))return"heic"}return"unknown"}(new Uint8Array(g,0,Math.min(g.byteLength,64))),w=e.type||"",x=performance.now(),y="native",b=new Blob([g],{type:w||"application/octet-stream"});try{u=await l(b)}catch(e){if("heic"!==f)throw new i("unknown"===f?"UNSUPPORTED_IMAGE":"IMAGE_DECODE_FAILED",f,e);t?.();try{u=await l(await s(b)),y="heic"}catch(e){throw new i("HEIC_DECODE_FAILED",f,e)}}let{width:v,height:C}=(d=u)instanceof HTMLImageElement?{width:d.naturalWidth,height:d.naturalHeight}:{width:d.width,height:d.height};if(!v||!C)throw new i("IMAGE_DECODE_FAILED",f);let k=o(v,C,{maxLongEdge:1600,maxPixels:1/0}),j=await c(h(u,0,0,v,C,k.width,k.height),.85),D=URL.createObjectURL(j),M=performance.now()-x;return{source:u,width:v,height:C,format:f,decoder:y,previewUrl:D,sourceType:w,sourceBytes:e.size,timings:{read:Math.round(p),convert:Math.round(M)},dispose:()=>{URL.revokeObjectURL(D),u instanceof HTMLImageElement||u.close()}}}let u={x:0,y:0,width:1,height:1};async function m(e,i=u,n=t){var r;let a=performance.now(),l=e=>Math.min(1,Math.max(0,e)),s=Math.round(l(i.x)*e.width),d=Math.round(l(i.y)*e.height),g=Math.max(1,Math.min(e.width-s,Math.round(l(i.width)*e.width))),p=Math.max(1,Math.min(e.height-d,Math.round(l(i.height)*e.height))),f=o(g,p,n),w=h(e.source,s,d,g,p,f.width,f.height),x=performance.now()-a,y=performance.now(),b=n.startQuality,v=await c(w,b);for(let t=0;v.size>n.maxBytes&&t<12;t++)b-.05>=n.minQuality-1e-9?b=Math.round((b-.05)*100)/100:(f={width:Math.max(1,Math.floor(.85*f.width)),height:Math.max(1,Math.floor(.85*f.height)),scale:.85*f.scale},w=h(e.source,s,d,g,p,f.width,f.height)),v=await c(w,b);return{dataUrl:await (r=v,new Promise((e,t)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=()=>t(i.error??Error("READ_FAILED")),i.readAsDataURL(r)})),width:f.width,height:f.height,bytes:v.size,quality:b,timings:{crop:Math.round(x),compress:Math.round(performance.now()-y)}}}e.s(["K",0,t,"o",0,i,"N",0,function(e,t){return{sourceType:e.sourceType||e.format,sourceBytes:e.sourceBytes,sourceWidth:e.width,sourceHeight:e.height,outputWidth:t.width,outputHeight:t.height,outputBytes:t.bytes,decoder:e.decoder,quality:t.quality}},"p",0,d,"X",0,m])},991722,e=>{function t(e){return"not_attempted"===e||"wrong_attempt"===e||"unknown"===e?e:"unknown"}e.s(["i",0,function(e,i="zh"){return("en"===i?{not_attempted:"Not attempted",wrong_attempt:"Wrong attempt",unknown:"Unknown"}:{not_attempted:"不会做",wrong_attempt:"做错了",unknown:"未判断"})[t(e)]},"h",0,t,"x",0,function(e,i){return(i||"").trim()?"wrong_attempt":t(e)}])},401280,e=>{let t={single_choice:"single_choice",singlechoice:"single_choice","single choice":"single_choice","single-choice":"single_choice",multiple_choice:"multiple_choice",multiplechoice:"multiple_choice","multiple choice":"multiple_choice","multiple-choice":"multiple_choice",multichoice:"multiple_choice","multi choice":"multiple_choice",true_false:"true_false",truefalse:"true_false","true/false":"true_false","true false":"true_false","true-false":"true_false","true / false":"true_false",fill_blank:"fill_blank",fillblank:"fill_blank","fill in the blank":"fill_blank","fill-in-the-blank":"fill_blank",fillintheblank:"fill_blank",calculation:"calculation",solution:"solution",reading:"reading",cloze:"cloze",writing:"writing",other:"other",选择题:"single_choice",单项选择:"single_choice",单选:"single_choice",单选题:"single_choice",不定项:"multiple_choice",不定项选择:"multiple_choice",多项选择:"multiple_choice",多选:"multiple_choice",多选题:"multiple_choice",判断:"true_false",判断题:"true_false",是非:"true_false",是非题:"true_false",填空:"fill_blank",填空题:"fill_blank",口算:"calculation",计算:"calculation",计算题:"calculation",解答:"solution",解答题:"solution",应用:"solution",应用题:"solution",证明:"solution",证明题:"solution",简答:"solution",简答题:"solution",阅读:"reading",阅读理解:"reading",完形:"cloze",完形填空:"cloze",作文:"writing",写作:"writing",书面表达:"writing",其他:"other"};e.s(["O",0,"__none__","V",0,["single_choice","multiple_choice","true_false","fill_blank","calculation","solution","reading","cloze","writing","other"],"u",0,{single_choice:"Single Choice",multiple_choice:"Multiple Choice",true_false:"True / False",fill_blank:"Fill in the Blank",calculation:"Calculation",solution:"Solution",reading:"Reading Comprehension",cloze:"Cloze",writing:"Writing",other:"Other"},"H",0,{single_choice:"单选题",multiple_choice:"多选题",true_false:"判断题",fill_blank:"填空题",calculation:"计算题",solution:"解答题",reading:"阅读理解",cloze:"完形填空",writing:"写作",other:"其他"},"P",0,function(e){if("string"!=typeof e)return null;let i=e.trim().toLowerCase();return i?t[i]??null:null}])},597138,e=>{e.i(306831),e.s(["f",0,function(e){if(!e)return null;let t=e.toLowerCase();return t.includes("math")||t.includes("数学")?"math":t.includes("physics")||t.includes("物理")?"physics":t.includes("chemistry")||t.includes("化学")?"chemistry":t.includes("biology")||t.includes("生物")?"biology":t.includes("english")||t.includes("英语")?"english":t.includes("chinese")||t.includes("语文")?"chinese":t.includes("history")||t.includes("历史")?"history":t.includes("geography")||t.includes("地理")?"geography":t.includes("politics")||t.includes("政治")?"politics":null}])}])})();
@@ -1,16 +0,0 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,399847,e=>{var t=e.i(456420);let s={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};s.node;let r=(0,t.f)(s);e.s(["f",0,r],399847)},13285,e=>{var t=e.i(456420);let s={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};s.node;let r=(0,t.f)(s);e.s(["f",0,r],13285)},615568,168148,e=>{var t=e.i(456420);let s={name:"pencil-line",size:24,node:[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]};s.node;let r=(0,t.f)(s);e.s(["f",0,r],615568);var n=e.i(843476),a=e.i(271645),i=e.i(30030),l=e.i(248425),o=Object.defineProperty,u=(e,t)=>o(e,"name",{value:t,configurable:!0}),d="Progress",[c,m]=(0,i.f)(d),[f,h]=c(d),g=a.forwardRef(u(function(e,t){let{__scopeProgress:s,value:r=null,max:a,getValueLabel:i=x,...o}=e;(a||0===a)&&!v(a)&&console.error(b(`${a}`,"Progress"));let u=v(a)?a:100;null===r||j(r,u)||console.error(k(`${r}`,"Progress"));let d=j(r,u)?r:null,c=w(d)?i(d,u):void 0;return(0,n.jsx)(f,{scope:s,value:d,max:u,children:(0,n.jsx)(l.V.div,{"aria-valuemax":u,"aria-valuemin":0,"aria-valuenow":w(d)?d:void 0,"aria-valuetext":c,role:"progressbar","data-state":y(d,u),"data-value":d??void 0,"data-max":u,...o,ref:t})})},"Progress")),p=a.forwardRef(u(function(e,t){let{__scopeProgress:s,...r}=e,a=h("ProgressIndicator",s);return(0,n.jsx)(l.V.div,{"data-state":y(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})},"ProgressIndicator"));function x(e,t){return`${Math.round(e/t*100)}%`}function y(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function w(e){return"number"==typeof e}function v(e){return w(e)&&!isNaN(e)&&e>0}function j(e,t){return w(e)&&!isNaN(e)&&e<=t&&e>=0}function b(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}function k(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
2
- - a positive number
3
- - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)
4
- - \`null\` or \`undefined\` if the progress is indeterminate.
5
-
6
- Defaulting to \`null\`.`}u(x,"defaultGetValueLabel"),u(y,"getProgressState"),u(w,"isNumber"),u(v,"isValidMaxNumber"),u(j,"isValidValueNumber"),u(b,"getInvalidMaxError"),u(k,"getInvalidValueError");var S=e.i(975157);let N=a.forwardRef(({className:e,value:t,...s},r)=>(0,n.jsx)(g,{ref:r,value:t,className:(0,S.f)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...s,children:(0,n.jsx)(p,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));N.displayName=g.displayName,e.s(["f",0,N],168148)},866531,497346,183444,e=>{var t=e.i(843476),s=e.i(271645),r=e.i(632781),n=e.i(741120),a=e.i(856522),i=e.i(314381),l=e.i(3198),o=e.i(519455),u=e.i(111110),d=e.i(41931),c=e.i(294114),m=e.i(201276);function f({data:e,onChange:n}){let{t:a}=(0,u.b)(),[h,g]=(0,s.useState)(!1),[p,x]=(0,s.useState)(null),y=async()=>{if(!e.questionText.trim())return void c.c.warning(a.editor.enterQuestionFirst||"Please enter question text first");if(!e.answerText.trim())return void c.c.warning(a.geogebra.answerRequired);g(!0),x(null);try{let t=await d.k.post("/api/geogebra-analyze",{questionText:e.questionText,answerText:e.answerText,analysis:e.analysis},{timeout:18e4,recoverable:!0});t.suitable&&t.commands&&t.commands.length>0?n({geogebraCommands:JSON.stringify(t.commands)}):x(t.description||a.geogebra.notSuitable)}catch(e){m.V.error("[CorrectionEditor]","GeoGebra analysis failed",{error:e}),x(a.geogebra.analyzeFailed)}finally{g(!1)}};return e.geogebraCommands?(0,t.jsx)(l.f,{commands:e.geogebraCommands,height:350,onRegenerate:y,onDelete:async()=>n({geogebraCommands:void 0})}):e.questionText.trim()&&e.answerText.trim()?(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(i.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:a.geogebra.title})]}),(0,t.jsx)(o.f,{variant:"outline",size:"sm",onClick:y,disabled:h,children:h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.geogebra.analyzing]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.f,{className:"mr-2 h-4 w-4"}),a.geogebra.generate]})})]}),p&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:p}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:a.geogebra.hint})]}):null}var h=e.i(469937),g=e.i(28342),p=e.i(438465),x=e.i(674166),y=e.i(110204),w=e.i(967489),v=e.i(401280);function j({data:e,paperLevel:s,onChange:r}){let{t:n}=(0,u.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:n.editor.selectNotebook||"Select Notebook"}),(0,t.jsx)(p.f,{value:e.subjectId,onChange:e=>r({subjectId:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:n.questionType.label||"Question Type"}),(0,t.jsxs)(w.d,{value:e.questionType||"",onValueChange:e=>r({questionType:e===v.O?null:e}),children:[(0,t.jsx)(w.P,{children:(0,t.jsx)(w.U,{placeholder:n.questionType.notSet||"Not set"})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:v.O,children:n.questionType.clear||"Clear"}),v.V.map(e=>(0,t.jsx)(w.T,{value:e,children:n.questionType.names?.[e]||e},e))]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{htmlFor:"correction-grade-semester",children:n.editor.gradeSemester||"Grade/Semester"}),(0,t.jsx)(g.f,{id:"correction-grade-semester",value:e.gradeSemester||"",onChange:e=>r({gradeSemester:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:n.editor.paperLevel||"Paper Level"}),(0,t.jsx)(x.f,{value:s,onChange:e=>r({paperLevel:e})})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:n.difficulty.label}),(0,t.jsx)("div",{children:(0,t.jsx)(h.f,{size:"md",value:e.difficultyStars,onChange:e=>r({difficultyStars:e})})})]})]})}var b=e.i(141176),k=e.i(515288);function S({data:e,onChange:s}){let{t:r}=(0,u.b)();return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(k.v,{children:r.editor.mistakeAnalysisTitle||"Mistake Analysis"})}),(0,t.jsxs)(k.O,{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:r.editor.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(w.d,{value:e.mistakeStatus||"unknown",onValueChange:e=>s({mistakeStatus:e}),children:[(0,t.jsx)(w.P,{children:(0,t.jsx)(w.U,{})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:"not_attempted",children:r.editor.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(w.T,{value:"wrong_attempt",children:r.editor.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(w.T,{value:"unknown",children:r.editor.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:r.editor.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(b.f,{value:e.wrongAnswerText||"",onChange:t=>s({wrongAnswerText:t,mistakeStatus:t.trim()?"wrong_attempt":e.mistakeStatus}),className:"min-h-[100px] font-mono text-sm",placeholder:r.editor.wrongAnswerPlaceholder||"Leave blank if no wrong answer is visible"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:r.editor.mistakeAnalysis||"Mistake Cause Analysis"}),(0,t.jsx)(b.f,{value:e.mistakeAnalysis||"",onChange:e=>s({mistakeAnalysis:e}),className:"min-h-[140px] font-mono text-sm",placeholder:r.editor.mistakeAnalysisPlaceholder||"Explain where and why the mistake happened"})]})]})]})}var N=e.i(511445),T=e.i(149704);function A({title:e,children:s,className:r}){return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(k.v,{children:e})}),(0,t.jsx)(k.O,{className:r,children:s})]})}function I({data:e,children:s}){let{t:r}=(0,u.b)(),n={wrong_attempt:r.editor.mistakeStatuses?.wrongAttempt||"Wrong attempt",not_attempted:r.editor.mistakeStatuses?.notAttempted||"Not attempted",unknown:r.editor.mistakeStatuses?.unknown||"Unknown"};return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(A,{title:r.editor.preview?.question||"Question Preview",children:[(0,t.jsx)(N.f,{content:e.questionText}),(0,t.jsx)(T.f,{svg:e.figureSvg})]}),s,(0,t.jsx)(A,{title:r.editor.preview?.answer||"Answer Preview",children:(0,t.jsx)(N.f,{content:e.answerText})}),(0,t.jsx)(A,{title:r.editor.preview?.analysis||"Analysis Preview",children:(0,t.jsx)(N.f,{content:e.analysis})}),(0,t.jsxs)(A,{title:r.editor.preview?.mistakeAnalysis||"Mistake Analysis Preview",className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"text-muted-foreground",children:[r.editor.mistakeStatus||"Attempt Status",r.common.colon,n[e.mistakeStatus]??n.unknown]}),e.wrongAnswerText&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium mb-1",children:r.editor.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(N.f,{content:e.wrongAnswerText})]}),e.mistakeAnalysis&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium mb-1",children:r.editor.mistakeAnalysis||"Mistake Cause Analysis"}),(0,t.jsx)(N.f,{content:e.mistakeAnalysis})]})]})]})}var E=e.i(574041),$=e.i(215519),_=e.i(306831);e.i(676167);var C=e.i(597138),M=e.i(991722),R=e.i(470279),q=e.i(303163);e.s(["f",0,function({initialData:e,onSave:i,onCancel:l,imagePreview:h,initialSubjectId:g,aiTimeout:p}){let{timeZone:x}=(0,$.M)(),{t:w,language:v}=(0,u.b)(),N=e=>e.trim()?e:"",[T,A]=(0,s.useState)({...e,answerText:N(e.answerText),analysis:N(e.analysis),wrongAnswerText:e.wrongAnswerText||"",mistakeAnalysis:e.mistakeAnalysis||"",mistakeStatus:e.mistakeStatus||"unknown",subjectId:g,gradeSemester:e.gradeSemester||""}),O=(0,s.useRef)(!1),P=e=>{"gradeSemester"in e&&(O.current=!0),A(t=>({...t,...e}))},{groups:U}=(0,R.f)(),V=(()=>{if(T.paperLevel)return T.paperLevel;let e="number"==typeof T.difficultyStars&&T.difficultyStars>=4?"b":"a";return U.find(t=>t.key===e&&t.isActive)?.id||""})(),L=T.paperLevel??V,[F,z]=(0,s.useState)(!1),[H,G]=(0,s.useState)(!1),[D,Q]=(0,s.useState)(!1),[W,B]=(0,s.useState)(void 0),[J,Z]=(0,s.useState)([]);(0,s.useEffect)(()=>{d.k.get("/api/notebooks").then(Z).catch(e=>m.V.error("[CorrectionEditor]","Failed to fetch notebooks",{error:e})),d.k.get("/api/user").then(e=>{if(Q(!!e?.enableGeogebra),e){let t=function(e,t=_.J){return"ai"===e.gradeRecognitionMode?null:e.fixedGradeSemester?e.fixedGradeSemester:e.educationStage&&e.enrollmentYear?function(e,t,s=new Date,r="en",n=_.J){let a=(0,_.c)(s,n),i=a.getFullYear(),l=a.getMonth()+1,o=i-t,u="2nd";l>=9?(o+=1,u="1st"):u=l<2?"1st":"2nd";let d="zh"===r,c=d?"1st"===u?"上期":"下期":"1st"===u?"1st Semester":"2nd Semester",m=(d?{primary:["一年级","二年级","三年级","四年级","五年级","六年级"],junior_high:["初一","初二","初三"],senior_high:["高一","高二","高三"],university:["大一","大二","大三","大四"]}:{primary:["Grade 1","Grade 2","Grade 3","Grade 4","Grade 5","Grade 6"],junior_high:["Junior High Grade 1","Junior High Grade 2","Junior High Grade 3"],senior_high:["Senior High Grade 1","Senior High Grade 2","Senior High Grade 3"],university:["Freshman","Sophomore","Junior","Senior"]})[e]||[],f=`${o}`;if(f=o>0&&o<=m.length?m[o-1]:o>m.length?d?"已毕业":"Graduated":d?"学前":"Pre-school",!d)return`${f}, ${c}`;{let e="1st"===u?"上":"下";return`${f}${e}`}}(e.educationStage,e.enrollmentYear,new Date,"zh",t):null}(e,x);A(e=>e.gradeSemester||O.current?e:{...e,gradeSemester:t||""}),B(e.educationStage||void 0)}}).catch(e=>m.V.error("[CorrectionEditor]","Failed to fetch user info for grade calculation",{error:e}))},[v,x]);let X=async()=>{if(!T.questionText.trim())return void c.c.warning(w.editor.enterQuestionFirst||"Please enter question text first");z(!0);try{let e=function({questionText:e,language:t,subject:s,imagePreview:r,gradeSemester:n,subjectId:a}){let i={questionText:e,language:t,subject:s};return r&&(i.imageBase64=r),n&&(i.gradeSemester=n),a&&(i.subjectId=a),i}({questionText:T.questionText,language:v,subject:T.subject,imagePreview:h,gradeSemester:T.gradeSemester??void 0,subjectId:T.subjectId});m.V.info("[Reanswer]",e.imageBase64?"Sending image + text (image available for mistake analysis)":"Sending text only (no image available)",{timeout:p});let t=await d.k.post("/api/reanswer",e,{timeout:p||18e4,recoverable:!0});A(e=>({...e,answerText:t.answerText,analysis:t.analysis,knowledgePoints:t.knowledgePoints,wrongAnswerText:t.wrongAnswerText||"",mistakeAnalysis:t.mistakeAnalysis||"",mistakeStatus:(0,M.x)(t.mistakeStatus,t.wrongAnswerText),difficultyStars:t.difficultyStars??e.difficultyStars,questionType:t.questionType??e.questionType})),c.c.success(w.editor.reanswerSuccess||"✅ Answer and analysis updated!")}catch(r){let e,t,s;m.V.error("[CorrectionEditor]","Reanswer failed",{error:r}),c.c.error((e=(0,q.d)(r)||"",s=(t=w.errors?.reanswer||{}).default||"Reanswer failed",e.includes("AI_AUTH_ERROR")?t.authError||w.errors?.AI_AUTH_ERROR||s:e.includes("AI_CONNECTION_FAILED")?t.connectionFailed||w.errors?.AI_CONNECTION_FAILED||s:e.includes("AI_RESPONSE_ERROR")&&(t.responseError||w.errors?.AI_RESPONSE_ERROR)||s))}finally{z(!1)}},Y=async()=>{if(!T.subjectId)return void c.c.warning(w.editor.messages?.selectNotebook||"Please select a notebook");if(!H){G(!0);try{await i({...T,paperLevel:L,mistakeStatus:(0,M.x)(T.mistakeStatus,T.wrongAnswerText)})}finally{G(!1)}}},K=w.editor.placeholder||"Supports Markdown and LaTeX...",ee=(0,C.f)(J.find(e=>e.id===T.subjectId)?.name||null)||(0,C.f)(T.subject||null)||void 0;return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold",children:w.editor.title}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(o.f,{variant:"outline",onClick:l,children:w.editor.cancel}),(0,t.jsxs)(o.f,{onClick:Y,disabled:H,children:[H?(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(a.f,{className:"mr-2 h-4 w-4"}),H?w.common?.pleaseWait||"Please wait...":w.editor.save]})]})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[h&&(0,t.jsx)(k.N,{children:(0,t.jsx)(k.O,{className:"p-4",children:(0,t.jsx)("img",{src:h,alt:"Original",className:"w-full rounded-md"})})}),(0,t.jsx)(j,{data:T,paperLevel:L,onChange:P}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:w.editor.question}),(0,t.jsx)(b.f,{value:T.questionText,onChange:e=>P({questionText:e}),className:"min-h-[150px] font-mono text-sm",placeholder:K}),(0,t.jsx)(o.f,{variant:"default",size:"sm",onClick:X,disabled:F||!T.questionText.trim(),className:"w-full bg-gradient-to-r from-indigo-600 to-violet-500 hover:from-indigo-700 hover:to-violet-600 text-white font-medium",children:F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.f,{className:"mr-2 h-4 w-4 animate-spin"}),w.editor.reanswering||"AI solving..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.f,{className:"mr-2 h-4 w-4"}),w.editor.reanswer||"🔄 Reanswer (based on corrected question)"]})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:w.editor.reanswerHint||"💡 If the question was misrecognized, correct it and click to regenerate answer"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:w.editor.tags}),(0,t.jsx)(E.f,{value:T.knowledgePoints,onChange:e=>P({knowledgePoints:e}),placeholder:w.editor.tagsPlaceholder||"Enter knowledge tags...",enterHint:w.editor.createTagHint,subject:ee,gradeStage:W}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:w.editor.tagsHint||"💡 Tag suggestions will appear as you type"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:w.editor.answer}),(0,t.jsx)(b.f,{value:T.answerText,onChange:e=>P({answerText:e}),className:"min-h-[100px] font-mono text-sm",placeholder:K})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(y.f,{children:w.editor.analysis}),(0,t.jsx)(b.f,{value:T.analysis,onChange:e=>P({analysis:e}),className:"min-h-[200px] font-mono text-sm",placeholder:K})]}),(0,t.jsx)(S,{data:T,onChange:P})]}),(0,t.jsx)(I,{data:T,children:D&&(0,t.jsx)(f,{data:T,onChange:P})})]})]})}],866531);var O=e.i(853138),P=e.i(263676);e.s(["f",0,function({message:e,onDismiss:s}){let{t:r}=(0,u.b)();return e?(0,t.jsxs)("div",{role:"alert",className:"flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[(0,t.jsx)(O.f,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0"}),(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:e}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":r.common.close,className:"shrink-0 rounded p-1 hover:bg-destructive/10",children:(0,t.jsx)(P.X,{"aria-hidden":"true",className:"h-4 w-4"})})]}):null}],497346);var U=e.i(618566),V=e.i(707212);function L(e){return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}function F(e,t){if("string"!=typeof e||!/^(QUESTION_SAVE_|AI_)[A-Z_]+$/.test(e))return;let s=t.errors[e];return"string"==typeof s?s:void 0}e.s(["f",0,function(e){let{t}=(0,u.b)(),r=(0,U.useRouter)(),[n,a]=(0,s.useState)(null),i=async(s,n,i=!0)=>{a(null);try{let e=await s();return c.c.success(e.duplicate?t.importFlow.duplicate:t.common.messages.saveSuccess),i&&(e.duplicate?r.push(`/error-items/${e.id}`):n&&r.push(`/notebooks/${n}`)),!0}catch(r){m.V.error(e,"Save failed",{errorMessage:(0,q.d)(r)??(0,q.Z)(r)});let s=function(e,t){let s=L(e),r=L(s?.data),n="number"==typeof s?.status?s.status:void 0,a=(0,q.d)(e),i=F(a,t)??F(r?.code,t),l={400:t.errors.QUESTION_SAVE_INVALID_INPUT,401:t.errors.QUESTION_SAVE_UNAUTHORIZED,403:t.errors.QUESTION_SAVE_FORBIDDEN,408:t.errors.QUESTION_SAVE_TIMEOUT,409:t.errors.QUESTION_SAVE_CONFLICT,413:t.errors.QUESTION_SAVE_TOO_LARGE,429:t.errors.QUESTION_SAVE_RATE_LIMITED,502:t.errors.QUESTION_SAVE_SERVER_UNAVAILABLE,503:t.errors.QUESTION_SAVE_SERVER_UNAVAILABLE,504:t.errors.QUESTION_SAVE_TIMEOUT},o=i??(n?l[n]:void 0)??t.errors.QUESTION_SAVE_FAILED;!n&&(e instanceof TypeError||/fetch|network|load failed/i.test((0,q.Z)(e)))&&(o=t.errors.QUESTION_SAVE_NETWORK_ERROR);let u=L(r?.details);if("QUESTION_SAVE_GRADE_FAILED"===a){let e=F(u?.reason,t);e&&(o+=`
7
- ${e}`)}return 400===n&&(o+=(function(e,t){if(!Array.isArray(e))return[];let s={questionText:t.editor.question,answerText:t.editor.answer,analysis:t.editor.analysis,wrongAnswerText:t.editor.wrongAnswerText,mistakeAnalysis:t.editor.mistakeAnalysis,knowledgePoints:t.editor.tags,subjectId:t.editor.selectNotebook,gradeSemester:t.editor.gradeSemester,paperLevel:t.editor.paperLevel};return e.slice(0,3).flatMap(e=>{let r=L(e),n=r?.path,a=Array.isArray(n)&&"string"==typeof n[0]?s[n[0]]:void 0;if(!a)return[];let i=r?.maximum,l=t.questionSave.invalidField;return r?.code==="too_big"&&"number"==typeof i&&Number.isSafeInteger(i)&&i>=0&&(l="array"===r.origin?t.questionSave.tooMany:t.questionSave.tooLong),[l.replace("{field}",a).replace("{maximum}",String(i))]})})(r?.details,t).map(e=>`
8
- ${e}`).join("")),"string"==typeof u?.databaseCode&&/^P\d{4}$/.test(u.databaseCode)&&(o+=`
9
- ${t.questionSave.databaseCode.replace("{code}",u.databaseCode)}`),n&&(o+=` (HTTP ${n})`),o}(r,t);return a(s),(0,V.t)((0,q.d)(r))||c.c.error(s),!1}};return{saveError:n,setSaveError:a,dismissSaveError:()=>a(null),run:i}}],183444)},731335,532377,339501,e=>{var t=e.i(843476),s=e.i(399847),r=e.i(551757),n=e.i(456420);let a={name:"clock-3",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]};a.node;let i=(0,n.f)(a);var l=e.i(632781),o=e.i(615568),u=e.i(487486),d=e.i(519455),c=e.i(168148),m=e.i(111110),f=e.i(215519),h=e.i(306831);let g=["read","convert","crop","compress","upload"],p=["receive","analyze","save"];function x(e){if(!Number.isFinite(e)||e<0)return"-";if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(+(t<10))}s`;let s=Math.round(t);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`}var y=e.i(975157);let w={analyzing:50,saving:90},v={analyzing:l.f,saving:l.f,review:o.f,saved:r.f,failed:s.f};e.s(["f",0,function({task:e,now:s,onReview:r,onViewItem:n,onRetry:a,onDiscard:l}){let{t:o}=(0,m.b)(),{timeZone:j}=(0,f.M)(),b=v[e.status],k="analyzing"===e.status||"saving"===e.status,S=o.errors,N=e.error?"string"==typeof S[e.error]?S[e.error]:e.error:null,T=function(e){let t=[];for(let s of g){let r=e?.client?.[s];"number"==typeof r&&t.push({stage:s,ms:r})}for(let s of p){let r=e?.server?.[s];"number"==typeof r&&t.push({stage:s,ms:r})}return t}(e.timings),A=k&&s?s-Date.parse(e.createdAt):null;return(0,t.jsxs)("div",{className:(0,y.f)("space-y-2 rounded-lg border p-3 text-sm",e.unread&&"border-primary/50 bg-primary/5"),"data-testid":"import-task-card","data-status":e.status,children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(b,{className:(0,y.f)("mt-0.5 h-4 w-4 shrink-0",k&&"animate-spin text-primary","saved"===e.status&&"text-green-600","failed"===e.status&&"text-destructive","review"===e.status&&"text-primary")}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:o.importTasks.status[e.status]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:o.importTasks.mode[e.mode]}),e.unread&&(0,t.jsx)(u.f,{children:o.importTasks.unread})]}),k&&(0,t.jsx)(c.f,{value:w[e.status],"aria-label":o.importTasks.stageEstimate,"aria-valuetext":o.common.progress.estimated.replace("{percent}",String(w[e.status])),className:"h-1.5"}),e.excerpt&&(0,t.jsx)("p",{className:"break-words text-muted-foreground",children:e.excerpt}),"saved"===e.status&&!e.errorItemId&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o.importTasks.itemDeleted}),"saved"===e.status&&e.errorItemId&&(0,t.jsx)("p",{className:"text-xs text-green-700 dark:text-green-300",children:e.duplicate?o.importTasks.duplicateSaved:o.importTasks.savedTo.replace("{notebook}",e.notebookName||"-").replace("{id}",e.errorItemShortId||"-")}),N&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:N}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(i,{className:"h-3 w-3"}),o.importTasks.createdAt.replace("{time}",(0,h.r)(e.createdAt,"MM-dd HH:mm",j))]}),null!==A&&(0,t.jsx)("span",{children:o.importTasks.elapsed.replace("{time}",x(A))}),e.attempts>1&&(0,t.jsx)("span",{children:o.importTasks.attempts.replace("{count}",String(e.attempts))})]}),T.length>0&&(0,t.jsx)("ul",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground tabular-nums","aria-label":"timings",children:T.map(({stage:e,ms:s})=>(0,t.jsxs)("li",{children:[o.importTasks.timings[e]," ",x(s)]},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:["review"===e.status&&r&&(0,t.jsx)(d.f,{size:"sm",onClick:r,children:o.importTasks.continueReview}),"saved"===e.status&&e.errorItemId&&n&&(0,t.jsx)(d.f,{size:"sm",variant:"outline",onClick:n,children:o.importTasks.viewItem}),"failed"===e.status&&a&&(0,t.jsx)(d.f,{size:"sm",onClick:a,children:o.importTasks.retry}),"saving"!==e.status&&"saved"!==e.status&&l&&(0,t.jsx)(d.f,{size:"sm",variant:"ghost",onClick:l,children:o.importTasks.discard})]})]})}],731335);var j=e.i(618566),b=e.i(767077),k=e.i(294114),S=e.i(201276),N=e.i(127175);e.s(["f",0,function(e){let{t}=(0,m.b)(),s=(0,j.useRouter)(),r=e=>{e.unread&&(0,N.N)(e.id).catch(e=>S.V.warn("[ImportTasks]","Mark read failed",{error:e}))};return{openReview:e=>{r(e),s.push(`/import-tasks/${e.id}`)},viewItem:e=>{e.errorItemId&&(r(e),s.push(`/error-items/${e.errorItemId}`))},markRead:r,retry:async s=>{try{await (0,N.R)(s.id),k.c.info(t.importTasks.retried)}catch(e){k.c.error((0,b.f)(e,t))}e?.()},discard:async s=>{if(!await (0,k.u)(t.importTasks.discardConfirm))return!1;let r=!1;try{await (0,N.x)(s.id),k.c.success(t.importTasks.discarded),r=!0}catch(e){k.c.error((0,b.f)(e,t))}return e?.(),r}}}],532377);var T=e.i(271645);e.s(["f",0,function(e,t=1e3){let[s,r]=(0,T.useState)(()=>Date.now());return(0,T.useEffect)(()=>{if(!e)return;let s=setInterval(()=>r(Date.now()),t);return()=>clearInterval(s)},[e,t]),s}],339501)},499930,e=>{var t=e.i(213761);function s(e,t=.008){let r=Math.max(0,e.x-t),n=Math.max(0,e.y-t);return{x:r,y:n,width:Math.min(1,e.x+e.width+t)-r,height:Math.min(1,e.y+e.height+t)-n}}async function r(e){let t=new Image;if(t.decoding="async",t.src=e,await t.decode(),!t.naturalWidth||!t.naturalHeight)throw Error("IMAGE_EMPTY");return t}async function n(e,s){let r=function(e,t=16,s=!1){let r=Math.max(...e.map(e=>e.width)),n=0,a=e.map(e=>{let a=s?r/e.width:e.scale??1,i={x:0,y:n,width:Math.round(e.width*a),height:Math.round(e.height*a)};return n+=i.height+t,i});return{width:Math.max(...a.map(e=>e.width)),height:n-t,rects:a}}(e.map(e=>({width:e.sw,height:e.sh,scale:e.scale})),16,s),n=document.createElement("canvas");n.width=r.width,n.height=r.height;let a=n.getContext("2d");if(!a)throw Error("CANVAS_UNSUPPORTED");a.fillStyle="#ffffff",a.fillRect(0,0,n.width,n.height),e.forEach((e,t)=>{let s=r.rects[t];a.drawImage(e.source,e.sx,e.sy,e.sw,e.sh,s.x,s.y,s.width,s.height)});let i=await createImageBitmap(n);try{return await (0,t.X)({source:i,width:n.width,height:n.height})}finally{i.close()}}async function a(e,r){let a=e.naturalWidth,i=e.naturalHeight,l=r.map(e=>s(e));return 1===l.length?(0,t.X)({source:e,width:a,height:i},l[0]):n(l.map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*i),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*i))})),!1)}async function i(e){return n((await Promise.all(e.map(r))).map(e=>({source:e,sx:0,sy:0,sw:e.naturalWidth,sh:e.naturalHeight})),!0)}async function l(e,t,r){let a=e.naturalWidth,i=e.naturalHeight,l=r.width/a,o=t.map(e=>s(e)).map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*i),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*i)),scale:l}));return o.push({source:r.source,sx:0,sy:0,sw:r.width,sh:r.height}),n(o,!1)}e.s(["y",0,r,"k",0,l,"M",0,a,"v",0,i])},119472,e=>{var t=e.i(41931),s=e.i(127175);async function r(e){let t;for(let s=0;s<3;s++)try{return await e()}catch(e){if(t=e,!function(e){let t=e?.status;return void 0===t||408===t||502===t||503===t||504===t}(e)||2===s)break;await new Promise(e=>setTimeout(e,1e3*(s+1)))}throw t}async function n(e,a=(0,s.c)()){let{batch:i}=await r(()=>t.k.post("/api/import-batches",{...e,clientRequestId:a,subjectId:e.subjectId||void 0,targetSubjectId:e.targetSubjectId||void 0,paperLevel:e.paperLevel||void 0,items:e.items?.map(e=>({...e})),origin:e.origin},{timeout:12e4}));return(0,s.P)(),i}async function a(e,s={}){let r=s.image?"?include=image":"",{batch:n}=await t.k.get(`/api/import-batches/${encodeURIComponent(e)}${r}`);return n}async function i(e,s,r){let{batch:n}=await t.k.patch(`/api/import-batches/${encodeURIComponent(e)}`,{version:s,draft:r});return n}async function l(e,n,a,i){let{batch:l}=await r(()=>t.k.post(`/api/import-batches/${encodeURIComponent(e)}/start`,{version:n,images:a,analysis:i},{timeout:12e4}));return(0,s.P)(),l}async function o(e){let{batch:r}=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/retry`,{});return(0,s.P)(),r}async function u(e){let r=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/confirm-all`,{});return(0,s.P)(),r}async function d(e){await t.k.delete(`/api/import-batches/${encodeURIComponent(e)}`),(0,s.P)()}async function c(e){await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/read`,{}),(0,s.P)()}async function m(e,s,r){return t.k.post(`/api/import-batches/${encodeURIComponent(e)}/fix-text`,{items:s},{timeout:6e5,recoverable:!0,requestId:r})}e.s(["J",0,u,"n",0,function(e){return e?.status===409?e.data?.details?.batch??null:null},"v",0,n,"o",0,d,"w",0,a,"$",0,m,"f",0,c,"s",0,o,"S",0,i,"g",0,l])},25197,e=>{var t=e.i(41931);function s(e){return e.trim()?e:""}async function r(){try{return!!(await t.k.get("/api/user")).confirmBeforeImport}catch{return!1}}async function n(e,r){let n=await t.k.post("/api/error-items",{questionText:e.questionText,answerText:s(e.answerText),analysis:s(e.analysis),wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",knowledgePoints:e.knowledgePoints||[],difficultyStars:e.difficultyStars??null,recognizedGradeSemester:e.gradeSemester??null,hasFigure:e.hasFigure??!1,figureSvg:e.figureSvg??null,questionType:e.questionType??null,subjectId:r.subjectId||void 0,subjectName:r.subjectId?void 0:e.subject,originalImageUrl:r.imageUrl||"",paperLevel:r.paperLevel||void 0});return{id:n.id,shortId:n.shortId??null,subjectId:n.subjectId??null,notebookName:n.subject?.name??null,duplicate:n.duplicate}}e.i(201276),e.s(["x",0,r,"a",0,n],25197)},35209,e=>{var t=e.i(271645),s=e.i(111110);e.s(["f",0,function(...e){let{t:r}=(0,s.b)(),n=[r.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=n},[n])}])},825624,e=>{let t=/^[\s  ]+/,s="一二三四五六七八九十",r=[{family:"dot",pattern:/^(\d{1,3})\s*(?:.|\.(?!\d))\s*/},{family:"comma",pattern:/^(\d{1,3})\s*[、,,](?!\d)\s*/},{family:"paren",pattern:/^(\d{1,3})\s*[))]\s*/},{family:"colon",pattern:/^(\d{1,3})\s*[::](?!\d)\s*/},{family:"ti",pattern:/^第\s*(\d{1,3}|[一二三四五六七八九十]{1,3})\s*题\s*[..、::]?\s*/},{family:"example",pattern:/^(?:例题?|练习|习题)\s*(\d{1,3})\s*[..、::]?\s*/},{family:"q",pattern:/^(?:Q|Question|Problem|Exercise)\s*(\d{1,3})\s*[..::)]?\s+/i},{family:"cn",pattern:/^([一二三四五六七八九十]{1,3})\s*[、..]\s*/}];function n(e){let n=e.replace(t,"");for(let{family:e,pattern:t}of r){let r=n.match(t);if(!r||n.length<=r[0].length)continue;let a=function(e){if(/^\d+$/.test(e))return Number(e);if("十"===e)return 10;let t=e.indexOf("十");return -1===t?s.indexOf(e)+1:10*(0===t?1:s.indexOf(e[0])+1)+(t===e.length-1?0:s.indexOf(e[t+1])+1)}(r[1]);if(Number.isFinite(a)&&!(a<=0))return{value:a,family:e,prefixLength:r[0].length,label:r[1]}}return null}function a(e){let s=e.split("\n"),r=s[0]?.replace(t,"")??"",a=n(r);return a&&"cn"!==a.family&&(s[0]=r.slice(a.prefixLength)),s.join("\n")}function i(e){let t=[];for(let s of e)(s||0!==t.length&&""!==t[t.length-1])&&t.push(s);for(;t.length>0&&""===t[t.length-1];)t.pop();return t.join("\n")}let l=/(姓名|班级|学号|日期|得分|分数|评分|考号|座位号|家长签字|用时|Name\s*[::_]|Class\s*[::_]|Date\s*[::_]|Score\s*[::_])|_{3,}|共\s*\d+\s*(道|题|小题)|做完|答案(见|在)|最后一页|满分\s*\d+\s*分/i,o=/(阅读|材料|短文|文章|选文|诗歌|古诗|文言文|下[面列]的?(表格|图表|统计|信息)|根据.{0,20}(回答|完成)|passage|read the|according to the)/i,u=/^(参考答案|答案与解析|答案|Answers?|Answer Key)\s*[::]?$/i,d=/^(第[一二三四五六七八九十]+(部分|大题|节)|(Part|Section)\s+[A-Z0-9IVX]+\b)/i,c=/(选择|填空|判断|计算|解答|应用|解决问题|操作|作图|阅读|写作|作文|综合|口算|听力|单项|完形|题)/,m=/(\d{1,3})\s*[~~\-—–至到]\s*(\d{1,3})\s*(?:小?题|questions?)/i,f=/(小问|小题|下列问题|以下问题|下列各题|下面各题|完成下列|回答下列|回答以下|following questions|answer the following)/i;function h(e){let t=[],s=[];for(let r of e)r?s.push(r):s.length&&(t.push(s.join("\n")),s=[]);return s.length&&t.push(s.join("\n")),t}function g(e,t=[]){let s=e.trim();return!(!s||s.length>12||/[。!?!?,,、;;::..()()【】\[\]{}]$/.test(s)||/\d/.test(s)||/[。!?!?;;,,]/.test(s))&&!!(/(篇|章|节|部分|组)$/.test(s)||/^(Part|Section)\s+[A-Z0-9]+$/i.test(s))&&(!t.length||t.some(e=>{let t=n(e);return null!==t&&1===t.value}))}function p(e,t){let s=[];for(let r=0;r<e.length;r++){let n=e[r],a=[n];for(let s=r+1;s<e.length;s++){let r=e[s],i=a[a.length-1];if(r.family!==n.family)continue;let l=1===r.value&&[...t].some(e=>e>i.line&&e<r.line);(r.value===i.value+1||l)&&a.push(r)}a.length>s.length&&(s=a)}return s}function x(e,t,s){return!!d.test(e)||!!t&&"cn"===t.family&&"cn"!==s&&null!==s&&(e.length<=40||c.test(e.slice(0,20)))}function y(e,t,s,r,n){for(let a=e-1;a>=0;a--)if(t[a]){if(n.has(a)||x(t[a],s[a],r)||g(t[a]))return t[a];break}return null}function w(e){let t=e.match(m);if(!t)return null;let s=Number(t[1]),r=Number(t[2]);return s<=r?{from:s,to:r}:null}let v={answer:/^(?:【\s*(?:参考答案|答案)\s*】|(?:参考答案|答案)\s*[::]|Answer\s*[::])\s*(.*)$/i,analysis:/^(?:【\s*(?:解析|分析|详解|解答|点评)\s*】|(?:解析|分析|详解|解答|点评)\s*[::])\s*(.*)$/,knowledge:/^(?:【\s*(?:知识点|考点)\s*】|(?:知识点|考点)\s*[::])\s*(.*)$/,difficulty:/^(?:【\s*难度\s*】|难度\s*[::])\s*(.*)$/,questionType:/^(?:【\s*题型\s*】|题型\s*[::])\s*(.*)$/,wrongAnswer:/^(?:【\s*错答\s*】|我的答案\s*[::]|学生答案\s*[::])\s*(.*)$/},j={易:1,较易:2,中等:3,较难:4,难:5};function b(e){return e.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean)}function k(e){let t={answer:[],analysis:[],knowledge:[],difficulty:[],questionType:[],wrongAnswer:[]},s=[],r=null;for(let n of e){let e=null;for(let s of Object.keys(v)){let a=n.match(v[s]);if(!a)continue;e=s,r=s;let i=a[1].trim();i&&t[s].push(i);break}e||(r&&n.trim()?t[r].push(n.trim()):s.push(n))}let n={},a=t.answer.join("\n").trim();a&&(n.answer=a);let l=t.analysis.join("\n").trim();l&&(n.analysis=l);let o=t.knowledge.flatMap(b);o.length&&(n.knowledgePoints=o);let u=t.difficulty.join(" ").trim(),d=u?function(e){let t=e.trim();if(!t)return null;let s=t.match(/^(\d{1,2})\s*(?:星|级)?$/);if(s){let e=Number(s[1]);return e>=1&&e<=5?e:null}if(/^[★☆]{1,5}$/.test(t)){let e=(t.match(/★/g)??[]).length;return e>=1?e:null}return t in j?j[t]:null}(u):null;null!==d&&(n.difficultyStars=d);let c=t.questionType.join(" ").trim();c&&(n.questionType=c);let m=t.wrongAnswer.join("\n").trim();return m&&(n.wrongAnswer=m),{text:i(s),fields:n}}let S=/^(\d{1,3})\s*[..、,,)]\s*(\S[\s\S]*)$/,N=/^(\d{1,3})\s*[~~—–-]\s*(\d{1,3})\s*[::..、]?\s*([A-Za-z]+)$/;function T(e){let t=e.trim();if(!t)return null;let s=function(e){let t=e.trim().match(N);if(!t)return null;let s=Number(t[1]),r=Number(t[2]),n=t[3];if(!Number.isFinite(s)||!Number.isFinite(r)||s<=0||r<=s||r-s+1>60)return null;let a=r-s+1;return n.length!==a?null:Array.from({length:a},(e,t)=>({label:String(s+t),text:n[t]}))}(t);if(s)return s;let r=function(e){let t=e.trim(),s=[];for(let e of t.matchAll(/(\d{1,3})\s*[..、,,;;]\s*/g)){let r=e.index??0,n=t[r+e[0].length];n&&/\d/.test(n)||s.push({index:r,label:e[1],afterIndex:r+e[0].length})}if(s.length<2)return null;for(let e=1;e<s.length;e++)if(Number(s[e].label)<=Number(s[e-1].label))return null;let r=[];for(let e=0;e<s.length;e++){let n=s[e].afterIndex,a=e+1<s.length?s[e+1].index:t.length,i=t.slice(n,a).trim().replace(/[;;]+$/,"").trim();if(!i||i.length>30||/[。!?!?]/.test(i))return null;r.push({label:s[e].label,text:i})}return r}(t);if(r)return r.map(e=>({label:e.label??"",text:e.text})).filter(e=>e.label);let n=t.match(S);if(!n)return null;let a=Number(n[1]);return!Number.isFinite(a)||a<=0?null:[{label:n[1],text:n[2].trim()}]}function A(e){let t=e.match(/^(.*?)(?:【?\s*(?:解析|分析|详解|解答|点评)\s*】?\s*[::])([\s\S]*)$/);if(t){let s=t[1].replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim(),r=t[2].trim();return r?{answer:s,analysis:r}:{answer:e.trim()}}return{answer:e.replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim()||e.trim()}}function I(e,t){let s=[],r=!1;for(let n of e){let e={value:!1},a=[];for(let s of n.split("\n")){let r=s.trim()?T(s):null;if(!r){s.trim()&&a.push(s);continue}let n=!1;for(let i of r){let r=t.find(e=>e.label===i.label);if(!r){a.push(s);break}n=!0,e.value=!0;let l=A(i.text);l.answer&&!r.answer&&(r.answer=l.answer),l.analysis&&(r.analysis=r.analysis?`${r.analysis}
10
- ${l.analysis}`:l.analysis)}!n&&!a.includes(s)&&s.trim()&&!a.includes(s)&&a.push(s)}r=r||e.value,e.value?a.length&&s.push(a.join("\n")):s.push(n)}return[s,r]}e.s(["k",0,2e3,"f",0,1e6,"S",0,60,"i",0,2e4,"J",0,function(e,s={}){let r,c,v=void 0===s.maxLength?2e4:Math.min(Math.max(s.maxLength,1e3),1e6),j=void 0===s.maxQuestions?60:Math.min(Math.max(s.maxQuestions,2),2e3),b=e.length>v,S=e.slice(0,v).replace(/\r\n?/g,"\n").split("\n").map(e=>e.replace(t,"").replace(/[\s ]+$/,"")),N=S.map(e=>e?n(e):null),E=S.length;for(let e=0;e<S.length;e++)if(u.test(S[e])){E=e;break}let $=[],_=[];for(let e=0;e<E;e++){let t=N[e];t&&("cn"===t.family?_:$).push({...t,line:e})}let C=new Set;for(let e=0;e<E;e++)(d.test(S[e])||N[e]?.family==="cn"||g(S[e],S.slice(e+1,e+5)))&&C.add(e);let M=[],R=p($,C);if(R.length<2){let e=p(_,new Set);e.length>=2&&(M=[{chain:e,sectionHeading:null}])}else M=function(e,t,s,r){if(e.length<2)return[];let n=e[0].family,a=[0];for(let t=1;t<e.length;t++)1===e[t].value&&a.push(t);if(a.length<2){let a=y(e[0].line,t,s,n,r);return null!==a?[{chain:e,sectionHeading:a}]:[]}let i=[];for(let l=0;l<a.length;l++){let o=a[l],u=l+1<a.length?a[l+1]:e.length,d=e.slice(o,u),c=0===l?y(e[0].line,t,s,n,r):function(e,t,s,r,n,a){for(let i=e+1;i<t;i++)if(s[i]&&(a.has(i)||x(s[i],r[i],n)||g(s[i])))return s[i];return null}(e[o-1].line,e[o].line,t,s,n,r);if(null===c&&l>0){i[i.length-1].chain.push(...d);continue}i.push({chain:d,sectionHeading:c})}return i.filter(e=>e.chain.length>0)}(R,S,N,C);let q=M.length?M.flatMap(e=>e.chain):R,O=i(S.slice(0,E)),P=E<S.length?h(S.slice(E)):[],U=(c=n(S[q[0]?.line??0]??""))?c.label:null,V=e=>({questions:O?[{label:U,text:O,material:null,section:null,lineRange:{from:0,to:E}}]:[],ignored:P,detected:!1,ambiguous:e,candidateCount:e?q.length:+!!O,overflow:0,tooLong:b});if(q.length<2){if(!O)return V(!1);let e=k(O.split("\n")),t=V(!1);if(t.questions.length>0&&Object.keys(e.fields).length>0&&(t.questions[0]={...t.questions[0],text:a(e.text),...e.fields}),t.questions.length>0&&P.length){let[e,s]=I(P,t.questions);t.ignored=e,s||(t.ignored=P)}return t}let L=q[0].family;if(!s.forceNumbered&&function(e,t,s,r){let n=null;for(let a=t-1;a>=0;a--)if(e[a]){n=x(e[a],r[a],s)?null:e[a];break}return!(!n||l.test(n)||m.test(n))&&("paren"===s?n.length>=15||/[。?!?!::,,;;]$/.test(n):/[::]$/.test(n)&&f.test(n))}(S,q[0].line,L,N)){let e=V(!0);if(e.questions.length>0&&O){let t=k(O.split("\n"));Object.keys(t.fields).length>0&&(e.questions[0]={...e.questions[0],text:a(t.text),...t.fields})}return e}let F=new Set(q.map(e=>e.line)),z=[],H=[],G=null,D=[],Q=[],W=(e,t)=>{for(let s of h(e))(!l.test(s)||!(s.length<80))&&(o.test(s)||s.length>=80&&/[。!?.!?;;]/.test(s))?D.push({text:s,range:w(s)}):t?z.push(s):G&&!H.some(e=>e.section===G)?G=`${G}
11
- ${s}`:z.push(s)},B=q[0].line,J=[];for(let e=0;e<B;e++)S[e]&&(x(S[e],N[e],L)||g(S[e],S.slice(e+1,e+5)))?(W(J.splice(0),!0),G=S[e],Q=[]):J.push(S[e]);W(J,!0);let Z=M.length>1,X=e=>{if(!Z)return -1;let t=0;for(let s=0;s<M.length;s++)if(e<(t+=M[s].chain.length))return s;return M.length-1};for(let e=0;e<q.length;e++){let t=q[e].line,s=e+1<q.length?q[e+1].line:E,r=X(e);if(Z&&r>=0){let e=M[r].sectionHeading;null!==e&&(G=e,Q=[])}D.length&&(Q=[...Q.filter(e=>e.range),...D],D=[]);let n=s,l=null;for(let e=t+1;e<s;e++)if(S[e]&&!F.has(e)&&x(S[e],N[e],L)){n=e,l=S[e];break}let u=S.slice(t,n),d=h(u),c=[];for(;d.length>1&&o.test(d[d.length-1].slice(0,30));)c.unshift(d.pop());let m=c.length?d.join("\n"):i(u),f=q[e].value,g=Q.filter(e=>!e.range||f>=e.range.from&&f<=e.range.to),p=k(a(m).split("\n"));for(let r of(H.push({label:q[e].label,text:p.text,material:g.length?g.map(e=>e.text).join("\n\n"):null,section:G,lineRange:{from:t,to:s},...p.fields}),c))D.push({text:r,range:w(r)});null!==l&&(G=l,Q=[],W(S.slice(n+1,s),!1))}if(Z&&P.length){let e=M.map(e=>e.sectionHeading).filter(e=>null!==e),t=P.join("\n");r=e.some(e=>t.includes(e))?function(e,t,s){let r=[],n=0,a=t.map(e=>{let t=s.slice(n,n+e.chain.length);return n+=e.chain.length,t}),i=-1;for(let n of e){let e=n.split("\n"),l=[],o=!1;for(let r of e){let e=r.trim();if(!e){l.push(r);continue}let n=t.findIndex(t=>t.sectionHeading&&e.includes(t.sectionHeading));if(n>=0){i=n;continue}let u=T(e);if(!u){l.push(r);continue}let d=i>=0?a[i]:s,c=!1;for(let e of u){let t=d.find(t=>t.label===e.label);if(!t){l.push(r);break}c=!0,o=!0;let s=A(e.text);s.answer&&!t.answer&&(t.answer=s.answer),s.analysis&&(t.analysis=t.analysis?`${t.analysis}
12
- ${s.analysis}`:s.analysis)}c||l.includes(r)||l.push(r)}o?l.length&&r.push(l.join("\n")):r.push(n)}return r}(P,M,H):P}else r=I(P,H)[0];let Y=H.slice(j);return{questions:H.slice(0,j),ignored:[...z,...r,...Y.map(e=>{var t;let s,r,n,a;return s=(t=e).text.trim(),n=(r=t.material?.trim())?`${r}
13
-
14
- ${s}`:s,a=[],(t.answer?.trim()&&a.push(`参考答案:${t.answer.trim()}`),t.analysis?.trim()&&a.push(`参考解析:${t.analysis.trim()}`),t.wrongAnswer?.trim()&&a.push(`学生作答:${t.wrongAnswer.trim()}`),a.length)?`${n}
15
-
16
- ${a.join("\n\n")}`:n})],detected:!0,ambiguous:!1,candidateCount:H.length,overflow:Y.length,tooLong:b}}])},767077,e=>{var t=e.i(303163);e.s(["f",0,function(e,s){let r=s.common?.messages?.analysisFailed||"Analysis failed, please try again",n=(0,t.d)(e);if(n){let e=s.errors??{};if(!(n in e))return n;let t=e[n];return"string"==typeof t?t:r}let a=(0,t.Z)(e);if(a.includes("fetch")||a.includes("network"))return s.errors?.AI_CONNECTION_FAILED||"网络连接失败";if("object"==typeof e&&null!==e&&"data"in e&&"string"==typeof e.data){let t="status"in e&&"number"==typeof e.status?e.status:"Error";return`${r} (${t})`}return r}])}])})();
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,[711241,e=>{var a=e.i(456420);let s={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};s.node;let t=(0,a.f)(s);e.s(["f",0,t],711241)},399847,e=>{var a=e.i(456420);let s={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};s.node;let t=(0,a.f)(s);e.s(["f",0,t],399847)},13285,e=>{var a=e.i(456420);let s={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};s.node;let t=(0,a.f)(s);e.s(["f",0,t],13285)},813572,e=>{var a=e.i(843476),s=e.i(271645),t=e.i(618566),i=e.i(518515),n=e.i(328623),l=e.i(747819),r=e.i(866531),o=e.i(12130),c=e.i(430634),d=e.i(576019),m=e.i(847483),p=e.i(497346),u=e.i(717448),f=e.i(798469),x=e.i(393842),h=e.i(956738),g=e.i(185592),j=e.i(111110),v=e.i(41931),k=e.i(201276),y=e.i(35209),b=e.i(598053),I=e.i(315092);e.s(["default",0,function(){let e=(0,t.useParams)(),N=(0,t.useRouter)(),S=e.id,{t:T}=(0,j.b)(),[w,P]=(0,s.useState)(null);(0,y.f)(T.notebooks.title,w?.name,T.pageTitle.addError);let[C,z]=(0,s.useState)("image"),A=(0,b.f)({logPrefix:"[AddErrorItem]",analyzeSubjectId:S,importSubjectId:S,textNotebook:{id:S,name:w?.name||""},fixedSubjectId:S});return((0,s.useEffect)(()=>{v.k.get(`/api/notebooks/${S}`).then(e=>P(e)).catch(e=>{k.V.error("[AddErrorItem]","Failed to fetch notebook",{error:e}),N.push("/notebooks")})},[S,N]),w)?(0,a.jsxs)("main",{className:"min-h-screen",children:[(0,a.jsx)(h.f,{status:A.analysisStep,completed:A.completedStages}),(0,a.jsxs)("div",{className:`mx-auto space-y-6 px-4 py-6 md:px-8 md:py-8 ${"review"===A.step?"max-w-6xl":"max-w-4xl"}`,children:[(0,a.jsx)(p.f,{message:A.saveError,onDismiss:A.dismissSaveError}),(0,a.jsx)(x.f,{backHref:`/notebooks/${S}`,title:T.app.addError,description:w.name}),"upload"===A.step&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(g.f,{options:[{value:"image",icon:i.f,label:T.app?.uploadImage||"Take Photo"},{value:"text",icon:n.f,label:T.app?.manualInput||"Manual Input"}],value:C,onChange:z}),A.pendingTask&&(0,a.jsx)(d.f,{task:A.pendingTask,onRefresh:A.refreshPendingTask,onDismiss:A.dismissPendingTask}),A.lastImported&&(0,a.jsx)(c.f,{imported:A.lastImported,onDismiss:A.dismissImported}),A.batchImages?(0,a.jsx)(l.f,{images:A.batchImages,subjectId:S,onClose:A.closeBatch}):"image"===C?(0,a.jsxs)(a.Fragment,{children:[A.parts.length>0&&(0,a.jsx)(m.f,{parts:A.parts.map(e=>e.dataUrl),busy:A.isBusy,onFinish:()=>void A.finishParts(),onDiscard:A.discardParts}),(0,a.jsx)(f.f,{onImageSelect:A.selectImage,isAnalyzing:A.isBusy})]}):(0,a.jsx)(u.f,{onSubmit:A.submitText,isAnalyzing:A.isBusy,defaultNotebookName:w.name,onCreateBatch:A.createTextBatch,creatingBatch:A.creatingBatch})]}),"review"===A.step&&A.parsedData&&(0,a.jsx)(r.f,{initialData:A.parsedData,imagePreview:A.currentImage,onSave:A.saveReviewed,onCancel:A.cancelReview,initialSubjectId:S,aiTimeout:A.aiTimeout})]}),(0,a.jsx)(o.f,{imageSrc:A.croppingImage||"",open:A.isCropperOpen,onClose:A.closeCropper,onRegionsSelected:A.cropRegions,allowMulti:0===A.parts.length,onAutoSplit:0===A.parts.length?A.autoSplitImage:void 0,onAddPart:A.parts.length<I.u-1?A.addPart:void 0,partCount:A.parts.length})]}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,a.jsx)("p",{className:"text-muted-foreground",children:T.common.loading})})}])},590546,e=>{var a=e.i(843476),s=e.i(618566),t=e.i(519455),i=e.i(711241);e.s(["f",0,function({fallbackUrl:e,className:n}){let l=(0,s.useRouter)();return(0,a.jsx)(t.f,{variant:"ghost",size:"icon",onClick:()=>{l.push(e)},className:n,children:(0,a.jsx)(i.f,{className:"h-5 w-5"})})}])},393842,e=>{var a=e.i(843476),s=e.i(590546),t=e.i(975157);e.s(["f",0,function({title:e,description:i,backHref:n,actions:l,titleAddon:r,className:o}){return(0,a.jsxs)("div",{className:(0,t.f)("flex items-start gap-3",o),children:[n&&(0,a.jsx)(s.f,{fallbackUrl:n,className:"-ml-2 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-bold tracking-tight sm:text-3xl",children:e}),r]}),i&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground sm:text-base",children:i})]}),l&&(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:l})]})}])},35209,e=>{var a=e.i(271645),s=e.i(111110);e.s(["f",0,function(...e){let{t}=(0,s.b)(),i=[t.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,a.useEffect)(()=>{document.title=i},[i])}])}],462684,e=>{e.v(a=>Promise.all(["static/chunks/2hh64gi4pmlk2.js"].map(a=>e.l(a))).then(()=>a(506175)))}]);